mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Dev: Standardize sortable test suite. Fixed #8755 - Dev: Get sortable test suite to pass
This commit is contained in:
parent
d771048a56
commit
68ad80c292
@ -24,7 +24,7 @@ var versions = {
|
||||
"Resizable": "resizable/resizable.html",
|
||||
"Selectable": "selectable/selectable.html",
|
||||
//"Slider": "slider/slider.html",
|
||||
//"Sortable": "sortable/sortable.html",
|
||||
"Sortable": "sortable/sortable.html",
|
||||
"Spinner": "spinner/spinner.html",
|
||||
"Tabs": "tabs/tabs.html",
|
||||
"Tooltip": "tooltip/tooltip.html",
|
||||
|
4
grunt.js
4
grunt.js
@ -281,13 +281,13 @@ grunt.initConfig({
|
||||
files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
|
||||
// disabling everything that doesn't (quite) work with PhantomJS for now
|
||||
// TODO except for all|index|test, try to include more as we go
|
||||
return !( /(all|all-active|index|test|sortable|dialog|slider|datepicker|tabs|tooltip)\.html$/ ).test( file );
|
||||
return !( /(all|all-active|index|test|dialog|slider|datepicker|tabs|tooltip)\.html$/ ).test( file );
|
||||
})
|
||||
},
|
||||
lint: {
|
||||
ui: grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) {
|
||||
// TODO remove items from this list once rewritten
|
||||
return !( /(mouse|datepicker|sortable)\.js$/ ).test( file );
|
||||
return !( /(mouse|datepicker)\.js$/ ).test( file );
|
||||
}),
|
||||
grunt: [ "grunt.js", "build/**/*.js" ],
|
||||
tests: "tests/unit/**/*.js"
|
||||
|
@ -31,7 +31,7 @@
|
||||
"resizable/resizable.html",
|
||||
"selectable/selectable.html",
|
||||
//"slider/slider.html",
|
||||
//"sortable/sortable.html",
|
||||
"sortable/sortable.html",
|
||||
"spinner/spinner.html",
|
||||
"tabs/tabs.html",
|
||||
"tooltip/tooltip.html",
|
||||
|
@ -31,7 +31,7 @@
|
||||
"resizable/resizable.html",
|
||||
"selectable/selectable.html",
|
||||
"slider/slider.html",
|
||||
//"sortable/sortable.html",
|
||||
"sortable/sortable.html",
|
||||
"spinner/spinner.html",
|
||||
"tabs/tabs.html",
|
||||
"tooltip/tooltip.html",
|
||||
|
@ -29,6 +29,22 @@
|
||||
<script src="sortable_tickets.js"></script>
|
||||
|
||||
<script src="../swarminject.js"></script>
|
||||
<style>
|
||||
#sortable, #sortable2 {
|
||||
position:relative;
|
||||
top:0;
|
||||
left:0;
|
||||
padding: 0;
|
||||
margin: 1px;
|
||||
border-width: 0;
|
||||
}
|
||||
#sortable li{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border-width: 0;
|
||||
height:19px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -5,6 +5,7 @@ TestHelpers.commonWidgetTests( "sortable", {
|
||||
cancel: "input,textarea,button,select,option",
|
||||
connectWith: false,
|
||||
containment: false,
|
||||
create: null,
|
||||
cursor: "auto",
|
||||
cursorAt: false,
|
||||
delay: 0,
|
||||
|
@ -4,10 +4,16 @@
|
||||
|
||||
(function($) {
|
||||
|
||||
TestHelpers.sortable = {
|
||||
sort: function(handle, dx, dy, index, msg) {
|
||||
$(handle).simulate("drag", {
|
||||
dx: dx || 0,
|
||||
dy: dy || 0
|
||||
});
|
||||
equal($(handle).parent().children().index(handle), index, msg);
|
||||
}
|
||||
};
|
||||
|
||||
module("sortable: core");
|
||||
|
||||
// this is here to make JSHint pass "unused", and we don't want to
|
||||
// remove the parameter for when we finally implement
|
||||
$.noop();
|
||||
|
||||
})(jQuery);
|
||||
|
@ -6,6 +6,7 @@
|
||||
module("sortable: events");
|
||||
|
||||
test("start", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
@ -15,15 +16,18 @@ test("start", function() {
|
||||
ok(hash, 'start event triggered');
|
||||
ok(hash.helper, 'UI hash includes: helper');
|
||||
ok(hash.placeholder, 'UI hash includes: placeholder');
|
||||
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
||||
ok(hash.item, 'UI hash includes: item');
|
||||
ok(!hash.sender, 'UI hash does not include: sender');
|
||||
|
||||
// todo: see if these events should actually have sane values in them
|
||||
ok('position' in hash, 'UI hash includes: position');
|
||||
ok('offset' in hash, 'UI hash includes: offset');
|
||||
|
||||
|
||||
});
|
||||
|
||||
test("sort", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
@ -33,7 +37,7 @@ test("sort", function() {
|
||||
ok(hash, 'sort event triggered');
|
||||
ok(hash.helper, 'UI hash includes: helper');
|
||||
ok(hash.placeholder, 'UI hash includes: placeholder');
|
||||
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
||||
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
||||
ok(hash.item, 'UI hash includes: item');
|
||||
ok(!hash.sender, 'UI hash does not include: sender');
|
||||
@ -41,6 +45,7 @@ test("sort", function() {
|
||||
});
|
||||
|
||||
test("change", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
@ -51,12 +56,12 @@ test("change", function() {
|
||||
|
||||
$("#sortable")
|
||||
.sortable({ change: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 22 });
|
||||
|
||||
ok(hash, 'change event triggered');
|
||||
ok(hash.helper, 'UI hash includes: helper');
|
||||
ok(hash.placeholder, 'UI hash includes: placeholder');
|
||||
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
||||
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
||||
ok(hash.item, 'UI hash includes: item');
|
||||
ok(!hash.sender, 'UI hash does not include: sender');
|
||||
@ -64,6 +69,7 @@ test("change", function() {
|
||||
});
|
||||
|
||||
test("beforeStop", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
@ -73,7 +79,7 @@ test("beforeStop", function() {
|
||||
ok(hash, 'beforeStop event triggered');
|
||||
ok(hash.helper, 'UI hash includes: helper');
|
||||
ok(hash.placeholder, 'UI hash includes: placeholder');
|
||||
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
||||
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
||||
ok(hash.item, 'UI hash includes: item');
|
||||
ok(!hash.sender, 'UI hash does not include: sender');
|
||||
@ -81,6 +87,7 @@ test("beforeStop", function() {
|
||||
});
|
||||
|
||||
test("stop", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
@ -90,7 +97,7 @@ test("stop", function() {
|
||||
ok(hash, 'stop event triggered');
|
||||
ok(!hash.helper, 'UI should not include: helper');
|
||||
ok(hash.placeholder, 'UI hash includes: placeholder');
|
||||
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
||||
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
||||
ok(hash.item, 'UI hash includes: item');
|
||||
ok(!hash.sender, 'UI hash does not include: sender');
|
||||
@ -98,6 +105,7 @@ test("stop", function() {
|
||||
});
|
||||
|
||||
test("update", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
@ -108,18 +116,19 @@ test("update", function() {
|
||||
|
||||
$("#sortable")
|
||||
.sortable({ update: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 22 });
|
||||
|
||||
ok(hash, 'update event triggered');
|
||||
ok(!hash.helper, 'UI hash should not include: helper');
|
||||
ok(hash.placeholder, 'UI hash includes: placeholder');
|
||||
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
||||
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
||||
ok(hash.item, 'UI hash includes: item');
|
||||
ok(!hash.sender, 'UI hash does not include: sender');
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
test("receive", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
@ -143,5 +152,6 @@ test("activate", function() {
|
||||
test("deactivate", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
*/
|
||||
|
||||
})(jQuery);
|
||||
|
@ -3,27 +3,10 @@
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
var el, offsetBefore, offsetAfter, dragged;
|
||||
|
||||
function drag(handle, dx, dy) {
|
||||
offsetBefore = $(handle).offset();
|
||||
$(handle).simulate("drag", {
|
||||
dx: dx || 0,
|
||||
dy: dy || 0
|
||||
});
|
||||
dragged = { dx: dx, dy: dy };
|
||||
offsetAfter = $(handle).offset();
|
||||
}
|
||||
|
||||
function sort(handle, dx, dy, index, msg) {
|
||||
drag(handle, dx, dy);
|
||||
equal($(handle).parent().children().index(handle), index, msg);
|
||||
}
|
||||
|
||||
module("sortable: methods");
|
||||
|
||||
test("init", function() {
|
||||
expect(6);
|
||||
expect(5);
|
||||
|
||||
$("<div></div>").appendTo('body').sortable().remove();
|
||||
ok(true, '.sortable() called on element');
|
||||
@ -34,9 +17,6 @@ test("init", function() {
|
||||
$("<div></div>").sortable();
|
||||
ok(true, '.sortable() called on disconnected DOMElement');
|
||||
|
||||
$("<div></div>").sortable().sortable("foo");
|
||||
ok(true, 'arbitrary method called after init');
|
||||
|
||||
$("<div></div>").sortable().sortable("option", "foo");
|
||||
ok(true, 'arbitrary option getter after init');
|
||||
|
||||
@ -45,6 +25,7 @@ test("init", function() {
|
||||
});
|
||||
|
||||
test("destroy", function() {
|
||||
expect(4);
|
||||
$("<div></div>").appendTo('body').sortable().sortable("destroy").remove();
|
||||
ok(true, '.sortable("destroy") called on element');
|
||||
|
||||
@ -54,9 +35,6 @@ test("destroy", function() {
|
||||
$("<div></div>").sortable().sortable("destroy");
|
||||
ok(true, '.sortable("destroy") called on disconnected DOMElement');
|
||||
|
||||
$("<div></div>").sortable().sortable("destroy").sortable("foo");
|
||||
ok(true, 'arbitrary method called after destroy');
|
||||
|
||||
var expected = $('<div></div>').sortable(),
|
||||
actual = expected.sortable('destroy');
|
||||
equal(actual, expected, 'destroy is chainable');
|
||||
@ -66,7 +44,7 @@ test("enable", function() {
|
||||
expect(5);
|
||||
el = $("#sortable").sortable({ disabled: true });
|
||||
|
||||
sort($("li", el)[0], 0, 40, 0, '.sortable({ disabled: true })');
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, '.sortable({ disabled: true })');
|
||||
|
||||
el.sortable("enable");
|
||||
equal(el.sortable("option", "disabled"), false, "disabled option getter");
|
||||
@ -76,7 +54,7 @@ test("enable", function() {
|
||||
el.sortable("option", "disabled", false);
|
||||
equal(el.sortable("option", "disabled"), false, "disabled option setter");
|
||||
|
||||
sort($("li", el)[0], 0, 40, 2, '.sortable("option", "disabled", false)');
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable("option", "disabled", false)');
|
||||
|
||||
var expected = $('<div></div>').sortable(),
|
||||
actual = expected.sortable('enable');
|
||||
@ -86,19 +64,19 @@ test("enable", function() {
|
||||
test("disable", function() {
|
||||
expect(7);
|
||||
el = $("#sortable").sortable({ disabled: false });
|
||||
sort($("li", el)[0], 0, 40, 2, '.sortable({ disabled: false })');
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable({ disabled: false })');
|
||||
|
||||
el.sortable("disable");
|
||||
sort($("li", el)[0], 0, 40, 0, 'disabled.sortable getter');
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, 'disabled.sortable getter');
|
||||
|
||||
el.sortable("destroy");
|
||||
|
||||
el.sortable({ disabled: false });
|
||||
sort($("li", el)[0], 0, 40, 2, '.sortable({ disabled: false })');
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable({ disabled: false })');
|
||||
el.sortable("option", "disabled", true);
|
||||
equal(el.sortable("option", "disabled"), true, "disabled option setter");
|
||||
ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction");
|
||||
sort($("li", el)[0], 0, 40, 0, '.sortable("option", "disabled", true)');
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, '.sortable("option", "disabled", true)');
|
||||
|
||||
var expected = $('<div></div>').sortable(),
|
||||
actual = expected.sortable('disable');
|
||||
|
@ -9,6 +9,7 @@ module("sortable: options");
|
||||
// remove the parameter for when we finally implement
|
||||
$.noop();
|
||||
|
||||
/*
|
||||
test("{ appendTo: 'parent' }, default", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
@ -256,5 +257,5 @@ test("{ zIndex: 1 }", function() {
|
||||
test("{ zIndex: false }", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
|
||||
*/
|
||||
})(jQuery);
|
||||
|
@ -3,26 +3,10 @@
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
var el, offsetBefore, offsetAfter, dragged;
|
||||
|
||||
function drag(handle, dx, dy) {
|
||||
offsetBefore = $(handle).offset();
|
||||
$(handle).simulate("drag", {
|
||||
dx: dx || 0,
|
||||
dy: dy || 0
|
||||
});
|
||||
dragged = { dx: dx, dy: dy };
|
||||
offsetAfter = $(handle).offset();
|
||||
}
|
||||
|
||||
function sort(handle, dx, dy, index, msg) {
|
||||
drag(handle, dx, dy);
|
||||
equal($(handle).parent().children().index(handle), index, msg);
|
||||
}
|
||||
|
||||
module("sortable: tickets");
|
||||
|
||||
test("#3019: Stop fires too early", function() {
|
||||
expect(2);
|
||||
|
||||
var helper = null;
|
||||
el = $("#sortable").sortable({
|
||||
@ -31,19 +15,21 @@ test("#3019: Stop fires too early", function() {
|
||||
}
|
||||
});
|
||||
|
||||
sort($("li", el)[0], 0, 40, 2, 'Dragging the sortable');
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable');
|
||||
equal(helper, null, "helper should be false");
|
||||
|
||||
});
|
||||
|
||||
test('#4752: link event firing on sortable with connect list', function () {
|
||||
expect( 10 );
|
||||
|
||||
var fired = {},
|
||||
hasFired = function (type) { return (type in fired) && (true === fired[type]); };
|
||||
|
||||
$('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable');
|
||||
|
||||
$('#main ul').sortable({
|
||||
connectWith: '#main ul',
|
||||
$('#qunit-fixture ul').sortable({
|
||||
connectWith: '#qunit-fixture ul',
|
||||
change: function () {
|
||||
fired.change = true;
|
||||
},
|
||||
@ -55,7 +41,7 @@ test('#4752: link event firing on sortable with connect list', function () {
|
||||
}
|
||||
});
|
||||
|
||||
$('#main ul li').live('click.ui-sortable-test', function () {
|
||||
$('#qunit-fixture ul').bind('click.ui-sortable-test', function () {
|
||||
fired.click = true;
|
||||
});
|
||||
|
||||
|
59
ui/jquery.ui.sortable.js
vendored
59
ui/jquery.ui.sortable.js
vendored
@ -15,6 +15,7 @@
|
||||
*/
|
||||
(function( $, undefined ) {
|
||||
|
||||
/*jshint onevar: false, curly: false, eqeqeq: false, laxbreak: true, shadow: true, loopfunc: true */
|
||||
$.widget("ui.sortable", $.ui.mouse, {
|
||||
version: "@VERSION",
|
||||
widgetEventPrefix: "sort",
|
||||
@ -62,7 +63,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
this._mouseInit();
|
||||
|
||||
//We're ready to go
|
||||
this.ready = true
|
||||
this.ready = true;
|
||||
|
||||
},
|
||||
|
||||
@ -101,7 +102,9 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
this._refreshItems(event);
|
||||
|
||||
//Find out if the clicked node (or one of its parents) is a actual item in this.items
|
||||
var currentItem = null, nodes = $(event.target).parents().each(function() {
|
||||
var currentItem = null;
|
||||
|
||||
$(event.target).parents().each(function() {
|
||||
if($.data(this, that.widgetName + '-item') == that) {
|
||||
currentItem = $(this);
|
||||
return false;
|
||||
@ -221,7 +224,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
//Post 'activate' events to possible containers
|
||||
if(!noActivation) {
|
||||
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
|
||||
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
|
||||
}
|
||||
|
||||
//Prepare possible droppables
|
||||
@ -418,7 +421,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
var str = []; o = o || {};
|
||||
|
||||
$(items).each(function() {
|
||||
var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
||||
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]));
|
||||
});
|
||||
|
||||
@ -458,7 +461,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
|
||||
|
||||
if( this.options.tolerance == "pointer"
|
||||
if (this.options.tolerance == "pointer"
|
||||
|| this.options.forcePointerForContainers
|
||||
|| (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
|
||||
) {
|
||||
@ -507,12 +510,12 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
_getDragVerticalDirection: function() {
|
||||
var delta = this.positionAbs.top - this.lastPositionAbs.top;
|
||||
return delta != 0 && (delta > 0 ? "down" : "up");
|
||||
return delta !== 0 && (delta > 0 ? "down" : "up");
|
||||
},
|
||||
|
||||
_getDragHorizontalDirection: function() {
|
||||
var delta = this.positionAbs.left - this.lastPositionAbs.left;
|
||||
return delta != 0 && (delta > 0 ? "right" : "left");
|
||||
return delta !== 0 && (delta > 0 ? "right" : "left");
|
||||
},
|
||||
|
||||
refresh: function(event) {
|
||||
@ -542,8 +545,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
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(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]);
|
||||
@ -552,7 +555,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
queries[i][0].each(function() {
|
||||
items.push(this);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return $(items);
|
||||
|
||||
@ -566,7 +569,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
for (var j=0; j < list.length; j++) {
|
||||
if(list[j] == item.item[0])
|
||||
return false;
|
||||
};
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -589,8 +592,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
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);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = queries.length - 1; i >= 0; i--) {
|
||||
@ -608,8 +611,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
width: 0, height: 0,
|
||||
left: 0, top: 0
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -637,7 +640,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
var p = t.offset();
|
||||
item.left = p.left;
|
||||
item.top = p.top;
|
||||
};
|
||||
}
|
||||
|
||||
if(this.options.custom && this.options.custom.refreshContainers) {
|
||||
this.options.custom.refreshContainers.call(this);
|
||||
@ -648,7 +651,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
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();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
@ -679,8 +682,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
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(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };
|
||||
if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };
|
||||
if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); }
|
||||
if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); }
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -786,8 +789,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
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;
|
||||
|
||||
@ -899,7 +902,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
if(!pos) pos = this.position;
|
||||
var mod = d == "absolute" ? 1 : -1;
|
||||
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
||||
var scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
||||
|
||||
return {
|
||||
top: (
|
||||
@ -949,10 +952,10 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1047,7 +1050,9 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
if(this.cancelHelperRemoval) {
|
||||
if(!noPropagation) {
|
||||
this._trigger("beforeStop", event, this._uiHash());
|
||||
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
|
||||
for (var i=0; i < delayedTriggers.length; i++) {
|
||||
delayedTriggers[i].call(this, event);
|
||||
} //Trigger all delayed events
|
||||
this._trigger("stop", event, this._uiHash());
|
||||
}
|
||||
|
||||
@ -1063,7 +1068,9 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
|
||||
|
||||
if(!noPropagation) {
|
||||
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
|
||||
for (var i=0; i < delayedTriggers.length; i++) {
|
||||
delayedTriggers[i].call(this, event);
|
||||
} //Trigger all delayed events
|
||||
this._trigger("stop", event, this._uiHash());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user