UNPKG

sortable

Version:

sort an array by dragging html elements

217 lines (183 loc) 467 kB
(function(){var require = function (file, cwd) { var resolved = require.resolve(file, cwd || '/'); var mod = require.modules[resolved]; if (!mod) throw new Error( 'Failed to resolve module ' + file + ', tried ' + resolved ); var cached = require.cache[resolved]; var res = cached? cached.exports : mod(); return res; }; require.paths = []; require.modules = {}; require.cache = {}; require.extensions = [".js",".coffee",".json"]; require._core = { 'assert': true, 'events': true, 'fs': true, 'path': true, 'vm': true }; require.resolve = (function () { return function (x, cwd) { if (!cwd) cwd = '/'; if (require._core[x]) return x; var path = require.modules.path(); cwd = path.resolve('/', cwd); var y = cwd || '/'; if (x.match(/^(?:\.\.?\/|\/)/)) { var m = loadAsFileSync(path.resolve(y, x)) || loadAsDirectorySync(path.resolve(y, x)); if (m) return m; } var n = loadNodeModulesSync(x, y); if (n) return n; throw new Error("Cannot find module '" + x + "'"); function loadAsFileSync (x) { x = path.normalize(x); if (require.modules[x]) { return x; } for (var i = 0; i < require.extensions.length; i++) { var ext = require.extensions[i]; if (require.modules[x + ext]) return x + ext; } } function loadAsDirectorySync (x) { x = x.replace(/\/+$/, ''); var pkgfile = path.normalize(x + '/package.json'); if (require.modules[pkgfile]) { var pkg = require.modules[pkgfile](); var b = pkg.browserify; if (typeof b === 'object' && b.main) { var m = loadAsFileSync(path.resolve(x, b.main)); if (m) return m; } else if (typeof b === 'string') { var m = loadAsFileSync(path.resolve(x, b)); if (m) return m; } else if (pkg.main) { var m = loadAsFileSync(path.resolve(x, pkg.main)); if (m) return m; } } return loadAsFileSync(x + '/index'); } function loadNodeModulesSync (x, start) { var dirs = nodeModulesPathsSync(start); for (var i = 0; i < dirs.length; i++) { var dir = dirs[i]; var m = loadAsFileSync(dir + '/' + x); if (m) return m; var n = loadAsDirectorySync(dir + '/' + x); if (n) return n; } var m = loadAsFileSync(x); if (m) return m; } function nodeModulesPathsSync (start) { var parts; if (start === '/') parts = [ '' ]; else parts = path.normalize(start).split('/'); var dirs = []; for (var i = parts.length - 1; i >= 0; i--) { if (parts[i] === 'node_modules') continue; var dir = parts.slice(0, i + 1).join('/') + '/node_modules'; dirs.push(dir); } return dirs; } }; })(); require.alias = function (from, to) { var path = require.modules.path(); var res = null; try { res = require.resolve(from + '/package.json', '/'); } catch (err) { res = require.resolve(from, '/'); } var basedir = path.dirname(res); var keys = (Object.keys || function (obj) { var res = []; for (var key in obj) res.push(key); return res; })(require.modules); for (var i = 0; i < keys.length; i++) { var key = keys[i]; if (key.slice(0, basedir.length + 1) === basedir + '/') { var f = key.slice(basedir.length); require.modules[to + f] = require.modules[basedir + f]; } else if (key === basedir) { require.modules[to] = require.modules[basedir]; } } }; (function () { var process = {}; var global = typeof window !== 'undefined' ? window : {}; var definedProcess = false; require.define = function (filename, fn) { if (!definedProcess && require.modules.__browserify_process) { process = require.modules.__browserify_process(); definedProcess = true; } var dirname = require._core[filename] ? '' : require.modules.path().dirname(filename) ; var require_ = function (file) { var requiredModule = require(file, dirname); var cached = require.cache[require.resolve(file, dirname)]; if (cached && cached.parent === null) { cached.parent = module_; } return requiredModule; }; require_.resolve = function (name) { return require.resolve(name, dirname); }; require_.modules = require.modules; require_.define = require.define; require_.cache = require.cache; var module_ = { id : filename, filename: filename, exports : {}, loaded : false, parent: null }; require.modules[filename] = function () { require.cache[filename] = module_; fn.call( module_.exports, require_, module_, module_.exports, dirname, filename, process, global ); module_.loaded = true; return module_.exports; }; }; })(); require.define("path",Function(['require','module','exports','__dirname','__filename','process','global'],"function filter (xs, fn) {\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (fn(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length; i >= 0; i--) {\n var last = parts[i];\n if (last == '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Regex to split a filename into [*, dir, basename, ext]\n// posix version\nvar splitPathRe = /^(.+\\/(?!$)|\\/)?((?:.+?)?(\\.[^.]*)?)$/;\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\nvar resolvedPath = '',\n resolvedAbsolute = false;\n\nfor (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0)\n ? arguments[i]\n : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string' || !path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n}\n\n// At this point the path should be resolved to a full absolute path, but\n// handle relative paths to be safe (might happen when process.cwd() fails)\n\n// Normalize the path\nresolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\nvar isAbsolute = path.charAt(0) === '/',\n trailingSlash = path.slice(-1) === '/';\n\n// Normalize the path\npath = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n \n return (isAbsolute ? '/' : '') + path;\n};\n\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n return p && typeof p === 'string';\n }).join('/'));\n};\n\n\nexports.dirname = function(path) {\n var dir = splitPathRe.exec(path)[1] || '';\n var isWindows = false;\n if (!dir) {\n // No dirname\n return '.';\n } else if (dir.length === 1 ||\n (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {\n // It is just a slash or a drive letter with a slash\n return dir;\n } else {\n // It is a full dirname, strip trailing slash\n return dir.substring(0, dir.length - 1);\n }\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPathRe.exec(path)[2] || '';\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPathRe.exec(path)[3] || '';\n};\n\n//@ sourceURL=path" )); require.define("__browserify_process",Function(['require','module','exports','__dirname','__filename','process','global'],"var process = module.exports = {};\n\nprocess.nextTick = (function () {\n var canSetImmediate = typeof window !== 'undefined'\n && window.setImmediate;\n var canPost = typeof window !== 'undefined'\n && window.postMessage && window.addEventListener\n ;\n\n if (canSetImmediate) {\n return function (f) { return window.setImmediate(f) };\n }\n\n if (canPost) {\n var queue = [];\n window.addEventListener('message', function (ev) {\n if (ev.source === window && ev.data === 'browserify-tick') {\n ev.stopPropagation();\n if (queue.length > 0) {\n var fn = queue.shift();\n fn();\n }\n }\n }, true);\n\n return function nextTick(fn) {\n queue.push(fn);\n window.postMessage('browserify-tick', '*');\n };\n }\n\n return function nextTick(fn) {\n setTimeout(fn, 0);\n };\n})();\n\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\n\nprocess.binding = function (name) {\n if (name === 'evals') return (require)('vm')\n else throw new Error('No such module. (Possibly not yet loaded)')\n};\n\n(function () {\n var cwd = '/';\n var path;\n process.cwd = function () { return cwd };\n process.chdir = function (dir) {\n if (!path) path = require('path');\n cwd = path.resolve(dir, cwd);\n };\n})();\n\n//@ sourceURL=__browserify_process" )); require.define("/node_modules/hyperscript/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/node_modules/hyperscript/package.json" )); require.define("/node_modules/hyperscript/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],";(function () {\n\nfunction h() {\n var args = [].slice.call(arguments), e = null\n function item (l) {\n var r\n function parseClass (string) {\n var m = string.split(/([\\.#]?[a-zA-Z0-9_-]+)/)\n m.forEach(function (v) {\n var s = v.substring(1,v.length)\n if(!v) return \n if(!e)\n e = document.createElement(v)\n else if (v[0] === '.')\n e.classList.add(s)\n else if (v[0] === '#')\n e.setAttribute('id', s)\n })\n }\n\n if(l == null)\n ;\n else if('string' === typeof l) {\n if(!e)\n parseClass(l)\n else\n e.appendChild(r = document.createTextNode(l))\n }\n else if('number' === typeof l \n || 'boolean' === typeof l\n || l instanceof Date \n || l instanceof RegExp ) {\n e.appendChild(r = document.createTextNode(l.toString()))\n }\n //there might be a better way to handle this...\n else if (Array.isArray(l))\n l.forEach(item)\n else if(l instanceof Node)\n e.appendChild(r = l)\n else if(l instanceof Text)\n e.appendChild(r = l)\n else if ('object' === typeof l) {\n for (var k in l) {\n if('function' === typeof l[k]) {\n if(/^on\\w+/.test(k)) {\n e.addEventListener(k.substring(2), l[k])\n } else {\n e[k] = l[k]()\n l[k](function (v) {\n e[k] = v\n })\n }\n }\n else if(k === 'style') {\n for (var s in l[k]) (function(s, v) {\n if('function' === typeof v) {\n e.style.setProperty(s, v())\n v(function (val) {\n e.style.setProperty(s, val)\n })\n } else\n e.style.setProperty(s, l[k][s])\n })(s, l[k][s])\n } else\n e[k] = l[k]\n }\n } else if ('function' === typeof l) {\n //assume it's an observable!\n var v = l()\n e.appendChild(r = v instanceof Node ? v : document.createTextNode(v))\n\n l(function (v) {\n if(v instanceof Node && r.parentElement)\n r.parentElement.replaceChild(v, r), r = v\n else\n r.textContent = v\n })\n \n }\n\n return r\n }\n while(args.length)\n item(args.shift())\n\n return e\n}\n\nif(typeof module === 'object')\n module.exports = h\nelse\n this.hyperscript = h\n})()\n\n//@ sourceURL=/node_modules/hyperscript/index.js" )); require.define("/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/package.json" )); require.define("/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var $ = require('./ui')\nvar EventEmitter = require('events').EventEmitter\n\nmodule.exports = function (array, template, list) {\n\n var emitter = new EventEmitter()\n if(!(list instanceof HTMLElement))\n list = document.createElement(list || \"ol\")\n\n function index (e) {\n return [].indexOf.call(e.parentNode.children, e)\n }\n\n sortableList(array, template, list) \n\n function length (a) {\n return 'function' === typeof a ? a.length() : a.length\n }\n\n function sortableList(array, template, list) {\n array.forEach(function (e, i) {\n var el = e && template(e, i)\n if(el) list.appendChild(el)\n })\n\n var from\n \n $(list).sortable({\n start: function (e, u) {\n from = index(u.item[0])\n //console.log('START', from)\n },\n stop: function (e, u) {\n var to = index(u.item[0])\n //console.log('TO', to, 'FROM', from)\n //if(to > from) to\n var v = array[from]\n var changes = [[from, 1], [to, 0, v]]\n \n changes.forEach(function (ch) {\n array.splice.apply(array, ch)\n emitter.emit('change', array, ch)\n emitter.emit('splice', ch)\n })\n }\n }).disableSelection();\n }\n\n emitter.element = list\n emitter.splice = function (index, del) {\n var insert = [].slice.call(arguments, 2)\n var args = [].slice.call(arguments)\n _del = del || 0\n\n function at(i) {\n return list.children[i]\n }\n\n while(_del--)\n list.removeChild(at(index))\n\n insert.forEach(function (e, i) {\n var t = template(e, index + i), a = at(index)\n if(!t) return\n if(a) list.insertBefore(t, a)\n else list.appendChild(t)\n })\n \n var r = array.splice.apply(array, args)\n emitter.emit('change', array, args)\n emitter.emit('splice', args)\n return r\n }\n\n emitter.unshift = function (o) {\n return emitter.splice(0, 0, o), length(array)\n }\n emitter.push = function (o) {\n return emitter.splice(length(array), 0, o), length(array)\n }\n emitter.shift = function (o) {\n return emitter.splice(0, 1)[0] || null\n }\n emitter.pop = function (o) {\n return emitter.splice(length(array) - 1, 1)[0]\n }\n emitter.length = function () {\n return length(array)\n }\n emitter.slice = function () {\n return array.slice.apply(array, arguments)\n }\n\n //this is just a hack, need better solution\n emitter._reset = function (ary) {\n list.innerHTML = '', array.length = 0\n ary.forEach(function (e, i) {\n var t = template(e, i)\n if(!t) return\n array[i] = e\n list.appendChild(t)\n })\n return emitter\n }\n\n return emitter\n}\n\n//@ sourceURL=/index.js" )); require.define("/ui.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\nvar jQuery = require('jquery-browserify');\nmodule.exports = jQuery\n\n;\n/*! jQuery UI - v1.10.1 - 2013-02-21\n* http://jqueryui.com\n* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.sortable.js\n* Copyright (c) 2013 jQuery Foundation and other contributors Licensed MIT */\n\n(function( $, undefined ) {\n\nvar uuid = 0,\n runiqueId = /^ui-id-\\d+$/;\n\n// prevent duplicate loading\n// this is only a problem because we proxy existing functions\n// and we don't want to double proxy them\n$.ui = $.ui || {};\nif ( $.ui.version ) {\n return;\n}\n\n$.extend( $.ui, {\n version: \"1.10.1\",\n\n keyCode: {\n BACKSPACE: 8,\n COMMA: 188,\n DELETE: 46,\n DOWN: 40,\n END: 35,\n ENTER: 13,\n ESCAPE: 27,\n HOME: 36,\n LEFT: 37,\n NUMPAD_ADD: 107,\n NUMPAD_DECIMAL: 110,\n NUMPAD_DIVIDE: 111,\n NUMPAD_ENTER: 108,\n NUMPAD_MULTIPLY: 106,\n NUMPAD_SUBTRACT: 109,\n PAGE_DOWN: 34,\n PAGE_UP: 33,\n PERIOD: 190,\n RIGHT: 39,\n SPACE: 32,\n TAB: 9,\n UP: 38\n }\n});\n\n// plugins\n$.fn.extend({\n _focus: $.fn.focus,\n focus: function( delay, fn ) {\n return typeof delay === \"number\" ?\n this.each(function() {\n var elem = this;\n setTimeout(function() {\n $( elem ).focus();\n if ( fn ) {\n fn.call( elem );\n }\n }, delay );\n }) :\n this._focus.apply( this, arguments );\n },\n\n scrollParent: function() {\n var scrollParent;\n if (($.ui.ie && (/(static|relative)/).test(this.css(\"position\"))) || (/absolute/).test(this.css(\"position\"))) {\n scrollParent = this.parents().filter(function() {\n return (/(relative|absolute|fixed)/).test($.css(this,\"position\")) && (/(auto|scroll)/).test($.css(this,\"overflow\")+$.css(this,\"overflow-y\")+$.css(this,\"overflow-x\"));\n }).eq(0);\n } else {\n scrollParent = this.parents().filter(function() {\n return (/(auto|scroll)/).test($.css(this,\"overflow\")+$.css(this,\"overflow-y\")+$.css(this,\"overflow-x\"));\n }).eq(0);\n }\n\n return (/fixed/).test(this.css(\"position\")) || !scrollParent.length ? $(document) : scrollParent;\n },\n\n zIndex: function( zIndex ) {\n if ( zIndex !== undefined ) {\n return this.css( \"zIndex\", zIndex );\n }\n\n if ( this.length ) {\n var elem = $( this[ 0 ] ), position, value;\n while ( elem.length && elem[ 0 ] !== document ) {\n // Ignore z-index if position is set to a value where z-index is ignored by the browser\n // This makes behavior of this function consistent across browsers\n // WebKit always returns auto if the element is positioned\n position = elem.css( \"position\" );\n if ( position === \"absolute\" || position === \"relative\" || position === \"fixed\" ) {\n // IE returns 0 when zIndex is not specified\n // other browsers return a string\n // we ignore the case of nested elements with an explicit value of 0\n // <div style=\"z-index: -10;\"><div style=\"z-index: 0;\"></div></div>\n value = parseInt( elem.css( \"zIndex\" ), 10 );\n if ( !isNaN( value ) && value !== 0 ) {\n return value;\n }\n }\n elem = elem.parent();\n }\n }\n\n return 0;\n },\n\n uniqueId: function() {\n return this.each(function() {\n if ( !this.id ) {\n this.id = \"ui-id-\" + (++uuid);\n }\n });\n },\n\n removeUniqueId: function() {\n return this.each(function() {\n if ( runiqueId.test( this.id ) ) {\n $( this ).removeAttr( \"id\" );\n }\n });\n }\n});\n\n// selectors\nfunction focusable( element, isTabIndexNotNaN ) {\n var map, mapName, img,\n nodeName = element.nodeName.toLowerCase();\n if ( \"area\" === nodeName ) {\n map = element.parentNode;\n mapName = map.name;\n if ( !element.href || !mapName || map.nodeName.toLowerCase() !== \"map\" ) {\n return false;\n }\n img = $( \"img[usemap=#\" + mapName + \"]\" )[0];\n return !!img && visible( img );\n }\n return ( /input|select|textarea|button|object/.test( nodeName ) ?\n !element.disabled :\n \"a\" === nodeName ?\n element.href || isTabIndexNotNaN :\n isTabIndexNotNaN) &&\n // the element and all of its ancestors must be visible\n visible( element );\n}\n\nfunction visible( element ) {\n return $.expr.filters.visible( element ) &&\n !$( element ).parents().addBack().filter(function() {\n return $.css( this, \"visibility\" ) === \"hidden\";\n }).length;\n}\n\n$.extend( $.expr[ \":\" ], {\n data: $.expr.createPseudo ?\n $.expr.createPseudo(function( dataName ) {\n return function( elem ) {\n return !!$.data( elem, dataName );\n };\n }) :\n // support: jQuery <1.8\n function( elem, i, match ) {\n return !!$.data( elem, match[ 3 ] );\n },\n\n focusable: function( element ) {\n return focusable( element, !isNaN( $.attr( element, \"tabindex\" ) ) );\n },\n\n tabbable: function( element ) {\n var tabIndex = $.attr( element, \"tabindex\" ),\n isTabIndexNaN = isNaN( tabIndex );\n return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );\n }\n});\n\n// support: jQuery <1.8\nif ( !$( \"<a>\" ).outerWidth( 1 ).jquery ) {\n $.each( [ \"Width\", \"Height\" ], function( i, name ) {\n var side = name === \"Width\" ? [ \"Left\", \"Right\" ] : [ \"Top\", \"Bottom\" ],\n type = name.toLowerCase(),\n orig = {\n innerWidth: $.fn.innerWidth,\n innerHeight: $.fn.innerHeight,\n outerWidth: $.fn.outerWidth,\n outerHeight: $.fn.outerHeight\n };\n\n function reduce( elem, size, border, margin ) {\n $.each( side, function() {\n size -= parseFloat( $.css( elem, \"padding\" + this ) ) || 0;\n if ( border ) {\n size -= parseFloat( $.css( elem, \"border\" + this + \"Width\" ) ) || 0;\n }\n if ( margin ) {\n size -= parseFloat( $.css( elem, \"margin\" + this ) ) || 0;\n }\n });\n return size;\n }\n\n $.fn[ \"inner\" + name ] = function( size ) {\n if ( size === undefined ) {\n return orig[ \"inner\" + name ].call( this );\n }\n\n return this.each(function() {\n $( this ).css( type, reduce( this, size ) + \"px\" );\n });\n };\n\n $.fn[ \"outer\" + name] = function( size, margin ) {\n if ( typeof size !== \"number\" ) {\n return orig[ \"outer\" + name ].call( this, size );\n }\n\n return this.each(function() {\n $( this).css( type, reduce( this, size, true, margin ) + \"px\" );\n });\n };\n });\n}\n\n// support: jQuery <1.8\nif ( !$.fn.addBack ) {\n $.fn.addBack = function( selector ) {\n return this.add( selector == null ?\n this.prevObject : this.prevObject.filter( selector )\n );\n };\n}\n\n// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)\nif ( $( \"<a>\" ).data( \"a-b\", \"a\" ).removeData( \"a-b\" ).data( \"a-b\" ) ) {\n $.fn.removeData = (function( removeData ) {\n return function( key ) {\n if ( arguments.length ) {\n return removeData.call( this, $.camelCase( key ) );\n } else {\n return removeData.call( this );\n }\n };\n })( $.fn.removeData );\n}\n\n\n\n\n\n// deprecated\n$.ui.ie = !!/msie [\\w.]+/.exec( navigator.userAgent.toLowerCase() );\n\n$.support.selectstart = \"onselectstart\" in document.createElement( \"div\" );\n$.fn.extend({\n disableSelection: function() {\n return this.bind( ( $.support.selectstart ? \"selectstart\" : \"mousedown\" ) +\n \".ui-disableSelection\", function( event ) {\n event.preventDefault();\n });\n },\n\n enableSelection: function() {\n return this.unbind( \".ui-disableSelection\" );\n }\n});\n\n$.extend( $.ui, {\n // $.ui.plugin is deprecated. Use the proxy pattern instead.\n plugin: {\n add: function( module, option, set ) {\n var i,\n proto = $.ui[ module ].prototype;\n for ( i in set ) {\n proto.plugins[ i ] = proto.plugins[ i ] || [];\n proto.plugins[ i ].push( [ option, set[ i ] ] );\n }\n },\n call: function( instance, name, args ) {\n var i,\n set = instance.plugins[ name ];\n if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {\n return;\n }\n\n for ( i = 0; i < set.length; i++ ) {\n if ( instance.options[ set[ i ][ 0 ] ] ) {\n set[ i ][ 1 ].apply( instance.element, args );\n }\n }\n }\n },\n\n // only used by resizable\n hasScroll: function( el, a ) {\n\n //If overflow is hidden, the element might have extra content, but the user wants to hide it\n if ( $( el ).css( \"overflow\" ) === \"hidden\") {\n return false;\n }\n\n var scroll = ( a && a === \"left\" ) ? \"scrollLeft\" : \"scrollTop\",\n has = false;\n\n if ( el[ scroll ] > 0 ) {\n return true;\n }\n\n // TODO: determine which cases actually cause this to happen\n // if the element doesn't have the scroll set, see if it's possible to\n // set the scroll\n el[ scroll ] = 1;\n has = ( el[ scroll ] > 0 );\n el[ scroll ] = 0;\n return has;\n }\n});\n\n})( jQuery );\n(function( $, undefined ) {\n\nvar uuid = 0,\n slice = Array.prototype.slice,\n _cleanData = $.cleanData;\n$.cleanData = function( elems ) {\n for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {\n try {\n $( elem ).triggerHandler( \"remove\" );\n // http://bugs.jquery.com/ticket/8235\n } catch( e ) {}\n }\n _cleanData( elems );\n};\n\n$.widget = function( name, base, prototype ) {\n var fullName, existingConstructor, constructor, basePrototype,\n // proxiedPrototype allows the provided prototype to remain unmodified\n // so that it can be used as a mixin for multiple widgets (#8876)\n proxiedPrototype = {},\n namespace = name.split( \".\" )[ 0 ];\n\n name = name.split( \".\" )[ 1 ];\n fullName = namespace + \"-\" + name;\n\n if ( !prototype ) {\n prototype = base;\n base = $.Widget;\n }\n\n // create selector for plugin\n $.expr[ \":\" ][ fullName.toLowerCase() ] = function( elem ) {\n return !!$.data( elem, fullName );\n };\n\n $[ namespace ] = $[ namespace ] || {};\n existingConstructor = $[ namespace ][ name ];\n constructor = $[ namespace ][ name ] = function( options, element ) {\n // allow instantiation without \"new\" keyword\n if ( !this._createWidget ) {\n return new constructor( options, element );\n }\n\n // allow instantiation without initializing for simple inheritance\n // must use \"new\" keyword (the code above always passes args)\n if ( arguments.length ) {\n this._createWidget( options, element );\n }\n };\n // extend with the existing constructor to carry over any static properties\n $.extend( constructor, existingConstructor, {\n version: prototype.version,\n // copy the object used to create the prototype in case we need to\n // redefine the widget later\n _proto: $.extend( {}, prototype ),\n // track widgets that inherit from this widget in case this widget is\n // redefined after a widget inherits from it\n _childConstructors: []\n });\n\n basePrototype = new base();\n // we need to make the options hash a property directly on the new instance\n // otherwise we'll modify the options hash on the prototype that we're\n // inheriting from\n basePrototype.options = $.widget.extend( {}, basePrototype.options );\n $.each( prototype, function( prop, value ) {\n if ( !$.isFunction( value ) ) {\n proxiedPrototype[ prop ] = value;\n return;\n }\n proxiedPrototype[ prop ] = (function() {\n var _super = function() {\n return base.prototype[ prop ].apply( this, arguments );\n },\n _superApply = function( args ) {\n return base.prototype[ prop ].apply( this, args );\n };\n return function() {\n var __super = this._super,\n __superApply = this._superApply,\n returnValue;\n\n this._super = _super;\n this._superApply = _superApply;\n\n returnValue = value.apply( this, arguments );\n\n this._super = __super;\n this._superApply = __superApply;\n\n return returnValue;\n };\n })();\n });\n constructor.prototype = $.widget.extend( basePrototype, {\n // TODO: remove support for widgetEventPrefix\n // always use the name + a colon as the prefix, e.g., draggable:start\n // don't prefix for widgets that aren't DOM-based\n widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name\n }, proxiedPrototype, {\n constructor: constructor,\n namespace: namespace,\n widgetName: name,\n widgetFullName: fullName\n });\n\n // If this widget is being redefined then we need to find all widgets that\n // are inheriting from it and redefine all of them so that they inherit from\n // the new version of this widget. We're essentially trying to replace one\n // level in the prototype chain.\n if ( existingConstructor ) {\n $.each( existingConstructor._childConstructors, function( i, child ) {\n var childPrototype = child.prototype;\n\n // redefine the child widget using the same prototype that was\n // originally used, but inherit from the new version of the base\n $.widget( childPrototype.namespace + \".\" + childPrototype.widgetName, constructor, child._proto );\n });\n // remove the list of existing child constructors from the old constructor\n // so the old child constructors can be garbage collected\n delete existingConstructor._childConstructors;\n } else {\n base._childConstructors.push( constructor );\n }\n\n $.widget.bridge( name, constructor );\n};\n\n$.widget.extend = function( target ) {\n var input = slice.call( arguments, 1 ),\n inputIndex = 0,\n inputLength = input.length,\n key,\n value;\n for ( ; inputIndex < inputLength; inputIndex++ ) {\n for ( key in input[ inputIndex ] ) {\n value = input[ inputIndex ][ key ];\n if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {\n // Clone objects\n if ( $.isPlainObject( value ) ) {\n target[ key ] = $.isPlainObject( target[ key ] ) ?\n $.widget.extend( {}, target[ key ], value ) :\n // Don't extend strings, arrays, etc. with objects\n $.widget.extend( {}, value );\n // Copy everything else by reference\n } else {\n target[ key ] = value;\n }\n }\n }\n }\n return target;\n};\n\n$.widget.bridge = function( name, object ) {\n var fullName = object.prototype.widgetFullName || name;\n $.fn[ name ] = function( options ) {\n var isMethodCall = typeof options === \"string\",\n args = slice.call( arguments, 1 ),\n returnValue = this;\n\n // allow multiple hashes to be passed on init\n options = !isMethodCall && args.length ?\n $.widget.extend.apply( null, [ options ].concat(args) ) :\n options;\n\n if ( isMethodCall ) {\n this.each(function() {\n var methodValue,\n instance = $.data( this, fullName );\n if ( !instance ) {\n return $.error( \"cannot call methods on \" + name + \" prior to initialization; \" +\n \"attempted to call method '\" + options + \"'\" );\n }\n if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === \"_\" ) {\n return $.error( \"no such method '\" + options + \"' for \" + name + \" widget instance\" );\n }\n methodValue = instance[ options ].apply( instance, args );\n if ( methodValue !== instance && methodValue !== undefined ) {\n returnValue = methodValue && methodValue.jquery ?\n returnValue.pushStack( methodValue.get() ) :\n methodValue;\n return false;\n }\n });\n } else {\n this.each(function() {\n var instance = $.data( this, fullName );\n if ( instance ) {\n instance.option( options || {} )._init();\n } else {\n $.data( this, fullName, new object( options, this ) );\n }\n });\n }\n\n return returnValue;\n };\n};\n\n$.Widget = function( /* options, element */ ) {};\n$.Widget._childConstructors = [];\n\n$.Widget.prototype = {\n widgetName: \"widget\",\n widgetEventPrefix: \"\",\n defaultElement: \"<div>\",\n options: {\n disabled: false,\n\n // callbacks\n create: null\n },\n _createWidget: function( options, element ) {\n element = $( element || this.defaultElement || this )[ 0 ];\n this.element = $( element );\n this.uuid = uuid++;\n this.eventNamespace = \".\" + this.widgetName + this.uuid;\n this.options = $.widget.extend( {},\n this.options,\n this._getCreateOptions(),\n options );\n\n this.bindings = $();\n this.hoverable = $();\n this.focusable = $();\n\n if ( element !== this ) {\n $.data( element, this.widgetFullName, this );\n this._on( true, this.element, {\n remove: function( event ) {\n if ( event.target === element ) {\n this.destroy();\n }\n }\n });\n this.document = $( element.style ?\n // element within the document\n element.ownerDocument :\n // element is window or document\n element.document || element );\n this.window = $( this.document[0].defaultView || this.document[0].parentWindow );\n }\n\n this._create();\n this._trigger( \"create\", null, this._getCreateEventData() );\n this._init();\n },\n _getCreateOptions: $.noop,\n _getCreateEventData: $.noop,\n _create: $.noop,\n _init: $.noop,\n\n destroy: function() {\n this._destroy();\n // we can probably remove the unbind calls in 2.0\n // all event bindings should go through this._on()\n this.element\n .unbind( this.eventNamespace )\n // 1.9 BC for #7810\n // TODO remove dual storage\n .removeData( this.widgetName )\n .removeData( this.widgetFullName )\n // support: jquery <1.6.3\n // http://bugs.jquery.com/ticket/9413\n .removeData( $.camelCase( this.widgetFullName ) );\n this.widget()\n .unbind( this.eventNamespace )\n .removeAttr( \"aria-disabled\" )\n .removeClass(\n this.widgetFullName + \"-disabled \" +\n \"ui-state-disabled\" );\n\n // clean up events and states\n this.bindings.unbind( this.eventNamespace );\n this.hoverable.removeClass( \"ui-state-hover\" );\n this.focusable.removeClass( \"ui-state-focus\" );\n },\n _destroy: $.noop,\n\n widget: function() {\n return this.element;\n },\n\n option: function( key, value ) {\n var options = key,\n parts,\n curOption,\n i;\n\n if ( arguments.length === 0 ) {\n // don't return a reference to the internal hash\n return $.widget.extend( {}, this.options );\n }\n\n if ( typeof key === \"string\" ) {\n // handle nested keys, e.g., \"foo.bar\" => { foo: { bar: ___ } }\n options = {};\n parts = key.split( \".\" );\n key = parts.shift();\n if ( parts.length ) {\n curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );\n for ( i = 0; i < parts.length - 1; i++ ) {\n curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};\n curOption = curOption[ parts[ i ] ];\n }\n key = parts.pop();\n if ( value === undefined ) {\n return curOption[ key ] === undefined ? null : curOption[ key ];\n }\n curOption[ key ] = value;\n } else {\n if ( value === undefined ) {\n return this.options[ key ] === undefined ? null : this.options[ key ];\n }\n options[ key ] = value;\n }\n }\n\n this._setOptions( options );\n\n return this;\n },\n _setOptions: function( options ) {\n var key;\n\n for ( key in options ) {\n this._setOption( key, options[ key ] );\n }\n\n return this;\n },\n _setOption: function( key, value ) {\n this.options[ key ] = value;\n\n if ( key === \"disabled\" ) {\n this.widget()\n .toggleClass( this.widgetFullName + \"-disabled ui-state-disabled\", !!value )\n .attr( \"aria-disabled\", value );\n this.hoverable.removeClass( \"ui-state-hover\" );\n this.focusable.removeClass( \"ui-state-focus\" );\n }\n\n return this;\n },\n\n enable: function() {\n return this._setOption( \"disabled\", false );\n },\n disable: function() {\n return this._setOption( \"disabled\", true );\n },\n\n _on: function( suppressDisabledCheck, element, handlers ) {\n var delegateElement,\n instance = this;\n\n // no suppressDisabledCheck flag, shuffle arguments\n if ( typeof suppressDisabledCheck !== \"boolean\" ) {\n handlers = element;\n element = suppressDisabledCheck;\n suppressDisabledCheck = false;\n }\n\n // no element argument, shuffle and use this.element\n if ( !handlers ) {\n handlers = element;\n element = this.element;\n delegateElement = this.widget();\n } else {\n // accept selectors, DOM elements\n element = delegateElement = $( element );\n this.bindings = this.bindings.add( element );\n }\n\n $.each( handlers, function( event, handler ) {\n function handlerProxy() {\n // allow widgets to customize the disabled handling\n // - disabled as an array instead of boolean\n // - disabled class as method for disabling individual parts\n if ( !suppressDisabledCheck &&\n ( instance.options.disabled === true ||\n $( this ).hasClass( \"ui-state-disabled\" ) ) ) {\n return;\n }\n return ( typeof handler === \"string\" ? instance[ handler ] : handler )\n .apply( instance, arguments );\n }\n\n // copy the guid so direct unbinding works\n if ( typeof handler !== \"string\" ) {\n handlerProxy.guid = handler.guid =\n handler.guid || handlerProxy.guid || $.guid++;\n }\n\n var match = event.match( /^(\\w+)\\s*(.*)$/ ),\n eventName = match[1] + instance.eventNamespace,\n selector = match[2];\n if ( selector ) {\n delegateElement.delegate( selector, eventName, handlerProxy );\n } else {\n element.bind( eventName, handlerProxy );\n }\n });\n },\n\n _off: function( element, eventName ) {\n eventName = (eventName || \"\").split( \" \" ).join( this.eventNamespace + \" \" ) + this.eventNamespace;\n element.unbind( eventName ).undelegate( eventName );\n },\n\n _delay: function( handler, delay ) {\n function handlerProxy() {\n return ( typeof handler === \"string\" ? instance[ handler ] : handler )\n .apply( instance, arguments );\n }\n var instance = this;\n return setTimeout( handlerProxy, delay || 0 );\n },\n\n _hoverable: function( element ) {\n this.hoverable = this.hoverable.add( element );\n this._on( element, {\n mouseenter: function( event ) {\n $( event.currentTarget ).addClass( \"ui-state-hover\" );\n },\n mouseleave: function( event ) {\n $( event.currentTarget ).removeClass( \"ui-state-hover\" );\n }\n });\n },\n\n _focusable: function( element ) {\n this.focusable = this.focusable.add( element );\n this._on( element, {\n focusin: function( event ) {\n $( event.currentTarget ).addClass( \"ui-state-focus\" );\n },\n focusout: function( event ) {\n $( event.currentTarget ).removeClass( \"ui-state-focus\" );\n }\n });\n },\n\n _trigger: function( type, event, data ) {\n var prop, orig,\n callback = this.options[ type ];\n\n data = data || {};\n event = $.Event( event );\n event.type = ( type === this.widgetEventPrefix ?\n type :\n this.widgetEventPrefix + type ).toLowerCase();\n // the original event may come from any element\n // so we need to reset the target on the new event\n event.target = this.element[ 0 ];\n\n // copy original event properties over to the new event\n orig = event.originalEvent;\n if ( orig ) {\n for ( prop in orig ) {\n if ( !( prop in event ) ) {\n event[ prop ] = orig[ prop ];\n }\n }\n }\n\n this.element.trigger( event, data );\n return !( $.isFunction( callback ) &&\n callback.apply( this.element[0], [ event ].concat( data ) ) === false ||\n event.isDefaultPrevented() );\n }\n};\n\n$.each( { show: \"fadeIn\", hide: \"fadeOut\" }, function( method, defaultEffect ) {\n $.Widget.prototype[ \"_\" + method ] = function( element, options, callback ) {\n if ( typeof options === \"string\" ) {\n options = { effect: options };\n }\n var hasOptions,\n effectName = !options ?\n method :\n options === true || typeof options === \"number\" ?\n defaultEffect :\n options.effect || defaultEffect;\n options = options || {};\n if ( typeof options === \"number\" ) {\n options = { duration: options };\n }\n hasOptions = !$.isEmptyObject( options );\n options.complete = callback;\n if ( options.delay ) {\n element.delay( options.delay );\n }\n if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {\n element[ method ]( options );\n } else if ( effectName !== method && element[ effectName ] ) {\n element[ effectName ]( options.duration, options.easing, callback );\n } else {\n element.queue(function( next ) {\n $( this )[ method ]();\n if ( callback ) {\n callback.call( element[ 0 ] );\n }\n next();\n });\n }\n };\n});\n\n})( jQuery );\n(function( $, undefined ) {\n\nvar mouseHandled = false;\n$( document ).mouseup( function() {\n mouseHandled = false;\n});\n\n$.widget(\"ui.mouse\", {\n version: \"1.10.1\",\n options: {\n cancel: \"input,textarea,button,select,option\",\n distance: 1,\n delay: 0\n },\n _mouseInit: function() {\n var that = this;\n\n this.element\n .bind(\"mousedown.\"+this.widgetName, function(event) {\n return that._mouseDown(event);\n })\n .bind(\"click.\"+this.widgetName, function(event) {\n if (true === $.data(event.target, that.widgetName + \".preventClickEvent\")) {\n $.removeData(event.target, that.widgetName + \".preventClickEvent\");\n event.stopImmediatePropagation();\n return false;\n }\n });\n\n this.started = false;\n },\n\n // TODO: make sure destroying one instance of mouse doesn't mess with\n // other instances of mouse\n _mouseDestroy: function() {\n this.element.unbind(\".\"+this.widgetName);\n if ( this._mouseMoveDelegate ) {\n $(document)\n .unbind(\"mousemove.\"+this.widgetName, this._mouseMoveDelegate)\n .unbind(\"mouseup.\"+this.widgetName, this._mouseUpDelegate);\n }\n },\n\n _mouseDown: function(event) {\n // don't let more than one widget handle mouseStart\n if( mouseHandled ) { return; }\n\n // we may have missed mouseup (out of window)\n (this._mouseStarted && this._mouseUp(event));\n\n this._mouseDownEvent = event;\n\n var that = this,\n btnIsLeft = (event.which === 1),\n // event.target.nodeName works around a bug in IE 8 with\n // disabled inputs (#7620)\n elIsCancel = (typeof this.options.cancel === \"string\" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);\n if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {\n return true;\n }\n\n this.mouseDelayMet = !this.options.delay;\n if (!this.mouseDelayMet) {\n this._mouseDelayTimer = setTimeout(function() {\n that.mouseDelayMet = true;\n }, this.options.delay);\n }\n\n if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {\n this._mouseStarted = (this._mouseStart(event) !== false);\n if (!this._mouseStarted) {\n event.preventDefault();\n return true;\n }\n }\n\n // Click event may never have fired (Gecko & Opera)\n if (true === $.data(event.target, this.widgetName + \".preventClickEvent\")) {\n $.removeData(event.target, this.widgetName + \".preventClickEvent\");\n }\n\n // these delegates are required to keep context\n this._mouseMoveDelegate = function(event) {\n return that._mouseMove(event);\n };\n this._mouseUpDelegate = function(event) {\n return that._mouseUp(event);\n };\n $(document)\n .bind(\"mousemove.\"+this.widgetName, this._mouseMoveDelegate)\n .bind(\"mouseup.\"+this.widgetName, this._mouseUpDelegate);\n\n event.preventDefault();\n\n mouseHandled = true;\n return true;\n },\n\n _mouseMove: function(event) {\n // IE mouseup check - mouseup happened when mouse was out of window\n if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {\n return this._mouseUp(event);\n }\n\n if (this._mouseStarted) {\n this._mouseDrag(event);\n return event.preventDefault();\n }\n\n if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {\n this._mouseStarted =\n (this._mouseStart(this._mouseDownEvent, event) !== false);\n (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));\n }\n\n return !this._mouseStarted;\n },\n\n _mouseUp: function(event) {\n $(document)\n .unbind(\"mousemove.\"+this.widgetName, this._mouseMoveDelegate)\n .unbind(\"mouseup.\"+this.widgetName, this._mouseUpDelegate);\n\n if (this._mouseStarted) {\n this._mouseStarted = false;\n\n if (event.target === this._mouseDownEvent.target) {\n $.data(event.target, this.widgetName + \".preventClickEvent\", true);\n }\n\n this._mouseStop(event);\n }\n\n return false;\n },\n\n _mouseDistanceMet: function(event) {\n return (Math.max(\n Math.abs(this._mouseDownEvent.pageX - event.pageX),\n Math.abs(this._mouseDownEvent.pageY - event.pageY)\n ) >= this.options.distance\n );\n },\n\n _mouseDelayMet: function(/* event */) {\n return this.mouseDelayMet;\n },\n\n // These are placeholder methods, to be overriden by extending plugin\n _mouseStart: function(/* event */) {},\n _mouseDrag: function(/* event */) {},\n _mouseStop: function(/* event */) {},\n _mouseCapture: function(/* event */) { return true; }\n});\n\n})(jQuery);\n(function( $, undefined ) {\n\n$.ui = $.ui || {};\n\nvar cachedScrollbarWidth,\n max = Math.max,\n abs = Math.abs,\n round = Math.round,\n rhorizontal = /left|center|right/,\n rvertical = /top|center|bottom/,\n roffset = /[\\+\\-]\\d+(\\.[\\d]+)?%?/,\n rposition = /^\\w+/,\n rpercent = /%$/,\n _position = $.fn.position;\n\nfunction getOffsets( offsets, width, height ) {\n return [\n parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),\n parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )\n ];\n}\n\nfunction parseCss( element, property ) {\n return parseInt( $.css( element, property ), 10 ) || 0;\n}\n\nfunction getDimensions( elem ) {\n var raw = elem[0];\n if ( raw.nodeType === 9 ) {\n return {\n width: elem.width(),\n height: elem.height(),\n offset: { top: 0, left: 0 }\n };\n }\n if ( $.isWindow( raw ) ) {\n return {\n width: elem.width(),\n height: elem.height(),\n offset: { top: elem.scrollTop(), left: elem.scrollLeft() }\n };\n }\n if ( raw.preventDefault ) {\n return {\n width: 0,\n height: 0,\n offset: { top: raw.pageY, left: raw.pageX }\n };\n }\n return {\n width: elem.outerWidth(),\n height: elem.outerHeight(),\n offset: elem.offset()\n };\n}\n\n$.position = {\n scrollbarWidth: function() {\n if ( cachedScrollbarWidth !== undefined ) {\n return cachedScrollbarWidth;\n }\n var w1, w2,\n div = $( \"<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>\" ),\n innerDiv = div.children()[0];\n\n $( \"body\" ).append( div );\n w1 = innerDiv.offsetWidth;\n div.css( \"overflow\", \"scroll\" );\n\n w2 = innerDiv.offsetWidth;\n\n if ( w1 === w2 ) {\n w2 = div[0].clientWidth;\n }\n\n div.remove();\n\n