From cf48fc7ee4fad5a641d675265afbe4573f55fb72 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Wed, 9 Jul 2008 09:03:24 +0000 Subject: sortable: added forcePointerForContainers option (to have another intersection mode for items, but allow only one container to be activated at the same time), added custom object in options, that holds custom (defined) functions that are called instead of original pieces. Only for advanced developers, currently only supported function: refreshContainers. --- ui/ui.sortable.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'ui') diff --git a/ui/ui.sortable.js b/ui/ui.sortable.js index 0fd46d152..6d33bf98c 100644 --- a/ui/ui.sortable.js +++ b/ui/ui.sortable.js @@ -92,7 +92,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { var l = item.left, r = l + item.width, t = item.top, b = t + item.height; - if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { + if(this.options.tolerance == "pointer" || this.options.forcePointerForContainers || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { return (y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r); } else { @@ -206,15 +206,19 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { this.items[i].top = p.top; }; - - for (var i = this.containers.length - 1; i >= 0; i--){ - var p =this.containers[i].element.offset(); - this.containers[i].containerCache.left = p.left; - this.containers[i].containerCache.top = p.top; - this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); - this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); - }; - + + if(this.options.custom && this.options.custom.refreshContainers) { + this.options.custom.refreshContainers.call(this); + } else { + for (var i = this.containers.length - 1; i >= 0; i--){ + var p =this.containers[i].element.offset(); + this.containers[i].containerCache.left = p.left; + this.containers[i].containerCache.top = p.top; + this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); + this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); + }; + } + }, destroy: function() { this.element -- cgit v1.2.3