diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-08-24 08:59:32 -0400 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-09-11 08:29:08 -0400 |
commit | 0cab9f0a2f1f91ae671d57dba5e5bdcde1f60622 (patch) | |
tree | c0b2a80e2dc4faf96eba0733ef7f687bcdecbf9e /ui | |
parent | 85ff5205605ad591af9e9848a78334ee44b2284e (diff) | |
download | jquery-ui-0cab9f0a2f1f91ae671d57dba5e5bdcde1f60622.tar.gz jquery-ui-0cab9f0a2f1f91ae671d57dba5e5bdcde1f60622.zip |
Droppable: Style updates
Ref #14246
Diffstat (limited to 'ui')
-rw-r--r-- | ui/widgets/droppable.js | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/ui/widgets/droppable.js b/ui/widgets/droppable.js index 6ba8d8c80..136a32b80 100644 --- a/ui/widgets/droppable.js +++ b/ui/widgets/droppable.js @@ -13,11 +13,11 @@ //>>docs: http://api.jqueryui.com/droppable/ //>>demos: http://jqueryui.com/droppable/ -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. - define([ + define( [ "jquery", "./draggable", "./mouse", @@ -29,7 +29,7 @@ // Browser globals factory( jQuery ); } -}(function( $ ) { +}( function( $ ) { $.widget( "ui.droppable", { version: "@VERSION", @@ -63,9 +63,11 @@ $.widget( "ui.droppable", { this.proportions = function( /* valueToWrite */ ) { if ( arguments.length ) { + // Store the droppable's proportions proportions = arguments[ 0 ]; } else { + // Retrieve or derive the droppable's proportions return proportions ? proportions : @@ -83,6 +85,7 @@ $.widget( "ui.droppable", { }, _addToManager: function( scope ) { + // Add the reference and positions to the manager $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || []; $.ui.ddmanager.droppables[ scope ].push( this ); @@ -123,7 +126,7 @@ $.widget( "ui.droppable", { var draggable = $.ui.ddmanager.current; this._addActiveClass(); - if ( draggable ){ + if ( draggable ) { this._trigger( "activate", event, this.ui( draggable ) ); } }, @@ -132,7 +135,7 @@ $.widget( "ui.droppable", { var draggable = $.ui.ddmanager.current; this._removeActiveClass(); - if ( draggable ){ + if ( draggable ) { this._trigger( "deactivate", event, this.ui( draggable ) ); } }, @@ -179,7 +182,7 @@ $.widget( "ui.droppable", { return false; } - this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() { + this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each( function() { var inst = $( this ).droppable( "instance" ); if ( inst.options.greedy && @@ -188,7 +191,7 @@ $.widget( "ui.droppable", { inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) && intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event ) ) { childrenIntersection = true; return false; } - }); + } ); if ( childrenIntersection ) { return false; } @@ -231,9 +234,9 @@ $.widget( "ui.droppable", { _removeActiveClass: function() { this._removeClass( "ui-droppable-active" ); } -}); +} ); -var intersect = (function() { +var intersect = ( function() { function isOverAxis( x, reference, size ) { return ( x >= reference ) && ( x < ( reference + size ) ); } @@ -277,7 +280,7 @@ var intersect = (function() { return false; } }; -})(); +} )(); /* This manager tracks offsets of draggables and droppables @@ -318,7 +321,7 @@ $.ui.ddmanager = { } m[ i ].offset = m[ i ].element.offset(); - m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight }); + m[ i ].proportions( { width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight } ); } @@ -326,6 +329,7 @@ $.ui.ddmanager = { drop: function( draggable, event ) { var dropped = false; + // Create a copy of the droppables in case the list changes during the drop (#9116) $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() { @@ -342,17 +346,18 @@ $.ui.ddmanager = { this._deactivate.call( this, event ); } - }); + } ); return dropped; }, dragStart: function( draggable, event ) { + // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003) draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() { if ( !draggable.options.refreshPositions ) { $.ui.ddmanager.prepareOffsets( draggable, event ); } - }); + } ); }, drag: function( draggable, event ) { @@ -376,11 +381,12 @@ $.ui.ddmanager = { } if ( this.options.greedy ) { + // find droppable parents with same scope scope = this.options.scope; - parent = this.element.parents( ":data(ui-droppable)" ).filter(function() { + parent = this.element.parents( ":data(ui-droppable)" ).filter( function() { return $( this ).droppable( "instance" ).options.scope === scope; - }); + } ); if ( parent.length ) { parentInstance = $( parent[ 0 ] ).droppable( "instance" ); @@ -396,8 +402,8 @@ $.ui.ddmanager = { } this[ c ] = true; - this[c === "isout" ? "isover" : "isout"] = false; - this[c === "isover" ? "_over" : "_out"].call( this, event ); + this[ c === "isout" ? "isover" : "isout" ] = false; + this[ c === "isover" ? "_over" : "_out" ].call( this, event ); // We just moved out of a greedy child if ( parentInstance && c === "isout" ) { @@ -405,11 +411,12 @@ $.ui.ddmanager = { parentInstance.isover = true; parentInstance._over.call( parentInstance, event ); } - }); + } ); }, dragStop: function( draggable, event ) { draggable.element.parentsUntil( "body" ).off( "scroll.droppable" ); + // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003) if ( !draggable.options.refreshPositions ) { $.ui.ddmanager.prepareOffsets( draggable, event ); @@ -451,9 +458,9 @@ if ( $.uiBackCompat !== false ) { this.element.removeClass( this.options.hoverClass ); } } - }); + } ); } return $.ui.droppable; -})); +} ) ); |