summaryrefslogtreecommitdiff
path: root/resources/jquery.ui/jquery.ui.sortable.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/jquery.ui/jquery.ui.sortable.js')
-rw-r--r--resources/jquery.ui/jquery.ui.sortable.js80
1 files changed, 44 insertions, 36 deletions
diff --git a/resources/jquery.ui/jquery.ui.sortable.js b/resources/jquery.ui/jquery.ui.sortable.js
index 26ba85f0..1d87f653 100644
--- a/resources/jquery.ui/jquery.ui.sortable.js
+++ b/resources/jquery.ui/jquery.ui.sortable.js
@@ -1,7 +1,7 @@
-/*
- * jQuery UI Sortable 1.8.17
+/*!
+ * jQuery UI Sortable 1.8.23
*
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
@@ -16,6 +16,7 @@
$.widget("ui.sortable", $.ui.mouse, {
widgetEventPrefix: "sort",
+ ready: false,
options: {
appendTo: "parent",
axis: false,
@@ -57,10 +58,14 @@ $.widget("ui.sortable", $.ui.mouse, {
//Initialize mouse events for interaction
this._mouseInit();
+
+ //We're ready to go
+ this.ready = true
},
destroy: function() {
+ $.Widget.prototype.destroy.call( this );
this.element
.removeClass("ui-sortable ui-sortable-disabled");
this._mouseDestroy();
@@ -150,11 +155,6 @@ $.widget("ui.sortable", $.ui.mouse, {
left: this.offset.left - this.margins.left
};
- // Only after we got the offset, we can change the helper's position to absolute
- // TODO: Still need to figure out a way to make relative sorting possible
- this.helper.css("position", "absolute");
- this.cssPosition = this.helper.css("position");
-
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
@@ -164,6 +164,11 @@ $.widget("ui.sortable", $.ui.mouse, {
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
});
+ // Only after we got the offset, we can change the helper's position to absolute
+ // TODO: Still need to figure out a way to make relative sorting possible
+ this.helper.css("position", "absolute");
+ this.cssPosition = this.helper.css("position");
+
//Generate the original position
this.originalPosition = this._generatePosition(event);
this.originalPageX = event.pageX;
@@ -463,8 +468,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_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),
+ var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
+ isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
isOverElement = isOverElementHeight && isOverElementWidth,
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
@@ -571,7 +576,7 @@ $.widget("ui.sortable", $.ui.mouse, {
var queries = [[$.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();
- if(connectWith) {
+ if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
for (var i = connectWith.length - 1; i >= 0; i--){
var cur = $(connectWith[i]);
for (var j = cur.length - 1; j >= 0; j--){
@@ -725,30 +730,31 @@ $.widget("ui.sortable", $.ui.mouse, {
if(this.containers.length === 1) {
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
- } else if(this.currentContainer != this.containers[innermostIndex]) {
-
- //When entering a new container, we will find the item with the least distance and append our item near it
- var dist = 10000; 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;
- var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
- if(Math.abs(cur - base) < dist) {
- dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
- }
- }
-
- 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);
- this._trigger("change", event, this._uiHash());
- this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
-
- //Update the placeholder
- this.options.placeholder.update(this.currentContainer, this.placeholder);
-
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
+ } else if(this.currentContainer != this.containers[innermostIndex]) {
+
+ //When entering a new container, we will find the item with the least distance and append our item near it
+ var dist = 10000; 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;
+ var cur = this.containers[innermostIndex].floating ? this.items[j].item.offset().left : this.items[j].item.offset().top;
+ if(Math.abs(cur - base) < dist) {
+ dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
+ this.direction = (cur - base > 0) ? 'down' : 'up';
+ }
+ }
+
+ 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);
+ this._trigger("change", event, this._uiHash());
+ this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
+
+ //Update the placeholder
+ this.options.placeholder.update(this.currentContainer, this.placeholder);
+
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
}
@@ -1028,6 +1034,8 @@ $.widget("ui.sortable", $.ui.mouse, {
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
this._trigger("stop", event, this._uiHash());
}
+
+ this.fromOutside = false;
return false;
}
@@ -1070,7 +1078,7 @@ $.widget("ui.sortable", $.ui.mouse, {
});
$.extend($.ui.sortable, {
- version: "1.8.17"
+ version: "1.8.23"
});
})(jQuery);