Skip to content

Commit

Permalink
sortable: added forcePointerForContainers option (to have another int…
Browse files Browse the repository at this point in the history
…ersection 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.
  • Loading branch information
Paul Bakaus committed Jul 9, 2008
1 parent a8c39c2 commit cf48fc7
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions ui/ui.sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cf48fc7

Please sign in to comment.