]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - resources/lib/jquery.ui/jquery.ui.droppable.js
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / resources / lib / jquery.ui / jquery.ui.droppable.js
similarity index 86%
rename from resources/jquery.ui/jquery.ui.droppable.js
rename to resources/lib/jquery.ui/jquery.ui.droppable.js
index b6a15fdf1b158d78598c7247ce0eedd8295ce9ef..1e9ea5139bb2c6724ba8529129e8a872f538370a 100644 (file)
@@ -1,11 +1,12 @@
-/*
- * jQuery UI Droppable 1.8.2
+/*!
+ * jQuery UI Droppable 1.9.2
+ * http://jqueryui.com
  *
- * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
- * Dual licensed under the MIT (MIT-LICENSE.txt)
- * and GPL (GPL-LICENSE.txt) licenses.
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
  *
- * http://docs.jquery.com/UI/Droppables
+ * http://api.jqueryui.com/droppable/
  *
  * Depends:
  *     jquery.ui.core.js
  *     jquery.ui.mouse.js
  *     jquery.ui.draggable.js
  */
-(function($) {
+(function( $, undefined ) {
 
 $.widget("ui.droppable", {
+       version: "1.9.2",
        widgetEventPrefix: "drop",
        options: {
                accept: '*',
@@ -46,18 +48,13 @@ $.widget("ui.droppable", {
 
        },
 
-       destroy: function() {
+       _destroy: function() {
                var drop = $.ui.ddmanager.droppables[this.options.scope];
                for ( var i = 0; i < drop.length; i++ )
                        if ( drop[i] == this )
                                drop.splice(i, 1);
 
-               this.element
-                       .removeClass("ui-droppable ui-droppable-disabled")
-                       .removeData("droppable")
-                       .unbind(".droppable");
-
-               return this;
+               this.element.removeClass("ui-droppable ui-droppable-disabled");
        },
 
        _setOption: function(key, value) {
@@ -146,10 +143,6 @@ $.widget("ui.droppable", {
 
 });
 
-$.extend($.ui.droppable, {
-       version: "1.8.2"
-});
-
 $.ui.intersect = function(draggable, droppable, toleranceMode) {
 
        if (!droppable.offset) return false;
@@ -161,8 +154,8 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) {
 
        switch (toleranceMode) {
                case 'fit':
-                       return (l < x1 && x2 < r
-                               && t < y1 && y2 < b);
+                       return (l <= x1 && x2 <= r
+                               && t <= y1 && y2 <= b);
                        break;
                case 'intersect':
                        return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
@@ -212,11 +205,11 @@ $.ui.ddmanager = {
                        for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
                        m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue;                                                                       //If the element is not visible, continue
 
+                       if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
+
                        m[i].offset = m[i].element.offset();
                        m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
 
-                       if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
-
                }
 
        },
@@ -227,7 +220,7 @@ $.ui.ddmanager = {
 
                        if(!this.options) return;
                        if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
-                               dropped = dropped || this._drop.call(this, event);
+                               dropped = this._drop.call(this, event) || dropped;
 
                        if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
                                this.isout = 1; this.isover = 0;
@@ -238,6 +231,12 @@ $.ui.ddmanager = {
                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" ).bind( "scroll.droppable", function() {
+                       if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
+               });
+       },
        drag: function(draggable, event) {
 
                //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
@@ -254,7 +253,12 @@ $.ui.ddmanager = {
 
                        var parentInstance;
                        if (this.options.greedy) {
-                               var parent = this.element.parents(':data(droppable):eq(0)');
+                               // find droppable parents with same scope
+                               var scope = this.options.scope;
+                               var parent = this.element.parents(':data(droppable)').filter(function () {
+                                       return $.data(this, 'droppable').options.scope === scope;
+                               });
+
                                if (parent.length) {
                                        parentInstance = $.data(parent[0], 'droppable');
                                        parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
@@ -279,6 +283,11 @@ $.ui.ddmanager = {
                        }
                });
 
+       },
+       dragStop: function( draggable, event ) {
+               draggable.element.parentsUntil( "body" ).unbind( "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 );
        }
 };