mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-07-03 16:48:57 +03:00
Remove broken jquery-ui
This commit is contained in:
parent
39aa35f2aa
commit
d3488a963e
718 changed files with 10 additions and 518340 deletions
|
@ -1,26 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Draggable Test Suite</title>
|
||||
|
||||
<script src="../../../external/jquery/jquery.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
|
||||
<script src="../subsuite.js"></script>
|
||||
|
||||
<script>
|
||||
testAllVersions( "draggable" );
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
48
jquery-ui/tests/unit/draggable/common.js
vendored
48
jquery-ui/tests/unit/draggable/common.js
vendored
|
@ -1,48 +0,0 @@
|
|||
define( [
|
||||
"lib/common",
|
||||
"ui/widgets/draggable"
|
||||
], function( common ) {
|
||||
|
||||
common.testWidget( "draggable", {
|
||||
defaults: {
|
||||
appendTo: "parent",
|
||||
axis: false,
|
||||
cancel: "input, textarea, button, select, option",
|
||||
classes: {},
|
||||
connectToSortable: false,
|
||||
containment: false,
|
||||
cursor: "auto",
|
||||
cursorAt: false,
|
||||
disabled: false,
|
||||
grid: false,
|
||||
handle: false,
|
||||
helper: "original",
|
||||
opacity: false,
|
||||
refreshPositions: false,
|
||||
revert: false,
|
||||
revertDuration: 500,
|
||||
scroll: true,
|
||||
scrollSensitivity: 20,
|
||||
scrollSpeed: 20,
|
||||
scope: "default",
|
||||
snap: false,
|
||||
snapMode: "both",
|
||||
snapTolerance: 20,
|
||||
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,
|
||||
start: null,
|
||||
stop: null
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
394
jquery-ui/tests/unit/draggable/core.js
vendored
394
jquery-ui/tests/unit/draggable/core.js
vendored
|
@ -1,394 +0,0 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/draggable",
|
||||
"ui/widgets/droppable",
|
||||
"ui/widgets/resizable"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
QUnit.module( "draggable: core" );
|
||||
|
||||
QUnit.test( "element types", function( assert ) {
|
||||
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( "," );
|
||||
|
||||
assert.expect( typeNames.length * 2 );
|
||||
|
||||
$.each( typeNames, function( i ) {
|
||||
var offsetBefore, offsetAfter,
|
||||
typeName = typeNames[ i ],
|
||||
el = $( document.createElement( typeName ) ).appendTo( "#qunit-fixture" );
|
||||
|
||||
if ( typeName === "table" ) {
|
||||
el.append( "<tr><td>content</td></tr>" );
|
||||
}
|
||||
|
||||
el.draggable( { cancel: "" } );
|
||||
offsetBefore = el.offset();
|
||||
el.simulate( "drag", {
|
||||
dx: 50,
|
||||
dy: 50
|
||||
} );
|
||||
offsetAfter = el.offset();
|
||||
|
||||
// Support: FF, Chrome, and IE9,
|
||||
// there are some rounding errors in so we can't say equal, we have to settle for close enough
|
||||
assert.close( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + "> left" );
|
||||
assert.close( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + "> top" );
|
||||
el.draggable( "destroy" );
|
||||
el.remove();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "No options, relative", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
testHelper.shouldMove( assert, $( "#draggable1" ).draggable(), "no options, relative" );
|
||||
} );
|
||||
|
||||
QUnit.test( "No options, absolute", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
testHelper.shouldMove( assert, $( "#draggable2" ).draggable(), "no options, absolute" );
|
||||
} );
|
||||
|
||||
QUnit.test( "resizable handle with complex markup (#8756 / #8757)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
$( "#draggable1" )
|
||||
.append(
|
||||
$( "<div>" )
|
||||
.addClass( "ui-resizable-handle ui-resizable-w" )
|
||||
.append( $( "<div>" ) )
|
||||
);
|
||||
|
||||
var handle = $( ".ui-resizable-w div" ),
|
||||
target = $( "#draggable1" ).draggable().resizable( { handles: "all" } );
|
||||
|
||||
// Todo: fix resizable so it doesn't require a mouseover
|
||||
handle.simulate( "mouseover" ).simulate( "drag", { dx: -50 } );
|
||||
assert.equal( target.width(), 250, "compare width" );
|
||||
|
||||
// Todo: fix resizable so it doesn't require a mouseover
|
||||
handle.simulate( "mouseover" ).simulate( "drag", { dx: 50 } );
|
||||
assert.equal( target.width(), 200, "compare width" );
|
||||
} );
|
||||
|
||||
QUnit.test( "#8269: Removing draggable element on drop", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable( {
|
||||
stop: function() {
|
||||
assert.ok( true, "stop still called despite element being removed from DOM on drop" );
|
||||
}
|
||||
} ),
|
||||
dropOffset = $( "#droppable" ).offset();
|
||||
|
||||
$( "#droppable" ).droppable( {
|
||||
drop: function() {
|
||||
$( "#wrapper" ).remove();
|
||||
assert.ok( true, "element removed from DOM on drop" );
|
||||
}
|
||||
} );
|
||||
|
||||
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
|
||||
if ( testHelper.unreliableContains ) {
|
||||
assert.ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
||||
assert.ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
||||
} else {
|
||||
element.simulate( "drag", {
|
||||
handle: "corner",
|
||||
x: dropOffset.left,
|
||||
y: dropOffset.top
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
// http://bugs.jqueryui.com/ticket/7778
|
||||
// drag element breaks in IE8 when its content is replaced onmousedown
|
||||
QUnit.test( "Stray mousemove after mousedown still drags", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable( { scroll: false } );
|
||||
|
||||
// In IE8, when content is placed under the mouse (e.g. when draggable content is replaced
|
||||
// on mousedown), mousemove is triggered on those elements even though the mouse hasn't moved.
|
||||
// Support: IE <9
|
||||
element.on( "mousedown", function() {
|
||||
$( document ).simulate( "mousemove", { button: -1 } );
|
||||
} );
|
||||
|
||||
testHelper.shouldMove( assert, element, "element is draggable" );
|
||||
} );
|
||||
|
||||
QUnit.test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable( {
|
||||
stop: function( event, ui ) {
|
||||
assert.equal( ui.position.left, 1, "left position is correct despite overflow on HTML" );
|
||||
assert.equal( ui.position.top, 1, "top position is correct despite overflow on HTML" );
|
||||
$( "html" )
|
||||
.css( "overflow-y", oldOverflowY )
|
||||
.css( "overflow-x", oldOverflowX )
|
||||
.scrollTop( 0 )
|
||||
.scrollLeft( 0 );
|
||||
}
|
||||
} ),
|
||||
oldOverflowY = $( "html" ).css( "overflow-y" ),
|
||||
oldOverflowX = $( "html" ).css( "overflow-x" );
|
||||
|
||||
testHelper.forceScrollableWindow();
|
||||
|
||||
$( "html" )
|
||||
.css( "overflow-y", "scroll" )
|
||||
.css( "overflow-x", "scroll" )
|
||||
.scrollTop( 300 )
|
||||
.scrollLeft( 300 );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1,
|
||||
moves: 1
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "#9315: jumps down with offset of scrollbar", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable( {
|
||||
stop: function( event, ui ) {
|
||||
assert.equal( ui.position.left, 11, "left position is correct when position is absolute" );
|
||||
assert.equal( ui.position.top, 11, "top position is correct when position is absolute" );
|
||||
$( "html" ).scrollTop( 0 ).scrollLeft( 0 );
|
||||
}
|
||||
} );
|
||||
|
||||
testHelper.forceScrollableWindow();
|
||||
|
||||
$( "html" ).scrollTop( 300 ).scrollLeft( 300 );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1,
|
||||
moves: 1
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "scroll offset with fixed ancestors", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var startValue = 300,
|
||||
element = $( "#draggable1" )
|
||||
|
||||
// http://bugs.jqueryui.com/ticket/5009
|
||||
// scroll not working with parent's position fixed
|
||||
.wrap( "<div id='wrapper' />" )
|
||||
|
||||
// http://bugs.jqueryui.com/ticket/9612
|
||||
// abspos elements inside of fixed elements moving away from the mouse when scrolling
|
||||
.wrap( "<div id='wrapper2' />" )
|
||||
.draggable( {
|
||||
drag: function() {
|
||||
startValue += 100;
|
||||
$( document ).scrollTop( startValue ).scrollLeft( startValue );
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
assert.equal( ui.position.left, 10, "left position is correct when parent position is fixed" );
|
||||
assert.equal( ui.position.top, 10, "top position is correct when parent position is fixed" );
|
||||
$( document ).scrollTop( 0 ).scrollLeft( 0 );
|
||||
}
|
||||
} );
|
||||
|
||||
testHelper.forceScrollableWindow();
|
||||
|
||||
$( "#wrapper" ).css( "position", "fixed" );
|
||||
$( "#wrapper2" ).css( "position", "absolute" );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10,
|
||||
moves: 3
|
||||
} );
|
||||
} );
|
||||
|
||||
$( [ "hidden", "auto", "scroll" ] ).each( function() {
|
||||
var overflow = this;
|
||||
|
||||
// Http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div
|
||||
// http://bugs.jqueryui.com/ticket/10147 - Wrong position in a parent with "overflow: hidden"
|
||||
QUnit.test( "position in scrollable parent with overflow: " + overflow, function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
$( "#qunit-fixture" ).html( "<div id='outer'><div id='inner'></div><div id='dragged'>a</div></div>" );
|
||||
$( "#inner" ).css( { position: "absolute", width: "500px", height: "500px" } );
|
||||
$( "#outer" ).css( { position: "absolute", width: "300px", height: "300px" } );
|
||||
$( "#dragged" ).css( { width: "10px", height: "10px" } );
|
||||
|
||||
var moves = 3,
|
||||
startValue = 0,
|
||||
dragDelta = 20,
|
||||
delta = 100,
|
||||
|
||||
// We scroll after each drag event, so subtract 1 from number of moves for expected
|
||||
expected = delta + ( ( moves - 1 ) * dragDelta ),
|
||||
element = $( "#dragged" ).draggable( {
|
||||
drag: function() {
|
||||
startValue += dragDelta;
|
||||
$( "#outer" ).scrollTop( startValue ).scrollLeft( startValue );
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
assert.equal( ui.position.left, expected, "left position is correct when grandparent is scrolled" );
|
||||
assert.equal( ui.position.top, expected, "top position is correct when grandparent is scrolled" );
|
||||
}
|
||||
} );
|
||||
|
||||
$( "#outer" ).css( "overflow", overflow );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dy: delta,
|
||||
dx: delta,
|
||||
moves: moves
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "#5727: draggable from iframe", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var iframeBody, draggable1,
|
||||
iframe = $( "<iframe />" ).appendTo( "#qunit-fixture" ),
|
||||
iframeDoc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
|
||||
|
||||
iframeDoc.write( "<!doctype html><html><body>" );
|
||||
iframeDoc.close();
|
||||
|
||||
iframeBody = $( iframeDoc.body ).append( "<div style='width: 2px; height: 2px;' />" );
|
||||
draggable1 = iframeBody.find( "div" );
|
||||
|
||||
draggable1.draggable();
|
||||
|
||||
assert.equal( draggable1.closest( iframeBody ).length, 1 );
|
||||
|
||||
// TODO: fix draggable within an IFRAME to fire events on the element properly
|
||||
// and these testHelper.shouldMove relies on events for testing
|
||||
//testHelper.shouldMove( assert, draggable1, "draggable from an iframe" );
|
||||
} );
|
||||
|
||||
QUnit.test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var element = $( "<a href='#'>link</a>" ).appendTo( "#qunit-fixture" ).draggable();
|
||||
|
||||
$( document ).one( "mousemove", function() {
|
||||
assert.notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" );
|
||||
} );
|
||||
|
||||
testHelper.move( element, 50, 50 );
|
||||
|
||||
assert.strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" );
|
||||
} );
|
||||
|
||||
QUnit.test( "blur behavior - handle is main element", function( assert ) {
|
||||
var ready = assert.async();
|
||||
assert.expect( 3 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable(),
|
||||
focusElement = $( "<div tabindex='1'></div>" ).appendTo( element );
|
||||
|
||||
testHelper.onFocus( focusElement, function() {
|
||||
assert.strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused before mousing down on a draggable" );
|
||||
|
||||
testHelper.move( focusElement, 1, 1 );
|
||||
|
||||
// Http://bugs.jqueryui.com/ticket/10527
|
||||
// Draggable: Can't select option in modal dialog (IE8)
|
||||
assert.strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused after mousing down on itself" );
|
||||
|
||||
testHelper.move( element, 50, 50 );
|
||||
|
||||
// Http://bugs.jqueryui.com/ticket/4261
|
||||
// active element should blur when mousing down on a draggable
|
||||
assert.notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" );
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "blur behavior - descendant of handle", function( assert ) {
|
||||
var ready = assert.async();
|
||||
assert.expect( 2 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable( { handle: "span" } ),
|
||||
|
||||
// The handle is a descendant, but we also want to grab a descendant of the handle
|
||||
handle = element.find( "span em" ),
|
||||
focusElement = $( "<div tabindex='1'></div>" ).appendTo( element );
|
||||
|
||||
testHelper.onFocus( focusElement, function() {
|
||||
assert.strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused before mousing down on a draggable" );
|
||||
|
||||
testHelper.move( handle, 50, 50 );
|
||||
|
||||
// Elements outside of the handle should blur (#12472, #14905)
|
||||
assert.notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" );
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "ui-draggable-handle assigned to appropriate element", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var p = $( "<p>" ).appendTo( "#qunit-fixture" ),
|
||||
element = $( "<div><p></p></div>" ).appendTo( "#qunit-fixture" ).draggable();
|
||||
assert.hasClasses( element, "ui-draggable-handle" );
|
||||
|
||||
element.draggable( "option", "handle", "p" );
|
||||
assert.lacksClasses( element, "ui-draggable-handle" );
|
||||
assert.hasClasses( element.find( "p" ), "ui-draggable-handle",
|
||||
"ensure handle class name is constrained within the draggble (#10212)" );
|
||||
assert.lacksClasses( p, "ui-draggable-handle" );
|
||||
|
||||
element.draggable( "destroy" );
|
||||
assert.lacksClasses( element.find( "p" ), "ui-draggable-handle" );
|
||||
} );
|
||||
|
||||
QUnit.test( "ui-draggable-handle managed correctly in nested draggables", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
var parent = $( "<div><div></div></div>" ).draggable().appendTo( "#qunit-fixture" ),
|
||||
child = parent.find( "div" ).draggable();
|
||||
|
||||
assert.hasClasses( parent, "ui-draggable-handle", "parent has class name on init" );
|
||||
assert.hasClasses( child, "ui-draggable-handle", "child has class name on init" );
|
||||
|
||||
parent.draggable( "destroy" );
|
||||
assert.lacksClasses( parent, "ui-draggable-handle", "parent loses class name on destroy" );
|
||||
assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" );
|
||||
} );
|
||||
|
||||
// Support: IE 8 only
|
||||
// IE 8 implements DOM Level 2 Events which only has events bubble up to the document.
|
||||
// We skip this test since it would be impossible for it to pass in such an environment.
|
||||
QUnit[ document.documentMode === 8 ? "skip" : "test" ](
|
||||
"does not stop propagation to window",
|
||||
function( assert ) {
|
||||
assert.expect( 1 );
|
||||
var element = $( "#draggable1" ).draggable();
|
||||
|
||||
var handler = function() {
|
||||
assert.ok( true, "mouseup propagates to window" );
|
||||
};
|
||||
$( window ).on( "mouseup", handler );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
} );
|
||||
|
||||
$( window ).off( "mouseup", handler );
|
||||
}
|
||||
);
|
||||
|
||||
} );
|
|
@ -1,98 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Draggable Test Suite</title>
|
||||
|
||||
<script src="../../../external/requirejs/require.js"></script>
|
||||
<script src="../../lib/css.js" data-modules="core"></script>
|
||||
<script src="../../lib/bootstrap.js" data-widget="draggable"></script>
|
||||
<style>
|
||||
#main {
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
overflow: scroll;
|
||||
overflow-x: scroll;
|
||||
overflow-y: scroll;
|
||||
position: relative;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
#main-forceScrollable {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 1100px;
|
||||
height: 1100px;
|
||||
}
|
||||
#scrollParent {
|
||||
width: 1200px;
|
||||
height: 1200px;
|
||||
position: relative;
|
||||
left: 0;
|
||||
top: 0;
|
||||
overflow: hidden;
|
||||
overflow-x: hidden;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
#scrollParent-forceScrollable {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 1300px;
|
||||
height: 1300px;
|
||||
}
|
||||
/* See #9077 */
|
||||
#draggable3, #draggable4 {
|
||||
z-index: 100;
|
||||
}
|
||||
.sortable {
|
||||
position: relative;
|
||||
top: 800px;
|
||||
left: 10px;
|
||||
width: 300px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
.sortable li {
|
||||
height: 100px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
list-style: none;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div id="scrollParent">
|
||||
<div id="main">
|
||||
<div id="draggable1" style="background: green; width: 200px; height: 100px; position: relative; top: 0; left: 0;">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-forceScrollable"></div>
|
||||
</div>
|
||||
<div id="scrollParent-forceScrollable"></div>
|
||||
</div>
|
||||
<div style="width: 1px; height: 1000px;"></div>
|
||||
<div style="position: absolute; width: 1px; height: 2000px;"></div>
|
||||
<ul id="sortable" class="sortable">
|
||||
<li id="draggableSortable">Item 0</li>
|
||||
<li id="draggableSortable2">Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
</ul>
|
||||
<ul id="sortable2" class="sortable">
|
||||
<li id="draggableSortableClone" class="sortable2Item">Item 0</li>
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
165
jquery-ui/tests/unit/draggable/events.js
vendored
165
jquery-ui/tests/unit/draggable/events.js
vendored
|
@ -1,165 +0,0 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"ui/widgets/draggable"
|
||||
], function( QUnit, $ ) {
|
||||
|
||||
var element;
|
||||
|
||||
QUnit.module( "draggable: events", {
|
||||
beforeEach: function() {
|
||||
element = $( "<div>" ).appendTo( "#qunit-fixture" );
|
||||
},
|
||||
afterEach: function() {
|
||||
element.draggable( "destroy" );
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( "callbacks occurrence count", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var start = 0,
|
||||
stop = 0,
|
||||
dragc = 0;
|
||||
|
||||
element.draggable( {
|
||||
start: function() {
|
||||
start++;
|
||||
},
|
||||
drag: function() {
|
||||
dragc++;
|
||||
},
|
||||
stop: function() {
|
||||
stop++;
|
||||
}
|
||||
} );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
} );
|
||||
|
||||
assert.equal( start, 1, "start callback should happen exactly once" );
|
||||
assert.equal( dragc, 3, "drag callback should happen exactly once per mousemove" );
|
||||
assert.equal( stop, 1, "stop callback should happen exactly once" );
|
||||
} );
|
||||
|
||||
QUnit.test( "stopping the start callback", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var start = 0,
|
||||
stop = 0,
|
||||
dragc = 0;
|
||||
|
||||
element.draggable( {
|
||||
start: function() {
|
||||
start++;
|
||||
return false;
|
||||
},
|
||||
drag: function() {
|
||||
dragc++;
|
||||
},
|
||||
stop: function() {
|
||||
stop++;
|
||||
}
|
||||
} );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
} );
|
||||
|
||||
assert.equal( start, 1, "start callback should happen exactly once" );
|
||||
assert.equal( dragc, 0, "drag callback should not happen at all" );
|
||||
assert.equal( stop, 0, "stop callback should not happen if there wasnt even a start" );
|
||||
} );
|
||||
|
||||
QUnit.test( "stopping the drag callback", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var start = 0,
|
||||
stop = 0,
|
||||
dragc = 0;
|
||||
|
||||
element.draggable( {
|
||||
start: function() {
|
||||
start++;
|
||||
},
|
||||
drag: function() {
|
||||
dragc++;
|
||||
return false;
|
||||
},
|
||||
stop: function() {
|
||||
stop++;
|
||||
}
|
||||
} );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
} );
|
||||
|
||||
assert.equal( start, 1, "start callback should happen exactly once" );
|
||||
assert.equal( stop, 1, "stop callback should happen, as we need to actively stop the drag" );
|
||||
} );
|
||||
|
||||
QUnit.test( "stopping the stop callback", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
element.draggable( {
|
||||
helper: "clone",
|
||||
stop: function() {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
} );
|
||||
|
||||
assert.ok( element.draggable( "instance" ).helper, "the clone should not be deleted if the stop callback is stopped" );
|
||||
} );
|
||||
|
||||
// http://bugs.jqueryui.com/ticket/6884
|
||||
// Draggable: ui.offset.left differs between the "start" and "drag" hooks
|
||||
QUnit.test( "position and offset in hash is consistent between start, drag, and stop", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var startPos, startOffset, dragPos, dragOffset, stopPos, stopOffset;
|
||||
|
||||
element = $( "<div style='margin: 2px;'></div>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
element.draggable( {
|
||||
start: function( event, ui ) {
|
||||
startPos = ui.position;
|
||||
startOffset = ui.offset;
|
||||
},
|
||||
drag: function( event, ui ) {
|
||||
dragPos = ui.position;
|
||||
dragOffset = ui.offset;
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
stopPos = ui.position;
|
||||
stopOffset = ui.offset;
|
||||
}
|
||||
} );
|
||||
|
||||
element.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10,
|
||||
moves: 1
|
||||
} );
|
||||
|
||||
startPos.left += 10;
|
||||
startPos.top += 10;
|
||||
startOffset.left += 10;
|
||||
startOffset.top += 10;
|
||||
|
||||
assert.deepEqual( startPos, dragPos, "start position equals drag position plus distance" );
|
||||
assert.deepEqual( dragPos, stopPos, "drag position equals stop position" );
|
||||
assert.deepEqual( startOffset, dragOffset, "start offset equals drag offset plus distance" );
|
||||
assert.deepEqual( dragOffset, stopOffset, "drag offset equals stop offset" );
|
||||
} );
|
||||
|
||||
} );
|
161
jquery-ui/tests/unit/draggable/helper.js
vendored
161
jquery-ui/tests/unit/draggable/helper.js
vendored
|
@ -1,161 +0,0 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"lib/helper",
|
||||
"ui/widgets/draggable"
|
||||
], function( QUnit, $, helper ) {
|
||||
|
||||
return $.extend( helper, {
|
||||
|
||||
// TODO: remove the unreliable offset hacks
|
||||
unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
|
||||
|
||||
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
|
||||
|
||||
unreliableContains: ( function() {
|
||||
var element = $( "<div>" );
|
||||
return $.contains( element[ 0 ].ownerDocument, element[ 0 ] );
|
||||
} )(),
|
||||
|
||||
testDragPosition: function( assert, 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 };
|
||||
assert.deepEqual( ui.position, positionExpected, "position dragged[" + dx + ", " + dy + "] " + msg );
|
||||
} );
|
||||
},
|
||||
|
||||
testDragOffset: function( assert, 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( event, ui ) {
|
||||
assert.deepEqual( ui.offset, offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
|
||||
} );
|
||||
},
|
||||
|
||||
testDragHelperOffset: function( assert, 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( event, ui ) {
|
||||
assert.deepEqual( ui.helper.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
|
||||
} );
|
||||
},
|
||||
|
||||
testDrag: function( assert, el, handle, dx, dy, expectedDX, expectedDY, msg ) {
|
||||
this.testDragPosition( assert, el, dx, dy, expectedDX, expectedDY, msg );
|
||||
this.testDragOffset( assert, el, dx, dy, expectedDX, expectedDY, msg );
|
||||
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: dx,
|
||||
dy: dy
|
||||
} );
|
||||
},
|
||||
|
||||
shouldMovePositionButNotOffset: function( assert, el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
this.testDragPosition( assert, el, 100, 100, 100, 100, msg );
|
||||
this.testDragHelperOffset( assert, el, 100, 100, 0, 0, msg );
|
||||
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: 100,
|
||||
dy: 100
|
||||
} );
|
||||
},
|
||||
|
||||
shouldMove: function( assert, el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
this.testDrag( assert, el, handle, 100, 100, 100, 100, msg );
|
||||
},
|
||||
|
||||
shouldNotMove: function( assert, el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
this.testDrag( assert, el, handle, 100, 100, 0, 0, msg );
|
||||
},
|
||||
|
||||
shouldNotDrag: function( assert, el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
|
||||
var newOffset,
|
||||
element = $( el ),
|
||||
beginOffset = element.offset();
|
||||
|
||||
element.on( "dragstop", function() {
|
||||
assert.ok( false, "should not drag " + msg );
|
||||
} );
|
||||
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: 100,
|
||||
dy: 100
|
||||
} );
|
||||
|
||||
newOffset = element.offset();
|
||||
|
||||
// Also assert that draggable did not move, to ensure it isn't just
|
||||
// that drag did not fire and draggable still somehow moved
|
||||
assert.equal( newOffset.left, beginOffset.left, "Offset left should not be different" );
|
||||
assert.equal( newOffset.top, beginOffset.top, "Offset top should not be different" );
|
||||
|
||||
element.off( "dragstop" );
|
||||
},
|
||||
|
||||
setScrollable: function( what, isScrollable ) {
|
||||
var overflow = isScrollable ? "scroll" : "hidden";
|
||||
$( what ).css( { overflow: overflow, overflowX: overflow, overflowY: overflow } );
|
||||
},
|
||||
|
||||
testScroll: function( assert, el, position ) {
|
||||
var oldPosition = $( "#main" ).css( "position" );
|
||||
$( "#main" ).css( { position: position, top: "0px", left: "0px" } );
|
||||
this.shouldMove( assert, el, position + " parent" );
|
||||
$( "#main" ).css( "position", oldPosition );
|
||||
},
|
||||
|
||||
restoreScroll: function( what ) {
|
||||
$( what ).scrollTop( 0 ).scrollLeft( 0 );
|
||||
},
|
||||
|
||||
setScroll: function( what ) {
|
||||
$( what ).scrollTop( 100 ).scrollLeft( 100 );
|
||||
},
|
||||
|
||||
border: function( el, side ) {
|
||||
return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0;
|
||||
},
|
||||
|
||||
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 ) {
|
||||
|
||||
// TODO: appendTo is currently ignored if helper is original (see #7044)
|
||||
el.draggable( "option", "helper", "clone" );
|
||||
|
||||
// Get what parent is at time of drag
|
||||
el.on( "drag", function( e, ui ) {
|
||||
el.data( "last_dragged_parent", ui.helper.parent()[ 0 ] );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
105
jquery-ui/tests/unit/draggable/methods.js
vendored
105
jquery-ui/tests/unit/draggable/methods.js
vendored
|
@ -1,105 +0,0 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/draggable"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
var element;
|
||||
|
||||
QUnit.module( "draggable: methods", {
|
||||
beforeEach: function() {
|
||||
element = $( "<div style='background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;'><span>Absolute</span></div>" ).appendTo( "#qunit-fixture" );
|
||||
},
|
||||
afterEach: function() {
|
||||
element.remove();
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( "init", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
element.draggable();
|
||||
assert.ok( true, ".draggable() called on element" );
|
||||
|
||||
$( [] ).draggable();
|
||||
assert.ok( true, ".draggable() called on empty collection" );
|
||||
|
||||
$( "<div></div>" ).draggable();
|
||||
assert.ok( true, ".draggable() called on disconnected DOMElement" );
|
||||
|
||||
element.draggable( "option", "foo" );
|
||||
assert.ok( true, "arbitrary option getter after init" );
|
||||
|
||||
element.draggable( "option", "foo", "bar" );
|
||||
assert.ok( true, "arbitrary option setter after init" );
|
||||
} );
|
||||
|
||||
QUnit.test( "destroy", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
element.draggable().draggable( "destroy" );
|
||||
assert.ok( true, ".draggable('destroy') called on element" );
|
||||
|
||||
$( [] ).draggable().draggable( "destroy" );
|
||||
assert.ok( true, ".draggable('destroy') called on empty collection" );
|
||||
|
||||
element.draggable().draggable( "destroy" );
|
||||
assert.ok( true, ".draggable('destroy') called on disconnected DOMElement" );
|
||||
|
||||
var expected = element.draggable(),
|
||||
actual = expected.draggable( "destroy" );
|
||||
assert.equal( actual, expected, "destroy is chainable" );
|
||||
} );
|
||||
|
||||
QUnit.test( "enable", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
element.draggable( { disabled: true } );
|
||||
testHelper.shouldNotDrag( assert, element, ".draggable({ disabled: true })" );
|
||||
|
||||
element.draggable( "enable" );
|
||||
testHelper.shouldMove( assert, element, ".draggable('enable')" );
|
||||
assert.equal( element.draggable( "option", "disabled" ), false, "disabled option getter" );
|
||||
|
||||
element.draggable( "destroy" );
|
||||
element.draggable( { disabled: true } );
|
||||
testHelper.shouldNotDrag( assert, element, ".draggable({ disabled: true })" );
|
||||
|
||||
element.draggable( "option", "disabled", false );
|
||||
assert.equal( element.draggable( "option", "disabled" ), false, "disabled option setter" );
|
||||
testHelper.shouldMove( assert, element, ".draggable('option', 'disabled', false)" );
|
||||
|
||||
var expected = element.draggable(),
|
||||
actual = expected.draggable( "enable" );
|
||||
assert.equal( actual, expected, "enable is chainable" );
|
||||
} );
|
||||
|
||||
QUnit.test( "disable", function( assert ) {
|
||||
assert.expect( 14 );
|
||||
|
||||
element = $( "#draggable2" ).draggable( { disabled: false } );
|
||||
testHelper.shouldMove( assert, element, ".draggable({ disabled: false })" );
|
||||
|
||||
element.draggable( "disable" );
|
||||
testHelper.shouldNotDrag( assert, element, ".draggable('disable')" );
|
||||
assert.equal( element.draggable( "option", "disabled" ), true, "disabled option getter" );
|
||||
|
||||
element.draggable( "destroy" );
|
||||
element.draggable( { disabled: false } );
|
||||
testHelper.shouldMove( assert, element, ".draggable({ disabled: false })" );
|
||||
|
||||
element.draggable( "option", "disabled", true );
|
||||
assert.equal( element.draggable( "option", "disabled" ), true, "disabled option setter" );
|
||||
testHelper.shouldNotDrag( assert, element, ".draggable('option', 'disabled', true)" );
|
||||
|
||||
assert.lacksClasses( element.draggable( "widget" ), "ui-state-disabled" );
|
||||
assert.ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
|
||||
assert.hasClasses( element.draggable( "widget" ), "ui-draggable-disabled" );
|
||||
|
||||
var expected = element.draggable(),
|
||||
actual = expected.draggable( "disable" );
|
||||
assert.equal( actual, expected, "disable is chainable" );
|
||||
} );
|
||||
|
||||
} );
|
1505
jquery-ui/tests/unit/draggable/options.js
vendored
1505
jquery-ui/tests/unit/draggable/options.js
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue