r861 - trunk/ui

r861 - trunk/ui


Author: paul.bakaus
Date: Tue Nov 4 05:34:04 2008
New Revision: 861
Modified:
trunk/ui/ui.sortable.js
Log:
sortable: removed support for ui.cancel(), must now be called via the
sortable() function as method (sortable('cancel')). Now works even if the
drag is still ongoing, i.e. the mouse button is still pressed.
Modified: trunk/ui/ui.sortable.js
==============================================================================
--- trunk/ui/ui.sortable.js    (original)
+++ trunk/ui/ui.sortable.js    Tue Nov 4 05:34:04 2008
@@ -45,7 +45,7 @@
    },
    plugins: {},
-    ui: function(inst) {
+    _ui: function(inst) {
        var self = inst || this;
        return {
            helper: self.helper,
@@ -55,14 +55,16 @@
            options: this.options,
            element: this.element,
            item: self.currentItem,
-            sender: inst ? inst.element : null,
-            cancel: function() { self.cancel(); }
+            sender: inst ? inst.element : null
        };
    },
    
    cancel: function() {
        if(this.dragging) {
+            
+            this._mouseUp();
+            
            if(this.options.helper == "original")
                
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
            else
@@ -76,6 +78,7 @@
                    this.containers[i].containerCache.over = 0;
                }
            }
+            
        }
        //$(this.placeholder[0]).remove(); would have been the jQuery way -
unfortunately, it unbinds ALL events from the original node!
@@ -100,8 +103,8 @@
    },
    _propagate: function(n,e,inst, noPropagation) {
-        $.ui.plugin.call(this, n, [e, this.ui(inst)]);
-        if(!noPropagation) this.element.triggerHandler(n == "sort" ?
n : "sort"+n, [e, this.ui(inst)], this.options[n]);
+        $.ui.plugin.call(this, n, [e, this._ui(inst)]);
+        if(!noPropagation) this.element.triggerHandler(n == "sort" ?
n : "sort"+n, [e, this._ui(inst)], this.options[n]);
    },
    serialize: function(o) {
@@ -699,7 +702,7 @@
        }
        //Call the internal plugins
-        $.ui.plugin.call(this, "sort", [e, this.ui()]);
+        $.ui.plugin.call(this, "sort", [e, this._ui()]);
        //Regenerate the absolute position used for position checks
        this.positionAbs = this._convertPositionTo("absolute");
@@ -738,7 +741,7 @@
        if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
        //Call callbacks
-        this.element.triggerHandler("sort", [e, this.ui()],
this.options["sort"]);
+        this.element.triggerHandler("sort", [e, this._ui()],
this.options["sort"]);
        this.lastPositionAbs = this.positionAbs;
@@ -765,6 +768,8 @@
    },
    _mouseStop: function(e, noPropagation) {
+
+        if(!e) return;
        //If we are using droppables, inform the manager about the drop
        if ($.ui.ddmanager && !this.options.dropBehaviour)