diff options
author | Eduardo Lundgren <eduardolundgren@gmail.com> | 2008-11-10 05:17:12 +0000 |
---|---|---|
committer | Eduardo Lundgren <eduardolundgren@gmail.com> | 2008-11-10 05:17:12 +0000 |
commit | acf15c4f085640e975f74959bd67b3723066ecfd (patch) | |
tree | e1373add5460f23348ad6e38c0e150fcf56579df | |
parent | 91377e4e5c75146be3f5ca7d3b7b50d75392c89f (diff) | |
download | jquery-ui-acf15c4f085640e975f74959bd67b3723066ecfd.tar.gz jquery-ui-acf15c4f085640e975f74959bd67b3723066ecfd.zip |
Sortable: Using the new core intersectHeight/intersectWidth methods.
-rw-r--r-- | ui/ui.sortable.js | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/ui/ui.sortable.js b/ui/ui.sortable.js index f49596c23..c8fbad184 100644 --- a/ui/ui.sortable.js +++ b/ui/ui.sortable.js @@ -58,18 +58,18 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { 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 this.currentItem.show(); - + //Post deactivating events to containers for (var i = this.containers.length - 1; i >= 0; i--){ this.containers[i]._propagate("deactivate", null, this); @@ -78,28 +78,28 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { 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! if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove(); - + $.extend(this, { helper: null, dragging: false, reverting: false, _noFinalSort: null }); - + if(this.domPosition.prev) { $(this.domPosition.prev).after(this.currentItem); } else { $(this.domPosition.parent).prepend(this.currentItem); } - return true; - + return true; + }, _propagate: function(n,e,inst, noPropagation) { @@ -156,19 +156,12 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { _intersectsWithEdge: function(item) { var dyClick = this.offset.click.top, dxClick = this.offset.click.left; - var helperHeight = this.helperProportions.height, helperWidth = this.helperProportions.width; var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; var itemHeight = item.height, itemWidth = item.width; var itemTop = item.top, itemLeft = item.left; - var isOverElementHeight = - ((helperTop + dyClick) > itemTop) && - ((helperTop + dyClick) < (itemTop + itemHeight)); - - var isOverElementWidth = - ((helperLeft + dxClick) > itemLeft) && - ((helperLeft + dxClick) < (itemLeft + itemWidth)); - + var isOverElementHeight = $.ui.intersectHeight(helperTop + dyClick, itemTop, itemHeight); + var isOverElementWidth = $.ui.intersectWidth(helperLeft + dxClick, itemLeft, itemWidth); var isOverElement = isOverElementHeight && isOverElementWidth; var verticalDirection = this._getDragVerticalDirection(); var horizontalDirection = this._getDragHorizontalDirection(); @@ -837,10 +830,10 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { } this._propagate("beforeStop", e, null, noPropagation); - + //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! this.placeholder[0].parentNode.removeChild(this.placeholder[0]); - + if(this.options.helper != "original") this.helper.remove(); this.helper = null; this._propagate("stop", e, null, noPropagation); |