Author: blabno
Date: 2011-11-23 10:26:54 -0500 (Wed, 23 Nov 2011)
New Revision: 22985
Modified:
sandbox/trunk/ui/dashboard/ui/src/main/resources/META-INF/resources/jquery.ui.sortable.js
Log:
fixed formatting of jquery.ui.sortable.js
Modified:
sandbox/trunk/ui/dashboard/ui/src/main/resources/META-INF/resources/jquery.ui.sortable.js
===================================================================
---
sandbox/trunk/ui/dashboard/ui/src/main/resources/META-INF/resources/jquery.ui.sortable.js 2011-11-23
15:21:04 UTC (rev 22984)
+++
sandbox/trunk/ui/dashboard/ui/src/main/resources/META-INF/resources/jquery.ui.sortable.js 2011-11-23
15:26:54 UTC (rev 22985)
@@ -12,8 +12,7 @@
* jquery.ui.mouse.js
* jquery.ui.widget.js
*/
-(function($, undefined)
-{
+(function($, undefined) {
$.widget("ui.sortable", $.ui.mouse, {
widgetEventPrefix: "sort",
@@ -41,8 +40,7 @@
tolerance: "intersect",
zIndex: 1000
},
- _create: function()
- {
+ _create: function() {
var o = this.options;
this.containerCache = {};
@@ -52,8 +50,7 @@
this.refresh();
//Let's determine if the items are being displayed horizontally
- this.floating = this.items.length ? o.axis === 'x' ||
(/left|right/).test(this.items[0].item.css('float')) ||
(/inline|table-cell/).test(this
- .items[0].item.css('display')) : false;
+ this.floating = this.items.length ? o.axis === 'x' ||
(/left|right/).test(this.items[0].item.css('float')) ||
(/inline|table-cell/).test(this.items[0].item.css('display')) : false;
//Let's determine the parent's offset
this.offset = this.element.offset();
@@ -63,20 +60,20 @@
},
- destroy: function()
- {
- this.element.removeClass("ui-sortable
ui-sortable-disabled").removeData("sortable").unbind(".sortable");
+ destroy: function() {
+ this.element
+ .removeClass("ui-sortable ui-sortable-disabled")
+ .removeData("sortable")
+ .unbind(".sortable");
this._mouseDestroy();
- for (var i = this.items.length - 1; i >= 0; i--) {
+ for (var i = this.items.length - 1; i >= 0; i--)
this.items[i].item.removeData("sortable-item");
- }
return this;
},
- _setOption: function(key, value)
- {
+ _setOption: function(key, value) {
if (key === "disabled") {
this.options[ key ] = value;
@@ -88,47 +85,34 @@
}
},
- _mouseCapture: function(event, overrideHandle)
- {
+ _mouseCapture: function(event, overrideHandle) {
if (this.reverting) {
return false;
}
- if (this.options.disabled || this.options.type == 'static') {
- return false;
- }
+ if (this.options.disabled || this.options.type == 'static') return
false;
//We have to refresh the items data once first
this._refreshItems(event);
//Find out if the clicked node (or one of its parents) is a actual item in
this.items
- var currentItem = null, self = this, nodes =
$(event.target).parents().each(function()
- {
+ var currentItem = null, self = this, nodes =
$(event.target).parents().each(function() {
if ($.data(this, 'sortable-item') == self) {
currentItem = $(this);
return false;
}
});
- if ($.data(event.target, 'sortable-item') == self) {
- currentItem = $(event.target);
- }
+ if ($.data(event.target, 'sortable-item') == self) currentItem =
$(event.target);
- if (!currentItem) {
- return false;
- }
+ if (!currentItem) return false;
if (this.options.handle && !overrideHandle) {
var validHandle = false;
- $(this.options.handle,
currentItem).find("*").andSelf().each(function()
- {
- if (this == event.target) {
- validHandle = true;
- }
+ $(this.options.handle,
currentItem).find("*").andSelf().each(function() {
+ if (this == event.target) validHandle = true;
});
- if (!validHandle) {
- return false;
- }
+ if (!validHandle) return false;
}
this.currentItem = currentItem;
@@ -137,8 +121,7 @@
},
- _mouseStart: function(event, overrideHandle, noActivation)
- {
+ _mouseStart: function(event, overrideHandle, noActivation) {
var o = this.options, self = this;
this.currentContainer = this;
@@ -181,8 +164,7 @@
top: event.pageY - this.offset.top
},
parent: this._getParentOffset(),
- relative: this
- ._getRelativeOffset() //This is a relative to absolute position
minus the actual position calculation - only used for relative positioned helper
+ relative: this._getRelativeOffset() //This is a relative to absolute
position minus the actual position calculation - only used for relative positioned helper
});
//Generate the original position
@@ -205,43 +187,34 @@
this._createPlaceholder();
//Set a containment if given in the options
- if (o.containment) {
+ if (o.containment)
this._setContainment();
- }
if (o.cursor) { // cursor option
- if ($('body').css("cursor")) {
- this._storedCursor = $('body').css("cursor");
- }
+ if ($('body').css("cursor")) this._storedCursor =
$('body').css("cursor");
$('body').css("cursor", o.cursor);
}
if (o.opacity) { // opacity option
- if (this.helper.css("opacity")) {
- this._storedOpacity = this.helper.css("opacity");
- }
+ if (this.helper.css("opacity")) this._storedOpacity =
this.helper.css("opacity");
this.helper.css("opacity", o.opacity);
}
if (o.zIndex) { // zIndex option
- if (this.helper.css("zIndex")) {
- this._storedZIndex = this.helper.css("zIndex");
- }
+ if (this.helper.css("zIndex")) this._storedZIndex =
this.helper.css("zIndex");
this.helper.css("zIndex", o.zIndex);
}
//Prepare scrolling
- if (this.scrollParent[0] != document && this.scrollParent[0].tagName
!= 'HTML') {
+ if (this.scrollParent[0] != document && this.scrollParent[0].tagName
!= 'HTML')
this.overflowOffset = this.scrollParent.offset();
- }
//Call callbacks
this._trigger("start", event, this._uiHash());
//Recache the helper size
- if (!this._preserveHelperProportions) {
+ if (!this._preserveHelperProportions)
this._cacheHelperProportions();
- }
//Post 'activate' events to possible containers
@@ -252,13 +225,11 @@
}
//Prepare possible droppables
- if ($.ui.ddmanager) {
+ if ($.ui.ddmanager)
$.ui.ddmanager.current = this;
- }
- if ($.ui.ddmanager && !o.dropBehaviour) {
+ if ($.ui.ddmanager && !o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this, event);
- }
this.dragging = true;
@@ -268,8 +239,7 @@
},
- _mouseDrag: function(event)
- {
+ _mouseDrag: function(event) {
//Compute the helpers position
this.position = this._generatePosition(event);
@@ -284,67 +254,54 @@
var o = this.options, scrolled = false;
if (this.scrollParent[0] != document &&
this.scrollParent[0].tagName != 'HTML') {
- if ((this.overflowOffset.top + this.scrollParent[0].offsetHeight) -
event.pageY < o.scrollSensitivity) {
+ if ((this.overflowOffset.top + this.scrollParent[0].offsetHeight) -
event.pageY < o.scrollSensitivity)
this.scrollParent[0].scrollTop = scrolled =
this.scrollParent[0].scrollTop + o.scrollSpeed;
- } else if (event.pageY - this.overflowOffset.top <
o.scrollSensitivity) {
+ else if (event.pageY - this.overflowOffset.top <
o.scrollSensitivity)
this.scrollParent[0].scrollTop = scrolled =
this.scrollParent[0].scrollTop - o.scrollSpeed;
- }
- if ((this.overflowOffset.left + this.scrollParent[0].offsetWidth) -
event.pageX < o.scrollSensitivity) {
+ if ((this.overflowOffset.left + this.scrollParent[0].offsetWidth) -
event.pageX < o.scrollSensitivity)
this.scrollParent[0].scrollLeft = scrolled =
this.scrollParent[0].scrollLeft + o.scrollSpeed;
- } else if (event.pageX - this.overflowOffset.left <
o.scrollSensitivity) {
+ else if (event.pageX - this.overflowOffset.left <
o.scrollSensitivity)
this.scrollParent[0].scrollLeft = scrolled =
this.scrollParent[0].scrollLeft - o.scrollSpeed;
- }
} else {
- if (event.pageY - $(document).scrollTop() < o.scrollSensitivity)
{
+ if (event.pageY - $(document).scrollTop() < o.scrollSensitivity)
scrolled = $(document).scrollTop($(document).scrollTop() -
o.scrollSpeed);
- } else if ($(window).height() - (event.pageY -
$(document).scrollTop()) < o.scrollSensitivity) {
+ else if ($(window).height() - (event.pageY - $(document).scrollTop())
< o.scrollSensitivity)
scrolled = $(document).scrollTop($(document).scrollTop() +
o.scrollSpeed);
- }
- if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
{
+ if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
scrolled = $(document).scrollLeft($(document).scrollLeft() -
o.scrollSpeed);
- } else if ($(window).width() - (event.pageX -
$(document).scrollLeft()) < o.scrollSensitivity) {
+ else if ($(window).width() - (event.pageX - $(document).scrollLeft())
< o.scrollSensitivity)
scrolled = $(document).scrollLeft($(document).scrollLeft() +
o.scrollSpeed);
- }
}
- if (scrolled !== false && $.ui.ddmanager &&
!o.dropBehaviour) {
+ if (scrolled !== false && $.ui.ddmanager &&
!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this, event);
- }
}
//Regenerate the absolute position used for position checks
this.positionAbs = this._convertPositionTo("absolute");
//Set the helper 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';
- }
+ 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';
//Rearrange
for (var i = this.items.length - 1; i >= 0; i--) {
//Cache variables and intersection, continue if no intersection
var item = this.items[i], itemElement = item.item[0], intersection =
this._intersectsWithPointer(item);
- if (!intersection) {
- continue;
- }
+ if (!intersection) continue;
- if (itemElement != this.currentItem[0] //cannot intersect with itself
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0]
- != itemElement //no useless actions that have been done before
&& !$.ui.contains(this.placeholder[0],
- {
- itemElement
- }
- ) //no action if the item moved is the parent of the item checked &&
(this.options.type == 'semi-dynamic' ? !$.ui
- .contains(this.element[0], itemElement) : true)
- //&& itemElement.parentNode == this.placeholder[0].parentNode //
only rearrange items within the same container) {
+ if (itemElement != this.currentItem[0] //cannot intersect with itself
+ && this.placeholder[intersection == 1 ? "next"
: "prev"]()[0] != itemElement //no useless actions that have been done before
+ && !$.ui.contains(this.placeholder[0], itemElement) //no
action if the item moved is the parent of the item checked
+ && (this.options.type == 'semi-dynamic' ?
!$.ui.contains(this.element[0], itemElement) : true)
+ //&& itemElement.parentNode == this.placeholder[0].parentNode //
only rearrange items within the same container
+ ) {
this.direction = intersection == 1 ? "down" :
"up";
@@ -363,9 +320,7 @@
this._contactContainers(event);
//Interconnect with droppables
- if ($.ui.ddmanager) {
- $.ui.ddmanager.drag(this, event);
- }
+ if ($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
//Call callbacks
this._trigger('sort', event, this._uiHash());
@@ -375,17 +330,13 @@
},
- _mouseStop: function(event, noPropagation)
- {
+ _mouseStop: function(event, noPropagation) {
- if (!event) {
- return;
- }
+ if (!event) return;
//If we are using droppables, inform the manager about the drop
- if ($.ui.ddmanager && !this.options.dropBehaviour) {
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
$.ui.ddmanager.drop(this, event);
- }
if (this.options.revert) {
var self = this;
@@ -394,11 +345,9 @@
self.reverting = true;
$(this.helper).animate({
- left: cur.left - this.offset.parent.left - self.margins.left +
(this.offsetParent[0] == document.body ? 0 : this.offsetParent[0]
- .scrollLeft),
+ left: cur.left - this.offset.parent.left - self.margins.left +
(this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
top: cur.top - this.offset.parent.top - self.margins.top +
(this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
- }, parseInt(this.options.revert, 10) || 500, function()
- {
+ }, parseInt(this.options.revert, 10) || 500, function() {
self._clear(event);
});
} else {
@@ -409,8 +358,7 @@
},
- cancel: function()
- {
+ cancel: function() {
var self = this;
@@ -418,11 +366,10 @@
this._mouseUp({ target: null });
- if (this.options.helper == "original") {
+ if (this.options.helper == "original")
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
- } else {
+ else
this.currentItem.show();
- }
//Post deactivating events to containers
for (var i = this.containers.length - 1; i >= 0; i--) {
@@ -437,12 +384,8 @@
if (this.placeholder) {
//$(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();
- }
+ 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,
@@ -462,19 +405,15 @@
},
- serialize: function(o)
- {
+ serialize: function(o) {
var items = this._getItemsAsjQuery(o && o.connected);
var str = [];
o = o || {};
- $(items).each(function()
- {
+ $(items).each(function() {
var res = ($(o.item || this).attr(o.attribute || 'id') ||
'').match(o.expression || (/(.+)[-=_](.+)/));
- if (res) {
- str.push((o.key || res[1] + '[]') + '=' + (o.key
&& o.expression ? res[1] : res[2]));
- }
+ if (res) str.push((o.key || res[1] + '[]') + '=' + (o.key
&& o.expression ? res[1] : res[2]));
});
if (!str.length && o.key) {
@@ -485,15 +424,13 @@
},
- toArray: function(o)
- {
+ toArray: function(o) {
var items = this._getItemsAsjQuery(o && o.connected);
var ret = [];
o = o || {};
- items.each(function()
- {
+ items.each(function() {
ret.push($(o.item || this).attr(o.attribute || 'id') ||
'');
});
return ret;
@@ -501,8 +438,7 @@
},
/* Be careful with the following core functions */
- _intersectsWith: function(item)
- {
+ _intersectsWith: function(item) {
var x1 = this.positionAbs.left,
x2 = x1 + this.helperProportions.width,
@@ -519,19 +455,22 @@
var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b
&& (x1 + dxClick) > l && (x1 + dxClick) < r;
- if (this.options.tolerance == "pointer" ||
this.options.forcePointerForContainers || (this.options.tolerance != "pointer"
&& this
- .helperProportions[this.floating ? 'width' :
'height'] > item[this.floating ? 'width' : 'height'])) {
+ if (this.options.tolerance == "pointer"
+ || this.options.forcePointerForContainers
+ || (this.options.tolerance != "pointer" &&
this.helperProportions[this.floating ? 'width' : 'height'] >
item[this.floating ? 'width' : 'height'])
+ ) {
return isOverElement;
} else {
- return (l < x1 + (this.helperProportions.width / 2) // Right Half
&& x2 - (this.helperProportions.width / 2) < r // Left Half && t <
y1 + (this
- .helperProportions.height / 2) // Bottom Half && y2 -
(this.helperProportions.height / 2) < b ); // Top Half
+ return (l < x1 + (this.helperProportions.width / 2) // Right Half
+ && x2 - (this.helperProportions.width / 2) < r // Left
Half
+ && t < y1 + (this.helperProportions.height / 2) //
Bottom Half
+ && y2 - (this.helperProportions.height / 2) < b ); //
Top Half
}
},
- _intersectsWithPointer: function(item)
- {
+ _intersectsWithPointer: function(item) {
var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top +
this.offset.click.top, item.top, item.height),
isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left +
this.offset.click.left, item.left, item.width),
@@ -539,17 +478,16 @@
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
- if (!isOverElement) {
+ if (!isOverElement)
return false;
- }
- return this.floating ? ( ((horizontalDirection && horizontalDirection
== "right") || verticalDirection == "down") ? 2 : 1 ) : (
verticalDirection
- && (verticalDirection == "down" ? 2 : 1) );
+ return this.floating ?
+ ( ((horizontalDirection && horizontalDirection ==
"right") || verticalDirection == "down") ? 2 : 1 )
+ : ( verticalDirection && (verticalDirection ==
"down" ? 2 : 1) );
},
- _intersectsWithSides: function(item)
- {
+ _intersectsWithSides: function(item) {
var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top +
this.offset.click.top, item.top + (item.height / 2), item.height),
isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left +
this.offset.click.left, item.left + (item.width / 2), item.width),
@@ -564,33 +502,30 @@
},
- _getDragVerticalDirection: function()
- {
+ _getDragVerticalDirection: function() {
var delta = this.positionAbs.top - this.lastPositionAbs.top;
return delta != 0 && (delta > 0 ? "down" :
"up");
},
- _getDragHorizontalDirection: function()
- {
+ _getDragHorizontalDirection: function() {
var delta = this.positionAbs.left - this.lastPositionAbs.left;
return delta != 0 && (delta > 0 ? "right" :
"left");
},
- refresh: function(event)
- {
+ refresh: function(event) {
this._refreshItems(event);
this.refreshPositions();
return this;
},
- _connectWith: function()
- {
+ _connectWith: function() {
var options = this.options;
- return options.connectWith.constructor == String ? [options.connectWith] :
options.connectWith;
+ return options.connectWith.constructor == String
+ ? [options.connectWith]
+ : options.connectWith;
},
- _getItemsAsjQuery: function(connected)
- {
+ _getItemsAsjQuery: function(connected) {
var self = this;
var items = [];
@@ -603,8 +538,7 @@
for (var j = cur.length - 1; j >= 0; j--) {
var inst = $.data(cur[j], 'sortable');
if (inst && inst != this &&
!inst.options.disabled) {
- queries.push([$.isFunction(inst.options.items) ?
inst.options.items.call(inst.element) : $(inst.options.items, inst.element)
-
.not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]);
+ queries.push([$.isFunction(inst.options.items) ?
inst.options.items.call(inst.element) : $(inst.options.items,
inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'),
inst]);
}
}
;
@@ -612,13 +546,10 @@
;
}
- queries.push([
- $.isFunction(this.options.items) ? this.options.items.call(this.element,
null, { options: this.options, item: this.currentItem }) : $(this
- .options.items,
this.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'),
this]);
+ queries.push([$.isFunction(this.options.items) ?
this.options.items.call(this.element, null, { options: this.options, item:
this.currentItem }) : $(this.options.items,
this.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'),
this]);
for (var i = queries.length - 1; i >= 0; i--) {
- queries[i][0].each(function()
- {
+ queries[i][0].each(function() {
items.push(this);
});
}
@@ -628,17 +559,15 @@
},
- _removeCurrentsFromItems: function()
- {
+ _removeCurrentsFromItems: function() {
var list = this.currentItem.find(":data(sortable-item)");
for (var i = 0; i < this.items.length; i++) {
for (var j = 0; j < list.length; j++) {
- if (list[j] == this.items[i].item[0]) {
+ if (list[j] == this.items[i].item[0])
this.items.splice(i, 1);
- }
}
;
@@ -647,16 +576,14 @@
},
- _refreshItems: function(event)
- {
+ _refreshItems: function(event) {
this.items = [];
this.containers = [this];
var items = this.items;
var self = this;
var queries = [
- [$.isFunction(this.options.items) ?
this.options.items.call(this.element[0], event, { item: this.currentItem }) :
$(this.options.items,
- this.element), this]
+ [$.isFunction(this.options.items) ?
this.options.items.call(this.element[0], event, { item: this.currentItem }) :
$(this.options.items, this.element), this]
];
var connectWith = this._connectWith();
@@ -666,9 +593,7 @@
for (var j = cur.length - 1; j >= 0; j--) {
var inst = $.data(cur[j], 'sortable');
if (inst && inst != this &&
!inst.options.disabled) {
- queries.push([
- $.isFunction(inst.options.items) ?
inst.options.items.call(inst.element[0], event, { item: this.currentItem }) :
$(inst.options
- .items, inst.element), inst]);
+ queries.push([$.isFunction(inst.options.items) ?
inst.options.items.call(inst.element[0], event, { item: this.currentItem }) :
$(inst.options.items, inst.element), inst]);
this.containers.push(inst);
}
}
@@ -699,8 +624,7 @@
},
- refreshPositions: function(fast)
- {
+ refreshPositions: function(fast) {
//This has to be redone because due to the item being moved out/into the
offsetParent, the offsetParent's position will change
if (this.offsetParent && this.helper) {
@@ -711,9 +635,8 @@
var item = this.items[i];
//We ignore calculating positions of all connected containers when
we're not over them
- if (item.instance != this.currentContainer &&
this.currentContainer && item.item[0] != this.currentItem[0]) {
+ if (item.instance != this.currentContainer &&
this.currentContainer && item.item[0] != this.currentItem[0])
continue;
- }
var t = this.options.toleranceElement ? $(this.options.toleranceElement,
item.item) : item.item;
@@ -744,44 +667,37 @@
return this;
},
- _createPlaceholder: function(that)
- {
+ _createPlaceholder: function(that) {
var self = that || this, o = self.options;
if (!o.placeholder || o.placeholder.constructor == String) {
var className = o.placeholder;
o.placeholder = {
- element: function()
- {
+ element: function() {
- var el =
$(document.createElement(self.currentItem[0].nodeName)).addClass(className ||
self.currentItem[0].className
- + "
ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];
+ var el = $(document.createElement(self.currentItem[0].nodeName))
+ .addClass(className || self.currentItem[0].className +
" ui-sortable-placeholder")
+ .removeClass("ui-sortable-helper")[0];
- if (!className) {
+ if (!className)
el.style.visibility = "hidden";
- }
return el;
},
- update: function(container, p)
- {
+ update: function(container, p) {
// 1. If a className is set as 'placeholder option, we
don't force sizes - the class is responsible for that
// 2. The option 'forcePlaceholderSize can be enabled to
force it even if a class name is specified
- if (className && !o.forcePlaceholderSize) {
- return;
- }
+ if (className && !o.forcePlaceholderSize) return;
//If the element doesn't have a actual height by itself
(without styles coming from a stylesheet), it receives the inline height from the dragged
item
if (!p.height()) {
- p.height(self.currentItem.innerHeight() -
parseInt(self.currentItem.css('paddingTop') || 0, 10) - parseInt(self.currentItem
- .css('paddingBottom') || 0, 10));
+ p.height(self.currentItem.innerHeight() -
parseInt(self.currentItem.css('paddingTop') || 0, 10) -
parseInt(self.currentItem.css('paddingBottom') || 0, 10));
}
;
if (!p.width()) {
- p.width(self.currentItem.innerWidth() -
parseInt(self.currentItem.css('paddingLeft') || 0, 10) -
parseInt(self.currentItem
- .css('paddingRight') || 0, 10));
+ p.width(self.currentItem.innerWidth() -
parseInt(self.currentItem.css('paddingLeft') || 0, 10) -
parseInt(self.currentItem.css('paddingRight') || 0, 10));
}
;
}
@@ -799,8 +715,7 @@
},
- _contactContainers: function(event)
- {
+ _contactContainers: function(event) {
// get innermost container that intersects with item
var innermostContainer = null, innermostIndex = null;
@@ -809,16 +724,14 @@
for (var i = this.containers.length - 1; i >= 0; i--) {
// never consider a container that's located within the item itself
- if ($.ui.contains(this.currentItem[0], this.containers[i].element[0])) {
+ if ($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
continue;
- }
if (this._intersectsWith(this.containers[i].containerCache)) {
// if we've already found a container and it's more
"inner" than this, then continue
- if (innermostContainer &&
$.ui.contains(this.containers[i].element[0], innermostContainer.element[0])) {
+ if (innermostContainer &&
$.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
continue;
- }
innermostContainer = this.containers[i];
innermostIndex = i;
@@ -834,9 +747,7 @@
}
// if no intersecting containers found, return
- if (!innermostContainer) {
- return;
- }
+ if (!innermostContainer) return;
// move the item into the container if it's not there already
if (this.containers.length === 1) {
@@ -849,9 +760,7 @@
var itemWithLeastDistance = null;
var base = this.positionAbs[this.containers[innermostIndex].floating ?
'left' : 'top'];
for (var j = this.items.length - 1; j >= 0; j--) {
- if (!$.ui.contains(this.containers[innermostIndex].element[0],
this.items[j].item[0])) {
- continue;
- }
+ if (!$.ui.contains(this.containers[innermostIndex].element[0],
this.items[j].item[0])) continue;
var cur = this.items[j][this.containers[innermostIndex].floating ?
'left' : 'top'];
if (Math.abs(cur - base) < dist) {
dist = Math.abs(cur - base);
@@ -860,13 +769,10 @@
}
if (!itemWithLeastDistance && !this.options.dropOnEmpty) //Check
if dropOnEmpty is enabled
- {
return;
- }
this.currentContainer = this.containers[innermostIndex];
- itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance,
null, true) : this._rearrange(event, null,
- this.containers[innermostIndex].element, true);
+ itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance,
null, true) : this._rearrange(event, null, this.containers[innermostIndex].element,
true);
this._trigger("change", event, this._uiHash());
this.containers[innermostIndex]._trigger("change", event,
this._uiHash(this));
@@ -880,36 +786,25 @@
},
- _createHelper: function(event)
- {
+ _createHelper: function(event) {
var o = this.options;
- var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0],
[event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem
- .clone() : this.currentItem);
+ var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0],
[event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() :
this.currentItem);
if (!helper.parents('body').length) //Add the helper to the DOM if
that didn't happen already
- {
$(o.appendTo != 'parent' ? o.appendTo :
this.currentItem[0].parentNode)[0].appendChild(helper[0]);
- }
- if (helper[0] == this.currentItem[0]) {
- this._storedCSS = { width: this.currentItem[0].style.width, height:
this.currentItem[0].style.height, position: this.currentItem
- .css("position"), top:
this.currentItem.css("top"), left: this.currentItem.css("left") };
- }
+ if (helper[0] == this.currentItem[0])
+ this._storedCSS = { width: this.currentItem[0].style.width, height:
this.currentItem[0].style.height, position: this.currentItem.css("position"),
top: this.currentItem.css("top"), left: this.currentItem.css("left")
};
- if (helper[0].style.width == '' || o.forceHelperSize) {
- helper.width(this.currentItem.width());
- }
- if (helper[0].style.height == '' || o.forceHelperSize) {
- helper.height(this.currentItem.height());
- }
+ if (helper[0].style.width == '' || o.forceHelperSize)
helper.width(this.currentItem.width());
+ if (helper[0].style.height == '' || o.forceHelperSize)
helper.height(this.currentItem.height());
return helper;
},
- _adjustOffsetFromHelper: function(obj)
- {
+ _adjustOffsetFromHelper: function(obj) {
if (typeof obj == 'string') {
obj = obj.split(' ');
}
@@ -930,8 +825,7 @@
}
},
- _getParentOffset: function()
- {
+ _getParentOffset: function() {
//Get the offsetParent and cache its position
@@ -947,8 +841,8 @@
po.top += this.scrollParent.scrollTop();
}
- if ((this.offsetParent[0] == document.body) //This needs to be actually done
for all browsers, since pageX/pageY includes this information || (this
- .offsetParent[0].tagName &&
this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie))
//Ugly IE fix
+ if ((this.offsetParent[0] == document.body) //This needs to be actually done
for all browsers, since pageX/pageY includes this information
+ || (this.offsetParent[0].tagName &&
this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie))
//Ugly IE fix
po = { top: 0, left: 0 };
return {
@@ -958,8 +852,7 @@
},
- _getRelativeOffset: function()
- {
+ _getRelativeOffset: function() {
if (this.cssPosition == "relative") {
var p = this.currentItem.position();
@@ -973,38 +866,30 @@
},
- _cacheMargins: function()
- {
+ _cacheMargins: function() {
this.margins = {
left: (parseInt(this.currentItem.css("marginLeft"), 10) || 0),
top: (parseInt(this.currentItem.css("marginTop"), 10) || 0)
};
},
- _cacheHelperProportions: function()
- {
+ _cacheHelperProportions: function() {
this.helperProportions = {
width: this.helper.outerWidth(),
height: this.helper.outerHeight()
};
},
- _setContainment: function()
- {
+ _setContainment: function() {
var o = this.options;
- if (o.containment == 'parent') {
- o.containment = this.helper[0].parentNode;
- }
- if (o.containment == 'document' || o.containment == 'window')
{
- this.containment = [
- 0 - this.offset.relative.left - this.offset.parent.left,
- 0 - this.offset.relative.top - this.offset.parent.top,
- $(o.containment == 'document' ? document : window).width() -
this.helperProportions.width - this.margins.left,
- ($(o.containment == 'document' ? document : window).height()
|| document.body.parentNode.scrollHeight) - this.helperProportions.height
- - this.margins.top
- ];
- }
+ if (o.containment == 'parent') o.containment =
this.helper[0].parentNode;
+ if (o.containment == 'document' || o.containment == 'window')
this.containment = [
+ 0 - this.offset.relative.left - this.offset.parent.left,
+ 0 - this.offset.relative.top - this.offset.parent.top,
+ $(o.containment == 'document' ? document : window).width() -
this.helperProportions.width - this.margins.left,
+ ($(o.containment == 'document' ? document : window).height() ||
document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
+ ];
if (!(/^(document|window|parent)$/).test(o.containment)) {
var ce = $(o.containment)[0];
@@ -1014,51 +899,39 @@
this.containment = [
co.left + (parseInt($(ce).css("borderLeftWidth"), 10) || 0)
+ (parseInt($(ce).css("paddingLeft"), 10) || 0) - this.margins.left,
co.top + (parseInt($(ce).css("borderTopWidth"), 10) || 0) +
(parseInt($(ce).css("paddingTop"), 10) || 0) - this.margins.top,
- co.left + (over ? Math.max(ce.scrollWidth, ce.offsetWidth) :
ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"), 10) || 0)
- - (parseInt($(ce).css("paddingRight"), 10) || 0) -
this.helperProportions.width - this.margins.left,
- co.top + (over ? Math.max(ce.scrollHeight, ce.offsetHeight) :
ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"), 10) || 0)
- - (parseInt($(ce).css("paddingBottom"), 10) || 0) -
this.helperProportions.height - this.margins.top
+ co.left + (over ? Math.max(ce.scrollWidth, ce.offsetWidth) :
ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"), 10) || 0) -
(parseInt($(ce).css("paddingRight"), 10) || 0) - this.helperProportions.width -
this.margins.left,
+ co.top + (over ? Math.max(ce.scrollHeight, ce.offsetHeight) :
ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"), 10) || 0) -
(parseInt($(ce).css("paddingBottom"), 10) || 0) - this.helperProportions.height
- this.margins.top
];
}
},
- _convertPositionTo: function(d, pos)
- {
+ _convertPositionTo: function(d, pos) {
- if (!pos) {
- pos = this.position;
- }
+ if (!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
- var o = this.options, scroll = this.cssPosition == 'absolute'
&& !(this.scrollParent[0] != document &&
$.ui.contains(this.scrollParent[0],
- this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute'
&& !(this.scrollParent[0] != document &&
$.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent :
this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
return {
top: (
- pos.top
// The absolute mouse position + this.offset.relative.top
- * mod // Only for
relative positioned nodes: Relative offset from element to offset parent
- + this.offset.parent.top
- * mod // The
offsetParent's offset without borders (offset + border) - ($.browser
- .safari && this.cssPosition == 'fixed' ?
0 : ( this.cssPosition == 'fixed' ? -this.scrollParent
- .scrollTop() : ( scrollIsRootNode ? 0 :
scroll.scrollTop() ) ) * mod)
+ pos.top
// The absolute mouse position
+ + this.offset.relative.top * mod
// Only for relative positioned nodes: Relative offset from element to
offset parent
+ + this.offset.parent.top * mod
// The offsetParent's offset without borders (offset + border)
+ - ($.browser.safari && this.cssPosition ==
'fixed' ? 0 : ( this.cssPosition == 'fixed' ?
-this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
),
left: (
- pos.left
// The absolute mouse position + this.offset.relative.left
- * mod // Only for
relative positioned nodes: Relative offset from element to offset parent
- + this.offset.parent.left
- * mod // The
offsetParent's offset without borders (offset + border) - ($.browser
- .safari && this.cssPosition == 'fixed' ?
0 : ( this.cssPosition == 'fixed' ? -this.scrollParent
- .scrollLeft() : scrollIsRootNode ? 0 :
scroll.scrollLeft() ) * mod)
+ pos.left
// The absolute mouse position
+ + this.offset.relative.left * mod
// Only for relative positioned nodes: Relative offset from element to
offset parent
+ + this.offset.parent.left * mod
// The offsetParent's offset without borders (offset + border)
+ - ($.browser.safari && this.cssPosition ==
'fixed' ? 0 : ( this.cssPosition == 'fixed' ?
-this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
)
};
},
- _generatePosition: function(event)
- {
+ _generatePosition: function(event) {
- var o = this.options, scroll = this.cssPosition == 'absolute'
&& !(this.scrollParent[0] != document &&
$.ui.contains(this.scrollParent[0],
- this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute'
&& !(this.scrollParent[0] != document &&
$.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent :
this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
// This is another very weird special case that only happens for relative
elements:
// 1. If the css position is relative
@@ -1079,60 +952,44 @@
if (this.originalPosition) { //If we are not dragging yet, we won't check
for options
if (this.containment) {
- if (event.pageX - this.offset.click.left < this.containment[0]) {
- pageX = this.containment[0] + this.offset.click.left;
- }
- if (event.pageY - this.offset.click.top < this.containment[1]) {
- pageY = this.containment[1] + this.offset.click.top;
- }
- if (event.pageX - this.offset.click.left > this.containment[2]) {
- pageX = this.containment[2] + this.offset.click.left;
- }
- if (event.pageY - this.offset.click.top > this.containment[3]) {
- pageY = this.containment[3] + this.offset.click.top;
- }
+ if (event.pageX - this.offset.click.left < this.containment[0])
pageX = this.containment[0] + this.offset.click.left;
+ if (event.pageY - this.offset.click.top < this.containment[1])
pageY = this.containment[1] + this.offset.click.top;
+ if (event.pageX - this.offset.click.left > this.containment[2])
pageX = this.containment[2] + this.offset.click.left;
+ if (event.pageY - this.offset.click.top > this.containment[3])
pageY = this.containment[3] + this.offset.click.top;
}
if (o.grid) {
var top = this.originalPageY + Math.round((pageY -
this.originalPageY) / o.grid[1]) * o.grid[1];
- pageY = this.containment ? (!(top - this.offset.click.top <
this.containment[1] || top - this.offset.click.top > this
- .containment[3]) ? top : (!(top - this.offset.click.top <
this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+ pageY = this.containment ? (!(top - this.offset.click.top <
this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top :
(!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top +
o.grid[1])) : top;
var left = this.originalPageX + Math.round((pageX -
this.originalPageX) / o.grid[0]) * o.grid[0];
- pageX = this.containment ? (!(left - this.offset.click.left <
this.containment[0] || left - this.offset.click.left > this
- .containment[2]) ? left : (!(left - this.offset.click.left
< this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
+ pageX = this.containment ? (!(left - this.offset.click.left <
this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left :
(!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left +
o.grid[0])) : left;
}
}
return {
top: (
- pageY
// The absolute mouse position - this.offset.click
- .top
// Click offset (relative to the element) - this.offset.relative
- .top //
Only for relative positioned nodes: Relative offset from element to offset parent
- - this.offset.parent
- .top //
The offsetParent's offset without borders (offset + border) + ($.browser
- .safari && this.cssPosition == 'fixed' ?
0 : ( this.cssPosition == 'fixed' ? -this.scrollParent
- .scrollTop() : ( scrollIsRootNode ? 0 :
scroll.scrollTop() ) ))
+ pageY
// The absolute mouse position
+ - this.offset.click.top
// Click offset (relative to the element)
+ - this.offset.relative.top
// Only for relative positioned nodes: Relative offset from element to
offset parent
+ - this.offset.parent.top
// The offsetParent's offset without borders (offset + border)
+ + ($.browser.safari && this.cssPosition ==
'fixed' ? 0 : ( this.cssPosition == 'fixed' ?
-this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
),
left: (
- pageX
// The absolute mouse position - this.offset.click
- .left //
Click offset (relative to the element) - this.offset.relative
- .left //
Only for relative positioned nodes: Relative offset from element to offset parent
- - this.offset.parent
- .left //
The offsetParent's offset without borders (offset + border) + ($.browser
- .safari && this.cssPosition == 'fixed' ?
0 : ( this.cssPosition == 'fixed' ? -this.scrollParent
- .scrollLeft() : scrollIsRootNode ? 0 :
scroll.scrollLeft() ))
+ pageX
// The absolute mouse position
+ - this.offset.click.left
// Click offset (relative to the element)
+ - this.offset.relative.left
// Only for relative positioned nodes: Relative offset from element to
offset parent
+ - this.offset.parent.left
// The offsetParent's offset without borders (offset + border)
+ + ($.browser.safari && this.cssPosition ==
'fixed' ? 0 : ( this.cssPosition == 'fixed' ?
-this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
)
};
},
- _rearrange: function(event, i, a, hardRefresh)
- {
+ _rearrange: function(event, i, a, hardRefresh) {
- a ? a[0].appendChild(this.placeholder[0]) :
i.item[0].parentNode.insertBefore(this.placeholder[0],
- (this.direction == 'down' ? i.item[0] :
i.item[0].nextSibling));
+ a ? a[0].appendChild(this.placeholder[0]) :
i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ?
i.item[0] : i.item[0].nextSibling));
//Various things done here to improve the performance:
// 1. we create a setTimeout, that calls refreshPositions
@@ -1142,17 +999,13 @@
this.counter = this.counter ? ++this.counter : 1;
var self = this, counter = this.counter;
- window.setTimeout(function()
- {
- if (counter == self.counter) {
- self.refreshPositions(!hardRefresh);
- } //Precompute after each DOM insertion, NOT on mousemove
+ window.setTimeout(function() {
+ if (counter == self.counter) self.refreshPositions(!hardRefresh);
//Precompute after each DOM insertion, NOT on mousemove
}, 0);
},
- _clear: function(event, noPropagation)
- {
+ _clear: function(event, noPropagation) {
this.reverting = false;
// We delay all events that have to be triggered to after the point where the
placeholder has been removed and
@@ -1161,55 +1014,37 @@
// We first have to update the dom position of the actual currentItem
// Note: don't do it if the current item is already removed (by a user),
or it gets reappended (see #4088)
- if (!this._noFinalSort && this.currentItem.parent().length) {
- this.placeholder.before(this.currentItem);
- }
+ if (!this._noFinalSort && this.currentItem.parent().length)
this.placeholder.before(this.currentItem);
this._noFinalSort = null;
if (this.helper[0] == this.currentItem[0]) {
for (var i in this._storedCSS) {
- if (this._storedCSS[i] == 'auto' || this._storedCSS[i] ==
'static') {
- this._storedCSS[i] = '';
- }
+ if (this._storedCSS[i] == 'auto' || this._storedCSS[i] ==
'static') this._storedCSS[i] = '';
}
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
} else {
this.currentItem.show();
}
- if (this.fromOutside && !noPropagation) {
- delayedTriggers.push(function(event)
- {
- this._trigger("receive", event,
this._uiHash(this.fromOutside));
- });
- }
- if ((this.fromOutside || this.domPosition.prev !=
this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent
!= this
- .currentItem.parent()[0]) && !noPropagation) {
- delayedTriggers.push(function(event)
- {
- this._trigger("update", event, this._uiHash());
- });
- } //Trigger update callback if the DOM position has changed
+ if (this.fromOutside && !noPropagation)
delayedTriggers.push(function(event) {
+ this._trigger("receive", event,
this._uiHash(this.fromOutside));
+ });
+ if ((this.fromOutside || this.domPosition.prev !=
this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent
!= this.currentItem.parent()[0]) && !noPropagation)
delayedTriggers.push(function(event) {
+ this._trigger("update", event, this._uiHash());
+ }); //Trigger update callback if the DOM position has changed
if (!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved
out of the current element
- if (!noPropagation) {
- delayedTriggers.push(function(event)
- {
- this._trigger("remove", event, this._uiHash());
- });
- }
+ if (!noPropagation) delayedTriggers.push(function(event) {
+ this._trigger("remove", event, this._uiHash());
+ });
for (var i = this.containers.length - 1; i >= 0; i--) {
if ($.ui.contains(this.containers[i].element[0], this.currentItem[0])
&& !noPropagation) {
- delayedTriggers.push((function(c)
- {
- return function(event)
- {
+ delayedTriggers.push((function(c) {
+ return function(event) {
c._trigger("receive", event,
this._uiHash(this));
};
}).call(this, this.containers[i]));
- delayedTriggers.push((function(c)
- {
- return function(event)
- {
+ delayedTriggers.push((function(c) {
+ return function(event) {
c._trigger("update", event,
this._uiHash(this));
};
}).call(this, this.containers[i]));
@@ -1221,20 +1056,14 @@
//Post events to containers
for (var i = this.containers.length - 1; i >= 0; i--) {
- if (!noPropagation) {
- delayedTriggers.push((function(c)
- {
- return function(event)
- {
- c._trigger("deactivate", event,
this._uiHash(this));
- };
- }).call(this, this.containers[i]));
- }
+ if (!noPropagation) delayedTriggers.push((function(c) {
+ return function(event) {
+ c._trigger("deactivate", event, this._uiHash(this));
+ };
+ }).call(this, this.containers[i]));
if (this.containers[i].containerCache.over) {
- delayedTriggers.push((function(c)
- {
- return function(event)
- {
+ delayedTriggers.push((function(c) {
+ return function(event) {
c._trigger("out", event, this._uiHash(this));
};
}).call(this, this.containers[i]));
@@ -1243,15 +1072,9 @@
}
//Do what was originally in plugins
- if (this._storedCursor) {
- $('body').css("cursor", this._storedCursor);
- } //Reset cursor
- if (this._storedOpacity) {
- this.helper.css("opacity", this._storedOpacity);
- } //Reset opacity
- if (this._storedZIndex) {
- this.helper.css("zIndex", this._storedZIndex == 'auto'
? '' : this._storedZIndex);
- } //Reset z-index
+ if (this._storedCursor) $('body').css("cursor",
this._storedCursor); //Reset cursor
+ if (this._storedOpacity) this.helper.css("opacity",
this._storedOpacity); //Reset opacity
+ if (this._storedZIndex) this.helper.css("zIndex",
this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
this.dragging = false;
if (this.cancelHelperRemoval) {
@@ -1266,16 +1089,12 @@
return false;
}
- if (!noPropagation) {
- this._trigger("beforeStop", event, this._uiHash());
- }
+ if (!noPropagation) this._trigger("beforeStop", event,
this._uiHash());
//$(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.helper[0] != this.currentItem[0]) {
- this.helper.remove();
- }
+ if (this.helper[0] != this.currentItem[0]) this.helper.remove();
this.helper = null;
if (!noPropagation) {
@@ -1291,15 +1110,13 @@
},
- _trigger: function()
- {
+ _trigger: function() {
if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
this.cancel();
}
},
- _uiHash: function(inst)
- {
+ _uiHash: function(inst) {
var self = inst || this;
return {
helper: self.helper,