mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Merge branch 'master' into selectmenu
This commit is contained in:
commit
fab6b8883e
@ -20,7 +20,7 @@
|
||||
$( "#draggable" ).draggable({ snap: true });
|
||||
$( "#draggable2" ).draggable({ snap: ".ui-widget-header" });
|
||||
$( "#draggable3" ).draggable({ snap: ".ui-widget-header", snapMode: "outer" });
|
||||
$( "#draggable4" ).draggable({ grid: [ 20,20 ] });
|
||||
$( "#draggable4" ).draggable({ grid: [ 20, 20 ] });
|
||||
$( "#draggable5" ).draggable({ grid: [ 80, 80 ] });
|
||||
});
|
||||
</script>
|
||||
|
@ -257,6 +257,15 @@ test( "ARIA", function() {
|
||||
"Live region for multiple values" );
|
||||
});
|
||||
|
||||
test( "ARIA, init on detached input", function() {
|
||||
expect( 1 );
|
||||
var element = $( "<input>" ).autocomplete({
|
||||
source: [ "java", "javascript" ]
|
||||
}),
|
||||
liveRegion = element.autocomplete( "instance" ).liveRegion;
|
||||
equal( liveRegion.parent().length, 1, "liveRegion must have a parent" );
|
||||
});
|
||||
|
||||
test( ".replaceWith() (#9172)", function() {
|
||||
expect( 1 );
|
||||
|
||||
|
@ -46,10 +46,11 @@
|
||||
<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><em>Absolute</em></span></div>
|
||||
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
|
||||
<div id="main">
|
||||
<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><em>Absolute</em></span></div>
|
||||
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
|
||||
</div>
|
||||
<div style="width: 1px; height: 1000px;"></div>
|
||||
<div style="position: absolute; width: 1px; height: 2000px;"></div>
|
||||
</div>
|
||||
|
@ -43,13 +43,13 @@ test( "element types", function() {
|
||||
});
|
||||
|
||||
test( "No options, relative", function() {
|
||||
expect( 1 );
|
||||
TestHelpers.draggable.shouldMove( $( "#draggable1" ).draggable() );
|
||||
expect( 2 );
|
||||
TestHelpers.draggable.shouldMove( $( "#draggable1" ).draggable(), "no options, relative" );
|
||||
});
|
||||
|
||||
test( "No options, absolute", function() {
|
||||
expect( 1 );
|
||||
TestHelpers.draggable.shouldMove( $( "#draggable2" ).draggable() );
|
||||
expect( 2 );
|
||||
TestHelpers.draggable.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" );
|
||||
});
|
||||
|
||||
test( "resizable handle with complex markup (#8756 / #8757)", function() {
|
||||
@ -118,14 +118,11 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
|
||||
.scrollLeft( 0 );
|
||||
}
|
||||
}),
|
||||
contentToForceScroll = $( "<div>" ).css({
|
||||
height: "10000px",
|
||||
width: "10000px"
|
||||
}),
|
||||
oldOverflowY = $( "html" ).css( "overflow-y" ),
|
||||
oldOverflowX = $( "html" ).css( "overflow-x" );
|
||||
|
||||
contentToForceScroll.appendTo( "#qunit-fixture" );
|
||||
TestHelpers.forceScrollableWindow();
|
||||
|
||||
$( "html" )
|
||||
.css( "overflow-y", "scroll" )
|
||||
.css( "overflow-x", "scroll" )
|
||||
@ -148,13 +145,10 @@ test( "#9315: Draggable: jumps down with offset of scrollbar", function() {
|
||||
equal( ui.position.top, 11, "top position is correct when position is absolute" );
|
||||
$( "html" ).scrollTop( 0 ).scrollLeft( 0 );
|
||||
}
|
||||
}),
|
||||
contentToForceScroll = $( "<div>" ).css({
|
||||
height: "10000px",
|
||||
width: "10000px"
|
||||
});
|
||||
|
||||
contentToForceScroll.appendTo( "#qunit-fixture" );
|
||||
TestHelpers.forceScrollableWindow();
|
||||
|
||||
$( "html" ).scrollTop( 300 ).scrollLeft( 300 );
|
||||
|
||||
element.simulate( "drag", {
|
||||
@ -178,13 +172,11 @@ test( "#5009: scroll not working with parent's position fixed", function() {
|
||||
equal( ui.position.top, 10, "top position is correct when parent position is fixed" );
|
||||
$( document ).scrollTop( 0 ).scrollLeft( 0 );
|
||||
}
|
||||
}),
|
||||
contentToForceScroll = $( "<div>" ).css({
|
||||
height: "20000px",
|
||||
width: "20000px"
|
||||
});
|
||||
|
||||
$( "#qunit-fixture" ).append( contentToForceScroll );
|
||||
|
||||
TestHelpers.forceScrollableWindow();
|
||||
|
||||
$( "#wrapper" ).css( "position", "fixed" );
|
||||
|
||||
element.simulate( "drag", {
|
||||
@ -195,7 +187,7 @@ test( "#5009: scroll not working with parent's position fixed", function() {
|
||||
});
|
||||
|
||||
test( "#5727: draggable from iframe" , function() {
|
||||
expect( 2 );
|
||||
expect( 1 );
|
||||
|
||||
var iframe = $( "<iframe id='iframe-draggable-container' src='about:blank'></iframe>" ).appendTo( "#qunit-fixture" ),
|
||||
iframeBody = iframe.contents().find( "body" ).append(
|
||||
@ -207,7 +199,9 @@ test( "#5727: draggable from iframe" , function() {
|
||||
|
||||
equal( draggable1.closest( iframeBody ).length, 1 );
|
||||
|
||||
TestHelpers.draggable.shouldMove( draggable1 );
|
||||
// TODO: fix draggable within an IFRAME to fire events on the element properly
|
||||
// and these TestHelpers.draggable.shouldMove relies on events for testing
|
||||
//TestHelpers.draggable.shouldMove( draggable1, "draggable from an iframe" );
|
||||
});
|
||||
|
||||
test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function() {
|
||||
|
@ -54,7 +54,7 @@ test( "enable", function() {
|
||||
expect( 7 );
|
||||
|
||||
element.draggable({ disabled: true });
|
||||
TestHelpers.draggable.shouldNotMove( element, ".draggable({ disabled: true })" );
|
||||
TestHelpers.draggable.shouldNotDrag( element, ".draggable({ disabled: true })" );
|
||||
|
||||
element.draggable("enable");
|
||||
TestHelpers.draggable.shouldMove( element, ".draggable('enable')" );
|
||||
@ -62,7 +62,7 @@ test( "enable", function() {
|
||||
|
||||
element.draggable("destroy");
|
||||
element.draggable({ disabled: true });
|
||||
TestHelpers.draggable.shouldNotMove( element, ".draggable({ disabled: true })" );
|
||||
TestHelpers.draggable.shouldNotDrag( element, ".draggable({ disabled: true })" );
|
||||
|
||||
element.draggable( "option", "disabled", false );
|
||||
equal(element.draggable( "option", "disabled" ), false, "disabled option setter" );
|
||||
@ -80,7 +80,7 @@ test( "disable", function() {
|
||||
TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" );
|
||||
|
||||
element.draggable( "disable" );
|
||||
TestHelpers.draggable.shouldNotMove( element, ".draggable('disable')" );
|
||||
TestHelpers.draggable.shouldNotDrag( element, ".draggable('disable')" );
|
||||
equal( element.draggable( "option", "disabled" ), true, "disabled option getter" );
|
||||
|
||||
element.draggable( "destroy" );
|
||||
@ -89,7 +89,7 @@ test( "disable", function() {
|
||||
|
||||
element.draggable( "option", "disabled", true );
|
||||
equal( element.draggable( "option", "disabled" ), true, "disabled option setter" );
|
||||
TestHelpers.draggable.shouldNotMove( element, ".draggable('option', 'disabled', true)" );
|
||||
TestHelpers.draggable.shouldNotDrag( element, ".draggable('option', 'disabled', true)" );
|
||||
|
||||
ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
|
||||
ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
|
||||
|
@ -4,33 +4,33 @@ module( "draggable: options" );
|
||||
|
||||
// TODO: This doesn't actually test whether append happened, possibly remove
|
||||
test( "{ appendTo: 'parent' }, default, no clone", function() {
|
||||
expect( 2 );
|
||||
expect( 4 );
|
||||
var element = $( "#draggable2" ).draggable({ appendTo: "parent" });
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "absolute appendTo: parent" );
|
||||
|
||||
element = $( "#draggable1" ).draggable({ appendTo: "parent" });
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "relative appendTo: parent" );
|
||||
});
|
||||
|
||||
// TODO: This doesn't actually test whether append happened, possibly remove
|
||||
test( "{ appendTo: Element }, no clone", function() {
|
||||
expect( 2 );
|
||||
expect( 4 );
|
||||
var element = $( "#draggable2" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] });
|
||||
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "absolute appendTo: Element" );
|
||||
|
||||
element = $( "#draggable1" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] });
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "relative appendTo: Element" );
|
||||
});
|
||||
|
||||
// TODO: This doesn't actually test whether append happened, possibly remove
|
||||
test( "{ appendTo: Selector }, no clone", function() {
|
||||
expect( 2 );
|
||||
expect( 4 );
|
||||
var element = $( "#draggable2" ).draggable({ appendTo: "#main" });
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "absolute appendTo: Selector" );
|
||||
|
||||
element = $( "#draggable1" ).draggable({ appendTo: "#main" });
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "relative appendTo: Selector" );
|
||||
});
|
||||
|
||||
test( "{ appendTo: 'parent' }, default", function() {
|
||||
@ -43,7 +43,7 @@ test( "{ appendTo: 'parent' }, default", function() {
|
||||
equal( element.draggable( "option", "appendTo" ), "parent" );
|
||||
|
||||
TestHelpers.draggable.move( element, 1, 1 );
|
||||
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
|
||||
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
|
||||
});
|
||||
|
||||
test( "{ appendTo: Element }", function() {
|
||||
@ -91,30 +91,30 @@ test( "appendTo, default, switching after initialization", function() {
|
||||
|
||||
// Move and make sure element was appended to fixture
|
||||
TestHelpers.draggable.move( element, 1, 1 );
|
||||
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
|
||||
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
|
||||
|
||||
// Move and make sure element was appended to main
|
||||
element.draggable( "option", "appendTo", $( "#main" ) );
|
||||
element.draggable( "option", "appendTo", $( "#qunit-fixture" ) );
|
||||
TestHelpers.draggable.move( element, 2, 2 );
|
||||
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
|
||||
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
|
||||
});
|
||||
|
||||
test( "{ axis: false }, default", function() {
|
||||
expect( 1 );
|
||||
expect( 2 );
|
||||
var element = $( "#draggable2" ).draggable({ axis: false });
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "axis: false" );
|
||||
});
|
||||
|
||||
test( "{ axis: 'x' }", function() {
|
||||
expect( 1 );
|
||||
expect( 2 );
|
||||
var element = $( "#draggable2" ).draggable({ axis: "x" });
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0 );
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0, "axis: x" );
|
||||
});
|
||||
|
||||
test( "{ axis: 'y' }", function() {
|
||||
expect( 1 );
|
||||
expect( 2 );
|
||||
var element = $( "#draggable2" ).draggable({ axis: "y" });
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50 );
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50, "axis: y" );
|
||||
});
|
||||
|
||||
test( "{ axis: ? }, unexpected", function() {
|
||||
@ -128,30 +128,30 @@ test( "{ axis: ? }, unexpected", function() {
|
||||
"function() {}": function() {}
|
||||
};
|
||||
|
||||
expect( 6 );
|
||||
expect( 12 );
|
||||
|
||||
$.each(unexpected, function(key, val) {
|
||||
element = $( "#draggable2" ).draggable({ axis: val });
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50, "axis: " + key );
|
||||
TestHelpers.draggable.shouldMove( element, "axis: " + key );
|
||||
element.draggable( "destroy" );
|
||||
});
|
||||
});
|
||||
|
||||
test( "axis, default, switching after initialization", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable({ axis : false });
|
||||
|
||||
// Any Direction
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 );
|
||||
TestHelpers.draggable.shouldMove( element, "axis: default" );
|
||||
|
||||
// Only horizontal
|
||||
element.draggable( "option", "axis", "x" );
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0 );
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0, "axis: x as option" );
|
||||
|
||||
// Vertical only
|
||||
element.draggable( "option", "axis", "y" );
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50 );
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" );
|
||||
|
||||
});
|
||||
|
||||
@ -161,12 +161,12 @@ test( "{ cancel: 'input,textarea,button,select,option' }, default", function() {
|
||||
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#main" );
|
||||
|
||||
var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "cancel: default, element dragged" );
|
||||
|
||||
element.draggable( "destroy" );
|
||||
|
||||
element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
|
||||
TestHelpers.draggable.testDrag( element, "#draggable-option-cancel-default input", 50, 50, 0, 0 );
|
||||
TestHelpers.draggable.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" );
|
||||
element.draggable( "destroy" );
|
||||
});
|
||||
|
||||
@ -174,16 +174,16 @@ test( "{ cancel: 'span' }", function() {
|
||||
expect( 2 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable();
|
||||
TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50 );
|
||||
TestHelpers.draggable.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" );
|
||||
|
||||
element.draggable( "destroy" );
|
||||
|
||||
element = $( "#draggable2" ).draggable({ cancel: "span" });
|
||||
TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 0, 0 );
|
||||
TestHelpers.draggable.shouldNotDrag( element, "cancel: span, span dragged","#draggable2 span" );
|
||||
});
|
||||
|
||||
test( "{ cancel: ? }, unexpected", function() {
|
||||
expect( 6 );
|
||||
expect( 12 );
|
||||
|
||||
var element,
|
||||
unexpected = {
|
||||
@ -202,10 +202,10 @@ test( "{ cancel: ? }, unexpected", function() {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
/*
|
||||
test( "{ cancel: Selectors }, matching parent selector", function() {
|
||||
|
||||
expect( 5 );
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({ cancel: "span a" });
|
||||
|
||||
@ -215,39 +215,36 @@ test( "{ cancel: Selectors }, matching parent selector", function() {
|
||||
|
||||
$( "#wrapping a" ).append( element );
|
||||
|
||||
TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span child" );
|
||||
TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ) );
|
||||
TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) );
|
||||
TestHelpers.draggable.shouldMove( element, "drag span child", "#draggable2 span" );
|
||||
TestHelpers.draggable.shouldNotDrag( $( "#draggable2 span a" ), "drag span a" );
|
||||
TestHelpers.draggable.shouldNotDrag( $( "#wrapping a" ), "drag wrapping a" );
|
||||
|
||||
$( "#draggable2" ).draggable( "option", "cancel", "span > a" );
|
||||
$( "#draggable2" ).find( "a" ).append( "<a>" );
|
||||
|
||||
|
||||
TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).last(), 50, 50, 50, 50, "drag span child" );
|
||||
TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).first() );
|
||||
|
||||
TestHelpers.draggable.shouldMove( element, "drag span child", $( "#draggable2 span a" ).last() );
|
||||
TestHelpers.draggable.shouldNotDrag( $( "#draggable2 span a" ).first(), "drag span a first child" );
|
||||
});
|
||||
*/
|
||||
|
||||
test( "cancelement, default, switching after initialization", function() {
|
||||
expect( 3 );
|
||||
expect( 2 );
|
||||
|
||||
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#main" );
|
||||
|
||||
var input = $( "#draggable-option-cancel-default input" ),
|
||||
element = $( "#draggable-option-cancel-default" ).draggable();
|
||||
|
||||
TestHelpers.draggable.testDrag( element, input, 50, 50, 0, 0 );
|
||||
TestHelpers.draggable.shouldNotDrag( element, "cancel: default, input dragged", input );
|
||||
|
||||
element.draggable( "option", "cancel", "textarea" );
|
||||
TestHelpers.draggable.testDrag( element, input, 50, 50, 50, 50 );
|
||||
TestHelpers.draggable.shouldMove( element, "cancel: textarea, input dragged", input );
|
||||
|
||||
element.draggable( "option", "cancel", "input" );
|
||||
TestHelpers.draggable.testDrag( element, input, 50, 50, 0, 0 );
|
||||
TestHelpers.draggable.shouldNotDrag( element, "cancel: input, input dragged", input );
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
test( "{ connectToSortable: selector }, default", function() {
|
||||
expect( 1 );
|
||||
|
||||
@ -296,14 +293,14 @@ test( "{ containment: Selector }", function() {
|
||||
});
|
||||
|
||||
test( "{ containment: [x1, y1, x2, y2] }", function() {
|
||||
expect( 1 );
|
||||
expect( 2 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable(),
|
||||
eo = element.offset();
|
||||
|
||||
element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.top + element.height() + 5 ] );
|
||||
|
||||
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 );
|
||||
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" );
|
||||
});
|
||||
|
||||
test( "{ containment: 'parent' }, relative", function() {
|
||||
@ -378,11 +375,11 @@ test( "containment, account for border", function() {
|
||||
});
|
||||
|
||||
test( "containment, default, switching after initialization", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable({ containment: false });
|
||||
|
||||
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 );
|
||||
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: default" );
|
||||
|
||||
element.draggable( "option", "containment", "parent" )
|
||||
.css({
|
||||
@ -391,10 +388,10 @@ test( "containment, default, switching after initialization", function() {
|
||||
})
|
||||
.appendTo( $( "#main" ) );
|
||||
|
||||
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 );
|
||||
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" );
|
||||
|
||||
element.draggable( "option", "containment", false );
|
||||
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 );
|
||||
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" );
|
||||
});
|
||||
|
||||
test( "{ cursor: 'auto' }, default", function() {
|
||||
@ -589,269 +586,272 @@ test( "cursorAt, switching after initialization", function() {
|
||||
});
|
||||
|
||||
test( "disabled", function() {
|
||||
expect( 3 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable();
|
||||
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
|
||||
element.draggable( "option", "disabled", true );
|
||||
TestHelpers.draggable.shouldNotMove( element );
|
||||
|
||||
element.draggable( "option", "disabled", false );
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
});
|
||||
|
||||
test( "{ grid: [50, 50] }, relative", function() {
|
||||
expect( 2 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] });
|
||||
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 );
|
||||
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 );
|
||||
});
|
||||
|
||||
test( "{ grid: [50, 50] }, absolute", function() {
|
||||
expect( 2 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] });
|
||||
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 );
|
||||
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 );
|
||||
});
|
||||
|
||||
test( "grid, switching after initialization", function() {
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable();
|
||||
|
||||
TestHelpers.draggable.shouldMove( element, "disabled: default" );
|
||||
|
||||
element.draggable( "option", "disabled", true );
|
||||
TestHelpers.draggable.shouldNotDrag( element, "option: disabled true" );
|
||||
|
||||
element.draggable( "option", "disabled", false );
|
||||
TestHelpers.draggable.shouldMove( element, "option: disabled false" );
|
||||
});
|
||||
|
||||
test( "{ grid: [50, 50] }, relative", function() {
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] });
|
||||
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" );
|
||||
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" );
|
||||
});
|
||||
|
||||
test( "{ grid: [50, 50] }, absolute", function() {
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] });
|
||||
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" );
|
||||
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" );
|
||||
});
|
||||
|
||||
test( "grid, switching after initialization", function() {
|
||||
expect( 8 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable();
|
||||
|
||||
// Forward
|
||||
TestHelpers.draggable.testDrag( element, element, 24, 24, 24, 24 );
|
||||
TestHelpers.draggable.testDrag( element, element, 0, 0, 0, 0 );
|
||||
TestHelpers.draggable.testDrag( element, element, 24, 24, 24, 24, "grid: default" );
|
||||
TestHelpers.draggable.testDrag( element, element, 0, 0, 0, 0, "grid: default" );
|
||||
|
||||
element.draggable( "option", "grid", [ 50,50 ] );
|
||||
|
||||
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 );
|
||||
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 );
|
||||
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" );
|
||||
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" );
|
||||
});
|
||||
|
||||
test( "{ handle: 'span' }", function() {
|
||||
expect( 3 );
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({ handle: "span" });
|
||||
|
||||
TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span" );
|
||||
TestHelpers.draggable.testDrag( element, "#draggable2 span em", 50, 50, 50, 50, "drag span child" );
|
||||
TestHelpers.draggable.shouldNotMove( element, "drag element" );
|
||||
TestHelpers.draggable.shouldMove( element, "handle: span", "#draggable2 span");
|
||||
TestHelpers.draggable.shouldMove( element, "handle: span child", "#draggable2 span em" );
|
||||
TestHelpers.draggable.shouldNotDrag( element, "handle: span element" );
|
||||
});
|
||||
|
||||
test( "handle, default, switching after initialization", function() {
|
||||
expect( 6 );
|
||||
expect( 10 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable();
|
||||
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 );
|
||||
TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 );
|
||||
TestHelpers.draggable.shouldMove( element, "handle: default, element dragged" );
|
||||
TestHelpers.draggable.shouldMove( element, "handle: default, span dragged", "#draggable2 span" );
|
||||
|
||||
// Switch
|
||||
element.draggable( "option", "handle", "span" );
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 0 );
|
||||
TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 );
|
||||
TestHelpers.draggable.shouldNotDrag( element, "handle: span as option, element dragged" );
|
||||
TestHelpers.draggable.shouldMove( element, "handle: span as option, span dragged", "#draggable2 span" );
|
||||
|
||||
// And back
|
||||
element.draggable( "option", "handle", false );
|
||||
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 );
|
||||
TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 );
|
||||
TestHelpers.draggable.shouldMove( element, "handle: false as option, element dragged" );
|
||||
TestHelpers.draggable.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" );
|
||||
});
|
||||
|
||||
test( "helper, default, switching after initialization", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable();
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "helper: default" );
|
||||
|
||||
element.draggable( "option", "helper", "clone" );
|
||||
TestHelpers.draggable.shouldNotMove( element );
|
||||
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone" );
|
||||
|
||||
element.draggable( "option", "helper", "original" );
|
||||
TestHelpers.draggable.shouldMove( element );
|
||||
TestHelpers.draggable.shouldMove( element, "helper: original" );
|
||||
});
|
||||
|
||||
test( "{ helper: 'clone' }, relative", function() {
|
||||
expect( 1 );
|
||||
expect( 2 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable({ helper: "clone" });
|
||||
TestHelpers.draggable.shouldNotMove( element );
|
||||
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone relative" );
|
||||
});
|
||||
|
||||
test( "{ helper: 'clone' }, absolute", function() {
|
||||
expect( 1 );
|
||||
expect( 2 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({ helper: "clone" });
|
||||
TestHelpers.draggable.shouldNotMove( element );
|
||||
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone absolute" );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, relative, with scroll offset on parent", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
TestHelpers.draggable.restoreScroll( "#main" );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, relative, with scroll offset on root", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll( "root" );
|
||||
TestHelpers.draggable.restoreScroll( document );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, relative, with scroll offset on root and parent", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
TestHelpers.draggable.restoreScroll( "root" );
|
||||
TestHelpers.draggable.restoreScroll( "#main" );
|
||||
TestHelpers.draggable.restoreScroll( document );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, absolute, with scroll offset on parent", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
TestHelpers.draggable.restoreScroll( "#main" );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, absolute, with scroll offset on root", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll( "root" );
|
||||
TestHelpers.draggable.restoreScroll( document );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, absolute, with scroll offset on root and parent", function() {
|
||||
expect( 3 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
TestHelpers.draggable.restoreScroll( "root" );
|
||||
TestHelpers.draggable.restoreScroll( "#main" );
|
||||
TestHelpers.draggable.restoreScroll( document );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, fixed, with scroll offset on parent", function() {
|
||||
expect( 3 );
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
// TODO: investigate these failure in PhantomJS
|
||||
//TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
TestHelpers.draggable.restoreScroll( "#main" );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, fixed, with scroll offset on root", function() {
|
||||
expect( 3 );
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
// TODO: investigate these failure in PhantomJS
|
||||
//TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll( "root" );
|
||||
TestHelpers.draggable.restoreScroll( document );
|
||||
});
|
||||
|
||||
test( "{ helper: 'original' }, fixed, with scroll offset on root and parent", function() {
|
||||
expect( 3 );
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "relative" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.testScroll( element, "static" );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
// TODO: investigate these failure in PhantomJS
|
||||
//TestHelpers.draggable.testScroll( element, "absolute" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
TestHelpers.draggable.restoreScroll( "root" );
|
||||
TestHelpers.draggable.restoreScroll( "#main" );
|
||||
TestHelpers.draggable.restoreScroll( document );
|
||||
});
|
||||
|
||||
test( "{ helper: 'clone' }, absolute", function() {
|
||||
@ -873,7 +873,7 @@ test( "{ helper: 'clone' }, absolute", function() {
|
||||
test( "{ helper: 'clone' }, absolute with scroll offset on parent", function() {
|
||||
expect( 3 );
|
||||
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
var helperOffset = null,
|
||||
origOffset = null,
|
||||
element = $( "#draggable1" ).draggable({
|
||||
@ -907,13 +907,13 @@ test( "{ helper: 'clone' }, absolute with scroll offset on parent", function() {
|
||||
});
|
||||
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
TestHelpers.draggable.restoreScroll( "#main" );
|
||||
});
|
||||
|
||||
test( "{ helper: 'clone' }, absolute with scroll offset on root", function() {
|
||||
expect( 3 );
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
var helperOffset = null,
|
||||
origOffset = null,
|
||||
element = $( "#draggable1" ).draggable({
|
||||
@ -947,14 +947,14 @@ test( "{ helper: 'clone' }, absolute with scroll offset on root", function() {
|
||||
});
|
||||
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll( "root" );
|
||||
TestHelpers.draggable.restoreScroll( document );
|
||||
});
|
||||
|
||||
test( "{ helper: 'clone' }, absolute with scroll offset on root and parent", function() {
|
||||
expect( 3 );
|
||||
|
||||
TestHelpers.draggable.setScroll( "root" );
|
||||
TestHelpers.draggable.setScroll();
|
||||
TestHelpers.draggable.setScroll( document );
|
||||
TestHelpers.draggable.setScroll( "#main" );
|
||||
|
||||
var helperOffset = null,
|
||||
origOffset = null,
|
||||
@ -989,8 +989,8 @@ test( "{ helper: 'clone' }, absolute with scroll offset on root and parent", fun
|
||||
});
|
||||
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
|
||||
|
||||
TestHelpers.draggable.restoreScroll( "root" );
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
TestHelpers.draggable.restoreScroll( document );
|
||||
TestHelpers.draggable.restoreScroll( "#main" );
|
||||
});
|
||||
|
||||
test( "{ opacity: 0.5 }", function() {
|
||||
@ -1035,16 +1035,16 @@ test( "opacity, default, switching after initialization", function() {
|
||||
});
|
||||
|
||||
asyncTest( "revert and revertDuration", function() {
|
||||
expect( 4 );
|
||||
expect( 7 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({
|
||||
revert: true,
|
||||
revertDuration: 0
|
||||
});
|
||||
TestHelpers.draggable.shouldNotMove( element, "revert: true, revertDuration: 0 should revert immediately" );
|
||||
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" );
|
||||
|
||||
$( "#draggable2" ).draggable( "option", "revert", "invalid" );
|
||||
TestHelpers.draggable.shouldNotMove( element, "revert: invalid, revertDuration: 0 should revert immediately" );
|
||||
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: invalid, revertDuration: 0 should revert immediately" );
|
||||
|
||||
$( "#draggable2" ).draggable( "option", "revert", false );
|
||||
TestHelpers.draggable.shouldMove( element, "revert: false should allow movement" );
|
||||
@ -1065,7 +1065,7 @@ asyncTest( "revert and revertDuration", function() {
|
||||
});
|
||||
|
||||
test( "revert: valid", function() {
|
||||
expect( 1 );
|
||||
expect( 2 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({
|
||||
revert: "valid",
|
||||
@ -1074,11 +1074,11 @@ test( "revert: valid", function() {
|
||||
|
||||
$( "#droppable" ).droppable();
|
||||
|
||||
TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" );
|
||||
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" );
|
||||
});
|
||||
|
||||
test( "scope", function() {
|
||||
expect( 2 );
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({
|
||||
scope: "tasks",
|
||||
@ -1088,11 +1088,11 @@ test( "scope", function() {
|
||||
|
||||
$( "#droppable" ).droppable({ scope: "tasks" });
|
||||
|
||||
TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable in scope" );
|
||||
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" );
|
||||
|
||||
$( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" });
|
||||
|
||||
TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable out of scope" );
|
||||
TestHelpers.draggable.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" );
|
||||
});
|
||||
|
||||
test( "scroll, scrollSensitivity, and scrollSpeed", function() {
|
||||
|
@ -6,27 +6,67 @@ TestHelpers.draggable = {
|
||||
var element = $( "<div>" );
|
||||
return $.contains( element[ 0 ].ownerDocument, element[ 0 ] );
|
||||
})(),
|
||||
testDragPosition: function( el, dx, dy, expectedDX, expectedDY, msg ) {
|
||||
msg = msg ? msg + "." : "";
|
||||
|
||||
$( el ).one( "dragstop", function( event, ui ) {
|
||||
var positionExpected = { left: ui.originalPosition.left + expectedDX, top: ui.originalPosition.top + expectedDY };
|
||||
deepEqual( ui.position, positionExpected, "position dragged[" + dx + ", " + dy + "] " + msg );
|
||||
} );
|
||||
},
|
||||
testDragOffset: function( el, dx, dy, expectedDX, expectedDY, msg ) {
|
||||
msg = msg ? msg + "." : "";
|
||||
|
||||
var offsetBefore = el.offset(),
|
||||
offsetExpected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
|
||||
|
||||
$( el ).one( "dragstop", function() {
|
||||
deepEqual( el.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
|
||||
} );
|
||||
},
|
||||
testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) {
|
||||
var offsetAfter, actual, expected,
|
||||
offsetBefore = el.offset();
|
||||
TestHelpers.draggable.testDragPosition( el, dx, dy, expectedDX, expectedDY, msg );
|
||||
TestHelpers.draggable.testDragOffset( el, dx, dy, expectedDX, expectedDY, msg );
|
||||
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: dx,
|
||||
dy: dy
|
||||
dy: dy,
|
||||
// moves is 1 here because simulate currently fire events synchronously
|
||||
// so we can't faithfully test things that rely on a scroll event (which is async)
|
||||
moves: 1
|
||||
});
|
||||
offsetAfter = el.offset();
|
||||
|
||||
actual = { left: offsetAfter.left, top: offsetAfter.top };
|
||||
expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
|
||||
|
||||
msg = msg ? msg + "." : "";
|
||||
deepEqual( actual, expected, "dragged[" + dx + ", " + dy + "] " + msg );
|
||||
},
|
||||
shouldMove: function( el, why ) {
|
||||
TestHelpers.draggable.testDrag( el, el, 50, 50, 50, 50, why );
|
||||
shouldMovePositionButNotOffset: function( el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
TestHelpers.draggable.testDragPosition( el, 100, 100, 100, 100, msg );
|
||||
TestHelpers.draggable.testDragOffset( el, 100, 100, 0, 0, msg );
|
||||
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: 100,
|
||||
dy: 100,
|
||||
// moves is 1 here because simulate currently fire events synchronously
|
||||
// so we can't faithfully test things that rely on a scroll event (which is async)
|
||||
moves: 1
|
||||
});
|
||||
},
|
||||
shouldNotMove: function( el, why ) {
|
||||
TestHelpers.draggable.testDrag( el, el, 50, 50, 0, 0, why );
|
||||
shouldMove: function( el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
TestHelpers.draggable.testDrag( el, handle, 100, 100, 100, 100, msg );
|
||||
},
|
||||
shouldNotMove: function( el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
TestHelpers.draggable.testDrag( el, handle, 100, 100, 0, 0, msg );
|
||||
},
|
||||
shouldNotDrag: function( el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
$( el ).bind( "dragstop", function() {
|
||||
ok( false, "should not drag " + msg );
|
||||
} );
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: 100,
|
||||
dy: 100
|
||||
});
|
||||
$( el ).unbind( "dragstop" );
|
||||
},
|
||||
testScroll: function( el, position ) {
|
||||
var oldPosition = $( "#main" ).css( "position" );
|
||||
@ -35,20 +75,10 @@ TestHelpers.draggable = {
|
||||
$( "#main" ).css( "position", oldPosition );
|
||||
},
|
||||
restoreScroll: function( what ) {
|
||||
if( what ) {
|
||||
$( document ).scrollTop( 0 ).scrollLeft( 0 );
|
||||
} else {
|
||||
$( "#main" ).scrollTop( 0 ).scrollLeft( 0 );
|
||||
}
|
||||
$( what ).scrollTop( 0 ).scrollLeft( 0 );
|
||||
},
|
||||
setScroll: function( what ) {
|
||||
if( what ) {
|
||||
// TODO: currently, the draggable interaction doesn't properly account for scrolled pages,
|
||||
// uncomment the line below to make the tests fail that should when the page is scrolled
|
||||
// $( document ).scrollTop( 100 ).scrollLeft( 100 );
|
||||
} else {
|
||||
$( "#main" ).scrollTop( 100 ).scrollLeft( 100 );
|
||||
}
|
||||
$( what ).scrollTop( 100 ).scrollLeft( 100 );
|
||||
},
|
||||
border: function( el, side ) {
|
||||
return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0;
|
||||
|
@ -45,4 +45,17 @@ asyncTest( "#9044: Autofocus issue with dialog opened from menu widget", functio
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "#9532: Need a way in Menu to keep ui-state-active class on selected item for Selectmenu", function() {
|
||||
expect( 1 );
|
||||
var element = $( "#menu1" ).menu(),
|
||||
firstChild = element.children().eq( 0 );
|
||||
|
||||
element.menu( "focus", null, firstChild );
|
||||
firstChild.addClass( "ui-state-active" );
|
||||
setTimeout( function() {
|
||||
ok( firstChild.is( ".ui-state-active" ), "ui-state-active improperly removed" );
|
||||
start();
|
||||
}, 500 );
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
@ -191,4 +191,19 @@ test("resizable accounts for scroll position correctly (#3815)", function() {
|
||||
equal( el.css("top"), top, "css('top') stays the same when resized" );
|
||||
});
|
||||
|
||||
test( "resizable stores correct size when using helper and grid (#9547)", function() {
|
||||
expect( 2 );
|
||||
|
||||
var handle = ".ui-resizable-se",
|
||||
target = $( "#resizable1" ).resizable({
|
||||
handles: "all",
|
||||
helper: "ui-resizable-helper",
|
||||
grid: [ 10, 10 ]
|
||||
});
|
||||
|
||||
TestHelpers.resizable.drag( handle, 1, 1 );
|
||||
equal( target.width(), 100, "compare width" );
|
||||
equal( target.height(), 100, "compare height" );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -40,12 +40,8 @@ test( "mousedown: initial position of helper", function() {
|
||||
|
||||
var helperOffset,
|
||||
element = $( "#selectable1" ).selectable(),
|
||||
contentToForceScroll = $( "<div>" ).css({
|
||||
height: "10000px",
|
||||
width: "10000px"
|
||||
});
|
||||
contentToForceScroll = TestHelpers.forceScrollableWindow( "body" );
|
||||
|
||||
contentToForceScroll.appendTo( "body" );
|
||||
$( window ).scrollTop( 100 ).scrollLeft( 100 );
|
||||
|
||||
element.simulate( "mousedown", {
|
||||
|
@ -191,6 +191,13 @@ TestHelpers.onFocus= function( element, onFocus ) {
|
||||
element.bind( "focus", fn )[ 0 ].focus();
|
||||
};
|
||||
|
||||
TestHelpers.forceScrollableWindow = function( appendTo ) {
|
||||
return $( "<div>" ).css({
|
||||
height: "10000px",
|
||||
width: "10000px"
|
||||
}).appendTo( appendTo || "#qunit-fixture" );
|
||||
};
|
||||
|
||||
/*
|
||||
* Taken from https://github.com/jquery/qunit/tree/master/addons/close-enough
|
||||
*/
|
||||
|
@ -535,7 +535,7 @@ test( ".option() - delegate to ._setOptions()", function() {
|
||||
});
|
||||
|
||||
test( ".option() - delegate to ._setOption()", function() {
|
||||
expect( 2 );
|
||||
expect( 3 );
|
||||
var div,
|
||||
calls = [];
|
||||
$.widget( "ui.testWidget", {
|
||||
@ -554,6 +554,11 @@ test( ".option() - delegate to ._setOption()", function() {
|
||||
deepEqual( calls, [{ key: "foo", val: "bar" }],
|
||||
"_setOption called for single option" );
|
||||
|
||||
calls = [];
|
||||
div.testWidget( "option", "foo", undefined );
|
||||
deepEqual( calls, [{ key: "foo", val: undefined }],
|
||||
"_setOption called for single option where value is undefined" );
|
||||
|
||||
calls = [];
|
||||
div.testWidget( "option", {
|
||||
bar: "qux",
|
||||
@ -566,9 +571,9 @@ test( ".option() - delegate to ._setOption()", function() {
|
||||
});
|
||||
|
||||
test( ".option() - deep option setter", function() {
|
||||
expect( 6 );
|
||||
expect( 9 );
|
||||
$.widget( "ui.testWidget", {} );
|
||||
var div = $( "<div>" ).testWidget();
|
||||
var result, div = $( "<div>" ).testWidget();
|
||||
function deepOption( from, to, msg ) {
|
||||
div.testWidget( "instance" ).options.foo = from;
|
||||
$.ui.testWidget.prototype._setOption = function( key, value ) {
|
||||
@ -580,6 +585,12 @@ test( ".option() - deep option setter", function() {
|
||||
deepOption( { bar: "baz" }, { bar: "qux" }, "one deep" );
|
||||
div.testWidget( "option", "foo.bar", "qux" );
|
||||
|
||||
deepOption( { bar: "baz" }, { bar: undefined }, "one deep - value = undefined" );
|
||||
|
||||
result = div.testWidget( "option", "foo.bar", undefined );
|
||||
|
||||
deepEqual ( result, div, "option should return widget on successful set operation" );
|
||||
|
||||
deepOption( null, { bar: "baz" }, "null" );
|
||||
div.testWidget( "option", "foo.bar", "baz" );
|
||||
|
||||
|
2
ui/i18n/jquery.ui.datepicker-fi.js
vendored
2
ui/i18n/jquery.ui.datepicker-fi.js
vendored
@ -14,7 +14,7 @@ jQuery(function($){
|
||||
dayNames: ['Sunnuntai','Maanantai','Tiistai','Keskiviikko','Torstai','Perjantai','Lauantai'],
|
||||
dayNamesMin: ['Su','Ma','Ti','Ke','To','Pe','La'],
|
||||
weekHeader: 'Vk',
|
||||
dateFormat: 'dd.mm.yy',
|
||||
dateFormat: 'd.m.yy',
|
||||
firstDay: 1,
|
||||
isRTL: false,
|
||||
showMonthAfterYear: false,
|
||||
|
2
ui/jquery.ui.autocomplete.js
vendored
2
ui/jquery.ui.autocomplete.js
vendored
@ -294,7 +294,7 @@ $.widget( "ui.autocomplete", {
|
||||
"aria-live": "polite"
|
||||
})
|
||||
.addClass( "ui-helper-hidden-accessible" )
|
||||
.insertBefore( this.element );
|
||||
.appendTo( this.document[ 0 ].body );
|
||||
|
||||
// turning off autocomplete prevents the browser from remembering the
|
||||
// value when navigating through history, so we re-enable autocomplete
|
||||
|
24
ui/jquery.ui.draggable.js
vendored
24
ui/jquery.ui.draggable.js
vendored
@ -166,7 +166,7 @@ $.widget("ui.draggable", $.ui.mouse, {
|
||||
});
|
||||
|
||||
//Generate the original position
|
||||
this.originalPosition = this.position = this._generatePosition(event);
|
||||
this.originalPosition = this.position = this._generatePosition( event, false );
|
||||
this.originalPageX = event.pageX;
|
||||
this.originalPageY = event.pageY;
|
||||
|
||||
@ -208,7 +208,7 @@ $.widget("ui.draggable", $.ui.mouse, {
|
||||
}
|
||||
|
||||
//Compute the helpers position
|
||||
this.position = this._generatePosition(event);
|
||||
this.position = this._generatePosition( event, true );
|
||||
this.positionAbs = this._convertPositionTo("absolute");
|
||||
|
||||
//Call plugins and callbacks and use the resulting position if something is returned
|
||||
@ -221,12 +221,9 @@ $.widget("ui.draggable", $.ui.mouse, {
|
||||
this.position = ui.position;
|
||||
}
|
||||
|
||||
if(!this.options.axis || this.options.axis !== "y") {
|
||||
this.helper[0].style.left = this.position.left+"px";
|
||||
}
|
||||
if(!this.options.axis || this.options.axis !== "x") {
|
||||
this.helper[0].style.top = this.position.top+"px";
|
||||
}
|
||||
this.helper[ 0 ].style.left = this.position.left + "px";
|
||||
this.helper[ 0 ].style.top = this.position.top + "px";
|
||||
|
||||
if($.ui.ddmanager) {
|
||||
$.ui.ddmanager.drag(this, event);
|
||||
}
|
||||
@ -491,7 +488,7 @@ $.widget("ui.draggable", $.ui.mouse, {
|
||||
|
||||
},
|
||||
|
||||
_generatePosition: function(event) {
|
||||
_generatePosition: function( event, constrainPosition ) {
|
||||
|
||||
var containment, co, top, left,
|
||||
o = this.options,
|
||||
@ -516,7 +513,7 @@ $.widget("ui.draggable", $.ui.mouse, {
|
||||
*/
|
||||
|
||||
// If we are not dragging yet, we won't check for options
|
||||
if ( this.originalPosition ) {
|
||||
if ( constrainPosition ) {
|
||||
if ( this.containment ) {
|
||||
if ( this.relative_container ){
|
||||
co = this.relative_container.offset();
|
||||
@ -554,6 +551,13 @@ $.widget("ui.draggable", $.ui.mouse, {
|
||||
pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
|
||||
}
|
||||
|
||||
if ( o.axis === "y" ) {
|
||||
pageX = this.originalPageX;
|
||||
}
|
||||
|
||||
if ( o.axis === "x" ) {
|
||||
pageY = this.originalPageY;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
4
ui/jquery.ui.menu.js
vendored
4
ui/jquery.ui.menu.js
vendored
@ -371,7 +371,7 @@ $.widget( "ui.menu", {
|
||||
this._scrollIntoView( item );
|
||||
|
||||
this.active = item.first();
|
||||
focused = this.active.addClass( "ui-state-focus" );
|
||||
focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
|
||||
// Only update aria-activedescendant if there's a role
|
||||
// otherwise we assume focus is managed elsewhere
|
||||
if ( this.options.role ) {
|
||||
@ -498,7 +498,7 @@ $.widget( "ui.menu", {
|
||||
.attr( "aria-hidden", "true" )
|
||||
.attr( "aria-expanded", "false" )
|
||||
.end()
|
||||
.find( ".ui-state-active" )
|
||||
.find( ".ui-state-active" ).not( ".ui-state-focus" )
|
||||
.removeClass( "ui-state-active" );
|
||||
},
|
||||
|
||||
|
2
ui/jquery.ui.resizable.js
vendored
2
ui/jquery.ui.resizable.js
vendored
@ -316,7 +316,7 @@ $.widget("ui.resizable", $.ui.mouse, {
|
||||
//Store needed variables
|
||||
this.offset = this.helper.offset();
|
||||
this.position = { left: curleft, top: curtop };
|
||||
this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
|
||||
this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
|
||||
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
|
||||
this.originalPosition = { left: curleft, top: curtop };
|
||||
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
|
||||
|
2
ui/jquery.ui.slider.js
vendored
2
ui/jquery.ui.slider.js
vendored
@ -322,7 +322,7 @@ $.widget( "ui.slider", $.ui.mouse, {
|
||||
} );
|
||||
otherVal = this.values( index ? 0 : 1 );
|
||||
if ( allowed !== false ) {
|
||||
this.values( index, newVal, true );
|
||||
this.values( index, newVal );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
6
ui/jquery.ui.sortable.js
vendored
6
ui/jquery.ui.sortable.js
vendored
@ -354,12 +354,12 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
}
|
||||
|
||||
// Only put the placeholder inside the current Container, skip all
|
||||
// items form other containers. This works because when moving
|
||||
// items from other containers. This works because when moving
|
||||
// an item from one container to another the
|
||||
// currentContainer is switched before the placeholder is moved.
|
||||
//
|
||||
// Without this moving items in "sub-sortables" can cause the placeholder to jitter
|
||||
// beetween the outer and inner container.
|
||||
// Without this, moving items in "sub-sortables" can cause
|
||||
// the placeholder to jitter beetween the outer and inner container.
|
||||
if (item.instance !== this.currentContainer) {
|
||||
continue;
|
||||
}
|
||||
|
4
ui/jquery.ui.widget.js
vendored
4
ui/jquery.ui.widget.js
vendored
@ -321,12 +321,12 @@ $.Widget.prototype = {
|
||||
curOption = curOption[ parts[ i ] ];
|
||||
}
|
||||
key = parts.pop();
|
||||
if ( value === undefined ) {
|
||||
if ( arguments.length === 1 ) {
|
||||
return curOption[ key ] === undefined ? null : curOption[ key ];
|
||||
}
|
||||
curOption[ key ] = value;
|
||||
} else {
|
||||
if ( value === undefined ) {
|
||||
if ( arguments.length === 1 ) {
|
||||
return this.options[ key ] === undefined ? null : this.options[ key ];
|
||||
}
|
||||
options[ key ] = value;
|
||||
|
Loading…
Reference in New Issue
Block a user