mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Merge branch 'master' into selectmenu
This commit is contained in:
commit
0bf91a41c6
@ -23,6 +23,7 @@
|
||||
"Globalize",
|
||||
"module",
|
||||
"notEqual",
|
||||
"notDeepEqual",
|
||||
"notStrictEqual",
|
||||
"ok",
|
||||
"QUnit",
|
||||
|
@ -277,18 +277,30 @@ function findCenter( elem ) {
|
||||
};
|
||||
}
|
||||
|
||||
function findCorner( elem ) {
|
||||
var offset,
|
||||
document = $( elem.ownerDocument );
|
||||
elem = $( elem );
|
||||
offset = elem.offset();
|
||||
|
||||
return {
|
||||
x: offset.left - document.scrollLeft(),
|
||||
y: offset.top - document.scrollTop()
|
||||
};
|
||||
}
|
||||
|
||||
$.extend( $.simulate.prototype, {
|
||||
simulateDrag: function() {
|
||||
var i = 0,
|
||||
target = this.target,
|
||||
options = this.options,
|
||||
center = findCenter( target ),
|
||||
center = options.handle === "corner" ? findCorner( target ) : findCenter( target ),
|
||||
x = Math.floor( center.x ),
|
||||
y = Math.floor( center.y ),
|
||||
dx = options.dx || 0,
|
||||
dy = options.dy || 0,
|
||||
moves = options.moves || 3,
|
||||
coord = { clientX: x, clientY: y };
|
||||
coord = { clientX: x, clientY: y },
|
||||
dx = options.dx || ( options.x !== undefined ? options.x - x : 0 ),
|
||||
dy = options.dy || ( options.y !== undefined ? options.y - y : 0 ),
|
||||
moves = options.moves || 3;
|
||||
|
||||
this.simulateEvent( target, "mousedown", coord );
|
||||
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
<script src="../../jquery.js"></script>
|
||||
<link rel="stylesheet" href="../../../external/qunit.css">
|
||||
|
||||
|
||||
<style>
|
||||
/* See #9077 */
|
||||
#draggable3, #draggable4 { z-index: 100; }
|
||||
</style>
|
||||
|
||||
|
||||
<script src="../../../external/qunit.js"></script>
|
||||
<script src="../../jquery.simulate.js"></script>
|
||||
<script src="../testsuite.js"></script>
|
||||
@ -23,7 +23,8 @@
|
||||
"ui/jquery.ui.widget.js",
|
||||
"ui/jquery.ui.mouse.js",
|
||||
"ui/jquery.ui.resizable.js",
|
||||
"ui/jquery.ui.draggable.js"
|
||||
"ui/jquery.ui.draggable.js",
|
||||
"ui/jquery.ui.droppable.js"
|
||||
]
|
||||
});
|
||||
</script>
|
||||
@ -45,15 +46,12 @@
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">
|
||||
<div id="main"></div>
|
||||
|
||||
<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
|
||||
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div>
|
||||
<div style='width: 1px; height: 1000px;'></div>
|
||||
<div style="position: absolute; width: 1px; height: 2000px;"></div>
|
||||
<div id="draggable3"></div>
|
||||
<div id="draggable4"></div>
|
||||
|
||||
<div id="main"></div>
|
||||
<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
|
||||
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div>
|
||||
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
|
||||
<div style="width: 1px; height: 1000px;"></div>
|
||||
<div style="position: absolute; width: 1px; height: 2000px;"></div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
@ -1,6 +1,5 @@
|
||||
TestHelpers.commonWidgetTests( "draggable", {
|
||||
defaults: {
|
||||
addClasses: true,
|
||||
appendTo: "parent",
|
||||
axis: false,
|
||||
cancel: "input,textarea,button,select,option",
|
||||
@ -8,13 +7,10 @@ TestHelpers.commonWidgetTests( "draggable", {
|
||||
containment: false,
|
||||
cursor: "auto",
|
||||
cursorAt: false,
|
||||
delay: 0,
|
||||
disabled: false,
|
||||
distance: 1,
|
||||
grid: false,
|
||||
handle: false,
|
||||
helper: "original",
|
||||
iframeFix: false,
|
||||
opacity: false,
|
||||
refreshPositions: false,
|
||||
revert: false,
|
||||
@ -29,6 +25,12 @@ TestHelpers.commonWidgetTests( "draggable", {
|
||||
stack: false,
|
||||
zIndex: false,
|
||||
|
||||
//todo: remove the following option checks when interactions are rewritten:
|
||||
addClasses: true,
|
||||
delay: 0,
|
||||
distance: 1,
|
||||
iframeFix: false,
|
||||
|
||||
// callbacks
|
||||
create: null,
|
||||
drag: null,
|
||||
|
@ -2,24 +2,40 @@
|
||||
* draggable_core.js
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
(function( $ ) {
|
||||
|
||||
module("draggable");
|
||||
var relativeElement, absoluteElement;
|
||||
|
||||
test("element types", function() {
|
||||
var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" +
|
||||
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
|
||||
",acronym,code,samp,kbd,var,img,hr" +
|
||||
",input,button,label,select,iframe").split(",");
|
||||
module( "draggable: core", {
|
||||
setup: function() {
|
||||
relativeElement = $("<div style='width: 200px; height: 100px;'>Relative</div>").appendTo("#qunit-fixture");
|
||||
absoluteElement = $("<div style='background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;'><span>Absolute</span></div>").appendTo("#qunit-fixture");
|
||||
},
|
||||
teardown: function() {
|
||||
relativeElement.remove();
|
||||
absoluteElement.remove();
|
||||
}
|
||||
});
|
||||
|
||||
test( "element types", function() {
|
||||
var typeNames = (
|
||||
"p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" +
|
||||
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
|
||||
",acronym,code,samp,kbd,var,img,hr" +
|
||||
",input,button,label,select,iframe"
|
||||
).split(",");
|
||||
|
||||
expect( typeNames.length * 2 );
|
||||
|
||||
$.each(typeNames, function(i) {
|
||||
$.each( typeNames, function( i ) {
|
||||
var offsetBefore, offsetAfter,
|
||||
typeName = typeNames[i],
|
||||
el = $(document.createElement(typeName)).appendTo("#qunit-fixture");
|
||||
typeName = typeNames[ i ],
|
||||
el = $( document.createElement( typeName ) ).appendTo("#qunit-fixture");
|
||||
|
||||
if ( typeName === "table" ) {
|
||||
el.append("<tr><td>content</td></tr>");
|
||||
}
|
||||
|
||||
(typeName === "table" && el.append("<tr><td>content</td></tr>"));
|
||||
el.draggable({ cancel: "" });
|
||||
offsetBefore = el.offset();
|
||||
el.simulate( "drag", {
|
||||
@ -27,39 +43,38 @@ test("element types", function() {
|
||||
dy: 50
|
||||
});
|
||||
offsetAfter = el.offset();
|
||||
// there are some rounding errors in FF, Chrome, and IE9, so we can't say equal, we have to settle for close enough
|
||||
closeEnough(offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">");
|
||||
closeEnough(offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + ">");
|
||||
|
||||
// Support: FF, Chrome, and IE9,
|
||||
// there are some rounding errors in so we can't say equal, we have to settle for close enough
|
||||
closeEnough( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">" );
|
||||
closeEnough( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + ">" );
|
||||
el.draggable("destroy");
|
||||
el.remove();
|
||||
});
|
||||
});
|
||||
|
||||
test("No options, relative", function() {
|
||||
test( "No options, relative", function() {
|
||||
expect( 1 );
|
||||
var el = $("#draggable1").draggable();
|
||||
TestHelpers.draggable.shouldMove(el);
|
||||
TestHelpers.draggable.shouldMove( relativeElement.draggable() );
|
||||
});
|
||||
|
||||
test("No options, absolute", function() {
|
||||
test( "No options, absolute", function() {
|
||||
expect( 1 );
|
||||
var el = $("#draggable2").draggable();
|
||||
TestHelpers.draggable.shouldMove(el);
|
||||
TestHelpers.draggable.shouldMove( absoluteElement.draggable() );
|
||||
});
|
||||
|
||||
test("resizable handle with complex markup (#8756 / #8757)", function() {
|
||||
test( "resizable handle with complex markup (#8756 / #8757)", function() {
|
||||
expect( 2 );
|
||||
|
||||
$("#draggable1")
|
||||
relativeElement
|
||||
.append(
|
||||
$("<div>")
|
||||
.addClass("ui-resizable-handle")
|
||||
.addClass("ui-resizable-w")
|
||||
.append($("<div>"))
|
||||
.addClass("ui-resizable-handle ui-resizable-w")
|
||||
.append( $("<div>") )
|
||||
);
|
||||
|
||||
var handle = $(".ui-resizable-w div"),
|
||||
target = $("#draggable1").draggable().resizable({ handles: "all" });
|
||||
target = relativeElement.draggable().resizable({ handles: "all" });
|
||||
|
||||
// todo: fix resizable so it doesn't require a mouseover
|
||||
handle.simulate("mouseover").simulate( "drag", { dx: -50 } );
|
||||
@ -70,4 +85,4 @@ test("resizable handle with complex markup (#8756 / #8757)", function() {
|
||||
equal( target.width(), 200, "compare width" );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
})( jQuery );
|
||||
|
@ -1,99 +1,125 @@
|
||||
/*
|
||||
* draggable_events.js
|
||||
*/
|
||||
(function($) {
|
||||
(function( $ ) {
|
||||
|
||||
module("draggable: events");
|
||||
var element;
|
||||
|
||||
test("callbacks occurrence count", function() {
|
||||
module( "draggable: events", {
|
||||
setup: function() {
|
||||
element = $("<div>").appendTo("#qunit-fixture");
|
||||
},
|
||||
teardown: function() {
|
||||
element.draggable("destroy");
|
||||
}
|
||||
});
|
||||
|
||||
expect(3);
|
||||
test( "callbacks occurrence count", function() {
|
||||
expect( 3 );
|
||||
|
||||
var start = 0,
|
||||
stop = 0,
|
||||
dragc = 0,
|
||||
el = $("#draggable2").draggable({
|
||||
start: function() { start++; },
|
||||
drag: function() { dragc++; },
|
||||
stop: function() { stop++; }
|
||||
});
|
||||
dragc = 0;
|
||||
|
||||
el.simulate( "drag", {
|
||||
element.draggable({
|
||||
start: function() {
|
||||
start++;
|
||||
},
|
||||
drag: function() {
|
||||
dragc++;
|
||||
},
|
||||
stop: function() {
|
||||
stop++;
|
||||
}
|
||||
});
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
});
|
||||
|
||||
equal(start, 1, "start callback should happen exactly once");
|
||||
equal(dragc, 3, "drag callback should happen exactly once per mousemove");
|
||||
equal(stop, 1, "stop callback should happen exactly once");
|
||||
|
||||
equal( start, 1, "start callback should happen exactly once" );
|
||||
equal( dragc, 3, "drag callback should happen exactly once per mousemove" );
|
||||
equal( stop, 1, "stop callback should happen exactly once" );
|
||||
});
|
||||
|
||||
test("stopping the start callback", function() {
|
||||
|
||||
expect(3);
|
||||
test( "stopping the start callback", function() {
|
||||
expect( 3 );
|
||||
|
||||
var start = 0,
|
||||
stop = 0,
|
||||
dragc = 0,
|
||||
el = $("#draggable2").draggable({
|
||||
start: function() { start++; return false; },
|
||||
drag: function() { dragc++; },
|
||||
stop: function() { stop++; }
|
||||
});
|
||||
dragc = 0;
|
||||
|
||||
el.simulate( "drag", {
|
||||
element.draggable({
|
||||
start: function() {
|
||||
start++;
|
||||
return false;
|
||||
},
|
||||
drag: function() {
|
||||
dragc++;
|
||||
},
|
||||
stop: function() {
|
||||
stop++;
|
||||
}
|
||||
});
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
});
|
||||
|
||||
equal(start, 1, "start callback should happen exactly once");
|
||||
equal(dragc, 0, "drag callback should not happen at all");
|
||||
equal(stop, 0, "stop callback should not happen if there wasnt even a start");
|
||||
|
||||
equal( start, 1, "start callback should happen exactly once" );
|
||||
equal( dragc, 0, "drag callback should not happen at all" );
|
||||
equal( stop, 0, "stop callback should not happen if there wasnt even a start" );
|
||||
});
|
||||
|
||||
test("stopping the drag callback", function() {
|
||||
|
||||
expect(3);
|
||||
test( "stopping the drag callback", function() {
|
||||
expect( 2 );
|
||||
|
||||
var start = 0,
|
||||
stop = 0,
|
||||
dragc = 0,
|
||||
el = $("#draggable2").draggable({
|
||||
start: function() { start++;},
|
||||
drag: function() { dragc++; return false; },
|
||||
stop: function() { stop++; }
|
||||
});
|
||||
dragc = 0;
|
||||
|
||||
el.simulate( "drag", {
|
||||
element.draggable({
|
||||
start: function() {
|
||||
start++;
|
||||
},
|
||||
drag: function() {
|
||||
dragc++;
|
||||
return false;
|
||||
},
|
||||
stop: function() {
|
||||
stop++;
|
||||
}
|
||||
});
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
});
|
||||
|
||||
equal(start, 1, "start callback should happen exactly once");
|
||||
equal(dragc, 1, "drag callback should happen exactly once");
|
||||
equal(stop, 1, "stop callback should happen, as we need to actively stop the drag");
|
||||
|
||||
equal( start, 1, "start callback should happen exactly once" );
|
||||
equal( stop, 1, "stop callback should happen, as we need to actively stop the drag" );
|
||||
});
|
||||
|
||||
test("stopping the stop callback", function() {
|
||||
test( "stopping the stop callback", function() {
|
||||
expect( 1 );
|
||||
|
||||
expect(1);
|
||||
|
||||
var el = $("#draggable2").draggable({
|
||||
element.draggable({
|
||||
helper: "clone",
|
||||
stop: function() { return false; }
|
||||
stop: function() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
el.simulate( "drag", {
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
});
|
||||
|
||||
ok($("#draggable2").data("ui-draggable").helper, "the clone should not be deleted if the stop callback is stopped");
|
||||
ok( element.data("ui-draggable").helper, "the clone should not be deleted if the stop callback is stopped" );
|
||||
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
})( jQuery );
|
||||
|
@ -1,94 +1,99 @@
|
||||
/*
|
||||
* draggable_methods.js
|
||||
*/
|
||||
(function($) {
|
||||
(function( $ ) {
|
||||
|
||||
module("draggable: methods");
|
||||
var element;
|
||||
|
||||
test("init", function() {
|
||||
expect(5);
|
||||
module( "draggable: methods", {
|
||||
setup: function() {
|
||||
element = $("<div style='background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;'><span>Absolute</span></div>").appendTo("#qunit-fixture");
|
||||
},
|
||||
teardown: function() {
|
||||
element.remove();
|
||||
}
|
||||
});
|
||||
|
||||
$("<div></div>").appendTo("body").draggable().remove();
|
||||
ok(true, ".draggable() called on element");
|
||||
test( "init", function() {
|
||||
expect( 5 );
|
||||
|
||||
element.draggable();
|
||||
ok( true, ".draggable() called on element" );
|
||||
|
||||
$([]).draggable();
|
||||
ok(true, ".draggable() called on empty collection");
|
||||
ok( true, ".draggable() called on empty collection" );
|
||||
|
||||
$("<div></div>").draggable();
|
||||
ok(true, ".draggable() called on disconnected DOMElement");
|
||||
ok( true, ".draggable() called on disconnected DOMElement" );
|
||||
|
||||
$("<div></div>").draggable().draggable("option", "foo");
|
||||
ok(true, "arbitrary option getter after init");
|
||||
element.draggable( "option", "foo" );
|
||||
ok( true, "arbitrary option getter after init" );
|
||||
|
||||
$("<div></div>").draggable().draggable("option", "foo", "bar");
|
||||
ok(true, "arbitrary option setter after init");
|
||||
element.draggable( "option", "foo", "bar" );
|
||||
ok( true, "arbitrary option setter after init" );
|
||||
});
|
||||
|
||||
test("destroy", function() {
|
||||
expect(4);
|
||||
$("<div></div>").appendTo("body").draggable().draggable("destroy").remove();
|
||||
ok(true, ".draggable('destroy') called on element");
|
||||
test( "destroy", function() {
|
||||
expect( 4 );
|
||||
|
||||
element.draggable().draggable("destroy");
|
||||
ok( true, ".draggable('destroy') called on element" );
|
||||
|
||||
$([]).draggable().draggable("destroy");
|
||||
ok(true, ".draggable('destroy') called on empty collection");
|
||||
ok( true, ".draggable('destroy') called on empty collection" );
|
||||
|
||||
$("<div></div>").draggable().draggable("destroy");
|
||||
ok(true, ".draggable('destroy') called on disconnected DOMElement");
|
||||
element.draggable().draggable("destroy");
|
||||
ok( true, ".draggable('destroy') called on disconnected DOMElement" );
|
||||
|
||||
var expected = $("<div></div>").draggable(),
|
||||
var expected = element.draggable(),
|
||||
actual = expected.draggable("destroy");
|
||||
equal(actual, expected, "destroy is chainable");
|
||||
equal( actual, expected, "destroy is chainable" );
|
||||
});
|
||||
|
||||
test("enable", function() {
|
||||
expect(7);
|
||||
test( "enable", function() {
|
||||
expect( 7 );
|
||||
|
||||
var expected, actual, el;
|
||||
element.draggable({ disabled: true });
|
||||
TestHelpers.draggable.shouldNotMove( element, ".draggable({ disabled: true })" );
|
||||
|
||||
el = $("#draggable2").draggable({ disabled: true });
|
||||
TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })");
|
||||
element.draggable("enable");
|
||||
TestHelpers.draggable.shouldMove( element, ".draggable('enable')" );
|
||||
equal( element.draggable( "option", "disabled" ), false, "disabled option getter" );
|
||||
|
||||
el.draggable("enable");
|
||||
TestHelpers.draggable.shouldMove(el, ".draggable('enable')");
|
||||
equal(el.draggable("option", "disabled"), false, "disabled option getter");
|
||||
element.draggable("destroy");
|
||||
element.draggable({ disabled: true });
|
||||
TestHelpers.draggable.shouldNotMove( element, ".draggable({ disabled: true })" );
|
||||
|
||||
el.draggable("destroy");
|
||||
el.draggable({ disabled: true });
|
||||
TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })");
|
||||
element.draggable( "option", "disabled", false );
|
||||
equal(element.draggable( "option", "disabled" ), false, "disabled option setter" );
|
||||
TestHelpers.draggable.shouldMove( element, ".draggable('option', 'disabled', false)" );
|
||||
|
||||
el.draggable("option", "disabled", false);
|
||||
equal(el.draggable("option", "disabled"), false, "disabled option setter");
|
||||
TestHelpers.draggable.shouldMove(el, ".draggable('option', 'disabled', false)");
|
||||
|
||||
expected = $("<div></div>").draggable(),
|
||||
actual = expected.draggable("enable");
|
||||
equal(actual, expected, "enable is chainable");
|
||||
var expected = element.draggable(),
|
||||
actual = expected.draggable("enable");
|
||||
equal( actual, expected, "enable is chainable" );
|
||||
});
|
||||
|
||||
test("disable", function() {
|
||||
expect(7);
|
||||
test( "disable", function() {
|
||||
expect( 7 );
|
||||
|
||||
var expected, actual, el;
|
||||
element = $("#draggable2").draggable({ disabled: false });
|
||||
TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" );
|
||||
|
||||
el = $("#draggable2").draggable({ disabled: false });
|
||||
TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })");
|
||||
element.draggable("disable");
|
||||
TestHelpers.draggable.shouldNotMove( element, ".draggable('disable')" );
|
||||
equal( element.draggable( "option", "disabled" ), true, "disabled option getter" );
|
||||
|
||||
el.draggable("disable");
|
||||
TestHelpers.draggable.shouldNotMove(el, ".draggable('disable')");
|
||||
equal(el.draggable("option", "disabled"), true, "disabled option getter");
|
||||
element.draggable("destroy");
|
||||
element.draggable({ disabled: false });
|
||||
TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" );
|
||||
|
||||
el.draggable("destroy");
|
||||
element.draggable( "option", "disabled", true );
|
||||
equal( element.draggable( "option", "disabled" ), true, "disabled option setter" );
|
||||
TestHelpers.draggable.shouldNotMove( element, ".draggable('option', 'disabled', true)" );
|
||||
|
||||
el.draggable({ disabled: false });
|
||||
TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })");
|
||||
|
||||
el.draggable("option", "disabled", true);
|
||||
equal(el.draggable("option", "disabled"), true, "disabled option setter");
|
||||
TestHelpers.draggable.shouldNotMove(el, ".draggable('option', 'disabled', true)");
|
||||
|
||||
expected = $("<div></div>").draggable(),
|
||||
actual = expected.draggable("disable");
|
||||
equal(actual, expected, "disable is chainable");
|
||||
var expected = element.draggable(),
|
||||
actual = expected.draggable("disable");
|
||||
equal( actual, expected, "disable is chainable" );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
})( jQuery );
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ TestHelpers.draggable = {
|
||||
});
|
||||
offsetAfter = el.offset();
|
||||
|
||||
actual = { left: offsetAfter.left, top: offsetAfter.top },
|
||||
actual = { left: offsetAfter.left, top: offsetAfter.top };
|
||||
expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
|
||||
|
||||
msg = msg ? msg + "." : "";
|
||||
@ -50,5 +50,29 @@ TestHelpers.draggable = {
|
||||
},
|
||||
margin: function(el, side) {
|
||||
return parseInt(el.css("margin-" + side), 10) || 0;
|
||||
},
|
||||
move: function( el, x, y ) {
|
||||
|
||||
$( el ).simulate( "drag", {
|
||||
dx: x,
|
||||
dy: y
|
||||
});
|
||||
|
||||
},
|
||||
trackMouseCss : function( el ) {
|
||||
el.on( "drag", function() {
|
||||
el.data( "last_dragged_cursor", $("body").css("cursor") );
|
||||
});
|
||||
},
|
||||
trackAppendedParent : function( el ) {
|
||||
|
||||
// appendTo ignored without being clone
|
||||
el.draggable( "option", "helper", "clone" );
|
||||
|
||||
el.on( "drag", function(e,ui) {
|
||||
// Get what parent is at time of drag
|
||||
el.data( "last_dragged_parent", ui.helper.parent()[0] );
|
||||
});
|
||||
|
||||
}
|
||||
};
|
@ -84,6 +84,13 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="sortable-images">
|
||||
<img src="../images/jqueryui_32x32.png" alt="">
|
||||
<img src="../images/jqueryui_32x32.png" alt="">
|
||||
<img src="../images/jqueryui_32x32.png" alt="">
|
||||
<img src="../images/jqueryui_32x32.png" alt="">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -5,10 +5,6 @@
|
||||
|
||||
module("sortable: options");
|
||||
|
||||
// this is here to make JSHint pass "unused", and we don't want to
|
||||
// remove the parameter for when we finally implement
|
||||
$.noop();
|
||||
|
||||
/*
|
||||
test("{ appendTo: 'parent' }, default", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
@ -186,6 +182,23 @@ test("{ placeholder: false }, default", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
*/
|
||||
|
||||
test( "{ placeholder: false } img", function() {
|
||||
expect( 3 );
|
||||
|
||||
var element = $( "#sortable-images" ).sortable({
|
||||
start: function( event, ui ) {
|
||||
equal( ui.placeholder.attr( "src" ), "../images/jqueryui_32x32.png", "placeholder img has correct src" );
|
||||
equal( ui.placeholder.height(), 32, "placeholder has correct height" );
|
||||
equal( ui.placeholder.width(), 32, "placeholder has correct width" );
|
||||
}
|
||||
});
|
||||
|
||||
element.find( "img" ).eq( 0 ).simulate( "drag", {
|
||||
dy: 1
|
||||
});
|
||||
});
|
||||
|
||||
test( "{ placeholder: String }", function() {
|
||||
expect( 1 );
|
||||
|
||||
|
14
ui/jquery.ui.draggable.js
vendored
14
ui/jquery.ui.draggable.js
vendored
@ -283,14 +283,12 @@ $.widget("ui.draggable", $.ui.mouse, {
|
||||
_getHandle: function(event) {
|
||||
|
||||
var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
|
||||
$(this.options.handle, this.element)
|
||||
.find("*")
|
||||
.addBack()
|
||||
.each(function() {
|
||||
if(this === event.target) {
|
||||
handle = true;
|
||||
}
|
||||
});
|
||||
|
||||
this.element.find( this.options.handle ).each(function() {
|
||||
if(this === event.target) {
|
||||
handle = true;
|
||||
}
|
||||
});
|
||||
|
||||
return handle;
|
||||
|
||||
|
2
ui/jquery.ui.sortable.js
vendored
2
ui/jquery.ui.sortable.js
vendored
@ -762,6 +762,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
// width of the table (browsers are smart enough to
|
||||
// handle this properly)
|
||||
element.append( "<td colspan='99'> </td>" );
|
||||
} else if ( nodeName === "img" ) {
|
||||
element.attr( "src", that.currentItem.attr( "src" ) );
|
||||
}
|
||||
|
||||
if ( !className ) {
|
||||
|
Loading…
Reference in New Issue
Block a user