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
4efd006e26
11
.jshintrc
11
.jshintrc
@ -1,12 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"boss": true,
|
||||||
"curly": true,
|
"curly": true,
|
||||||
"eqnull": true,
|
|
||||||
"eqeqeq": true,
|
"eqeqeq": true,
|
||||||
|
"eqnull": true,
|
||||||
"expr": true,
|
"expr": true,
|
||||||
|
"immed": true,
|
||||||
"noarg": true,
|
"noarg": true,
|
||||||
"node": true,
|
|
||||||
"onevar": true,
|
"onevar": true,
|
||||||
|
"quotmark": "double",
|
||||||
|
"smarttabs": true,
|
||||||
"trailing": true,
|
"trailing": true,
|
||||||
"undef": true,
|
"undef": true,
|
||||||
"unused": true
|
"unused": true,
|
||||||
|
|
||||||
|
"node": true
|
||||||
}
|
}
|
||||||
|
2
.mailmap
2
.mailmap
@ -11,7 +11,7 @@ Ben Hollis <bhollis@amazon.com> <ben@benhollis.net>
|
|||||||
Benjamin Scott Boyle <benjamins.boyle@gmail.com>
|
Benjamin Scott Boyle <benjamins.boyle@gmail.com>
|
||||||
Bert ter Heide <bertjh@hotmail.com>
|
Bert ter Heide <bertjh@hotmail.com>
|
||||||
Chairat Sunthornwiphat <pipo@sixhead.com>
|
Chairat Sunthornwiphat <pipo@sixhead.com>
|
||||||
Corey Frang <gnarf@gnarf.net>
|
Corey Frang <gnarf37@gmail.com> <gnarf@gnarf.net>
|
||||||
Courtland Allen <courtlandallen@gmail.com>
|
Courtland Allen <courtlandallen@gmail.com>
|
||||||
Dan Streetman <ddstreet@ieee.org>
|
Dan Streetman <ddstreet@ieee.org>
|
||||||
Diego Tres <diegotres@gmail.com>
|
Diego Tres <diegotres@gmail.com>
|
||||||
|
@ -74,7 +74,7 @@ var
|
|||||||
},
|
},
|
||||||
main: {
|
main: {
|
||||||
options: {
|
options: {
|
||||||
keepSpecialComments: '*'
|
keepSpecialComments: "*"
|
||||||
},
|
},
|
||||||
src: "dist/jquery-ui.css",
|
src: "dist/jquery-ui.css",
|
||||||
dest: "dist/jquery-ui.min.css"
|
dest: "dist/jquery-ui.min.css"
|
||||||
@ -319,7 +319,7 @@ grunt.initConfig({
|
|||||||
files: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
|
files: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
|
||||||
// disabling everything that doesn't (quite) work with PhantomJS for now
|
// disabling everything that doesn't (quite) work with PhantomJS for now
|
||||||
// TODO except for all|index|test, try to include more as we go
|
// TODO except for all|index|test, try to include more as we go
|
||||||
return !( /(all|index|test|dialog|tabs|tooltip)\.html$/ ).test( file );
|
return !( /(all|index|test|dialog|tooltip)\.html$/ ).test( file );
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
/*global cat:true cd:true echo:true exec:true exit:true*/
|
/* global cat:true, cd:true, echo:true, exec:true, exit:true */
|
||||||
|
|
||||||
// Usage:
|
// Usage:
|
||||||
// stable release: node release.js
|
// stable release: node release.js
|
||||||
|
@ -140,7 +140,7 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() {
|
|||||||
cmd: "zip",
|
cmd: "zip",
|
||||||
args: [ "-r", dest, this.data.src ],
|
args: [ "-r", dest, this.data.src ],
|
||||||
opts: {
|
opts: {
|
||||||
cwd: 'dist'
|
cwd: "dist"
|
||||||
}
|
}
|
||||||
}, function( err ) {
|
}, function( err ) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
|
@ -34,37 +34,40 @@ var versions = {
|
|||||||
"Widget": "widget/widget.html"
|
"Widget": "widget/widget.html"
|
||||||
};
|
};
|
||||||
|
|
||||||
function submit( commit, runs, configFile, version, done ) {
|
function submit( commit, runs, configFile, extra, done ) {
|
||||||
var testName,
|
var testName,
|
||||||
testswarm = require( "testswarm" ),
|
testswarm = require( "testswarm" ),
|
||||||
config = grunt.file.readJSON( configFile ).jqueryui;
|
config = grunt.file.readJSON( configFile ).jqueryui,
|
||||||
version = version ? ( version + " " ) : "";
|
commitUrl = "https://github.com/jquery/jquery-ui/commit/" + commit;
|
||||||
for ( testName in runs ) {
|
|
||||||
runs[ testName] = config.testUrl + commit + "/tests/unit/" + runs[ testName ];
|
if ( extra ) {
|
||||||
|
extra = " " + extra;
|
||||||
}
|
}
|
||||||
testswarm.createClient( {
|
|
||||||
|
for ( testName in runs ) {
|
||||||
|
runs[ testName ] = config.testUrl + commit + "/tests/unit/" + runs[ testName ];
|
||||||
|
}
|
||||||
|
testswarm.createClient({
|
||||||
url: config.swarmUrl,
|
url: config.swarmUrl,
|
||||||
pollInterval: 10000,
|
pollInterval: 10000,
|
||||||
timeout: 1000 * 60 * 45
|
timeout: 1000 * 60 * 45
|
||||||
} )
|
})
|
||||||
.addReporter( testswarm.reporters.cli )
|
.addReporter( testswarm.reporters.cli )
|
||||||
.auth( {
|
.auth({
|
||||||
id: config.authUsername,
|
id: config.authUsername,
|
||||||
token: config.authToken
|
token: config.authToken
|
||||||
} )
|
})
|
||||||
.addjob(
|
.addjob({
|
||||||
{
|
name: "jQuery UI #<a href='" + commitUrl + "'>" + commit.substr( 0, 10 ) + "</a>" + extra,
|
||||||
name: 'jQuery UI ' + version + '#<a href="https://github.com/jquery/jquery-ui/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
|
runs: runs,
|
||||||
runs: runs,
|
runMax: config.runMax,
|
||||||
runMax: config.runMax,
|
browserSets: config.browserSets
|
||||||
browserSets: config.browserSets
|
}, function( error, passed ) {
|
||||||
}, function( err, passed ) {
|
if ( error ) {
|
||||||
if ( err ) {
|
grunt.log.error( error );
|
||||||
grunt.log.error( err );
|
|
||||||
}
|
|
||||||
done( passed );
|
|
||||||
}
|
}
|
||||||
);
|
done( passed );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
grunt.registerTask( "testswarm", function( commit, configFile ) {
|
grunt.registerTask( "testswarm", function( commit, configFile ) {
|
||||||
@ -83,7 +86,7 @@ grunt.registerTask( "testswarm-multi-jquery", function( commit, configFile, mino
|
|||||||
allTests[ test + "-" + version ] = tests[ test ] + "?nojshint=true&jquery=" + version;
|
allTests[ test + "-" + version ] = tests[ test ] + "?nojshint=true&jquery=" + version;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
submit( commit, allTests, configFile, minor + " core", this.async() );
|
submit( commit, allTests, configFile, "core " + minor, this.async() );
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
<script src="../../ui/jquery.ui.tooltip.js"></script>
|
<script src="../../ui/jquery.ui.tooltip.js"></script>
|
||||||
<link rel="stylesheet" href="../demos.css">
|
<link rel="stylesheet" href="../demos.css">
|
||||||
<style>
|
<style>
|
||||||
.ui-combobox {
|
.custom-combobox {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
.ui-combobox-toggle {
|
.custom-combobox-toggle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@ -28,17 +28,17 @@
|
|||||||
*height: 1.7em;
|
*height: 1.7em;
|
||||||
*top: 0.1em;
|
*top: 0.1em;
|
||||||
}
|
}
|
||||||
.ui-combobox-input {
|
.custom-combobox-input {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0.3em;
|
padding: 0.3em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
(function( $ ) {
|
(function( $ ) {
|
||||||
$.widget( "ui.combobox", {
|
$.widget( "custom.combobox", {
|
||||||
_create: function() {
|
_create: function() {
|
||||||
this.wrapper = $( "<span>" )
|
this.wrapper = $( "<span>" )
|
||||||
.addClass( "ui-combobox" )
|
.addClass( "custom-combobox" )
|
||||||
.insertAfter( this.element );
|
.insertAfter( this.element );
|
||||||
|
|
||||||
this.element.hide();
|
this.element.hide();
|
||||||
@ -54,7 +54,7 @@
|
|||||||
.appendTo( this.wrapper )
|
.appendTo( this.wrapper )
|
||||||
.val( value )
|
.val( value )
|
||||||
.attr( "title", "" )
|
.attr( "title", "" )
|
||||||
.addClass( "ui-state-default ui-combobox-input ui-widget ui-widget-content ui-corner-left" )
|
.addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
|
||||||
.autocomplete({
|
.autocomplete({
|
||||||
delay: 0,
|
delay: 0,
|
||||||
minLength: 0,
|
minLength: 0,
|
||||||
@ -92,7 +92,7 @@
|
|||||||
text: false
|
text: false
|
||||||
})
|
})
|
||||||
.removeClass( "ui-corner-all" )
|
.removeClass( "ui-corner-all" )
|
||||||
.addClass( "ui-corner-right ui-combobox-toggle" )
|
.addClass( "custom-combobox-toggle ui-corner-right" )
|
||||||
.mousedown(function() {
|
.mousedown(function() {
|
||||||
wasOpen = input.autocomplete( "widget" ).is( ":visible" );
|
wasOpen = input.autocomplete( "widget" ).is( ":visible" );
|
||||||
})
|
})
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt": "0.4.1",
|
"grunt": "0.4.1",
|
||||||
"grunt-contrib-jshint": "0.1.1",
|
"grunt-contrib-jshint": "0.4.1",
|
||||||
"grunt-contrib-uglify": "0.1.1",
|
"grunt-contrib-uglify": "0.1.1",
|
||||||
"grunt-contrib-concat": "0.1.3",
|
"grunt-contrib-concat": "0.1.3",
|
||||||
"grunt-contrib-qunit": "0.2.0",
|
"grunt-contrib-qunit": "0.2.0",
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
{
|
{
|
||||||
"browser": true,
|
"boss": true,
|
||||||
"curly": true,
|
"curly": true,
|
||||||
"eqnull": true,
|
|
||||||
"eqeqeq": true,
|
"eqeqeq": true,
|
||||||
|
"eqnull": true,
|
||||||
"expr": true,
|
"expr": true,
|
||||||
"evil": true,
|
"immed": true,
|
||||||
"jquery": true,
|
|
||||||
"latedef": true,
|
|
||||||
"noarg": true,
|
"noarg": true,
|
||||||
"onevar": true,
|
"onevar": true,
|
||||||
"quotmark": "double",
|
"quotmark": "double",
|
||||||
|
"smarttabs": true,
|
||||||
"trailing": true,
|
"trailing": true,
|
||||||
"undef": true,
|
"undef": true,
|
||||||
"unused": true,
|
"unused": true,
|
||||||
|
|
||||||
|
"browser": true,
|
||||||
|
"evil": true,
|
||||||
|
"jquery": true,
|
||||||
|
|
||||||
"globals": {
|
"globals": {
|
||||||
"asyncTest": false,
|
"asyncTest": false,
|
||||||
"closeEnough": false,
|
"closeEnough": false,
|
||||||
@ -34,4 +38,4 @@
|
|||||||
"TestHelpers": true,
|
"TestHelpers": true,
|
||||||
"JSHINT": false
|
"JSHINT": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,8 +316,12 @@ $.extend( $.simulate.prototype, {
|
|||||||
this.simulateEvent( document, "mousemove", coord );
|
this.simulateEvent( document, "mousemove", coord );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.simulateEvent( target, "mouseup", coord );
|
if ( $.contains( document, target ) ) {
|
||||||
this.simulateEvent( target, "click", coord );
|
this.simulateEvent( target, "mouseup", coord );
|
||||||
|
this.simulateEvent( target, "click", coord );
|
||||||
|
} else {
|
||||||
|
this.simulateEvent( document, "mouseup", coord );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@
|
|||||||
|
|
||||||
<div><input id="submit" type="submit" value="Label"></div>
|
<div><input id="submit" type="submit" value="Label"></div>
|
||||||
|
|
||||||
|
<button id="button1">Button</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -153,6 +153,30 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
|
|||||||
ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
|
ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
asyncTest( "Resetting a button's form should refresh the visual state of the button widget to match.", function() {
|
||||||
|
expect( 2 );
|
||||||
|
var form = $( "<form>" +
|
||||||
|
"<button></button>" +
|
||||||
|
"<label for='c1'></label><input id='c1' type='checkbox' checked>" +
|
||||||
|
"</form>" ),
|
||||||
|
button = form.find( "button" ).button(),
|
||||||
|
checkbox = form.find( "input[type=checkbox]" ).button();
|
||||||
|
|
||||||
|
checkbox.prop( "checked", false ).button( "refresh" );
|
||||||
|
ok( !checkbox.button( "widget" ).hasClass( "ui-state-active" ) );
|
||||||
|
|
||||||
|
form.get( 0 ).reset();
|
||||||
|
|
||||||
|
// #9213: If a button has been removed, refresh should not be called on it when
|
||||||
|
// its corresponding form is reset.
|
||||||
|
button.remove();
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
ok( checkbox.button( "widget" ).hasClass( "ui-state-active" ));
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
|
asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
|
||||||
expect( 2 );
|
expect( 2 );
|
||||||
var check = $( "#check" ).button(),
|
var check = $( "#check" ).button(),
|
||||||
@ -172,4 +196,17 @@ test( "#7534 - Button label selector works for ids with \":\"", function() {
|
|||||||
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
|
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
asyncTest( "#9169 - Disabled button maintains ui-state-focus", function() {
|
||||||
|
expect( 2 );
|
||||||
|
var element = $( "#button1" ).button();
|
||||||
|
element[ 0 ].focus();
|
||||||
|
setTimeout(function() {
|
||||||
|
ok( element.hasClass( "ui-state-focus" ), "button has ui-state-focus" );
|
||||||
|
element.button( "disable" );
|
||||||
|
ok( !element.hasClass( "ui-state-focus" ),
|
||||||
|
"button does not have ui-state-focus when disabled" );
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -30,154 +30,173 @@ test("widget method", function() {
|
|||||||
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
|
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("baseStructure", function() {
|
asyncTest( "baseStructure", function() {
|
||||||
expect( 58 );
|
expect( 58 );
|
||||||
var header, title, table, thead, week, panel, inl, child,
|
var header, title, table, thead, week, panel, inl, child,
|
||||||
inp = TestHelpers.datepicker.init("#inp"),
|
inp = TestHelpers.datepicker.initNewInput(),
|
||||||
dp = $("#ui-datepicker-div");
|
dp = $( "#ui-datepicker-div" );
|
||||||
|
|
||||||
function step1() {
|
function step1() {
|
||||||
inp[0].focus();
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
setTimeout(function() {
|
ok( dp.is( ":visible" ), "Structure - datepicker visible" );
|
||||||
ok(dp.is(":visible"), "Structure - datepicker visible");
|
ok( !dp.is( ".ui-datepicker-rtl" ), "Structure - not right-to-left" );
|
||||||
ok(!dp.is(".ui-datepicker-rtl"), "Structure - not right-to-left");
|
ok( !dp.is( ".ui-datepicker-multi" ), "Structure - not multi-month" );
|
||||||
ok(!dp.is(".ui-datepicker-multi"), "Structure - not multi-month");
|
equal( dp.children().length, 2, "Structure - child count" );
|
||||||
equal(dp.children().length, 2, "Structure - child count");
|
|
||||||
|
|
||||||
header = dp.children(":first");
|
header = dp.children( ":first" );
|
||||||
ok(header.is("div.ui-datepicker-header"), "Structure - header division");
|
ok( header.is( "div.ui-datepicker-header" ), "Structure - header division" );
|
||||||
equal(header.children().length, 3, "Structure - header child count");
|
equal( header.children().length, 3, "Structure - header child count" );
|
||||||
ok(header.children(":first").is("a.ui-datepicker-prev") && header.children(":first").html() !== "", "Structure - prev link");
|
ok( header.children( ":first" ).is( "a.ui-datepicker-prev" ) && header.children( ":first" ).html() !== "", "Structure - prev link" );
|
||||||
ok(header.children(":eq(1)").is("a.ui-datepicker-next") && header.children(":eq(1)").html() !== "", "Structure - next link");
|
ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-next" ) && header.children( ":eq(1)" ).html() !== "", "Structure - next link" );
|
||||||
|
|
||||||
title = header.children(":last");
|
title = header.children( ":last" );
|
||||||
ok(title.is("div.ui-datepicker-title") && title.html() !== "","Structure - title division");
|
ok( title.is( "div.ui-datepicker-title" ) && title.html() !== "","Structure - title division" );
|
||||||
equal(title.children().length, 2, "Structure - title child count");
|
equal( title.children().length, 2, "Structure - title child count" );
|
||||||
ok(title.children(":first").is("span.ui-datepicker-month") && title.children(":first").text() !== "", "Structure - month text");
|
ok( title.children( ":first" ).is( "span.ui-datepicker-month" ) && title.children( ":first" ).text() !== "", "Structure - month text" );
|
||||||
ok(title.children(":last").is("span.ui-datepicker-year") && title.children(":last").text() !== "", "Structure - year text");
|
ok( title.children( ":last" ).is( "span.ui-datepicker-year" ) && title.children( ":last" ).text() !== "", "Structure - year text" );
|
||||||
|
|
||||||
table = dp.children(":eq(1)");
|
table = dp.children( ":eq(1)" );
|
||||||
ok(table.is("table.ui-datepicker-calendar"), "Structure - month table");
|
ok( table.is( "table.ui-datepicker-calendar" ), "Structure - month table" );
|
||||||
ok(table.children(":first").is("thead"), "Structure - month table thead");
|
ok( table.children( ":first" ).is( "thead" ), "Structure - month table thead" );
|
||||||
thead = table.children(":first").children(":first");
|
|
||||||
ok(thead.is("tr"), "Structure - month table title row");
|
|
||||||
equal(thead.find("th").length, 7, "Structure - month table title cells");
|
|
||||||
ok(table.children(":eq(1)").is("tbody"), "Structure - month table body");
|
|
||||||
ok(table.children(":eq(1)").children("tr").length >= 4, "Structure - month table week count");
|
|
||||||
week = table.children(":eq(1)").children(":first");
|
|
||||||
ok(week.is("tr"), "Structure - month table week row");
|
|
||||||
equal(week.children().length, 7, "Structure - week child count");
|
|
||||||
ok(week.children(":first").is("td.ui-datepicker-week-end"), "Structure - month table first day cell");
|
|
||||||
ok(week.children(":last").is("td.ui-datepicker-week-end"), "Structure - month table second day cell");
|
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
|
||||||
|
|
||||||
|
thead = table.children( ":first" ).children( ":first" );
|
||||||
|
ok( thead.is( "tr" ), "Structure - month table title row" );
|
||||||
|
equal( thead.find( "th" ).length, 7, "Structure - month table title cells" );
|
||||||
|
ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure - month table body" );
|
||||||
|
ok( table.children( ":eq(1)" ).children( "tr" ).length >= 4, "Structure - month table week count" );
|
||||||
|
|
||||||
|
week = table.children( ":eq(1)" ).children( ":first" );
|
||||||
|
ok( week.is( "tr" ), "Structure - month table week row" );
|
||||||
|
equal( week.children().length, 7, "Structure - week child count" );
|
||||||
|
ok( week.children( ":first" ).is( "td.ui-datepicker-week-end" ), "Structure - month table first day cell" );
|
||||||
|
ok( week.children( ":last" ).is( "td.ui-datepicker-week-end" ), "Structure - month table second day cell" );
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
step2();
|
step2();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function step2() {
|
function step2() {
|
||||||
// Editable month/year and button panel
|
// Editable month/year and button panel
|
||||||
inp = TestHelpers.datepicker.init("#inp", {changeMonth: true, changeYear: true, showButtonPanel: true});
|
inp = TestHelpers.datepicker.initNewInput({
|
||||||
inp.focus();
|
changeMonth: true,
|
||||||
setTimeout(function() {
|
changeYear: true,
|
||||||
title = dp.find("div.ui-datepicker-title");
|
showButtonPanel: true
|
||||||
ok(title.children(":first").is("select.ui-datepicker-month"), "Structure - month selector");
|
});
|
||||||
ok(title.children(":last").is("select.ui-datepicker-year"), "Structure - year selector");
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
|
title = dp.find( "div.ui-datepicker-title" );
|
||||||
|
ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure - month selector" );
|
||||||
|
ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure - year selector" );
|
||||||
|
|
||||||
panel = dp.children(":last");
|
panel = dp.children( ":last" );
|
||||||
ok(panel.is("div.ui-datepicker-buttonpane"), "Structure - button panel division");
|
ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure - button panel division" );
|
||||||
equal(panel.children().length, 2, "Structure - button panel child count");
|
equal( panel.children().length, 2, "Structure - button panel child count" );
|
||||||
ok(panel.children(":first").is("button.ui-datepicker-current"), "Structure - today button");
|
ok( panel.children( ":first" ).is( "button.ui-datepicker-current" ), "Structure - today button" );
|
||||||
ok(panel.children(":last").is("button.ui-datepicker-close"), "Structure - close button");
|
ok( panel.children( ":last" ).is( "button.ui-datepicker-close" ), "Structure - close button" );
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
step3();
|
step3();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function step3() {
|
function step3() {
|
||||||
// Multi-month 2
|
// Multi-month 2
|
||||||
inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: 2});
|
inp = TestHelpers.datepicker.initNewInput({ numberOfMonths: 2 });
|
||||||
inp.focus();
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
setTimeout(function() {
|
ok( dp.is( ".ui-datepicker-multi" ), "Structure multi [2] - multi-month" );
|
||||||
ok(dp.is(".ui-datepicker-multi"), "Structure multi [2] - multi-month");
|
equal( dp.children().length, 3, "Structure multi [2] - child count" );
|
||||||
equal(dp.children().length, 3, "Structure multi [2] - child count");
|
|
||||||
child = dp.children(":first");
|
|
||||||
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2] - first month division");
|
|
||||||
child = dp.children(":eq(1)");
|
|
||||||
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2] - second month division");
|
|
||||||
child = dp.children(":eq(2)");
|
|
||||||
ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2] - row break");
|
|
||||||
ok(dp.is(".ui-datepicker-multi-2"), "Structure multi [2] - multi-2");
|
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
|
||||||
|
|
||||||
|
child = dp.children( ":first" );
|
||||||
|
ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2] - first month division" );
|
||||||
|
|
||||||
|
child = dp.children( ":eq(1)" );
|
||||||
|
ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2] - second month division" );
|
||||||
|
|
||||||
|
child = dp.children( ":eq(2)" );
|
||||||
|
ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2] - row break" );
|
||||||
|
ok( dp.is( ".ui-datepicker-multi-2" ), "Structure multi [2] - multi-2" );
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
step4();
|
step4();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function step4() {
|
function step4() {
|
||||||
// Multi-month 3
|
// Multi-month 3
|
||||||
inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: 3});
|
inp = TestHelpers.datepicker.initNewInput({ numberOfMonths: 3 });
|
||||||
inp.focus();
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
setTimeout(function() {
|
ok( dp.is( ".ui-datepicker-multi-3" ), "Structure multi [3] - multi-3" );
|
||||||
ok(dp.is(".ui-datepicker-multi-3"), "Structure multi [3] - multi-3");
|
ok( !dp.is( ".ui-datepicker-multi-2" ), "Structure multi [3] - Trac #6704" );
|
||||||
ok(! dp.is(".ui-datepicker-multi-2"), "Structure multi [3] - Trac #6704");
|
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
step5();
|
step5();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function step5() {
|
function step5() {
|
||||||
// Multi-month [2, 2]
|
// Multi-month [2, 2]
|
||||||
inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: [2, 2]});
|
inp = TestHelpers.datepicker.initNewInput({ numberOfMonths: [ 2, 2 ] });
|
||||||
inp.focus();
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
setTimeout(function() {
|
ok( dp.is( ".ui-datepicker-multi" ), "Structure multi - multi-month" );
|
||||||
ok(dp.is(".ui-datepicker-multi"), "Structure multi - multi-month");
|
equal( dp.children().length, 6, "Structure multi [2,2] - child count" );
|
||||||
equal(dp.children().length, 6, "Structure multi [2,2] - child count");
|
|
||||||
child = dp.children(":first");
|
child = dp.children( ":first" );
|
||||||
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2,2] - first month division");
|
ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - first month division" );
|
||||||
child = dp.children(":eq(1)");
|
|
||||||
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2,2] - second month division");
|
child = dp.children( ":eq(1)" );
|
||||||
child = dp.children(":eq(2)");
|
ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - second month division" );
|
||||||
ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2,2] - row break");
|
|
||||||
child = dp.children(":eq(3)");
|
child = dp.children( ":eq(2)" );
|
||||||
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2,2] - third month division");
|
ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
|
||||||
child = dp.children(":eq(4)");
|
|
||||||
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2,2] - fourth month division");
|
child = dp.children( ":eq(3)" );
|
||||||
child = dp.children(":eq(5)");
|
ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - third month division" );
|
||||||
ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2,2] - row break");
|
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
child = dp.children( ":eq(4)" );
|
||||||
|
ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - fourth month division" );
|
||||||
|
|
||||||
|
child = dp.children( ":eq(5)" );
|
||||||
|
ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
|
||||||
// Inline
|
// Inline
|
||||||
inl = TestHelpers.datepicker.init("#inl");
|
inl = TestHelpers.datepicker.init( "#inl" );
|
||||||
dp = inl.children();
|
dp = inl.children();
|
||||||
ok(dp.is(".ui-datepicker-inline"), "Structure inline - main div");
|
|
||||||
ok(!dp.is(".ui-datepicker-rtl"), "Structure inline - not right-to-left");
|
ok( dp.is( ".ui-datepicker-inline" ), "Structure inline - main div" );
|
||||||
ok(!dp.is(".ui-datepicker-multi"), "Structure inline - not multi-month");
|
ok( !dp.is( ".ui-datepicker-rtl" ), "Structure inline - not right-to-left" );
|
||||||
equal(dp.children().length, 2, "Structure inline - child count");
|
ok( !dp.is( ".ui-datepicker-multi" ), "Structure inline - not multi-month" );
|
||||||
header = dp.children(":first");
|
equal( dp.children().length, 2, "Structure inline - child count" );
|
||||||
ok(header.is("div.ui-datepicker-header"), "Structure inline - header division");
|
|
||||||
equal(header.children().length, 3, "Structure inline - header child count");
|
header = dp.children( ":first" );
|
||||||
table = dp.children(":eq(1)");
|
ok( header.is( "div.ui-datepicker-header" ), "Structure inline - header division" );
|
||||||
ok(table.is("table.ui-datepicker-calendar"), "Structure inline - month table");
|
equal( header.children().length, 3, "Structure inline - header child count" );
|
||||||
ok(table.children(":first").is("thead"), "Structure inline - month table thead");
|
|
||||||
ok(table.children(":eq(1)").is("tbody"), "Structure inline - month table body");
|
table = dp.children( ":eq(1)" );
|
||||||
inl.datepicker("destroy");
|
ok( table.is( "table.ui-datepicker-calendar" ), "Structure inline - month table" );
|
||||||
|
ok( table.children( ":first" ).is( "thead" ), "Structure inline - month table thead" );
|
||||||
|
ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure inline - month table body" );
|
||||||
|
|
||||||
|
inl.datepicker( "destroy" );
|
||||||
|
|
||||||
// Inline multi-month
|
// Inline multi-month
|
||||||
inl = TestHelpers.datepicker.init("#inl", {numberOfMonths: 2});
|
inl = TestHelpers.datepicker.init( "#inl", { numberOfMonths: 2 } );
|
||||||
dp = inl.children();
|
dp = inl.children();
|
||||||
ok(dp.is(".ui-datepicker-inline") && dp.is(".ui-datepicker-multi"), "Structure inline multi - main div");
|
|
||||||
equal(dp.children().length, 3, "Structure inline multi - child count");
|
|
||||||
child = dp.children(":first");
|
|
||||||
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure inline multi - first month division");
|
|
||||||
child = dp.children(":eq(1)");
|
|
||||||
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure inline multi - second month division");
|
|
||||||
child = dp.children(":eq(2)");
|
|
||||||
ok(child.is("div.ui-datepicker-row-break"), "Structure inline multi - row break");
|
|
||||||
inl.datepicker("destroy");
|
|
||||||
|
|
||||||
|
ok( dp.is( ".ui-datepicker-inline" ) && dp.is( ".ui-datepicker-multi" ), "Structure inline multi - main div" );
|
||||||
|
equal( dp.children().length, 3, "Structure inline multi - child count" );
|
||||||
|
|
||||||
|
child = dp.children( ":first" );
|
||||||
|
ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure inline multi - first month division" );
|
||||||
|
|
||||||
|
child = dp.children( ":eq(1)" );
|
||||||
|
ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure inline multi - second month division" );
|
||||||
|
|
||||||
|
child = dp.children( ":eq(2)" );
|
||||||
|
ok( child.is( "div.ui-datepicker-row-break" ), "Structure inline multi - row break" );
|
||||||
|
|
||||||
|
inl.datepicker( "destroy" );
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -185,61 +204,103 @@ asyncTest("baseStructure", function() {
|
|||||||
step1();
|
step1();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("customStructure", function() {
|
asyncTest( "customStructure", function() {
|
||||||
expect( 20 );
|
expect( 20 );
|
||||||
var header, panel, title, thead,
|
var header, panel, title, thead,
|
||||||
dp = $("#ui-datepicker-div"),
|
inp = TestHelpers.datepicker.initNewInput( $.datepicker.regional.he ),
|
||||||
// Check right-to-left localisation
|
dp = $( "#ui-datepicker-div" );
|
||||||
inp = TestHelpers.datepicker.init("#inp", $.datepicker.regional.he);
|
|
||||||
inp.datepicker( "option", "showButtonPanel", true);
|
function step1() {
|
||||||
inp.focus();
|
inp.datepicker( "option", "showButtonPanel", true );
|
||||||
ok(dp.is(".ui-datepicker-rtl"), "Structure RTL - right-to-left");
|
|
||||||
header = dp.children(":first");
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
ok(header.is("div.ui-datepicker-header"), "Structure RTL - header division");
|
ok( dp.is( ".ui-datepicker-rtl" ), "Structure RTL - right-to-left" );
|
||||||
equal(header.children().length, 3, "Structure RTL - header child count");
|
|
||||||
ok(header.children(":first").is("a.ui-datepicker-next"), "Structure RTL - prev link");
|
header = dp.children( ":first" );
|
||||||
ok(header.children(":eq(1)").is("a.ui-datepicker-prev"), "Structure RTL - next link");
|
ok( header.is( "div.ui-datepicker-header" ), "Structure RTL - header division" );
|
||||||
panel = dp.children(":last");
|
equal( header.children().length, 3, "Structure RTL - header child count" );
|
||||||
ok(panel.is("div.ui-datepicker-buttonpane"), "Structure RTL - button division");
|
ok( header.children( ":first" ).is( "a.ui-datepicker-next" ), "Structure RTL - prev link" );
|
||||||
equal(panel.children().length, 2, "Structure RTL - button panel child count");
|
ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-prev" ), "Structure RTL - next link" );
|
||||||
ok(panel.children(":first").is("button.ui-datepicker-close"), "Structure RTL - close button");
|
|
||||||
ok(panel.children(":last").is("button.ui-datepicker-current"), "Structure RTL - today button");
|
panel = dp.children( ":last" );
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure RTL - button division" );
|
||||||
|
equal( panel.children().length, 2, "Structure RTL - button panel child count" );
|
||||||
|
ok( panel.children( ":first" ).is( "button.ui-datepicker-close" ), "Structure RTL - close button" );
|
||||||
|
ok( panel.children( ":last" ).is( "button.ui-datepicker-current" ), "Structure RTL - today button" );
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
step2();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Hide prev/next
|
// Hide prev/next
|
||||||
inp = TestHelpers.datepicker.init("#inp", {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});
|
function step2() {
|
||||||
inp.val("02/10/2008").focus();
|
inp = TestHelpers.datepicker.initNewInput({
|
||||||
header = dp.children(":first");
|
hideIfNoPrevNext: true,
|
||||||
ok(header.is("div.ui-datepicker-header"), "Structure hide prev/next - header division");
|
minDate: new Date( 2008, 2 - 1, 4 ),
|
||||||
equal(header.children().length, 1, "Structure hide prev/next - links child count");
|
maxDate: new Date( 2008, 2 - 1, 14 )
|
||||||
ok(header.children(":first").is("div.ui-datepicker-title"), "Structure hide prev/next - title division");
|
});
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
inp.val( "02/10/2008" );
|
||||||
|
|
||||||
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
|
header = dp.children( ":first" );
|
||||||
|
ok( header.is( "div.ui-datepicker-header" ), "Structure hide prev/next - header division" );
|
||||||
|
equal( header.children().length, 1, "Structure hide prev/next - links child count" );
|
||||||
|
ok( header.children( ":first" ).is( "div.ui-datepicker-title" ), "Structure hide prev/next - title division" );
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
step3();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Changeable Month with read-only year
|
// Changeable Month with read-only year
|
||||||
inp = TestHelpers.datepicker.init("#inp", {changeMonth: true});
|
function step3() {
|
||||||
inp.focus();
|
inp = TestHelpers.datepicker.initNewInput({ changeMonth: true });
|
||||||
title = dp.children(":first").children(":last");
|
|
||||||
equal(title.children().length, 2, "Structure changeable month - title child count");
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
ok(title.children(":first").is("select.ui-datepicker-month"), "Structure changeable month - month selector");
|
title = dp.children( ":first" ).children( ":last" );
|
||||||
ok(title.children(":last").is("span.ui-datepicker-year"), "Structure changeable month - read-only year");
|
equal( title.children().length, 2, "Structure changeable month - title child count" );
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" );
|
||||||
|
ok( title.children( ":last" ).is( "span.ui-datepicker-year" ), "Structure changeable month - read-only year" );
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
step4();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Changeable year with read-only month
|
// Changeable year with read-only month
|
||||||
inp = TestHelpers.datepicker.init("#inp", {changeYear: true});
|
function step4() {
|
||||||
inp.focus();
|
inp = TestHelpers.datepicker.initNewInput({ changeYear: true });
|
||||||
title = dp.children(":first").children(":last");
|
|
||||||
equal(title.children().length, 2, "Structure changeable year - title child count");
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
ok(title.children(":first").is("span.ui-datepicker-month"), "Structure changeable year - read-only month");
|
title = dp.children( ":first" ).children( ":last" );
|
||||||
ok(title.children(":last").is("select.ui-datepicker-year"), "Structure changeable year - year selector");
|
equal( title.children().length, 2, "Structure changeable year - title child count" );
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
ok( title.children( ":first" ).is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" );
|
||||||
|
ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure changeable year - year selector" );
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
step5();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Read-only first day of week
|
// Read-only first day of week
|
||||||
inp = TestHelpers.datepicker.init("#inp", {changeFirstDay: false});
|
function step5() {
|
||||||
inp.focus();
|
inp = TestHelpers.datepicker.initNewInput({ changeFirstDay: false });
|
||||||
thead = dp.find(".ui-datepicker-calendar thead tr");
|
|
||||||
equal(thead.children().length, 7, "Structure read-only first day - thead child count");
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
equal(thead.find("a").length, 0, "Structure read-only first day - thead links count");
|
thead = dp.find( ".ui-datepicker-calendar thead tr" );
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
equal( thead.children().length, 7, "Structure read-only first day - thead child count" );
|
||||||
|
equal( thead.find( "a" ).length, 0, "Structure read-only first day - thead links count" );
|
||||||
|
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: figure out why this setTimeout is needed in IE,
|
||||||
|
// it only is necessary when the previous baseStructure tests runs first
|
||||||
|
// Support: IE
|
||||||
|
setTimeout( step1 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("keystrokes", function() {
|
test("keystrokes", function() {
|
||||||
|
@ -87,114 +87,135 @@ test("change", function() {
|
|||||||
equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
|
equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("invocation", function() {
|
asyncTest( "invocation", function() {
|
||||||
expect( 29 );
|
|
||||||
var button, image,
|
var button, image,
|
||||||
inp = TestHelpers.datepicker.init("#inp"),
|
isOldIE = $.ui.ie && ( !document.documentMode || document.documentMode < 9 ),
|
||||||
dp = $("#ui-datepicker-div"),
|
body = $( "body" );
|
||||||
body = $("body");
|
|
||||||
|
expect( isOldIE ? 25 : 29 );
|
||||||
|
|
||||||
|
function step0() {
|
||||||
|
var inp = TestHelpers.datepicker.initNewInput(),
|
||||||
|
dp = $( "#ui-datepicker-div" );
|
||||||
|
|
||||||
|
button = inp.siblings( "button" );
|
||||||
|
ok( button.length === 0, "Focus - button absent" );
|
||||||
|
image = inp.siblings( "img" );
|
||||||
|
ok( image.length === 0, "Focus - image absent" );
|
||||||
|
|
||||||
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
|
ok( dp.is( ":visible" ), "Focus - rendered on focus" );
|
||||||
|
inp.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
||||||
|
ok( !dp.is( ":visible" ), "Focus - hidden on exit" );
|
||||||
|
step1();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function step1() {
|
function step1() {
|
||||||
// On focus
|
|
||||||
button = inp.siblings("button");
|
|
||||||
ok(button.length === 0, "Focus - button absent");
|
|
||||||
image = inp.siblings("img");
|
|
||||||
ok(image.length === 0, "Focus - image absent");
|
|
||||||
inp[0].focus();
|
|
||||||
setTimeout(function() {
|
|
||||||
ok(dp.is(":visible"), "Focus - rendered on focus");
|
|
||||||
inp.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
|
|
||||||
ok(!dp.is(":visible"), "Focus - hidden on exit");
|
|
||||||
inp[0].blur();
|
|
||||||
setTimeout(function() {
|
|
||||||
inp[0].focus();
|
|
||||||
setTimeout(function() {
|
|
||||||
ok(dp.is(":visible"), "Focus - rendered on focus");
|
|
||||||
body.simulate("mousedown", {});
|
|
||||||
ok(!dp.is(":visible"), "Focus - hidden on external click");
|
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
|
||||||
|
|
||||||
step2();
|
var inp = TestHelpers.datepicker.initNewInput(),
|
||||||
});
|
dp = $( "#ui-datepicker-div" );
|
||||||
});
|
|
||||||
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
|
ok( dp.is( ":visible" ), "Focus - rendered on focus" );
|
||||||
|
body.simulate( "mousedown", {} );
|
||||||
|
ok( !dp.is( ":visible" ), "Focus - hidden on external click" );
|
||||||
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
|
||||||
|
step2();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function step2() {
|
function step2() {
|
||||||
// On button
|
var inp = TestHelpers.datepicker.initNewInput({
|
||||||
inp = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonText: "Popup"});
|
showOn: "button",
|
||||||
ok(!dp.is(":visible"), "Button - initially hidden");
|
buttonText: "Popup"
|
||||||
button = inp.siblings("button");
|
}),
|
||||||
image = inp.siblings("img");
|
dp = $( "#ui-datepicker-div" );
|
||||||
ok(button.length === 1, "Button - button present");
|
|
||||||
ok(image.length === 0, "Button - image absent");
|
ok( !dp.is( ":visible" ), "Button - initially hidden" );
|
||||||
equal(button.text(), "Popup", "Button - button text");
|
button = inp.siblings( "button" );
|
||||||
inp[0].focus();
|
image = inp.siblings( "img" );
|
||||||
setTimeout(function() {
|
ok( button.length === 1, "Button - button present" );
|
||||||
ok(!dp.is(":visible"), "Button - not rendered on focus");
|
ok( image.length === 0, "Button - image absent" );
|
||||||
|
equal( button.text(), "Popup", "Button - button text" );
|
||||||
|
|
||||||
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
|
ok( !dp.is( ":visible" ), "Button - not rendered on focus" );
|
||||||
button.click();
|
button.click();
|
||||||
ok(dp.is(":visible"), "Button - rendered on button click");
|
ok( dp.is( ":visible" ), "Button - rendered on button click" );
|
||||||
button.click();
|
button.click();
|
||||||
ok(!dp.is(":visible"), "Button - hidden on second button click");
|
ok( !dp.is( ":visible" ), "Button - hidden on second button click" );
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
|
||||||
step3();
|
step3();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function step3() {
|
function step3() {
|
||||||
// On image button
|
var inp = TestHelpers.datepicker.initNewInput({
|
||||||
inp = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonImageOnly: true,
|
showOn: "button",
|
||||||
buttonImage: "images/calendar.gif", buttonText: "Cal"});
|
buttonImageOnly: true,
|
||||||
ok(!dp.is(":visible"), "Image button - initially hidden");
|
buttonImage: "images/calendar.gif",
|
||||||
button = inp.siblings("button");
|
buttonText: "Cal"
|
||||||
ok(button.length === 0, "Image button - button absent");
|
}),
|
||||||
image = inp.siblings("img");
|
dp = $( "#ui-datepicker-div" );
|
||||||
ok(image.length === 1, "Image button - image present");
|
|
||||||
equal(image.attr("src"), "images/calendar.gif", "Image button - image source");
|
ok( !dp.is( ":visible" ), "Image button - initially hidden" );
|
||||||
equal(image.attr("title"), "Cal", "Image button - image text");
|
button = inp.siblings( "button" );
|
||||||
inp[0].focus();
|
ok( button.length === 0, "Image button - button absent" );
|
||||||
setTimeout(function() {
|
image = inp.siblings( "img" );
|
||||||
ok(!dp.is(":visible"), "Image button - not rendered on focus");
|
ok( image.length === 1, "Image button - image present" );
|
||||||
|
equal( image.attr( "src" ), "images/calendar.gif", "Image button - image source" );
|
||||||
|
equal( image.attr( "title" ), "Cal", "Image button - image text" );
|
||||||
|
|
||||||
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
|
ok( !dp.is( ":visible" ), "Image button - not rendered on focus" );
|
||||||
image.click();
|
image.click();
|
||||||
ok(dp.is(":visible"), "Image button - rendered on image click");
|
ok( dp.is( ":visible" ), "Image button - rendered on image click" );
|
||||||
image.click();
|
image.click();
|
||||||
ok(!dp.is(":visible"), "Image button - hidden on second image click");
|
ok( !dp.is( ":visible" ), "Image button - hidden on second image click" );
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
|
||||||
step4();
|
step4();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function step4() {
|
function step4() {
|
||||||
// On both
|
var inp = TestHelpers.datepicker.initNewInput({
|
||||||
inp = TestHelpers.datepicker.init("#inp", {showOn: "both", buttonImage: "images/calendar.gif"});
|
showOn: "both",
|
||||||
ok(!dp.is(":visible"), "Both - initially hidden");
|
buttonImage: "images/calendar.gif"
|
||||||
button = inp.siblings("button");
|
}),
|
||||||
ok(button.length === 1, "Both - button present");
|
dp = $( "#ui-datepicker-div" );
|
||||||
image = inp.siblings("img");
|
|
||||||
ok(image.length === 0, "Both - image absent");
|
ok( !dp.is( ":visible" ), "Both - initially hidden" );
|
||||||
image = button.children("img");
|
button = inp.siblings( "button" );
|
||||||
ok(image.length === 1, "Both - button image present");
|
ok( button.length === 1, "Both - button present" );
|
||||||
inp[0].blur();
|
image = inp.siblings( "img" );
|
||||||
setTimeout(function() {
|
ok( image.length === 0, "Both - image absent" );
|
||||||
inp[0].focus();
|
image = button.children( "img" );
|
||||||
setTimeout(function() {
|
ok( image.length === 1, "Both - button image present" );
|
||||||
ok(dp.is(":visible"), "Both - rendered on focus");
|
|
||||||
body.simulate("mousedown", {});
|
// TODO: occasionally this test flakily fails to focus in IE8 in browserstack
|
||||||
ok(!dp.is(":visible"), "Both - hidden on external click");
|
if ( !isOldIE ) {
|
||||||
|
TestHelpers.datepicker.onFocus( inp, function() {
|
||||||
|
ok( dp.is( ":visible" ), "Both - rendered on focus" );
|
||||||
|
body.simulate( "mousedown", {} );
|
||||||
|
ok( !dp.is( ":visible" ), "Both - hidden on external click" );
|
||||||
button.click();
|
button.click();
|
||||||
ok(dp.is(":visible"), "Both - rendered on button click");
|
ok( dp.is( ":visible" ), "Both - rendered on button click" );
|
||||||
button.click();
|
button.click();
|
||||||
ok(!dp.is(":visible"), "Both - hidden on second button click");
|
ok( !dp.is( ":visible" ), "Both - hidden on second button click" );
|
||||||
inp.datepicker("hide").datepicker("destroy");
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
|
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
step1();
|
step0();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("otherMonths", function() {
|
test("otherMonths", function() {
|
||||||
@ -1046,44 +1067,47 @@ test("formatDate", function() {
|
|||||||
"Format date 'jour' d 'de' MM (''DD''), yy with settings");
|
"Format date 'jour' d 'de' MM (''DD''), yy with settings");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Ticket 6827: formatDate day of year calculation is wrong during day lights savings time", function(){
|
// TODO: Fix this test so it isn't mysteriously flaky in Browserstack on certain OS/Browser combos
|
||||||
expect( 1 );
|
// test("Ticket 6827: formatDate day of year calculation is wrong during day lights savings time", function(){
|
||||||
var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
|
// expect( 1 );
|
||||||
equal(time, "089");
|
// var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
|
||||||
});
|
// equal(time, "089");
|
||||||
|
// });
|
||||||
|
|
||||||
test("Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function(){
|
test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function() {
|
||||||
expect( 3 );
|
expect( 3 );
|
||||||
var inp = TestHelpers.datepicker.init("#inp",{
|
|
||||||
beforeShow: function(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
dp = $("#ui-datepicker-div");
|
|
||||||
inp.datepicker("show");
|
|
||||||
equal(dp.css("display"), "none","beforeShow returns false");
|
|
||||||
inp.datepicker("destroy");
|
|
||||||
|
|
||||||
inp = TestHelpers.datepicker.init("#inp",{
|
var inp, dp;
|
||||||
beforeShow: function(){
|
|
||||||
|
inp = TestHelpers.datepicker.init( "#inp", {
|
||||||
|
beforeShow: function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dp = $("#ui-datepicker-div");
|
dp = $( "#ui-datepicker-div" );
|
||||||
inp.datepicker("show");
|
inp.datepicker( "show" );
|
||||||
equal(dp.css("display"), "block","beforeShow returns nothing");
|
equal( dp.css( "display" ), "block", "beforeShow returns nothing" );
|
||||||
inp.datepicker("hide");
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
||||||
inp.datepicker("destroy");
|
|
||||||
|
|
||||||
inp = TestHelpers.datepicker.init("#inp",{
|
inp = TestHelpers.datepicker.init( "#inp", {
|
||||||
beforeShow: function(){
|
beforeShow: function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dp = $("#ui-datepicker-div");
|
dp = $( "#ui-datepicker-div" );
|
||||||
inp.datepicker("show");
|
inp.datepicker( "show" );
|
||||||
equal(dp.css("display"), "block","beforeShow returns true");
|
equal( dp.css( "display" ), "block", "beforeShow returns true" );
|
||||||
inp.datepicker("hide");
|
inp.datepicker( "hide" );
|
||||||
inp.datepicker("destroy");
|
inp.datepicker( "destroy" );
|
||||||
|
|
||||||
|
inp = TestHelpers.datepicker.init( "#inp", {
|
||||||
|
beforeShow: function() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dp = $( "#ui-datepicker-div" );
|
||||||
|
inp.datepicker( "show" );
|
||||||
|
equal( dp.css( "display" ), "none","beforeShow returns false" );
|
||||||
|
inp.datepicker( "destroy" );
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -14,9 +14,24 @@ TestHelpers.datepicker = {
|
|||||||
d2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate());
|
d2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate());
|
||||||
equal(d1.toString(), d2.toString(), message);
|
equal(d1.toString(), d2.toString(), message);
|
||||||
},
|
},
|
||||||
init: function(id, options) {
|
init: function( id, options ) {
|
||||||
$.datepicker.setDefaults($.datepicker.regional[""]);
|
$.datepicker.setDefaults( $.datepicker.regional[ "" ] );
|
||||||
return $(id).datepicker($.extend({showAnim: ""}, options || {}));
|
return $( id ).datepicker( $.extend( { showAnim: "" }, options || {} ) );
|
||||||
|
},
|
||||||
|
initNewInput: function( options ) {
|
||||||
|
var id = $( "<input>" ).appendTo( "#qunit-fixture" );
|
||||||
|
return TestHelpers.datepicker.init( id, options );
|
||||||
|
},
|
||||||
|
onFocus: function( element, onFocus ) {
|
||||||
|
var fn = function( event ){
|
||||||
|
if( !event.originalEvent ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element.unbind( "focus", fn );
|
||||||
|
onFocus();
|
||||||
|
};
|
||||||
|
|
||||||
|
element.bind( "focus", fn )[ 0 ].focus();
|
||||||
},
|
},
|
||||||
PROP_NAME: "datepicker"
|
PROP_NAME: "datepicker"
|
||||||
};
|
};
|
@ -75,9 +75,13 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test( "#8269: Removing draggable element on drop", function() {
|
test( "#8269: Removing draggable element on drop", function() {
|
||||||
expect( 1 );
|
expect( 2 );
|
||||||
|
|
||||||
var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable(),
|
var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable({
|
||||||
|
stop: function() {
|
||||||
|
ok( true, "stop still called despite element being removed from DOM on drop" );
|
||||||
|
}
|
||||||
|
}),
|
||||||
dropOffset = $( "#droppable" ).offset();
|
dropOffset = $( "#droppable" ).offset();
|
||||||
|
|
||||||
$( "#droppable" ).droppable({
|
$( "#droppable" ).droppable({
|
||||||
@ -87,10 +91,81 @@ test( "#8269: Removing draggable element on drop", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
|
||||||
|
if ( TestHelpers.draggable.unreliableContains ) {
|
||||||
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
||||||
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() {
|
||||||
|
expect( 2 );
|
||||||
|
|
||||||
|
var element = $( "#draggable1" ).draggable({
|
||||||
|
stop: function( event, ui ) {
|
||||||
|
equal( ui.position.left, 1, "left position is correct despite overflow on HTML" );
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
contentToForceScroll = $( "<div>" ).css({
|
||||||
|
height: "10000px",
|
||||||
|
width: "10000px"
|
||||||
|
}),
|
||||||
|
oldOverflowY = $( "html" ).css( "overflow-y" ),
|
||||||
|
oldOverflowX = $( "html" ).css( "overflow-x" );
|
||||||
|
|
||||||
|
contentToForceScroll.appendTo( "#qunit-fixture" );
|
||||||
|
$( "html" )
|
||||||
|
.css( "overflow-y", "scroll" )
|
||||||
|
.css( "overflow-x", "scroll" )
|
||||||
|
.scrollTop( 300 )
|
||||||
|
.scrollLeft( 300 );
|
||||||
|
|
||||||
|
element.simulate( "drag", {
|
||||||
|
dx: 1,
|
||||||
|
dy: 1,
|
||||||
|
moves: 1
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test( "#5009: scroll not working with parent's position fixed", function() {
|
||||||
|
expect( 2 );
|
||||||
|
|
||||||
|
var startValue = 300,
|
||||||
|
element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable({
|
||||||
|
drag: function() {
|
||||||
|
startValue += 100;
|
||||||
|
$( document ).scrollTop( startValue ).scrollLeft( startValue );
|
||||||
|
},
|
||||||
|
stop: function( event, ui ) {
|
||||||
|
equal( ui.position.left, 10, "left position is correct when parent position is fixed" );
|
||||||
|
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 );
|
||||||
|
$( "#wrapper" ).css( "position", "fixed" );
|
||||||
|
|
||||||
element.simulate( "drag", {
|
element.simulate( "drag", {
|
||||||
handle: "corner",
|
dx: 10,
|
||||||
x: dropOffset.left,
|
dy: 10,
|
||||||
y: dropOffset.top
|
moves: 3
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -451,6 +451,38 @@ test( "{ cursor: 'move' }", function() {
|
|||||||
equal( after, before, "after drag: cursor restored" );
|
equal( after, before, "after drag: cursor restored" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "#6889: Cursor doesn't revert to pre-dragging state after revert action when original element is removed", function() {
|
||||||
|
function getCursor() {
|
||||||
|
return $( "body" ).css( "cursor" );
|
||||||
|
}
|
||||||
|
|
||||||
|
expect( 2 );
|
||||||
|
|
||||||
|
var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable({
|
||||||
|
cursor: "move",
|
||||||
|
revert: true,
|
||||||
|
revertDuration: 0,
|
||||||
|
start: function() {
|
||||||
|
notEqual( getCursor(), expected, "start callback: cursor '" + expected + "'" );
|
||||||
|
$( "#wrapper" ).remove();
|
||||||
|
},
|
||||||
|
stop: function() {
|
||||||
|
equal( getCursor(), expected, "after drag: cursor restored" );
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
expected = getCursor();
|
||||||
|
|
||||||
|
if ( TestHelpers.draggable.unreliableContains ) {
|
||||||
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
||||||
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
||||||
|
} else {
|
||||||
|
element.simulate( "drag", {
|
||||||
|
dx: -1,
|
||||||
|
dy: -1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test( "cursor, default, switching after initialization", function() {
|
test( "cursor, default, switching after initialization", function() {
|
||||||
expect( 3 );
|
expect( 3 );
|
||||||
|
|
||||||
@ -1289,9 +1321,15 @@ test( "#8459: element can snap to an element that was removed during drag", func
|
|||||||
moves: 1
|
moves: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
|
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
|
||||||
closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" );
|
if ( TestHelpers.draggable.unreliableContains ) {
|
||||||
closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" );
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
||||||
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
||||||
|
} else {
|
||||||
|
// TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
|
||||||
|
closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" );
|
||||||
|
closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() {
|
test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() {
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
TestHelpers.draggable = {
|
TestHelpers.draggable = {
|
||||||
// todo: remove the unreliable offset hacks
|
// TODO: remove the unreliable offset hacks
|
||||||
unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
|
unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
|
||||||
testDrag: function(el, handle, dx, dy, expectedDX, expectedDY, msg) {
|
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
|
||||||
|
unreliableContains: (function(){
|
||||||
|
var element = $( "<div>" );
|
||||||
|
return $.contains( element[ 0 ].ownerDocument, element[ 0 ] );
|
||||||
|
})(),
|
||||||
|
testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) {
|
||||||
var offsetAfter, actual, expected,
|
var offsetAfter, actual, expected,
|
||||||
offsetBefore = el.offset();
|
offsetBefore = el.offset();
|
||||||
|
|
||||||
@ -15,64 +20,60 @@ TestHelpers.draggable = {
|
|||||||
expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
|
expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
|
||||||
|
|
||||||
msg = msg ? msg + "." : "";
|
msg = msg ? msg + "." : "";
|
||||||
deepEqual(actual, expected, "dragged[" + dx + ", " + dy + "] " + msg);
|
deepEqual( actual, expected, "dragged[" + dx + ", " + dy + "] " + msg );
|
||||||
},
|
},
|
||||||
shouldMove: function(el, why) {
|
shouldMove: function( el, why ) {
|
||||||
TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50, why);
|
TestHelpers.draggable.testDrag( el, el, 50, 50, 50, 50, why );
|
||||||
},
|
},
|
||||||
shouldNotMove: function(el, why) {
|
shouldNotMove: function( el, why ) {
|
||||||
TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 0, why);
|
TestHelpers.draggable.testDrag( el, el, 50, 50, 0, 0, why );
|
||||||
},
|
},
|
||||||
testScroll: function(el, position ) {
|
testScroll: function( el, position ) {
|
||||||
var oldPosition = $("#main").css("position");
|
var oldPosition = $( "#main" ).css( "position" );
|
||||||
$("#main").css("position", position);
|
$( "#main" ).css( "position", position);
|
||||||
TestHelpers.draggable.shouldMove(el, position+" parent");
|
TestHelpers.draggable.shouldMove( el, position + " parent" );
|
||||||
$("#main").css("position", oldPosition);
|
$( "#main" ).css( "position", oldPosition );
|
||||||
},
|
},
|
||||||
restoreScroll: function( what ) {
|
restoreScroll: function( what ) {
|
||||||
if( what ) {
|
if( what ) {
|
||||||
$(document).scrollTop(0); $(document).scrollLeft(0);
|
$( document ).scrollTop( 0 ).scrollLeft( 0 );
|
||||||
} else {
|
} else {
|
||||||
$("#main").scrollTop(0); $("#main").scrollLeft(0);
|
$( "#main" ).scrollTop( 0 ).scrollLeft( 0 );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setScroll: function( what ) {
|
setScroll: function( what ) {
|
||||||
if(what) {
|
if( what ) {
|
||||||
// todo: currently, the draggable interaction doesn't properly account for scrolled pages,
|
// 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
|
// uncomment the line below to make the tests fail that should when the page is scrolled
|
||||||
// $(document).scrollTop(100); $(document).scrollLeft(100);
|
// $( document ).scrollTop( 100 ).scrollLeft( 100 );
|
||||||
} else {
|
} else {
|
||||||
$("#main").scrollTop(100); $("#main").scrollLeft(100);
|
$( "#main" ).scrollTop( 100 ).scrollLeft( 100 );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
border: function(el, side) {
|
border: function( el, side ) {
|
||||||
return parseInt(el.css("border-" + side + "-width"), 10) || 0;
|
return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0;
|
||||||
},
|
},
|
||||||
margin: function(el, side) {
|
margin: function( el, side ) {
|
||||||
return parseInt(el.css("margin-" + side), 10) || 0;
|
return parseInt( el.css( "margin-" + side ), 10 ) || 0;
|
||||||
},
|
},
|
||||||
move: function( el, x, y ) {
|
move: function( el, x, y ) {
|
||||||
|
|
||||||
$( el ).simulate( "drag", {
|
$( el ).simulate( "drag", {
|
||||||
dx: x,
|
dx: x,
|
||||||
dy: y
|
dy: y
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
trackMouseCss : function( el ) {
|
trackMouseCss : function( el ) {
|
||||||
el.bind( "drag", function() {
|
el.bind( "drag", function() {
|
||||||
el.data( "last_dragged_cursor", $("body").css("cursor") );
|
el.data( "last_dragged_cursor", $( "body" ).css( "cursor" ) );
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
trackAppendedParent : function( el ) {
|
trackAppendedParent : function( el ) {
|
||||||
|
// TODO: appendTo is currently ignored if helper is original (see #7044)
|
||||||
// appendTo ignored without being clone
|
|
||||||
el.draggable( "option", "helper", "clone" );
|
el.draggable( "option", "helper", "clone" );
|
||||||
|
|
||||||
|
// Get what parent is at time of drag
|
||||||
el.bind( "drag", function(e,ui) {
|
el.bind( "drag", function(e,ui) {
|
||||||
// Get what parent is at time of drag
|
el.data( "last_dragged_parent", ui.helper.parent()[ 0 ] );
|
||||||
el.data( "last_dragged_parent", ui.helper.parent()[0] );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
12
ui/.jshintrc
12
ui/.jshintrc
@ -1,17 +1,21 @@
|
|||||||
{
|
{
|
||||||
"browser": true,
|
"boss": true,
|
||||||
"curly": true,
|
"curly": true,
|
||||||
"eqnull": true,
|
|
||||||
"eqeqeq": true,
|
"eqeqeq": true,
|
||||||
|
"eqnull": true,
|
||||||
"expr": true,
|
"expr": true,
|
||||||
"jquery": true,
|
"immed": true,
|
||||||
"latedef": true,
|
|
||||||
"noarg": true,
|
"noarg": true,
|
||||||
"onevar": true,
|
"onevar": true,
|
||||||
"quotmark": "double",
|
"quotmark": "double",
|
||||||
|
"smarttabs": true,
|
||||||
"trailing": true,
|
"trailing": true,
|
||||||
"undef": true,
|
"undef": true,
|
||||||
"unused": true,
|
"unused": true,
|
||||||
|
|
||||||
|
"browser": true,
|
||||||
|
"jquery": true,
|
||||||
|
|
||||||
"globals": {
|
"globals": {
|
||||||
"Globalize": false
|
"Globalize": false
|
||||||
}
|
}
|
||||||
|
2
ui/i18n/jquery.ui.datepicker-sr-SR.js
vendored
2
ui/i18n/jquery.ui.datepicker-sr-SR.js
vendored
@ -14,7 +14,7 @@ jQuery(function($){
|
|||||||
dayNamesShort: ['Ned','Pon','Uto','Sre','Čet','Pet','Sub'],
|
dayNamesShort: ['Ned','Pon','Uto','Sre','Čet','Pet','Sub'],
|
||||||
dayNamesMin: ['Ne','Po','Ut','Sr','Če','Pe','Su'],
|
dayNamesMin: ['Ne','Po','Ut','Sr','Če','Pe','Su'],
|
||||||
weekHeader: 'Sed',
|
weekHeader: 'Sed',
|
||||||
dateFormat: 'dd/mm/yy',
|
dateFormat: 'dd.mm.yy',
|
||||||
firstDay: 1,
|
firstDay: 1,
|
||||||
isRTL: false,
|
isRTL: false,
|
||||||
showMonthAfterYear: false,
|
showMonthAfterYear: false,
|
||||||
|
2
ui/i18n/jquery.ui.datepicker-sr.js
vendored
2
ui/i18n/jquery.ui.datepicker-sr.js
vendored
@ -14,7 +14,7 @@ jQuery(function($){
|
|||||||
dayNamesShort: ['Нед','Пон','Уто','Сре','Чет','Пет','Суб'],
|
dayNamesShort: ['Нед','Пон','Уто','Сре','Чет','Пет','Суб'],
|
||||||
dayNamesMin: ['Не','По','Ут','Ср','Че','Пе','Су'],
|
dayNamesMin: ['Не','По','Ут','Ср','Че','Пе','Су'],
|
||||||
weekHeader: 'Сед',
|
weekHeader: 'Сед',
|
||||||
dateFormat: 'dd/mm/yy',
|
dateFormat: 'dd.mm.yy',
|
||||||
firstDay: 1,
|
firstDay: 1,
|
||||||
isRTL: false,
|
isRTL: false,
|
||||||
showMonthAfterYear: false,
|
showMonthAfterYear: false,
|
||||||
|
31
ui/jquery.ui.button.js
vendored
31
ui/jquery.ui.button.js
vendored
@ -16,12 +16,11 @@
|
|||||||
|
|
||||||
var lastActive, startXPos, startYPos, clickDragged,
|
var lastActive, startXPos, startYPos, clickDragged,
|
||||||
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
|
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
|
||||||
stateClasses = "ui-state-hover ui-state-active ",
|
|
||||||
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
|
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
|
||||||
formResetHandler = function() {
|
formResetHandler = function() {
|
||||||
var buttons = $( this ).find( ":ui-button" );
|
var form = $( this );
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
buttons.button( "refresh" );
|
form.find( ":ui-button" ).button( "refresh" );
|
||||||
}, 1 );
|
}, 1 );
|
||||||
},
|
},
|
||||||
radioGroup = function( radio ) {
|
radioGroup = function( radio ) {
|
||||||
@ -71,8 +70,7 @@ $.widget( "ui.button", {
|
|||||||
var that = this,
|
var that = this,
|
||||||
options = this.options,
|
options = this.options,
|
||||||
toggleButton = this.type === "checkbox" || this.type === "radio",
|
toggleButton = this.type === "checkbox" || this.type === "radio",
|
||||||
activeClass = !toggleButton ? "ui-state-active" : "",
|
activeClass = !toggleButton ? "ui-state-active" : "";
|
||||||
focusClass = "ui-state-focus";
|
|
||||||
|
|
||||||
if ( options.label === null ) {
|
if ( options.label === null ) {
|
||||||
options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
|
options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
|
||||||
@ -104,14 +102,16 @@ $.widget( "ui.button", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.element
|
// Can't use _focusable() because the element that receives focus
|
||||||
.bind( "focus" + this.eventNamespace, function() {
|
// and the element that gets the ui-state-focus class are different
|
||||||
// no need to check disabled, focus won't be triggered anyway
|
this._on({
|
||||||
that.buttonElement.addClass( focusClass );
|
focus: function() {
|
||||||
})
|
this.buttonElement.addClass( "ui-state-focus" );
|
||||||
.bind( "blur" + this.eventNamespace, function() {
|
},
|
||||||
that.buttonElement.removeClass( focusClass );
|
blur: function() {
|
||||||
});
|
this.buttonElement.removeClass( "ui-state-focus" );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if ( toggleButton ) {
|
if ( toggleButton ) {
|
||||||
this.element.bind( "change" + this.eventNamespace, function() {
|
this.element.bind( "change" + this.eventNamespace, function() {
|
||||||
@ -257,7 +257,7 @@ $.widget( "ui.button", {
|
|||||||
this.element
|
this.element
|
||||||
.removeClass( "ui-helper-hidden-accessible" );
|
.removeClass( "ui-helper-hidden-accessible" );
|
||||||
this.buttonElement
|
this.buttonElement
|
||||||
.removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
|
.removeClass( baseClasses + " ui-state-active " + typeClasses )
|
||||||
.removeAttr( "role" )
|
.removeAttr( "role" )
|
||||||
.removeAttr( "aria-pressed" )
|
.removeAttr( "aria-pressed" )
|
||||||
.html( this.buttonElement.find(".ui-button-text").html() );
|
.html( this.buttonElement.find(".ui-button-text").html() );
|
||||||
@ -272,6 +272,9 @@ $.widget( "ui.button", {
|
|||||||
if ( key === "disabled" ) {
|
if ( key === "disabled" ) {
|
||||||
this.widget().toggleClass( "ui-state-disabled", !!value );
|
this.widget().toggleClass( "ui-state-disabled", !!value );
|
||||||
this.element.prop( "disabled", !!value );
|
this.element.prop( "disabled", !!value );
|
||||||
|
if ( value ) {
|
||||||
|
this.buttonElement.removeClass( "ui-state-focus" );
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._resetButton();
|
this._resetButton();
|
||||||
|
9
ui/jquery.ui.core.js
vendored
9
ui/jquery.ui.core.js
vendored
@ -276,10 +276,15 @@ $.ui.plugin = {
|
|||||||
proto.plugins[ i ].push( [ option, set[ i ] ] );
|
proto.plugins[ i ].push( [ option, set[ i ] ] );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
call: function( instance, name, args ) {
|
call: function( instance, name, args, allowDisconnected ) {
|
||||||
var i,
|
var i,
|
||||||
set = instance.plugins[ name ];
|
set = instance.plugins[ name ];
|
||||||
if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
|
|
||||||
|
if ( !set ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
ui/jquery.ui.datepicker.js
vendored
42
ui/jquery.ui.datepicker.js
vendored
@ -16,7 +16,6 @@
|
|||||||
$.extend($.ui, { datepicker: { version: "@VERSION" } });
|
$.extend($.ui, { datepicker: { version: "@VERSION" } });
|
||||||
|
|
||||||
var PROP_NAME = "datepicker",
|
var PROP_NAME = "datepicker",
|
||||||
dpuuid = new Date().getTime(),
|
|
||||||
instActive;
|
instActive;
|
||||||
|
|
||||||
function getZindex( elem ) {
|
function getZindex( elem ) {
|
||||||
@ -775,9 +774,10 @@ $.extend(Datepicker.prototype, {
|
|||||||
inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
|
inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inst.input.is(":visible") && !inst.input.is(":disabled")) {
|
if ( $.datepicker._shouldFocusInput( inst ) ) {
|
||||||
inst.input.focus();
|
inst.input.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
$.datepicker._curInst = inst;
|
$.datepicker._curInst = inst;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -804,10 +804,7 @@ $.extend(Datepicker.prototype, {
|
|||||||
inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
|
inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
|
||||||
"Class"]("ui-datepicker-rtl");
|
"Class"]("ui-datepicker-rtl");
|
||||||
|
|
||||||
// #6694 - don't focus the input if it's already focused
|
if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
|
||||||
// this breaks the change event in IE
|
|
||||||
if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
|
|
||||||
inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) {
|
|
||||||
inst.input.focus();
|
inst.input.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,16 +821,11 @@ $.extend(Datepicker.prototype, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Retrieve the size of left and top borders for an element.
|
// #6694 - don't focus the input if it's already focused
|
||||||
* @param elem (jQuery object) the element of interest
|
// this breaks the change event in IE
|
||||||
* @return (number[2]) the left and top borders
|
// Support: IE and jQuery <1.9
|
||||||
*/
|
_shouldFocusInput: function( inst ) {
|
||||||
_getBorders: function(elem) {
|
return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
|
||||||
var convert = function(value) {
|
|
||||||
return {thin: 1, medium: 2, thick: 3}[value] || value;
|
|
||||||
};
|
|
||||||
return [parseFloat(convert(elem.css("border-left-width"))),
|
|
||||||
parseFloat(convert(elem.css("border-top-width")))];
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Check positioning to remain on screen. */
|
/* Check positioning to remain on screen. */
|
||||||
@ -1580,27 +1572,27 @@ $.extend(Datepicker.prototype, {
|
|||||||
inst.dpDiv.find("[data-handler]").map(function () {
|
inst.dpDiv.find("[data-handler]").map(function () {
|
||||||
var handler = {
|
var handler = {
|
||||||
prev: function () {
|
prev: function () {
|
||||||
window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, -stepMonths, "M");
|
$.datepicker._adjustDate(id, -stepMonths, "M");
|
||||||
},
|
},
|
||||||
next: function () {
|
next: function () {
|
||||||
window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, +stepMonths, "M");
|
$.datepicker._adjustDate(id, +stepMonths, "M");
|
||||||
},
|
},
|
||||||
hide: function () {
|
hide: function () {
|
||||||
window["DP_jQuery_" + dpuuid].datepicker._hideDatepicker();
|
$.datepicker._hideDatepicker();
|
||||||
},
|
},
|
||||||
today: function () {
|
today: function () {
|
||||||
window["DP_jQuery_" + dpuuid].datepicker._gotoToday(id);
|
$.datepicker._gotoToday(id);
|
||||||
},
|
},
|
||||||
selectDay: function () {
|
selectDay: function () {
|
||||||
window["DP_jQuery_" + dpuuid].datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
|
$.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
selectMonth: function () {
|
selectMonth: function () {
|
||||||
window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "M");
|
$.datepicker._selectMonthYear(id, this, "M");
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
selectYear: function () {
|
selectYear: function () {
|
||||||
window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "Y");
|
$.datepicker._selectMonthYear(id, this, "Y");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2065,8 +2057,4 @@ $.datepicker.initialized = false;
|
|||||||
$.datepicker.uuid = new Date().getTime();
|
$.datepicker.uuid = new Date().getTime();
|
||||||
$.datepicker.version = "@VERSION";
|
$.datepicker.version = "@VERSION";
|
||||||
|
|
||||||
// Workaround for #4055
|
|
||||||
// Add another global to avoid noConflict issues with inline event handlers
|
|
||||||
window["DP_jQuery_" + dpuuid] = $;
|
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
101
ui/jquery.ui.draggable.js
vendored
101
ui/jquery.ui.draggable.js
vendored
@ -66,6 +66,10 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_destroy: function() {
|
_destroy: function() {
|
||||||
|
if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
|
||||||
|
this.destroyOnClear = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
|
this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
|
||||||
this._mouseDestroy();
|
this._mouseDestroy();
|
||||||
},
|
},
|
||||||
@ -125,8 +129,10 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
this._cacheMargins();
|
this._cacheMargins();
|
||||||
|
|
||||||
//Store the helper's css position
|
//Store the helper's css position
|
||||||
this.cssPosition = this.helper.css("position");
|
this.cssPosition = this.helper.css( "position" );
|
||||||
this.scrollParent = this.helper.scrollParent();
|
this.scrollParent = this.helper.scrollParent();
|
||||||
|
this.offsetParent = this.helper.offsetParent();
|
||||||
|
this.offsetParentCssPosition = this.offsetParent.css( "position" );
|
||||||
|
|
||||||
//The element's absolute position on the page minus margins
|
//The element's absolute position on the page minus margins
|
||||||
this.offset = this.positionAbs = this.element.offset();
|
this.offset = this.positionAbs = this.element.offset();
|
||||||
@ -184,6 +190,10 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_mouseDrag: function(event, noPropagation) {
|
_mouseDrag: function(event, noPropagation) {
|
||||||
|
// reset any necessary cached properties (see #5009)
|
||||||
|
if ( this.offsetParentCssPosition === "fixed" ) {
|
||||||
|
this.offset.parent = this._getParentOffset();
|
||||||
|
}
|
||||||
|
|
||||||
//Compute the helpers position
|
//Compute the helpers position
|
||||||
this.position = this._generatePosition(event);
|
this.position = this._generatePosition(event);
|
||||||
@ -227,11 +237,6 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
this.dropped = false;
|
this.dropped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the original element is no longer in the DOM don't bother to continue (see #8269)
|
|
||||||
if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
|
if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
|
||||||
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
|
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
|
||||||
if(that._trigger("stop", event) !== false) {
|
if(that._trigger("stop", event) !== false) {
|
||||||
@ -320,7 +325,6 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
_getParentOffset: function() {
|
_getParentOffset: function() {
|
||||||
|
|
||||||
//Get the offsetParent and cache its position
|
//Get the offsetParent and cache its position
|
||||||
this.offsetParent = this.helper.offsetParent();
|
|
||||||
var po = this.offsetParent.offset();
|
var po = this.offsetParent.offset();
|
||||||
|
|
||||||
// This is a special case where we need to modify a offset calculated on start, since the following happened:
|
// This is a special case where we need to modify a offset calculated on start, since the following happened:
|
||||||
@ -440,7 +444,7 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mod = d === "absolute" ? 1 : -1,
|
var mod = d === "absolute" ? 1 : -1,
|
||||||
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
|
||||||
|
|
||||||
//Cache the scroll
|
//Cache the scroll
|
||||||
if (!this.offset.scroll) {
|
if (!this.offset.scroll) {
|
||||||
@ -452,13 +456,13 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
pos.top + // The absolute mouse position
|
pos.top + // The absolute mouse position
|
||||||
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
||||||
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
|
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
|
||||||
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
|
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
|
||||||
),
|
),
|
||||||
left: (
|
left: (
|
||||||
pos.left + // The absolute mouse position
|
pos.left + // The absolute mouse position
|
||||||
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
||||||
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
|
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
|
||||||
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left ) * mod)
|
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -468,8 +472,7 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
|
|
||||||
var containment, co, top, left,
|
var containment, co, top, left,
|
||||||
o = this.options,
|
o = this.options,
|
||||||
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
|
scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
|
||||||
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName),
|
|
||||||
pageX = event.pageX,
|
pageX = event.pageX,
|
||||||
pageY = event.pageY;
|
pageY = event.pageY;
|
||||||
|
|
||||||
@ -530,14 +533,14 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
this.offset.click.top - // Click offset (relative to the element)
|
this.offset.click.top - // Click offset (relative to the element)
|
||||||
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
|
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
|
||||||
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
|
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
|
||||||
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ))
|
( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
|
||||||
),
|
),
|
||||||
left: (
|
left: (
|
||||||
pageX - // The absolute mouse position
|
pageX - // The absolute mouse position
|
||||||
this.offset.click.left - // Click offset (relative to the element)
|
this.offset.click.left - // Click offset (relative to the element)
|
||||||
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
|
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
|
||||||
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
|
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
|
||||||
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left ))
|
( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -550,13 +553,16 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
}
|
}
|
||||||
this.helper = null;
|
this.helper = null;
|
||||||
this.cancelHelperRemoval = false;
|
this.cancelHelperRemoval = false;
|
||||||
|
if ( this.destroyOnClear ) {
|
||||||
|
this.destroy();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// From now on bulk stuff - mainly helpers
|
// From now on bulk stuff - mainly helpers
|
||||||
|
|
||||||
_trigger: function(type, event, ui) {
|
_trigger: function(type, event, ui) {
|
||||||
ui = ui || this._uiHash();
|
ui = ui || this._uiHash();
|
||||||
$.ui.plugin.call(this, type, [event, ui]);
|
$.ui.plugin.call( this, type, [ event, ui, this ], true );
|
||||||
//The absolute position has to be recalculated after plugins
|
//The absolute position has to be recalculated after plugins
|
||||||
if(type === "drag") {
|
if(type === "drag") {
|
||||||
this.positionAbs = this._convertPositionTo("absolute");
|
this.positionAbs = this._convertPositionTo("absolute");
|
||||||
@ -578,9 +584,9 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.ui.plugin.add("draggable", "connectToSortable", {
|
$.ui.plugin.add("draggable", "connectToSortable", {
|
||||||
start: function(event, ui) {
|
start: function( event, ui, inst ) {
|
||||||
|
|
||||||
var inst = $(this).draggable( "instance" ), o = inst.options,
|
var o = inst.options,
|
||||||
uiSortable = $.extend({}, ui, { item: inst.element });
|
uiSortable = $.extend({}, ui, { item: inst.element });
|
||||||
inst.sortables = [];
|
inst.sortables = [];
|
||||||
$(o.connectToSortable).each(function() {
|
$(o.connectToSortable).each(function() {
|
||||||
@ -596,11 +602,12 @@ $.ui.plugin.add("draggable", "connectToSortable", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
stop: function(event, ui) {
|
stop: function( event, ui, inst ) {
|
||||||
|
|
||||||
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
|
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
|
||||||
var inst = $(this).draggable( "instance" ),
|
var uiSortable = $.extend( {}, ui, {
|
||||||
uiSortable = $.extend({}, ui, { item: inst.element });
|
item: inst.element
|
||||||
|
});
|
||||||
|
|
||||||
$.each(inst.sortables, function() {
|
$.each(inst.sortables, function() {
|
||||||
if(this.instance.isOver) {
|
if(this.instance.isOver) {
|
||||||
@ -633,9 +640,9 @@ $.ui.plugin.add("draggable", "connectToSortable", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
drag: function(event, ui) {
|
drag: function( event, ui, inst ) {
|
||||||
|
|
||||||
var inst = $(this).draggable( "instance" ), that = this;
|
var that = this;
|
||||||
|
|
||||||
$.each(inst.sortables, function() {
|
$.each(inst.sortables, function() {
|
||||||
|
|
||||||
@ -735,15 +742,17 @@ $.ui.plugin.add("draggable", "connectToSortable", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.ui.plugin.add("draggable", "cursor", {
|
$.ui.plugin.add("draggable", "cursor", {
|
||||||
start: function() {
|
start: function( event, ui, instance ) {
|
||||||
var t = $("body"), o = $(this).draggable( "instance" ).options;
|
var t = $( "body" ),
|
||||||
|
o = instance.options;
|
||||||
|
|
||||||
if (t.css("cursor")) {
|
if (t.css("cursor")) {
|
||||||
o._cursor = t.css("cursor");
|
o._cursor = t.css("cursor");
|
||||||
}
|
}
|
||||||
t.css("cursor", o.cursor);
|
t.css("cursor", o.cursor);
|
||||||
},
|
},
|
||||||
stop: function() {
|
stop: function( event, ui, instance ) {
|
||||||
var o = $(this).draggable( "instance" ).options;
|
var o = instance.options;
|
||||||
if (o._cursor) {
|
if (o._cursor) {
|
||||||
$("body").css("cursor", o._cursor);
|
$("body").css("cursor", o._cursor);
|
||||||
}
|
}
|
||||||
@ -751,15 +760,16 @@ $.ui.plugin.add("draggable", "cursor", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.ui.plugin.add("draggable", "opacity", {
|
$.ui.plugin.add("draggable", "opacity", {
|
||||||
start: function(event, ui) {
|
start: function( event, ui, instance ) {
|
||||||
var t = $(ui.helper), o = $(this).draggable( "instance" ).options;
|
var t = $( ui.helper ),
|
||||||
|
o = instance.options;
|
||||||
if(t.css("opacity")) {
|
if(t.css("opacity")) {
|
||||||
o._opacity = t.css("opacity");
|
o._opacity = t.css("opacity");
|
||||||
}
|
}
|
||||||
t.css("opacity", o.opacity);
|
t.css("opacity", o.opacity);
|
||||||
},
|
},
|
||||||
stop: function(event, ui) {
|
stop: function( event, ui, instance ) {
|
||||||
var o = $(this).draggable( "instance" ).options;
|
var o = instance.options;
|
||||||
if(o._opacity) {
|
if(o._opacity) {
|
||||||
$(ui.helper).css("opacity", o._opacity);
|
$(ui.helper).css("opacity", o._opacity);
|
||||||
}
|
}
|
||||||
@ -767,15 +777,15 @@ $.ui.plugin.add("draggable", "opacity", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.ui.plugin.add("draggable", "scroll", {
|
$.ui.plugin.add("draggable", "scroll", {
|
||||||
start: function() {
|
start: function( event, ui, i ) {
|
||||||
var i = $(this).draggable( "instance" );
|
|
||||||
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
|
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
|
||||||
i.overflowOffset = i.scrollParent.offset();
|
i.overflowOffset = i.scrollParent.offset();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
drag: function( event ) {
|
drag: function( event, ui, i ) {
|
||||||
|
|
||||||
var i = $(this).draggable( "instance" ), o = i.options, scrolled = false;
|
var o = i.options,
|
||||||
|
scrolled = false;
|
||||||
|
|
||||||
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
|
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
|
||||||
|
|
||||||
@ -823,10 +833,9 @@ $.ui.plugin.add("draggable", "scroll", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.ui.plugin.add("draggable", "snap", {
|
$.ui.plugin.add("draggable", "snap", {
|
||||||
start: function() {
|
start: function( event, ui, i ) {
|
||||||
|
|
||||||
var i = $(this).draggable( "instance" ),
|
var o = i.options;
|
||||||
o = i.options;
|
|
||||||
|
|
||||||
i.snapElements = [];
|
i.snapElements = [];
|
||||||
|
|
||||||
@ -843,10 +852,9 @@ $.ui.plugin.add("draggable", "snap", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
drag: function(event, ui) {
|
drag: function( event, ui, inst ) {
|
||||||
|
|
||||||
var ts, bs, ls, rs, l, r, t, b, i, first,
|
var ts, bs, ls, rs, l, r, t, b, i, first,
|
||||||
inst = $(this).draggable( "instance" ),
|
|
||||||
o = inst.options,
|
o = inst.options,
|
||||||
d = o.snapTolerance,
|
d = o.snapTolerance,
|
||||||
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
|
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
|
||||||
@ -918,9 +926,9 @@ $.ui.plugin.add("draggable", "snap", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.ui.plugin.add("draggable", "stack", {
|
$.ui.plugin.add("draggable", "stack", {
|
||||||
start: function() {
|
start: function( event, ui, instance ) {
|
||||||
var min,
|
var min,
|
||||||
o = $(this).draggable( "instance" ).options,
|
o = instance.options,
|
||||||
group = $.makeArray($(o.stack)).sort(function(a,b) {
|
group = $.makeArray($(o.stack)).sort(function(a,b) {
|
||||||
return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
|
return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
|
||||||
});
|
});
|
||||||
@ -936,15 +944,18 @@ $.ui.plugin.add("draggable", "stack", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.ui.plugin.add("draggable", "zIndex", {
|
$.ui.plugin.add("draggable", "zIndex", {
|
||||||
start: function(event, ui) {
|
start: function( event, ui, instance ) {
|
||||||
var t = $(ui.helper), o = $(this).draggable( "instance" ).options;
|
var t = $( ui.helper ),
|
||||||
|
o = instance.options;
|
||||||
|
|
||||||
if(t.css("zIndex")) {
|
if(t.css("zIndex")) {
|
||||||
o._zIndex = t.css("zIndex");
|
o._zIndex = t.css("zIndex");
|
||||||
}
|
}
|
||||||
t.css("zIndex", o.zIndex);
|
t.css("zIndex", o.zIndex);
|
||||||
},
|
},
|
||||||
stop: function(event, ui) {
|
stop: function( event, ui, instance ) {
|
||||||
var o = $(this).draggable( "instance" ).options;
|
var o = instance.options;
|
||||||
|
|
||||||
if(o._zIndex) {
|
if(o._zIndex) {
|
||||||
$(ui.helper).css("zIndex", o._zIndex);
|
$(ui.helper).css("zIndex", o._zIndex);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user