} element to specify the
+ * language, as in {@code }. Any class that
+ * starts with "lang-" followed by a file extension, specifies the file type.
+ * See the "lang-*.js" files in this directory for code that implements
+ * per-language file handlers.
+ *
+ * Change log:
+ * cbeust, 2006/08/22
+ *
+ * Java annotations (start with "@") are now captured as literals ("lit")
+ *
+ * @requires console
+ */
+
+// JSLint declarations
+/*global console, document, navigator, setTimeout, window, define */
+
+/**
+ * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
+ * UI events.
+ * If set to {@code false}, {@code prettyPrint()} is synchronous.
+ */
+window['PR_SHOULD_USE_CONTINUATION'] = true;
+
+/**
+ * Find all the {@code } and {@code } tags in the DOM with
+ * {@code class=prettyprint} and prettify them.
+ *
+ * @param {Function?} opt_whenDone if specified, called when the last entry
+ * has been finished.
+ */
+var prettyPrintOne;
+/**
+ * Pretty print a chunk of code.
+ *
+ * @param {string} sourceCodeHtml code as html
+ * @return {string} code as html, but prettier
+ */
+var prettyPrint;
+
+
+(function () {
+ var win = window;
+ // Keyword lists for various languages.
+ // We use things that coerce to strings to make them compact when minified
+ // and to defeat aggressive optimizers that fold large string constants.
+ var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"];
+ var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," +
+ "double,enum,extern,float,goto,int,long,register,short,signed,sizeof," +
+ "static,struct,switch,typedef,union,unsigned,void,volatile"];
+ var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," +
+ "new,operator,private,protected,public,this,throw,true,try,typeof"];
+ var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," +
+ "concept,concept_map,const_cast,constexpr,decltype," +
+ "dynamic_cast,explicit,export,friend,inline,late_check," +
+ "mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast," +
+ "template,typeid,typename,using,virtual,where"];
+ var JAVA_KEYWORDS = [COMMON_KEYWORDS,
+ "abstract,boolean,byte,extends,final,finally,implements,import," +
+ "instanceof,null,native,package,strictfp,super,synchronized,throws," +
+ "transient"];
+ var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
+ "as,base,by,checked,decimal,delegate,descending,dynamic,event," +
+ "fixed,foreach,from,group,implicit,in,interface,internal,into,is,let," +
+ "lock,object,out,override,orderby,params,partial,readonly,ref,sbyte," +
+ "sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort," +
+ "var,virtual,where"];
+ var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," +
+ "for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," +
+ "throw,true,try,unless,until,when,while,yes";
+ var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,
+ "debugger,eval,export,function,get,null,set,undefined,var,with," +
+ "Infinity,NaN"];
+ var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," +
+ "goto,if,import,last,local,my,next,no,our,print,package,redo,require," +
+ "sub,undef,unless,until,use,wantarray,while,BEGIN,END";
+ var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "and,as,assert,class,def,del," +
+ "elif,except,exec,finally,from,global,import,in,is,lambda," +
+ "nonlocal,not,or,pass,print,raise,try,with,yield," +
+ "False,True,None"];
+ var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "alias,and,begin,case,class," +
+ "def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo," +
+ "rescue,retry,self,super,then,true,undef,unless,until,when,yield," +
+ "BEGIN,END"];
+ var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "case,done,elif,esac,eval,fi," +
+ "function,in,local,set,then,until"];
+ var ALL_KEYWORDS = [
+ CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS +
+ PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];
+ var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;
+
+ // token style names. correspond to css classes
+ /**
+ * token style for a string literal
+ * @const
+ */
+ var PR_STRING = 'str';
+ /**
+ * token style for a keyword
+ * @const
+ */
+ var PR_KEYWORD = 'kwd';
+ /**
+ * token style for a comment
+ * @const
+ */
+ var PR_COMMENT = 'com';
+ /**
+ * token style for a type
+ * @const
+ */
+ var PR_TYPE = 'typ';
+ /**
+ * token style for a literal value. e.g. 1, null, true.
+ * @const
+ */
+ var PR_LITERAL = 'lit';
+ /**
+ * token style for a punctuation string.
+ * @const
+ */
+ var PR_PUNCTUATION = 'pun';
+ /**
+ * token style for plain text.
+ * @const
+ */
+ var PR_PLAIN = 'pln';
+
+ /**
+ * token style for an sgml tag.
+ * @const
+ */
+ var PR_TAG = 'tag';
+ /**
+ * token style for a markup declaration such as a DOCTYPE.
+ * @const
+ */
+ var PR_DECLARATION = 'dec';
+ /**
+ * token style for embedded source.
+ * @const
+ */
+ var PR_SOURCE = 'src';
+ /**
+ * token style for an sgml attribute name.
+ * @const
+ */
+ var PR_ATTRIB_NAME = 'atn';
+ /**
+ * token style for an sgml attribute value.
+ * @const
+ */
+ var PR_ATTRIB_VALUE = 'atv';
+
+ /**
+ * A class that indicates a section of markup that is not code, e.g. to allow
+ * embedding of line numbers within code listings.
+ * @const
+ */
+ var PR_NOCODE = 'nocode';
+
+
+
+ /**
+ * A set of tokens that can precede a regular expression literal in
+ * javascript
+ * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html
+ * has the full list, but I've removed ones that might be problematic when
+ * seen in languages that don't support regular expression literals.
+ *
+ * Specifically, I've removed any keywords that can't precede a regexp
+ * literal in a syntactically legal javascript program, and I've removed the
+ * "in" keyword since it's not a keyword in many languages, and might be used
+ * as a count of inches.
+ *
+ *
The link above does not accurately describe EcmaScript rules since
+ * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
+ * very well in practice.
+ *
+ * @private
+ * @const
+ */
+ var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*';
+
+// CAVEAT: this does not properly handle the case where a regular
+// expression immediately follows another since a regular expression may
+// have flags for case-sensitivity and the like. Having regexp tokens
+// adjacent is not valid in any language I'm aware of, so I'm punting.
+// TODO: maybe style special characters inside a regexp as punctuation.
+
+
+ /**
+ * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
+ * matches the union of the sets of strings matched by the input RegExp.
+ * Since it matches globally, if the input strings have a start-of-input
+ * anchor (/^.../), it is ignored for the purposes of unioning.
+ * @param {Array.} regexs non multiline, non-global regexs.
+ * @return {RegExp} a global regex.
+ */
+ function combinePrefixPatterns(regexs) {
+ var capturedGroupIndex = 0;
+
+ var needToFoldCase = false;
+ var ignoreCase = false;
+ for (var i = 0, n = regexs.length; i < n; ++i) {
+ var regex = regexs[i];
+ if (regex.ignoreCase) {
+ ignoreCase = true;
+ } else if (/[a-z]/i.test(regex.source.replace(
+ /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
+ needToFoldCase = true;
+ ignoreCase = false;
+ break;
+ }
+ }
+
+ var escapeCharToCodeUnit = {
+ 'b': 8,
+ 't': 9,
+ 'n': 0xa,
+ 'v': 0xb,
+ 'f': 0xc,
+ 'r': 0xd
+ };
+
+ function decodeEscape(charsetPart) {
+ var cc0 = charsetPart.charCodeAt(0);
+ if (cc0 !== 92 /* \\ */) {
+ return cc0;
+ }
+ var c1 = charsetPart.charAt(1);
+ cc0 = escapeCharToCodeUnit[c1];
+ if (cc0) {
+ return cc0;
+ } else if ('0' <= c1 && c1 <= '7') {
+ return parseInt(charsetPart.substring(1), 8);
+ } else if (c1 === 'u' || c1 === 'x') {
+ return parseInt(charsetPart.substring(2), 16);
+ } else {
+ return charsetPart.charCodeAt(1);
+ }
+ }
+
+ function encodeEscape(charCode) {
+ if (charCode < 0x20) {
+ return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
+ }
+ var ch = String.fromCharCode(charCode);
+ return (ch === '\\' || ch === '-' || ch === ']' || ch === '^')
+ ? "\\" + ch : ch;
+ }
+
+ function caseFoldCharset(charSet) {
+ var charsetParts = charSet.substring(1, charSet.length - 1).match(
+ new RegExp(
+ '\\\\u[0-9A-Fa-f]{4}'
+ + '|\\\\x[0-9A-Fa-f]{2}'
+ + '|\\\\[0-3][0-7]{0,2}'
+ + '|\\\\[0-7]{1,2}'
+ + '|\\\\[\\s\\S]'
+ + '|-'
+ + '|[^-\\\\]',
+ 'g'));
+ var ranges = [];
+ var inverse = charsetParts[0] === '^';
+
+ var out = ['['];
+ if (inverse) { out.push('^'); }
+
+ for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
+ var p = charsetParts[i];
+ if (/\\[bdsw]/i.test(p)) { // Don't muck with named groups.
+ out.push(p);
+ } else {
+ var start = decodeEscape(p);
+ var end;
+ if (i + 2 < n && '-' === charsetParts[i + 1]) {
+ end = decodeEscape(charsetParts[i + 2]);
+ i += 2;
+ } else {
+ end = start;
+ }
+ ranges.push([start, end]);
+ // If the range might intersect letters, then expand it.
+ // This case handling is too simplistic.
+ // It does not deal with non-latin case folding.
+ // It works for latin source code identifiers though.
+ if (!(end < 65 || start > 122)) {
+ if (!(end < 65 || start > 90)) {
+ ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
+ }
+ if (!(end < 97 || start > 122)) {
+ ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
+ }
+ }
+ }
+ }
+
+ // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
+ // -> [[1, 12], [14, 14], [16, 17]]
+ ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
+ var consolidatedRanges = [];
+ var lastRange = [];
+ for (var i = 0; i < ranges.length; ++i) {
+ var range = ranges[i];
+ if (range[0] <= lastRange[1] + 1) {
+ lastRange[1] = Math.max(lastRange[1], range[1]);
+ } else {
+ consolidatedRanges.push(lastRange = range);
+ }
+ }
+
+ for (var i = 0; i < consolidatedRanges.length; ++i) {
+ var range = consolidatedRanges[i];
+ out.push(encodeEscape(range[0]));
+ if (range[1] > range[0]) {
+ if (range[1] + 1 > range[0]) { out.push('-'); }
+ out.push(encodeEscape(range[1]));
+ }
+ }
+ out.push(']');
+ return out.join('');
+ }
+
+ function allowAnywhereFoldCaseAndRenumberGroups(regex) {
+ // Split into character sets, escape sequences, punctuation strings
+ // like ('(', '(?:', ')', '^'), and runs of characters that do not
+ // include any of the above.
+ var parts = regex.source.match(
+ new RegExp(
+ '(?:'
+ + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
+ + '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
+ + '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
+ + '|\\\\[0-9]+' // a back-reference or octal escape
+ + '|\\\\[^ux0-9]' // other escape sequence
+ + '|\\(\\?[:!=]' // start of a non-capturing group
+ + '|[\\(\\)\\^]' // start/end of a group, or line start
+ + '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
+ + ')',
+ 'g'));
+ var n = parts.length;
+
+ // Maps captured group numbers to the number they will occupy in
+ // the output or to -1 if that has not been determined, or to
+ // undefined if they need not be capturing in the output.
+ var capturedGroups = [];
+
+ // Walk over and identify back references to build the capturedGroups
+ // mapping.
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ var p = parts[i];
+ if (p === '(') {
+ // groups are 1-indexed, so max group index is count of '('
+ ++groupIndex;
+ } else if ('\\' === p.charAt(0)) {
+ var decimalValue = +p.substring(1);
+ if (decimalValue) {
+ if (decimalValue <= groupIndex) {
+ capturedGroups[decimalValue] = -1;
+ } else {
+ // Replace with an unambiguous escape sequence so that
+ // an octal escape sequence does not turn into a backreference
+ // to a capturing group from an earlier regex.
+ parts[i] = encodeEscape(decimalValue);
+ }
+ }
+ }
+ }
+
+ // Renumber groups and reduce capturing groups to non-capturing groups
+ // where possible.
+ for (var i = 1; i < capturedGroups.length; ++i) {
+ if (-1 === capturedGroups[i]) {
+ capturedGroups[i] = ++capturedGroupIndex;
+ }
+ }
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ var p = parts[i];
+ if (p === '(') {
+ ++groupIndex;
+ if (!capturedGroups[groupIndex]) {
+ parts[i] = '(?:';
+ }
+ } else if ('\\' === p.charAt(0)) {
+ var decimalValue = +p.substring(1);
+ if (decimalValue && decimalValue <= groupIndex) {
+ parts[i] = '\\' + capturedGroups[decimalValue];
+ }
+ }
+ }
+
+ // Remove any prefix anchors so that the output will match anywhere.
+ // ^^ really does mean an anchored match though.
+ for (var i = 0; i < n; ++i) {
+ if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
+ }
+
+ // Expand letters to groups to handle mixing of case-sensitive and
+ // case-insensitive patterns if necessary.
+ if (regex.ignoreCase && needToFoldCase) {
+ for (var i = 0; i < n; ++i) {
+ var p = parts[i];
+ var ch0 = p.charAt(0);
+ if (p.length >= 2 && ch0 === '[') {
+ parts[i] = caseFoldCharset(p);
+ } else if (ch0 !== '\\') {
+ // TODO: handle letters in numeric escapes.
+ parts[i] = p.replace(
+ /[a-zA-Z]/g,
+ function (ch) {
+ var cc = ch.charCodeAt(0);
+ return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
+ });
+ }
+ }
+ }
+
+ return parts.join('');
+ }
+
+ var rewritten = [];
+ for (var i = 0, n = regexs.length; i < n; ++i) {
+ var regex = regexs[i];
+ if (regex.global || regex.multiline) { throw new Error('' + regex); }
+ rewritten.push(
+ '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
+ }
+
+ return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
+ }
+
+
+ /**
+ * Split markup into a string of source code and an array mapping ranges in
+ * that string to the text nodes in which they appear.
+ *
+ *
+ * The HTML DOM structure:
+ *
+ * (Element "p"
+ * (Element "b"
+ * (Text "print ")) ; #1
+ * (Text "'Hello '") ; #2
+ * (Element "br") ; #3
+ * (Text " + 'World';")) ; #4
+ *
+ *
+ * corresponds to the HTML
+ * {@code
print 'Hello ' + 'World';
}.
+ *
+ *
+ * It will produce the output:
+ *
+ * {
+ * sourceCode: "print 'Hello '\n + 'World';",
+ * // 1 2
+ * // 012345678901234 5678901234567
+ * spans: [0, #1, 6, #2, 14, #3, 15, #4]
+ * }
+ *
+ *
+ * where #1 is a reference to the {@code "print "} text node above, and so
+ * on for the other text nodes.
+ *
+ *
+ *
+ * The {@code} spans array is an array of pairs. Even elements are the start
+ * indices of substrings, and odd elements are the text nodes (or BR elements)
+ * that contain the text for those substrings.
+ * Substrings continue until the next index or the end of the source.
+ *
+ *
+ * @param {Node} node an HTML DOM subtree containing source-code.
+ * @param {boolean} isPreformatted true if white-space in text nodes should
+ * be considered significant.
+ * @return {Object} source code and the text nodes in which they occur.
+ */
+ function extractSourceSpans(node, isPreformatted) {
+ var nocode = /(?:^|\s)nocode(?:\s|$)/;
+
+ var chunks = [];
+ var length = 0;
+ var spans = [];
+ var k = 0;
+
+ function walk(node) {
+ switch (node.nodeType) {
+ case 1: // Element
+ if (nocode.test(node.className)) { return; }
+ for (var child = node.firstChild; child; child = child.nextSibling) {
+ walk(child);
+ }
+ var nodeName = node.nodeName.toLowerCase();
+ if ('br' === nodeName || 'li' === nodeName) {
+ chunks[k] = '\n';
+ spans[k << 1] = length++;
+ spans[(k++ << 1) | 1] = node;
+ }
+ break;
+ case 3: case 4: // Text
+ var text = node.nodeValue;
+ if (text.length) {
+ if (!isPreformatted) {
+ text = text.replace(/[ \t\r\n]+/g, ' ');
+ } else {
+ text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
+ }
+ // TODO: handle tabs here?
+ chunks[k] = text;
+ spans[k << 1] = length;
+ length += text.length;
+ spans[(k++ << 1) | 1] = node;
+ }
+ break;
+ }
+ }
+
+ walk(node);
+
+ return {
+ sourceCode: chunks.join('').replace(/\n$/, ''),
+ spans: spans
+ };
+ }
+
+
+ /**
+ * Apply the given language handler to sourceCode and add the resulting
+ * decorations to out.
+ * @param {number} basePos the index of sourceCode within the chunk of source
+ * whose decorations are already present on out.
+ */
+ function appendDecorations(basePos, sourceCode, langHandler, out) {
+ if (!sourceCode) { return; }
+ var job = {
+ sourceCode: sourceCode,
+ basePos: basePos
+ };
+ langHandler(job);
+ out.push.apply(out, job.decorations);
+ }
+
+ var notWs = /\S/;
+
+ /**
+ * Given an element, if it contains only one child element and any text nodes
+ * it contains contain only space characters, return the sole child element.
+ * Otherwise returns undefined.
+ *
+ * This is meant to return the CODE element in {@code
} when
+ * there is a single child element that contains all the non-space textual
+ * content, but not to return anything where there are multiple child elements
+ * as in {@code ...
...
} or when there
+ * is textual content.
+ */
+ function childContentWrapper(element) {
+ var wrapper = undefined;
+ for (var c = element.firstChild; c; c = c.nextSibling) {
+ var type = c.nodeType;
+ wrapper = (type === 1) // Element Node
+ ? (wrapper ? element : c)
+ : (type === 3) // Text Node
+ ? (notWs.test(c.nodeValue) ? element : wrapper)
+ : wrapper;
+ }
+ return wrapper === element ? undefined : wrapper;
+ }
+
+ /** Given triples of [style, pattern, context] returns a lexing function,
+ * The lexing function interprets the patterns to find token boundaries and
+ * returns a decoration list of the form
+ * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
+ * where index_n is an index into the sourceCode, and style_n is a style
+ * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
+ * all characters in sourceCode[index_n-1:index_n].
+ *
+ * The stylePatterns is a list whose elements have the form
+ * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
+ *
+ * Style is a style constant like PR_PLAIN, or can be a string of the
+ * form 'lang-FOO', where FOO is a language extension describing the
+ * language of the portion of the token in $1 after pattern executes.
+ * E.g., if style is 'lang-lisp', and group 1 contains the text
+ * '(hello (world))', then that portion of the token will be passed to the
+ * registered lisp handler for formatting.
+ * The text before and after group 1 will be restyled using this decorator
+ * so decorators should take care that this doesn't result in infinite
+ * recursion. For example, the HTML lexer rule for SCRIPT elements looks
+ * something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
+ * '\n';
+ }
+
+ return r;
+ };
+
+ var listUpLink = function(cssFiles){
+ var r = "";
+ for(var i = 0, len = cssFiles.length; i < len; i++) {
+ r += ' \n';
+ }
+ return r;
+ };
+
+ var indexContent = function () {
+ return '\n' +
+ '\n\n' +
+ ' \n' +
+ ' \n' +
+ ' ' + moduleName + ' : demo \n\n\n' +
+ ' \n' +
+
+ listUpLink(vendor_css) + '\n' +
+
+ '
\n' +
+ ' \n\n\n' +
+ ' \n' +
+
+ content.markup + '\n\n\n' +
+
+ ' \n' +
+ ' \n' +
+
+ listUpScript(vendor_js) +
+
+ ' \n' +
+
+ ' \n' +
+ ' \n' +
+ '\n';
+ };
+
+ var scriptContent = function(content) {
+ return "var app = angular.module('x', ['" + moduleName.toLowerCase() + "']);" + "\n\n\n" + content;
+ };
+
+
+
+ addField('description', 'http://angular-ui.github.io/' + repoName);
+ addField('files[index.html]', indexContent(content));
+ addField('files[app.js]', scriptContent(content.javascript || ""));
+
+ if (content.css){
+ addField('files[style.css]', content.css);
+ }
+
+ $document.find('body').append(form);
+ form[0].submit();
+ form.remove();
+ };
+ })
+
+ .controller('PlunkerCtrl', function ($scope, plunkGenerator) {
+
+ $scope.content = {};
+ $scope.vendor_css = [];
+ $scope.vendor_js = [];
+
+ $scope.edit = function (ngVersion, moduleName, repoName) {
+ plunkGenerator(ngVersion, moduleName, repoName,
+ $scope.content, $scope.vendor_css, $scope.vendor_js
+ );
+ };
+ })
+
+ .directive('plunkerContent', function () {
+ return {
+ link:function (scope, element, attrs) {
+ var htmlContent = "";
+ angular.forEach(element.find('li'), function(e){
+ t = angular.element(e).text();
+ htmlContent += (t.trim() === '') ? "\n" : t +"\n";
+ });
+ scope.content[attrs.plunkerContent] = htmlContent;
+ }
+ };
+ });
\ No newline at end of file
diff --git a/core/prettifyDirective.js b/core/prettifyDirective.js
new file mode 100644
index 0000000..08e5011
--- /dev/null
+++ b/core/prettifyDirective.js
@@ -0,0 +1,43 @@
+/*
+ * Copy paste from https://github.com/angular/angular.js/blob/master/src/bootstrap/bootstrap-prettify.js
+ * */
+angular.module('prettifyDirective', [])
+ .factory('reindentCode', function () {
+ return function (text, spaces) {
+ if (!text) return text;
+ var lines = text.split(/\r?\n/);
+ var prefix = ' '.substr(0, spaces || 0);
+ var i;
+
+ // remove any leading blank lines
+ while (lines.length && lines[0].match(/^\s*$/)) lines.shift();
+ // remove any trailing blank lines
+ while (lines.length && lines[lines.length - 1].match(/^\s*$/)) lines.pop();
+ var minIndent = 999;
+ for (i = 0; i < lines.length; i++) {
+ var line = lines[0];
+ var reindentCode = line.match(/^\s*/)[0];
+ if (reindentCode !== line && reindentCode.length < minIndent) {
+ minIndent = reindentCode.length;
+ }
+ }
+
+ for (i = 0; i < lines.length; i++) {
+ lines[i] = prefix + lines[i].substring(minIndent);
+ }
+ lines.push('');
+ return lines.join('\n');
+ };
+ })
+ .directive('prettyprint', ['reindentCode', function (reindentCode) {
+ return {
+ restrict: 'C',
+ terminal: true,
+ compile: function (element) {
+ element.html(window.prettyPrintOne(
+ reindentCode(element.html()),
+ undefined, true));
+ }
+ };
+ }])
+;
\ No newline at end of file
diff --git a/src/sortable.js b/dist/sortable.js
similarity index 98%
rename from src/sortable.js
rename to dist/sortable.js
index ed0c482..2b5f91b 100644
--- a/src/sortable.js
+++ b/dist/sortable.js
@@ -1,3 +1,12 @@
+/**
+ * angular-ui-sortable - This directive allows you to jQueryUI Sortable.
+ * @version v0.19.0 - 2018-05-16
+ * @link http://angular-ui.github.com
+ * @license MIT
+ */
+
+(function(window, angular, undefined) {
+'use strict';
/*
jQuery UI Sortable plugin wrapper
@@ -682,3 +691,5 @@ angular
};
}
]);
+
+})(window, window.angular);
diff --git a/dist/sortable.min.js b/dist/sortable.min.js
new file mode 100644
index 0000000..4ccbace
--- /dev/null
+++ b/dist/sortable.min.js
@@ -0,0 +1,8 @@
+/**
+ * angular-ui-sortable - This directive allows you to jQueryUI Sortable.
+ * @version v0.19.0 - 2018-05-16
+ * @link http://angular-ui.github.com
+ * @license MIT
+ */
+
+!function(a,b,c){"use strict";b.module("ui.sortable",[]).value("uiSortableConfig",{items:"> [ng-repeat],> [data-ng-repeat],> [x-ng-repeat]"}).directive("uiSortable",["uiSortableConfig","$timeout","$log",function(a,d,e){return{require:"?ngModel",scope:{ngModel:"=",uiSortable:"=",create:"&uiSortableCreate",start:"&uiSortableStart",activate:"&uiSortableActivate",beforeStop:"&uiSortableBeforeStop",update:"&uiSortableUpdate",remove:"&uiSortableRemove",receive:"&uiSortableReceive",deactivate:"&uiSortableDeactivate",stop:"&uiSortableStop"},link:function(f,g,h,i){function j(a,b){var c="function"==typeof a,d="function"==typeof b;return c&&d?function(){a.apply(this,arguments),b.apply(this,arguments)}:d?b:a}function k(a){var b=a.data("ui-sortable");return b&&"object"==typeof b&&"ui-sortable"===b.widgetFullName?b:null}function l(a){a.children().each(function(){var a=b.element(this);a.width(a.width())})}function m(a,b){return b}function n(b,c){return E[b]?("stop"===b&&(c=j(c,function(){f.$apply()}),c=j(c,v)),c=j(E[b],c)):F[b]&&(c=F[b](c)),c||"items"!==b&&"ui-model-items"!==b||(c=a.items),c}function o(a,d,e){function f(a,b){b in C||(C[b]=null)}b.forEach(E,f);var g=null;if(d){var h;b.forEach(d,function(d,e){if(!(a&&e in a)){if(e in D)return void("ui-floating"===e?C[e]="auto":C[e]=n(e,c));h||(h=b.element.ui.sortable().options);var f=h[e];f=n(e,f),g||(g={}),g[e]=f,C[e]=f}})}return a=b.extend({},a),b.forEach(a,function(b,c){if(c in D){if("ui-floating"!==c||b!==!1&&b!==!0||!e||(e.floating=b),"ui-preserve-size"===c&&(b===!1||b===!0)){var d=C.helper;a.helper=function(a,b){return C["ui-preserve-size"]===!0&&l(b),(d||m).apply(this,arguments)}}C[c]=n(c,b)}}),b.forEach(a,function(a,b){b in D||(a=n(b,a),g||(g={}),g[b]=a,C[b]=a)}),g}function p(a){var c=a.sortable("option","placeholder");if(c&&c.element&&"function"==typeof c.element){var d=c.element();return d=b.element(d)}return null}function q(a,b){var c=C["ui-model-items"].replace(/[^,]*>/g,""),d=a.find('[class="'+b.attr("class")+'"]:not('+c+")");return d}function r(a,b){var c=a.sortable("option","helper");return"clone"===c||"function"==typeof c&&b.item.sortable.isCustomHelperUsed()}function s(a,b){var c=null;return r(a,b)&&"parent"===a.sortable("option","appendTo")&&(c=B),c}function t(a){return/left|right/.test(a.css("float"))||/inline|table-cell/.test(a.css("display"))}function u(a,b){for(var c=0;c - <%= pkg.description %>',
- ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>',
- ' * @link <%= pkg.homepage %>',
- ' * @license <%= pkg.license %>',
- ' */',
- ''].join('\n')
- },
-
- connect: {
- options: {
- base : 'out/built/gh-pages',
- open: true,
- livereload: true
- },
- server: { options: { keepalive: true } },
- continuous: { options: { keepalive: false } }
- },
-
- coveralls: {
- options: {
- coverage_dir: 'coverage/',
- // debug: true
- // dryRun: true,
- // force: true,
- // recursive: true
- }
- },
-
- karma: {
- unit: testConfig('test/karma.conf.js'),
- server: {configFile: 'test/karma.conf.js'},
- continuous: {configFile: 'test/karma.conf.js', background: true },
- coverage: {
- configFile: 'test/karma.conf.js',
- reporters: ['progress', 'coverage'],
- preprocessors: { 'src/*.js': ['coverage'] },
- coverageReporter: {
- reporters: [{
- type: 'text'
- }, {
- type: 'lcov',
- dir: 'coverage/'
- }]
- },
- singleRun: true
- },
- junit: {
- configFile: 'test/karma.conf.js',
- reporters: ['progress', 'junit'],
- junitReporter: {
- outputFile: 'junit/unit.xml',
- suite: 'unit'
- },
- singleRun: true
- }
- },
-
- jshint: {
- src: {
- files:{ src : ['src/**/*.js', 'demo/**/*.js'] },
- options: { jshintrc: '.jshintrc' }
- },
- test: {
- files:{ src : [ 'test/*.js', 'gruntFile.js'] },
- options: grunt.util._.extend({}, grunt.file.readJSON('.jshintrc'), grunt.file.readJSON('test/.jshintrc'))
- }
- },
-
- uglify: {
- build: {
- expand: true,
- cwd: 'dist',
- src: ['*.js', '!*.min.js'],
- ext: '.min.js',
- dest: 'dist'
- }
- },
-
- surround: {
- main: {
- expand: true,
- cwd: 'src',
- src: ['*.js'],
- dest: 'dist',
- options: {
- prepend: ['(function(window, angular, undefined) {',
- '\'use strict\';'].join('\n'),
- append: '})(window, window.angular);'
- }
- },
- banner: {
- expand: true,
- cwd: 'dist',
- src: ['*.js'],
- dest: 'dist',
- options: {
- prepend: '<%= meta.banner %>'
- }
- }
- },
-
- ngmin: {
- main: {
- expand: true,
- cwd: 'src',
- src: ['*.js'],
- dest: 'dist'
- }
- },
-
- changelog: {
- options: {
- dest: 'CHANGELOG.md'
- }
- },
-
- watch: {
- src: {
- files: ['src/*'],
- tasks: ['jshint:src', 'karma:unit:run', 'dist', 'build:gh-pages']
- },
- test: {
- files: ['test/*.js'],
- tasks: ['jshint:test', 'karma:unit:run']
- },
- demo: {
- files: ['demo/*', 'publish.js'],
- tasks: ['jshint', 'build:gh-pages']
- },
- livereload: {
- files: ['out/built/gh-pages/**/*'],
- options: { livereload: true }
- }
- }
- });
-
-};
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..79af543
--- /dev/null
+++ b/index.html
@@ -0,0 +1,197 @@
+
+
+
+
+
+ Angular UI ~ UI.Sortable Doc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sortable items
+
+
+ Connected items
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/package.json b/package.json
deleted file mode 100644
index 9a61e8f..0000000
--- a/package.json
+++ /dev/null
@@ -1,63 +0,0 @@
-{
- "name": "angular-ui-sortable",
- "version": "0.19.0",
- "description": "This directive allows you to jQueryUI Sortable.",
- "author": "https://github.com/angular-ui/ui-sortable/graphs/contributors",
- "license": "MIT",
- "homepage": "http://angular-ui.github.com",
- "main": "./src/sortable.js",
- "dependencies": {
- "angular": ">=1.2.x",
- "jquery": ">=3.1.x",
- "jquery-ui-dist": ">=1.12.x"
- },
- "devDependencies": {
- "angular-ui-publisher": "1.2.x",
- "grunt": "~0.4.x",
- "grunt-contrib-connect": "0.5.x",
- "grunt-contrib-jshint": "0.8.x",
- "grunt-contrib-uglify": "0.2.x",
- "grunt-contrib-watch": "0.5.x",
- "grunt-conventional-changelog": "~1.0.0",
- "grunt-karma": "^0.12.1",
- "grunt-ngmin": "0.0.x",
- "grunt-surround": "0.1.x",
- "husky": "^0.14.3",
- "jasmine-core": "^2.4.1",
- "karma": "^0.13.22",
- "karma-chrome-launcher": "0.1.x",
- "karma-coffee-preprocessor": "^0.3.0",
- "karma-coverage": "^0.5.5",
- "karma-coveralls": "~0.1.4",
- "karma-firefox-launcher": "0.1.x",
- "karma-html2js-preprocessor": "^0.1.0",
- "karma-jasmine": "^0.3.7",
- "karma-junit-reporter": "^0.4.0",
- "karma-phantomjs-launcher": "^1.0.0",
- "karma-requirejs": "^0.2.5",
- "karma-script-launcher": "^0.2.0",
- "lint-staged": "^5.0.0",
- "load-grunt-tasks": "0.2.x",
- "prettier": "^1.8.2",
- "requirejs": "2.1.x",
- "wiredep": "1.8.x"
- },
- "scripts": {
- "coverage": "grunt coverage",
- "dist": "grunt dist",
- "precommit": "lint-staged",
- "prettify": "prettier --write \"src/**/*.js\" \"test/**/*.js\"",
- "serve": "grunt serve",
- "test": "grunt test"
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/angular-ui/ui-sortable.git"
- },
- "lint-staged": {
- "*.js": [
- "prettier --write",
- "git add"
- ]
- }
-}
diff --git a/publish.js b/publish.js
deleted file mode 100644
index a0addca..0000000
--- a/publish.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/* jshint node:true */
-
-'use strict';
-
-var fs = require('fs');
-var path = require('path');
-
-module.exports = function() {
- var wiredep = require('wiredep');
-
- var bower_dependencies = wiredep({ cwd: __dirname });
-
- var js_dependencies = []
- .concat(bower_dependencies.packages['jquery'].main)
- .concat(bower_dependencies.packages['jquery-ui'].main)
- .map(function(p) {
- return p.replace(path.join(__dirname, '/'), '');
- });
-
- var css_dependencies = [
- 'bower_components/jquery-ui/themes/smoothness/jquery-ui.css'
- ];
-
- function putThemInVendorDir (filepath) {
- return 'vendor/' + path.basename(filepath);
- }
-
- return {
- humaName : 'UI.Sortable',
- repoName : 'ui-sortable',
- inlineHTML : fs.readFileSync(__dirname + '/demo/demo.html'),
- inlineJS : fs.readFileSync(__dirname + '/demo/demo.js'),
- css: css_dependencies.map(putThemInVendorDir).concat(['demo/demo.css']),
- js : function(defaultJsFiles){
- // HACK TO LOAD JQUERY BEFORE ANGULAR
- return ['vendor/jquery.js'].concat(defaultJsFiles, js_dependencies.slice(1).map(putThemInVendorDir).concat(['dist/sortable.js']));
- },
- bowerData: { main : './sortable.js' },
- tocopy : css_dependencies.concat(js_dependencies)
- };
-};
diff --git a/test/.jshintrc b/test/.jshintrc
deleted file mode 100644
index 7bca420..0000000
--- a/test/.jshintrc
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "node": true,
- "globals": {
- "angular": false,
- "inject": false,
- "$": false,
-
- "jasmine": false,
- "afterEach": false,
- "beforeEach": false,
- "ddescribe": false,
- "describe": false,
- "expect": false,
- "fit": false,
- "iit": false,
- "it": false,
- "spyOn": false,
- "xdescribe": false,
- "xit": false
- }
-}
diff --git a/test/bower_overrides.json b/test/bower_overrides.json
deleted file mode 100644
index 3816572..0000000
--- a/test/bower_overrides.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "jquery-simulate": {
- "main": "jquery.simulate.js",
- "dependencies": {
- "jquery": ""
- }
- },
- "angular": {
- "dependencies": {
- "jquery": ""
- }
- }
-}
diff --git a/test/karma.conf.js b/test/karma.conf.js
deleted file mode 100644
index 1067454..0000000
--- a/test/karma.conf.js
+++ /dev/null
@@ -1,73 +0,0 @@
-// Karma configuration
-// Generated on Sat Dec 28 2013 20:27:08 GMT+0100 (CET)
-
-'use strict';
-
-module.exports = function(config) {
- var wiredep = require('wiredep');
-
- var fs = require('fs');
- var bowerOverrides = JSON.parse(
- fs.readFileSync('./test/bower_overrides.json')
- );
-
- var devJSDependencies = wiredep({
- devDependencies: true,
- overrides: bowerOverrides
- }).js;
-
- config.set({
- // base path, that will be used to resolve files and exclude
- basePath: '..',
-
- // frameworks to use
- frameworks: ['jasmine'],
-
- // list of files / patterns to load in the browser
- files: devJSDependencies.concat([
- 'test/libs/jquery.simulate.dragandrevert.js',
- 'src/sortable.js',
- 'test/sortable.test-helper.js',
- 'test/sortable.test-directives.js',
- 'test/*.spec.js',
- 'test/sortable.tests.css'
- ]),
-
- // list of files to exclude
- exclude: [],
-
- // test results reporter to use
- // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
- reporters: ['progress'],
-
- // web server port
- port: 9876,
-
- // enable / disable colors in the output (reporters and logs)
- colors: true,
-
- // level of logging
- // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
- logLevel: config.LOG_INFO,
-
- // enable / disable watching file and executing tests whenever any file changes
- autoWatch: false,
-
- // Start these browsers, currently available:
- // - Chrome
- // - ChromeCanary
- // - Firefox
- // - Opera (has to be installed with `npm install karma-opera-launcher`)
- // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
- // - PhantomJS
- // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
- browsers: ['Chrome', 'Firefox' /*, 'PhantomJS'*/],
-
- // If browser does not capture in given timeout [ms], kill it
- captureTimeout: 60000,
-
- // Continuous Integration mode
- // if true, it capture browsers, run tests and exit
- singleRun: false
- });
-};
diff --git a/test/libs/jquery.simulate.dragandrevert.js b/test/libs/jquery.simulate.dragandrevert.js
deleted file mode 100644
index 5ca102f..0000000
--- a/test/libs/jquery.simulate.dragandrevert.js
+++ /dev/null
@@ -1,60 +0,0 @@
-(function($, undefined) {
- function findCenter(elem) {
- var offset,
- document = $(elem.ownerDocument);
- elem = $(elem);
- offset = elem.offset();
-
- return {
- x: offset.left + elem.outerWidth() / 2 - document.scrollLeft(),
- y: offset.top + elem.outerHeight() / 2 - document.scrollTop()
- };
- }
-
- $.extend($.simulate.prototype, {
- simulateDragAndRevert: function() {
- var i = 0,
- target = this.target,
- options = this.options,
- center = findCenter(target),
- x = Math.floor(center.x),
- y = Math.floor(center.y),
- dx = options.dx || 0,
- dy = options.dy || 0,
- moves = options.moves || 3,
- coord = {
- clientX: x,
- clientY: y
- };
-
- this.simulateEvent(target, 'mousedown', coord);
-
- for (; i < moves; i++) {
- x += dx / moves;
- y += dy / moves;
-
- coord = {
- clientX: Math.round(x),
- clientY: Math.round(y)
- };
-
- this.simulateEvent(document, 'mousemove', coord);
- }
-
- for (i = 0; i < moves; i++) {
- x -= dx / moves;
- y -= dy / moves;
-
- coord = {
- clientX: Math.round(x),
- clientY: Math.round(y)
- };
-
- this.simulateEvent(document, 'mousemove', coord);
- }
-
- this.simulateEvent(target, 'mouseup', coord);
- this.simulateEvent(target, 'click', coord);
- }
- });
-})(jQuery);
diff --git a/test/sortable.e2e.callbacks.attr.spec.js b/test/sortable.e2e.callbacks.attr.spec.js
deleted file mode 100644
index f09f8ff..0000000
--- a/test/sortable.e2e.callbacks.attr.spec.js
+++ /dev/null
@@ -1,215 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
-
- var EXTRA_DY_PERCENTAGE,
- listContent,
- hasUndefinedProperties,
- beforeLiElement,
- afterLiElement;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
- listContent = sortableTestHelper.listContent;
- hasUndefinedProperties = sortableTestHelper.hasUndefinedProperties;
- beforeLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeLiElement;
- afterLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterLiElement;
- })
- );
-
- tests.description = 'Attribute Callbacks related';
- function tests(useExtraElements) {
- var host;
-
- beforeEach(
- inject(function() {
- host = $('
');
- $('body').append(host);
-
- if (!useExtraElements) {
- beforeLiElement = afterLiElement = '';
- }
- })
- );
-
- afterEach(function() {
- host.remove();
- host = null;
- });
-
- it('should cancel sorting of node "Two"', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.update = function(e, ui) {
- if (ui.item.sortable.model === 'Two') {
- ui.item.sortable.cancel();
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should call all callbacks with the proper context', function() {
- inject(function($compile, $rootScope) {
- var element,
- callbackContexts = {};
- $rootScope.$apply(function() {
- $rootScope.create = function() {
- callbackContexts.create = this;
- };
- // $rootScope.helper = function(e, item) {
- // callbackContexts.helper = this;
- // return item;
- // };
- $rootScope.start = function() {
- callbackContexts.start = this;
- };
- $rootScope.activate = function() {
- callbackContexts.activate = this;
- };
- $rootScope.beforeStop = function() {
- callbackContexts.beforeStop = this;
- };
- $rootScope.update = function() {
- callbackContexts.update = this;
- };
- $rootScope.deactivate = function() {
- callbackContexts.deactivate = this;
- };
- $rootScope.stop = function() {
- callbackContexts.stop = this;
- };
-
- // spyOn($rootScope, 'helper').and.callThrough();
- spyOn($rootScope, 'create').and.callThrough();
- spyOn($rootScope, 'start').and.callThrough();
- spyOn($rootScope, 'activate').and.callThrough();
- spyOn($rootScope, 'beforeStop').and.callThrough();
- spyOn($rootScope, 'update').and.callThrough();
- spyOn($rootScope, 'deactivate').and.callThrough();
- spyOn($rootScope, 'stop').and.callThrough();
- $rootScope.items = ['One', 'Two', 'Three'];
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- });
-
- host.append(element);
-
- $rootScope.$apply(function() {});
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- expect($rootScope.create).toHaveBeenCalled();
- // expect($rootScope.helper).toHaveBeenCalled();
- expect($rootScope.start).toHaveBeenCalled();
- expect($rootScope.activate).toHaveBeenCalled();
- expect($rootScope.beforeStop).toHaveBeenCalled();
- expect($rootScope.update).toHaveBeenCalled();
- expect($rootScope.deactivate).toHaveBeenCalled();
- expect($rootScope.stop).toHaveBeenCalled();
-
- expect(callbackContexts.create).toEqual(element[0]);
- // expect(callbackContexts.helper).toEqual(element[0]);
- expect(callbackContexts.start).toEqual(element[0]);
- expect(callbackContexts.activate).toEqual(element[0]);
- expect(callbackContexts.beforeStop).toEqual(element[0]);
- expect(callbackContexts.update).toEqual(element[0]);
- expect(callbackContexts.deactivate).toEqual(element[0]);
- expect(callbackContexts.stop).toEqual(element[0]);
-
- $(element).remove();
- });
- });
- }
-
- [0, 1].forEach(function(useExtraElements) {
- var testDescription = tests.description;
-
- if (useExtraElements) {
- testDescription += ' with extra elements';
- }
-
- describe(testDescription, function() {
- tests(useExtraElements);
- });
- });
-});
diff --git a/test/sortable.e2e.callbacks.spec.js b/test/sortable.e2e.callbacks.spec.js
deleted file mode 100644
index 29356f8..0000000
--- a/test/sortable.e2e.callbacks.spec.js
+++ /dev/null
@@ -1,768 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
-
- var EXTRA_DY_PERCENTAGE,
- listContent,
- hasUndefinedProperties,
- beforeLiElement,
- afterLiElement;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
- listContent = sortableTestHelper.listContent;
- hasUndefinedProperties = sortableTestHelper.hasUndefinedProperties;
- beforeLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeLiElement;
- afterLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterLiElement;
- })
- );
-
- tests.description = 'Callbacks related';
- function tests(useExtraElements) {
- var host;
-
- beforeEach(
- inject(function() {
- host = $('
');
- $('body').append(host);
-
- if (!useExtraElements) {
- beforeLiElement = afterLiElement = '';
- }
- })
- );
-
- afterEach(function() {
- host.remove();
- host = null;
- });
-
- it('should cancel sorting of node "Two"', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- update: function(e, ui) {
- if (ui.item.sortable.model === 'Two') {
- ui.item.sortable.cancel();
- }
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should cancel sorting of node "Two" and "helper: function" that returns an element is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- return item.clone();
- },
- update: function(e, ui) {
- if (ui.item.sortable.model === 'Two') {
- ui.item.sortable.cancel();
- }
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should cancel sorting of node "Two" when then helper is appended to the `body`', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- return item.clone().appendTo('body');
- },
- update: function(e, ui) {
- if (ui.item.sortable.model === 'Two') {
- ui.item.sortable.cancel();
- }
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should cancel sorting of node "Two" and "helper: function" that returns a list element is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- return item;
- },
- update: function(e, ui) {
- if (ui.item.sortable.model === 'Two') {
- ui.item.sortable.cancel();
- }
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- // try again
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should update model from update() callback', function() {
- inject(function($compile, $rootScope) {
- var element, logsElement;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- logsElement = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ log }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- update: function(e, ui) {
- $rootScope.logs.push('Moved element ' + ui.item.sortable.model);
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- $rootScope.logs = [];
- });
-
- host.append(element).append(logsElement);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.logs).toEqual(['Moved element Two']);
- expect($rootScope.items).toEqual(listContent(element));
- expect($rootScope.logs).toEqual(listContent(logsElement));
-
- $(element).remove();
- $(logsElement).remove();
- });
- });
-
- // ensure scope.apply() is called after a stop() callback
- it('should update model from stop() callback', function() {
- inject(function($compile, $rootScope) {
- var element, logsElement;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- logsElement = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ log }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- stop: function(e, ui) {
- $rootScope.logs.push('Moved element ' + ui.item.sortable.model);
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- $rootScope.logs = [];
- });
-
- host.append(element).append(logsElement);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.logs).toEqual(['Moved element Two']);
- expect($rootScope.items).toEqual(listContent(element));
- expect($rootScope.logs).toEqual(listContent(logsElement));
-
- $(element).remove();
- $(logsElement).remove();
- });
- });
-
- it('should call the create() callback when initialized', function() {
- inject(function($compile, $rootScope) {
- var element;
- $rootScope.$apply(function() {
- $rootScope.items = ['One', 'Two', 'Three'];
- $rootScope.opts = {
- create: function() {}
- };
- spyOn($rootScope.opts, 'create');
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- });
-
- host.append(element);
-
- expect($rootScope.opts.create).toHaveBeenCalled();
-
- $(element).remove();
- });
- });
-
- it('should properly set ui.item.sortable properties', function() {
- inject(function($compile, $rootScope) {
- var element, updateCallbackExpectations;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- update: function(e, ui) {
- if (ui.item.sortable.model === 'Two') {
- ui.item.sortable.cancel();
- }
- updateCallbackExpectations(ui.item.sortable);
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- $rootScope.$apply(function() {});
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.model).toEqual('Two');
- expect(uiItemSortable.index).toEqual(1);
- expect(uiItemSortable.source.length).toEqual(1);
- expect(uiItemSortable.source[0]).toBe(host.children()[0]);
- expect(uiItemSortable.sourceModel).toBe($rootScope.items);
- expect(uiItemSortable.isCanceled()).toBe(true);
- expect(uiItemSortable.isCustomHelperUsed()).toBe(false);
- };
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- updateCallbackExpectations = undefined;
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.model).toEqual('One');
- expect(uiItemSortable.index).toEqual(0);
- expect(uiItemSortable.source.length).toEqual(1);
- expect(uiItemSortable.source[0]).toBe(host.children()[0]);
- expect(uiItemSortable.sourceModel).toBe($rootScope.items);
- expect(uiItemSortable.isCanceled()).toBe(false);
- expect(uiItemSortable.isCustomHelperUsed()).toBe(false);
- };
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
- updateCallbackExpectations = undefined;
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.model).toEqual('One');
- expect(uiItemSortable.index).toEqual(2);
- expect(uiItemSortable.source.length).toEqual(1);
- expect(uiItemSortable.source[0]).toBe(host.children()[0]);
- expect(uiItemSortable.sourceModel).toBe($rootScope.items);
- expect(uiItemSortable.isCanceled()).toBe(false);
- expect(uiItemSortable.isCustomHelperUsed()).toBe(false);
- };
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- updateCallbackExpectations = undefined;
-
- $(element).remove();
- });
- });
-
- it('should call all callbacks with the proper context', function() {
- inject(function($compile, $rootScope) {
- var element,
- callbackContexts = {};
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- callbackContexts.helper = this;
- return item;
- },
- create: function() {
- callbackContexts.create = this;
- },
- start: function() {
- callbackContexts.start = this;
- },
- activate: function() {
- callbackContexts.activate = this;
- },
- beforeStop: function() {
- callbackContexts.beforeStop = this;
- },
- update: function() {
- callbackContexts.update = this;
- },
- deactivate: function() {
- callbackContexts.deactivate = this;
- },
- stop: function() {
- callbackContexts.stop = this;
- }
- };
- spyOn($rootScope.opts, 'helper').and.callThrough();
- spyOn($rootScope.opts, 'create').and.callThrough();
- spyOn($rootScope.opts, 'start').and.callThrough();
- spyOn($rootScope.opts, 'activate').and.callThrough();
- spyOn($rootScope.opts, 'beforeStop').and.callThrough();
- spyOn($rootScope.opts, 'update').and.callThrough();
- spyOn($rootScope.opts, 'deactivate').and.callThrough();
- spyOn($rootScope.opts, 'stop').and.callThrough();
- $rootScope.items = ['One', 'Two', 'Three'];
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- });
-
- host.append(element);
-
- $rootScope.$apply(function() {});
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- expect($rootScope.opts.helper).toHaveBeenCalled();
- expect($rootScope.opts.create).toHaveBeenCalled();
- expect($rootScope.opts.start).toHaveBeenCalled();
- expect($rootScope.opts.activate).toHaveBeenCalled();
- expect($rootScope.opts.beforeStop).toHaveBeenCalled();
- expect($rootScope.opts.update).toHaveBeenCalled();
- expect($rootScope.opts.deactivate).toHaveBeenCalled();
- expect($rootScope.opts.stop).toHaveBeenCalled();
-
- expect(callbackContexts.helper).toEqual(element[0]);
- expect(callbackContexts.create).toEqual(element[0]);
- expect(callbackContexts.start).toEqual(element[0]);
- expect(callbackContexts.activate).toEqual(element[0]);
- expect(callbackContexts.beforeStop).toEqual(element[0]);
- expect(callbackContexts.update).toEqual(element[0]);
- expect(callbackContexts.deactivate).toEqual(element[0]);
- expect(callbackContexts.stop).toEqual(element[0]);
-
- $(element).remove();
- });
- });
-
- it('should properly free ui.item.sortable object', function() {
- inject(function($compile, $rootScope) {
- var element, uiItem, uiItemSortable_Destroy;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- start: function(e, ui) {
- uiItem = ui.item;
- spyOn(ui.item.sortable, '_destroy').and.callThrough();
- uiItemSortable_Destroy = ui.item.sortable._destroy;
- },
- update: function(e, ui) {
- if (ui.item.sortable.model === 'Two') {
- ui.item.sortable.cancel();
- }
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- expect(uiItemSortable_Destroy).toHaveBeenCalled();
- expect(hasUndefinedProperties(uiItem.sortable)).toBe(true);
- uiItem = uiItemSortable_Destroy = undefined;
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
- expect(uiItemSortable_Destroy).toHaveBeenCalled();
- expect(hasUndefinedProperties(uiItem.sortable)).toBe(true);
- uiItem = uiItemSortable_Destroy = undefined;
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
- expect(uiItemSortable_Destroy).toHaveBeenCalled();
- expect(hasUndefinedProperties(uiItem.sortable)).toBe(true);
- uiItem = uiItemSortable_Destroy = undefined;
-
- $(element).remove();
- });
- });
-
- it('should provide the item.sortable properties on helper callback', function() {
- inject(function($compile, $rootScope) {
- var element,
- helperItem,
- itemSortable_Restore,
- sortableAfterRestore,
- helperCallbackExpectations;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- helperItem = item;
-
- var oldRestore = item.sortable._restore;
- item.sortable._restore = function() {
- oldRestore.apply(this, arguments);
- // hold the value of the sortable object
- // right after the _restore method completes
- sortableAfterRestore = item.sortable;
- };
-
- spyOn(item.sortable, '_restore').and.callThrough();
- itemSortable_Restore = item.sortable._restore;
- helperCallbackExpectations(item.sortable);
- return item.clone();
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- $rootScope.$apply(function() {});
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- helperCallbackExpectations = function(helperItemSortable) {
- expect(helperItemSortable.model).toEqual('One');
- expect(helperItemSortable.index).toEqual(0);
- expect(helperItemSortable.source.length).toEqual(1);
- expect(helperItemSortable.source[0]).toBe(host.children()[0]);
- expect(helperItemSortable.sourceModel).toBe($rootScope.items);
- };
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
- expect(itemSortable_Restore).toHaveBeenCalled();
- expect(hasUndefinedProperties(helperItem.sortable)).toBe(true);
- // this happens after the update callback, so everything is udnefined
- expect(typeof sortableAfterRestore).toBe('function');
- helperItem = itemSortable_Restore = sortableAfterRestore = helperCallbackExpectations = undefined;
-
- $(element).remove();
- });
- });
-
- it('should properly reset a deleted callback option', function() {
- inject(function($compile, $rootScope) {
- var element, logsElement;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- logsElement = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ log }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- stop: function(e, ui) {
- $rootScope.logs.push('Moved element ' + ui.item.sortable.model);
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- $rootScope.logs = [];
- });
-
- host.append(element).append(logsElement);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.logs).toEqual(['Moved element Two']);
- expect($rootScope.items).toEqual(listContent(element));
- expect($rootScope.logs).toEqual(listContent(logsElement));
-
- $rootScope.$digest();
-
- $rootScope.$apply(function() {
- $rootScope.opts = {};
- });
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
- // the log should be the same
- expect($rootScope.logs).toEqual(['Moved element Two']);
- expect($rootScope.logs).toEqual(listContent(logsElement));
-
- $(element).remove();
- $(logsElement).remove();
- });
- });
- }
-
- [0, 1].forEach(function(useExtraElements) {
- var testDescription = tests.description;
-
- if (useExtraElements) {
- testDescription += ' with extra elements';
- }
-
- describe(testDescription, function() {
- tests(useExtraElements);
- });
- });
-});
diff --git a/test/sortable.e2e.directiveoptions.spec.js b/test/sortable.e2e.directiveoptions.spec.js
deleted file mode 100644
index af7c91c..0000000
--- a/test/sortable.e2e.directiveoptions.spec.js
+++ /dev/null
@@ -1,637 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
-
- var EXTRA_DY_PERCENTAGE,
- listContent,
- beforeLiElement,
- afterLiElement,
- beforeTrElement,
- afterTrElement;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
- listContent = sortableTestHelper.listContent;
- beforeLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeLiElement;
- afterLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterLiElement;
- beforeTrElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeTrElement;
- afterTrElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterTrElement;
- })
- );
-
- tests.description = 'Custom directive options related';
- function tests(useExtraElements) {
- var host;
-
- beforeEach(
- inject(function() {
- host = $('
');
- $('body').append(host);
-
- if (!useExtraElements) {
- beforeLiElement = afterLiElement = '';
- beforeTrElement = afterTrElement = '';
- }
- })
- );
-
- afterEach(function() {
- host.remove();
- host = null;
- });
-
- it('should work when "ui-floating: false" option is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- 'ui-floating': false
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "ui-floating: true" option is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement.replace('', ' '),
- ' {{ item }} ',
- afterLiElement.replace('', ' '),
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- 'ui-floating': true
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx, moves: 5 });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "ui-floating: \'auto\'" option is used and elements are "float"ing', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement.replace('', ' '),
- ' {{ item }} ',
- afterLiElement.replace('', ' '),
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- 'ui-floating': 'auto'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx, moves: 5 });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "ui-floating: \'auto\'" option is used and elements are "display: inline-block"', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement.replace('', ' '),
- ' {{ item }} ',
- afterLiElement.replace('', ' '),
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- 'ui-floating': 'auto'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dx = (1 + EXTRA_DY_PERCENTAGE) * li.outerWidth();
- li.simulate('drag', { dx: dx, moves: 5 });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should properly reset deleted directive options', function() {
- inject(function($compile, $rootScope) {
- var element, logsElement;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement + ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- 'ui-floating': true,
- 'ui-model-items': '> [sortable-item]'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append(logsElement);
-
- var sortableWidgetInstance = element.data('ui-sortable');
-
- expect(sortableWidgetInstance.floating).toBe(true);
-
- $rootScope.$digest();
-
- $rootScope.$apply(function() {
- $rootScope.opts = {};
- });
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
- expect(sortableWidgetInstance.floating).toBe(false);
-
- $(element).remove();
- $(logsElement).remove();
- });
- });
-
- it('should work when custom "ui-model-items" option is used with an attribute selector', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
-
- var itemsSelector = '[ui-sortable-item]';
- $rootScope.$apply(function() {
- $rootScope.opts = {
- items: '> ' + itemsSelector,
- 'ui-model-items': '> ' + itemsSelector
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var li = element.find(itemsSelector + ':eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find(itemsSelector + ':eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when custom "ui-model-items" option is used with a class selector', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
-
- var itemsSelector = '.ui-sortable-item';
- $rootScope.$apply(function() {
- $rootScope.opts = {
- items: '> ' + itemsSelector,
- 'ui-model-items': '> ' + itemsSelector
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var li = element.find(itemsSelector + ':eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find(itemsSelector + ':eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- xit('should work with multiple [ng-repeat] when attribute "ui-model-items" selector', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- beforeLiElement.replace(
- '',
- ' {{ item }}'
- ),
- ' {{ item }} ',
- afterLiElement.replace(
- '',
- ' {{ item }}'
- ),
- afterLiElement,
- ' '
- )
- )($rootScope);
-
- var itemsSelector = '[ui-sortable-item]';
- $rootScope.$apply(function() {
- $rootScope.opts = {
- items: '> ' + itemsSelector,
- 'ui-model-items': '> ' + itemsSelector
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var li = element.find(itemsSelector + ':eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element, itemsSelector));
-
- li = element.find(itemsSelector + ':eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element, itemsSelector));
-
- $(element).remove();
- });
- });
-
- xit('should work with multiple [ng-repeat] when class "ui-model-items" selector', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- beforeLiElement.replace(
- '',
- ' {{ item }}'
- ),
- ' {{ item }} ',
- afterLiElement.replace(
- '',
- ' {{ item }}'
- ),
- afterLiElement,
- ' '
- )
- )($rootScope);
-
- var itemsSelector = '.ui-sortable-item';
- $rootScope.$apply(function() {
- $rootScope.opts = {
- items: '> ' + itemsSelector,
- 'ui-model-items': '> ' + itemsSelector
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var li = element.find(itemsSelector + ':eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element, itemsSelector));
-
- li = element.find(itemsSelector + ':eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element, itemsSelector));
-
- $(element).remove();
- });
- });
-
- it('should work when the "ui-preserve-size" option is used', function() {
- inject(function($compile, $rootScope) {
- var width = '200px';
- var element;
- element = $compile(
- ''.concat(
- '',
- ' ',
- '',
- beforeTrElement,
- '',
- '{{ item }} ',
- ' ',
- afterTrElement,
- ' ',
- '
'
- )
- )($rootScope);
-
- var itemsSelector = '.sortable-item';
- $rootScope.$apply(function() {
- $rootScope.opts = {
- 'ui-preserve-size': true,
- stop: function(e, ui) {
- expect(ui.item.children().css('width')).toEqual(width);
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var tr = element.find(itemsSelector + ':eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * tr.outerHeight();
- tr.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(
- listContent(element.find('tbody'))
- .map($)
- .map($.text)
- );
-
- tr = element.find(itemsSelector + ':eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * tr.outerHeight();
- tr.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(
- listContent(element.find('tbody'))
- .map($)
- .map($.text)
- );
-
- $(element).remove();
- });
- });
-
- it('should work when the "ui-preserve-size" option is false', function() {
- inject(function($compile, $rootScope) {
- var width = '200px';
- var element;
- element = $compile(
- ''.concat(
- '',
- ' ',
- '',
- beforeTrElement,
- '',
- '{{ item }} ',
- ' ',
- afterTrElement,
- ' ',
- '
'
- )
- )($rootScope);
-
- var itemsSelector = '.sortable-item';
- $rootScope.$apply(function() {
- $rootScope.opts = {
- 'ui-preserve-size': false,
- stop: function(e, ui) {
- expect(ui.item.children().attr('style')).toEqual(undefined);
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var tr = element.find(itemsSelector + ':eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * tr.outerHeight();
- tr.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(
- listContent(element.find('tbody'))
- .map($)
- .map($.text)
- );
-
- tr = element.find(itemsSelector + ':eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * tr.outerHeight();
- tr.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(
- listContent(element.find('tbody'))
- .map($)
- .map($.text)
- );
-
- $(element).remove();
- });
- });
-
- it('should work when the "ui-preserve-size" & helper options are used', function() {
- inject(function($compile, $rootScope) {
- var width = '200px';
- var element;
- element = $compile(
- ''.concat(
- '',
- ' ',
- '',
- beforeTrElement,
- '',
- '{{ item }} ',
- ' ',
- afterTrElement,
- ' ',
- '
'
- )
- )($rootScope);
-
- var itemsSelector = '.sortable-item';
- $rootScope.$apply(function() {
- $rootScope.opts = {
- 'ui-preserve-size': true,
- helper: function(e, item) {
- return item.clone();
- },
- stop: function(e, ui) {
- expect(ui.item.children().css('width')).toEqual(width);
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element).append('
');
-
- var tr = element.find(itemsSelector + ':eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * tr.outerHeight();
- tr.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(
- listContent(element.find('tbody'))
- .map($)
- .map($.text)
- );
-
- tr = element.find(itemsSelector + ':eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * tr.outerHeight();
- tr.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(
- listContent(element.find('tbody'))
- .map($)
- .map($.text)
- );
-
- $(element).remove();
- });
- });
- }
-
- [0, 1].forEach(function(useExtraElements) {
- var testDescription = tests.description;
-
- if (useExtraElements) {
- testDescription += ' with extra elements';
- }
-
- describe(testDescription, function() {
- tests(useExtraElements);
- });
- });
-});
diff --git a/test/sortable.e2e.directives.spec.js b/test/sortable.e2e.directives.spec.js
deleted file mode 100644
index 7e900fb..0000000
--- a/test/sortable.e2e.directives.spec.js
+++ /dev/null
@@ -1,470 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
- beforeEach(module('ui.sortable.testDirectives'));
-
- var EXTRA_DY_PERCENTAGE,
- listContent,
- listFindContent,
- listInnerContent,
- simulateElementDrag,
- beforeLiElement,
- afterLiElement,
- beforeDivElement,
- afterDivElement;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
- listContent = sortableTestHelper.listContent;
- listFindContent = sortableTestHelper.listFindContent;
- listInnerContent = sortableTestHelper.listInnerContent;
- simulateElementDrag = sortableTestHelper.simulateElementDrag;
- beforeLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeLiElement;
- afterLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterLiElement;
- beforeDivElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeDivElement;
- afterDivElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterDivElement;
- })
- );
-
- tests.description = 'Inner directives related';
- function tests(useExtraElements) {
- var host;
-
- beforeEach(
- inject(function() {
- host = $('
');
- $('body').append(host);
-
- if (!useExtraElements) {
- beforeLiElement = afterLiElement = '';
- beforeDivElement = afterDivElement = '';
- }
- })
- );
-
- afterEach(function() {
- host.remove();
- host = null;
- });
-
- it('should work when inner directives are used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '',
- ' ',
- ' ',
- afterLiElement,
- ' '
- )
- )($rootScope);
-
- $rootScope.$apply(function() {
- $rootScope.opts = {};
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('> [ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- li = element.find('> [ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- $(element).remove();
- });
- });
-
- it('should not $destroy directives after sorting.', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '',
- ' ',
- ' ',
- afterLiElement,
- ' '
- )
- )($rootScope);
-
- $rootScope.$apply(function() {
- $rootScope.opts = {};
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('> [ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- li = element.find('> [ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when the items are inside a transcluded directive', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- '
',
- beforeLiElement,
- '',
- '{{ item }}',
- '
',
- afterLiElement,
- '',
- ' '
- )
- )($rootScope);
-
- $rootScope.$apply(function() {
- $rootScope.opts = {
- items: '> * .sortable-item'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('.sortable-item:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listFindContent(element));
-
- li = element.find('.sortable-item:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listFindContent(element));
-
- $(element).remove();
- });
- });
-
- it('should properly cancel() when the items are inside a transcluded directive', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- '
',
- beforeLiElement,
- '',
- '{{ item }}',
- '
',
- afterLiElement,
- '',
- ' '
- )
- )($rootScope);
-
- $rootScope.$apply(function() {
- $rootScope.opts = {
- items: '> * .sortable-item',
- update: function(e, ui) {
- if (ui.item.sortable.model === 'Two') {
- ui.item.sortable.cancel();
- }
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('.sortable-item:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listFindContent(element));
- // try again
- li = element.find('.sortable-item:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listFindContent(element));
- // try again
- li = element.find('.sortable-item:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listFindContent(element));
-
- li = element.find('.sortable-item:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listFindContent(element));
-
- li = element.find('.sortable-item:eq(2)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listFindContent(element));
-
- $(element).remove();
- });
- });
-
- it('should update model when the items are inside a transcluded directive and sorting between sortables', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- '
',
- beforeDivElement,
- '{{ item }}
',
- afterDivElement,
- '',
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- '
',
- beforeDivElement,
- '{{ item }}
',
- afterDivElement,
- '',
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- connectWith: '.cross-sortable',
- items: '> * .sortable-item'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('.sortable-item:eq(0)');
- var li2 = elementBottom.find('.sortable-item:eq(2)');
- simulateElementDrag(li1, li2, { place: 'above', moves: 100 });
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Top One',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listFindContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listFindContent(elementBottom));
-
- // it seems that it ony likes the last spot
- li1 = elementBottom.find('.sortable-item:eq(2)');
- li2 = elementTop.find('.sortable-item:eq(1)');
- simulateElementDrag(li1, li2, { place: 'below', moves: 100 });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top Three',
- 'Top One'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listFindContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listFindContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should properly cancel() when the items are inside a transcluded directive and sorting between sortables', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- '
',
- beforeDivElement,
- '{{ item }}
',
- afterDivElement,
- '',
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- '
',
- beforeDivElement,
- '{{ item }}
',
- afterDivElement,
- '',
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- connectWith: '.cross-sortable',
- items: '> * .sortable-item',
- update: function(e, ui) {
- if (
- ui.item.sortable.model &&
- typeof ui.item.sortable.model === 'string' &&
- ui.item.sortable.model.indexOf('Two') >= 0
- ) {
- ui.item.sortable.cancel();
- }
- }
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('.sortable-item:eq(1)');
- var li2 = elementBottom.find('.sortable-item:eq(0)');
- simulateElementDrag(li1, li2, { place: 'below', moves: 100 });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listFindContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listFindContent(elementBottom));
- // try again
- li1 = elementBottom.find('.sortable-item:eq(1)');
- li2 = elementTop.find('.sortable-item:eq(1)');
- simulateElementDrag(li1, li2, { place: 'above', moves: 100 });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listFindContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listFindContent(elementBottom));
- // try again
- li1 = elementBottom.find('.sortable-item:eq(1)');
- li2 = elementTop.find('.sortable-item:eq(1)');
- simulateElementDrag(li1, li2, { place: 'above', moves: 100 });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listFindContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listFindContent(elementBottom));
-
- li1 = elementTop.find('.sortable-item:eq(0)');
- li2 = elementBottom.find('.sortable-item:eq(2)');
- simulateElementDrag(li1, li2, { place: 'above', moves: 100 });
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Top One',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listFindContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listFindContent(elementBottom));
-
- // it seems that it ony likes the last spot
- li1 = elementBottom.find('.sortable-item:eq(2)');
- li2 = elementTop.find('.sortable-item:eq(1)');
- simulateElementDrag(li1, li2, { place: 'below', moves: 100 });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top Three',
- 'Top One'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listFindContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listFindContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
- }
-
- [0, 1].forEach(function(useExtraElements) {
- var testDescription = tests.description;
-
- if (useExtraElements) {
- testDescription += ' with extra elements';
- }
-
- describe(testDescription, function() {
- tests(useExtraElements);
- });
- });
-});
diff --git a/test/sortable.e2e.events.spec.js b/test/sortable.e2e.events.spec.js
deleted file mode 100644
index 3aad70e..0000000
--- a/test/sortable.e2e.events.spec.js
+++ /dev/null
@@ -1,212 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
-
- var EXTRA_DY_PERCENTAGE,
- listContent,
- simulateElementDrag,
- hasUndefinedProperties,
- beforeLiElement,
- afterLiElement;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
- listContent = sortableTestHelper.listContent;
- simulateElementDrag = sortableTestHelper.simulateElementDrag;
- hasUndefinedProperties = sortableTestHelper.hasUndefinedProperties;
- beforeLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeLiElement;
- afterLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterLiElement;
- })
- );
-
- tests.description = 'Events related';
- function tests(useExtraElements) {
- var host;
-
- beforeEach(
- inject(function() {
- host = $('
');
- $('body').append(host);
-
- if (!useExtraElements) {
- beforeLiElement = afterLiElement = '';
- }
- })
- );
-
- afterEach(function() {
- host.remove();
- host = null;
- });
-
- it('should emit an event after sorting', function() {
- inject(function($compile, $rootScope) {
- var element, uiParam, emittedUiParam;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.items = ['One', 'Two', 'Three'];
- $rootScope.update = function(e, ui) {
- uiParam = ui;
- };
- $rootScope.onSorting = function(e, ui) {
- emittedUiParam = ui;
- };
- spyOn($rootScope, 'onSorting').and.callThrough();
-
- $rootScope.$on('ui-sortable:moved', $rootScope.onSorting);
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- expect($rootScope.onSorting).toHaveBeenCalled();
- expect(uiParam).toEqual(emittedUiParam);
-
- $(element).remove();
- });
- });
-
- it('should emit an event after sorting between sortables of different scopes', function() {
- inject(function($compile, $rootScope) {
- var elementTop,
- elementBottom,
- wrapperTop,
- wrapperBottom,
- wrapperTopScope,
- wrapperBottomScope,
- itemsTop,
- itemsBottom;
- wrapperTopScope = $rootScope.$new();
- wrapperBottomScope = $rootScope.$new();
- wrapperTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )(wrapperTopScope);
- wrapperBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )(wrapperBottomScope);
-
- host
- .append(wrapperTop)
- .append(wrapperBottom)
- .append('
');
- $rootScope.$apply(function() {
- wrapperTopScope.itemsTop = itemsTop = [
- 'Top One',
- 'Top Two',
- 'Top Three'
- ];
- wrapperTopScope.opts = {
- connectWith: '.cross-sortable',
- stop: function(e, ui) {
- wrapperTopScope.uiParam = ui;
- }
- };
- wrapperTopScope.onSorting = function(e, ui) {
- wrapperTopScope.emittedUiParam = ui;
- };
- spyOn(wrapperTopScope, 'onSorting').and.callThrough();
- $rootScope.$on('ui-sortable:moved', wrapperTopScope.onSorting);
-
- wrapperBottomScope.itemsBottom = itemsBottom = [
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ];
- wrapperBottomScope.opts = {
- connectWith: '.cross-sortable',
- update: function(e, ui) {
- wrapperBottomScope.uiParam = ui;
- }
- };
- wrapperBottomScope.onSorting = function(e, ui) {
- wrapperBottomScope.emittedUiParam = ui;
- };
- spyOn(wrapperBottomScope, 'onSorting').and.callThrough();
- $rootScope.$on('ui-sortable:moved', wrapperBottomScope.onSorting);
- });
-
- elementTop = wrapperTop.find('> [ui-sortable]');
- elementBottom = wrapperBottom.find('> [ui-sortable]');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect(itemsTop).toEqual(['Top Two', 'Top Three']);
- expect(itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect(itemsTop).toEqual(listContent(elementTop));
- expect(itemsBottom).toEqual(listContent(elementBottom));
-
- expect(wrapperTopScope.onSorting).toHaveBeenCalled();
- expect(wrapperTopScope.uiParam.item).toEqual(
- wrapperTopScope.emittedUiParam.item
- );
-
- expect(wrapperBottomScope.onSorting).toHaveBeenCalled();
- expect(wrapperBottomScope.uiParam.item).toEqual(
- wrapperBottomScope.emittedUiParam.item
- );
-
- $(wrapperBottom).remove();
- $(wrapperTop).remove();
- });
- });
- }
-
- [0, 1].forEach(function(useExtraElements) {
- var testDescription = tests.description;
-
- if (useExtraElements) {
- testDescription += ' with extra elements';
- }
-
- describe(testDescription, function() {
- tests(useExtraElements);
- });
- });
-});
diff --git a/test/sortable.e2e.multi.spec.js b/test/sortable.e2e.multi.spec.js
deleted file mode 100644
index 3d755ba..0000000
--- a/test/sortable.e2e.multi.spec.js
+++ /dev/null
@@ -1,1895 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
-
- var EXTRA_DY_PERCENTAGE,
- listContent,
- listInnerContent,
- simulateElementDrag,
- hasUndefinedProperties,
- beforeLiElement,
- afterLiElement;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
- listContent = sortableTestHelper.listContent;
- listInnerContent = sortableTestHelper.listInnerContent;
- simulateElementDrag = sortableTestHelper.simulateElementDrag;
- hasUndefinedProperties = sortableTestHelper.hasUndefinedProperties;
- beforeLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeLiElement;
- afterLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterLiElement;
- })
- );
-
- tests.description = 'Multiple sortables related';
- function tests(useExtraElements) {
- var host;
-
- beforeEach(
- inject(function() {
- host = $('
');
- $('body').append(host);
-
- if (!useExtraElements) {
- beforeLiElement = afterLiElement = '';
- }
- })
- );
-
- afterEach(function() {
- host.remove();
- host = null;
- });
-
- it('should update model when sorting between sortables', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = { connectWith: '.cross-sortable' };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should update model when sorting between sortables of different scopes', function() {
- inject(function($compile, $rootScope) {
- var elementTop,
- elementBottom,
- wrapperTop,
- wrapperBottom,
- wrapperTopScope,
- wrapperBottomScope,
- itemsTop,
- itemsBottom;
- wrapperTopScope = $rootScope.$new();
- wrapperBottomScope = $rootScope.$new();
- wrapperTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )(wrapperTopScope);
- wrapperBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )(wrapperBottomScope);
-
- host
- .append(wrapperTop)
- .append(wrapperBottom)
- .append('
');
- $rootScope.$apply(function() {
- wrapperTopScope.itemsTop = itemsTop = [
- 'Top One',
- 'Top Two',
- 'Top Three'
- ];
- wrapperBottomScope.itemsBottom = itemsBottom = [
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ];
- $rootScope.opts = { connectWith: '.cross-sortable' };
- });
-
- elementTop = wrapperTop.find('> [ui-sortable]');
- elementBottom = wrapperBottom.find('> [ui-sortable]');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect(itemsTop).toEqual(['Top Two', 'Top Three']);
- expect(itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect(itemsTop).toEqual(listContent(elementTop));
- expect(itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect(itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
- expect(itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect(itemsTop).toEqual(listContent(elementTop));
- expect(itemsBottom).toEqual(listContent(elementBottom));
-
- $(wrapperBottom).remove();
- $(wrapperTop).remove();
- });
- });
-
- it('should update model when sorting a "falsy" item between sortables', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = [0, 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = { connectWith: '.cross-sortable' };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- function parseFalsyValue(value) {
- if (value === '0') {
- return 0;
- }
- return value;
- }
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 0,
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(
- listContent(elementTop).map(parseFalsyValue)
- );
- expect($rootScope.itemsBottom).toEqual(
- listContent(elementBottom).map(parseFalsyValue)
- );
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual(['Top Two', 0, 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(
- listContent(elementTop).map(parseFalsyValue)
- );
- expect($rootScope.itemsBottom).toEqual(
- listContent(elementBottom).map(parseFalsyValue)
- );
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "placeholder" option is used', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- placeholder: 'sortable-item-placeholder',
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "placeholder" option equals the class of items', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- placeholder: 'sortable-item',
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "helper: clone" option is used', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- helper: 'clone',
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "placeholder" and "helper: clone" options are used', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- helper: 'clone',
- placeholder: 'sortable-item-placeholder',
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "helper: function" option is used', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- helper: function(e, item) {
- return item.clone().text('helper');
- },
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "placeholder" and "helper: function" options are used', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- helper: function(e, item) {
- return item.clone().text('helper');
- },
- placeholder: 'sortable-item-placeholder',
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "placeholder" and "helper: function" options are used and a drag is reverted', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- helper: function(e, item) {
- return item.clone().text('helper');
- },
- placeholder: 'sortable-item-placeholder',
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(2)');
- var li2 = elementBottom.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'below',
- action: 'dragAndRevert'
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementTop.find('[ng-repeat]:eq(0)');
- li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementTop.find('[ng-repeat]:eq(2)');
- li2 = elementBottom.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'below',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Top Three',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "helper: function" that returns a list element is used', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- helper: function(e, item) {
- return item;
- },
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should work when "placeholder" and "helper: function" that returns a list element are used', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- helper: function(e, item) {
- return item;
- },
- placeholder: 'sortable-item-placeholder',
- connectWith: '.cross-sortable'
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(0)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should cancel sorting of nodes that contain "Two"', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- connectWith: '.cross-sortable',
- update: function(e, ui) {
- if (
- ui.item.sortable.model &&
- typeof ui.item.sortable.model === 'string' &&
- ui.item.sortable.model.indexOf('Two') >= 0
- ) {
- ui.item.sortable.cancel();
- }
- }
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(1)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementTop.find('[ng-repeat]:eq(0)');
- li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should properly set ui.item.sortable properties', function() {
- inject(function($compile, $rootScope) {
- var elementTop,
- elementBottom,
- updateCallbackExpectations,
- stopCallbackExpectations;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- connectWith: '.cross-sortable',
- update: function(e, ui) {
- if (
- ui.item.sortable.model &&
- typeof ui.item.sortable.model === 'string' &&
- ui.item.sortable.model.indexOf('Two') >= 0
- ) {
- ui.item.sortable.cancel();
- }
- updateCallbackExpectations(ui.item.sortable);
- },
- stop: function(e, ui) {
- stopCallbackExpectations(ui.item.sortable);
- }
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(1)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.model).toEqual('Top Two');
- expect(uiItemSortable.index).toEqual(1);
- expect(uiItemSortable.source.length).toEqual(1);
- expect(uiItemSortable.source[0]).toBe(host.children()[0]);
- expect(uiItemSortable.sourceModel).toBe($rootScope.itemsTop);
- expect(uiItemSortable.isCanceled()).toBe(true);
- expect(uiItemSortable.isCustomHelperUsed()).toBe(false);
-
- expect(uiItemSortable.dropindex).toEqual(1);
- expect(uiItemSortable.droptarget.length).toBe(1);
- expect(uiItemSortable.droptarget[0]).toBe(host.children()[1]);
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsBottom);
- };
- stopCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.received).toBe(true);
- expect(uiItemSortable.moved).toBe(undefined);
- };
- simulateElementDrag(li1, li2, {
- place: 'below',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = stopCallbackExpectations = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.model).toEqual('Bottom Two');
- expect(uiItemSortable.index).toEqual(1);
- expect(uiItemSortable.source.length).toEqual(1);
- expect(uiItemSortable.source[0]).toBe(host.children()[1]);
- expect(uiItemSortable.sourceModel).toBe($rootScope.itemsBottom);
- expect(uiItemSortable.isCanceled()).toBe(true);
- expect(uiItemSortable.isCustomHelperUsed()).toBe(false);
-
- expect(uiItemSortable.dropindex).toEqual(1);
- expect(uiItemSortable.droptarget.length).toBe(1);
- expect(uiItemSortable.droptarget[0]).toBe(host.children()[0]);
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsTop);
- };
- stopCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.received).toBe(true);
- expect(uiItemSortable.moved).toBe(undefined);
- };
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = stopCallbackExpectations = undefined;
-
- li1 = elementTop.find('[ng-repeat]:eq(0)');
- li2 = elementBottom.find('[ng-repeat]:eq(0)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.model).toEqual('Top One');
- expect(uiItemSortable.index).toEqual(0);
- expect(uiItemSortable.source.length).toEqual(1);
- expect(uiItemSortable.source[0]).toBe(host.children()[0]);
- expect(uiItemSortable.sourceModel).toBe($rootScope.itemsTop);
- expect(uiItemSortable.isCanceled()).toBe(false);
- expect(uiItemSortable.isCustomHelperUsed()).toBe(false);
-
- expect(uiItemSortable.dropindex).toEqual(1);
- expect(uiItemSortable.droptarget.length).toBe(1);
- expect(uiItemSortable.droptarget[0]).toBe(host.children()[1]);
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsBottom);
- };
- stopCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.received).toBe(true);
- expect(uiItemSortable.moved).toBe('Top One');
- };
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = stopCallbackExpectations = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.model).toEqual('Top One');
- expect(uiItemSortable.index).toEqual(1);
- expect(uiItemSortable.source.length).toEqual(1);
- expect(uiItemSortable.source[0]).toBe(host.children()[1]);
- expect(uiItemSortable.sourceModel).toBe($rootScope.itemsBottom);
- expect(uiItemSortable.isCanceled()).toBe(false);
- expect(uiItemSortable.isCustomHelperUsed()).toBe(false);
-
- expect(uiItemSortable.dropindex).toEqual(1);
- expect(uiItemSortable.droptarget.length).toBe(1);
- expect(uiItemSortable.droptarget[0]).toBe(host.children()[0]);
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsTop);
- };
- stopCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.received).toBe(true);
- expect(uiItemSortable.moved).toBe('Top One');
- };
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = stopCallbackExpectations = undefined;
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should properly set ui.item.sortable.droptargetModel when using data-ng-model', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom, updateCallbackExpectations;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- connectWith: '.cross-sortable',
- update: function(e, ui) {
- if (
- ui.item.sortable.model &&
- typeof ui.item.sortable.model === 'string' &&
- ui.item.sortable.model.indexOf('Two') >= 0
- ) {
- ui.item.sortable.cancel();
- }
- updateCallbackExpectations(ui.item.sortable);
- }
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(1)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsBottom);
- };
- simulateElementDrag(li1, li2, {
- place: 'below',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsTop);
- };
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementTop.find('[ng-repeat]:eq(0)');
- li2 = elementBottom.find('[ng-repeat]:eq(0)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsBottom);
- };
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsTop);
- };
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should properly set ui.item.sortable.droptargetModel when using data-ui-sortable', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom, updateCallbackExpectations;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- connectWith: '.cross-sortable',
- update: function(e, ui) {
- if (
- ui.item.sortable.model &&
- typeof ui.item.sortable.model === 'string' &&
- ui.item.sortable.model.indexOf('Two') >= 0
- ) {
- ui.item.sortable.cancel();
- }
- updateCallbackExpectations(ui.item.sortable);
- }
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(1)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsBottom);
- };
- simulateElementDrag(li1, li2, {
- place: 'below',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsTop);
- };
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementTop.find('[ng-repeat]:eq(0)');
- li2 = elementBottom.find('[ng-repeat]:eq(0)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsBottom);
- };
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe($rootScope.itemsTop);
- };
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
-
- it('should properly set ui.item.sortable.droptargetModel when sorting between different scopes', function() {
- inject(function($compile, $rootScope) {
- var elementTop,
- elementBottom,
- wrapperTop,
- wrapperBottom,
- wrapperTopScope,
- wrapperBottomScope,
- itemsTop,
- itemsBottom,
- updateCallbackExpectations;
- wrapperTopScope = $rootScope.$new();
- wrapperBottomScope = $rootScope.$new();
- wrapperTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )(wrapperTopScope);
- wrapperBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )(wrapperBottomScope);
-
- host
- .append(wrapperTop)
- .append(wrapperBottom)
- .append('
');
- $rootScope.$apply(function() {
- wrapperTopScope.itemsTop = itemsTop = [
- 'Top One',
- 'Top Two',
- 'Top Three'
- ];
- wrapperBottomScope.itemsBottom = itemsBottom = [
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ];
- $rootScope.opts = {
- connectWith: '.cross-sortable',
- update: function(e, ui) {
- if (
- ui.item.sortable.model &&
- typeof ui.item.sortable.model === 'string' &&
- ui.item.sortable.model.indexOf('Two') >= 0
- ) {
- ui.item.sortable.cancel();
- }
- updateCallbackExpectations(ui.item.sortable);
- }
- };
- });
-
- elementTop = wrapperTop.find('> [ui-sortable]');
- elementBottom = wrapperBottom.find('> [ui-sortable]');
-
- var li1 = elementTop.find('[ng-repeat]:eq(1)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe(itemsBottom);
- };
- simulateElementDrag(li1, li2, {
- place: 'below',
- extradx: -20,
- extrady: -11
- });
- expect(itemsTop).toEqual(['Top One', 'Top Two', 'Top Three']);
- expect(itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect(itemsTop).toEqual(listContent(elementTop));
- expect(itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe(itemsTop);
- };
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect(itemsTop).toEqual(['Top One', 'Top Two', 'Top Three']);
- expect(itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect(itemsTop).toEqual(listContent(elementTop));
- expect(itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementTop.find('[ng-repeat]:eq(0)');
- li2 = elementBottom.find('[ng-repeat]:eq(0)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe(itemsBottom);
- };
- simulateElementDrag(li1, li2, 'below');
- expect(itemsTop).toEqual(['Top Two', 'Top Three']);
- expect(itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect(itemsTop).toEqual(listContent(elementTop));
- expect(itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- updateCallbackExpectations = function(uiItemSortable) {
- expect(uiItemSortable.droptargetModel).toBe(itemsTop);
- };
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect(itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
- expect(itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect(itemsTop).toEqual(listContent(elementTop));
- expect(itemsBottom).toEqual(listContent(elementBottom));
- updateCallbackExpectations = undefined;
-
- $(wrapperTop).remove();
- $(wrapperBottom).remove();
- });
- });
-
- it('should properly free ui.item.sortable object', function() {
- inject(function($compile, $rootScope) {
- var elementTop, elementBottom, uiItem, uiItemSortable_Destroy;
- elementTop = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- elementBottom = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
- $rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
- $rootScope.opts = {
- connectWith: '.cross-sortable',
- start: function(e, ui) {
- uiItem = ui.item;
- spyOn(ui.item.sortable, '_destroy').and.callThrough();
- uiItemSortable_Destroy = ui.item.sortable._destroy;
- },
- update: function(e, ui) {
- uiItem.sortable = ui.item.sortable;
- if (
- ui.item.sortable.model &&
- typeof ui.item.sortable.model === 'string' &&
- ui.item.sortable.model.indexOf('Two') >= 0
- ) {
- ui.item.sortable.cancel();
- }
- }
- };
- });
-
- host
- .append(elementTop)
- .append(elementBottom)
- .append('
');
-
- var li1 = elementTop.find('[ng-repeat]:eq(1)');
- var li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- expect(uiItemSortable_Destroy).toHaveBeenCalled();
- expect(hasUndefinedProperties(uiItem.sortable)).toBe(true);
- uiItem = uiItemSortable_Destroy = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top One',
- 'Top Two',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- expect(uiItemSortable_Destroy).toHaveBeenCalled();
- expect(hasUndefinedProperties(uiItem.sortable)).toBe(true);
- uiItem = uiItemSortable_Destroy = undefined;
-
- li1 = elementTop.find('[ng-repeat]:eq(0)');
- li2 = elementBottom.find('[ng-repeat]:eq(0)');
- simulateElementDrag(li1, li2, 'below');
- expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Top One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- expect(uiItemSortable_Destroy).toHaveBeenCalled();
- expect(hasUndefinedProperties(uiItem.sortable)).toBe(true);
- uiItem = uiItemSortable_Destroy = undefined;
-
- li1 = elementBottom.find('[ng-repeat]:eq(1)');
- li2 = elementTop.find('[ng-repeat]:eq(1)');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -20,
- extrady: -11
- });
- expect($rootScope.itemsTop).toEqual([
- 'Top Two',
- 'Top One',
- 'Top Three'
- ]);
- expect($rootScope.itemsBottom).toEqual([
- 'Bottom One',
- 'Bottom Two',
- 'Bottom Three'
- ]);
- expect($rootScope.itemsTop).toEqual(listContent(elementTop));
- expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
- expect(uiItemSortable_Destroy).toHaveBeenCalled();
- expect(hasUndefinedProperties(uiItem.sortable)).toBe(true);
- uiItem = uiItemSortable_Destroy = undefined;
-
- $(elementTop).remove();
- $(elementBottom).remove();
- });
- });
- }
-
- [0, 1].forEach(function(useExtraElements) {
- var testDescription = tests.description;
-
- if (useExtraElements) {
- testDescription += ' with extra elements';
- }
-
- describe(testDescription, function() {
- tests(useExtraElements);
- });
- });
-});
diff --git a/test/sortable.e2e.nested.spec.js b/test/sortable.e2e.nested.spec.js
deleted file mode 100644
index 6759ff3..0000000
--- a/test/sortable.e2e.nested.spec.js
+++ /dev/null
@@ -1,285 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
-
- var EXTRA_DY_PERCENTAGE, listInnerContent, simulateElementDrag;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
- listInnerContent = sortableTestHelper.listInnerContent;
- simulateElementDrag = sortableTestHelper.simulateElementDrag;
- })
- );
-
- describe('Nested sortables related', function() {
- var host;
-
- beforeEach(
- inject(function() {
- host = $('
');
- $('body').append(host);
- })
- );
-
- afterEach(function() {
- host.remove();
- host = null;
- });
-
- it('should update model when sorting between nested sortables', function() {
- inject(function($compile, $rootScope) {
- var elementTree, li1, li2;
-
- elementTree = $compile(
- ''.concat(
- '',
- '',
- '',
- '
{{item.text}} ',
- '
',
- '',
- '{{i.text}} ',
- ' ',
- ' ',
- '
',
- ' ',
- ' ',
- '
'
- )
- )($rootScope);
-
- $rootScope.$apply(function() {
- $rootScope.items = [
- {
- text: 'Item 1',
- items: []
- },
- {
- text: 'Item 2',
- items: [
- { text: 'Item 2.1', items: [] },
- { text: 'Item 2.2', items: [] }
- ]
- }
- ];
-
- $rootScope.sortableOptions = {
- connectWith: '.nested-sortable'
- };
- });
-
- host.append(elementTree);
-
- // this should drag the item out of the list and
- // the item should return back to its original position
- li1 = elementTree.find('.innerList:last').find('li:last');
- li1.simulate('drag', { dx: -200, moves: 30 });
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Item 1', 'Item 2']);
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(listInnerContent(elementTree, '.lvl1ItemContent'));
- expect(
- $rootScope.items[0].items.map(function(x) {
- return x.text;
- })
- ).toEqual([]);
- expect(
- $rootScope.items[0].items.map(function(x) {
- return x.text;
- })
- ).toEqual(
- listInnerContent(
- elementTree.find('.innerList:eq(0)'),
- '.lvl2ItemContent'
- )
- );
- expect(
- $rootScope.items[1].items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Item 2.1', 'Item 2.2']);
- expect(
- $rootScope.items[1].items.map(function(x) {
- return x.text;
- })
- ).toEqual(
- listInnerContent(
- elementTree.find('.innerList:eq(1)'),
- '.lvl2ItemContent'
- )
- );
-
- // this should drag the item from the outter list and
- // drop it to the inner list
- li1 = elementTree.find('> li:first');
- li2 = elementTree.find('.innerList:last').find('li:last');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: 10,
- extrady: -5
- });
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Item 2']);
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(listInnerContent(elementTree, '.lvl1ItemContent'));
- expect(
- $rootScope.items[0].items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Item 2.1', 'Item 1', 'Item 2.2']);
- expect(
- $rootScope.items[0].items.map(function(x) {
- return x.text;
- })
- ).toEqual(
- listInnerContent(
- elementTree.find('.innerList:eq(0)'),
- '.lvl2ItemContent'
- )
- );
-
- // this should drag the item from the inner list and
- // drop it to the outter list
- li1 = elementTree.find('.innerList:last').find('li:last');
- li2 = elementTree.find('> li:first');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -10,
- extrady: -6
- });
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Item 2.2', 'Item 2']);
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(listInnerContent(elementTree, '.lvl1ItemContent'));
- expect(
- $rootScope.items[0].items.map(function(x) {
- return x.text;
- })
- ).toEqual([]);
- expect(
- $rootScope.items[0].items.map(function(x) {
- return x.text;
- })
- ).toEqual(
- listInnerContent(
- elementTree.find('.innerList:eq(0)'),
- '.lvl2ItemContent'
- )
- );
- expect(
- $rootScope.items[1].items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Item 2.1', 'Item 1']);
- expect(
- $rootScope.items[1].items.map(function(x) {
- return x.text;
- })
- ).toEqual(
- listInnerContent(
- elementTree.find('.innerList:eq(1)'),
- '.lvl2ItemContent'
- )
- );
-
- $(elementTree).remove();
- });
- });
-
- it('should update model when sorting between drectly nested sortables', function() {
- inject(function($compile, $rootScope) {
- var elementTree, li1, li2;
-
- elementTree = $compile(
- ''.concat(
- '',
- '
',
- '
{{item.text}}
',
- '
',
- '
',
- '
',
- '
'
- )
- )($rootScope);
-
- $rootScope.$apply(function() {
- $rootScope.items = [
- {
- text: 'Item 1',
- items: [
- { text: 'Item 1.1', items: [] },
- { text: 'Item 1.2', items: [] }
- ]
- },
- {
- text: 'Item 2',
- items: [
- { text: 'Item 2.1', items: [] },
- { text: 'Item 2.2', items: [] }
- ]
- }
- ];
-
- $rootScope.sortableOptions = {};
- $rootScope.innerSortableOptions = {
- connectWith: '.nested-sortable'
- };
- });
-
- host.append(elementTree);
-
- li1 = elementTree.find('.innerList:last');
- li2 = elementTree.find('.innerList:first');
- simulateElementDrag(li1, li2, {
- place: 'above',
- extradx: -10,
- extrady: -6
- });
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Item 2', 'Item 1']);
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(listInnerContent(elementTree, '.lvl1ItemContent'));
-
- $(elementTree).remove();
- });
- });
- });
-});
diff --git a/test/sortable.e2e.spec.js b/test/sortable.e2e.spec.js
deleted file mode 100644
index ff2168f..0000000
--- a/test/sortable.e2e.spec.js
+++ /dev/null
@@ -1,997 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
-
- var EXTRA_DY_PERCENTAGE,
- listContent,
- listInnerContent,
- beforeLiElement,
- afterLiElement;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
- listContent = sortableTestHelper.listContent;
- listInnerContent = sortableTestHelper.listInnerContent;
- beforeLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.beforeLiElement;
- afterLiElement =
- sortableTestHelper.extraElements &&
- sortableTestHelper.extraElements.afterLiElement;
- })
- );
-
- tests.description = 'Drag & Drop simulation';
- function tests(useExtraElements) {
- var host;
-
- beforeEach(
- inject(function() {
- host = $('
');
- $('body').append(host);
-
- if (!useExtraElements) {
- beforeLiElement = afterLiElement = '';
- }
- })
- );
-
- afterEach(function() {
- host.remove();
- host = null;
- });
-
- it('should update model when order changes', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should not allow sorting of "locked" nodes', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item.text }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- items: '> .sortable'
- };
- $rootScope.items = [
- { text: 'One', sortable: true },
- { text: 'Two', sortable: true },
- { text: 'Three', sortable: false },
- { text: 'Four', sortable: true }
- ];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(2)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(['One', 'Two', 'Three', 'Four']);
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(['One', 'Three', 'Four', 'Two']);
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Four', 'One', 'Three', 'Two']);
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(3)');
- dy = -(2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(['Four', 'Two', 'One', 'Three']);
- expect(
- $rootScope.items.map(function(x) {
- return x.text;
- })
- ).toEqual(listContent(element));
-
- // also placing right above the locked node seems a bit harder !?!?
-
- $(element).remove();
- });
- });
-
- it('should work when "placeholder" option is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- placeholder: 'sortable-item-placeholder'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "placeholder" option equals the class of items', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- placeholder: 'sortable-item'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "placeholder" option equals the class of items [data-ng-repeat]', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- placeholder: 'sortable-item'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[data-ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[data-ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should continue to work after a drag is reverted', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- placeholder: 'sortable-item'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "handle" option is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- 'H {{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- handle: '.handle'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.find('.handle').simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.find('.handle').simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- $(element).remove();
- });
- });
-
- it('should properly remove elements after a sorting', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- 'H {{ item }} X ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- handle: '.handle'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
-
- $rootScope.remove = function(item, itemIndex) {
- $rootScope.items.splice(itemIndex, 1);
- };
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.find('.handle').simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- li.find('.removeButton').click();
- expect($rootScope.items).toEqual(['One', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.find('.handle').simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- li.find('.removeButton').click();
- expect($rootScope.items).toEqual(['One']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- $(element).remove();
- });
- });
-
- it('should properly remove elements after a drag is reverted', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- 'H {{ item }} X ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- handle: '.handle'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
-
- $rootScope.remove = function(item, itemIndex) {
- $rootScope.items.splice(itemIndex, 1);
- };
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.find('.handle').simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- li.find('.removeButton').click();
- expect($rootScope.items).toEqual(['Two', 'Three']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.find('.handle').simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'Two']);
- expect($rootScope.items).toEqual(listInnerContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: clone" option is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: 'clone'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: clone" option is used and a drag is reverted', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: 'clone'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: clone" and "appendTo [selector]" options are used together', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: 'clone',
- appendTo: 'body'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: clone" and "appendTo [element]" options are used together', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: 'clone',
- appendTo: document.body
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: clone" and "appendTo [jQuery object]" options are used together', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: 'clone',
- appendTo: angular.element(document.body)
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(2)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: clone" and "placeholder" options are used together.', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: 'clone',
- placeholder: 'sortable-item'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: function" option is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- return item.clone().text('helper');
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(1)');
- var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Three', 'One', 'Two']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: function" option is used and a drag is reverted', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- return item.clone().text('helper');
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: function" and "placeholder" options are used together.', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- return item.clone().text('helper');
- },
- placeholder: 'sortable-item'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: function" that returns a list element is used', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- return item;
- }
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
-
- it('should work when "helper: function" that returns a list element and "placeholder" options are used together.', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile(
- ''.concat(
- '',
- beforeLiElement,
- '{{ item }} ',
- afterLiElement,
- ' '
- )
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.opts = {
- helper: function(e, item) {
- return item;
- },
- placeholder: 'sortable-item'
- };
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- host.append(element);
-
- var li = element.find('[ng-repeat]:eq(0)');
- var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(0)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('dragAndRevert', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'Three', 'One']);
- expect($rootScope.items).toEqual(listContent(element));
-
- li = element.find('[ng-repeat]:eq(1)');
- dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
- li.simulate('drag', { dy: dy });
- expect($rootScope.items).toEqual(['Two', 'One', 'Three']);
- expect($rootScope.items).toEqual(listContent(element));
-
- $(element).remove();
- });
- });
- }
-
- [0, 1].forEach(function(useExtraElements) {
- var testDescription = tests.description;
-
- if (useExtraElements) {
- testDescription += ' with extra elements';
- }
-
- describe(testDescription, function() {
- tests(useExtraElements);
- });
- });
-});
diff --git a/test/sortable.spec.js b/test/sortable.spec.js
deleted file mode 100644
index a4bbb9d..0000000
--- a/test/sortable.spec.js
+++ /dev/null
@@ -1,475 +0,0 @@
-'use strict';
-
-describe('uiSortable', function() {
- beforeEach(
- module(function($compileProvider) {
- if (typeof $compileProvider.debugInfoEnabled === 'function') {
- $compileProvider.debugInfoEnabled(false);
- }
- })
- );
-
- // Ensure the sortable angular module is loaded
- beforeEach(module('ui.sortable'));
- beforeEach(module('ui.sortable.testHelper'));
-
- var listContent;
-
- beforeEach(
- inject(function(sortableTestHelper) {
- listContent = sortableTestHelper.listContent;
- })
- );
-
- describe('Simple use', function() {
- it('should have a ui-sortable class', function() {
- inject(function($compile, $rootScope) {
- var element;
- element = $compile('')($rootScope);
- expect(element.hasClass('ui-sortable')).toBeTruthy();
- });
- });
-
- it('should log that ngModel was not provided', function() {
- inject(function($compile, $rootScope, $log) {
- var element;
- element = $compile(
- ''
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- expect($log.info.logs.length).toEqual(1);
- expect($log.info.logs[0].length).toEqual(2);
- expect($log.info.logs[0][0]).toEqual(
- 'ui.sortable: ngModel not provided!'
- );
- });
- });
-
- it('should log an error about jQuery dependency', function() {
- inject(function($compile, $rootScope, $log) {
- var oldAngularElementFn = angular.element.fn;
- var mockJQliteFn = $({}, angular.element.fn, true);
- mockJQliteFn.jquery = null;
- angular.element.fn = mockJQliteFn;
-
- var element;
- element = $compile(
- ''
- )($rootScope);
- $rootScope.$apply(function() {
- $rootScope.items = ['One', 'Two', 'Three'];
- });
-
- expect($log.error.logs.length).toEqual(1);
- expect($log.error.logs[0].length).toEqual(1);
- expect($log.error.logs[0][0]).toEqual(
- 'ui.sortable: jQuery should be included before AngularJS!'
- );
-
- angular.element.fn = oldAngularElementFn;
- });
- });
-
- it('should refresh sortable properly after an apply', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- element = $compile(
- ''
- )(childScope);
- $rootScope.$apply(function() {
- childScope.items = ['One', 'Two', 'Three'];
- });
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
-
- expect(childScope.items).toEqual(['One', 'Two', 'Three']);
- expect(childScope.items).toEqual(listContent(element));
- });
- });
-
- it('should refresh sortable properly after an apply [data-* anotation]', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- element = $compile(
- ''
- )(childScope);
- $rootScope.$apply(function() {
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {};
- });
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
-
- expect(childScope.items).toEqual(['One', 'Two', 'Three']);
- expect(childScope.items).toEqual(listContent(element));
- });
- });
-
- it('should not refresh sortable if destroyed', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- element = $compile(
- ''
- )(childScope);
- $rootScope.$apply(function() {
- childScope.items = ['One', 'Two', 'Three'];
- });
-
- element.remove(element.firstChild);
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- it('should not refresh sortable if destroyed [data-* anotation]', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- element = $compile(
- ''
- )(childScope);
- $rootScope.$apply(function() {
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {};
- });
-
- element.remove(element.firstChild);
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- it('should not try to apply options to a destroyed sortable', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- element = $compile(
- ''
- )(childScope);
- $rootScope.$apply(function() {
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {
- update: function() {}
- };
-
- element.remove(element.firstChild);
- });
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- it('should not try to apply options to a destroyed sortable [data-* anotation]', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- element = $compile(
- ''
- )(childScope);
- $rootScope.$apply(function() {
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {
- update: function() {}
- };
-
- element.remove(element.firstChild);
- });
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- describe('items option', function() {
- it('should use a default items that is restricted to ng-repeat items', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- element = $compile(
- ''
- )(childScope);
-
- $rootScope.$digest();
-
- expect(element.find('ul').sortable('option', 'items')).toBe(
- '> [ng-repeat],> [data-ng-repeat],> [x-ng-repeat]'
- );
-
- element.remove(element.firstChild);
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- it('should not change items option if given', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- childScope.opts = {
- items: '> .class'
- };
-
- element = $compile(
- ''
- )(childScope);
-
- $rootScope.$digest();
-
- expect(element.find('ul').sortable('option', 'items')).toBe(
- '> .class'
- );
-
- element.remove(element.firstChild);
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- it('should restrict to ng-items if items is removed after initialization', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- childScope.opts = {
- items: '> .class'
- };
-
- element = $compile(
- ''
- )(childScope);
-
- $rootScope.$digest();
-
- $rootScope.$apply(function() {
- childScope.opts = { items: null };
- });
-
- expect(element.find('ul').sortable('option', 'items')).toBe(
- '> [ng-repeat],> [data-ng-repeat],> [x-ng-repeat]'
- );
-
- element.remove(element.firstChild);
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- it('should properly reset the value of a deleted option', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- childScope.opts = {
- opacity: 0.7,
- placeholder: 'phClass',
- update: function() {}
- };
-
- element = $compile(
- ''
- )(childScope);
- var $sortableElement = element.find('[data-ui-sortable]');
-
- expect($sortableElement.sortable('option', 'opacity')).toBe(0.7);
- expect($sortableElement.sortable('option', 'placeholder')).toBe(
- 'phClass'
- );
- expect(typeof $sortableElement.sortable('option', 'update')).toBe(
- 'function'
- );
-
- $rootScope.$digest();
-
- $rootScope.$apply(function() {
- delete childScope.opts.opacity;
- });
-
- expect($sortableElement.sortable('option', 'opacity')).toBe(false);
- expect($sortableElement.sortable('option', 'placeholder')).toBe(
- 'phClass'
- );
- expect(typeof $sortableElement.sortable('option', 'update')).toBe(
- 'function'
- );
-
- $rootScope.$digest();
-
- $rootScope.$apply(function() {
- childScope.opts = {};
- });
-
- expect($sortableElement.sortable('option', 'opacity')).toBe(false);
- expect($sortableElement.sortable('option', 'placeholder')).toBe(
- false
- );
- expect(typeof $sortableElement.sortable('option', 'update')).toBe(
- 'function'
- );
-
- element.remove(element.firstChild);
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- it('should not initialize a disabled sortable', function() {
- inject(function($compile, $rootScope) {
- var element;
- var childScope = $rootScope.$new();
- spyOn(angular.element.fn, 'sortable');
-
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {
- disabled: true
- };
- element = $compile(
- ''
- )(childScope);
-
- expect(angular.element.fn.sortable).not.toHaveBeenCalled();
- });
- });
-
- it('should lazily initialize a latelly enabled sortable (set disabled = false)', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- spyOn(angular.element.fn, 'sortable');
-
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {
- disabled: true
- };
- element = $compile(
- ''
- )(childScope);
-
- expect(angular.element.fn.sortable).not.toHaveBeenCalled();
-
- $rootScope.$apply(function() {
- childScope.opts.disabled = false;
- });
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
-
- expect(angular.element.fn.sortable).toHaveBeenCalled();
- });
- });
-
- it('should lazily initialize a sortable enabled in $timeout (set disabled = false)', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- spyOn(angular.element.fn, 'sortable');
-
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {
- disabled: true
- };
- element = $compile(
- ''
- )(childScope);
-
- expect(angular.element.fn.sortable).not.toHaveBeenCalled();
-
- $timeout(function() {
- childScope.opts.disabled = false;
- });
-
- $timeout(function() {
- expect(angular.element.fn.sortable).toHaveBeenCalled();
- });
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
-
- it('should lazily initialize a latelly enabled sortable (delete disabled option)', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- spyOn(angular.element.fn, 'sortable');
-
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {
- disabled: true
- };
- element = $compile(
- ''
- )(childScope);
-
- expect(angular.element.fn.sortable).not.toHaveBeenCalled();
-
- $rootScope.$apply(function() {
- childScope.opts = {};
- });
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
-
- expect(angular.element.fn.sortable).toHaveBeenCalled();
- });
- });
-
- it('should lazily initialize a sortable enabled in $timeout (delete disabled option)', function() {
- inject(function($compile, $rootScope, $timeout) {
- var element;
- var childScope = $rootScope.$new();
- spyOn(angular.element.fn, 'sortable');
-
- childScope.items = ['One', 'Two', 'Three'];
- childScope.opts = {
- disabled: true
- };
- element = $compile(
- ''
- )(childScope);
-
- expect(angular.element.fn.sortable).not.toHaveBeenCalled();
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
-
- $timeout(function() {
- childScope.opts = {};
- });
-
- $timeout(function() {
- expect(angular.element.fn.sortable).toHaveBeenCalled();
- });
-
- expect(function() {
- $timeout.flush();
- }).not.toThrow();
- });
- });
- });
- });
-});
diff --git a/test/sortable.test-directives.js b/test/sortable.test-directives.js
deleted file mode 100644
index 8186789..0000000
--- a/test/sortable.test-directives.js
+++ /dev/null
@@ -1,52 +0,0 @@
-'use strict';
-
-angular
- .module('ui.sortable.testDirectives', [])
- .directive('uiSortableSimpleTestDirective', function() {
- return {
- restrict: 'AE',
- scope: true,
- require: '?ngModel',
- template:
- 'Directive: !!!
',
- link: function(scope, element, attrs) {
- scope.$watch(attrs.ngModel, function(value) {
- scope.text = value;
- });
- }
- };
- })
- .directive('uiSortableDestroyableTestDirective', function() {
- return {
- restrict: 'AE',
- scope: true,
- require: '?ngModel',
- template:
- '$destroy(able) Directive: !!!
',
- link: function(scope, element, attrs) {
- scope.$watch(attrs.ngModel, function(value) {
- scope.text = value;
- });
-
- element.bind('$destroy', function() {
- element.html('');
- });
- }
- };
- })
- .directive('uiSortableTransclusionTestDirective', function() {
- return {
- restrict: 'E',
- transclude: true,
- scope: true,
- template:
- '' +
- '
Transclusion Directive ' +
- '
' +
- '
' +
- ' ' +
- '
' +
- '
' +
- '
'
- };
- });
diff --git a/test/sortable.test-helper.js b/test/sortable.test-helper.js
deleted file mode 100644
index 0cd4a24..0000000
--- a/test/sortable.test-helper.js
+++ /dev/null
@@ -1,136 +0,0 @@
-'use strict';
-
-angular
- .module('ui.sortable.testHelper', [])
- .factory('sortableTestHelper', function() {
- var EXTRA_DY_PERCENTAGE = 0.25;
-
- function listContent(list, contentSelector) {
- if (!contentSelector) {
- contentSelector = '[ng-repeat], [data-ng-repeat], [x-ng-repeat]';
- }
-
- if (list && list.length) {
- return list
- .children(contentSelector)
- .map(function() {
- return this.innerHTML;
- })
- .toArray();
- }
- return [];
- }
-
- function listFindContent(list, contentSelector) {
- if (!contentSelector) {
- contentSelector = '.sortable-item';
- }
-
- if (list && list.length) {
- return list
- .find(contentSelector)
- .map(function() {
- return this.innerHTML;
- })
- .toArray();
- }
- return [];
- }
-
- function listInnerContent(list, contentSelector) {
- if (!contentSelector) {
- contentSelector = '.itemContent';
- }
-
- if (list && list.length) {
- return list
- .children()
- .map(function() {
- return $(this)
- .find(contentSelector)
- .html();
- })
- .toArray();
- }
- return [];
- }
-
- function simulateElementDrag(draggedElement, dropTarget, options) {
- var dragOptions = {
- dx: dropTarget.position().left - draggedElement.position().left,
- dy: dropTarget.position().top - draggedElement.position().top,
- moves: 30,
- action: (options && options.action) || 'drag'
- };
-
- if (options === 'above') {
- options = { place: 'above' };
- } else if (options === 'below') {
- options = { place: 'below' };
- }
-
- if (typeof options === 'object') {
- if ('place' in options) {
- if (options.place === 'above') {
- dragOptions.dy -=
- EXTRA_DY_PERCENTAGE * draggedElement.outerHeight();
- } else if (options.place === 'below') {
- dragOptions.dy +=
- EXTRA_DY_PERCENTAGE * draggedElement.outerHeight();
- }
- }
-
- if (isFinite(options.dx)) {
- dragOptions.dx = options.dx;
- }
- if (isFinite(options.dy)) {
- dragOptions.dy = options.dy;
- }
-
- if (isFinite(options.extrady)) {
- dragOptions.dy += options.extrady;
- }
-
- if (isFinite(options.extradx)) {
- dragOptions.dx += options.extradx;
- }
-
- if (isFinite(options.moves) && options.moves > 0) {
- dragOptions.moves = options.moves;
- }
- }
-
- draggedElement.simulate(dragOptions.action, dragOptions);
- }
-
- function hasUndefinedProperties(testObject) {
- return (
- testObject &&
- Object.keys(testObject).filter(function(key) {
- return (
- testObject.hasOwnProperty(key) && testObject[key] !== undefined
- );
- }).length === 0
- );
- }
-
- return {
- EXTRA_DY_PERCENTAGE: EXTRA_DY_PERCENTAGE,
- listContent: listContent,
- listFindContent: listFindContent,
- listInnerContent: listInnerContent,
- simulateElementDrag: simulateElementDrag,
- hasUndefinedProperties: hasUndefinedProperties,
- extraElements: {
- beforeLiElement: 'extra element ',
- afterLiElement: 'extra element ',
- beforeTrElement: 'extra element ',
- afterTrElement: 'extra element ',
- beforeDivElement: 'extra element
',
- afterDivElement: 'extra element
'
- }
- };
- })
- .controller('dummyController', function($scope) {
- $scope.testItems = ['One', 'Two', 'Three'];
- });
diff --git a/test/sortable.tests.css b/test/sortable.tests.css
deleted file mode 100644
index 6601ca0..0000000
--- a/test/sortable.tests.css
+++ /dev/null
@@ -1,12 +0,0 @@
-.inline-block {
- display: inline-block;
-}
-
-.floatleft,
-.cross-sortable {
- float: left;
-}
-
-.clear {
- clear: both;
-}
\ No newline at end of file
diff --git a/vendor/jquery-ui.css b/vendor/jquery-ui.css
new file mode 100644
index 0000000..294452f
--- /dev/null
+++ b/vendor/jquery-ui.css
@@ -0,0 +1,1311 @@
+/*! jQuery UI - v1.12.1 - 2016-09-14
+* http://jqueryui.com
+* Includes: core.css, accordion.css, autocomplete.css, menu.css, button.css, controlgroup.css, checkboxradio.css, datepicker.css, dialog.css, draggable.css, resizable.css, progressbar.css, selectable.css, selectmenu.css, slider.css, sortable.css, spinner.css, tabs.css, tooltip.css, theme.css
+* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=highlight_soft&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=flat&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=glass&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=glass&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=glass&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=glass&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
+* Copyright jQuery Foundation and other contributors; Licensed MIT */
+
+/* Layout helpers
+----------------------------------*/
+.ui-helper-hidden {
+ display: none;
+}
+.ui-helper-hidden-accessible {
+ border: 0;
+ clip: rect(0 0 0 0);
+ height: 1px;
+ margin: -1px;
+ overflow: hidden;
+ padding: 0;
+ position: absolute;
+ width: 1px;
+}
+.ui-helper-reset {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: 0;
+ line-height: 1.3;
+ text-decoration: none;
+ font-size: 100%;
+ list-style: none;
+}
+.ui-helper-clearfix:before,
+.ui-helper-clearfix:after {
+ content: "";
+ display: table;
+ border-collapse: collapse;
+}
+.ui-helper-clearfix:after {
+ clear: both;
+}
+.ui-helper-zfix {
+ width: 100%;
+ height: 100%;
+ top: 0;
+ left: 0;
+ position: absolute;
+ opacity: 0;
+ filter:Alpha(Opacity=0); /* support: IE8 */
+}
+
+.ui-front {
+ z-index: 100;
+}
+
+
+/* Interaction Cues
+----------------------------------*/
+.ui-state-disabled {
+ cursor: default !important;
+ pointer-events: none;
+}
+
+
+/* Icons
+----------------------------------*/
+.ui-icon {
+ display: inline-block;
+ vertical-align: middle;
+ margin-top: -.25em;
+ position: relative;
+ text-indent: -99999px;
+ overflow: hidden;
+ background-repeat: no-repeat;
+}
+
+.ui-widget-icon-block {
+ left: 50%;
+ margin-left: -8px;
+ display: block;
+}
+
+/* Misc visuals
+----------------------------------*/
+
+/* Overlays */
+.ui-widget-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+}
+.ui-accordion .ui-accordion-header {
+ display: block;
+ cursor: pointer;
+ position: relative;
+ margin: 2px 0 0 0;
+ padding: .5em .5em .5em .7em;
+ font-size: 100%;
+}
+.ui-accordion .ui-accordion-content {
+ padding: 1em 2.2em;
+ border-top: 0;
+ overflow: auto;
+}
+.ui-autocomplete {
+ position: absolute;
+ top: 0;
+ left: 0;
+ cursor: default;
+}
+.ui-menu {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ display: block;
+ outline: 0;
+}
+.ui-menu .ui-menu {
+ position: absolute;
+}
+.ui-menu .ui-menu-item {
+ margin: 0;
+ cursor: pointer;
+ /* support: IE10, see #8844 */
+ list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
+}
+.ui-menu .ui-menu-item-wrapper {
+ position: relative;
+ padding: 3px 1em 3px .4em;
+}
+.ui-menu .ui-menu-divider {
+ margin: 5px 0;
+ height: 0;
+ font-size: 0;
+ line-height: 0;
+ border-width: 1px 0 0 0;
+}
+.ui-menu .ui-state-focus,
+.ui-menu .ui-state-active {
+ margin: -1px;
+}
+
+/* icon support */
+.ui-menu-icons {
+ position: relative;
+}
+.ui-menu-icons .ui-menu-item-wrapper {
+ padding-left: 2em;
+}
+
+/* left-aligned */
+.ui-menu .ui-icon {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: .2em;
+ margin: auto 0;
+}
+
+/* right-aligned */
+.ui-menu .ui-menu-icon {
+ left: auto;
+ right: 0;
+}
+.ui-button {
+ padding: .4em 1em;
+ display: inline-block;
+ position: relative;
+ line-height: normal;
+ margin-right: .1em;
+ cursor: pointer;
+ vertical-align: middle;
+ text-align: center;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+
+ /* Support: IE <= 11 */
+ overflow: visible;
+}
+
+.ui-button,
+.ui-button:link,
+.ui-button:visited,
+.ui-button:hover,
+.ui-button:active {
+ text-decoration: none;
+}
+
+/* to make room for the icon, a width needs to be set here */
+.ui-button-icon-only {
+ width: 2em;
+ box-sizing: border-box;
+ text-indent: -9999px;
+ white-space: nowrap;
+}
+
+/* no icon support for input elements */
+input.ui-button.ui-button-icon-only {
+ text-indent: 0;
+}
+
+/* button icon element(s) */
+.ui-button-icon-only .ui-icon {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ margin-top: -8px;
+ margin-left: -8px;
+}
+
+.ui-button.ui-icon-notext .ui-icon {
+ padding: 0;
+ width: 2.1em;
+ height: 2.1em;
+ text-indent: -9999px;
+ white-space: nowrap;
+
+}
+
+input.ui-button.ui-icon-notext .ui-icon {
+ width: auto;
+ height: auto;
+ text-indent: 0;
+ white-space: normal;
+ padding: .4em 1em;
+}
+
+/* workarounds */
+/* Support: Firefox 5 - 40 */
+input.ui-button::-moz-focus-inner,
+button.ui-button::-moz-focus-inner {
+ border: 0;
+ padding: 0;
+}
+.ui-controlgroup {
+ vertical-align: middle;
+ display: inline-block;
+}
+.ui-controlgroup > .ui-controlgroup-item {
+ float: left;
+ margin-left: 0;
+ margin-right: 0;
+}
+.ui-controlgroup > .ui-controlgroup-item:focus,
+.ui-controlgroup > .ui-controlgroup-item.ui-visual-focus {
+ z-index: 9999;
+}
+.ui-controlgroup-vertical > .ui-controlgroup-item {
+ display: block;
+ float: none;
+ width: 100%;
+ margin-top: 0;
+ margin-bottom: 0;
+ text-align: left;
+}
+.ui-controlgroup-vertical .ui-controlgroup-item {
+ box-sizing: border-box;
+}
+.ui-controlgroup .ui-controlgroup-label {
+ padding: .4em 1em;
+}
+.ui-controlgroup .ui-controlgroup-label span {
+ font-size: 80%;
+}
+.ui-controlgroup-horizontal .ui-controlgroup-label + .ui-controlgroup-item {
+ border-left: none;
+}
+.ui-controlgroup-vertical .ui-controlgroup-label + .ui-controlgroup-item {
+ border-top: none;
+}
+.ui-controlgroup-horizontal .ui-controlgroup-label.ui-widget-content {
+ border-right: none;
+}
+.ui-controlgroup-vertical .ui-controlgroup-label.ui-widget-content {
+ border-bottom: none;
+}
+
+/* Spinner specific style fixes */
+.ui-controlgroup-vertical .ui-spinner-input {
+
+ /* Support: IE8 only, Android < 4.4 only */
+ width: 75%;
+ width: calc( 100% - 2.4em );
+}
+.ui-controlgroup-vertical .ui-spinner .ui-spinner-up {
+ border-top-style: solid;
+}
+
+.ui-checkboxradio-label .ui-icon-background {
+ box-shadow: inset 1px 1px 1px #ccc;
+ border-radius: .12em;
+ border: none;
+}
+.ui-checkboxradio-radio-label .ui-icon-background {
+ width: 16px;
+ height: 16px;
+ border-radius: 1em;
+ overflow: visible;
+ border: none;
+}
+.ui-checkboxradio-radio-label.ui-checkboxradio-checked .ui-icon,
+.ui-checkboxradio-radio-label.ui-checkboxradio-checked:hover .ui-icon {
+ background-image: none;
+ width: 8px;
+ height: 8px;
+ border-width: 4px;
+ border-style: solid;
+}
+.ui-checkboxradio-disabled {
+ pointer-events: none;
+}
+.ui-datepicker {
+ width: 17em;
+ padding: .2em .2em 0;
+ display: none;
+}
+.ui-datepicker .ui-datepicker-header {
+ position: relative;
+ padding: .2em 0;
+}
+.ui-datepicker .ui-datepicker-prev,
+.ui-datepicker .ui-datepicker-next {
+ position: absolute;
+ top: 2px;
+ width: 1.8em;
+ height: 1.8em;
+}
+.ui-datepicker .ui-datepicker-prev-hover,
+.ui-datepicker .ui-datepicker-next-hover {
+ top: 1px;
+}
+.ui-datepicker .ui-datepicker-prev {
+ left: 2px;
+}
+.ui-datepicker .ui-datepicker-next {
+ right: 2px;
+}
+.ui-datepicker .ui-datepicker-prev-hover {
+ left: 1px;
+}
+.ui-datepicker .ui-datepicker-next-hover {
+ right: 1px;
+}
+.ui-datepicker .ui-datepicker-prev span,
+.ui-datepicker .ui-datepicker-next span {
+ display: block;
+ position: absolute;
+ left: 50%;
+ margin-left: -8px;
+ top: 50%;
+ margin-top: -8px;
+}
+.ui-datepicker .ui-datepicker-title {
+ margin: 0 2.3em;
+ line-height: 1.8em;
+ text-align: center;
+}
+.ui-datepicker .ui-datepicker-title select {
+ font-size: 1em;
+ margin: 1px 0;
+}
+.ui-datepicker select.ui-datepicker-month,
+.ui-datepicker select.ui-datepicker-year {
+ width: 45%;
+}
+.ui-datepicker table {
+ width: 100%;
+ font-size: .9em;
+ border-collapse: collapse;
+ margin: 0 0 .4em;
+}
+.ui-datepicker th {
+ padding: .7em .3em;
+ text-align: center;
+ font-weight: bold;
+ border: 0;
+}
+.ui-datepicker td {
+ border: 0;
+ padding: 1px;
+}
+.ui-datepicker td span,
+.ui-datepicker td a {
+ display: block;
+ padding: .2em;
+ text-align: right;
+ text-decoration: none;
+}
+.ui-datepicker .ui-datepicker-buttonpane {
+ background-image: none;
+ margin: .7em 0 0 0;
+ padding: 0 .2em;
+ border-left: 0;
+ border-right: 0;
+ border-bottom: 0;
+}
+.ui-datepicker .ui-datepicker-buttonpane button {
+ float: right;
+ margin: .5em .2em .4em;
+ cursor: pointer;
+ padding: .2em .6em .3em .6em;
+ width: auto;
+ overflow: visible;
+}
+.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current {
+ float: left;
+}
+
+/* with multiple calendars */
+.ui-datepicker.ui-datepicker-multi {
+ width: auto;
+}
+.ui-datepicker-multi .ui-datepicker-group {
+ float: left;
+}
+.ui-datepicker-multi .ui-datepicker-group table {
+ width: 95%;
+ margin: 0 auto .4em;
+}
+.ui-datepicker-multi-2 .ui-datepicker-group {
+ width: 50%;
+}
+.ui-datepicker-multi-3 .ui-datepicker-group {
+ width: 33.3%;
+}
+.ui-datepicker-multi-4 .ui-datepicker-group {
+ width: 25%;
+}
+.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,
+.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header {
+ border-left-width: 0;
+}
+.ui-datepicker-multi .ui-datepicker-buttonpane {
+ clear: left;
+}
+.ui-datepicker-row-break {
+ clear: both;
+ width: 100%;
+ font-size: 0;
+}
+
+/* RTL support */
+.ui-datepicker-rtl {
+ direction: rtl;
+}
+.ui-datepicker-rtl .ui-datepicker-prev {
+ right: 2px;
+ left: auto;
+}
+.ui-datepicker-rtl .ui-datepicker-next {
+ left: 2px;
+ right: auto;
+}
+.ui-datepicker-rtl .ui-datepicker-prev:hover {
+ right: 1px;
+ left: auto;
+}
+.ui-datepicker-rtl .ui-datepicker-next:hover {
+ left: 1px;
+ right: auto;
+}
+.ui-datepicker-rtl .ui-datepicker-buttonpane {
+ clear: right;
+}
+.ui-datepicker-rtl .ui-datepicker-buttonpane button {
+ float: left;
+}
+.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,
+.ui-datepicker-rtl .ui-datepicker-group {
+ float: right;
+}
+.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,
+.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header {
+ border-right-width: 0;
+ border-left-width: 1px;
+}
+
+/* Icons */
+.ui-datepicker .ui-icon {
+ display: block;
+ text-indent: -99999px;
+ overflow: hidden;
+ background-repeat: no-repeat;
+ left: .5em;
+ top: .3em;
+}
+.ui-dialog {
+ position: absolute;
+ top: 0;
+ left: 0;
+ padding: .2em;
+ outline: 0;
+}
+.ui-dialog .ui-dialog-titlebar {
+ padding: .4em 1em;
+ position: relative;
+}
+.ui-dialog .ui-dialog-title {
+ float: left;
+ margin: .1em 0;
+ white-space: nowrap;
+ width: 90%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.ui-dialog .ui-dialog-titlebar-close {
+ position: absolute;
+ right: .3em;
+ top: 50%;
+ width: 20px;
+ margin: -10px 0 0 0;
+ padding: 1px;
+ height: 20px;
+}
+.ui-dialog .ui-dialog-content {
+ position: relative;
+ border: 0;
+ padding: .5em 1em;
+ background: none;
+ overflow: auto;
+}
+.ui-dialog .ui-dialog-buttonpane {
+ text-align: left;
+ border-width: 1px 0 0 0;
+ background-image: none;
+ margin-top: .5em;
+ padding: .3em 1em .5em .4em;
+}
+.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
+ float: right;
+}
+.ui-dialog .ui-dialog-buttonpane button {
+ margin: .5em .4em .5em 0;
+ cursor: pointer;
+}
+.ui-dialog .ui-resizable-n {
+ height: 2px;
+ top: 0;
+}
+.ui-dialog .ui-resizable-e {
+ width: 2px;
+ right: 0;
+}
+.ui-dialog .ui-resizable-s {
+ height: 2px;
+ bottom: 0;
+}
+.ui-dialog .ui-resizable-w {
+ width: 2px;
+ left: 0;
+}
+.ui-dialog .ui-resizable-se,
+.ui-dialog .ui-resizable-sw,
+.ui-dialog .ui-resizable-ne,
+.ui-dialog .ui-resizable-nw {
+ width: 7px;
+ height: 7px;
+}
+.ui-dialog .ui-resizable-se {
+ right: 0;
+ bottom: 0;
+}
+.ui-dialog .ui-resizable-sw {
+ left: 0;
+ bottom: 0;
+}
+.ui-dialog .ui-resizable-ne {
+ right: 0;
+ top: 0;
+}
+.ui-dialog .ui-resizable-nw {
+ left: 0;
+ top: 0;
+}
+.ui-draggable .ui-dialog-titlebar {
+ cursor: move;
+}
+.ui-draggable-handle {
+ -ms-touch-action: none;
+ touch-action: none;
+}
+.ui-resizable {
+ position: relative;
+}
+.ui-resizable-handle {
+ position: absolute;
+ font-size: 0.1px;
+ display: block;
+ -ms-touch-action: none;
+ touch-action: none;
+}
+.ui-resizable-disabled .ui-resizable-handle,
+.ui-resizable-autohide .ui-resizable-handle {
+ display: none;
+}
+.ui-resizable-n {
+ cursor: n-resize;
+ height: 7px;
+ width: 100%;
+ top: -5px;
+ left: 0;
+}
+.ui-resizable-s {
+ cursor: s-resize;
+ height: 7px;
+ width: 100%;
+ bottom: -5px;
+ left: 0;
+}
+.ui-resizable-e {
+ cursor: e-resize;
+ width: 7px;
+ right: -5px;
+ top: 0;
+ height: 100%;
+}
+.ui-resizable-w {
+ cursor: w-resize;
+ width: 7px;
+ left: -5px;
+ top: 0;
+ height: 100%;
+}
+.ui-resizable-se {
+ cursor: se-resize;
+ width: 12px;
+ height: 12px;
+ right: 1px;
+ bottom: 1px;
+}
+.ui-resizable-sw {
+ cursor: sw-resize;
+ width: 9px;
+ height: 9px;
+ left: -5px;
+ bottom: -5px;
+}
+.ui-resizable-nw {
+ cursor: nw-resize;
+ width: 9px;
+ height: 9px;
+ left: -5px;
+ top: -5px;
+}
+.ui-resizable-ne {
+ cursor: ne-resize;
+ width: 9px;
+ height: 9px;
+ right: -5px;
+ top: -5px;
+}
+.ui-progressbar {
+ height: 2em;
+ text-align: left;
+ overflow: hidden;
+}
+.ui-progressbar .ui-progressbar-value {
+ margin: -1px;
+ height: 100%;
+}
+.ui-progressbar .ui-progressbar-overlay {
+ background: url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw==");
+ height: 100%;
+ filter: alpha(opacity=25); /* support: IE8 */
+ opacity: 0.25;
+}
+.ui-progressbar-indeterminate .ui-progressbar-value {
+ background-image: none;
+}
+.ui-selectable {
+ -ms-touch-action: none;
+ touch-action: none;
+}
+.ui-selectable-helper {
+ position: absolute;
+ z-index: 100;
+ border: 1px dotted black;
+}
+.ui-selectmenu-menu {
+ padding: 0;
+ margin: 0;
+ position: absolute;
+ top: 0;
+ left: 0;
+ display: none;
+}
+.ui-selectmenu-menu .ui-menu {
+ overflow: auto;
+ overflow-x: hidden;
+ padding-bottom: 1px;
+}
+.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup {
+ font-size: 1em;
+ font-weight: bold;
+ line-height: 1.5;
+ padding: 2px 0.4em;
+ margin: 0.5em 0 0 0;
+ height: auto;
+ border: 0;
+}
+.ui-selectmenu-open {
+ display: block;
+}
+.ui-selectmenu-text {
+ display: block;
+ margin-right: 20px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.ui-selectmenu-button.ui-button {
+ text-align: left;
+ white-space: nowrap;
+ width: 14em;
+}
+.ui-selectmenu-icon.ui-icon {
+ float: right;
+ margin-top: 0;
+}
+.ui-slider {
+ position: relative;
+ text-align: left;
+}
+.ui-slider .ui-slider-handle {
+ position: absolute;
+ z-index: 2;
+ width: 1.2em;
+ height: 1.2em;
+ cursor: default;
+ -ms-touch-action: none;
+ touch-action: none;
+}
+.ui-slider .ui-slider-range {
+ position: absolute;
+ z-index: 1;
+ font-size: .7em;
+ display: block;
+ border: 0;
+ background-position: 0 0;
+}
+
+/* support: IE8 - See #6727 */
+.ui-slider.ui-state-disabled .ui-slider-handle,
+.ui-slider.ui-state-disabled .ui-slider-range {
+ filter: inherit;
+}
+
+.ui-slider-horizontal {
+ height: .8em;
+}
+.ui-slider-horizontal .ui-slider-handle {
+ top: -.3em;
+ margin-left: -.6em;
+}
+.ui-slider-horizontal .ui-slider-range {
+ top: 0;
+ height: 100%;
+}
+.ui-slider-horizontal .ui-slider-range-min {
+ left: 0;
+}
+.ui-slider-horizontal .ui-slider-range-max {
+ right: 0;
+}
+
+.ui-slider-vertical {
+ width: .8em;
+ height: 100px;
+}
+.ui-slider-vertical .ui-slider-handle {
+ left: -.3em;
+ margin-left: 0;
+ margin-bottom: -.6em;
+}
+.ui-slider-vertical .ui-slider-range {
+ left: 0;
+ width: 100%;
+}
+.ui-slider-vertical .ui-slider-range-min {
+ bottom: 0;
+}
+.ui-slider-vertical .ui-slider-range-max {
+ top: 0;
+}
+.ui-sortable-handle {
+ -ms-touch-action: none;
+ touch-action: none;
+}
+.ui-spinner {
+ position: relative;
+ display: inline-block;
+ overflow: hidden;
+ padding: 0;
+ vertical-align: middle;
+}
+.ui-spinner-input {
+ border: none;
+ background: none;
+ color: inherit;
+ padding: .222em 0;
+ margin: .2em 0;
+ vertical-align: middle;
+ margin-left: .4em;
+ margin-right: 2em;
+}
+.ui-spinner-button {
+ width: 1.6em;
+ height: 50%;
+ font-size: .5em;
+ padding: 0;
+ margin: 0;
+ text-align: center;
+ position: absolute;
+ cursor: default;
+ display: block;
+ overflow: hidden;
+ right: 0;
+}
+/* more specificity required here to override default borders */
+.ui-spinner a.ui-spinner-button {
+ border-top-style: none;
+ border-bottom-style: none;
+ border-right-style: none;
+}
+.ui-spinner-up {
+ top: 0;
+}
+.ui-spinner-down {
+ bottom: 0;
+}
+.ui-tabs {
+ position: relative;/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
+ padding: .2em;
+}
+.ui-tabs .ui-tabs-nav {
+ margin: 0;
+ padding: .2em .2em 0;
+}
+.ui-tabs .ui-tabs-nav li {
+ list-style: none;
+ float: left;
+ position: relative;
+ top: 0;
+ margin: 1px .2em 0 0;
+ border-bottom-width: 0;
+ padding: 0;
+ white-space: nowrap;
+}
+.ui-tabs .ui-tabs-nav .ui-tabs-anchor {
+ float: left;
+ padding: .5em 1em;
+ text-decoration: none;
+}
+.ui-tabs .ui-tabs-nav li.ui-tabs-active {
+ margin-bottom: -1px;
+ padding-bottom: 1px;
+}
+.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,
+.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,
+.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor {
+ cursor: text;
+}
+.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor {
+ cursor: pointer;
+}
+.ui-tabs .ui-tabs-panel {
+ display: block;
+ border-width: 0;
+ padding: 1em 1.4em;
+ background: none;
+}
+.ui-tooltip {
+ padding: 8px;
+ position: absolute;
+ z-index: 9999;
+ max-width: 300px;
+}
+body .ui-tooltip {
+ border-width: 2px;
+}
+/* Component containers
+----------------------------------*/
+.ui-widget {
+ font-family: Verdana,Arial,sans-serif;
+ font-size: 1.1em;
+}
+.ui-widget .ui-widget {
+ font-size: 1em;
+}
+.ui-widget input,
+.ui-widget select,
+.ui-widget textarea,
+.ui-widget button {
+ font-family: Verdana,Arial,sans-serif;
+ font-size: 1em;
+}
+.ui-widget.ui-widget-content {
+ border: 1px solid #d3d3d3;
+}
+.ui-widget-content {
+ border: 1px solid #aaaaaa;
+ background: #ffffff;
+ color: #222222;
+}
+.ui-widget-content a {
+ color: #222222;
+}
+.ui-widget-header {
+ border: 1px solid #aaaaaa;
+ background: #cccccc url("images/ui-bg_highlight-soft_75_cccccc_1x100.png") 50% 50% repeat-x;
+ color: #222222;
+ font-weight: bold;
+}
+.ui-widget-header a {
+ color: #222222;
+}
+
+/* Interaction states
+----------------------------------*/
+.ui-state-default,
+.ui-widget-content .ui-state-default,
+.ui-widget-header .ui-state-default,
+.ui-button,
+
+/* We use html here because we need a greater specificity to make sure disabled
+works properly when clicked or hovered */
+html .ui-button.ui-state-disabled:hover,
+html .ui-button.ui-state-disabled:active {
+ border: 1px solid #d3d3d3;
+ background: #e6e6e6 url("images/ui-bg_glass_75_e6e6e6_1x400.png") 50% 50% repeat-x;
+ font-weight: normal;
+ color: #555555;
+}
+.ui-state-default a,
+.ui-state-default a:link,
+.ui-state-default a:visited,
+a.ui-button,
+a:link.ui-button,
+a:visited.ui-button,
+.ui-button {
+ color: #555555;
+ text-decoration: none;
+}
+.ui-state-hover,
+.ui-widget-content .ui-state-hover,
+.ui-widget-header .ui-state-hover,
+.ui-state-focus,
+.ui-widget-content .ui-state-focus,
+.ui-widget-header .ui-state-focus,
+.ui-button:hover,
+.ui-button:focus {
+ border: 1px solid #999999;
+ background: #dadada url("images/ui-bg_glass_75_dadada_1x400.png") 50% 50% repeat-x;
+ font-weight: normal;
+ color: #212121;
+}
+.ui-state-hover a,
+.ui-state-hover a:hover,
+.ui-state-hover a:link,
+.ui-state-hover a:visited,
+.ui-state-focus a,
+.ui-state-focus a:hover,
+.ui-state-focus a:link,
+.ui-state-focus a:visited,
+a.ui-button:hover,
+a.ui-button:focus {
+ color: #212121;
+ text-decoration: none;
+}
+
+.ui-visual-focus {
+ box-shadow: 0 0 3px 1px rgb(94, 158, 214);
+}
+.ui-state-active,
+.ui-widget-content .ui-state-active,
+.ui-widget-header .ui-state-active,
+a.ui-button:active,
+.ui-button:active,
+.ui-button.ui-state-active:hover {
+ border: 1px solid #aaaaaa;
+ background: #ffffff url("images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x;
+ font-weight: normal;
+ color: #212121;
+}
+.ui-icon-background,
+.ui-state-active .ui-icon-background {
+ border: #aaaaaa;
+ background-color: #212121;
+}
+.ui-state-active a,
+.ui-state-active a:link,
+.ui-state-active a:visited {
+ color: #212121;
+ text-decoration: none;
+}
+
+/* Interaction Cues
+----------------------------------*/
+.ui-state-highlight,
+.ui-widget-content .ui-state-highlight,
+.ui-widget-header .ui-state-highlight {
+ border: 1px solid #fcefa1;
+ background: #fbf9ee url("images/ui-bg_glass_55_fbf9ee_1x400.png") 50% 50% repeat-x;
+ color: #363636;
+}
+.ui-state-checked {
+ border: 1px solid #fcefa1;
+ background: #fbf9ee;
+}
+.ui-state-highlight a,
+.ui-widget-content .ui-state-highlight a,
+.ui-widget-header .ui-state-highlight a {
+ color: #363636;
+}
+.ui-state-error,
+.ui-widget-content .ui-state-error,
+.ui-widget-header .ui-state-error {
+ border: 1px solid #cd0a0a;
+ background: #fef1ec url("images/ui-bg_glass_95_fef1ec_1x400.png") 50% 50% repeat-x;
+ color: #cd0a0a;
+}
+.ui-state-error a,
+.ui-widget-content .ui-state-error a,
+.ui-widget-header .ui-state-error a {
+ color: #cd0a0a;
+}
+.ui-state-error-text,
+.ui-widget-content .ui-state-error-text,
+.ui-widget-header .ui-state-error-text {
+ color: #cd0a0a;
+}
+.ui-priority-primary,
+.ui-widget-content .ui-priority-primary,
+.ui-widget-header .ui-priority-primary {
+ font-weight: bold;
+}
+.ui-priority-secondary,
+.ui-widget-content .ui-priority-secondary,
+.ui-widget-header .ui-priority-secondary {
+ opacity: .7;
+ filter:Alpha(Opacity=70); /* support: IE8 */
+ font-weight: normal;
+}
+.ui-state-disabled,
+.ui-widget-content .ui-state-disabled,
+.ui-widget-header .ui-state-disabled {
+ opacity: .35;
+ filter:Alpha(Opacity=35); /* support: IE8 */
+ background-image: none;
+}
+.ui-state-disabled .ui-icon {
+ filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */
+}
+
+/* Icons
+----------------------------------*/
+
+/* states and images */
+.ui-icon {
+ width: 16px;
+ height: 16px;
+}
+.ui-icon,
+.ui-widget-content .ui-icon {
+ background-image: url("images/ui-icons_222222_256x240.png");
+}
+.ui-widget-header .ui-icon {
+ background-image: url("images/ui-icons_222222_256x240.png");
+}
+.ui-state-hover .ui-icon,
+.ui-state-focus .ui-icon,
+.ui-button:hover .ui-icon,
+.ui-button:focus .ui-icon {
+ background-image: url("images/ui-icons_454545_256x240.png");
+}
+.ui-state-active .ui-icon,
+.ui-button:active .ui-icon {
+ background-image: url("images/ui-icons_454545_256x240.png");
+}
+.ui-state-highlight .ui-icon,
+.ui-button .ui-state-highlight.ui-icon {
+ background-image: url("images/ui-icons_2e83ff_256x240.png");
+}
+.ui-state-error .ui-icon,
+.ui-state-error-text .ui-icon {
+ background-image: url("images/ui-icons_cd0a0a_256x240.png");
+}
+.ui-button .ui-icon {
+ background-image: url("images/ui-icons_888888_256x240.png");
+}
+
+/* positioning */
+.ui-icon-blank { background-position: 16px 16px; }
+.ui-icon-caret-1-n { background-position: 0 0; }
+.ui-icon-caret-1-ne { background-position: -16px 0; }
+.ui-icon-caret-1-e { background-position: -32px 0; }
+.ui-icon-caret-1-se { background-position: -48px 0; }
+.ui-icon-caret-1-s { background-position: -65px 0; }
+.ui-icon-caret-1-sw { background-position: -80px 0; }
+.ui-icon-caret-1-w { background-position: -96px 0; }
+.ui-icon-caret-1-nw { background-position: -112px 0; }
+.ui-icon-caret-2-n-s { background-position: -128px 0; }
+.ui-icon-caret-2-e-w { background-position: -144px 0; }
+.ui-icon-triangle-1-n { background-position: 0 -16px; }
+.ui-icon-triangle-1-ne { background-position: -16px -16px; }
+.ui-icon-triangle-1-e { background-position: -32px -16px; }
+.ui-icon-triangle-1-se { background-position: -48px -16px; }
+.ui-icon-triangle-1-s { background-position: -65px -16px; }
+.ui-icon-triangle-1-sw { background-position: -80px -16px; }
+.ui-icon-triangle-1-w { background-position: -96px -16px; }
+.ui-icon-triangle-1-nw { background-position: -112px -16px; }
+.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
+.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
+.ui-icon-arrow-1-n { background-position: 0 -32px; }
+.ui-icon-arrow-1-ne { background-position: -16px -32px; }
+.ui-icon-arrow-1-e { background-position: -32px -32px; }
+.ui-icon-arrow-1-se { background-position: -48px -32px; }
+.ui-icon-arrow-1-s { background-position: -65px -32px; }
+.ui-icon-arrow-1-sw { background-position: -80px -32px; }
+.ui-icon-arrow-1-w { background-position: -96px -32px; }
+.ui-icon-arrow-1-nw { background-position: -112px -32px; }
+.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
+.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
+.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
+.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
+.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
+.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
+.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
+.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
+.ui-icon-arrowthick-1-n { background-position: 1px -48px; }
+.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
+.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
+.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
+.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
+.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
+.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
+.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
+.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
+.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
+.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
+.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
+.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
+.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
+.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
+.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
+.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
+.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
+.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
+.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
+.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
+.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
+.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
+.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
+.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
+.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
+.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
+.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
+.ui-icon-arrow-4 { background-position: 0 -80px; }
+.ui-icon-arrow-4-diag { background-position: -16px -80px; }
+.ui-icon-extlink { background-position: -32px -80px; }
+.ui-icon-newwin { background-position: -48px -80px; }
+.ui-icon-refresh { background-position: -64px -80px; }
+.ui-icon-shuffle { background-position: -80px -80px; }
+.ui-icon-transfer-e-w { background-position: -96px -80px; }
+.ui-icon-transferthick-e-w { background-position: -112px -80px; }
+.ui-icon-folder-collapsed { background-position: 0 -96px; }
+.ui-icon-folder-open { background-position: -16px -96px; }
+.ui-icon-document { background-position: -32px -96px; }
+.ui-icon-document-b { background-position: -48px -96px; }
+.ui-icon-note { background-position: -64px -96px; }
+.ui-icon-mail-closed { background-position: -80px -96px; }
+.ui-icon-mail-open { background-position: -96px -96px; }
+.ui-icon-suitcase { background-position: -112px -96px; }
+.ui-icon-comment { background-position: -128px -96px; }
+.ui-icon-person { background-position: -144px -96px; }
+.ui-icon-print { background-position: -160px -96px; }
+.ui-icon-trash { background-position: -176px -96px; }
+.ui-icon-locked { background-position: -192px -96px; }
+.ui-icon-unlocked { background-position: -208px -96px; }
+.ui-icon-bookmark { background-position: -224px -96px; }
+.ui-icon-tag { background-position: -240px -96px; }
+.ui-icon-home { background-position: 0 -112px; }
+.ui-icon-flag { background-position: -16px -112px; }
+.ui-icon-calendar { background-position: -32px -112px; }
+.ui-icon-cart { background-position: -48px -112px; }
+.ui-icon-pencil { background-position: -64px -112px; }
+.ui-icon-clock { background-position: -80px -112px; }
+.ui-icon-disk { background-position: -96px -112px; }
+.ui-icon-calculator { background-position: -112px -112px; }
+.ui-icon-zoomin { background-position: -128px -112px; }
+.ui-icon-zoomout { background-position: -144px -112px; }
+.ui-icon-search { background-position: -160px -112px; }
+.ui-icon-wrench { background-position: -176px -112px; }
+.ui-icon-gear { background-position: -192px -112px; }
+.ui-icon-heart { background-position: -208px -112px; }
+.ui-icon-star { background-position: -224px -112px; }
+.ui-icon-link { background-position: -240px -112px; }
+.ui-icon-cancel { background-position: 0 -128px; }
+.ui-icon-plus { background-position: -16px -128px; }
+.ui-icon-plusthick { background-position: -32px -128px; }
+.ui-icon-minus { background-position: -48px -128px; }
+.ui-icon-minusthick { background-position: -64px -128px; }
+.ui-icon-close { background-position: -80px -128px; }
+.ui-icon-closethick { background-position: -96px -128px; }
+.ui-icon-key { background-position: -112px -128px; }
+.ui-icon-lightbulb { background-position: -128px -128px; }
+.ui-icon-scissors { background-position: -144px -128px; }
+.ui-icon-clipboard { background-position: -160px -128px; }
+.ui-icon-copy { background-position: -176px -128px; }
+.ui-icon-contact { background-position: -192px -128px; }
+.ui-icon-image { background-position: -208px -128px; }
+.ui-icon-video { background-position: -224px -128px; }
+.ui-icon-script { background-position: -240px -128px; }
+.ui-icon-alert { background-position: 0 -144px; }
+.ui-icon-info { background-position: -16px -144px; }
+.ui-icon-notice { background-position: -32px -144px; }
+.ui-icon-help { background-position: -48px -144px; }
+.ui-icon-check { background-position: -64px -144px; }
+.ui-icon-bullet { background-position: -80px -144px; }
+.ui-icon-radio-on { background-position: -96px -144px; }
+.ui-icon-radio-off { background-position: -112px -144px; }
+.ui-icon-pin-w { background-position: -128px -144px; }
+.ui-icon-pin-s { background-position: -144px -144px; }
+.ui-icon-play { background-position: 0 -160px; }
+.ui-icon-pause { background-position: -16px -160px; }
+.ui-icon-seek-next { background-position: -32px -160px; }
+.ui-icon-seek-prev { background-position: -48px -160px; }
+.ui-icon-seek-end { background-position: -64px -160px; }
+.ui-icon-seek-start { background-position: -80px -160px; }
+/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
+.ui-icon-seek-first { background-position: -80px -160px; }
+.ui-icon-stop { background-position: -96px -160px; }
+.ui-icon-eject { background-position: -112px -160px; }
+.ui-icon-volume-off { background-position: -128px -160px; }
+.ui-icon-volume-on { background-position: -144px -160px; }
+.ui-icon-power { background-position: 0 -176px; }
+.ui-icon-signal-diag { background-position: -16px -176px; }
+.ui-icon-signal { background-position: -32px -176px; }
+.ui-icon-battery-0 { background-position: -48px -176px; }
+.ui-icon-battery-1 { background-position: -64px -176px; }
+.ui-icon-battery-2 { background-position: -80px -176px; }
+.ui-icon-battery-3 { background-position: -96px -176px; }
+.ui-icon-circle-plus { background-position: 0 -192px; }
+.ui-icon-circle-minus { background-position: -16px -192px; }
+.ui-icon-circle-close { background-position: -32px -192px; }
+.ui-icon-circle-triangle-e { background-position: -48px -192px; }
+.ui-icon-circle-triangle-s { background-position: -64px -192px; }
+.ui-icon-circle-triangle-w { background-position: -80px -192px; }
+.ui-icon-circle-triangle-n { background-position: -96px -192px; }
+.ui-icon-circle-arrow-e { background-position: -112px -192px; }
+.ui-icon-circle-arrow-s { background-position: -128px -192px; }
+.ui-icon-circle-arrow-w { background-position: -144px -192px; }
+.ui-icon-circle-arrow-n { background-position: -160px -192px; }
+.ui-icon-circle-zoomin { background-position: -176px -192px; }
+.ui-icon-circle-zoomout { background-position: -192px -192px; }
+.ui-icon-circle-check { background-position: -208px -192px; }
+.ui-icon-circlesmall-plus { background-position: 0 -208px; }
+.ui-icon-circlesmall-minus { background-position: -16px -208px; }
+.ui-icon-circlesmall-close { background-position: -32px -208px; }
+.ui-icon-squaresmall-plus { background-position: -48px -208px; }
+.ui-icon-squaresmall-minus { background-position: -64px -208px; }
+.ui-icon-squaresmall-close { background-position: -80px -208px; }
+.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
+.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
+.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
+.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
+.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
+.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
+
+
+/* Misc visuals
+----------------------------------*/
+
+/* Corner radius */
+.ui-corner-all,
+.ui-corner-top,
+.ui-corner-left,
+.ui-corner-tl {
+ border-top-left-radius: 4px;
+}
+.ui-corner-all,
+.ui-corner-top,
+.ui-corner-right,
+.ui-corner-tr {
+ border-top-right-radius: 4px;
+}
+.ui-corner-all,
+.ui-corner-bottom,
+.ui-corner-left,
+.ui-corner-bl {
+ border-bottom-left-radius: 4px;
+}
+.ui-corner-all,
+.ui-corner-bottom,
+.ui-corner-right,
+.ui-corner-br {
+ border-bottom-right-radius: 4px;
+}
+
+/* Overlays */
+.ui-widget-overlay {
+ background: #aaaaaa;
+ opacity: .3;
+ filter: Alpha(Opacity=30); /* support: IE8 */
+}
+.ui-widget-shadow {
+ -webkit-box-shadow: -8px -8px 8px #aaaaaa;
+ box-shadow: -8px -8px 8px #aaaaaa;
+}
diff --git a/vendor/jquery-ui.js b/vendor/jquery-ui.js
new file mode 100644
index 0000000..0213552
--- /dev/null
+++ b/vendor/jquery-ui.js
@@ -0,0 +1,18706 @@
+/*! jQuery UI - v1.12.1 - 2016-09-14
+* http://jqueryui.com
+* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
+* Copyright jQuery Foundation and other contributors; Licensed MIT */
+
+(function( factory ) {
+ if ( typeof define === "function" && define.amd ) {
+
+ // AMD. Register as an anonymous module.
+ define([ "jquery" ], factory );
+ } else {
+
+ // Browser globals
+ factory( jQuery );
+ }
+}(function( $ ) {
+
+$.ui = $.ui || {};
+
+var version = $.ui.version = "1.12.1";
+
+
+/*!
+ * jQuery UI Widget 1.12.1
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Widget
+//>>group: Core
+//>>description: Provides a factory for creating stateful widgets with a common API.
+//>>docs: http://api.jqueryui.com/jQuery.widget/
+//>>demos: http://jqueryui.com/widget/
+
+
+
+var widgetUuid = 0;
+var widgetSlice = Array.prototype.slice;
+
+$.cleanData = ( function( orig ) {
+ return function( elems ) {
+ var events, elem, i;
+ for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
+ try {
+
+ // Only trigger remove when necessary to save time
+ events = $._data( elem, "events" );
+ if ( events && events.remove ) {
+ $( elem ).triggerHandler( "remove" );
+ }
+
+ // Http://bugs.jquery.com/ticket/8235
+ } catch ( e ) {}
+ }
+ orig( elems );
+ };
+} )( $.cleanData );
+
+$.widget = function( name, base, prototype ) {
+ var existingConstructor, constructor, basePrototype;
+
+ // ProxiedPrototype allows the provided prototype to remain unmodified
+ // so that it can be used as a mixin for multiple widgets (#8876)
+ var proxiedPrototype = {};
+
+ var namespace = name.split( "." )[ 0 ];
+ name = name.split( "." )[ 1 ];
+ var fullName = namespace + "-" + name;
+
+ if ( !prototype ) {
+ prototype = base;
+ base = $.Widget;
+ }
+
+ if ( $.isArray( prototype ) ) {
+ prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
+ }
+
+ // Create selector for plugin
+ $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
+ return !!$.data( elem, fullName );
+ };
+
+ $[ namespace ] = $[ namespace ] || {};
+ existingConstructor = $[ namespace ][ name ];
+ constructor = $[ namespace ][ name ] = function( options, element ) {
+
+ // Allow instantiation without "new" keyword
+ if ( !this._createWidget ) {
+ return new constructor( options, element );
+ }
+
+ // Allow instantiation without initializing for simple inheritance
+ // must use "new" keyword (the code above always passes args)
+ if ( arguments.length ) {
+ this._createWidget( options, element );
+ }
+ };
+
+ // Extend with the existing constructor to carry over any static properties
+ $.extend( constructor, existingConstructor, {
+ version: prototype.version,
+
+ // Copy the object used to create the prototype in case we need to
+ // redefine the widget later
+ _proto: $.extend( {}, prototype ),
+
+ // Track widgets that inherit from this widget in case this widget is
+ // redefined after a widget inherits from it
+ _childConstructors: []
+ } );
+
+ basePrototype = new base();
+
+ // We need to make the options hash a property directly on the new instance
+ // otherwise we'll modify the options hash on the prototype that we're
+ // inheriting from
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
+ $.each( prototype, function( prop, value ) {
+ if ( !$.isFunction( value ) ) {
+ proxiedPrototype[ prop ] = value;
+ return;
+ }
+ proxiedPrototype[ prop ] = ( function() {
+ function _super() {
+ return base.prototype[ prop ].apply( this, arguments );
+ }
+
+ function _superApply( args ) {
+ return base.prototype[ prop ].apply( this, args );
+ }
+
+ return function() {
+ var __super = this._super;
+ var __superApply = this._superApply;
+ var returnValue;
+
+ this._super = _super;
+ this._superApply = _superApply;
+
+ returnValue = value.apply( this, arguments );
+
+ this._super = __super;
+ this._superApply = __superApply;
+
+ return returnValue;
+ };
+ } )();
+ } );
+ constructor.prototype = $.widget.extend( basePrototype, {
+
+ // TODO: remove support for widgetEventPrefix
+ // always use the name + a colon as the prefix, e.g., draggable:start
+ // don't prefix for widgets that aren't DOM-based
+ widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
+ }, proxiedPrototype, {
+ constructor: constructor,
+ namespace: namespace,
+ widgetName: name,
+ widgetFullName: fullName
+ } );
+
+ // If this widget is being redefined then we need to find all widgets that
+ // are inheriting from it and redefine all of them so that they inherit from
+ // the new version of this widget. We're essentially trying to replace one
+ // level in the prototype chain.
+ if ( existingConstructor ) {
+ $.each( existingConstructor._childConstructors, function( i, child ) {
+ var childPrototype = child.prototype;
+
+ // Redefine the child widget using the same prototype that was
+ // originally used, but inherit from the new version of the base
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
+ child._proto );
+ } );
+
+ // Remove the list of existing child constructors from the old constructor
+ // so the old child constructors can be garbage collected
+ delete existingConstructor._childConstructors;
+ } else {
+ base._childConstructors.push( constructor );
+ }
+
+ $.widget.bridge( name, constructor );
+
+ return constructor;
+};
+
+$.widget.extend = function( target ) {
+ var input = widgetSlice.call( arguments, 1 );
+ var inputIndex = 0;
+ var inputLength = input.length;
+ var key;
+ var value;
+
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
+ for ( key in input[ inputIndex ] ) {
+ value = input[ inputIndex ][ key ];
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
+
+ // Clone objects
+ if ( $.isPlainObject( value ) ) {
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
+ $.widget.extend( {}, target[ key ], value ) :
+
+ // Don't extend strings, arrays, etc. with objects
+ $.widget.extend( {}, value );
+
+ // Copy everything else by reference
+ } else {
+ target[ key ] = value;
+ }
+ }
+ }
+ }
+ return target;
+};
+
+$.widget.bridge = function( name, object ) {
+ var fullName = object.prototype.widgetFullName || name;
+ $.fn[ name ] = function( options ) {
+ var isMethodCall = typeof options === "string";
+ var args = widgetSlice.call( arguments, 1 );
+ var returnValue = this;
+
+ if ( isMethodCall ) {
+
+ // If this is an empty collection, we need to have the instance method
+ // return undefined instead of the jQuery instance
+ if ( !this.length && options === "instance" ) {
+ returnValue = undefined;
+ } else {
+ this.each( function() {
+ var methodValue;
+ var instance = $.data( this, fullName );
+
+ if ( options === "instance" ) {
+ returnValue = instance;
+ return false;
+ }
+
+ if ( !instance ) {
+ return $.error( "cannot call methods on " + name +
+ " prior to initialization; " +
+ "attempted to call method '" + options + "'" );
+ }
+
+ if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
+ return $.error( "no such method '" + options + "' for " + name +
+ " widget instance" );
+ }
+
+ methodValue = instance[ options ].apply( instance, args );
+
+ if ( methodValue !== instance && methodValue !== undefined ) {
+ returnValue = methodValue && methodValue.jquery ?
+ returnValue.pushStack( methodValue.get() ) :
+ methodValue;
+ return false;
+ }
+ } );
+ }
+ } else {
+
+ // Allow multiple hashes to be passed on init
+ if ( args.length ) {
+ options = $.widget.extend.apply( null, [ options ].concat( args ) );
+ }
+
+ this.each( function() {
+ var instance = $.data( this, fullName );
+ if ( instance ) {
+ instance.option( options || {} );
+ if ( instance._init ) {
+ instance._init();
+ }
+ } else {
+ $.data( this, fullName, new object( options, this ) );
+ }
+ } );
+ }
+
+ return returnValue;
+ };
+};
+
+$.Widget = function( /* options, element */ ) {};
+$.Widget._childConstructors = [];
+
+$.Widget.prototype = {
+ widgetName: "widget",
+ widgetEventPrefix: "",
+ defaultElement: "