Changeset 3684:1c48f7836e8a
- Timestamp:
- 01/27/18 11:56:45 (8 years ago)
- Branch:
- default
- Location:
- admin/js/jquery
- Files:
-
- 2 edited
-
jquery-migrate.js (modified) (10 diffs)
-
jquery-ui.custom.js (modified) (181 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin/js/jquery/jquery-migrate.js
r3178 r3684 1 1 /*! 2 * jQuery Migrate - v1. 3.0 - 2016-01-132 * jQuery Migrate - v1.4.1 - 2016-05-19 3 3 * Copyright jQuery Foundation and other contributors 4 4 */ … … 8 8 9 9 10 jQuery.migrateVersion = "1. 3.0";10 jQuery.migrateVersion = "1.4.1"; 11 11 12 12 … … 20 20 21 21 // Show a message on the console so devs know we're active 22 if ( !jQuery.migrateMute && window.console && window.console.log ) { 23 window.console.log("JQMIGRATE: Logging is active"); 22 if ( window.console && window.console.log ) { 23 window.console.log( "JQMIGRATE: Migrate is installed" + 24 ( jQuery.migrateMute ? "" : " with logging active" ) + 25 ", version " + jQuery.migrateVersion ); 24 26 } 25 27 … … 192 194 var matched, browser, 193 195 oldInit = jQuery.fn.init, 196 oldFind = jQuery.find, 194 197 oldParseJSON = jQuery.parseJSON, 195 198 rspaceAngle = /^\s*</, 199 rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, 200 rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g, 196 201 // Note: XSS check is done below after string is trimmed 197 202 rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/; … … 201 206 var match, ret; 202 207 203 if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) && 204 (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) { 205 // This is an HTML string according to the "old" rules; is it still? 206 if ( !rspaceAngle.test( selector ) ) { 207 migrateWarn("$(html) HTML strings must start with '<' character"); 208 } 209 if ( match[ 3 ] ) { 210 migrateWarn("$(html) HTML text after last tag is ignored"); 211 } 212 213 // Consistently reject any HTML-like string starting with a hash (#9521) 214 // Note that this may break jQuery 1.6.x code that otherwise would work. 215 if ( match[ 0 ].charAt( 0 ) === "#" ) { 216 migrateWarn("HTML string cannot start with a '#' character"); 217 jQuery.error("JQMIGRATE: Invalid selector string (XSS)"); 218 } 219 // Now process using loose rules; let pre-1.8 play too 220 if ( context && context.context ) { 221 // jQuery object as context; parseHTML expects a DOM object 222 context = context.context; 223 } 224 if ( jQuery.parseHTML ) { 225 return oldInit.call( this, 226 jQuery.parseHTML( match[ 2 ], context && context.ownerDocument || 227 context || document, true ), context, rootjQuery ); 228 } 229 } 230 231 // jQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0 232 if ( selector === "#" ) { 233 migrateWarn( "jQuery( '#' ) is not a valid selector" ); 234 selector = []; 208 if ( selector && typeof selector === "string" ) { 209 if ( !jQuery.isPlainObject( context ) && 210 (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) { 211 212 // This is an HTML string according to the "old" rules; is it still? 213 if ( !rspaceAngle.test( selector ) ) { 214 migrateWarn("$(html) HTML strings must start with '<' character"); 215 } 216 if ( match[ 3 ] ) { 217 migrateWarn("$(html) HTML text after last tag is ignored"); 218 } 219 220 // Consistently reject any HTML-like string starting with a hash (gh-9521) 221 // Note that this may break jQuery 1.6.x code that otherwise would work. 222 if ( match[ 0 ].charAt( 0 ) === "#" ) { 223 migrateWarn("HTML string cannot start with a '#' character"); 224 jQuery.error("JQMIGRATE: Invalid selector string (XSS)"); 225 } 226 227 // Now process using loose rules; let pre-1.8 play too 228 // Is this a jQuery context? parseHTML expects a DOM element (#178) 229 if ( context && context.context && context.context.nodeType ) { 230 context = context.context; 231 } 232 233 if ( jQuery.parseHTML ) { 234 return oldInit.call( this, 235 jQuery.parseHTML( match[ 2 ], context && context.ownerDocument || 236 context || document, true ), context, rootjQuery ); 237 } 238 } 235 239 } 236 240 … … 253 257 }; 254 258 jQuery.fn.init.prototype = jQuery.fn; 259 260 jQuery.find = function( selector ) { 261 var args = Array.prototype.slice.call( arguments ); 262 263 // Support: PhantomJS 1.x 264 // String#match fails to match when used with a //g RegExp, only on some strings 265 if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { 266 267 // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0 268 // First see if qS thinks it's a valid selector, if so avoid a false positive 269 try { 270 document.querySelector( selector ); 271 } catch ( err1 ) { 272 273 // Didn't *look* valid to qSA, warn and try quoting what we think is the value 274 selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) { 275 return "[" + attr + op + "\"" + value + "\"]"; 276 } ); 277 278 // If the regexp *may* have created an invalid selector, don't update it 279 // Note that there may be false alarms if selector uses jQuery extensions 280 try { 281 document.querySelector( selector ); 282 migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] ); 283 args[ 0 ] = selector; 284 } catch ( err2 ) { 285 migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] ); 286 } 287 } 288 } 289 290 return oldFind.apply( this, args ); 291 }; 292 293 // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) 294 var findProp; 295 for ( findProp in oldFind ) { 296 if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { 297 jQuery.find[ findProp ] = oldFind[ findProp ]; 298 } 299 } 255 300 256 301 // Let $.parseJSON(falsy_value) return null … … 504 549 jQuery.fn[ name ] = function() { 505 550 var args = Array.prototype.slice.call( arguments, 0 ); 506 migrateWarn( "jQuery.fn." + name + "() is deprecated" );507 551 508 552 // If this is an ajax load() the first arg should be the string URL; … … 510 554 // which just goes to show why this dumb signature has been deprecated! 511 555 // jQuery custom builds that exclude the Ajax module justifiably die here. 512 if ( name === "load" && typeof arguments[ 0 ] === "string" ) { 513 return oldLoad.apply( this, arguments ); 514 } 556 if ( name === "load" && typeof args[ 0 ] === "string" ) { 557 return oldLoad.apply( this, args ); 558 } 559 560 migrateWarn( "jQuery.fn." + name + "() is deprecated" ); 515 561 516 562 args.splice( 0, 0, name ); … … 613 659 614 660 jQuery.event.special.ready = { 615 setup: function() { migrateWarn( "'ready' event is deprecated" ); } 661 setup: function() { 662 if ( this === document ) { 663 migrateWarn( "'ready' event is deprecated" ); 664 } 665 } 616 666 }; 617 667 618 668 var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack, 619 oldF ind = jQuery.fn.find;669 oldFnFind = jQuery.fn.find; 620 670 621 671 jQuery.fn.andSelf = function() { … … 625 675 626 676 jQuery.fn.find = function( selector ) { 627 var ret = oldF ind.apply( this, arguments );677 var ret = oldFnFind.apply( this, arguments ); 628 678 ret.context = this.context; 629 679 ret.selector = this.selector ? this.selector + " " + selector : selector; -
admin/js/jquery/jquery-ui.custom.js
r3178 r3684 1 /*! jQuery UI - v1.1 1.4 - 2016-02-201 /*! jQuery UI - v1.12.1 - 2018-01-27 2 2 * http://jqueryui.com 3 * Includes: core.js, widget.js, mouse.js, draggable.js, sortable.js, accordion.js3 * Includes: widget.js, data.js, keycode.js, scroll-parent.js, unique-id.js, widgets/draggable.js, widgets/sortable.js, widgets/accordion.js, widgets/mouse.js 4 4 * Copyright jQuery Foundation and other contributors; Licensed MIT */ 5 5 … … 15 15 } 16 16 }(function( $ ) { 17 18 $.ui = $.ui || {}; 19 20 var version = $.ui.version = "1.12.1"; 21 22 17 23 /*! 18 * jQuery UI Core 1.11.424 * jQuery UI Widget 1.12.1 19 25 * http://jqueryui.com 20 26 * … … 22 28 * Released under the MIT license. 23 29 * http://jquery.org/license 24 *25 * http://api.jqueryui.com/category/ui-core/26 30 */ 27 31 28 29 // $.ui might exist from components with no dependencies, e.g., $.ui.position 30 $.ui = $.ui || {}; 31 32 $.extend( $.ui, { 33 version: "1.11.4", 34 35 keyCode: { 36 BACKSPACE: 8, 37 COMMA: 188, 38 DELETE: 46, 39 DOWN: 40, 40 END: 35, 41 ENTER: 13, 42 ESCAPE: 27, 43 HOME: 36, 44 LEFT: 37, 45 PAGE_DOWN: 34, 46 PAGE_UP: 33, 47 PERIOD: 190, 48 RIGHT: 39, 49 SPACE: 32, 50 TAB: 9, 51 UP: 38 52 } 53 }); 54 55 // plugins 56 $.fn.extend({ 57 scrollParent: function( includeHidden ) { 58 var position = this.css( "position" ), 59 excludeStaticParent = position === "absolute", 60 overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, 61 scrollParent = this.parents().filter( function() { 62 var parent = $( this ); 63 if ( excludeStaticParent && parent.css( "position" ) === "static" ) { 64 return false; 65 } 66 return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) ); 67 }).eq( 0 ); 68 69 return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent; 70 }, 71 72 uniqueId: (function() { 73 var uuid = 0; 74 75 return function() { 76 return this.each(function() { 77 if ( !this.id ) { 78 this.id = "ui-id-" + ( ++uuid ); 79 } 80 }); 81 }; 82 })(), 83 84 removeUniqueId: function() { 85 return this.each(function() { 86 if ( /^ui-id-\d+$/.test( this.id ) ) { 87 $( this ).removeAttr( "id" ); 88 } 89 }); 90 } 91 }); 92 93 // selectors 94 function focusable( element, isTabIndexNotNaN ) { 95 var map, mapName, img, 96 nodeName = element.nodeName.toLowerCase(); 97 if ( "area" === nodeName ) { 98 map = element.parentNode; 99 mapName = map.name; 100 if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { 101 return false; 102 } 103 img = $( "img[usemap='#" + mapName + "']" )[ 0 ]; 104 return !!img && visible( img ); 105 } 106 return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ? 107 !element.disabled : 108 "a" === nodeName ? 109 element.href || isTabIndexNotNaN : 110 isTabIndexNotNaN) && 111 // the element and all of its ancestors must be visible 112 visible( element ); 113 } 114 115 function visible( element ) { 116 return $.expr.filters.visible( element ) && 117 !$( element ).parents().addBack().filter(function() { 118 return $.css( this, "visibility" ) === "hidden"; 119 }).length; 120 } 121 122 $.extend( $.expr[ ":" ], { 123 data: $.expr.createPseudo ? 124 $.expr.createPseudo(function( dataName ) { 125 return function( elem ) { 126 return !!$.data( elem, dataName ); 127 }; 128 }) : 129 // support: jQuery <1.8 130 function( elem, i, match ) { 131 return !!$.data( elem, match[ 3 ] ); 132 }, 133 134 focusable: function( element ) { 135 return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) ); 136 }, 137 138 tabbable: function( element ) { 139 var tabIndex = $.attr( element, "tabindex" ), 140 isTabIndexNaN = isNaN( tabIndex ); 141 return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN ); 142 } 143 }); 144 145 // support: jQuery <1.8 146 if ( !$( "<a>" ).outerWidth( 1 ).jquery ) { 147 $.each( [ "Width", "Height" ], function( i, name ) { 148 var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], 149 type = name.toLowerCase(), 150 orig = { 151 innerWidth: $.fn.innerWidth, 152 innerHeight: $.fn.innerHeight, 153 outerWidth: $.fn.outerWidth, 154 outerHeight: $.fn.outerHeight 155 }; 156 157 function reduce( elem, size, border, margin ) { 158 $.each( side, function() { 159 size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; 160 if ( border ) { 161 size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; 162 } 163 if ( margin ) { 164 size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; 165 } 166 }); 167 return size; 168 } 169 170 $.fn[ "inner" + name ] = function( size ) { 171 if ( size === undefined ) { 172 return orig[ "inner" + name ].call( this ); 173 } 174 175 return this.each(function() { 176 $( this ).css( type, reduce( this, size ) + "px" ); 177 }); 178 }; 179 180 $.fn[ "outer" + name] = function( size, margin ) { 181 if ( typeof size !== "number" ) { 182 return orig[ "outer" + name ].call( this, size ); 183 } 184 185 return this.each(function() { 186 $( this).css( type, reduce( this, size, true, margin ) + "px" ); 187 }); 188 }; 189 }); 190 } 191 192 // support: jQuery <1.8 193 if ( !$.fn.addBack ) { 194 $.fn.addBack = function( selector ) { 195 return this.add( selector == null ? 196 this.prevObject : this.prevObject.filter( selector ) 197 ); 198 }; 199 } 200 201 // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413) 202 if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { 203 $.fn.removeData = (function( removeData ) { 204 return function( key ) { 205 if ( arguments.length ) { 206 return removeData.call( this, $.camelCase( key ) ); 207 } else { 208 return removeData.call( this ); 209 } 210 }; 211 })( $.fn.removeData ); 212 } 213 214 // deprecated 215 $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); 216 217 $.fn.extend({ 218 focus: (function( orig ) { 219 return function( delay, fn ) { 220 return typeof delay === "number" ? 221 this.each(function() { 222 var elem = this; 223 setTimeout(function() { 224 $( elem ).focus(); 225 if ( fn ) { 226 fn.call( elem ); 227 } 228 }, delay ); 229 }) : 230 orig.apply( this, arguments ); 231 }; 232 })( $.fn.focus ), 233 234 disableSelection: (function() { 235 var eventType = "onselectstart" in document.createElement( "div" ) ? 236 "selectstart" : 237 "mousedown"; 238 239 return function() { 240 return this.bind( eventType + ".ui-disableSelection", function( event ) { 241 event.preventDefault(); 242 }); 243 }; 244 })(), 245 246 enableSelection: function() { 247 return this.unbind( ".ui-disableSelection" ); 248 }, 249 250 zIndex: function( zIndex ) { 251 if ( zIndex !== undefined ) { 252 return this.css( "zIndex", zIndex ); 253 } 254 255 if ( this.length ) { 256 var elem = $( this[ 0 ] ), position, value; 257 while ( elem.length && elem[ 0 ] !== document ) { 258 // Ignore z-index if position is set to a value where z-index is ignored by the browser 259 // This makes behavior of this function consistent across browsers 260 // WebKit always returns auto if the element is positioned 261 position = elem.css( "position" ); 262 if ( position === "absolute" || position === "relative" || position === "fixed" ) { 263 // IE returns 0 when zIndex is not specified 264 // other browsers return a string 265 // we ignore the case of nested elements with an explicit value of 0 266 // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> 267 value = parseInt( elem.css( "zIndex" ), 10 ); 268 if ( !isNaN( value ) && value !== 0 ) { 269 return value; 270 } 271 } 272 elem = elem.parent(); 273 } 274 } 275 276 return 0; 277 } 278 }); 279 280 // $.ui.plugin is deprecated. Use $.widget() extensions instead. 281 $.ui.plugin = { 282 add: function( module, option, set ) { 283 var i, 284 proto = $.ui[ module ].prototype; 285 for ( i in set ) { 286 proto.plugins[ i ] = proto.plugins[ i ] || []; 287 proto.plugins[ i ].push( [ option, set[ i ] ] ); 288 } 289 }, 290 call: function( instance, name, args, allowDisconnected ) { 291 var i, 292 set = instance.plugins[ name ]; 293 294 if ( !set ) { 295 return; 296 } 297 298 if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) { 299 return; 300 } 301 302 for ( i = 0; i < set.length; i++ ) { 303 if ( instance.options[ set[ i ][ 0 ] ] ) { 304 set[ i ][ 1 ].apply( instance.element, args ); 305 } 306 } 307 } 308 }; 309 310 311 /*! 312 * jQuery UI Widget 1.11.4 313 * http://jqueryui.com 314 * 315 * Copyright jQuery Foundation and other contributors 316 * Released under the MIT license. 317 * http://jquery.org/license 318 * 319 * http://api.jqueryui.com/jQuery.widget/ 320 */ 321 322 323 var widget_uuid = 0, 324 widget_slice = Array.prototype.slice; 325 326 $.cleanData = (function( orig ) { 32 //>>label: Widget 33 //>>group: Core 34 //>>description: Provides a factory for creating stateful widgets with a common API. 35 //>>docs: http://api.jqueryui.com/jQuery.widget/ 36 //>>demos: http://jqueryui.com/widget/ 37 38 39 40 var widgetUuid = 0; 41 var widgetSlice = Array.prototype.slice; 42 43 $.cleanData = ( function( orig ) { 327 44 return function( elems ) { 328 45 var events, elem, i; 329 for ( i = 0; ( elem = elems[i]) != null; i++ ) {46 for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { 330 47 try { 331 48 … … 336 53 } 337 54 338 // http://bugs.jquery.com/ticket/823555 // Http://bugs.jquery.com/ticket/8235 339 56 } catch ( e ) {} 340 57 } 341 58 orig( elems ); 342 59 }; 343 } )( $.cleanData );60 } )( $.cleanData ); 344 61 345 62 $.widget = function( name, base, prototype ) { 346 var fullName, existingConstructor, constructor, basePrototype, 347 // proxiedPrototype allows the provided prototype to remain unmodified 348 // so that it can be used as a mixin for multiple widgets (#8876) 349 proxiedPrototype = {}, 350 namespace = name.split( "." )[ 0 ]; 351 63 var existingConstructor, constructor, basePrototype; 64 65 // ProxiedPrototype allows the provided prototype to remain unmodified 66 // so that it can be used as a mixin for multiple widgets (#8876) 67 var proxiedPrototype = {}; 68 69 var namespace = name.split( "." )[ 0 ]; 352 70 name = name.split( "." )[ 1 ]; 353 fullName = namespace + "-" + name;71 var fullName = namespace + "-" + name; 354 72 355 73 if ( !prototype ) { … … 358 76 } 359 77 360 // create selector for plugin 78 if ( $.isArray( prototype ) ) { 79 prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); 80 } 81 82 // Create selector for plugin 361 83 $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { 362 84 return !!$.data( elem, fullName ); … … 366 88 existingConstructor = $[ namespace ][ name ]; 367 89 constructor = $[ namespace ][ name ] = function( options, element ) { 368 // allow instantiation without "new" keyword 90 91 // Allow instantiation without "new" keyword 369 92 if ( !this._createWidget ) { 370 93 return new constructor( options, element ); 371 94 } 372 95 373 // allow instantiation without initializing for simple inheritance96 // Allow instantiation without initializing for simple inheritance 374 97 // must use "new" keyword (the code above always passes args) 375 98 if ( arguments.length ) { … … 377 100 } 378 101 }; 379 // extend with the existing constructor to carry over any static properties 102 103 // Extend with the existing constructor to carry over any static properties 380 104 $.extend( constructor, existingConstructor, { 381 105 version: prototype.version, 382 // copy the object used to create the prototype in case we need to 106 107 // Copy the object used to create the prototype in case we need to 383 108 // redefine the widget later 384 109 _proto: $.extend( {}, prototype ), 385 // track widgets that inherit from this widget in case this widget is 110 111 // Track widgets that inherit from this widget in case this widget is 386 112 // redefined after a widget inherits from it 387 113 _childConstructors: [] 388 } );114 } ); 389 115 390 116 basePrototype = new base(); 391 // we need to make the options hash a property directly on the new instance 117 118 // We need to make the options hash a property directly on the new instance 392 119 // otherwise we'll modify the options hash on the prototype that we're 393 120 // inheriting from … … 398 125 return; 399 126 } 400 proxiedPrototype[ prop ] = (function() { 401 var _super = function() { 402 return base.prototype[ prop ].apply( this, arguments ); 403 }, 404 _superApply = function( args ) { 405 return base.prototype[ prop ].apply( this, args ); 406 }; 127 proxiedPrototype[ prop ] = ( function() { 128 function _super() { 129 return base.prototype[ prop ].apply( this, arguments ); 130 } 131 132 function _superApply( args ) { 133 return base.prototype[ prop ].apply( this, args ); 134 } 135 407 136 return function() { 408 var __super = this._super ,409 __superApply = this._superApply,410 returnValue;137 var __super = this._super; 138 var __superApply = this._superApply; 139 var returnValue; 411 140 412 141 this._super = _super; … … 420 149 return returnValue; 421 150 }; 422 } )();423 } );151 } )(); 152 } ); 424 153 constructor.prototype = $.widget.extend( basePrototype, { 154 425 155 // TODO: remove support for widgetEventPrefix 426 156 // always use the name + a colon as the prefix, e.g., draggable:start 427 157 // don't prefix for widgets that aren't DOM-based 428 widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name) : name158 widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name 429 159 }, proxiedPrototype, { 430 160 constructor: constructor, … … 432 162 widgetName: name, 433 163 widgetFullName: fullName 434 } );164 } ); 435 165 436 166 // If this widget is being redefined then we need to find all widgets that … … 442 172 var childPrototype = child.prototype; 443 173 444 // redefine the child widget using the same prototype that was174 // Redefine the child widget using the same prototype that was 445 175 // originally used, but inherit from the new version of the base 446 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto ); 447 }); 448 // remove the list of existing child constructors from the old constructor 176 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, 177 child._proto ); 178 } ); 179 180 // Remove the list of existing child constructors from the old constructor 449 181 // so the old child constructors can be garbage collected 450 182 delete existingConstructor._childConstructors; … … 459 191 460 192 $.widget.extend = function( target ) { 461 var input = widget_slice.call( arguments, 1 ), 462 inputIndex = 0, 463 inputLength = input.length, 464 key, 465 value; 193 var input = widgetSlice.call( arguments, 1 ); 194 var inputIndex = 0; 195 var inputLength = input.length; 196 var key; 197 var value; 198 466 199 for ( ; inputIndex < inputLength; inputIndex++ ) { 467 200 for ( key in input[ inputIndex ] ) { 468 201 value = input[ inputIndex ][ key ]; 469 202 if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { 203 470 204 // Clone objects 471 205 if ( $.isPlainObject( value ) ) { 472 206 target[ key ] = $.isPlainObject( target[ key ] ) ? 473 207 $.widget.extend( {}, target[ key ], value ) : 208 474 209 // Don't extend strings, arrays, etc. with objects 475 210 $.widget.extend( {}, value ); 211 476 212 // Copy everything else by reference 477 213 } else { … … 487 223 var fullName = object.prototype.widgetFullName || name; 488 224 $.fn[ name ] = function( options ) { 489 var isMethodCall = typeof options === "string" ,490 args = widget_slice.call( arguments, 1 ),491 returnValue = this;225 var isMethodCall = typeof options === "string"; 226 var args = widgetSlice.call( arguments, 1 ); 227 var returnValue = this; 492 228 493 229 if ( isMethodCall ) { 494 this.each(function() { 495 var methodValue, 496 instance = $.data( this, fullName ); 497 if ( options === "instance" ) { 498 returnValue = instance; 499 return false; 500 } 501 if ( !instance ) { 502 return $.error( "cannot call methods on " + name + " prior to initialization; " + 503 "attempted to call method '" + options + "'" ); 504 } 505 if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { 506 return $.error( "no such method '" + options + "' for " + name + " widget instance" ); 507 } 508 methodValue = instance[ options ].apply( instance, args ); 509 if ( methodValue !== instance && methodValue !== undefined ) { 510 returnValue = methodValue && methodValue.jquery ? 511 returnValue.pushStack( methodValue.get() ) : 512 methodValue; 513 return false; 514 } 515 }); 230 231 // If this is an empty collection, we need to have the instance method 232 // return undefined instead of the jQuery instance 233 if ( !this.length && options === "instance" ) { 234 returnValue = undefined; 235 } else { 236 this.each( function() { 237 var methodValue; 238 var instance = $.data( this, fullName ); 239 240 if ( options === "instance" ) { 241 returnValue = instance; 242 return false; 243 } 244 245 if ( !instance ) { 246 return $.error( "cannot call methods on " + name + 247 " prior to initialization; " + 248 "attempted to call method '" + options + "'" ); 249 } 250 251 if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { 252 return $.error( "no such method '" + options + "' for " + name + 253 " widget instance" ); 254 } 255 256 methodValue = instance[ options ].apply( instance, args ); 257 258 if ( methodValue !== instance && methodValue !== undefined ) { 259 returnValue = methodValue && methodValue.jquery ? 260 returnValue.pushStack( methodValue.get() ) : 261 methodValue; 262 return false; 263 } 264 } ); 265 } 516 266 } else { 517 267 518 268 // Allow multiple hashes to be passed on init 519 269 if ( args.length ) { 520 options = $.widget.extend.apply( null, [ options ].concat( args) );521 } 522 523 this.each( function() {270 options = $.widget.extend.apply( null, [ options ].concat( args ) ); 271 } 272 273 this.each( function() { 524 274 var instance = $.data( this, fullName ); 525 275 if ( instance ) { … … 531 281 $.data( this, fullName, new object( options, this ) ); 532 282 } 533 } );283 } ); 534 284 } 535 285 … … 545 295 widgetEventPrefix: "", 546 296 defaultElement: "<div>", 297 547 298 options: { 299 classes: {}, 548 300 disabled: false, 549 301 550 // callbacks302 // Callbacks 551 303 create: null 552 304 }, 305 553 306 _createWidget: function( options, element ) { 554 307 element = $( element || this.defaultElement || this )[ 0 ]; 555 308 this.element = $( element ); 556 this.uuid = widget _uuid++;309 this.uuid = widgetUuid++; 557 310 this.eventNamespace = "." + this.widgetName + this.uuid; 558 311 … … 560 313 this.hoverable = $(); 561 314 this.focusable = $(); 315 this.classesElementLookup = {}; 562 316 563 317 if ( element !== this ) { … … 569 323 } 570 324 } 571 } );325 } ); 572 326 this.document = $( element.style ? 573 // element within the document 327 328 // Element within the document 574 329 element.ownerDocument : 575 // element is window or document 330 331 // Element is window or document 576 332 element.document || element ); 577 this.window = $( this.document[ 0].defaultView || this.document[0].parentWindow );333 this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); 578 334 } 579 335 … … 584 340 585 341 this._create(); 342 343 if ( this.options.disabled ) { 344 this._setOptionDisabled( this.options.disabled ); 345 } 346 586 347 this._trigger( "create", null, this._getCreateEventData() ); 587 348 this._init(); 588 349 }, 589 _getCreateOptions: $.noop, 350 351 _getCreateOptions: function() { 352 return {}; 353 }, 354 590 355 _getCreateEventData: $.noop, 356 591 357 _create: $.noop, 358 592 359 _init: $.noop, 593 360 594 361 destroy: function() { 362 var that = this; 363 595 364 this._destroy(); 596 // we can probably remove the unbind calls in 2.0 365 $.each( this.classesElementLookup, function( key, value ) { 366 that._removeClass( value, key ); 367 } ); 368 369 // We can probably remove the unbind calls in 2.0 597 370 // all event bindings should go through this._on() 598 371 this.element 599 .unbind( this.eventNamespace ) 600 .removeData( this.widgetFullName ) 601 // support: jquery <1.6.3 602 // http://bugs.jquery.com/ticket/9413 603 .removeData( $.camelCase( this.widgetFullName ) ); 372 .off( this.eventNamespace ) 373 .removeData( this.widgetFullName ); 604 374 this.widget() 605 .unbind( this.eventNamespace ) 606 .removeAttr( "aria-disabled" ) 607 .removeClass( 608 this.widgetFullName + "-disabled " + 609 "ui-state-disabled" ); 610 611 // clean up events and states 612 this.bindings.unbind( this.eventNamespace ); 613 this.hoverable.removeClass( "ui-state-hover" ); 614 this.focusable.removeClass( "ui-state-focus" ); 615 }, 375 .off( this.eventNamespace ) 376 .removeAttr( "aria-disabled" ); 377 378 // Clean up events and states 379 this.bindings.off( this.eventNamespace ); 380 }, 381 616 382 _destroy: $.noop, 617 383 … … 621 387 622 388 option: function( key, value ) { 623 var options = key ,624 parts,625 curOption,626 i;389 var options = key; 390 var parts; 391 var curOption; 392 var i; 627 393 628 394 if ( arguments.length === 0 ) { 629 // don't return a reference to the internal hash 395 396 // Don't return a reference to the internal hash 630 397 return $.widget.extend( {}, this.options ); 631 398 } 632 399 633 400 if ( typeof key === "string" ) { 634 // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } 401 402 // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } 635 403 options = {}; 636 404 parts = key.split( "." ); … … 659 427 return this; 660 428 }, 429 661 430 _setOptions: function( options ) { 662 431 var key; … … 668 437 return this; 669 438 }, 439 670 440 _setOption: function( key, value ) { 441 if ( key === "classes" ) { 442 this._setOptionClasses( value ); 443 } 444 671 445 this.options[ key ] = value; 672 446 673 447 if ( key === "disabled" ) { 674 this.widget() 675 .toggleClass( this.widgetFullName + "-disabled", !!value ); 676 677 // If the widget is becoming disabled, then nothing is interactive 678 if ( value ) { 679 this.hoverable.removeClass( "ui-state-hover" ); 680 this.focusable.removeClass( "ui-state-focus" ); 681 } 448 this._setOptionDisabled( value ); 682 449 } 683 450 … … 685 452 }, 686 453 454 _setOptionClasses: function( value ) { 455 var classKey, elements, currentElements; 456 457 for ( classKey in value ) { 458 currentElements = this.classesElementLookup[ classKey ]; 459 if ( value[ classKey ] === this.options.classes[ classKey ] || 460 !currentElements || 461 !currentElements.length ) { 462 continue; 463 } 464 465 // We are doing this to create a new jQuery object because the _removeClass() call 466 // on the next line is going to destroy the reference to the current elements being 467 // tracked. We need to save a copy of this collection so that we can add the new classes 468 // below. 469 elements = $( currentElements.get() ); 470 this._removeClass( currentElements, classKey ); 471 472 // We don't use _addClass() here, because that uses this.options.classes 473 // for generating the string of classes. We want to use the value passed in from 474 // _setOption(), this is the new value of the classes option which was passed to 475 // _setOption(). We pass this value directly to _classes(). 476 elements.addClass( this._classes( { 477 element: elements, 478 keys: classKey, 479 classes: value, 480 add: true 481 } ) ); 482 } 483 }, 484 485 _setOptionDisabled: function( value ) { 486 this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); 487 488 // If the widget is becoming disabled, then nothing is interactive 489 if ( value ) { 490 this._removeClass( this.hoverable, null, "ui-state-hover" ); 491 this._removeClass( this.focusable, null, "ui-state-focus" ); 492 } 493 }, 494 687 495 enable: function() { 688 return this._setOptions({ disabled: false }); 689 }, 496 return this._setOptions( { disabled: false } ); 497 }, 498 690 499 disable: function() { 691 return this._setOptions({ disabled: true }); 500 return this._setOptions( { disabled: true } ); 501 }, 502 503 _classes: function( options ) { 504 var full = []; 505 var that = this; 506 507 options = $.extend( { 508 element: this.element, 509 classes: this.options.classes || {} 510 }, options ); 511 512 function processClassString( classes, checkOption ) { 513 var current, i; 514 for ( i = 0; i < classes.length; i++ ) { 515 current = that.classesElementLookup[ classes[ i ] ] || $(); 516 if ( options.add ) { 517 current = $( $.unique( current.get().concat( options.element.get() ) ) ); 518 } else { 519 current = $( current.not( options.element ).get() ); 520 } 521 that.classesElementLookup[ classes[ i ] ] = current; 522 full.push( classes[ i ] ); 523 if ( checkOption && options.classes[ classes[ i ] ] ) { 524 full.push( options.classes[ classes[ i ] ] ); 525 } 526 } 527 } 528 529 this._on( options.element, { 530 "remove": "_untrackClassesElement" 531 } ); 532 533 if ( options.keys ) { 534 processClassString( options.keys.match( /\S+/g ) || [], true ); 535 } 536 if ( options.extra ) { 537 processClassString( options.extra.match( /\S+/g ) || [] ); 538 } 539 540 return full.join( " " ); 541 }, 542 543 _untrackClassesElement: function( event ) { 544 var that = this; 545 $.each( that.classesElementLookup, function( key, value ) { 546 if ( $.inArray( event.target, value ) !== -1 ) { 547 that.classesElementLookup[ key ] = $( value.not( event.target ).get() ); 548 } 549 } ); 550 }, 551 552 _removeClass: function( element, keys, extra ) { 553 return this._toggleClass( element, keys, extra, false ); 554 }, 555 556 _addClass: function( element, keys, extra ) { 557 return this._toggleClass( element, keys, extra, true ); 558 }, 559 560 _toggleClass: function( element, keys, extra, add ) { 561 add = ( typeof add === "boolean" ) ? add : extra; 562 var shift = ( typeof element === "string" || element === null ), 563 options = { 564 extra: shift ? keys : extra, 565 keys: shift ? element : keys, 566 element: shift ? this.element : element, 567 add: add 568 }; 569 options.element.toggleClass( this._classes( options ), add ); 570 return this; 692 571 }, 693 572 694 573 _on: function( suppressDisabledCheck, element, handlers ) { 695 var delegateElement ,696 instance = this;697 698 // no suppressDisabledCheck flag, shuffle arguments574 var delegateElement; 575 var instance = this; 576 577 // No suppressDisabledCheck flag, shuffle arguments 699 578 if ( typeof suppressDisabledCheck !== "boolean" ) { 700 579 handlers = element; … … 703 582 } 704 583 705 // no element argument, shuffle and use this.element584 // No element argument, shuffle and use this.element 706 585 if ( !handlers ) { 707 586 handlers = element; … … 715 594 $.each( handlers, function( event, handler ) { 716 595 function handlerProxy() { 717 // allow widgets to customize the disabled handling 596 597 // Allow widgets to customize the disabled handling 718 598 // - disabled as an array instead of boolean 719 599 // - disabled class as method for disabling individual parts 720 600 if ( !suppressDisabledCheck && 721 601 ( instance.options.disabled === true || 722 $( this ).hasClass( "ui-state-disabled" ) ) ) {602 $( this ).hasClass( "ui-state-disabled" ) ) ) { 723 603 return; 724 604 } … … 727 607 } 728 608 729 // copy the guid so direct unbinding works609 // Copy the guid so direct unbinding works 730 610 if ( typeof handler !== "string" ) { 731 611 handlerProxy.guid = handler.guid = … … 733 613 } 734 614 735 var match = event.match( /^([\w:-]*)\s*(.*)$/ ), 736 eventName = match[1] + instance.eventNamespace, 737 selector = match[2]; 615 var match = event.match( /^([\w:-]*)\s*(.*)$/ ); 616 var eventName = match[ 1 ] + instance.eventNamespace; 617 var selector = match[ 2 ]; 618 738 619 if ( selector ) { 739 delegateElement. delegate( selector, eventName, handlerProxy );620 delegateElement.on( eventName, selector, handlerProxy ); 740 621 } else { 741 element. bind( eventName, handlerProxy );742 } 743 } );622 element.on( eventName, handlerProxy ); 623 } 624 } ); 744 625 }, 745 626 746 627 _off: function( element, eventName ) { 747 eventName = ( eventName || "").split( " " ).join( this.eventNamespace + " " ) +628 eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + 748 629 this.eventNamespace; 749 element. unbind( eventName ).undelegate( eventName );630 element.off( eventName ).off( eventName ); 750 631 751 632 // Clear the stack to avoid memory leaks (#10056) … … 768 649 this._on( element, { 769 650 mouseenter: function( event ) { 770 $( event.currentTarget ).addClass("ui-state-hover" );651 this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); 771 652 }, 772 653 mouseleave: function( event ) { 773 $( event.currentTarget ).removeClass("ui-state-hover" );774 } 775 } );654 this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); 655 } 656 } ); 776 657 }, 777 658 … … 780 661 this._on( element, { 781 662 focusin: function( event ) { 782 $( event.currentTarget ).addClass("ui-state-focus" );663 this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); 783 664 }, 784 665 focusout: function( event ) { 785 $( event.currentTarget ).removeClass("ui-state-focus" );786 } 787 } );666 this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); 667 } 668 } ); 788 669 }, 789 670 790 671 _trigger: function( type, event, data ) { 791 var prop, orig ,792 callback = this.options[ type ];672 var prop, orig; 673 var callback = this.options[ type ]; 793 674 794 675 data = data || {}; … … 797 678 type : 798 679 this.widgetEventPrefix + type ).toLowerCase(); 799 // the original event may come from any element 680 681 // The original event may come from any element 800 682 // so we need to reset the target on the new event 801 683 event.target = this.element[ 0 ]; 802 684 803 // copy original event properties over to the new event685 // Copy original event properties over to the new event 804 686 orig = event.originalEvent; 805 687 if ( orig ) { … … 813 695 this.element.trigger( event, data ); 814 696 return !( $.isFunction( callback ) && 815 callback.apply( this.element[ 0], [ event ].concat( data ) ) === false ||697 callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || 816 698 event.isDefaultPrevented() ); 817 699 } … … 823 705 options = { effect: options }; 824 706 } 825 var hasOptions, 826 effectName = !options ? 827 method : 828 options === true || typeof options === "number" ? 829 defaultEffect : 830 options.effect || defaultEffect; 707 708 var hasOptions; 709 var effectName = !options ? 710 method : 711 options === true || typeof options === "number" ? 712 defaultEffect : 713 options.effect || defaultEffect; 714 831 715 options = options || {}; 832 716 if ( typeof options === "number" ) { 833 717 options = { duration: options }; 834 718 } 719 835 720 hasOptions = !$.isEmptyObject( options ); 836 721 options.complete = callback; 722 837 723 if ( options.delay ) { 838 724 element.delay( options.delay ); 839 725 } 726 840 727 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { 841 728 element[ method ]( options ); … … 843 730 element[ effectName ]( options.duration, options.easing, callback ); 844 731 } else { 845 element.queue( function( next ) {732 element.queue( function( next ) { 846 733 $( this )[ method ](); 847 734 if ( callback ) { … … 849 736 } 850 737 next(); 851 } );738 } ); 852 739 } 853 740 }; 854 } );741 } ); 855 742 856 743 var widget = $.widget; … … 858 745 859 746 /*! 860 * jQuery UI Mouse 1.11.4747 * jQuery UI :data 1.12.1 861 748 * http://jqueryui.com 862 749 * … … 864 751 * Released under the MIT license. 865 752 * http://jquery.org/license 753 */ 754 755 //>>label: :data Selector 756 //>>group: Core 757 //>>description: Selects elements which have data stored under the specified key. 758 //>>docs: http://api.jqueryui.com/data-selector/ 759 760 761 var data = $.extend( $.expr[ ":" ], { 762 data: $.expr.createPseudo ? 763 $.expr.createPseudo( function( dataName ) { 764 return function( elem ) { 765 return !!$.data( elem, dataName ); 766 }; 767 } ) : 768 769 // Support: jQuery <1.8 770 function( elem, i, match ) { 771 return !!$.data( elem, match[ 3 ] ); 772 } 773 } ); 774 775 /*! 776 * jQuery UI Keycode 1.12.1 777 * http://jqueryui.com 866 778 * 867 * http://api.jqueryui.com/mouse/ 779 * Copyright jQuery Foundation and other contributors 780 * Released under the MIT license. 781 * http://jquery.org/license 868 782 */ 869 783 784 //>>label: Keycode 785 //>>group: Core 786 //>>description: Provide keycodes as keynames 787 //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/ 788 789 790 var keycode = $.ui.keyCode = { 791 BACKSPACE: 8, 792 COMMA: 188, 793 DELETE: 46, 794 DOWN: 40, 795 END: 35, 796 ENTER: 13, 797 ESCAPE: 27, 798 HOME: 36, 799 LEFT: 37, 800 PAGE_DOWN: 34, 801 PAGE_UP: 33, 802 PERIOD: 190, 803 RIGHT: 39, 804 SPACE: 32, 805 TAB: 9, 806 UP: 38 807 }; 808 809 810 /*! 811 * jQuery UI Scroll Parent 1.12.1 812 * http://jqueryui.com 813 * 814 * Copyright jQuery Foundation and other contributors 815 * Released under the MIT license. 816 * http://jquery.org/license 817 */ 818 819 //>>label: scrollParent 820 //>>group: Core 821 //>>description: Get the closest ancestor element that is scrollable. 822 //>>docs: http://api.jqueryui.com/scrollParent/ 823 824 825 826 var scrollParent = $.fn.scrollParent = function( includeHidden ) { 827 var position = this.css( "position" ), 828 excludeStaticParent = position === "absolute", 829 overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, 830 scrollParent = this.parents().filter( function() { 831 var parent = $( this ); 832 if ( excludeStaticParent && parent.css( "position" ) === "static" ) { 833 return false; 834 } 835 return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + 836 parent.css( "overflow-x" ) ); 837 } ).eq( 0 ); 838 839 return position === "fixed" || !scrollParent.length ? 840 $( this[ 0 ].ownerDocument || document ) : 841 scrollParent; 842 }; 843 844 845 /*! 846 * jQuery UI Unique ID 1.12.1 847 * http://jqueryui.com 848 * 849 * Copyright jQuery Foundation and other contributors 850 * Released under the MIT license. 851 * http://jquery.org/license 852 */ 853 854 //>>label: uniqueId 855 //>>group: Core 856 //>>description: Functions to generate and remove uniqueId's 857 //>>docs: http://api.jqueryui.com/uniqueId/ 858 859 860 861 var uniqueId = $.fn.extend( { 862 uniqueId: ( function() { 863 var uuid = 0; 864 865 return function() { 866 return this.each( function() { 867 if ( !this.id ) { 868 this.id = "ui-id-" + ( ++uuid ); 869 } 870 } ); 871 }; 872 } )(), 873 874 removeUniqueId: function() { 875 return this.each( function() { 876 if ( /^ui-id-\d+$/.test( this.id ) ) { 877 $( this ).removeAttr( "id" ); 878 } 879 } ); 880 } 881 } ); 882 883 884 885 886 // This file is deprecated 887 var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); 888 889 /*! 890 * jQuery UI Mouse 1.12.1 891 * http://jqueryui.com 892 * 893 * Copyright jQuery Foundation and other contributors 894 * Released under the MIT license. 895 * http://jquery.org/license 896 */ 897 898 //>>label: Mouse 899 //>>group: Widgets 900 //>>description: Abstracts mouse-based interactions to assist in creating certain widgets. 901 //>>docs: http://api.jqueryui.com/mouse/ 902 903 870 904 871 905 var mouseHandled = false; 872 $( document ). mouseup(function() {906 $( document ).on( "mouseup", function() { 873 907 mouseHandled = false; 874 } );875 876 var mouse = $.widget("ui.mouse", {877 version: "1.1 1.4",908 } ); 909 910 var widgetsMouse = $.widget( "ui.mouse", { 911 version: "1.12.1", 878 912 options: { 879 cancel: "input, textarea,button,select,option",913 cancel: "input, textarea, button, select, option", 880 914 distance: 1, 881 915 delay: 0 … … 885 919 886 920 this.element 887 . bind("mousedown." + this.widgetName, function(event) {888 return that._mouseDown( event);889 } )890 . bind("click." + this.widgetName, function(event) {891 if ( true === $.data(event.target, that.widgetName + ".preventClickEvent")) {892 $.removeData( event.target, that.widgetName + ".preventClickEvent");921 .on( "mousedown." + this.widgetName, function( event ) { 922 return that._mouseDown( event ); 923 } ) 924 .on( "click." + this.widgetName, function( event ) { 925 if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) { 926 $.removeData( event.target, that.widgetName + ".preventClickEvent" ); 893 927 event.stopImmediatePropagation(); 894 928 return false; 895 929 } 896 } );930 } ); 897 931 898 932 this.started = false; … … 902 936 // other instances of mouse 903 937 _mouseDestroy: function() { 904 this.element. unbind("." + this.widgetName);938 this.element.off( "." + this.widgetName ); 905 939 if ( this._mouseMoveDelegate ) { 906 940 this.document 907 .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate) 908 .unbind("mouseup." + this.widgetName, this._mouseUpDelegate); 909 } 910 }, 911 912 _mouseDown: function(event) { 941 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 942 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 943 } 944 }, 945 946 _mouseDown: function( event ) { 947 913 948 // don't let more than one widget handle mouseStart 914 949 if ( mouseHandled ) { … … 918 953 this._mouseMoved = false; 919 954 920 // we may have missed mouseup (out of window)921 ( this._mouseStarted && this._mouseUp(event));955 // We may have missed mouseup (out of window) 956 ( this._mouseStarted && this._mouseUp( event ) ); 922 957 923 958 this._mouseDownEvent = event; 924 959 925 960 var that = this, 926 btnIsLeft = (event.which === 1), 961 btnIsLeft = ( event.which === 1 ), 962 927 963 // event.target.nodeName works around a bug in IE 8 with 928 964 // disabled inputs (#7620) 929 elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false); 930 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { 965 elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? 966 $( event.target ).closest( this.options.cancel ).length : false ); 967 if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) { 931 968 return true; 932 969 } 933 970 934 971 this.mouseDelayMet = !this.options.delay; 935 if ( !this.mouseDelayMet) {936 this._mouseDelayTimer = setTimeout( function() {972 if ( !this.mouseDelayMet ) { 973 this._mouseDelayTimer = setTimeout( function() { 937 974 that.mouseDelayMet = true; 938 }, this.options.delay );939 } 940 941 if ( this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {942 this._mouseStarted = ( this._mouseStart(event) !== false);943 if ( !this._mouseStarted) {975 }, this.options.delay ); 976 } 977 978 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 979 this._mouseStarted = ( this._mouseStart( event ) !== false ); 980 if ( !this._mouseStarted ) { 944 981 event.preventDefault(); 945 982 return true; … … 948 985 949 986 // Click event may never have fired (Gecko & Opera) 950 if ( true === $.data(event.target, this.widgetName + ".preventClickEvent")) {951 $.removeData( event.target, this.widgetName + ".preventClickEvent");952 } 953 954 // these delegates are required to keep context955 this._mouseMoveDelegate = function( event) {956 return that._mouseMove( event);987 if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) { 988 $.removeData( event.target, this.widgetName + ".preventClickEvent" ); 989 } 990 991 // These delegates are required to keep context 992 this._mouseMoveDelegate = function( event ) { 993 return that._mouseMove( event ); 957 994 }; 958 this._mouseUpDelegate = function( event) {959 return that._mouseUp( event);995 this._mouseUpDelegate = function( event ) { 996 return that._mouseUp( event ); 960 997 }; 961 998 962 999 this.document 963 . bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )964 . bind( "mouseup." + this.widgetName, this._mouseUpDelegate );1000 .on( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 1001 .on( "mouseup." + this.widgetName, this._mouseUpDelegate ); 965 1002 966 1003 event.preventDefault(); … … 970 1007 }, 971 1008 972 _mouseMove: function(event) { 1009 _mouseMove: function( event ) { 1010 973 1011 // Only check for mouseups outside the document if you've moved inside the document 974 1012 // at least once. This prevents the firing of mouseup in the case of IE<9, which will … … 976 1014 // Support: IE <9 977 1015 if ( this._mouseMoved ) { 1016 978 1017 // IE mouseup check - mouseup happened when mouse was out of window 979 if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) { 980 return this._mouseUp(event); 1018 if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && 1019 !event.button ) { 1020 return this._mouseUp( event ); 981 1021 982 1022 // Iframe mouseup check - mouseup occurred in another document 983 1023 } else if ( !event.which ) { 984 return this._mouseUp( event ); 1024 1025 // Support: Safari <=8 - 9 1026 // Safari sets which to 0 if you press any of the following keys 1027 // during a drag (#14461) 1028 if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || 1029 event.originalEvent.metaKey || event.originalEvent.shiftKey ) { 1030 this.ignoreMissingWhich = true; 1031 } else if ( !this.ignoreMissingWhich ) { 1032 return this._mouseUp( event ); 1033 } 985 1034 } 986 1035 } … … 990 1039 } 991 1040 992 if ( this._mouseStarted) {993 this._mouseDrag( event);1041 if ( this._mouseStarted ) { 1042 this._mouseDrag( event ); 994 1043 return event.preventDefault(); 995 1044 } 996 1045 997 if ( this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {1046 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 998 1047 this._mouseStarted = 999 ( this._mouseStart(this._mouseDownEvent, event) !== false);1000 ( this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));1048 ( this._mouseStart( this._mouseDownEvent, event ) !== false ); 1049 ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) ); 1001 1050 } 1002 1051 … … 1004 1053 }, 1005 1054 1006 _mouseUp: function( event) {1055 _mouseUp: function( event ) { 1007 1056 this.document 1008 . unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )1009 . unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );1010 1011 if ( this._mouseStarted) {1057 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 1058 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 1059 1060 if ( this._mouseStarted ) { 1012 1061 this._mouseStarted = false; 1013 1062 1014 if (event.target === this._mouseDownEvent.target) { 1015 $.data(event.target, this.widgetName + ".preventClickEvent", true); 1016 } 1017 1018 this._mouseStop(event); 1019 } 1020 1063 if ( event.target === this._mouseDownEvent.target ) { 1064 $.data( event.target, this.widgetName + ".preventClickEvent", true ); 1065 } 1066 1067 this._mouseStop( event ); 1068 } 1069 1070 if ( this._mouseDelayTimer ) { 1071 clearTimeout( this._mouseDelayTimer ); 1072 delete this._mouseDelayTimer; 1073 } 1074 1075 this.ignoreMissingWhich = false; 1021 1076 mouseHandled = false; 1022 return false;1023 }, 1024 1025 _mouseDistanceMet: function( event) {1026 return ( Math.max(1027 Math.abs( this._mouseDownEvent.pageX - event.pageX),1028 Math.abs( this._mouseDownEvent.pageY - event.pageY)1077 event.preventDefault(); 1078 }, 1079 1080 _mouseDistanceMet: function( event ) { 1081 return ( Math.max( 1082 Math.abs( this._mouseDownEvent.pageX - event.pageX ), 1083 Math.abs( this._mouseDownEvent.pageY - event.pageY ) 1029 1084 ) >= this.options.distance 1030 1085 ); 1031 1086 }, 1032 1087 1033 _mouseDelayMet: function( /* event */) {1088 _mouseDelayMet: function( /* event */ ) { 1034 1089 return this.mouseDelayMet; 1035 1090 }, 1036 1091 1037 1092 // These are placeholder methods, to be overriden by extending plugin 1038 _mouseStart: function(/* event */) {}, 1039 _mouseDrag: function(/* event */) {}, 1040 _mouseStop: function(/* event */) {}, 1041 _mouseCapture: function(/* event */) { return true; } 1042 }); 1093 _mouseStart: function( /* event */ ) {}, 1094 _mouseDrag: function( /* event */ ) {}, 1095 _mouseStop: function( /* event */ ) {}, 1096 _mouseCapture: function( /* event */ ) { return true; } 1097 } ); 1098 1099 1100 1101 1102 // $.ui.plugin is deprecated. Use $.widget() extensions instead. 1103 var plugin = $.ui.plugin = { 1104 add: function( module, option, set ) { 1105 var i, 1106 proto = $.ui[ module ].prototype; 1107 for ( i in set ) { 1108 proto.plugins[ i ] = proto.plugins[ i ] || []; 1109 proto.plugins[ i ].push( [ option, set[ i ] ] ); 1110 } 1111 }, 1112 call: function( instance, name, args, allowDisconnected ) { 1113 var i, 1114 set = instance.plugins[ name ]; 1115 1116 if ( !set ) { 1117 return; 1118 } 1119 1120 if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || 1121 instance.element[ 0 ].parentNode.nodeType === 11 ) ) { 1122 return; 1123 } 1124 1125 for ( i = 0; i < set.length; i++ ) { 1126 if ( instance.options[ set[ i ][ 0 ] ] ) { 1127 set[ i ][ 1 ].apply( instance.element, args ); 1128 } 1129 } 1130 } 1131 }; 1132 1133 1134 1135 var safeActiveElement = $.ui.safeActiveElement = function( document ) { 1136 var activeElement; 1137 1138 // Support: IE 9 only 1139 // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> 1140 try { 1141 activeElement = document.activeElement; 1142 } catch ( error ) { 1143 activeElement = document.body; 1144 } 1145 1146 // Support: IE 9 - 11 only 1147 // IE may return null instead of an element 1148 // Interestingly, this only seems to occur when NOT in an iframe 1149 if ( !activeElement ) { 1150 activeElement = document.body; 1151 } 1152 1153 // Support: IE 11 only 1154 // IE11 returns a seemingly empty object in some cases when accessing 1155 // document.activeElement from an <iframe> 1156 if ( !activeElement.nodeName ) { 1157 activeElement = document.body; 1158 } 1159 1160 return activeElement; 1161 }; 1162 1163 1164 1165 var safeBlur = $.ui.safeBlur = function( element ) { 1166 1167 // Support: IE9 - 10 only 1168 // If the <body> is blurred, IE will switch windows, see #9420 1169 if ( element && element.nodeName.toLowerCase() !== "body" ) { 1170 $( element ).trigger( "blur" ); 1171 } 1172 }; 1043 1173 1044 1174 1045 1175 /*! 1046 * jQuery UI Draggable 1.1 1.41176 * jQuery UI Draggable 1.12.1 1047 1177 * http://jqueryui.com 1048 1178 * … … 1050 1180 * Released under the MIT license. 1051 1181 * http://jquery.org/license 1052 *1053 * http://api.jqueryui.com/draggable/1054 1182 */ 1055 1183 1056 1057 $.widget("ui.draggable", $.ui.mouse, { 1058 version: "1.11.4", 1184 //>>label: Draggable 1185 //>>group: Interactions 1186 //>>description: Enables dragging functionality for any element. 1187 //>>docs: http://api.jqueryui.com/draggable/ 1188 //>>demos: http://jqueryui.com/draggable/ 1189 //>>css.structure: ../../themes/base/draggable.css 1190 1191 1192 1193 $.widget( "ui.draggable", $.ui.mouse, { 1194 version: "1.12.1", 1059 1195 widgetEventPrefix: "drag", 1060 1196 options: { … … 1084 1220 zIndex: false, 1085 1221 1086 // callbacks1222 // Callbacks 1087 1223 drag: null, 1088 1224 start: null, … … 1094 1230 this._setPositionRelative(); 1095 1231 } 1096 if (this.options.addClasses){ 1097 this.element.addClass("ui-draggable"); 1098 } 1099 if (this.options.disabled){ 1100 this.element.addClass("ui-draggable-disabled"); 1232 if ( this.options.addClasses ) { 1233 this._addClass( "ui-draggable" ); 1101 1234 } 1102 1235 this._setHandleClassName(); … … 1118 1251 return; 1119 1252 } 1120 this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );1121 1253 this._removeHandleClassName(); 1122 1254 this._mouseDestroy(); 1123 1255 }, 1124 1256 1125 _mouseCapture: function( event) {1257 _mouseCapture: function( event ) { 1126 1258 var o = this.options; 1127 1259 1260 // Among others, prevent a drag on a resizable-handle 1261 if ( this.helper || o.disabled || 1262 $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) { 1263 return false; 1264 } 1265 1266 //Quit if we're not on a valid handle 1267 this.handle = this._getHandle( event ); 1268 if ( !this.handle ) { 1269 return false; 1270 } 1271 1128 1272 this._blurActiveElement( event ); 1129 1273 1130 // among others, prevent a drag on a resizable-handle1131 if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {1132 return false;1133 }1134 1135 //Quit if we're not on a valid handle1136 this.handle = this._getHandle(event);1137 if (!this.handle) {1138 return false;1139 }1140 1141 1274 this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix ); 1142 1275 … … 1146 1279 1147 1280 _blockFrames: function( selector ) { 1148 this.iframeBlocks = this.document.find( selector ).map( function() {1281 this.iframeBlocks = this.document.find( selector ).map( function() { 1149 1282 var iframe = $( this ); 1150 1283 … … 1155 1288 .outerHeight( iframe.outerHeight() ) 1156 1289 .offset( iframe.offset() )[ 0 ]; 1157 } );1290 } ); 1158 1291 }, 1159 1292 … … 1166 1299 1167 1300 _blurActiveElement: function( event ) { 1168 var document = this.document[ 0 ]; 1169 1170 // Only need to blur if the event occurred on the draggable itself, see #10527 1171 if ( !this.handleElement.is( event.target ) ) { 1301 var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ), 1302 target = $( event.target ); 1303 1304 // Don't blur if the event occurred on an element that is within 1305 // the currently focused element 1306 // See #10527, #12472 1307 if ( target.closest( activeElement ).length ) { 1172 1308 return; 1173 1309 } 1174 1310 1175 // support: IE9 1176 // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> 1177 try { 1178 1179 // Support: IE9, IE10 1180 // If the <body> is blurred, IE will switch windows, see #9520 1181 if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) { 1182 1183 // Blur any element that currently has focus, see #4261 1184 $( document.activeElement ).blur(); 1185 } 1186 } catch ( error ) {} 1187 }, 1188 1189 _mouseStart: function(event) { 1311 // Blur any element that currently has focus, see #4261 1312 $.ui.safeBlur( activeElement ); 1313 }, 1314 1315 _mouseStart: function( event ) { 1190 1316 1191 1317 var o = this.options; 1192 1318 1193 1319 //Create and append the visible helper 1194 this.helper = this._createHelper( event);1195 1196 this. helper.addClass("ui-draggable-dragging");1320 this.helper = this._createHelper( event ); 1321 1322 this._addClass( this.helper, "ui-draggable-dragging" ); 1197 1323 1198 1324 //Cache the helper size … … 1200 1326 1201 1327 //If ddmanager is used for droppables, set the global draggable 1202 if ( $.ui.ddmanager) {1328 if ( $.ui.ddmanager ) { 1203 1329 $.ui.ddmanager.current = this; 1204 1330 } … … 1216 1342 this.scrollParent = this.helper.scrollParent( true ); 1217 1343 this.offsetParent = this.helper.offsetParent(); 1218 this.hasFixedAncestor = this.helper.parents().filter( function() {1344 this.hasFixedAncestor = this.helper.parents().filter( function() { 1219 1345 return $( this ).css( "position" ) === "fixed"; 1220 } ).length > 0;1346 } ).length > 0; 1221 1347 1222 1348 //The element's absolute position on the page minus margins … … 1230 1356 1231 1357 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied 1232 ( o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));1358 ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); 1233 1359 1234 1360 //Set a containment if given in the options … … 1236 1362 1237 1363 //Trigger event + callbacks 1238 if ( this._trigger("start", event) === false) {1364 if ( this._trigger( "start", event ) === false ) { 1239 1365 this._clear(); 1240 1366 return false; … … 1245 1371 1246 1372 //Prepare the droppable offsets 1247 if ($.ui.ddmanager && !o.dropBehaviour) { 1248 $.ui.ddmanager.prepareOffsets(this, event); 1249 } 1250 1251 // Reset helper's right/bottom css if they're set and set explicit width/height instead 1252 // as this prevents resizing of elements with right/bottom set (see #7772) 1253 this._normalizeRightBottom(); 1254 1255 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position 1256 1257 //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) 1373 if ( $.ui.ddmanager && !o.dropBehaviour ) { 1374 $.ui.ddmanager.prepareOffsets( this, event ); 1375 } 1376 1377 // Execute the drag once - this causes the helper not to be visible before getting its 1378 // correct position 1379 this._mouseDrag( event, true ); 1380 1381 // If the ddmanager is used for droppables, inform the manager that dragging has started 1382 // (see #5003) 1258 1383 if ( $.ui.ddmanager ) { 1259 $.ui.ddmanager.dragStart( this, event);1384 $.ui.ddmanager.dragStart( this, event ); 1260 1385 } 1261 1386 … … 1278 1403 }, 1279 1404 1280 _mouseDrag: function(event, noPropagation) { 1405 _mouseDrag: function( event, noPropagation ) { 1406 1281 1407 // reset any necessary cached properties (see #5009) 1282 1408 if ( this.hasFixedAncestor ) { … … 1286 1412 //Compute the helpers position 1287 1413 this.position = this._generatePosition( event, true ); 1288 this.positionAbs = this._convertPositionTo( "absolute");1414 this.positionAbs = this._convertPositionTo( "absolute" ); 1289 1415 1290 1416 //Call plugins and callbacks and use the resulting position if something is returned 1291 if ( !noPropagation) {1417 if ( !noPropagation ) { 1292 1418 var ui = this._uiHash(); 1293 if ( this._trigger("drag", event, ui) === false) {1294 this._mouseUp( {});1419 if ( this._trigger( "drag", event, ui ) === false ) { 1420 this._mouseUp( new $.Event( "mouseup", event ) ); 1295 1421 return false; 1296 1422 } … … 1301 1427 this.helper[ 0 ].style.top = this.position.top + "px"; 1302 1428 1303 if ( $.ui.ddmanager) {1304 $.ui.ddmanager.drag( this, event);1429 if ( $.ui.ddmanager ) { 1430 $.ui.ddmanager.drag( this, event ); 1305 1431 } 1306 1432 … … 1308 1434 }, 1309 1435 1310 _mouseStop: function( event) {1436 _mouseStop: function( event ) { 1311 1437 1312 1438 //If we are using droppables, inform the manager about the drop 1313 1439 var that = this, 1314 1440 dropped = false; 1315 if ( $.ui.ddmanager && !this.options.dropBehaviour) {1316 dropped = $.ui.ddmanager.drop( this, event);1441 if ( $.ui.ddmanager && !this.options.dropBehaviour ) { 1442 dropped = $.ui.ddmanager.drop( this, event ); 1317 1443 } 1318 1444 1319 1445 //if a drop comes from outside (a sortable) 1320 if ( this.dropped) {1446 if ( this.dropped ) { 1321 1447 dropped = this.dropped; 1322 1448 this.dropped = false; 1323 1449 } 1324 1450 1325 if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { 1326 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { 1327 if (that._trigger("stop", event) !== false) { 1328 that._clear(); 1329 } 1330 }); 1451 if ( ( this.options.revert === "invalid" && !dropped ) || 1452 ( this.options.revert === "valid" && dropped ) || 1453 this.options.revert === true || ( $.isFunction( this.options.revert ) && 1454 this.options.revert.call( this.element, dropped ) ) 1455 ) { 1456 $( this.helper ).animate( 1457 this.originalPosition, 1458 parseInt( this.options.revertDuration, 10 ), 1459 function() { 1460 if ( that._trigger( "stop", event ) !== false ) { 1461 that._clear(); 1462 } 1463 } 1464 ); 1331 1465 } else { 1332 if ( this._trigger("stop", event) !== false) {1466 if ( this._trigger( "stop", event ) !== false ) { 1333 1467 this._clear(); 1334 1468 } … … 1341 1475 this._unblockFrames(); 1342 1476 1343 //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) 1477 // If the ddmanager is used for droppables, inform the manager that dragging has stopped 1478 // (see #5003) 1344 1479 if ( $.ui.ddmanager ) { 1345 $.ui.ddmanager.dragStop( this, event);1480 $.ui.ddmanager.dragStop( this, event ); 1346 1481 } 1347 1482 1348 1483 // Only need to focus if the event occurred on the draggable itself, see #10527 1349 1484 if ( this.handleElement.is( event.target ) ) { 1350 // The interaction is over; whether or not the click resulted in a drag, focus the element 1351 this.element.focus(); 1352 } 1353 1354 return $.ui.mouse.prototype._mouseUp.call(this, event); 1485 1486 // The interaction is over; whether or not the click resulted in a drag, 1487 // focus the element 1488 this.element.trigger( "focus" ); 1489 } 1490 1491 return $.ui.mouse.prototype._mouseUp.call( this, event ); 1355 1492 }, 1356 1493 1357 1494 cancel: function() { 1358 1495 1359 if ( this.helper.is(".ui-draggable-dragging")) {1360 this._mouseUp( {});1496 if ( this.helper.is( ".ui-draggable-dragging" ) ) { 1497 this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) ); 1361 1498 } else { 1362 1499 this._clear(); … … 1367 1504 }, 1368 1505 1369 _getHandle: function( event) {1506 _getHandle: function( event ) { 1370 1507 return this.options.handle ? 1371 1508 !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : … … 1376 1513 this.handleElement = this.options.handle ? 1377 1514 this.element.find( this.options.handle ) : this.element; 1378 this. handleElement.addClass("ui-draggable-handle" );1515 this._addClass( this.handleElement, "ui-draggable-handle" ); 1379 1516 }, 1380 1517 1381 1518 _removeHandleClassName: function() { 1382 this. handleElement.removeClass("ui-draggable-handle" );1383 }, 1384 1385 _createHelper: function( event) {1519 this._removeClass( this.handleElement, "ui-draggable-handle" ); 1520 }, 1521 1522 _createHelper: function( event ) { 1386 1523 1387 1524 var o = this.options, … … 1393 1530 this.element ); 1394 1531 1395 if (!helper.parents("body").length) { 1396 helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo)); 1397 } 1398 1399 // http://bugs.jqueryui.com/ticket/9446 1532 if ( !helper.parents( "body" ).length ) { 1533 helper.appendTo( ( o.appendTo === "parent" ? 1534 this.element[ 0 ].parentNode : 1535 o.appendTo ) ); 1536 } 1537 1538 // Http://bugs.jqueryui.com/ticket/9446 1400 1539 // a helper function can return the original element 1401 1540 // which wouldn't have been set to relative in _create … … 1404 1543 } 1405 1544 1406 if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) { 1407 helper.css("position", "absolute"); 1545 if ( helper[ 0 ] !== this.element[ 0 ] && 1546 !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) { 1547 helper.css( "position", "absolute" ); 1408 1548 } 1409 1549 … … 1418 1558 }, 1419 1559 1420 _adjustOffsetFromHelper: function( obj) {1421 if ( typeof obj === "string") {1422 obj = obj.split( " ");1423 } 1424 if ( $.isArray(obj)) {1425 obj = { left: +obj[ 0], top: +obj[1] || 0 };1426 } 1427 if ( "left" in obj) {1560 _adjustOffsetFromHelper: function( obj ) { 1561 if ( typeof obj === "string" ) { 1562 obj = obj.split( " " ); 1563 } 1564 if ( $.isArray( obj ) ) { 1565 obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; 1566 } 1567 if ( "left" in obj ) { 1428 1568 this.offset.click.left = obj.left + this.margins.left; 1429 1569 } 1430 if ( "right" in obj) {1570 if ( "right" in obj ) { 1431 1571 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 1432 1572 } 1433 if ( "top" in obj) {1573 if ( "top" in obj ) { 1434 1574 this.offset.click.top = obj.top + this.margins.top; 1435 1575 } 1436 if ( "bottom" in obj) {1576 if ( "bottom" in obj ) { 1437 1577 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 1438 1578 } … … 1449 1589 document = this.document[ 0 ]; 1450 1590 1451 // This is a special case where we need to modify a offset calculated on start, since the following happened: 1452 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent 1453 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that 1454 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag 1455 if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) { 1591 // This is a special case where we need to modify a offset calculated on start, since the 1592 // following happened: 1593 // 1. The position of the helper is absolute, so it's position is calculated based on the 1594 // next positioned parent 1595 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't 1596 // the document, which means that the scroll is included in the initial calculation of the 1597 // offset of the parent, and never recalculated upon drag 1598 if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document && 1599 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { 1456 1600 po.left += this.scrollParent.scrollLeft(); 1457 1601 po.top += this.scrollParent.scrollTop(); … … 1463 1607 1464 1608 return { 1465 top: po.top + ( parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),1466 left: po.left + ( parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)1609 top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ), 1610 left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 ) 1467 1611 }; 1468 1612 … … 1478 1622 1479 1623 return { 1480 top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ), 1481 left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 ) 1624 top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + 1625 ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ), 1626 left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + 1627 ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 ) 1482 1628 }; 1483 1629 … … 1486 1632 _cacheMargins: function() { 1487 1633 this.margins = { 1488 left: ( parseInt(this.element.css("marginLeft"), 10) || 0),1489 top: ( parseInt(this.element.css("marginTop"), 10) || 0),1490 right: ( parseInt(this.element.css("marginRight"), 10) || 0),1491 bottom: ( parseInt(this.element.css("marginBottom"), 10) || 0)1634 left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ), 1635 top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ), 1636 right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ), 1637 bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 ) 1492 1638 }; 1493 1639 }, … … 1517 1663 $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, 1518 1664 $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, 1519 $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left, 1520 $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top 1665 $( window ).scrollLeft() + $( window ).width() - 1666 this.helperProportions.width - this.margins.left, 1667 $( window ).scrollTop() + 1668 ( $( window ).height() || document.body.parentNode.scrollHeight ) - 1669 this.helperProportions.height - this.margins.top 1521 1670 ]; 1522 1671 return; 1523 1672 } 1524 1673 1525 if ( o.containment === "document" ) {1674 if ( o.containment === "document" ) { 1526 1675 this.containment = [ 1527 1676 0, 1528 1677 0, 1529 1678 $( document ).width() - this.helperProportions.width - this.margins.left, 1530 ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top 1679 ( $( document ).height() || document.body.parentNode.scrollHeight ) - 1680 this.helperProportions.height - this.margins.top 1531 1681 ]; 1532 1682 return; … … 1552 1702 1553 1703 this.containment = [ 1554 ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), 1555 ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ), 1704 ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + 1705 ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), 1706 ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + 1707 ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ), 1556 1708 ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - 1557 1709 ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - … … 1570 1722 }, 1571 1723 1572 _convertPositionTo: function( d, pos) {1573 1574 if ( !pos) {1724 _convertPositionTo: function( d, pos ) { 1725 1726 if ( !pos ) { 1575 1727 pos = this.position; 1576 1728 } … … 1581 1733 return { 1582 1734 top: ( 1583 pos.top + // The absolute mouse position 1584 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent 1585 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) 1586 ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod) 1735 1736 // The absolute mouse position 1737 pos.top + 1738 1739 // Only for relative positioned nodes: Relative offset from element to offset parent 1740 this.offset.relative.top * mod + 1741 1742 // The offsetParent's offset without borders (offset + border) 1743 this.offset.parent.top * mod - 1744 ( ( this.cssPosition === "fixed" ? 1745 -this.offset.scroll.top : 1746 ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod ) 1587 1747 ), 1588 1748 left: ( 1589 pos.left + // The absolute mouse position 1590 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent 1591 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) 1592 ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod) 1749 1750 // The absolute mouse position 1751 pos.left + 1752 1753 // Only for relative positioned nodes: Relative offset from element to offset parent 1754 this.offset.relative.left * mod + 1755 1756 // The offsetParent's offset without borders (offset + border) 1757 this.offset.parent.left * mod - 1758 ( ( this.cssPosition === "fixed" ? 1759 -this.offset.scroll.left : 1760 ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod ) 1593 1761 ) 1594 1762 }; … … 1620 1788 if ( constrainPosition ) { 1621 1789 if ( this.containment ) { 1622 if ( this.relativeContainer ) {1790 if ( this.relativeContainer ) { 1623 1791 co = this.relativeContainer.offset(); 1624 1792 containment = [ … … 1632 1800 } 1633 1801 1634 if (event.pageX - this.offset.click.left < containment[0]) { 1635 pageX = containment[0] + this.offset.click.left; 1636 } 1637 if (event.pageY - this.offset.click.top < containment[1]) { 1638 pageY = containment[1] + this.offset.click.top; 1639 } 1640 if (event.pageX - this.offset.click.left > containment[2]) { 1641 pageX = containment[2] + this.offset.click.left; 1642 } 1643 if (event.pageY - this.offset.click.top > containment[3]) { 1644 pageY = containment[3] + this.offset.click.top; 1645 } 1646 } 1647 1648 if (o.grid) { 1649 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) 1650 top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; 1651 pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; 1652 1653 left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX; 1654 pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; 1802 if ( event.pageX - this.offset.click.left < containment[ 0 ] ) { 1803 pageX = containment[ 0 ] + this.offset.click.left; 1804 } 1805 if ( event.pageY - this.offset.click.top < containment[ 1 ] ) { 1806 pageY = containment[ 1 ] + this.offset.click.top; 1807 } 1808 if ( event.pageX - this.offset.click.left > containment[ 2 ] ) { 1809 pageX = containment[ 2 ] + this.offset.click.left; 1810 } 1811 if ( event.pageY - this.offset.click.top > containment[ 3 ] ) { 1812 pageY = containment[ 3 ] + this.offset.click.top; 1813 } 1814 } 1815 1816 if ( o.grid ) { 1817 1818 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid 1819 // argument errors in IE (see ticket #6950) 1820 top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY - 1821 this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY; 1822 pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] || 1823 top - this.offset.click.top > containment[ 3 ] ) ? 1824 top : 1825 ( ( top - this.offset.click.top >= containment[ 1 ] ) ? 1826 top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top; 1827 1828 left = o.grid[ 0 ] ? this.originalPageX + 1829 Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] : 1830 this.originalPageX; 1831 pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] || 1832 left - this.offset.click.left > containment[ 2 ] ) ? 1833 left : 1834 ( ( left - this.offset.click.left >= containment[ 0 ] ) ? 1835 left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left; 1655 1836 } 1656 1837 … … 1666 1847 return { 1667 1848 top: ( 1668 pageY - // The absolute mouse position 1669 this.offset.click.top - // Click offset (relative to the element) 1670 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent 1671 this.offset.parent.top + // The offsetParent's offset without borders (offset + border) 1672 ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) 1849 1850 // The absolute mouse position 1851 pageY - 1852 1853 // Click offset (relative to the element) 1854 this.offset.click.top - 1855 1856 // Only for relative positioned nodes: Relative offset from element to offset parent 1857 this.offset.relative.top - 1858 1859 // The offsetParent's offset without borders (offset + border) 1860 this.offset.parent.top + 1861 ( this.cssPosition === "fixed" ? 1862 -this.offset.scroll.top : 1863 ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) 1673 1864 ), 1674 1865 left: ( 1675 pageX - // The absolute mouse position 1676 this.offset.click.left - // Click offset (relative to the element) 1677 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent 1678 this.offset.parent.left + // The offsetParent's offset without borders (offset + border) 1679 ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) 1866 1867 // The absolute mouse position 1868 pageX - 1869 1870 // Click offset (relative to the element) 1871 this.offset.click.left - 1872 1873 // Only for relative positioned nodes: Relative offset from element to offset parent 1874 this.offset.relative.left - 1875 1876 // The offsetParent's offset without borders (offset + border) 1877 this.offset.parent.left + 1878 ( this.cssPosition === "fixed" ? 1879 -this.offset.scroll.left : 1880 ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) 1680 1881 ) 1681 1882 }; … … 1684 1885 1685 1886 _clear: function() { 1686 this. helper.removeClass("ui-draggable-dragging");1687 if ( this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {1887 this._removeClass( this.helper, "ui-draggable-dragging" ); 1888 if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) { 1688 1889 this.helper.remove(); 1689 1890 } … … 1692 1893 if ( this.destroyOnClear ) { 1693 1894 this.destroy(); 1694 }1695 },1696 1697 _normalizeRightBottom: function() {1698 if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {1699 this.helper.width( this.helper.width() );1700 this.helper.css( "right", "auto" );1701 }1702 if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {1703 this.helper.height( this.helper.height() );1704 this.helper.css( "bottom", "auto" );1705 1895 } 1706 1896 }, … … 1731 1921 } 1732 1922 1733 } );1923 } ); 1734 1924 1735 1925 $.ui.plugin.add( "draggable", "connectToSortable", { … … 1737 1927 var uiSortable = $.extend( {}, ui, { 1738 1928 item: draggable.element 1739 } );1929 } ); 1740 1930 1741 1931 draggable.sortables = []; 1742 $( draggable.options.connectToSortable ).each( function() {1932 $( draggable.options.connectToSortable ).each( function() { 1743 1933 var sortable = $( this ).sortable( "instance" ); 1744 1934 … … 1746 1936 draggable.sortables.push( sortable ); 1747 1937 1748 // refreshPositions is called at drag start to refresh the containerCache1938 // RefreshPositions is called at drag start to refresh the containerCache 1749 1939 // which is used in drag. This ensures it's initialized and synchronized 1750 1940 // with any changes that might have happened on the page since initialization. 1751 1941 sortable.refreshPositions(); 1752 sortable._trigger( "activate", event, uiSortable);1753 } 1754 } );1942 sortable._trigger( "activate", event, uiSortable ); 1943 } 1944 } ); 1755 1945 }, 1756 1946 stop: function( event, ui, draggable ) { 1757 1947 var uiSortable = $.extend( {}, ui, { 1758 1948 item: draggable.element 1759 } );1949 } ); 1760 1950 1761 1951 draggable.cancelHelperRemoval = false; … … 1780 1970 }; 1781 1971 1782 sortable._mouseStop( event);1972 sortable._mouseStop( event ); 1783 1973 1784 1974 // Once drag has ended, the sortable should return to using … … 1786 1976 sortable.options.helper = sortable.options._helper; 1787 1977 } else { 1978 1788 1979 // Prevent this Sortable from removing the helper. 1789 1980 // However, don't set the draggable to remove the helper … … 1793 1984 sortable._trigger( "deactivate", event, uiSortable ); 1794 1985 } 1795 } );1986 } ); 1796 1987 }, 1797 1988 drag: function( event, ui, draggable ) { … … 1809 2000 1810 2001 $.each( draggable.sortables, function() { 2002 1811 2003 // Copy over variables that sortable's _intersectsWith uses 1812 2004 this.positionAbs = draggable.positionAbs; … … 1821 2013 1822 2014 return innermostIntersecting; 1823 } );2015 } ); 1824 2016 } 1825 2017 1826 2018 if ( innermostIntersecting ) { 2019 1827 2020 // If it intersects, we use a little isOver variable and set it once, 1828 2021 // so that the move-in stuff gets fired only once. … … 1869 2062 $.each( draggable.sortables, function() { 1870 2063 this.refreshPositions(); 1871 } );1872 1873 // hack so receive/update callbacks work (mostly)2064 } ); 2065 2066 // Hack so receive/update callbacks work (mostly) 1874 2067 draggable.currentItem = draggable.element; 1875 2068 sortable.fromOutside = draggable; … … 1878 2071 if ( sortable.currentItem ) { 1879 2072 sortable._mouseDrag( event ); 2073 1880 2074 // Copy the sortable's position because the draggable's can potentially reflect 1881 2075 // a relative position, while sortable is always absolute, which the dragged … … 1884 2078 } 1885 2079 } else { 2080 1886 2081 // If it doesn't intersect with the sortable, and it intersected before, 1887 2082 // we fake the drag stop of the sortable, but make sure it doesn't remove … … 1900 2095 sortable._mouseStop( event, true ); 1901 2096 1902 // restore sortable behaviors that were modfied2097 // Restore sortable behaviors that were modfied 1903 2098 // when the draggable entered the sortable area (#9481) 1904 2099 sortable.options.revert = sortable.options._revert; … … 1924 2119 $.each( draggable.sortables, function() { 1925 2120 this.refreshPositions(); 1926 } );1927 } 1928 } 1929 } );2121 } ); 2122 } 2123 } 2124 } ); 1930 2125 } 1931 } );1932 1933 $.ui.plugin.add( "draggable", "cursor", {2126 } ); 2127 2128 $.ui.plugin.add( "draggable", "cursor", { 1934 2129 start: function( event, ui, instance ) { 1935 2130 var t = $( "body" ), 1936 2131 o = instance.options; 1937 2132 1938 if ( t.css("cursor")) {1939 o._cursor = t.css( "cursor");1940 } 1941 t.css( "cursor", o.cursor);2133 if ( t.css( "cursor" ) ) { 2134 o._cursor = t.css( "cursor" ); 2135 } 2136 t.css( "cursor", o.cursor ); 1942 2137 }, 1943 2138 stop: function( event, ui, instance ) { 1944 2139 var o = instance.options; 1945 if ( o._cursor) {1946 $( "body").css("cursor", o._cursor);2140 if ( o._cursor ) { 2141 $( "body" ).css( "cursor", o._cursor ); 1947 2142 } 1948 2143 } 1949 } );1950 1951 $.ui.plugin.add( "draggable", "opacity", {2144 } ); 2145 2146 $.ui.plugin.add( "draggable", "opacity", { 1952 2147 start: function( event, ui, instance ) { 1953 2148 var t = $( ui.helper ), 1954 2149 o = instance.options; 1955 if ( t.css("opacity")) {1956 o._opacity = t.css( "opacity");1957 } 1958 t.css( "opacity", o.opacity);2150 if ( t.css( "opacity" ) ) { 2151 o._opacity = t.css( "opacity" ); 2152 } 2153 t.css( "opacity", o.opacity ); 1959 2154 }, 1960 2155 stop: function( event, ui, instance ) { 1961 2156 var o = instance.options; 1962 if ( o._opacity) {1963 $( ui.helper).css("opacity", o._opacity);2157 if ( o._opacity ) { 2158 $( ui.helper ).css( "opacity", o._opacity ); 1964 2159 } 1965 2160 } 1966 } );1967 1968 $.ui.plugin.add( "draggable", "scroll", {2161 } ); 2162 2163 $.ui.plugin.add( "draggable", "scroll", { 1969 2164 start: function( event, ui, i ) { 1970 2165 if ( !i.scrollParentNotHidden ) { … … 1972 2167 } 1973 2168 1974 if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) { 2169 if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && 2170 i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) { 1975 2171 i.overflowOffset = i.scrollParentNotHidden.offset(); 1976 2172 } … … 1985 2181 if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) { 1986 2182 if ( !o.axis || o.axis !== "x" ) { 1987 if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) { 2183 if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < 2184 o.scrollSensitivity ) { 1988 2185 scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed; 1989 2186 } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) { … … 1993 2190 1994 2191 if ( !o.axis || o.axis !== "y" ) { 1995 if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) { 2192 if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < 2193 o.scrollSensitivity ) { 1996 2194 scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed; 1997 2195 } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) { … … 2002 2200 } else { 2003 2201 2004 if (!o.axis || o.axis !== "x") { 2005 if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) { 2006 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); 2007 } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { 2008 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); 2009 } 2010 } 2011 2012 if (!o.axis || o.axis !== "y") { 2013 if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) { 2014 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); 2015 } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) { 2016 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); 2017 } 2018 } 2019 2020 } 2021 2022 if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { 2023 $.ui.ddmanager.prepareOffsets(i, event); 2202 if ( !o.axis || o.axis !== "x" ) { 2203 if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) { 2204 scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed ); 2205 } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) < 2206 o.scrollSensitivity ) { 2207 scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed ); 2208 } 2209 } 2210 2211 if ( !o.axis || o.axis !== "y" ) { 2212 if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) { 2213 scrolled = $( document ).scrollLeft( 2214 $( document ).scrollLeft() - o.scrollSpeed 2215 ); 2216 } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) < 2217 o.scrollSensitivity ) { 2218 scrolled = $( document ).scrollLeft( 2219 $( document ).scrollLeft() + o.scrollSpeed 2220 ); 2221 } 2222 } 2223 2224 } 2225 2226 if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) { 2227 $.ui.ddmanager.prepareOffsets( i, event ); 2024 2228 } 2025 2229 2026 2230 } 2027 } );2028 2029 $.ui.plugin.add( "draggable", "snap", {2231 } ); 2232 2233 $.ui.plugin.add( "draggable", "snap", { 2030 2234 start: function( event, ui, i ) { 2031 2235 … … 2034 2238 i.snapElements = []; 2035 2239 2036 $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() { 2037 var $t = $(this), 2038 $o = $t.offset(); 2039 if (this !== i.element[0]) { 2040 i.snapElements.push({ 2041 item: this, 2042 width: $t.outerWidth(), height: $t.outerHeight(), 2043 top: $o.top, left: $o.left 2044 }); 2045 } 2046 }); 2240 $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap ) 2241 .each( function() { 2242 var $t = $( this ), 2243 $o = $t.offset(); 2244 if ( this !== i.element[ 0 ] ) { 2245 i.snapElements.push( { 2246 item: this, 2247 width: $t.outerWidth(), height: $t.outerHeight(), 2248 top: $o.top, left: $o.left 2249 } ); 2250 } 2251 } ); 2047 2252 2048 2253 }, … … 2055 2260 y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; 2056 2261 2057 for (i = inst.snapElements.length - 1; i >= 0; i--){ 2058 2059 l = inst.snapElements[i].left - inst.margins.left; 2060 r = l + inst.snapElements[i].width; 2061 t = inst.snapElements[i].top - inst.margins.top; 2062 b = t + inst.snapElements[i].height; 2063 2064 if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) { 2065 if (inst.snapElements[i].snapping) { 2066 (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); 2067 } 2068 inst.snapElements[i].snapping = false; 2262 for ( i = inst.snapElements.length - 1; i >= 0; i-- ) { 2263 2264 l = inst.snapElements[ i ].left - inst.margins.left; 2265 r = l + inst.snapElements[ i ].width; 2266 t = inst.snapElements[ i ].top - inst.margins.top; 2267 b = t + inst.snapElements[ i ].height; 2268 2269 if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || 2270 !$.contains( inst.snapElements[ i ].item.ownerDocument, 2271 inst.snapElements[ i ].item ) ) { 2272 if ( inst.snapElements[ i ].snapping ) { 2273 ( inst.options.snap.release && 2274 inst.options.snap.release.call( 2275 inst.element, 2276 event, 2277 $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) 2278 ) ); 2279 } 2280 inst.snapElements[ i ].snapping = false; 2069 2281 continue; 2070 2282 } 2071 2283 2072 if (o.snapMode !== "inner") { 2073 ts = Math.abs(t - y2) <= d; 2074 bs = Math.abs(b - y1) <= d; 2075 ls = Math.abs(l - x2) <= d; 2076 rs = Math.abs(r - x1) <= d; 2077 if (ts) { 2078 ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top; 2079 } 2080 if (bs) { 2081 ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top; 2082 } 2083 if (ls) { 2084 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left; 2085 } 2086 if (rs) { 2087 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left; 2088 } 2089 } 2090 2091 first = (ts || bs || ls || rs); 2092 2093 if (o.snapMode !== "outer") { 2094 ts = Math.abs(t - y1) <= d; 2095 bs = Math.abs(b - y2) <= d; 2096 ls = Math.abs(l - x1) <= d; 2097 rs = Math.abs(r - x2) <= d; 2098 if (ts) { 2099 ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top; 2100 } 2101 if (bs) { 2102 ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top; 2103 } 2104 if (ls) { 2105 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left; 2106 } 2107 if (rs) { 2108 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left; 2109 } 2110 } 2111 2112 if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) { 2113 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); 2114 } 2115 inst.snapElements[i].snapping = (ts || bs || ls || rs || first); 2284 if ( o.snapMode !== "inner" ) { 2285 ts = Math.abs( t - y2 ) <= d; 2286 bs = Math.abs( b - y1 ) <= d; 2287 ls = Math.abs( l - x2 ) <= d; 2288 rs = Math.abs( r - x1 ) <= d; 2289 if ( ts ) { 2290 ui.position.top = inst._convertPositionTo( "relative", { 2291 top: t - inst.helperProportions.height, 2292 left: 0 2293 } ).top; 2294 } 2295 if ( bs ) { 2296 ui.position.top = inst._convertPositionTo( "relative", { 2297 top: b, 2298 left: 0 2299 } ).top; 2300 } 2301 if ( ls ) { 2302 ui.position.left = inst._convertPositionTo( "relative", { 2303 top: 0, 2304 left: l - inst.helperProportions.width 2305 } ).left; 2306 } 2307 if ( rs ) { 2308 ui.position.left = inst._convertPositionTo( "relative", { 2309 top: 0, 2310 left: r 2311 } ).left; 2312 } 2313 } 2314 2315 first = ( ts || bs || ls || rs ); 2316 2317 if ( o.snapMode !== "outer" ) { 2318 ts = Math.abs( t - y1 ) <= d; 2319 bs = Math.abs( b - y2 ) <= d; 2320 ls = Math.abs( l - x1 ) <= d; 2321 rs = Math.abs( r - x2 ) <= d; 2322 if ( ts ) { 2323 ui.position.top = inst._convertPositionTo( "relative", { 2324 top: t, 2325 left: 0 2326 } ).top; 2327 } 2328 if ( bs ) { 2329 ui.position.top = inst._convertPositionTo( "relative", { 2330 top: b - inst.helperProportions.height, 2331 left: 0 2332 } ).top; 2333 } 2334 if ( ls ) { 2335 ui.position.left = inst._convertPositionTo( "relative", { 2336 top: 0, 2337 left: l 2338 } ).left; 2339 } 2340 if ( rs ) { 2341 ui.position.left = inst._convertPositionTo( "relative", { 2342 top: 0, 2343 left: r - inst.helperProportions.width 2344 } ).left; 2345 } 2346 } 2347 2348 if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) { 2349 ( inst.options.snap.snap && 2350 inst.options.snap.snap.call( 2351 inst.element, 2352 event, 2353 $.extend( inst._uiHash(), { 2354 snapItem: inst.snapElements[ i ].item 2355 } ) ) ); 2356 } 2357 inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first ); 2116 2358 2117 2359 } 2118 2360 2119 2361 } 2120 } );2121 2122 $.ui.plugin.add( "draggable", "stack", {2362 } ); 2363 2364 $.ui.plugin.add( "draggable", "stack", { 2123 2365 start: function( event, ui, instance ) { 2124 2366 var min, 2125 2367 o = instance.options, 2126 group = $.makeArray($(o.stack)).sort(function(a, b) { 2127 return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0); 2128 }); 2129 2130 if (!group.length) { return; } 2131 2132 min = parseInt($(group[0]).css("zIndex"), 10) || 0; 2133 $(group).each(function(i) { 2134 $(this).css("zIndex", min + i); 2135 }); 2136 this.css("zIndex", (min + group.length)); 2368 group = $.makeArray( $( o.stack ) ).sort( function( a, b ) { 2369 return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) - 2370 ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 ); 2371 } ); 2372 2373 if ( !group.length ) { return; } 2374 2375 min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0; 2376 $( group ).each( function( i ) { 2377 $( this ).css( "zIndex", min + i ); 2378 } ); 2379 this.css( "zIndex", ( min + group.length ) ); 2137 2380 } 2138 } );2139 2140 $.ui.plugin.add( "draggable", "zIndex", {2381 } ); 2382 2383 $.ui.plugin.add( "draggable", "zIndex", { 2141 2384 start: function( event, ui, instance ) { 2142 2385 var t = $( ui.helper ), 2143 2386 o = instance.options; 2144 2387 2145 if ( t.css("zIndex")) {2146 o._zIndex = t.css( "zIndex");2147 } 2148 t.css( "zIndex", o.zIndex);2388 if ( t.css( "zIndex" ) ) { 2389 o._zIndex = t.css( "zIndex" ); 2390 } 2391 t.css( "zIndex", o.zIndex ); 2149 2392 }, 2150 2393 stop: function( event, ui, instance ) { 2151 2394 var o = instance.options; 2152 2395 2153 if ( o._zIndex) {2154 $( ui.helper).css("zIndex", o._zIndex);2396 if ( o._zIndex ) { 2397 $( ui.helper ).css( "zIndex", o._zIndex ); 2155 2398 } 2156 2399 } 2157 } );2158 2159 var draggable = $.ui.draggable;2400 } ); 2401 2402 var widgetsDraggable = $.ui.draggable; 2160 2403 2161 2404 2162 2405 /*! 2163 * jQuery UI Sortable 1.1 1.42406 * jQuery UI Sortable 1.12.1 2164 2407 * http://jqueryui.com 2165 2408 * … … 2167 2410 * Released under the MIT license. 2168 2411 * http://jquery.org/license 2169 *2170 * http://api.jqueryui.com/sortable/2171 2412 */ 2172 2413 2173 2174 var sortable = $.widget("ui.sortable", $.ui.mouse, { 2175 version: "1.11.4", 2414 //>>label: Sortable 2415 //>>group: Interactions 2416 //>>description: Enables items in a list to be sorted using the mouse. 2417 //>>docs: http://api.jqueryui.com/sortable/ 2418 //>>demos: http://jqueryui.com/sortable/ 2419 //>>css.structure: ../../themes/base/sortable.css 2420 2421 2422 2423 var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, { 2424 version: "1.12.1", 2176 2425 widgetEventPrefix: "sort", 2177 2426 ready: false, … … 2200 2449 zIndex: 1000, 2201 2450 2202 // callbacks2451 // Callbacks 2203 2452 activate: null, 2204 2453 beforeStop: null, … … 2220 2469 2221 2470 _isFloating: function( item ) { 2222 return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display")); 2471 return ( /left|right/ ).test( item.css( "float" ) ) || 2472 ( /inline|table-cell/ ).test( item.css( "display" ) ); 2223 2473 }, 2224 2474 2225 2475 _create: function() { 2226 2476 this.containerCache = {}; 2227 this. element.addClass("ui-sortable");2477 this._addClass( "ui-sortable" ); 2228 2478 2229 2479 //Get the items … … 2252 2502 2253 2503 _setHandleClassName: function() { 2254 this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" ); 2504 var that = this; 2505 this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" ); 2255 2506 $.each( this.items, function() { 2256 ( this.instance.options.handle ? 2257 this.item.find( this.instance.options.handle ) : this.item ) 2258 .addClass( "ui-sortable-handle" ); 2259 }); 2507 that._addClass( 2508 this.instance.options.handle ? 2509 this.item.find( this.instance.options.handle ) : 2510 this.item, 2511 "ui-sortable-handle" 2512 ); 2513 } ); 2260 2514 }, 2261 2515 2262 2516 _destroy: function() { 2263 this.element2264 .removeClass( "ui-sortable ui-sortable-disabled" )2265 .find( ".ui-sortable-handle" )2266 .removeClass( "ui-sortable-handle" );2267 2517 this._mouseDestroy(); 2268 2518 2269 2519 for ( var i = this.items.length - 1; i >= 0; i-- ) { 2270 this.items[ i].item.removeData(this.widgetName + "-item");2520 this.items[ i ].item.removeData( this.widgetName + "-item" ); 2271 2521 } 2272 2522 … … 2274 2524 }, 2275 2525 2276 _mouseCapture: function( event, overrideHandle) {2526 _mouseCapture: function( event, overrideHandle ) { 2277 2527 var currentItem = null, 2278 2528 validHandle = false, 2279 2529 that = this; 2280 2530 2281 if ( this.reverting) {2531 if ( this.reverting ) { 2282 2532 return false; 2283 2533 } 2284 2534 2285 if (this.options.disabled || this.options.type === "static") {2535 if ( this.options.disabled || this.options.type === "static" ) { 2286 2536 return false; 2287 2537 } 2288 2538 2289 2539 //We have to refresh the items data once first 2290 this._refreshItems( event);2540 this._refreshItems( event ); 2291 2541 2292 2542 //Find out if the clicked node (or one of its parents) is a actual item in this.items 2293 $( event.target).parents().each(function() {2294 if ($.data(this, that.widgetName + "-item") === that) {2295 currentItem = $( this);2543 $( event.target ).parents().each( function() { 2544 if ( $.data( this, that.widgetName + "-item" ) === that ) { 2545 currentItem = $( this ); 2296 2546 return false; 2297 2547 } 2298 } );2299 if ($.data(event.target, that.widgetName + "-item") === that) {2300 currentItem = $( event.target);2301 } 2302 2303 if (!currentItem) {2548 } ); 2549 if ( $.data( event.target, that.widgetName + "-item" ) === that ) { 2550 currentItem = $( event.target ); 2551 } 2552 2553 if ( !currentItem ) { 2304 2554 return false; 2305 2555 } 2306 if (this.options.handle && !overrideHandle) {2307 $( this.options.handle, currentItem).find("*").addBack().each(function() {2308 if (this === event.target) {2556 if ( this.options.handle && !overrideHandle ) { 2557 $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() { 2558 if ( this === event.target ) { 2309 2559 validHandle = true; 2310 2560 } 2311 } );2312 if (!validHandle) {2561 } ); 2562 if ( !validHandle ) { 2313 2563 return false; 2314 2564 } … … 2321 2571 }, 2322 2572 2323 _mouseStart: function( event, overrideHandle, noActivation) {2573 _mouseStart: function( event, overrideHandle, noActivation ) { 2324 2574 2325 2575 var i, body, … … 2328 2578 this.currentContainer = this; 2329 2579 2330 //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture 2580 //We only need to call refreshPositions, because the refreshItems call has been moved to 2581 // mouseCapture 2331 2582 this.refreshPositions(); 2332 2583 2333 2584 //Create and append the visible helper 2334 this.helper = this._createHelper( event);2585 this.helper = this._createHelper( event ); 2335 2586 2336 2587 //Cache the helper size … … 2355 2606 }; 2356 2607 2357 $.extend( this.offset, {2608 $.extend( this.offset, { 2358 2609 click: { //Where the click happened, relative to the element 2359 2610 left: event.pageX - this.offset.left, … … 2361 2612 }, 2362 2613 parent: this._getParentOffset(), 2363 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper 2364 }); 2614 2615 // This is a relative to absolute position minus the actual position calculation - 2616 // only used for relative positioned helper 2617 relative: this._getRelativeOffset() 2618 } ); 2365 2619 2366 2620 // Only after we got the offset, we can change the helper's position to absolute 2367 2621 // TODO: Still need to figure out a way to make relative sorting possible 2368 this.helper.css( "position", "absolute");2369 this.cssPosition = this.helper.css( "position");2622 this.helper.css( "position", "absolute" ); 2623 this.cssPosition = this.helper.css( "position" ); 2370 2624 2371 2625 //Generate the original position 2372 this.originalPosition = this._generatePosition( event);2626 this.originalPosition = this._generatePosition( event ); 2373 2627 this.originalPageX = event.pageX; 2374 2628 this.originalPageY = event.pageY; 2375 2629 2376 2630 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied 2377 ( o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));2631 ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); 2378 2632 2379 2633 //Cache the former DOM position 2380 this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; 2381 2382 //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way 2383 if(this.helper[0] !== this.currentItem[0]) { 2634 this.domPosition = { 2635 prev: this.currentItem.prev()[ 0 ], 2636 parent: this.currentItem.parent()[ 0 ] 2637 }; 2638 2639 // If the helper is not the original, hide the original so it's not playing any role during 2640 // the drag, won't cause anything bad this way 2641 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { 2384 2642 this.currentItem.hide(); 2385 2643 } … … 2389 2647 2390 2648 //Set a containment if given in the options 2391 if (o.containment) {2649 if ( o.containment ) { 2392 2650 this._setContainment(); 2393 2651 } 2394 2652 2395 if ( o.cursor && o.cursor !== "auto" ) { // cursor option2653 if ( o.cursor && o.cursor !== "auto" ) { // cursor option 2396 2654 body = this.document.find( "body" ); 2397 2655 2398 // support: IE2656 // Support: IE 2399 2657 this.storedCursor = body.css( "cursor" ); 2400 2658 body.css( "cursor", o.cursor ); 2401 2659 2402 this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body ); 2403 } 2404 2405 if(o.opacity) { // opacity option 2406 if (this.helper.css("opacity")) { 2407 this._storedOpacity = this.helper.css("opacity"); 2408 } 2409 this.helper.css("opacity", o.opacity); 2410 } 2411 2412 if(o.zIndex) { // zIndex option 2413 if (this.helper.css("zIndex")) { 2414 this._storedZIndex = this.helper.css("zIndex"); 2415 } 2416 this.helper.css("zIndex", o.zIndex); 2660 this.storedStylesheet = 2661 $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body ); 2662 } 2663 2664 if ( o.opacity ) { // opacity option 2665 if ( this.helper.css( "opacity" ) ) { 2666 this._storedOpacity = this.helper.css( "opacity" ); 2667 } 2668 this.helper.css( "opacity", o.opacity ); 2669 } 2670 2671 if ( o.zIndex ) { // zIndex option 2672 if ( this.helper.css( "zIndex" ) ) { 2673 this._storedZIndex = this.helper.css( "zIndex" ); 2674 } 2675 this.helper.css( "zIndex", o.zIndex ); 2417 2676 } 2418 2677 2419 2678 //Prepare scrolling 2420 if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") { 2679 if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && 2680 this.scrollParent[ 0 ].tagName !== "HTML" ) { 2421 2681 this.overflowOffset = this.scrollParent.offset(); 2422 2682 } 2423 2683 2424 2684 //Call callbacks 2425 this._trigger( "start", event, this._uiHash());2685 this._trigger( "start", event, this._uiHash() ); 2426 2686 2427 2687 //Recache the helper size 2428 if (!this._preserveHelperProportions) {2688 if ( !this._preserveHelperProportions ) { 2429 2689 this._cacheHelperProportions(); 2430 2690 } 2431 2691 2432 2433 2692 //Post "activate" events to possible containers 2434 if ( !noActivation ) {2693 if ( !noActivation ) { 2435 2694 for ( i = this.containers.length - 1; i >= 0; i-- ) { 2436 2695 this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); … … 2439 2698 2440 2699 //Prepare possible droppables 2441 if ($.ui.ddmanager) {2700 if ( $.ui.ddmanager ) { 2442 2701 $.ui.ddmanager.current = this; 2443 2702 } 2444 2703 2445 if ( $.ui.ddmanager && !o.dropBehaviour) {2446 $.ui.ddmanager.prepareOffsets( this, event);2704 if ( $.ui.ddmanager && !o.dropBehaviour ) { 2705 $.ui.ddmanager.prepareOffsets( this, event ); 2447 2706 } 2448 2707 2449 2708 this.dragging = true; 2450 2709 2451 this.helper.addClass("ui-sortable-helper"); 2452 this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position 2710 this._addClass( this.helper, "ui-sortable-helper" ); 2711 2712 // Execute the drag once - this causes the helper not to be visiblebefore getting its 2713 // correct position 2714 this._mouseDrag( event ); 2453 2715 return true; 2454 2716 2455 2717 }, 2456 2718 2457 _mouseDrag: function( event) {2719 _mouseDrag: function( event ) { 2458 2720 var i, item, itemElement, intersection, 2459 2721 o = this.options, … … 2461 2723 2462 2724 //Compute the helpers position 2463 this.position = this._generatePosition( event);2464 this.positionAbs = this._convertPositionTo( "absolute");2465 2466 if ( !this.lastPositionAbs) {2725 this.position = this._generatePosition( event ); 2726 this.positionAbs = this._convertPositionTo( "absolute" ); 2727 2728 if ( !this.lastPositionAbs ) { 2467 2729 this.lastPositionAbs = this.positionAbs; 2468 2730 } 2469 2731 2470 2732 //Do scrolling 2471 if(this.options.scroll) { 2472 if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") { 2473 2474 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) { 2475 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; 2476 } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) { 2477 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; 2478 } 2479 2480 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) { 2481 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; 2482 } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) { 2483 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; 2733 if ( this.options.scroll ) { 2734 if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && 2735 this.scrollParent[ 0 ].tagName !== "HTML" ) { 2736 2737 if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) - 2738 event.pageY < o.scrollSensitivity ) { 2739 this.scrollParent[ 0 ].scrollTop = 2740 scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed; 2741 } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) { 2742 this.scrollParent[ 0 ].scrollTop = 2743 scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed; 2744 } 2745 2746 if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) - 2747 event.pageX < o.scrollSensitivity ) { 2748 this.scrollParent[ 0 ].scrollLeft = scrolled = 2749 this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed; 2750 } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) { 2751 this.scrollParent[ 0 ].scrollLeft = scrolled = 2752 this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed; 2484 2753 } 2485 2754 2486 2755 } else { 2487 2756 2488 if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) { 2489 scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed); 2490 } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) { 2491 scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed); 2492 } 2493 2494 if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) { 2495 scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed); 2496 } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) { 2497 scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed); 2498 } 2499 2500 } 2501 2502 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { 2503 $.ui.ddmanager.prepareOffsets(this, event); 2757 if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) { 2758 scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed ); 2759 } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) < 2760 o.scrollSensitivity ) { 2761 scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed ); 2762 } 2763 2764 if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) { 2765 scrolled = this.document.scrollLeft( 2766 this.document.scrollLeft() - o.scrollSpeed 2767 ); 2768 } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) < 2769 o.scrollSensitivity ) { 2770 scrolled = this.document.scrollLeft( 2771 this.document.scrollLeft() + o.scrollSpeed 2772 ); 2773 } 2774 2775 } 2776 2777 if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) { 2778 $.ui.ddmanager.prepareOffsets( this, event ); 2504 2779 } 2505 2780 } 2506 2781 2507 2782 //Regenerate the absolute position used for position checks 2508 this.positionAbs = this._convertPositionTo( "absolute");2783 this.positionAbs = this._convertPositionTo( "absolute" ); 2509 2784 2510 2785 //Set the helper position 2511 if (!this.options.axis || this.options.axis !== "y") {2512 this.helper[ 0].style.left = this.position.left+"px";2513 } 2514 if (!this.options.axis || this.options.axis !== "x") {2515 this.helper[ 0].style.top = this.position.top+"px";2786 if ( !this.options.axis || this.options.axis !== "y" ) { 2787 this.helper[ 0 ].style.left = this.position.left + "px"; 2788 } 2789 if ( !this.options.axis || this.options.axis !== "x" ) { 2790 this.helper[ 0 ].style.top = this.position.top + "px"; 2516 2791 } 2517 2792 2518 2793 //Rearrange 2519 for ( i = this.items.length - 1; i >= 0; i--) {2794 for ( i = this.items.length - 1; i >= 0; i-- ) { 2520 2795 2521 2796 //Cache variables and intersection, continue if no intersection 2522 item = this.items[ i];2523 itemElement = item.item[ 0];2524 intersection = this._intersectsWithPointer( item);2525 if ( !intersection) {2797 item = this.items[ i ]; 2798 itemElement = item.item[ 0 ]; 2799 intersection = this._intersectsWithPointer( item ); 2800 if ( !intersection ) { 2526 2801 continue; 2527 2802 } … … 2534 2809 // Without this, moving items in "sub-sortables" can cause 2535 2810 // the placeholder to jitter between the outer and inner container. 2536 if ( item.instance !== this.currentContainer) {2811 if ( item.instance !== this.currentContainer ) { 2537 2812 continue; 2538 2813 } 2539 2814 2540 // cannot intersect with itself2815 // Cannot intersect with itself 2541 2816 // no useless actions that have been done before 2542 2817 // no action if the item moved is the parent of the item checked 2543 if (itemElement !== this.currentItem[0] && 2544 this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement && 2545 !$.contains(this.placeholder[0], itemElement) && 2546 (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true) 2818 if ( itemElement !== this.currentItem[ 0 ] && 2819 this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement && 2820 !$.contains( this.placeholder[ 0 ], itemElement ) && 2821 ( this.options.type === "semi-dynamic" ? 2822 !$.contains( this.element[ 0 ], itemElement ) : 2823 true 2824 ) 2547 2825 ) { 2548 2826 2549 2827 this.direction = intersection === 1 ? "down" : "up"; 2550 2828 2551 if ( this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {2552 this._rearrange( event, item);2829 if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) { 2830 this._rearrange( event, item ); 2553 2831 } else { 2554 2832 break; 2555 2833 } 2556 2834 2557 this._trigger( "change", event, this._uiHash());2835 this._trigger( "change", event, this._uiHash() ); 2558 2836 break; 2559 2837 } … … 2561 2839 2562 2840 //Post events to containers 2563 this._contactContainers( event);2841 this._contactContainers( event ); 2564 2842 2565 2843 //Interconnect with droppables 2566 if ($.ui.ddmanager) {2567 $.ui.ddmanager.drag( this, event);2844 if ( $.ui.ddmanager ) { 2845 $.ui.ddmanager.drag( this, event ); 2568 2846 } 2569 2847 2570 2848 //Call callbacks 2571 this._trigger( "sort", event, this._uiHash());2849 this._trigger( "sort", event, this._uiHash() ); 2572 2850 2573 2851 this.lastPositionAbs = this.positionAbs; … … 2576 2854 }, 2577 2855 2578 _mouseStop: function( event, noPropagation) {2579 2580 if (!event) {2856 _mouseStop: function( event, noPropagation ) { 2857 2858 if ( !event ) { 2581 2859 return; 2582 2860 } 2583 2861 2584 2862 //If we are using droppables, inform the manager about the drop 2585 if ( $.ui.ddmanager && !this.options.dropBehaviour) {2586 $.ui.ddmanager.drop( this, event);2587 } 2588 2589 if (this.options.revert) {2863 if ( $.ui.ddmanager && !this.options.dropBehaviour ) { 2864 $.ui.ddmanager.drop( this, event ); 2865 } 2866 2867 if ( this.options.revert ) { 2590 2868 var that = this, 2591 2869 cur = this.placeholder.offset(), … … 2594 2872 2595 2873 if ( !axis || axis === "x" ) { 2596 animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft); 2874 animation.left = cur.left - this.offset.parent.left - this.margins.left + 2875 ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 2876 0 : 2877 this.offsetParent[ 0 ].scrollLeft 2878 ); 2597 2879 } 2598 2880 if ( !axis || axis === "y" ) { 2599 animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop); 2881 animation.top = cur.top - this.offset.parent.top - this.margins.top + 2882 ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 2883 0 : 2884 this.offsetParent[ 0 ].scrollTop 2885 ); 2600 2886 } 2601 2887 this.reverting = true; 2602 $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { 2603 that._clear(event); 2604 }); 2888 $( this.helper ).animate( 2889 animation, 2890 parseInt( this.options.revert, 10 ) || 500, 2891 function() { 2892 that._clear( event ); 2893 } 2894 ); 2605 2895 } else { 2606 this._clear( event, noPropagation);2896 this._clear( event, noPropagation ); 2607 2897 } 2608 2898 … … 2613 2903 cancel: function() { 2614 2904 2615 if(this.dragging) { 2616 2617 this._mouseUp({ target: null }); 2618 2619 if(this.options.helper === "original") { 2620 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); 2905 if ( this.dragging ) { 2906 2907 this._mouseUp( new $.Event( "mouseup", { target: null } ) ); 2908 2909 if ( this.options.helper === "original" ) { 2910 this.currentItem.css( this._storedCSS ); 2911 this._removeClass( this.currentItem, "ui-sortable-helper" ); 2621 2912 } else { 2622 2913 this.currentItem.show(); … … 2624 2915 2625 2916 //Post deactivating events to containers 2626 for (var i = this.containers.length - 1; i >= 0; i--){ 2627 this.containers[i]._trigger("deactivate", null, this._uiHash(this)); 2628 if(this.containers[i].containerCache.over) { 2629 this.containers[i]._trigger("out", null, this._uiHash(this)); 2630 this.containers[i].containerCache.over = 0; 2631 } 2632 } 2633 2634 } 2635 2636 if (this.placeholder) { 2637 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! 2638 if(this.placeholder[0].parentNode) { 2639 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); 2640 } 2641 if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) { 2917 for ( var i = this.containers.length - 1; i >= 0; i-- ) { 2918 this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) ); 2919 if ( this.containers[ i ].containerCache.over ) { 2920 this.containers[ i ]._trigger( "out", null, this._uiHash( this ) ); 2921 this.containers[ i ].containerCache.over = 0; 2922 } 2923 } 2924 2925 } 2926 2927 if ( this.placeholder ) { 2928 2929 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, 2930 // it unbinds ALL events from the original node! 2931 if ( this.placeholder[ 0 ].parentNode ) { 2932 this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); 2933 } 2934 if ( this.options.helper !== "original" && this.helper && 2935 this.helper[ 0 ].parentNode ) { 2642 2936 this.helper.remove(); 2643 2937 } 2644 2938 2645 $.extend( this, {2939 $.extend( this, { 2646 2940 helper: null, 2647 2941 dragging: false, 2648 2942 reverting: false, 2649 2943 _noFinalSort: null 2650 } );2651 2652 if (this.domPosition.prev) {2653 $( this.domPosition.prev).after(this.currentItem);2944 } ); 2945 2946 if ( this.domPosition.prev ) { 2947 $( this.domPosition.prev ).after( this.currentItem ); 2654 2948 } else { 2655 $( this.domPosition.parent).prepend(this.currentItem);2949 $( this.domPosition.parent ).prepend( this.currentItem ); 2656 2950 } 2657 2951 } … … 2661 2955 }, 2662 2956 2663 serialize: function( o) {2664 2665 var items = this._getItemsAsjQuery( o && o.connected),2957 serialize: function( o ) { 2958 2959 var items = this._getItemsAsjQuery( o && o.connected ), 2666 2960 str = []; 2667 2961 o = o || {}; 2668 2962 2669 $(items).each(function() { 2670 var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/)); 2671 if (res) { 2672 str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2])); 2673 } 2674 }); 2675 2676 if(!str.length && o.key) { 2677 str.push(o.key + "="); 2678 } 2679 2680 return str.join("&"); 2681 2682 }, 2683 2684 toArray: function(o) { 2685 2686 var items = this._getItemsAsjQuery(o && o.connected), 2963 $( items ).each( function() { 2964 var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" ) 2965 .match( o.expression || ( /(.+)[\-=_](.+)/ ) ); 2966 if ( res ) { 2967 str.push( 2968 ( o.key || res[ 1 ] + "[]" ) + 2969 "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) ); 2970 } 2971 } ); 2972 2973 if ( !str.length && o.key ) { 2974 str.push( o.key + "=" ); 2975 } 2976 2977 return str.join( "&" ); 2978 2979 }, 2980 2981 toArray: function( o ) { 2982 2983 var items = this._getItemsAsjQuery( o && o.connected ), 2687 2984 ret = []; 2688 2985 2689 2986 o = o || {}; 2690 2987 2691 items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); }); 2988 items.each( function() { 2989 ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" ); 2990 } ); 2692 2991 return ret; 2693 2992 … … 2695 2994 2696 2995 /* Be careful with the following core functions */ 2697 _intersectsWith: function( item) {2996 _intersectsWith: function( item ) { 2698 2997 2699 2998 var x1 = this.positionAbs.left, … … 2707 3006 dyClick = this.offset.click.top, 2708 3007 dxClick = this.offset.click.left, 2709 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ), 2710 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ), 3008 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && 3009 ( y1 + dyClick ) < b ), 3010 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && 3011 ( x1 + dxClick ) < r ), 2711 3012 isOverElement = isOverElementHeight && isOverElementWidth; 2712 3013 2713 3014 if ( this.options.tolerance === "pointer" || 2714 3015 this.options.forcePointerForContainers || 2715 (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"]) 3016 ( this.options.tolerance !== "pointer" && 3017 this.helperProportions[ this.floating ? "width" : "height" ] > 3018 item[ this.floating ? "width" : "height" ] ) 2716 3019 ) { 2717 3020 return isOverElement; 2718 3021 } else { 2719 3022 2720 return (l < x1 + (this.helperProportions.width / 2) && // Right Half 2721 x2 - (this.helperProportions.width / 2) < r && // Left Half 2722 t < y1 + (this.helperProportions.height / 2) && // Bottom Half 2723 y2 - (this.helperProportions.height / 2) < b ); // Top Half 2724 2725 } 2726 }, 2727 2728 _intersectsWithPointer: function(item) { 2729 2730 var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), 2731 isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), 2732 isOverElement = isOverElementHeight && isOverElementWidth, 3023 return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half 3024 x2 - ( this.helperProportions.width / 2 ) < r && // Left Half 3025 t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half 3026 y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half 3027 3028 } 3029 }, 3030 3031 _intersectsWithPointer: function( item ) { 3032 var verticalDirection, horizontalDirection, 3033 isOverElementHeight = ( this.options.axis === "x" ) || 3034 this._isOverAxis( 3035 this.positionAbs.top + this.offset.click.top, item.top, item.height ), 3036 isOverElementWidth = ( this.options.axis === "y" ) || 3037 this._isOverAxis( 3038 this.positionAbs.left + this.offset.click.left, item.left, item.width ), 3039 isOverElement = isOverElementHeight && isOverElementWidth; 3040 3041 if ( !isOverElement ) { 3042 return false; 3043 } 3044 3045 verticalDirection = this._getDragVerticalDirection(); 3046 horizontalDirection = this._getDragHorizontalDirection(); 3047 3048 return this.floating ? 3049 ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 ) 3050 : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) ); 3051 3052 }, 3053 3054 _intersectsWithSides: function( item ) { 3055 3056 var isOverBottomHalf = this._isOverAxis( this.positionAbs.top + 3057 this.offset.click.top, item.top + ( item.height / 2 ), item.height ), 3058 isOverRightHalf = this._isOverAxis( this.positionAbs.left + 3059 this.offset.click.left, item.left + ( item.width / 2 ), item.width ), 2733 3060 verticalDirection = this._getDragVerticalDirection(), 2734 3061 horizontalDirection = this._getDragHorizontalDirection(); 2735 3062 2736 if (!isOverElement) { 2737 return false; 2738 } 2739 2740 return this.floating ? 2741 ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 ) 2742 : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) ); 2743 2744 }, 2745 2746 _intersectsWithSides: function(item) { 2747 2748 var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), 2749 isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), 2750 verticalDirection = this._getDragVerticalDirection(), 2751 horizontalDirection = this._getDragHorizontalDirection(); 2752 2753 if (this.floating && horizontalDirection) { 2754 return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf)); 3063 if ( this.floating && horizontalDirection ) { 3064 return ( ( horizontalDirection === "right" && isOverRightHalf ) || 3065 ( horizontalDirection === "left" && !isOverRightHalf ) ); 2755 3066 } else { 2756 return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf)); 3067 return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) || 3068 ( verticalDirection === "up" && !isOverBottomHalf ) ); 2757 3069 } 2758 3070 … … 2761 3073 _getDragVerticalDirection: function() { 2762 3074 var delta = this.positionAbs.top - this.lastPositionAbs.top; 2763 return delta !== 0 && ( delta > 0 ? "down" : "up");3075 return delta !== 0 && ( delta > 0 ? "down" : "up" ); 2764 3076 }, 2765 3077 2766 3078 _getDragHorizontalDirection: function() { 2767 3079 var delta = this.positionAbs.left - this.lastPositionAbs.left; 2768 return delta !== 0 && ( delta > 0 ? "right" : "left");2769 }, 2770 2771 refresh: function( event) {2772 this._refreshItems( event);3080 return delta !== 0 && ( delta > 0 ? "right" : "left" ); 3081 }, 3082 3083 refresh: function( event ) { 3084 this._refreshItems( event ); 2773 3085 this._setHandleClassName(); 2774 3086 this.refreshPositions(); … … 2778 3090 _connectWith: function() { 2779 3091 var options = this.options; 2780 return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith; 2781 }, 2782 2783 _getItemsAsjQuery: function(connected) { 3092 return options.connectWith.constructor === String ? 3093 [ options.connectWith ] : 3094 options.connectWith; 3095 }, 3096 3097 _getItemsAsjQuery: function( connected ) { 2784 3098 2785 3099 var i, j, cur, inst, … … 2788 3102 connectWith = this._connectWith(); 2789 3103 2790 if(connectWith && connected) { 2791 for (i = connectWith.length - 1; i >= 0; i--){ 2792 cur = $(connectWith[i], this.document[0]); 2793 for ( j = cur.length - 1; j >= 0; j--){ 2794 inst = $.data(cur[j], this.widgetFullName); 2795 if(inst && inst !== this && !inst.options.disabled) { 2796 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]); 3104 if ( connectWith && connected ) { 3105 for ( i = connectWith.length - 1; i >= 0; i-- ) { 3106 cur = $( connectWith[ i ], this.document[ 0 ] ); 3107 for ( j = cur.length - 1; j >= 0; j-- ) { 3108 inst = $.data( cur[ j ], this.widgetFullName ); 3109 if ( inst && inst !== this && !inst.options.disabled ) { 3110 queries.push( [ $.isFunction( inst.options.items ) ? 3111 inst.options.items.call( inst.element ) : 3112 $( inst.options.items, inst.element ) 3113 .not( ".ui-sortable-helper" ) 3114 .not( ".ui-sortable-placeholder" ), inst ] ); 2797 3115 } 2798 3116 } … … 2800 3118 } 2801 3119 2802 queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]); 3120 queries.push( [ $.isFunction( this.options.items ) ? 3121 this.options.items 3122 .call( this.element, null, { options: this.options, item: this.currentItem } ) : 3123 $( this.options.items, this.element ) 3124 .not( ".ui-sortable-helper" ) 3125 .not( ".ui-sortable-placeholder" ), this ] ); 2803 3126 2804 3127 function addItems() { 2805 3128 items.push( this ); 2806 3129 } 2807 for ( i = queries.length - 1; i >= 0; i--){2808 queries[ i][0].each( addItems );2809 } 2810 2811 return $( items);3130 for ( i = queries.length - 1; i >= 0; i-- ) { 3131 queries[ i ][ 0 ].each( addItems ); 3132 } 3133 3134 return $( items ); 2812 3135 2813 3136 }, … … 2815 3138 _removeCurrentsFromItems: function() { 2816 3139 2817 var list = this.currentItem.find( ":data(" + this.widgetName + "-item)");2818 2819 this.items = $.grep( this.items, function (item) {2820 for ( var j=0; j < list.length; j++) {2821 if (list[j] === item.item[0]) {3140 var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" ); 3141 3142 this.items = $.grep( this.items, function( item ) { 3143 for ( var j = 0; j < list.length; j++ ) { 3144 if ( list[ j ] === item.item[ 0 ] ) { 2822 3145 return false; 2823 3146 } 2824 3147 } 2825 3148 return true; 2826 } );2827 2828 }, 2829 2830 _refreshItems: function( event) {3149 } ); 3150 3151 }, 3152 3153 _refreshItems: function( event ) { 2831 3154 2832 3155 this.items = []; 2833 this.containers = [ this];3156 this.containers = [ this ]; 2834 3157 2835 3158 var i, j, cur, inst, targetData, _queries, item, queriesLength, 2836 3159 items = this.items, 2837 queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]], 3160 queries = [ [ $.isFunction( this.options.items ) ? 3161 this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : 3162 $( this.options.items, this.element ), this ] ], 2838 3163 connectWith = this._connectWith(); 2839 3164 2840 if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down 2841 for (i = connectWith.length - 1; i >= 0; i--){ 2842 cur = $(connectWith[i], this.document[0]); 2843 for (j = cur.length - 1; j >= 0; j--){ 2844 inst = $.data(cur[j], this.widgetFullName); 2845 if(inst && inst !== this && !inst.options.disabled) { 2846 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); 2847 this.containers.push(inst); 3165 //Shouldn't be run the first time through due to massive slow-down 3166 if ( connectWith && this.ready ) { 3167 for ( i = connectWith.length - 1; i >= 0; i-- ) { 3168 cur = $( connectWith[ i ], this.document[ 0 ] ); 3169 for ( j = cur.length - 1; j >= 0; j-- ) { 3170 inst = $.data( cur[ j ], this.widgetFullName ); 3171 if ( inst && inst !== this && !inst.options.disabled ) { 3172 queries.push( [ $.isFunction( inst.options.items ) ? 3173 inst.options.items 3174 .call( inst.element[ 0 ], event, { item: this.currentItem } ) : 3175 $( inst.options.items, inst.element ), inst ] ); 3176 this.containers.push( inst ); 2848 3177 } 2849 3178 } … … 2851 3180 } 2852 3181 2853 for (i = queries.length - 1; i >= 0; i--) { 2854 targetData = queries[i][1]; 2855 _queries = queries[i][0]; 2856 2857 for (j=0, queriesLength = _queries.length; j < queriesLength; j++) { 2858 item = $(_queries[j]); 2859 2860 item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager) 2861 2862 items.push({ 3182 for ( i = queries.length - 1; i >= 0; i-- ) { 3183 targetData = queries[ i ][ 1 ]; 3184 _queries = queries[ i ][ 0 ]; 3185 3186 for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) { 3187 item = $( _queries[ j ] ); 3188 3189 // Data for target checking (mouse manager) 3190 item.data( this.widgetName + "-item", targetData ); 3191 3192 items.push( { 2863 3193 item: item, 2864 3194 instance: targetData, 2865 3195 width: 0, height: 0, 2866 3196 left: 0, top: 0 2867 } );2868 } 2869 } 2870 2871 }, 2872 2873 refreshPositions: function( fast) {3197 } ); 3198 } 3199 } 3200 3201 }, 3202 3203 refreshPositions: function( fast ) { 2874 3204 2875 3205 // Determine whether items are being displayed horizontally … … 2878 3208 false; 2879 3209 2880 //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change 2881 if(this.offsetParent && this.helper) { 3210 //This has to be redone because due to the item being moved out/into the offsetParent, 3211 // the offsetParent's position will change 3212 if ( this.offsetParent && this.helper ) { 2882 3213 this.offset.parent = this._getParentOffset(); 2883 3214 } … … 2885 3216 var i, item, t, p; 2886 3217 2887 for ( i = this.items.length - 1; i >= 0; i--){2888 item = this.items[ i];3218 for ( i = this.items.length - 1; i >= 0; i-- ) { 3219 item = this.items[ i ]; 2889 3220 2890 3221 //We ignore calculating positions of all connected containers when we're not over them 2891 if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) { 3222 if ( item.instance !== this.currentContainer && this.currentContainer && 3223 item.item[ 0 ] !== this.currentItem[ 0 ] ) { 2892 3224 continue; 2893 3225 } 2894 3226 2895 t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; 2896 2897 if (!fast) { 3227 t = this.options.toleranceElement ? 3228 $( this.options.toleranceElement, item.item ) : 3229 item.item; 3230 3231 if ( !fast ) { 2898 3232 item.width = t.outerWidth(); 2899 3233 item.height = t.outerHeight(); … … 2905 3239 } 2906 3240 2907 if (this.options.custom && this.options.custom.refreshContainers) {2908 this.options.custom.refreshContainers.call( this);3241 if ( this.options.custom && this.options.custom.refreshContainers ) { 3242 this.options.custom.refreshContainers.call( this ); 2909 3243 } else { 2910 for (i = this.containers.length - 1; i >= 0; i--){ 2911 p = this.containers[i].element.offset(); 2912 this.containers[i].containerCache.left = p.left; 2913 this.containers[i].containerCache.top = p.top; 2914 this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); 2915 this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); 3244 for ( i = this.containers.length - 1; i >= 0; i-- ) { 3245 p = this.containers[ i ].element.offset(); 3246 this.containers[ i ].containerCache.left = p.left; 3247 this.containers[ i ].containerCache.top = p.top; 3248 this.containers[ i ].containerCache.width = 3249 this.containers[ i ].element.outerWidth(); 3250 this.containers[ i ].containerCache.height = 3251 this.containers[ i ].element.outerHeight(); 2916 3252 } 2917 3253 } … … 2920 3256 }, 2921 3257 2922 _createPlaceholder: function( that) {3258 _createPlaceholder: function( that ) { 2923 3259 that = that || this; 2924 3260 var className, 2925 3261 o = that.options; 2926 3262 2927 if (!o.placeholder || o.placeholder.constructor === String) {3263 if ( !o.placeholder || o.placeholder.constructor === String ) { 2928 3264 className = o.placeholder; 2929 3265 o.placeholder = { 2930 3266 element: function() { 2931 3267 2932 var nodeName = that.currentItem[0].nodeName.toLowerCase(), 2933 element = $( "<" + nodeName + ">", that.document[0] ) 2934 .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") 2935 .removeClass("ui-sortable-helper"); 3268 var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(), 3269 element = $( "<" + nodeName + ">", that.document[ 0 ] ); 3270 3271 that._addClass( element, "ui-sortable-placeholder", 3272 className || that.currentItem[ 0 ].className ) 3273 ._removeClass( element, "ui-sortable-helper" ); 2936 3274 2937 3275 if ( nodeName === "tbody" ) { … … 2952 3290 return element; 2953 3291 }, 2954 update: function(container, p) { 2955 2956 // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that 2957 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified 2958 if(className && !o.forcePlaceholderSize) { 3292 update: function( container, p ) { 3293 3294 // 1. If a className is set as 'placeholder option, we don't force sizes - 3295 // the class is responsible for that 3296 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a 3297 // class name is specified 3298 if ( className && !o.forcePlaceholderSize ) { 2959 3299 return; 2960 3300 } 2961 3301 2962 //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item 2963 if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); } 2964 if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); } 3302 //If the element doesn't have a actual height by itself (without styles coming 3303 // from a stylesheet), it receives the inline height from the dragged item 3304 if ( !p.height() ) { 3305 p.height( 3306 that.currentItem.innerHeight() - 3307 parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) - 3308 parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) ); 3309 } 3310 if ( !p.width() ) { 3311 p.width( 3312 that.currentItem.innerWidth() - 3313 parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) - 3314 parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) ); 3315 } 2965 3316 } 2966 3317 }; … … 2968 3319 2969 3320 //Create the placeholder 2970 that.placeholder = $( o.placeholder.element.call(that.element, that.currentItem));3321 that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) ); 2971 3322 2972 3323 //Append it after the actual current item 2973 that.currentItem.after( that.placeholder);3324 that.currentItem.after( that.placeholder ); 2974 3325 2975 3326 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) 2976 o.placeholder.update( that, that.placeholder);3327 o.placeholder.update( that, that.placeholder ); 2977 3328 2978 3329 }, … … 2981 3332 var that = this; 2982 3333 2983 sourceTr.children().each( function() {3334 sourceTr.children().each( function() { 2984 3335 $( "<td> </td>", that.document[ 0 ] ) 2985 3336 .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) 2986 3337 .appendTo( targetTr ); 2987 }); 2988 }, 2989 2990 _contactContainers: function(event) { 2991 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis, 3338 } ); 3339 }, 3340 3341 _contactContainers: function( event ) { 3342 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, 3343 floating, axis, 2992 3344 innermostContainer = null, 2993 3345 innermostIndex = null; 2994 3346 2995 // get innermost container that intersects with item2996 for ( i = this.containers.length - 1; i >= 0; i--) {2997 2998 // never consider a container that's located within the item itself2999 if ($.contains(this.currentItem[0], this.containers[i].element[0])) {3347 // Get innermost container that intersects with item 3348 for ( i = this.containers.length - 1; i >= 0; i-- ) { 3349 3350 // Never consider a container that's located within the item itself 3351 if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) { 3000 3352 continue; 3001 3353 } 3002 3354 3003 if(this._intersectsWith(this.containers[i].containerCache)) { 3004 3005 // if we've already found a container and it's more "inner" than this, then continue 3006 if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) { 3355 if ( this._intersectsWith( this.containers[ i ].containerCache ) ) { 3356 3357 // If we've already found a container and it's more "inner" than this, then continue 3358 if ( innermostContainer && 3359 $.contains( 3360 this.containers[ i ].element[ 0 ], 3361 innermostContainer.element[ 0 ] ) ) { 3007 3362 continue; 3008 3363 } 3009 3364 3010 innermostContainer = this.containers[ i];3365 innermostContainer = this.containers[ i ]; 3011 3366 innermostIndex = i; 3012 3367 3013 3368 } else { 3369 3014 3370 // container doesn't intersect. trigger "out" event if necessary 3015 if (this.containers[i].containerCache.over) {3016 this.containers[ i]._trigger("out", event, this._uiHash(this));3017 this.containers[ i].containerCache.over = 0;3018 } 3019 } 3020 3021 } 3022 3023 // if no intersecting containers found, return3024 if (!innermostContainer) {3371 if ( this.containers[ i ].containerCache.over ) { 3372 this.containers[ i ]._trigger( "out", event, this._uiHash( this ) ); 3373 this.containers[ i ].containerCache.over = 0; 3374 } 3375 } 3376 3377 } 3378 3379 // If no intersecting containers found, return 3380 if ( !innermostContainer ) { 3025 3381 return; 3026 3382 } 3027 3383 3028 // move the item into the container if it's not there already3029 if (this.containers.length === 1) {3030 if ( !this.containers[innermostIndex].containerCache.over) {3031 this.containers[ innermostIndex]._trigger("over", event, this._uiHash(this));3032 this.containers[ innermostIndex].containerCache.over = 1;3384 // Move the item into the container if it's not there already 3385 if ( this.containers.length === 1 ) { 3386 if ( !this.containers[ innermostIndex ].containerCache.over ) { 3387 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); 3388 this.containers[ innermostIndex ].containerCache.over = 1; 3033 3389 } 3034 3390 } else { 3035 3391 3036 //When entering a new container, we will find the item with the least distance and append our item near it 3392 // When entering a new container, we will find the item with the least distance and 3393 // append our item near it 3037 3394 dist = 10000; 3038 3395 itemWithLeastDistance = null; 3039 floating = innermostContainer.floating || this._isFloating( this.currentItem);3396 floating = innermostContainer.floating || this._isFloating( this.currentItem ); 3040 3397 posProperty = floating ? "left" : "top"; 3041 3398 sizeProperty = floating ? "width" : "height"; 3042 axis = floating ? "clientX" : "clientY"; 3043 3044 for (j = this.items.length - 1; j >= 0; j--) { 3045 if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { 3399 axis = floating ? "pageX" : "pageY"; 3400 3401 for ( j = this.items.length - 1; j >= 0; j-- ) { 3402 if ( !$.contains( 3403 this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] ) 3404 ) { 3046 3405 continue; 3047 3406 } 3048 if (this.items[j].item[0] === this.currentItem[0]) {3407 if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) { 3049 3408 continue; 3050 3409 } 3051 3410 3052 cur = this.items[ j].item.offset()[posProperty];3411 cur = this.items[ j ].item.offset()[ posProperty ]; 3053 3412 nearBottom = false; 3054 3413 if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) { … … 3059 3418 dist = Math.abs( event[ axis ] - cur ); 3060 3419 itemWithLeastDistance = this.items[ j ]; 3061 this.direction = nearBottom ? "up" : "down";3420 this.direction = nearBottom ? "up" : "down"; 3062 3421 } 3063 3422 } 3064 3423 3065 3424 //Check if dropOnEmpty is enabled 3066 if (!itemWithLeastDistance && !this.options.dropOnEmpty) {3425 if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) { 3067 3426 return; 3068 3427 } 3069 3428 3070 if (this.currentContainer === this.containers[innermostIndex]) {3429 if ( this.currentContainer === this.containers[ innermostIndex ] ) { 3071 3430 if ( !this.currentContainer.containerCache.over ) { 3072 3431 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() ); … … 3076 3435 } 3077 3436 3078 itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); 3079 this._trigger("change", event, this._uiHash()); 3080 this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); 3081 this.currentContainer = this.containers[innermostIndex]; 3437 itemWithLeastDistance ? 3438 this._rearrange( event, itemWithLeastDistance, null, true ) : 3439 this._rearrange( event, null, this.containers[ innermostIndex ].element, true ); 3440 this._trigger( "change", event, this._uiHash() ); 3441 this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) ); 3442 this.currentContainer = this.containers[ innermostIndex ]; 3082 3443 3083 3444 //Update the placeholder 3084 this.options.placeholder.update(this.currentContainer, this.placeholder); 3085 3086 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); 3087 this.containers[innermostIndex].containerCache.over = 1; 3088 } 3089 3090 3091 }, 3092 3093 _createHelper: function(event) { 3445 this.options.placeholder.update( this.currentContainer, this.placeholder ); 3446 3447 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); 3448 this.containers[ innermostIndex ].containerCache.over = 1; 3449 } 3450 3451 }, 3452 3453 _createHelper: function( event ) { 3094 3454 3095 3455 var o = this.options, 3096 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem); 3456 helper = $.isFunction( o.helper ) ? 3457 $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : 3458 ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem ); 3097 3459 3098 3460 //Add the helper to the DOM if that didn't happen already 3099 if(!helper.parents("body").length) { 3100 $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); 3101 } 3102 3103 if(helper[0] === this.currentItem[0]) { 3104 this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") }; 3105 } 3106 3107 if(!helper[0].style.width || o.forceHelperSize) { 3108 helper.width(this.currentItem.width()); 3109 } 3110 if(!helper[0].style.height || o.forceHelperSize) { 3111 helper.height(this.currentItem.height()); 3461 if ( !helper.parents( "body" ).length ) { 3462 $( o.appendTo !== "parent" ? 3463 o.appendTo : 3464 this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] ); 3465 } 3466 3467 if ( helper[ 0 ] === this.currentItem[ 0 ] ) { 3468 this._storedCSS = { 3469 width: this.currentItem[ 0 ].style.width, 3470 height: this.currentItem[ 0 ].style.height, 3471 position: this.currentItem.css( "position" ), 3472 top: this.currentItem.css( "top" ), 3473 left: this.currentItem.css( "left" ) 3474 }; 3475 } 3476 3477 if ( !helper[ 0 ].style.width || o.forceHelperSize ) { 3478 helper.width( this.currentItem.width() ); 3479 } 3480 if ( !helper[ 0 ].style.height || o.forceHelperSize ) { 3481 helper.height( this.currentItem.height() ); 3112 3482 } 3113 3483 … … 3116 3486 }, 3117 3487 3118 _adjustOffsetFromHelper: function( obj) {3119 if ( typeof obj === "string") {3120 obj = obj.split( " ");3121 } 3122 if ( $.isArray(obj)) {3123 obj = { left: +obj[0], top: +obj[1] || 0};3124 } 3125 if ( "left" in obj) {3488 _adjustOffsetFromHelper: function( obj ) { 3489 if ( typeof obj === "string" ) { 3490 obj = obj.split( " " ); 3491 } 3492 if ( $.isArray( obj ) ) { 3493 obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; 3494 } 3495 if ( "left" in obj ) { 3126 3496 this.offset.click.left = obj.left + this.margins.left; 3127 3497 } 3128 if ( "right" in obj) {3498 if ( "right" in obj ) { 3129 3499 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 3130 3500 } 3131 if ( "top" in obj) {3501 if ( "top" in obj ) { 3132 3502 this.offset.click.top = obj.top + this.margins.top; 3133 3503 } 3134 if ( "bottom" in obj) {3504 if ( "bottom" in obj ) { 3135 3505 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 3136 3506 } … … 3138 3508 3139 3509 _getParentOffset: function() { 3140 3141 3510 3142 3511 //Get the offsetParent and cache its position … … 3144 3513 var po = this.offsetParent.offset(); 3145 3514 3146 // This is a special case where we need to modify a offset calculated on start, since the following happened: 3147 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent 3148 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that 3149 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag 3150 if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) { 3515 // This is a special case where we need to modify a offset calculated on start, since the 3516 // following happened: 3517 // 1. The position of the helper is absolute, so it's position is calculated based on the 3518 // next positioned parent 3519 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't 3520 // the document, which means that the scroll is included in the initial calculation of the 3521 // offset of the parent, and never recalculated upon drag 3522 if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && 3523 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { 3151 3524 po.left += this.scrollParent.scrollLeft(); 3152 3525 po.top += this.scrollParent.scrollTop(); 3153 3526 } 3154 3527 3155 // This needs to be actually done for all browsers, since pageX/pageY includes this information 3156 // with an ugly IE fix 3157 if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { 3528 // This needs to be actually done for all browsers, since pageX/pageY includes this 3529 // information with an ugly IE fix 3530 if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || 3531 ( this.offsetParent[ 0 ].tagName && 3532 this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) { 3158 3533 po = { top: 0, left: 0 }; 3159 3534 } 3160 3535 3161 3536 return { 3162 top: po.top + ( parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),3163 left: po.left + ( parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)3537 top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ), 3538 left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 ) 3164 3539 }; 3165 3540 … … 3168 3543 _getRelativeOffset: function() { 3169 3544 3170 if (this.cssPosition === "relative") {3545 if ( this.cssPosition === "relative" ) { 3171 3546 var p = this.currentItem.position(); 3172 3547 return { 3173 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), 3174 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() 3548 top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + 3549 this.scrollParent.scrollTop(), 3550 left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + 3551 this.scrollParent.scrollLeft() 3175 3552 }; 3176 3553 } else { … … 3182 3559 _cacheMargins: function() { 3183 3560 this.margins = { 3184 left: ( parseInt(this.currentItem.css("marginLeft"),10) || 0),3185 top: ( parseInt(this.currentItem.css("marginTop"),10) || 0)3561 left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ), 3562 top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 ) 3186 3563 }; 3187 3564 }, … … 3198 3575 var ce, co, over, 3199 3576 o = this.options; 3200 if (o.containment === "parent") {3201 o.containment = this.helper[ 0].parentNode;3202 } 3203 if (o.containment === "document" || o.containment === "window") {3577 if ( o.containment === "parent" ) { 3578 o.containment = this.helper[ 0 ].parentNode; 3579 } 3580 if ( o.containment === "document" || o.containment === "window" ) { 3204 3581 this.containment = [ 3205 3582 0 - this.offset.relative.left - this.offset.parent.left, 3206 3583 0 - this.offset.relative.top - this.offset.parent.top, 3207 o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left, 3208 (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top 3584 o.containment === "document" ? 3585 this.document.width() : 3586 this.window.width() - this.helperProportions.width - this.margins.left, 3587 ( o.containment === "document" ? 3588 ( this.document.height() || document.body.parentNode.scrollHeight ) : 3589 this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight 3590 ) - this.helperProportions.height - this.margins.top 3209 3591 ]; 3210 3592 } 3211 3593 3212 if (!(/^(document|window|parent)$/).test(o.containment)) {3213 ce = $( o.containment)[0];3214 co = $( o.containment).offset();3215 over = ( $(ce).css("overflow") !== "hidden");3594 if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) { 3595 ce = $( o.containment )[ 0 ]; 3596 co = $( o.containment ).offset(); 3597 over = ( $( ce ).css( "overflow" ) !== "hidden" ); 3216 3598 3217 3599 this.containment = [ 3218 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, 3219 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, 3220 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, 3221 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top 3600 co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) + 3601 ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left, 3602 co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) + 3603 ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top, 3604 co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - 3605 ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) - 3606 ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) - 3607 this.helperProportions.width - this.margins.left, 3608 co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - 3609 ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) - 3610 ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) - 3611 this.helperProportions.height - this.margins.top 3222 3612 ]; 3223 3613 } … … 3225 3615 }, 3226 3616 3227 _convertPositionTo: function( d, pos) {3228 3229 if (!pos) {3617 _convertPositionTo: function( d, pos ) { 3618 3619 if ( !pos ) { 3230 3620 pos = this.position; 3231 3621 } 3232 3622 var mod = d === "absolute" ? 1 : -1, 3233 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, 3234 scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); 3623 scroll = this.cssPosition === "absolute" && 3624 !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 3625 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? 3626 this.offsetParent : 3627 this.scrollParent, 3628 scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); 3235 3629 3236 3630 return { 3237 3631 top: ( 3238 pos.top + // The absolute mouse position 3239 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent 3240 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) 3241 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) 3632 3633 // The absolute mouse position 3634 pos.top + 3635 3636 // Only for relative positioned nodes: Relative offset from element to offset parent 3637 this.offset.relative.top * mod + 3638 3639 // The offsetParent's offset without borders (offset + border) 3640 this.offset.parent.top * mod - 3641 ( ( this.cssPosition === "fixed" ? 3642 -this.scrollParent.scrollTop() : 3643 ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod ) 3242 3644 ), 3243 3645 left: ( 3244 pos.left + // The absolute mouse position 3245 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent 3246 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) 3247 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) 3646 3647 // The absolute mouse position 3648 pos.left + 3649 3650 // Only for relative positioned nodes: Relative offset from element to offset parent 3651 this.offset.relative.left * mod + 3652 3653 // The offsetParent's offset without borders (offset + border) 3654 this.offset.parent.left * mod - 3655 ( ( this.cssPosition === "fixed" ? 3656 -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : 3657 scroll.scrollLeft() ) * mod ) 3248 3658 ) 3249 3659 }; … … 3251 3661 }, 3252 3662 3253 _generatePosition: function( event) {3663 _generatePosition: function( event ) { 3254 3664 3255 3665 var top, left, … … 3257 3667 pageX = event.pageX, 3258 3668 pageY = event.pageY, 3259 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); 3669 scroll = this.cssPosition === "absolute" && 3670 !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 3671 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? 3672 this.offsetParent : 3673 this.scrollParent, 3674 scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); 3260 3675 3261 3676 // This is another very weird special case that only happens for relative elements: … … 3263 3678 // 2. and the scroll parent is the document or similar to the offset parent 3264 3679 // we have to refresh the relative offset during the scroll so there are no jumps 3265 if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) { 3680 if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 3681 this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) { 3266 3682 this.offset.relative = this._getRelativeOffset(); 3267 3683 } … … 3272 3688 */ 3273 3689 3274 if(this.originalPosition) { //If we are not dragging yet, we won't check for options 3275 3276 if(this.containment) { 3277 if(event.pageX - this.offset.click.left < this.containment[0]) { 3278 pageX = this.containment[0] + this.offset.click.left; 3279 } 3280 if(event.pageY - this.offset.click.top < this.containment[1]) { 3281 pageY = this.containment[1] + this.offset.click.top; 3282 } 3283 if(event.pageX - this.offset.click.left > this.containment[2]) { 3284 pageX = this.containment[2] + this.offset.click.left; 3285 } 3286 if(event.pageY - this.offset.click.top > this.containment[3]) { 3287 pageY = this.containment[3] + this.offset.click.top; 3288 } 3289 } 3290 3291 if(o.grid) { 3292 top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; 3293 pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; 3294 3295 left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; 3296 pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; 3690 if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options 3691 3692 if ( this.containment ) { 3693 if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) { 3694 pageX = this.containment[ 0 ] + this.offset.click.left; 3695 } 3696 if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) { 3697 pageY = this.containment[ 1 ] + this.offset.click.top; 3698 } 3699 if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) { 3700 pageX = this.containment[ 2 ] + this.offset.click.left; 3701 } 3702 if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) { 3703 pageY = this.containment[ 3 ] + this.offset.click.top; 3704 } 3705 } 3706 3707 if ( o.grid ) { 3708 top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) / 3709 o.grid[ 1 ] ) * o.grid[ 1 ]; 3710 pageY = this.containment ? 3711 ( ( top - this.offset.click.top >= this.containment[ 1 ] && 3712 top - this.offset.click.top <= this.containment[ 3 ] ) ? 3713 top : 3714 ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ? 3715 top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : 3716 top; 3717 3718 left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) / 3719 o.grid[ 0 ] ) * o.grid[ 0 ]; 3720 pageX = this.containment ? 3721 ( ( left - this.offset.click.left >= this.containment[ 0 ] && 3722 left - this.offset.click.left <= this.containment[ 2 ] ) ? 3723 left : 3724 ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ? 3725 left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : 3726 left; 3297 3727 } 3298 3728 … … 3301 3731 return { 3302 3732 top: ( 3303 pageY - // The absolute mouse position 3304 this.offset.click.top - // Click offset (relative to the element) 3305 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent 3306 this.offset.parent.top + // The offsetParent's offset without borders (offset + border) 3307 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) 3733 3734 // The absolute mouse position 3735 pageY - 3736 3737 // Click offset (relative to the element) 3738 this.offset.click.top - 3739 3740 // Only for relative positioned nodes: Relative offset from element to offset parent 3741 this.offset.relative.top - 3742 3743 // The offsetParent's offset without borders (offset + border) 3744 this.offset.parent.top + 3745 ( ( this.cssPosition === "fixed" ? 3746 -this.scrollParent.scrollTop() : 3747 ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) ) 3308 3748 ), 3309 3749 left: ( 3310 pageX - // The absolute mouse position 3311 this.offset.click.left - // Click offset (relative to the element) 3312 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent 3313 this.offset.parent.left + // The offsetParent's offset without borders (offset + border) 3314 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) 3750 3751 // The absolute mouse position 3752 pageX - 3753 3754 // Click offset (relative to the element) 3755 this.offset.click.left - 3756 3757 // Only for relative positioned nodes: Relative offset from element to offset parent 3758 this.offset.relative.left - 3759 3760 // The offsetParent's offset without borders (offset + border) 3761 this.offset.parent.left + 3762 ( ( this.cssPosition === "fixed" ? 3763 -this.scrollParent.scrollLeft() : 3764 scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) 3315 3765 ) 3316 3766 }; … … 3318 3768 }, 3319 3769 3320 _rearrange: function(event, i, a, hardRefresh) { 3321 3322 a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling)); 3770 _rearrange: function( event, i, a, hardRefresh ) { 3771 3772 a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) : 3773 i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ], 3774 ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) ); 3323 3775 3324 3776 //Various things done here to improve the performance: 3325 3777 // 1. we create a setTimeout, that calls refreshPositions 3326 3778 // 2. on the instance, we have a counter variable, that get's higher after every append 3327 // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same 3779 // 3. on the local scope, we copy the counter variable, and check in the timeout, 3780 // if it's still the same 3328 3781 // 4. this lets only the last addition to the timeout stack through 3329 3782 this.counter = this.counter ? ++this.counter : 1; 3330 3783 var counter = this.counter; 3331 3784 3332 this._delay(function() { 3333 if(counter === this.counter) { 3334 this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove 3335 } 3336 }); 3337 3338 }, 3339 3340 _clear: function(event, noPropagation) { 3785 this._delay( function() { 3786 if ( counter === this.counter ) { 3787 3788 //Precompute after each DOM insertion, NOT on mousemove 3789 this.refreshPositions( !hardRefresh ); 3790 } 3791 } ); 3792 3793 }, 3794 3795 _clear: function( event, noPropagation ) { 3341 3796 3342 3797 this.reverting = false; 3343 // We delay all events that have to be triggered to after the point where the placeholder has been removed and 3344 // everything else normalized again 3798 3799 // We delay all events that have to be triggered to after the point where the placeholder 3800 // has been removed and everything else normalized again 3345 3801 var i, 3346 3802 delayedTriggers = []; 3347 3803 3348 3804 // We first have to update the dom position of the actual currentItem 3349 // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) 3350 if(!this._noFinalSort && this.currentItem.parent().length) { 3351 this.placeholder.before(this.currentItem); 3805 // Note: don't do it if the current item is already removed (by a user), or it gets 3806 // reappended (see #4088) 3807 if ( !this._noFinalSort && this.currentItem.parent().length ) { 3808 this.placeholder.before( this.currentItem ); 3352 3809 } 3353 3810 this._noFinalSort = null; 3354 3811 3355 if(this.helper[0] === this.currentItem[0]) { 3356 for(i in this._storedCSS) { 3357 if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") { 3358 this._storedCSS[i] = ""; 3359 } 3360 } 3361 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); 3812 if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) { 3813 for ( i in this._storedCSS ) { 3814 if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) { 3815 this._storedCSS[ i ] = ""; 3816 } 3817 } 3818 this.currentItem.css( this._storedCSS ); 3819 this._removeClass( this.currentItem, "ui-sortable-helper" ); 3362 3820 } else { 3363 3821 this.currentItem.show(); 3364 3822 } 3365 3823 3366 if(this.fromOutside && !noPropagation) { 3367 delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); 3368 } 3369 if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) { 3370 delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed 3824 if ( this.fromOutside && !noPropagation ) { 3825 delayedTriggers.push( function( event ) { 3826 this._trigger( "receive", event, this._uiHash( this.fromOutside ) ); 3827 } ); 3828 } 3829 if ( ( this.fromOutside || 3830 this.domPosition.prev !== 3831 this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] || 3832 this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) { 3833 3834 // Trigger update callback if the DOM position has changed 3835 delayedTriggers.push( function( event ) { 3836 this._trigger( "update", event, this._uiHash() ); 3837 } ); 3371 3838 } 3372 3839 3373 3840 // Check if the items Container has Changed and trigger appropriate 3374 3841 // events. 3375 if (this !== this.currentContainer) { 3376 if(!noPropagation) { 3377 delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); }); 3378 delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); 3379 delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); 3380 } 3381 } 3382 3842 if ( this !== this.currentContainer ) { 3843 if ( !noPropagation ) { 3844 delayedTriggers.push( function( event ) { 3845 this._trigger( "remove", event, this._uiHash() ); 3846 } ); 3847 delayedTriggers.push( ( function( c ) { 3848 return function( event ) { 3849 c._trigger( "receive", event, this._uiHash( this ) ); 3850 }; 3851 } ).call( this, this.currentContainer ) ); 3852 delayedTriggers.push( ( function( c ) { 3853 return function( event ) { 3854 c._trigger( "update", event, this._uiHash( this ) ); 3855 }; 3856 } ).call( this, this.currentContainer ) ); 3857 } 3858 } 3383 3859 3384 3860 //Post events to containers … … 3388 3864 }; 3389 3865 } 3390 for ( i = this.containers.length - 1; i >= 0; i--){3391 if ( !noPropagation) {3866 for ( i = this.containers.length - 1; i >= 0; i-- ) { 3867 if ( !noPropagation ) { 3392 3868 delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) ); 3393 3869 } 3394 if (this.containers[i].containerCache.over) {3870 if ( this.containers[ i ].containerCache.over ) { 3395 3871 delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) ); 3396 this.containers[ i].containerCache.over = 0;3872 this.containers[ i ].containerCache.over = 0; 3397 3873 } 3398 3874 } … … 3403 3879 this.storedStylesheet.remove(); 3404 3880 } 3405 if (this._storedOpacity) {3406 this.helper.css( "opacity", this._storedOpacity);3407 } 3408 if (this._storedZIndex) {3409 this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);3881 if ( this._storedOpacity ) { 3882 this.helper.css( "opacity", this._storedOpacity ); 3883 } 3884 if ( this._storedZIndex ) { 3885 this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex ); 3410 3886 } 3411 3887 3412 3888 this.dragging = false; 3413 3889 3414 if(!noPropagation) { 3415 this._trigger("beforeStop", event, this._uiHash()); 3416 } 3417 3418 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! 3419 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); 3890 if ( !noPropagation ) { 3891 this._trigger( "beforeStop", event, this._uiHash() ); 3892 } 3893 3894 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, 3895 // it unbinds ALL events from the original node! 3896 this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); 3420 3897 3421 3898 if ( !this.cancelHelperRemoval ) { … … 3426 3903 } 3427 3904 3428 if(!noPropagation) { 3429 for (i=0; i < delayedTriggers.length; i++) { 3430 delayedTriggers[i].call(this, event); 3431 } //Trigger all delayed events 3432 this._trigger("stop", event, this._uiHash()); 3905 if ( !noPropagation ) { 3906 for ( i = 0; i < delayedTriggers.length; i++ ) { 3907 3908 // Trigger all delayed events 3909 delayedTriggers[ i ].call( this, event ); 3910 } 3911 this._trigger( "stop", event, this._uiHash() ); 3433 3912 } 3434 3913 … … 3439 3918 3440 3919 _trigger: function() { 3441 if ( $.Widget.prototype._trigger.apply(this, arguments) === false) {3920 if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) { 3442 3921 this.cancel(); 3443 3922 } 3444 3923 }, 3445 3924 3446 _uiHash: function( _inst) {3925 _uiHash: function( _inst ) { 3447 3926 var inst = _inst || this; 3448 3927 return { 3449 3928 helper: inst.helper, 3450 placeholder: inst.placeholder || $( []),3929 placeholder: inst.placeholder || $( [] ), 3451 3930 position: inst.position, 3452 3931 originalPosition: inst.originalPosition, … … 3457 3936 } 3458 3937 3459 } );3938 } ); 3460 3939 3461 3940 3462 3941 /*! 3463 * jQuery UI Accordion 1.1 1.43942 * jQuery UI Accordion 1.12.1 3464 3943 * http://jqueryui.com 3465 3944 * … … 3467 3946 * Released under the MIT license. 3468 3947 * http://jquery.org/license 3469 *3470 * http://api.jqueryui.com/accordion/3471 3948 */ 3472 3949 3473 3474 var accordion = $.widget( "ui.accordion", { 3475 version: "1.11.4", 3950 //>>label: Accordion 3951 //>>group: Widgets 3952 // jscs:disable maximumLineLength 3953 //>>description: Displays collapsible content panels for presenting information in a limited amount of space. 3954 // jscs:enable maximumLineLength 3955 //>>docs: http://api.jqueryui.com/accordion/ 3956 //>>demos: http://jqueryui.com/accordion/ 3957 //>>css.structure: ../../themes/base/core.css 3958 //>>css.structure: ../../themes/base/accordion.css 3959 //>>css.theme: ../../themes/base/theme.css 3960 3961 3962 3963 var widgetsAccordion = $.widget( "ui.accordion", { 3964 version: "1.12.1", 3476 3965 options: { 3477 3966 active: 0, 3478 3967 animate: {}, 3968 classes: { 3969 "ui-accordion-header": "ui-corner-top", 3970 "ui-accordion-header-collapsed": "ui-corner-all", 3971 "ui-accordion-content": "ui-corner-bottom" 3972 }, 3479 3973 collapsible: false, 3480 3974 event: "click", 3481 header: "> li > :first-child, > :not(li):even",3975 header: "> li > :first-child, > :not(li):even", 3482 3976 heightStyle: "auto", 3483 3977 icons: { … … 3486 3980 }, 3487 3981 3488 // callbacks3982 // Callbacks 3489 3983 activate: null, 3490 3984 beforeActivate: null … … 3509 4003 _create: function() { 3510 4004 var options = this.options; 4005 3511 4006 this.prevShow = this.prevHide = $(); 3512 this.element.addClass( "ui-accordion ui-widget ui-helper-reset" ) 3513 // ARIA 3514 .attr( "role", "tablist" ); 3515 3516 // don't allow collapsible: false and active: false / null 3517 if ( !options.collapsible && (options.active === false || options.active == null) ) { 4007 this._addClass( "ui-accordion", "ui-widget ui-helper-reset" ); 4008 this.element.attr( "role", "tablist" ); 4009 4010 // Don't allow collapsible: false and active: false / null 4011 if ( !options.collapsible && ( options.active === false || options.active == null ) ) { 3518 4012 options.active = 0; 3519 4013 } 3520 4014 3521 4015 this._processPanels(); 4016 3522 4017 // handle negative values 3523 4018 if ( options.active < 0 ) { … … 3535 4030 3536 4031 _createIcons: function() { 3537 var icons = this.options.icons; 4032 var icon, children, 4033 icons = this.options.icons; 4034 3538 4035 if ( icons ) { 3539 $( "<span>" )3540 .addClass( "ui-accordion-header-icon ui-icon " + icons.header )3541 .prependTo( this.headers );3542 this.active.children( ".ui-accordion-header-icon" )3543 .removeClass(icons.header )3544 . addClass( icons.activeHeader );3545 this.headers.addClass("ui-accordion-icons" );4036 icon = $( "<span>" ); 4037 this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header ); 4038 icon.prependTo( this.headers ); 4039 children = this.active.children( ".ui-accordion-header-icon" ); 4040 this._removeClass( children, icons.header ) 4041 ._addClass( children, null, icons.activeHeader ) 4042 ._addClass( this.headers, "ui-accordion-icons" ); 3546 4043 } 3547 4044 }, 3548 4045 3549 4046 _destroyIcons: function() { 3550 this.headers 3551 .removeClass( "ui-accordion-icons" ) 3552 .children( ".ui-accordion-header-icon" ) 3553 .remove(); 4047 this._removeClass( this.headers, "ui-accordion-icons" ); 4048 this.headers.children( ".ui-accordion-header-icon" ).remove(); 3554 4049 }, 3555 4050 … … 3557 4052 var contents; 3558 4053 3559 // clean up main element 3560 this.element 3561 .removeClass( "ui-accordion ui-widget ui-helper-reset" ) 3562 .removeAttr( "role" ); 3563 3564 // clean up headers 4054 // Clean up main element 4055 this.element.removeAttr( "role" ); 4056 4057 // Clean up headers 3565 4058 this.headers 3566 .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " + 3567 "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" ) 3568 .removeAttr( "role" ) 3569 .removeAttr( "aria-expanded" ) 3570 .removeAttr( "aria-selected" ) 3571 .removeAttr( "aria-controls" ) 3572 .removeAttr( "tabIndex" ) 4059 .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" ) 3573 4060 .removeUniqueId(); 3574 4061 3575 4062 this._destroyIcons(); 3576 4063 3577 // clean up content panels4064 // Clean up content panels 3578 4065 contents = this.headers.next() 3579 .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +3580 "ui-accordion-content ui-accordion-content-active ui-state-disabled" )3581 4066 .css( "display", "" ) 3582 .removeAttr( "role" ) 3583 .removeAttr( "aria-hidden" ) 3584 .removeAttr( "aria-labelledby" ) 4067 .removeAttr( "role aria-hidden aria-labelledby" ) 3585 4068 .removeUniqueId(); 3586 4069 … … 3592 4075 _setOption: function( key, value ) { 3593 4076 if ( key === "active" ) { 4077 3594 4078 // _activate() will handle invalid values and update this.options 3595 4079 this._activate( value ); … … 3606 4090 this._super( key, value ); 3607 4091 3608 // setting collapsible: false while collapsed; open first panel4092 // Setting collapsible: false while collapsed; open first panel 3609 4093 if ( key === "collapsible" && !value && this.options.active === false ) { 3610 4094 this._activate( 0 ); … … 3617 4101 } 3618 4102 } 3619 3620 // #5332 - opacity doesn't cascade to positioned elements in IE 4103 }, 4104 4105 _setOptionDisabled: function( value ) { 4106 this._super( value ); 4107 4108 this.element.attr( "aria-disabled", value ); 4109 4110 // Support: IE8 Only 4111 // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE 3621 4112 // so we need to add the disabled class to the headers and panels 3622 if ( key === "disabled" ) { 3623 this.element 3624 .toggleClass( "ui-state-disabled", !!value ) 3625 .attr( "aria-disabled", value ); 3626 this.headers.add( this.headers.next() ) 3627 .toggleClass( "ui-state-disabled", !!value ); 3628 } 4113 this._toggleClass( null, "ui-state-disabled", !!value ); 4114 this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled", 4115 !!value ); 3629 4116 }, 3630 4117 … … 3640 4127 3641 4128 switch ( event.keyCode ) { 3642 case keyCode.RIGHT:3643 case keyCode.DOWN:3644 toFocus = this.headers[ ( currentIndex + 1 ) % length ];3645 break;3646 case keyCode.LEFT:3647 case keyCode.UP:3648 toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];3649 break;3650 case keyCode.SPACE:3651 case keyCode.ENTER:3652 this._eventHandler( event );3653 break;3654 case keyCode.HOME:3655 toFocus = this.headers[ 0 ];3656 break;3657 case keyCode.END:3658 toFocus = this.headers[ length - 1 ];3659 break;4129 case keyCode.RIGHT: 4130 case keyCode.DOWN: 4131 toFocus = this.headers[ ( currentIndex + 1 ) % length ]; 4132 break; 4133 case keyCode.LEFT: 4134 case keyCode.UP: 4135 toFocus = this.headers[ ( currentIndex - 1 + length ) % length ]; 4136 break; 4137 case keyCode.SPACE: 4138 case keyCode.ENTER: 4139 this._eventHandler( event ); 4140 break; 4141 case keyCode.HOME: 4142 toFocus = this.headers[ 0 ]; 4143 break; 4144 case keyCode.END: 4145 toFocus = this.headers[ length - 1 ]; 4146 break; 3660 4147 } 3661 4148 … … 3663 4150 $( event.target ).attr( "tabIndex", -1 ); 3664 4151 $( toFocus ).attr( "tabIndex", 0 ); 3665 toFocus.focus();4152 $( toFocus ).trigger( "focus" ); 3666 4153 event.preventDefault(); 3667 4154 } … … 3670 4157 _panelKeyDown: function( event ) { 3671 4158 if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) { 3672 $( event.currentTarget ).prev(). focus();4159 $( event.currentTarget ).prev().trigger( "focus" ); 3673 4160 } 3674 4161 }, … … 3678 4165 this._processPanels(); 3679 4166 3680 // was collapsed or no panel 3681 if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) { 4167 // Was collapsed or no panel 4168 if ( ( options.active === false && options.collapsible === true ) || 4169 !this.headers.length ) { 3682 4170 options.active = false; 3683 4171 this.active = $(); 4172 3684 4173 // active false only when collapsible is true 3685 4174 } else if ( options.active === false ) { 3686 4175 this._activate( 0 ); 4176 3687 4177 // was active, but active panel is gone 3688 4178 } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { 4179 3689 4180 // all remaining panel are disabled 3690 if ( this.headers.length === this.headers.find( ".ui-state-disabled").length ) {4181 if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) { 3691 4182 options.active = false; 3692 4183 this.active = $(); 4184 3693 4185 // activate previous panel 3694 4186 } else { 3695 4187 this._activate( Math.max( 0, options.active - 1 ) ); 3696 4188 } 4189 3697 4190 // was active, active panel still exists 3698 4191 } else { 4192 3699 4193 // make sure active index is correct 3700 4194 options.active = this.headers.index( this.active ); … … 3710 4204 prevPanels = this.panels; 3711 4205 3712 this.headers = this.element.find( this.options.header ) 3713 .addClass( "ui-accordion-header ui-state-default ui-corner-all" ); 3714 3715 this.panels = this.headers.next() 3716 .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ) 3717 .filter( ":not(.ui-accordion-content-active)" ) 3718 .hide(); 4206 this.headers = this.element.find( this.options.header ); 4207 this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed", 4208 "ui-state-default" ); 4209 4210 this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide(); 4211 this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" ); 3719 4212 3720 4213 // Avoid memory leaks (#10056) … … 3731 4224 parent = this.element.parent(); 3732 4225 3733 this.active = this._findActive( options.active ) 3734 .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ) 3735 .removeClass( "ui-corner-all" ); 3736 this.active.next() 3737 .addClass( "ui-accordion-content-active" ) 3738 .show(); 4226 this.active = this._findActive( options.active ); 4227 this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" ) 4228 ._removeClass( this.active, "ui-accordion-header-collapsed" ); 4229 this._addClass( this.active.next(), "ui-accordion-content-active" ); 4230 this.active.next().show(); 3739 4231 3740 4232 this.headers 3741 4233 .attr( "role", "tab" ) 3742 .each( function() {4234 .each( function() { 3743 4235 var header = $( this ), 3744 4236 headerId = header.uniqueId().attr( "id" ), … … 3747 4239 header.attr( "aria-controls", panelId ); 3748 4240 panel.attr( "aria-labelledby", headerId ); 3749 } )4241 } ) 3750 4242 .next() 3751 4243 .attr( "role", "tabpanel" ); … … 3753 4245 this.headers 3754 4246 .not( this.active ) 3755 .attr({3756 "aria-selected": "false",3757 "aria-expanded": "false",3758 tabIndex: -13759 })3760 .next()3761 .attr({3762 "aria-hidden": "true"3763 })3764 .hide();3765 3766 // make sure at least one header is in the tab order4247 .attr( { 4248 "aria-selected": "false", 4249 "aria-expanded": "false", 4250 tabIndex: -1 4251 } ) 4252 .next() 4253 .attr( { 4254 "aria-hidden": "true" 4255 } ) 4256 .hide(); 4257 4258 // Make sure at least one header is in the tab order 3767 4259 if ( !this.active.length ) { 3768 4260 this.headers.eq( 0 ).attr( "tabIndex", 0 ); 3769 4261 } else { 3770 this.active.attr( {4262 this.active.attr( { 3771 4263 "aria-selected": "true", 3772 4264 "aria-expanded": "true", 3773 4265 tabIndex: 0 3774 } )3775 .next()3776 .attr({3777 "aria-hidden": "false"3778 });4266 } ) 4267 .next() 4268 .attr( { 4269 "aria-hidden": "false" 4270 } ); 3779 4271 } 3780 4272 … … 3785 4277 if ( heightStyle === "fill" ) { 3786 4278 maxHeight = parent.height(); 3787 this.element.siblings( ":visible" ).each( function() {4279 this.element.siblings( ":visible" ).each( function() { 3788 4280 var elem = $( this ), 3789 4281 position = elem.css( "position" ); … … 3793 4285 } 3794 4286 maxHeight -= elem.outerHeight( true ); 3795 } );3796 3797 this.headers.each( function() {4287 } ); 4288 4289 this.headers.each( function() { 3798 4290 maxHeight -= $( this ).outerHeight( true ); 3799 } );4291 } ); 3800 4292 3801 4293 this.headers.next() 3802 .each( function() {4294 .each( function() { 3803 4295 $( this ).height( Math.max( 0, maxHeight - 3804 4296 $( this ).innerHeight() + $( this ).height() ) ); 3805 } )4297 } ) 3806 4298 .css( "overflow", "auto" ); 3807 4299 } else if ( heightStyle === "auto" ) { 3808 4300 maxHeight = 0; 3809 4301 this.headers.next() 3810 .each(function() { 4302 .each( function() { 4303 var isVisible = $( this ).is( ":visible" ); 4304 if ( !isVisible ) { 4305 $( this ).show(); 4306 } 3811 4307 maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); 3812 }) 4308 if ( !isVisible ) { 4309 $( this ).hide(); 4310 } 4311 } ) 3813 4312 .height( maxHeight ); 3814 4313 } … … 3818 4317 var active = this._findActive( index )[ 0 ]; 3819 4318 3820 // trying to activate the already active panel4319 // Trying to activate the already active panel 3821 4320 if ( active === this.active[ 0 ] ) { 3822 4321 return; 3823 4322 } 3824 4323 3825 // trying to collapse, simulate a click on the currently active header4324 // Trying to collapse, simulate a click on the currently active header 3826 4325 active = active || this.active[ 0 ]; 3827 4326 3828 this._eventHandler( {4327 this._eventHandler( { 3829 4328 target: active, 3830 4329 currentTarget: active, 3831 4330 preventDefault: $.noop 3832 } );4331 } ); 3833 4332 }, 3834 4333 … … 3844 4343 $.each( event.split( " " ), function( index, eventName ) { 3845 4344 events[ eventName ] = "_eventHandler"; 3846 } );4345 } ); 3847 4346 } 3848 4347 3849 4348 this._off( this.headers.add( this.headers.next() ) ); 3850 4349 this._on( this.headers, events ); 3851 this._on( this.headers.next(), { keydown: "_panelKeyDown" } );4350 this._on( this.headers.next(), { keydown: "_panelKeyDown" } ); 3852 4351 this._hoverable( this.headers ); 3853 4352 this._focusable( this.headers ); … … 3855 4354 3856 4355 _eventHandler: function( event ) { 3857 var options = this.options, 4356 var activeChildren, clickedChildren, 4357 options = this.options, 3858 4358 active = this.active, 3859 4359 clicked = $( event.currentTarget ), … … 3872 4372 3873 4373 if ( 4374 3874 4375 // click on active header, but not collapsible 3875 4376 ( clickedIsActive && !options.collapsible ) || 4377 3876 4378 // allow canceling activation 3877 4379 ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { … … 3881 4383 options.active = collapsing ? false : this.headers.index( clicked ); 3882 4384 3883 // when the call to ._toggle() comes after the class changes4385 // When the call to ._toggle() comes after the class changes 3884 4386 // it causes a very odd bug in IE 8 (see #6720) 3885 4387 this.active = clickedIsActive ? $() : clicked; 3886 4388 this._toggle( eventData ); 3887 4389 3888 // switch classes4390 // Switch classes 3889 4391 // corner classes on the previously active header stay after the animation 3890 active.removeClass( "ui-accordion-header-activeui-state-active" );4392 this._removeClass( active, "ui-accordion-header-active", "ui-state-active" ); 3891 4393 if ( options.icons ) { 3892 active .children( ".ui-accordion-header-icon" )3893 .removeClass(options.icons.activeHeader )3894 . addClass(options.icons.header );4394 activeChildren = active.children( ".ui-accordion-header-icon" ); 4395 this._removeClass( activeChildren, null, options.icons.activeHeader ) 4396 ._addClass( activeChildren, null, options.icons.header ); 3895 4397 } 3896 4398 3897 4399 if ( !clickedIsActive ) { 3898 clicked 3899 .removeClass( "ui-corner-all" ) 3900 .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ); 4400 this._removeClass( clicked, "ui-accordion-header-collapsed" ) 4401 ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" ); 3901 4402 if ( options.icons ) { 3902 clicked.children( ".ui-accordion-header-icon" ) 3903 .removeClass( options.icons.header ) 3904 .addClass( options.icons.activeHeader ); 3905 } 3906 3907 clicked 3908 .next() 3909 .addClass( "ui-accordion-content-active" ); 4403 clickedChildren = clicked.children( ".ui-accordion-header-icon" ); 4404 this._removeClass( clickedChildren, null, options.icons.header ) 4405 ._addClass( clickedChildren, null, options.icons.activeHeader ); 4406 } 4407 4408 this._addClass( clicked.next(), "ui-accordion-content-active" ); 3910 4409 } 3911 4410 }, … … 3915 4414 toHide = this.prevShow.length ? this.prevShow : data.oldPanel; 3916 4415 3917 // handle activating a panel during the animation for another activation4416 // Handle activating a panel during the animation for another activation 3918 4417 this.prevShow.add( this.prevHide ).stop( true, true ); 3919 4418 this.prevShow = toShow; … … 3928 4427 } 3929 4428 3930 toHide.attr( {4429 toHide.attr( { 3931 4430 "aria-hidden": "true" 3932 } );3933 toHide.prev().attr( {4431 } ); 4432 toHide.prev().attr( { 3934 4433 "aria-selected": "false", 3935 4434 "aria-expanded": "false" 3936 }); 4435 } ); 4436 3937 4437 // if we're switching panels, remove the old header from the tab order 3938 4438 // if we're opening from collapsed state, remove the previous header from the tab order 3939 4439 // if we're collapsing, then keep the collapsing header in the tab order 3940 4440 if ( toShow.length && toHide.length ) { 3941 toHide.prev().attr( {4441 toHide.prev().attr( { 3942 4442 "tabIndex": -1, 3943 4443 "aria-expanded": "false" 3944 } );4444 } ); 3945 4445 } else if ( toShow.length ) { 3946 this.headers.filter( function() {4446 this.headers.filter( function() { 3947 4447 return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0; 3948 } )3949 .attr( "tabIndex", -1 );4448 } ) 4449 .attr( "tabIndex", -1 ); 3950 4450 } 3951 4451 … … 3953 4453 .attr( "aria-hidden", "false" ) 3954 4454 .prev() 3955 .attr( {4455 .attr( { 3956 4456 "aria-selected": "true", 3957 4457 "aria-expanded": "true", 3958 4458 tabIndex: 0 3959 } );4459 } ); 3960 4460 }, 3961 4461 … … 3979 4479 easing = options; 3980 4480 } 4481 3981 4482 // fall back from options to animation in case of partial down settings 3982 4483 easing = easing || options.easing || animate.easing; … … 3997 4498 fx.now = Math.round( now ); 3998 4499 } 3999 } );4500 } ); 4000 4501 toShow 4001 4502 .hide() … … 4015 4516 } 4016 4517 } 4017 } );4518 } ); 4018 4519 }, 4019 4520 4020 4521 _toggleComplete: function( data ) { 4021 var toHide = data.oldPanel; 4022 4023 toHide 4024 .removeClass( "ui-accordion-content-active" ) 4025 .prev() 4026 .removeClass( "ui-corner-top" ) 4027 .addClass( "ui-corner-all" ); 4522 var toHide = data.oldPanel, 4523 prev = toHide.prev(); 4524 4525 this._removeClass( toHide, "ui-accordion-content-active" ); 4526 this._removeClass( prev, "ui-accordion-header-active" ) 4527 ._addClass( prev, "ui-accordion-header-collapsed" ); 4028 4528 4029 4529 // Work around for rendering bug in IE (#5421) … … 4033 4533 this._trigger( "activate", null, data ); 4034 4534 } 4035 }); 4535 } ); 4536 4036 4537 4037 4538
Note: See TracChangeset
for help on using the changeset viewer.
