r1611 - trunk/ui

r1611 - trunk/ui


Author: scott.gonzalez
Date: Thu Jan 15 11:40:11 2009
New Revision: 1611
Modified:
trunk/ui/ui.core.js
trunk/ui/ui.draggable.js
Log:
Widget factory: Fixed event triggering (again).
Draggable: To modify the position during drag, you now set ui.position
instead of returning new coords.
Modified: trunk/ui/ui.core.js
==============================================================================
--- trunk/ui/ui.core.js    (original)
+++ trunk/ui/ui.core.js    Thu Jan 15 11:40:11 2009
@@ -370,20 +370,13 @@
            eventName = (type == this.widgetEventPrefix
                ? type : this.widgetEventPrefix + type);
-        // event can be null, a hash, a native event, a fixed event
-        event = event ? $.extend(event, $.Event()) : $.Event();
+        event = $.Event(event);
        event.type = eventName;
        this.element.trigger(event, data);
-        var callbackResult = callback
-            ? callback.call(this.element[0], event, data)
-            : undefined;
-        
-        event.result = callbackResult !== undefined
-            ? callbackResult
-            : event.result;
-        
-        return event.result !== false;
+
+        return !(callback && callback.call(this.element[0], event, data) ===
false
+            || event.isDefaultPrevented());
    }
};
Modified: trunk/ui/ui.draggable.js
==============================================================================
--- trunk/ui/ui.draggable.js    (original)
+++ trunk/ui/ui.draggable.js    Thu Jan 15 11:40:11 2009
@@ -125,7 +125,11 @@
        this.positionAbs = this._convertPositionTo("absolute");
        //Call plugins and callbacks and use the resulting position if something
is returned
-        if(!noPropagation) this.position = this._trigger("drag", event) ||
this.position;
+        if (!noPropagation) {
+            var ui = this._uiHash();
+            this._trigger('drag', event, ui);
+            this.position = ui.position;
+        }
        if(!this.options.axis || this.options.axis != "y")
this.helper[0].style.left = this.position.left+'px';
        if(!this.options.axis || this.options.axis != "x")
this.helper[0].style.top = this.position.top+'px';
@@ -368,11 +372,11 @@
    // From now on bulk stuff - mainly helpers
-    _trigger: function(type, event) {
-        $.ui.plugin.call(this, type, [event, this._uiHash()]);
+    _trigger: function(type, event, ui) {
+        ui = ui || this._uiHash();
+        $.ui.plugin.call(this, type, [event, ui]);
        if(type == "drag") this.positionAbs =
this._convertPositionTo("absolute"); //The absolute position has to be
recalculated after plugins
-        $.widget.prototype._trigger.call(this, type, event, this._uiHash());
-        return event.returnValue;
+        return $.widget.prototype._trigger.call(this, type, event, ui);
    },
    plugins: {},