mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
sortable: connecting draggables to a sortable and dropping them on the sortable now also triggers a "receive" event, where the sender will be the original draggable. Moving out of the sortable while dragging a connected draggable will not trigger the stop/update events anymore.
This commit is contained in:
parent
aba9f32531
commit
2d6b7469cb
@ -456,6 +456,10 @@
|
|||||||
this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
|
this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
|
||||||
if(this.shouldRevert) this.instance.options.revert = true; //revert here
|
if(this.shouldRevert) this.instance.options.revert = true; //revert here
|
||||||
this.instance.mouseStop(e);
|
this.instance.mouseStop(e);
|
||||||
|
|
||||||
|
//Also propagate receive event, since the sortable is actually receiving a element
|
||||||
|
this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]);
|
||||||
|
|
||||||
this.instance.options.helper = "original";
|
this.instance.options.helper = "original";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -514,7 +518,7 @@
|
|||||||
this.instance.isOver = 0;
|
this.instance.isOver = 0;
|
||||||
this.instance.cancelHelperRemoval = true;
|
this.instance.cancelHelperRemoval = true;
|
||||||
this.instance.options.revert = false; //No revert here
|
this.instance.options.revert = false; //No revert here
|
||||||
this.instance.mouseStop(e);
|
this.instance.mouseStop(e, true);
|
||||||
this.instance.options.helper = "original";
|
this.instance.options.helper = "original";
|
||||||
|
|
||||||
//Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
|
//Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
|
||||||
|
@ -60,13 +60,15 @@
|
|||||||
sender: inst ? inst.element : null
|
sender: inst ? inst.element : null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
propagate: function(n,e,inst) {
|
propagate: function(n,e,inst, noPropagation) {
|
||||||
$.ui.plugin.call(this, n, [e, this.ui(inst)]);
|
$.ui.plugin.call(this, n, [e, this.ui(inst)]);
|
||||||
this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]);
|
if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]);
|
||||||
},
|
},
|
||||||
serialize: function(o) {
|
serialize: function(o) {
|
||||||
|
|
||||||
var items = $(this.options.items, this.element).not('.ui-sortable-helper'); //Only the items of the sortable itself
|
|
||||||
|
|
||||||
|
var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself
|
||||||
var str = []; o = o || {};
|
var str = []; o = o || {};
|
||||||
|
|
||||||
items.each(function() {
|
items.each(function() {
|
||||||
@ -78,7 +80,7 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
toArray: function(attr) {
|
toArray: function(attr) {
|
||||||
var items = $(this.options.items, this.element).not('.ui-sortable-helper'); //Only the items of the sortable itself
|
var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself
|
||||||
var ret = [];
|
var ret = [];
|
||||||
|
|
||||||
items.each(function() { ret.push($(this).attr(attr || 'id')); });
|
items.each(function() { ret.push($(this).attr(attr || 'id')); });
|
||||||
@ -167,7 +169,7 @@
|
|||||||
for (var j = cur.length - 1; j >= 0; j--){
|
for (var j = cur.length - 1; j >= 0; j--){
|
||||||
var inst = $.data(cur[j], 'sortable');
|
var inst = $.data(cur[j], 'sortable');
|
||||||
if(inst && !inst.options.disabled) {
|
if(inst && !inst.options.disabled) {
|
||||||
queries.push($.isFunction(inst.options.items) ? inst.options.items.call(this.element) : $(inst.options.items, inst.element));
|
queries.push($.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element));
|
||||||
this.containers.push(inst);
|
this.containers.push(inst);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -495,7 +497,7 @@
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
},
|
},
|
||||||
mouseStop: function(e) {
|
mouseStop: function(e, noPropagation) {
|
||||||
|
|
||||||
//If we are using droppables, inform the manager about the drop
|
//If we are using droppables, inform the manager about the drop
|
||||||
if ($.ui.ddmanager && !this.options.dropBehaviour)
|
if ($.ui.ddmanager && !this.options.dropBehaviour)
|
||||||
@ -512,20 +514,20 @@
|
|||||||
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)
|
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.propagate("stop", e);
|
self.propagate("stop", e, null, noPropagation);
|
||||||
self.clear(e);
|
self.clear(e);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.propagate("stop", e);
|
this.propagate("stop", e, null, noPropagation);
|
||||||
this.clear(e);
|
this.clear(e, noPropagation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
},
|
},
|
||||||
clear: function(e) {
|
clear: function(e, noPropagation) {
|
||||||
|
|
||||||
if(this.domPosition != this.currentItem.prev()[0]) this.propagate("update", e); //Trigger update callback if the DOM position has changed
|
if(this.domPosition != this.currentItem.prev()[0]) this.propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed
|
||||||
if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
|
if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
|
||||||
this.propagate("remove", e);
|
this.propagate("remove", e);
|
||||||
for (var i = this.containers.length - 1; i >= 0; i--){
|
for (var i = this.containers.length - 1; i >= 0; i--){
|
||||||
|
Loading…
Reference in New Issue
Block a user