mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
sortable: removed ui.element and ui.options from the UI object, corrected the callback for the items option, now includes event if applicable
This commit is contained in:
parent
8306e62887
commit
2a6a356109
@ -40,8 +40,6 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
|
|||||||
placeholder: self.placeholder || $([]),
|
placeholder: self.placeholder || $([]),
|
||||||
position: self.position,
|
position: self.position,
|
||||||
absolutePosition: self.positionAbs,
|
absolutePosition: self.positionAbs,
|
||||||
options: this.options,
|
|
||||||
element: this.element,
|
|
||||||
item: self.currentItem,
|
item: self.currentItem,
|
||||||
sender: inst ? inst.element : null
|
sender: inst ? inst.element : null
|
||||||
};
|
};
|
||||||
@ -206,8 +204,8 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
|
|||||||
return direction;
|
return direction;
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
refresh: function(event) {
|
||||||
this._refreshItems();
|
this._refreshItems(event);
|
||||||
this.refreshPositions();
|
this.refreshPositions();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -256,13 +254,13 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_refreshItems: function() {
|
_refreshItems: function(event) {
|
||||||
|
|
||||||
this.items = [];
|
this.items = [];
|
||||||
this.containers = [this];
|
this.containers = [this];
|
||||||
var items = this.items;
|
var items = this.items;
|
||||||
var self = this;
|
var self = this;
|
||||||
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element), this]];
|
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
|
||||||
|
|
||||||
if(this.options.connectWith) {
|
if(this.options.connectWith) {
|
||||||
for (var i = this.options.connectWith.length - 1; i >= 0; i--){
|
for (var i = this.options.connectWith.length - 1; i >= 0; i--){
|
||||||
@ -270,7 +268,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
|
|||||||
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 != this && !inst.options.disabled) {
|
if(inst && inst != this && !inst.options.disabled) {
|
||||||
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(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);
|
this.containers.push(inst);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -449,7 +447,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
|
|||||||
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
|
//We have to refresh the items data once first
|
||||||
this._refreshItems();
|
this._refreshItems(event);
|
||||||
|
|
||||||
//Find out if the clicked node (or one of its parents) is a actual item in this.items
|
//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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user