diff options
author | Paul Bakaus <paul.bakaus@googlemail.com> | 2010-01-28 16:35:59 +0000 |
---|---|---|
committer | Paul Bakaus <paul.bakaus@googlemail.com> | 2010-01-28 16:35:59 +0000 |
commit | 9617d150548df1dead1da9743d99abe378b41a3f (patch) | |
tree | 3b65e82c17e707743505a9d122b963e4bdbcd245 /ui/jquery.ui.draggable.js | |
parent | b72caa0f3d093dfa45cc022f11a4af13225d4ee6 (diff) | |
download | jquery-ui-9617d150548df1dead1da9743d99abe378b41a3f.tar.gz jquery-ui-9617d150548df1dead1da9743d99abe378b41a3f.zip |
draggable: implemented #4145 - start,drag and stop events should be preventable
Diffstat (limited to 'ui/jquery.ui.draggable.js')
-rw-r--r-- | ui/jquery.ui.draggable.js | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 0cc564b78..1753aa02b 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -137,8 +137,11 @@ $.widget("ui.draggable", $.ui.mouse, { if(o.containment) this._setContainment(); - //Call plugins and callbacks - this._trigger("start", event); + //Trigger event + callbacks + if(this._trigger("start", event) === false) { + this._clear(); + return false; + } //Recache the helper size this._cacheHelperProportions(); @@ -161,7 +164,10 @@ $.widget("ui.draggable", $.ui.mouse, { //Call plugins and callbacks and use the resulting position if something is returned if (!noPropagation) { var ui = this._uiHash(); - this._trigger('drag', event, ui); + if(this._trigger('drag', event, ui) === false) { + this._mouseUp({}); + return false; + } this.position = ui.position; } @@ -192,16 +198,30 @@ $.widget("ui.draggable", $.ui.mouse, { 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))) { var self = this; $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { - self._trigger("stop", event); - self._clear(); + if(self._trigger("stop", event) !== false) { + self._clear(); + } }); } else { - this._trigger("stop", event); - this._clear(); + if(this._trigger("stop", event) !== false) { + this._clear(); + } } return false; }, + + cancel: function() { + + if(this.helper.is(".ui-draggable-dragging")) { + this._mouseUp({}); + } else { + this._clear(); + } + + return this; + + }, _getHandle: function(event) { |