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
f6372bd7ea
@ -56,7 +56,7 @@ function submit( commit, tests, configFile, version, done ) {
|
||||
runMax: config.runMax,
|
||||
"runNames[]": Object.keys( tests ),
|
||||
"runUrls[]": testUrls,
|
||||
"browserSets[]": [ "popular-no-ie6" ]
|
||||
"browserSets[]": config.browserSets
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
<link rel="stylesheet" href="../demos.css">
|
||||
<style>
|
||||
#toolbar {
|
||||
padding: 11px 4px 9px 4px;
|
||||
padding: 4px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* support: IE7 */
|
||||
*:first-child+html #toolbar {
|
||||
padding: 4px 0px 4px 5px;
|
||||
*+html #toolbar {
|
||||
display: inline;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
@ -91,7 +91,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<span id="toolbar" class="ui-widget-header ui-corner-all">
|
||||
<div id="toolbar" class="ui-widget-header ui-corner-all">
|
||||
<button id="beginning">go to beginning</button>
|
||||
<button id="rewind">rewind</button>
|
||||
<button id="play">play</button>
|
||||
@ -106,7 +106,7 @@
|
||||
<input type="radio" id="repeat1" name="repeat" /><label for="repeat1">Once</label>
|
||||
<input type="radio" id="repeatall" name="repeat" /><label for="repeatall">All</label>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="demo-description">
|
||||
<p>
|
||||
|
@ -12,6 +12,7 @@
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-ar.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-ar-DZ.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-az.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-be.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-bg.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-bs.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-ca.js"></script>
|
||||
@ -53,8 +54,10 @@
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-mk.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-ml.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-ms.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-nb.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-nl.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-nl-BE.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-nn.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-no.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-pl.js"></script>
|
||||
<script src="../../ui/i18n/jquery.ui.datepicker-pt.js"></script>
|
||||
@ -100,6 +103,7 @@
|
||||
<option value="hy">Armenian (Հայերեն)</option>
|
||||
<option value="az">Azerbaijani (Azərbaycan dili)</option>
|
||||
<option value="eu">Basque (Euskara)</option>
|
||||
<option value="be">Belarusian</option>
|
||||
<option value="bs">Bosnian (Bosanski)</option>
|
||||
<option value="bg">Bulgarian (български език)</option>
|
||||
<option value="ca">Catalan (Català)</option>
|
||||
@ -142,7 +146,9 @@
|
||||
<option value="mk">Macedonian</option>
|
||||
<option value="ml">Malayalam</option>
|
||||
<option value="ms">Malaysian (Bahasa Malaysia)</option>
|
||||
<option value="nb">Norwegian (Bokmål)</option>
|
||||
<option value="no">Norwegian (Norsk)</option>
|
||||
<option value="nn">Norwegian (Nynorsk)</option>
|
||||
<option value="pl">Polish (Polski)</option>
|
||||
<option value="pt">Portuguese (Português)</option>
|
||||
<option value="pt-BR">Portuguese/Brazilian (Português)</option>
|
||||
|
@ -1,34 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Progressbar - Animated</title>
|
||||
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
|
||||
<script src="../../jquery-1.8.3.js"></script>
|
||||
<script src="../../ui/jquery.ui.core.js"></script>
|
||||
<script src="../../ui/jquery.ui.widget.js"></script>
|
||||
<script src="../../ui/jquery.ui.progressbar.js"></script>
|
||||
<link rel="stylesheet" href="../demos.css">
|
||||
<script>
|
||||
$(function() {
|
||||
$( "#progressbar" ).progressbar({
|
||||
value: 59
|
||||
}).find( ".ui-progressbar-value div" ).addClass( "ui-progressbar-overlay" );
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="progressbar"></div>
|
||||
|
||||
<div class="demo-description">
|
||||
<p>
|
||||
This progressbar has an animated fill by setting the
|
||||
<code>ui-progressbar-overlay</code> class
|
||||
on the
|
||||
<code>.ui-progressbar-value</code>
|
||||
element's overlay div.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -16,26 +16,26 @@
|
||||
});
|
||||
$( "button" ).on( "click", function( event ) {
|
||||
var target = $( event.target ),
|
||||
pbar = $( "#progressbar" ),
|
||||
pbarValue = pbar.find( ".ui-progressbar-value" );
|
||||
progressbar = $( "#progressbar" ),
|
||||
progressbarValue = progressbar.find( ".ui-progressbar-value" );
|
||||
|
||||
if ( target.is( "#numButton" ) ) {
|
||||
pbar.progressbar( "option", {
|
||||
progressbar.progressbar( "option", {
|
||||
value: Math.floor( Math.random() * 100 )
|
||||
});
|
||||
} else if ( target.is( "#colorButton" ) ) {
|
||||
pbarValue.css({
|
||||
progressbarValue.css({
|
||||
"background": '#' + Math.floor( Math.random() * 16777215 ).toString( 16 )
|
||||
});
|
||||
} else if ( target.is( "#falseButton" ) ) {
|
||||
pbar.progressbar( "option", "value", false );
|
||||
progressbar.progressbar( "option", "value", false );
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
#progressbar .ui-progressbar-value {
|
||||
background-color: #CCCCCC;
|
||||
background-color: #ccc;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
@ -8,9 +8,8 @@
|
||||
|
||||
<ul>
|
||||
<li><a href="default.html">Default functionality</a></li>
|
||||
<li><a href="animated.html">Animated</a></li>
|
||||
<li><a href="resize.html">Resizable progressbar</a></li>
|
||||
<li><a href="indeterminate.html">Indeterminate</a></li>
|
||||
<li><a href="label.html">Custom Labels</a></li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
|
58
demos/progressbar/label.html
Normal file
58
demos/progressbar/label.html
Normal file
@ -0,0 +1,58 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Progressbar - Custom Label</title>
|
||||
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
|
||||
<script src="../../jquery-1.8.3.js"></script>
|
||||
<script src="../../ui/jquery.ui.core.js"></script>
|
||||
<script src="../../ui/jquery.ui.widget.js"></script>
|
||||
<script src="../../ui/jquery.ui.progressbar.js"></script>
|
||||
<link rel="stylesheet" href="../demos.css">
|
||||
<style>
|
||||
.progress-label {
|
||||
float: left;
|
||||
margin-left: 50%;
|
||||
margin-top: 5px;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 0 #fff;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
$(function() {
|
||||
var progressbar = $( "#progressbar" ),
|
||||
progressLabel = $( ".progress-label" );
|
||||
|
||||
progressbar.progressbar({
|
||||
value: false,
|
||||
change: function() {
|
||||
progressLabel.text( progressbar.progressbar( "value" ) + "%" );
|
||||
},
|
||||
complete: function() {
|
||||
progressLabel.text( "Complete!" );
|
||||
}
|
||||
});
|
||||
|
||||
function progress() {
|
||||
var val = progressbar.progressbar( "value" ) || 0;
|
||||
|
||||
progressbar.progressbar( "value", val + 1 );
|
||||
|
||||
if ( val < 99 ) {
|
||||
setTimeout( progress, 100 );
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout( progress, 3000 );
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="progressbar"><div class="progress-label">Loading...</div></div>
|
||||
|
||||
<div class="demo-description">
|
||||
<p>Custom updated label demo.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,33 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Progressbar - Resizable</title>
|
||||
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
|
||||
<script src="../../jquery-1.8.3.js"></script>
|
||||
<script src="../../ui/jquery.ui.core.js"></script>
|
||||
<script src="../../ui/jquery.ui.widget.js"></script>
|
||||
<script src="../../ui/jquery.ui.mouse.js"></script>
|
||||
<script src="../../ui/jquery.ui.progressbar.js"></script>
|
||||
<script src="../../ui/jquery.ui.resizable.js"></script>
|
||||
<link rel="stylesheet" href="../demos.css">
|
||||
<script>
|
||||
$(function() {
|
||||
$( "#progressbar" ).progressbar({
|
||||
value: 37
|
||||
});
|
||||
$( "#progressbarWrapper" ).resizable();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="progressbarWrapper" style="height:30px; " class="ui-widget-default">
|
||||
<div id="progressbar" style="height:100%;"></div>
|
||||
</div>
|
||||
|
||||
<div class="demo-description">
|
||||
<p>The progress bar's widths are specified in percentages for flexible sizing so it will resize to fit its container. Try resizing the height and width of this bar to see how it maintains the correct proportions. (This is not necessarily a real-world example, but it's a good illustration of how flexibly all the plugins are coded.)</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -47,10 +47,10 @@
|
||||
"grunt-css": "0.2.0",
|
||||
"grunt-compare-size": "0.1.4",
|
||||
"grunt-html": "0.1.1",
|
||||
"grunt-junit": "0.1.4",
|
||||
"grunt-junit": "0.1.5",
|
||||
"grunt-git-authors": "1.0.0",
|
||||
"rimraf": "2.0.1",
|
||||
"testswarm": "0.2.3"
|
||||
"testswarm": "0.3.0"
|
||||
},
|
||||
"keywords": []
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
/*
|
||||
* jquery.simulate - simulate browser mouse and keyboard events
|
||||
* http://jqueryui.com
|
||||
/*!
|
||||
* jQuery Simulate v0.0.1 - simulate browser mouse and keyboard events
|
||||
* https://github.com/jquery/jquery-simulate
|
||||
*
|
||||
* Copyright 2012 jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* Date: Sun Dec 9 12:15:33 2012 -0500
|
||||
*/
|
||||
|
||||
;(function( $ ) {
|
||||
;(function( $, undefined ) {
|
||||
|
||||
var rkeyEvent = /^key/,
|
||||
rmouseEvent = /^(?:mouse|contextmenu)|click/;
|
||||
@ -31,7 +33,42 @@ $.simulate = function( elem, type, options ) {
|
||||
}
|
||||
};
|
||||
|
||||
$.extend( $.simulate, {
|
||||
|
||||
keyCode: {
|
||||
BACKSPACE: 8,
|
||||
COMMA: 188,
|
||||
DELETE: 46,
|
||||
DOWN: 40,
|
||||
END: 35,
|
||||
ENTER: 13,
|
||||
ESCAPE: 27,
|
||||
HOME: 36,
|
||||
LEFT: 37,
|
||||
NUMPAD_ADD: 107,
|
||||
NUMPAD_DECIMAL: 110,
|
||||
NUMPAD_DIVIDE: 111,
|
||||
NUMPAD_ENTER: 108,
|
||||
NUMPAD_MULTIPLY: 106,
|
||||
NUMPAD_SUBTRACT: 109,
|
||||
PAGE_DOWN: 34,
|
||||
PAGE_UP: 33,
|
||||
PERIOD: 190,
|
||||
RIGHT: 39,
|
||||
SPACE: 32,
|
||||
TAB: 9,
|
||||
UP: 38
|
||||
},
|
||||
|
||||
buttonCode: {
|
||||
LEFT: 0,
|
||||
MIDDLE: 1,
|
||||
RIGHT: 2
|
||||
}
|
||||
});
|
||||
|
||||
$.extend( $.simulate.prototype, {
|
||||
|
||||
simulateEvent: function( elem, type, options ) {
|
||||
var event = this.createEvent( type, options );
|
||||
this.dispatchEvent( elem, type, event, options );
|
||||
@ -56,7 +93,6 @@ $.extend( $.simulate.prototype, {
|
||||
detail: 0,
|
||||
screenX: 0,
|
||||
screenY: 0,
|
||||
// TODO: default clientX/Y to a position within the target element
|
||||
clientX: 1,
|
||||
clientY: 1,
|
||||
ctrlKey: false,
|
||||
@ -101,8 +137,14 @@ $.extend( $.simulate.prototype, {
|
||||
} else if ( document.createEventObject ) {
|
||||
event = document.createEventObject();
|
||||
$.extend( event, options );
|
||||
// TODO: what is this mapping for?
|
||||
event.button = { 0:1, 1:4, 2:2 }[ event.button ] || event.button;
|
||||
// standards event.button uses constants defined here: http://msdn.microsoft.com/en-us/library/ie/ff974877(v=vs.85).aspx
|
||||
// old IE event.button uses constants defined here: http://msdn.microsoft.com/en-us/library/ie/ms533544(v=vs.85).aspx
|
||||
// so we actually need to map the standard back to oldIE
|
||||
event.button = {
|
||||
0: 1,
|
||||
1: 4,
|
||||
2: 2
|
||||
}[ event.button ] || event.button;
|
||||
}
|
||||
|
||||
return event;
|
||||
@ -128,7 +170,10 @@ $.extend( $.simulate.prototype, {
|
||||
event.initKeyEvent( type, options.bubbles, options.cancelable, options.view,
|
||||
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
|
||||
options.keyCode, options.charCode );
|
||||
// TODO: what is this supporting?
|
||||
// initKeyEvent throws an exception in WebKit
|
||||
// see: http://stackoverflow.com/questions/6406784/initkeyevent-keypress-only-works-in-firefox-need-a-cross-browser-solution
|
||||
// and also https://bugs.webkit.org/show_bug.cgi?id=13368
|
||||
// fall back to a generic event until we decide to implement initKeyboardEvent
|
||||
} catch( err ) {
|
||||
event = document.createEvent( "Events" );
|
||||
event.initEvent( type, options.bubbles, options.cancelable );
|
||||
@ -147,9 +192,7 @@ $.extend( $.simulate.prototype, {
|
||||
$.extend( event, options );
|
||||
}
|
||||
|
||||
// TODO: can we hook into core's logic?
|
||||
if ( $.ui.ie || (({}).toString.call( window.opera ) === "[object Opera]") ) {
|
||||
// TODO: is charCode ever <0 ? Can we just use charCode || keyCode?
|
||||
if ( !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ) || (({}).toString.call( window.opera ) === "[object Opera]") ) {
|
||||
event.keyCode = (options.charCode > 0) ? options.charCode : options.keyCode;
|
||||
event.charCode = undefined;
|
||||
}
|
||||
@ -157,7 +200,6 @@ $.extend( $.simulate.prototype, {
|
||||
return event;
|
||||
},
|
||||
|
||||
// TODO: does this need type? Can't we just check event.type?
|
||||
dispatchEvent: function( elem, type, event ) {
|
||||
if ( elem.dispatchEvent ) {
|
||||
elem.dispatchEvent( event );
|
||||
@ -237,20 +279,31 @@ function findCenter( elem ) {
|
||||
|
||||
$.extend( $.simulate.prototype, {
|
||||
simulateDrag: function() {
|
||||
var target = this.target,
|
||||
var i = 0,
|
||||
target = this.target,
|
||||
options = this.options,
|
||||
center = findCenter( target ),
|
||||
x = Math.floor( center.x ),
|
||||
y = Math.floor( center.y ),
|
||||
dx = options.dx || 0,
|
||||
dy = options.dy || 0,
|
||||
moves = options.moves || 3,
|
||||
coord = { clientX: x, clientY: y };
|
||||
|
||||
this.simulateEvent( target, "mousedown", coord );
|
||||
coord = { clientX: x + 1, clientY: y + 1 };
|
||||
this.simulateEvent( document, "mousemove", coord );
|
||||
coord = { clientX: x + dx, clientY: y + dy };
|
||||
this.simulateEvent( document, "mousemove", coord );
|
||||
|
||||
for ( ; i < moves ; i++ ) {
|
||||
x += dx / moves;
|
||||
y += dy / moves;
|
||||
|
||||
coord = {
|
||||
clientX: Math.round( x ),
|
||||
clientY: Math.round( y )
|
||||
};
|
||||
|
||||
this.simulateEvent( document, "mousemove", coord );
|
||||
}
|
||||
|
||||
this.simulateEvent( target, "mouseup", coord );
|
||||
this.simulateEvent( target, "click", coord );
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ module( "autocomplete: options" );
|
||||
var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ];
|
||||
|
||||
test( "appendTo", function() {
|
||||
expect( 7 );
|
||||
expect( 8 );
|
||||
var detached = $( "<div>" ),
|
||||
element = $( "#autocomplete" ).autocomplete();
|
||||
equal( element.autocomplete( "widget" ).parent()[0], document.body, "defaults to body" );
|
||||
@ -39,6 +39,10 @@ test( "appendTo", function() {
|
||||
});
|
||||
equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached DOM element" );
|
||||
element.autocomplete( "destroy" );
|
||||
|
||||
element.autocomplete().autocomplete( "option", "appendTo", detached );
|
||||
equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
|
||||
element.autocomplete( "destroy" );
|
||||
});
|
||||
|
||||
function autoFocusTest( afValue, focusedLength ) {
|
||||
|
@ -92,7 +92,7 @@ test("buttonset (rtl)", function() {
|
||||
// remove this when simulate properly simulates this
|
||||
// see http://yuilibrary.com/projects/yui2/ticket/2528826 fore more info
|
||||
if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
|
||||
test( "ensure checked and aria after single click on checkbox label button, see #5518", function() {
|
||||
asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function() {
|
||||
expect( 3 );
|
||||
|
||||
$("#check2").button().change( function() {
|
||||
@ -100,8 +100,76 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
|
||||
ok( this.checked, "checked ok" );
|
||||
ok( lbl.attr("aria-pressed") === "true", "aria ok" );
|
||||
ok( lbl.hasClass("ui-state-active"), "ui-state-active ok" );
|
||||
}).button("widget").simulate("mousedown").simulate("click").simulate("mouseup");
|
||||
});
|
||||
|
||||
// support: Opera
|
||||
// Opera doesn't trigger a change event when this is done synchronously.
|
||||
// This seems to be a side effect of another test, but until that can be
|
||||
// tracked down, this delay will have to do.
|
||||
setTimeout(function() {
|
||||
$("#check2").button("widget").simulate("click");
|
||||
start();
|
||||
}, 1 );
|
||||
});
|
||||
}
|
||||
|
||||
test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
|
||||
expect( 5 );
|
||||
var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
|
||||
group.find( "input[type=checkbox]" ).button();
|
||||
ok( group.find( "label" ).is( ".ui-button" ) );
|
||||
|
||||
group = $( "<input type='checkbox' id='t7092b'><label for='t7092b'></label>" );
|
||||
group.filter( "input[type=checkbox]" ).button();
|
||||
ok( group.filter( "label" ).is( ".ui-button" ) );
|
||||
|
||||
group = $( "<span><input type='checkbox' id='t7092c'></span><label for='t7092c'></label>" );
|
||||
group.find( "input[type=checkbox]" ).button();
|
||||
ok( group.filter( "label" ).is( ".ui-button" ) );
|
||||
|
||||
group = $( "<span><input type='checkbox' id='t7092d'></span><span><label for='t7092d'></label></span>" );
|
||||
group.find( "input[type=checkbox]" ).button();
|
||||
ok( group.find( "label" ).is( ".ui-button" ) );
|
||||
|
||||
group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" );
|
||||
group.filter( "input[type=checkbox]" ).button();
|
||||
ok( group.find( "label" ).is( ".ui-button" ) );
|
||||
});
|
||||
|
||||
test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
|
||||
expect( 2 );
|
||||
$( "#radio01" ).next().andSelf().hide();
|
||||
var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
|
||||
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
|
||||
ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );
|
||||
});
|
||||
|
||||
test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
|
||||
expect( 3 );
|
||||
$( "#radio0" ).hide();
|
||||
var set = $( "#radio0" ).buttonset();
|
||||
ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
|
||||
ok( set.find( "label:eq(1)" ).is( ".ui-button" ) );
|
||||
ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
|
||||
});
|
||||
|
||||
asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
|
||||
expect( 2 );
|
||||
var check = $( "#check" ).button(),
|
||||
label = $( "label[for='check']" );
|
||||
ok( !label.is( ".ui-state-focus" ) );
|
||||
check.focus();
|
||||
setTimeout(function() {
|
||||
ok( label.is( ".ui-state-focus" ) );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
test( "#7534 - Button label selector works for ids with \":\"", function() {
|
||||
expect( 1 );
|
||||
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
|
||||
group.find( "input" ).button();
|
||||
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -13,14 +13,24 @@ test("buttonset works with single-quote named elements (#7505)", function() {
|
||||
}).click();
|
||||
});
|
||||
|
||||
test( "when button loses focus, ensure active state is removed (#8559)", function() {
|
||||
asyncTest( "when button loses focus, ensure active state is removed (#8559)", function() {
|
||||
expect( 1 );
|
||||
|
||||
$("#button").button().keypress( function() {
|
||||
$("#button").one( "blur", function() {
|
||||
ok( !$("#button").is(".ui-state-active"), "button loses active state appropriately" );
|
||||
var element = $( "#button" ).button();
|
||||
|
||||
element.one( "keypress", function() {
|
||||
element.one( "blur", function() {
|
||||
ok( !element.is(".ui-state-active"), "button loses active state appropriately" );
|
||||
start();
|
||||
}).blur();
|
||||
}).focus().simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ).simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } );
|
||||
});
|
||||
|
||||
element.focus();
|
||||
setTimeout(function() {
|
||||
element
|
||||
.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } )
|
||||
.simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } );
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -103,4 +103,15 @@ test("icons", function() {
|
||||
$("#button").button("destroy");
|
||||
});
|
||||
|
||||
test( "#5295 - button does not remove hoverstate if disabled" , function() {
|
||||
expect( 1 );
|
||||
var btn = $("#button").button();
|
||||
btn.hover( function() {
|
||||
btn.button( "disable" );
|
||||
});
|
||||
btn.trigger( "mouseenter" );
|
||||
btn.trigger( "mouseleave" );
|
||||
ok( !btn.is( ".ui-state-hover") );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* button_tickets.js
|
||||
*/
|
||||
(function( $ ) {
|
||||
|
||||
module( "button: tickets" );
|
||||
|
||||
test( "#5295 - button does not remove hoverstate if disabled" , function() {
|
||||
expect( 1 );
|
||||
var btn = $("#button").button();
|
||||
btn.hover( function() {
|
||||
btn.button( "disable" );
|
||||
});
|
||||
btn.trigger( "mouseenter" );
|
||||
btn.trigger( "mouseleave" );
|
||||
ok( !btn.is( ".ui-state-hover") );
|
||||
});
|
||||
|
||||
test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
|
||||
expect( 2 );
|
||||
$( "#radio01" ).next().andSelf().hide();
|
||||
var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
|
||||
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
|
||||
ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );
|
||||
});
|
||||
|
||||
test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
|
||||
expect( 3 );
|
||||
$( "#radio0" ).hide();
|
||||
var set = $( "#radio0" ).buttonset();
|
||||
ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
|
||||
ok( set.find( "label:eq(1)" ).is( ".ui-button" ) );
|
||||
ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
|
||||
});
|
||||
|
||||
test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
|
||||
expect( 2 );
|
||||
var check = $( "#check" ).button(),
|
||||
label = $( "label[for='check']" );
|
||||
ok( !label.is( ".ui-state-focus" ) );
|
||||
check.focus();
|
||||
ok( label.is( ".ui-state-focus" ) );
|
||||
});
|
||||
|
||||
test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
|
||||
expect( 5 );
|
||||
var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
|
||||
group.find( "input[type=checkbox]" ).button();
|
||||
ok( group.find( "label" ).is( ".ui-button" ) );
|
||||
|
||||
group = $( "<input type='checkbox' id='t7092b'><label for='t7092b'></label>" );
|
||||
group.filter( "input[type=checkbox]" ).button();
|
||||
ok( group.filter( "label" ).is( ".ui-button" ) );
|
||||
|
||||
group = $( "<span><input type='checkbox' id='t7092c'></span><label for='t7092c'></label>" );
|
||||
group.find( "input[type=checkbox]" ).button();
|
||||
ok( group.filter( "label" ).is( ".ui-button" ) );
|
||||
|
||||
group = $( "<span><input type='checkbox' id='t7092d'></span><span><label for='t7092d'></label></span>" );
|
||||
group.find( "input[type=checkbox]" ).button();
|
||||
ok( group.find( "label" ).is( ".ui-button" ) );
|
||||
|
||||
group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" );
|
||||
group.filter( "input[type=checkbox]" ).button();
|
||||
ok( group.find( "label" ).is( ".ui-button" ) );
|
||||
});
|
||||
|
||||
test( "#7534 - Button label selector works for ids with \":\"", function() {
|
||||
expect( 1 );
|
||||
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
|
||||
group.find( "input" ).button();
|
||||
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
|
||||
});
|
||||
|
||||
})( jQuery );
|
@ -4,11 +4,12 @@ module( "core - jQuery extensions" );
|
||||
|
||||
TestHelpers.testJshint( "core" );
|
||||
|
||||
test( "focus - original functionality", function() {
|
||||
asyncTest( "focus - original functionality", function() {
|
||||
expect( 1 );
|
||||
$( "#inputTabindex0" )
|
||||
.focus(function() {
|
||||
.one( "focus", function() {
|
||||
ok( true, "event triggered" );
|
||||
start();
|
||||
})
|
||||
.focus();
|
||||
});
|
||||
@ -16,12 +17,10 @@ test( "focus - original functionality", function() {
|
||||
asyncTest( "focus", function() {
|
||||
expect( 2 );
|
||||
$( "#inputTabindex0" )
|
||||
.focus(function() {
|
||||
.one( "focus", function() {
|
||||
ok( true, "event triggered" );
|
||||
})
|
||||
.focus( 500, function() {
|
||||
// prevent double focus event in IE
|
||||
$( this ).unbind( "focus" );
|
||||
ok( true, "callback triggered" );
|
||||
start();
|
||||
});
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
module("datepicker: core");
|
||||
|
||||
TestHelpers.testJshint( "datepicker" );
|
||||
|
||||
test("initialization - Reinitialization after body had been emptied.", function() {
|
||||
expect( 1 );
|
||||
var bodyContent = $('body').children(), inp = $("#inp");
|
||||
@ -28,11 +30,15 @@ test("widget method", function() {
|
||||
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
|
||||
});
|
||||
|
||||
test('baseStructure', function() {
|
||||
asyncTest('baseStructure', function() {
|
||||
expect( 58 );
|
||||
var header, title, table, thead, week, panel, inl, child,
|
||||
inp = TestHelpers.datepicker.init('#inp').focus(),
|
||||
inp = TestHelpers.datepicker.init('#inp'),
|
||||
dp = $('#ui-datepicker-div');
|
||||
|
||||
function step1() {
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is(':visible'), 'Structure - datepicker visible');
|
||||
ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');
|
||||
ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');
|
||||
@ -65,10 +71,15 @@ test('baseStructure', function() {
|
||||
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step2();
|
||||
});
|
||||
}
|
||||
|
||||
function step2() {
|
||||
// Editable month/year and button panel
|
||||
inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
|
||||
inp.focus();
|
||||
|
||||
setTimeout(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');
|
||||
@ -80,9 +91,15 @@ test('baseStructure', function() {
|
||||
ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step3();
|
||||
});
|
||||
}
|
||||
|
||||
function step3() {
|
||||
// Multi-month 2
|
||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2});
|
||||
inp.focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
|
||||
equal(dp.children().length, 3, 'Structure multi [2] - child count');
|
||||
child = dp.children(':first');
|
||||
@ -94,16 +111,28 @@ test('baseStructure', function() {
|
||||
ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step4();
|
||||
});
|
||||
}
|
||||
|
||||
function step4() {
|
||||
// Multi-month 3
|
||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3});
|
||||
inp.focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3');
|
||||
ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step5();
|
||||
});
|
||||
}
|
||||
|
||||
function step5() {
|
||||
// Multi-month [2, 2]
|
||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: [2, 2]});
|
||||
inp.focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month');
|
||||
equal(dp.children().length, 6, 'Structure multi [2,2] - child count');
|
||||
child = dp.children(':first');
|
||||
@ -148,6 +177,12 @@ test('baseStructure', function() {
|
||||
child = dp.children(':eq(2)');
|
||||
ok(child.is('div.ui-datepicker-row-break'), 'Structure inline multi - row break');
|
||||
inl.datepicker('destroy');
|
||||
|
||||
start();
|
||||
});
|
||||
}
|
||||
|
||||
step1();
|
||||
});
|
||||
|
||||
test('customStructure', function() {
|
||||
|
@ -48,6 +48,24 @@ test('option', function() {
|
||||
'Get default settings');
|
||||
});
|
||||
|
||||
test( "disabled", function() {
|
||||
expect(8);
|
||||
var inp = TestHelpers.datepicker.init('#inp');
|
||||
ok(!inp.datepicker('isDisabled'), 'Initially marked as enabled');
|
||||
ok(!inp[0].disabled, 'Field initially enabled');
|
||||
inp.datepicker('option', 'disabled', true);
|
||||
ok(inp.datepicker('isDisabled'), 'Marked as disabled');
|
||||
ok(inp[0].disabled, 'Field now disabled');
|
||||
inp.datepicker('option', 'disabled', false);
|
||||
ok(!inp.datepicker('isDisabled'), 'Marked as enabled');
|
||||
ok(!inp[0].disabled, 'Field now enabled');
|
||||
inp.datepicker('destroy');
|
||||
|
||||
inp = TestHelpers.datepicker.init('#inp', { disabled: true });
|
||||
ok(inp.datepicker('isDisabled'), 'Initially marked as disabled');
|
||||
ok(inp[0].disabled, 'Field initially disabled');
|
||||
});
|
||||
|
||||
test('change', function() {
|
||||
expect( 12 );
|
||||
var inp = TestHelpers.datepicker.init('#inp'),
|
||||
@ -69,26 +87,40 @@ test('change', function() {
|
||||
equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
|
||||
});
|
||||
|
||||
test('invocation', function() {
|
||||
asyncTest('invocation', function() {
|
||||
expect( 29 );
|
||||
var button, image,
|
||||
inp = TestHelpers.datepicker.init('#inp'),
|
||||
dp = $('#ui-datepicker-div'),
|
||||
body = $('body');
|
||||
|
||||
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.focus();
|
||||
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.focus();
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function step2() {
|
||||
// On button
|
||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonText: 'Popup'});
|
||||
ok(!dp.is(':visible'), 'Button - initially hidden');
|
||||
@ -97,13 +129,20 @@ test('invocation', function() {
|
||||
ok(button.length === 1, 'Button - button present');
|
||||
ok(image.length === 0, 'Button - image absent');
|
||||
equal(button.text(), 'Popup', 'Button - button text');
|
||||
inp.focus();
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(!dp.is(':visible'), 'Button - not rendered on focus');
|
||||
button.click();
|
||||
ok(dp.is(':visible'), 'Button - rendered on button click');
|
||||
button.click();
|
||||
ok(!dp.is(':visible'), 'Button - hidden on second button click');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step3();
|
||||
});
|
||||
}
|
||||
|
||||
function step3() {
|
||||
// On image button
|
||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true,
|
||||
buttonImage: 'img/calendar.gif', buttonText: 'Cal'});
|
||||
@ -114,13 +153,20 @@ test('invocation', function() {
|
||||
ok(image.length === 1, 'Image button - image present');
|
||||
equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source');
|
||||
equal(image.attr('title'), 'Cal', 'Image button - image text');
|
||||
inp.focus();
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(!dp.is(':visible'), 'Image button - not rendered on focus');
|
||||
image.click();
|
||||
ok(dp.is(':visible'), 'Image button - rendered on image click');
|
||||
image.click();
|
||||
ok(!dp.is(':visible'), 'Image button - hidden on second image click');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step4();
|
||||
});
|
||||
}
|
||||
|
||||
function step4() {
|
||||
// On both
|
||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'});
|
||||
ok(!dp.is(':visible'), 'Both - initially hidden');
|
||||
@ -130,7 +176,10 @@ test('invocation', function() {
|
||||
ok(image.length === 0, 'Both - image absent');
|
||||
image = button.children('img');
|
||||
ok(image.length === 1, 'Both - button image present');
|
||||
inp.focus();
|
||||
inp[0].blur();
|
||||
setTimeout(function() {
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is(':visible'), 'Both - rendered on focus');
|
||||
body.simulate('mousedown', {});
|
||||
ok(!dp.is(':visible'), 'Both - hidden on external click');
|
||||
@ -139,6 +188,13 @@ test('invocation', function() {
|
||||
button.click();
|
||||
ok(!dp.is(':visible'), 'Both - hidden on second button click');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
start();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
step1();
|
||||
});
|
||||
|
||||
test('otherMonths', function() {
|
||||
@ -538,10 +594,9 @@ test('altField', function() {
|
||||
});
|
||||
|
||||
test('autoSize', function() {
|
||||
expect( 14 );
|
||||
expect( 15 );
|
||||
var inp = TestHelpers.datepicker.init('#inp');
|
||||
// todo: figure out why this test fails in Opera 11.6
|
||||
//equal(inp.prop('size'), 20, 'Auto size - default');
|
||||
equal(inp.prop('size'), 20, 'Auto size - default');
|
||||
inp.datepicker('option', 'autoSize', true);
|
||||
equal(inp.prop('size'), 10, 'Auto size - mm/dd/yy');
|
||||
inp.datepicker('option', 'dateFormat', 'm/d/yy');
|
||||
|
@ -23,6 +23,8 @@
|
||||
"ui/jquery.ui.draggable.js",
|
||||
"ui/jquery.ui.resizable.js",
|
||||
"ui/jquery.ui.button.js",
|
||||
"ui/jquery.ui.effect.js",
|
||||
"ui/jquery.ui.effect-clip.js",
|
||||
"ui/jquery.ui.dialog.js"
|
||||
]
|
||||
});
|
||||
@ -59,6 +61,8 @@
|
||||
<label for="favorite-food">Favorite food</label><input id="favorite-food">
|
||||
</div>
|
||||
</div>
|
||||
<div class="wrap" id="wrap1"></div>
|
||||
<div class="wrap" id="wrap2"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,7 +1,8 @@
|
||||
TestHelpers.commonWidgetTests( "dialog", {
|
||||
defaults: {
|
||||
appendTo: "body",
|
||||
autoOpen: true,
|
||||
buttons: {},
|
||||
buttons: [],
|
||||
closeOnEscape: true,
|
||||
closeText: 'close',
|
||||
disabled: false,
|
||||
@ -9,8 +10,8 @@ TestHelpers.commonWidgetTests( "dialog", {
|
||||
draggable: true,
|
||||
height: 'auto',
|
||||
hide: null,
|
||||
maxHeight: false,
|
||||
maxWidth: false,
|
||||
maxHeight: null,
|
||||
maxWidth: null,
|
||||
minHeight: 150,
|
||||
minWidth: 150,
|
||||
modal: false,
|
||||
|
@ -34,11 +34,12 @@ test( "ARIA", function() {
|
||||
|
||||
test("widget method", function() {
|
||||
expect( 1 );
|
||||
var dialog = $("<div>").appendTo("#main").dialog();
|
||||
var dialog = $("<div>").appendTo("#qunit-fixture").dialog();
|
||||
deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]);
|
||||
dialog.remove();
|
||||
});
|
||||
|
||||
test( "focus tabbable", function() {
|
||||
asyncTest( "focus tabbable", function() {
|
||||
expect( 5 );
|
||||
var el,
|
||||
options = {
|
||||
@ -48,40 +49,62 @@ test( "focus tabbable", function() {
|
||||
}]
|
||||
};
|
||||
|
||||
el = $( "<div><input><input autofocus></div>" ).dialog( options );
|
||||
equal( document.activeElement, el.find( "input" )[ 1 ], "1. first element inside the dialog matching [autofocus]" );
|
||||
el.remove();
|
||||
|
||||
// IE8 fails to focus the input, <body> ends up being the activeElement
|
||||
// so wait for that stupid browser
|
||||
stop();
|
||||
function checkFocus( markup, options, testFn, next ) {
|
||||
el = $( markup ).dialog( options );
|
||||
setTimeout(function() {
|
||||
el = $( "<div><input><input></div>" ).dialog( options );
|
||||
equal( document.activeElement, el.find( "input" )[ 0 ], "2. tabbable element inside the content element" );
|
||||
testFn();
|
||||
el.remove();
|
||||
setTimeout( next );
|
||||
});
|
||||
}
|
||||
|
||||
el = $( "<div>text</div>" ).dialog( options );
|
||||
equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], "3. tabbable element inside the buttonpane" );
|
||||
el.remove();
|
||||
function step1() {
|
||||
checkFocus( "<div><input><input autofocus></div>", options, function() {
|
||||
equal( document.activeElement, el.find( "input" )[ 1 ],
|
||||
"1. first element inside the dialog matching [autofocus]" );
|
||||
}, step2 );
|
||||
}
|
||||
|
||||
el = $( "<div>text</div>" ).dialog();
|
||||
equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], "4. the close button" );
|
||||
el.remove();
|
||||
function step2() {
|
||||
checkFocus( "<div><input><input></div>", options, function() {
|
||||
equal( document.activeElement, el.find( "input" )[ 0 ],
|
||||
"2. tabbable element inside the content element" );
|
||||
}, step3 );
|
||||
}
|
||||
|
||||
function step3() {
|
||||
checkFocus( "<div>text</div>", options, function() {
|
||||
equal( document.activeElement,
|
||||
el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ],
|
||||
"3. tabbable element inside the buttonpane" );
|
||||
}, step4 );
|
||||
}
|
||||
|
||||
function step4() {
|
||||
checkFocus( "<div>text</div>", {}, function() {
|
||||
equal( document.activeElement,
|
||||
el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ],
|
||||
"4. the close button" );
|
||||
}, step5 );
|
||||
}
|
||||
|
||||
function step5() {
|
||||
el = $( "<div>text</div>" ).dialog({
|
||||
autoOpen: false
|
||||
});
|
||||
el.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
|
||||
el.dialog( "open" );
|
||||
setTimeout(function() {
|
||||
equal( document.activeElement, el.parent()[ 0 ], "5. the dialog itself" );
|
||||
el.remove();
|
||||
|
||||
start();
|
||||
}, 13);
|
||||
});
|
||||
}
|
||||
|
||||
step1();
|
||||
});
|
||||
|
||||
// #7960
|
||||
test( "resizable handles below modal overlays", function() {
|
||||
test( "#7960: resizable handles below modal overlays", function() {
|
||||
expect( 1 );
|
||||
|
||||
var resizable = $( "<div>" ).resizable(),
|
||||
@ -93,4 +116,35 @@ test( "resizable handles below modal overlays", function() {
|
||||
dialog.dialog( "destroy" );
|
||||
});
|
||||
|
||||
asyncTest( "Prevent tabbing out of dialogs", function() {
|
||||
expect( 3 );
|
||||
|
||||
var el = $( "<div><input><input></div>" ).dialog(),
|
||||
inputs = el.find( "input" ),
|
||||
widget = el.dialog( "widget" )[ 0 ];
|
||||
|
||||
function checkTab() {
|
||||
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
|
||||
|
||||
// check shift tab
|
||||
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
|
||||
setTimeout( checkShiftTab );
|
||||
}
|
||||
|
||||
function checkShiftTab() {
|
||||
ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
|
||||
|
||||
el.remove();
|
||||
setTimeout( start );
|
||||
}
|
||||
|
||||
inputs[1].focus();
|
||||
setTimeout(function() {
|
||||
equal( document.activeElement, inputs[1], "Focus set on second input" );
|
||||
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
|
||||
|
||||
setTimeout( checkTab );
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -57,6 +57,8 @@
|
||||
<label for="favorite-food">Favorite food</label><input id="favorite-food">
|
||||
</div>
|
||||
</div>
|
||||
<div class="wrap" id="wrap1"></div>
|
||||
<div class="wrap" id="wrap2"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -341,4 +341,18 @@ asyncTest("ensure dialog's container doesn't scroll on resize and focus", functi
|
||||
}, 500);
|
||||
});
|
||||
|
||||
test("#5184: isOpen in dialogclose event is true", function() {
|
||||
expect( 3 );
|
||||
|
||||
var el = $( "<div></div>" ).dialog({
|
||||
close: function() {
|
||||
ok( !el.dialog("isOpen"), "dialog is not open during close" );
|
||||
}
|
||||
});
|
||||
ok( el.dialog("isOpen"), "dialog is open after init" );
|
||||
el.dialog( "close" );
|
||||
ok( !el.dialog("isOpen"), "dialog is not open after close" );
|
||||
el.remove();
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -34,7 +34,9 @@ test("init", function() {
|
||||
});
|
||||
|
||||
test("destroy", function() {
|
||||
expect( 6 );
|
||||
expect( 7 );
|
||||
|
||||
$( "#dialog1, #form-dialog" ).hide();
|
||||
domEqual( "#dialog1", function() {
|
||||
var dialog = $( "#dialog1" ).dialog().dialog( "destroy" );
|
||||
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
|
||||
@ -45,6 +47,26 @@ test("destroy", function() {
|
||||
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
|
||||
equal( dialog.index(), 2 );
|
||||
});
|
||||
|
||||
// Ensure dimensions are restored (#8119)
|
||||
$( "#dialog1" ).show().css({
|
||||
width: "400px",
|
||||
minHeight: "100px",
|
||||
height: "200px"
|
||||
});
|
||||
domEqual( "#dialog1", function() {
|
||||
$( "#dialog1" ).dialog().dialog( "destroy" );
|
||||
});
|
||||
});
|
||||
|
||||
test("#4980: Destroy should place element back in original DOM position", function(){
|
||||
expect( 2 );
|
||||
var container = $('<div id="container"><div id="modal">Content</div></div>'),
|
||||
modal = container.find('#modal');
|
||||
modal.dialog();
|
||||
ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element');
|
||||
modal.dialog('destroy');
|
||||
ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position');
|
||||
});
|
||||
|
||||
test( "enable/disable disabled", function() {
|
||||
@ -125,4 +147,41 @@ test("open", function() {
|
||||
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called');
|
||||
});
|
||||
|
||||
test("#6137: dialog('open') causes form elements to reset on IE7", function() {
|
||||
expect(2);
|
||||
|
||||
var d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' +
|
||||
'<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false});
|
||||
|
||||
d1.find('#b').prop( "checked", true );
|
||||
equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
|
||||
|
||||
d1.dialog('open');
|
||||
equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
|
||||
|
||||
d1.remove();
|
||||
});
|
||||
|
||||
test("#5531: dialog width should be at least minWidth on creation", function () {
|
||||
expect( 4 );
|
||||
var el = $('<div></div>').dialog({
|
||||
width: 200,
|
||||
minWidth: 300
|
||||
});
|
||||
|
||||
equal(el.dialog('option', 'width'), 300, "width is minWidth");
|
||||
el.dialog('option', 'width', 200);
|
||||
equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
|
||||
el.dialog('option', 'width', 320);
|
||||
equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
|
||||
el.remove();
|
||||
|
||||
el = $('<div></div>').dialog({
|
||||
minWidth: 300
|
||||
});
|
||||
ok(el.dialog('option', 'width') >= 300, "width is at least 300");
|
||||
el.remove();
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -5,6 +5,47 @@
|
||||
|
||||
module("dialog: options");
|
||||
|
||||
test( "appendTo", function() {
|
||||
expect( 8 );
|
||||
var detached = $( "<div>" ),
|
||||
element = $( "#dialog1" ).dialog();
|
||||
equal( element.dialog( "widget" ).parent()[0], document.body, "defaults to body" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: ".wrap"
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "first found element" );
|
||||
equal( $( "#wrap2 .ui-dialog" ).length, 0, "only appends to one element" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: null
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], document.body, "null" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({ autoOpen: false }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
|
||||
equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: detached
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached jQuery object" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: detached[0]
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({ autoOpen: false }).dialog( "option", "appendTo", detached );
|
||||
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
|
||||
element.dialog( "destroy" );
|
||||
});
|
||||
|
||||
test("autoOpen", function() {
|
||||
expect(2);
|
||||
|
||||
@ -212,6 +253,15 @@ test("height", function() {
|
||||
el.remove();
|
||||
});
|
||||
|
||||
asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() {
|
||||
expect( 1 );
|
||||
$( "#dialog1" ).dialog({ hide: "clip" }).dialog( "close" ).dialog( "destroy" );
|
||||
setTimeout(function() {
|
||||
equal( $( ".ui-effects-wrapper" ).length, 0 );
|
||||
start();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
test("maxHeight", function() {
|
||||
expect(3);
|
||||
|
||||
@ -428,4 +478,26 @@ test("width", function() {
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("#4826: setting resizable false toggles resizable on dialog", function() {
|
||||
expect(6);
|
||||
var i,
|
||||
el = $('<div></div>').dialog({ resizable: false });
|
||||
|
||||
TestHelpers.dialog.shouldResize(el, 0, 0, "[default]");
|
||||
for (i=0; i<2; i++) {
|
||||
el.dialog('close').dialog('open');
|
||||
TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')');
|
||||
}
|
||||
el.remove();
|
||||
|
||||
el = $('<div></div>').dialog({ resizable: true });
|
||||
TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
|
||||
for (i=0; i<2; i++) {
|
||||
el.dialog('close').dialog('option', 'resizable', false).dialog('open');
|
||||
TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')');
|
||||
}
|
||||
el.remove();
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -3,10 +3,9 @@ TestHelpers.dialog = {
|
||||
var d = el.dialog('widget');
|
||||
//this mouseover is to work around a limitation in resizable
|
||||
//TODO: fix resizable so handle doesn't require mouseover in order to be used
|
||||
$(handle, d).simulate("mouseover");
|
||||
$(handle, d).simulate("drag", {
|
||||
dx: dx || 0,
|
||||
dy: dy || 0
|
||||
$( handle, d ).simulate("mouseover").simulate( "drag", {
|
||||
dx: dx,
|
||||
dy: dy
|
||||
});
|
||||
},
|
||||
testDrag: function(el, dx, dy, expectedDX, expectedDY, msg) {
|
||||
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
* dialog_tickets.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
module( "dialog: tickets" );
|
||||
|
||||
asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
|
||||
expect( 3 );
|
||||
|
||||
var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
|
||||
inputs = el.find( "input" ),
|
||||
widget = el.dialog( "widget" )[ 0 ];
|
||||
|
||||
function checkTab() {
|
||||
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
|
||||
|
||||
// check shift tab
|
||||
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
|
||||
setTimeout( checkShiftTab, 2 );
|
||||
}
|
||||
|
||||
function checkShiftTab() {
|
||||
ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
|
||||
|
||||
el.remove();
|
||||
start();
|
||||
}
|
||||
|
||||
inputs.eq( 1 ).focus();
|
||||
equal( document.activeElement, inputs[1], "Focus set on second input" );
|
||||
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
|
||||
|
||||
setTimeout( checkTab, 2 );
|
||||
});
|
||||
|
||||
test("#4826: setting resizable false toggles resizable on dialog", function() {
|
||||
expect(6);
|
||||
var i,
|
||||
el = $('<div></div>').dialog({ resizable: false });
|
||||
|
||||
TestHelpers.dialog.shouldResize(el, 0, 0, "[default]");
|
||||
for (i=0; i<2; i++) {
|
||||
el.dialog('close').dialog('open');
|
||||
TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')');
|
||||
}
|
||||
el.remove();
|
||||
|
||||
el = $('<div></div>').dialog({ resizable: true });
|
||||
TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
|
||||
for (i=0; i<2; i++) {
|
||||
el.dialog('close').dialog('option', 'resizable', false).dialog('open');
|
||||
TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')');
|
||||
}
|
||||
el.remove();
|
||||
|
||||
});
|
||||
|
||||
test("#5184: isOpen in dialogclose event is true", function() {
|
||||
expect( 3 );
|
||||
|
||||
var el = $( "<div></div>" ).dialog({
|
||||
close: function() {
|
||||
ok( !el.dialog("isOpen"), "dialog is not open during close" );
|
||||
}
|
||||
});
|
||||
ok( el.dialog("isOpen"), "dialog is open after init" );
|
||||
el.dialog( "close" );
|
||||
ok( !el.dialog("isOpen"), "dialog is not open after close" );
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("#5531: dialog width should be at least minWidth on creation", function () {
|
||||
expect( 4 );
|
||||
var el = $('<div></div>').dialog({
|
||||
width: 200,
|
||||
minWidth: 300
|
||||
});
|
||||
|
||||
equal(el.dialog('option', 'width'), 300, "width is minWidth");
|
||||
el.dialog('option', 'width', 200);
|
||||
equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
|
||||
el.dialog('option', 'width', 320);
|
||||
equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
|
||||
el.remove();
|
||||
|
||||
el = $('<div></div>').dialog({
|
||||
minWidth: 300
|
||||
});
|
||||
ok(el.dialog('option', 'width') >= 300, "width is at least 300");
|
||||
el.remove();
|
||||
|
||||
});
|
||||
|
||||
test("#6137: dialog('open') causes form elements to reset on IE7", function() {
|
||||
expect(2);
|
||||
|
||||
var d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' +
|
||||
'<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false});
|
||||
|
||||
d1.find('#b').prop( "checked", true );
|
||||
equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
|
||||
|
||||
d1.dialog('open');
|
||||
equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
|
||||
|
||||
d1.remove();
|
||||
});
|
||||
|
||||
test("#6645: Missing element not found check in overlay", function(){
|
||||
expect(2);
|
||||
var d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true}),
|
||||
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
|
||||
|
||||
equal($.ui.dialog.overlay.instances.length, 2, 'two overlays created');
|
||||
d2.dialog('close');
|
||||
equal($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay');
|
||||
d1.add(d2).remove();
|
||||
});
|
||||
|
||||
// TODO merge this with the main destroy test
|
||||
test("#4980: Destroy should place element back in original DOM position", function(){
|
||||
expect( 2 );
|
||||
var container = $('<div id="container"><div id="modal">Content</div></div>'),
|
||||
modal = container.find('#modal');
|
||||
modal.dialog();
|
||||
ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element');
|
||||
modal.dialog('destroy');
|
||||
ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position');
|
||||
});
|
||||
|
||||
})(jQuery);
|
@ -17,12 +17,15 @@ test("element types", function() {
|
||||
$.each(typeNames, function(i) {
|
||||
var offsetBefore, offsetAfter,
|
||||
typeName = typeNames[i],
|
||||
el = $(document.createElement(typeName)).appendTo('#main');
|
||||
el = $(document.createElement(typeName)).appendTo('#qunit-fixture');
|
||||
|
||||
(typeName === 'table' && el.append("<tr><td>content</td></tr>"));
|
||||
el.draggable({ cancel: '' });
|
||||
offsetBefore = el.offset();
|
||||
TestHelpers.draggable.drag(el, 50, 50);
|
||||
el.simulate( "drag", {
|
||||
dx: 50,
|
||||
dy: 50
|
||||
});
|
||||
offsetAfter = el.offset();
|
||||
// there are some rounding errors in FF, Chrome, and IE9, so we can't say equal, we have to settle for close enough
|
||||
closeEnough(offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">");
|
||||
@ -55,21 +58,15 @@ test("resizable handle with complex markup (#8756 / #8757)", function() {
|
||||
.append($('<div>'))
|
||||
);
|
||||
|
||||
var handle = '.ui-resizable-w div',
|
||||
target = $('#draggable1').draggable().resizable({ handles: 'all' }),
|
||||
drag = function(el, dx) {
|
||||
$(el)
|
||||
.simulate("mouseover")
|
||||
.simulate("drag", {
|
||||
dx: dx || 0,
|
||||
speed: 'sync'
|
||||
});
|
||||
};
|
||||
var handle = $('.ui-resizable-w div'),
|
||||
target = $('#draggable1').draggable().resizable({ handles: 'all' });
|
||||
|
||||
drag(handle, -50);
|
||||
// todo: fix resizable so it doesn't require a mouseover
|
||||
handle.simulate("mouseover").simulate( "drag", { dx: -50 } );
|
||||
equal( target.width(), 250, "compare width" );
|
||||
|
||||
drag(handle, 50);
|
||||
// todo: fix resizable so it doesn't require a mouseover
|
||||
handle.simulate("mouseover").simulate( "drag", { dx: 50 } );
|
||||
equal( target.width(), 200, "compare width" );
|
||||
});
|
||||
|
||||
|
@ -18,7 +18,10 @@ test("callbacks occurrence count", function() {
|
||||
stop: function() { stop++; }
|
||||
});
|
||||
|
||||
TestHelpers.draggable.drag(el, 10, 10);
|
||||
el.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
});
|
||||
|
||||
equal(start, 1, "start callback should happen exactly once");
|
||||
equal(dragc, 3, "drag callback should happen exactly once per mousemove");
|
||||
@ -39,7 +42,10 @@ test("stopping the start callback", function() {
|
||||
stop: function() { stop++; }
|
||||
});
|
||||
|
||||
TestHelpers.draggable.drag(el, 10, 10);
|
||||
el.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
});
|
||||
|
||||
equal(start, 1, "start callback should happen exactly once");
|
||||
equal(dragc, 0, "drag callback should not happen at all");
|
||||
@ -60,7 +66,10 @@ test("stopping the drag callback", function() {
|
||||
stop: function() { stop++; }
|
||||
});
|
||||
|
||||
TestHelpers.draggable.drag(el, 10, 10);
|
||||
el.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
});
|
||||
|
||||
equal(start, 1, "start callback should happen exactly once");
|
||||
equal(dragc, 1, "drag callback should happen exactly once");
|
||||
@ -77,7 +86,10 @@ test("stopping the stop callback", function() {
|
||||
stop: function() { return false; }
|
||||
});
|
||||
|
||||
TestHelpers.draggable.drag(el, 10, 10);
|
||||
el.simulate( "drag", {
|
||||
dx: 10,
|
||||
dy: 10
|
||||
});
|
||||
|
||||
ok($("#draggable2").data('ui-draggable').helper, "the clone should not be deleted if the stop callback is stopped");
|
||||
|
||||
|
@ -162,7 +162,11 @@ test("{ containment: 'parent' }, relative", function() {
|
||||
left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'),
|
||||
top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top')
|
||||
};
|
||||
TestHelpers.draggable.drag(el, -100, -100);
|
||||
|
||||
el.simulate( "drag", {
|
||||
dx: -100,
|
||||
dy: -100
|
||||
});
|
||||
offsetAfter = el.offset();
|
||||
deepEqual(offsetAfter, expected, 'compare offset to parent');
|
||||
});
|
||||
@ -178,7 +182,11 @@ test("{ containment: 'parent' }, absolute", function() {
|
||||
left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'),
|
||||
top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top')
|
||||
};
|
||||
TestHelpers.draggable.drag(el, -100, -100);
|
||||
|
||||
el.simulate( "drag", {
|
||||
dx: -100,
|
||||
dy: -100
|
||||
});
|
||||
offsetAfter = el.offset();
|
||||
deepEqual(offsetAfter, expected, 'compare offset to parent');
|
||||
});
|
||||
@ -214,9 +222,9 @@ test("{ cursor: 'auto' }, default", function() {
|
||||
|
||||
expect(2);
|
||||
|
||||
var expected = "auto", actual, before, after;
|
||||
|
||||
$("#draggable2").draggable({
|
||||
var actual, before, after,
|
||||
expected = "auto",
|
||||
el = $("#draggable2").draggable({
|
||||
cursor: expected,
|
||||
start: function() {
|
||||
actual = getCursor();
|
||||
@ -224,7 +232,10 @@ test("{ cursor: 'auto' }, default", function() {
|
||||
});
|
||||
|
||||
before = getCursor();
|
||||
TestHelpers.draggable.drag("#draggable2", -1, -1);
|
||||
el.simulate( "drag", {
|
||||
dx: -1,
|
||||
dy: -1
|
||||
});
|
||||
after = getCursor();
|
||||
|
||||
equal(actual, expected, "start callback: cursor '" + expected + "'");
|
||||
@ -238,9 +249,9 @@ test("{ cursor: 'move' }", function() {
|
||||
|
||||
expect(2);
|
||||
|
||||
var expected = "move", actual, before, after;
|
||||
|
||||
$("#draggable2").draggable({
|
||||
var actual, before, after,
|
||||
expected = "move",
|
||||
el = $("#draggable2").draggable({
|
||||
cursor: expected,
|
||||
start: function() {
|
||||
actual = getCursor();
|
||||
@ -248,7 +259,10 @@ test("{ cursor: 'move' }", function() {
|
||||
});
|
||||
|
||||
before = getCursor();
|
||||
TestHelpers.draggable.drag("#draggable2", -1, -1);
|
||||
el.simulate( "drag", {
|
||||
dx: -1,
|
||||
dy: -1
|
||||
});
|
||||
after = getCursor();
|
||||
|
||||
equal(actual, expected, "start callback: cursor '" + expected + "'");
|
||||
@ -648,7 +662,10 @@ test("{ helper: 'clone' }, absolute", function() {
|
||||
helperOffset = ui.helper.offset();
|
||||
} });
|
||||
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
});
|
||||
@ -666,17 +683,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
|
||||
|
||||
$("#main").css('position', 'relative');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
$("#main").css('position', 'static');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
$("#main").css('position', 'absolute');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
TestHelpers.draggable.restoreScroll();
|
||||
@ -696,17 +722,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on root", function() {
|
||||
|
||||
$("#main").css('position', 'relative');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
$("#main").css('position', 'static');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
$("#main").css('position', 'absolute');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
TestHelpers.draggable.restoreScroll('root');
|
||||
@ -728,17 +763,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func
|
||||
|
||||
$("#main").css('position', 'relative');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
$("#main").css('position', 'static');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
$("#main").css('position', 'absolute');
|
||||
origOffset = $("#draggable1").offset();
|
||||
TestHelpers.draggable.drag(el, 1, 1);
|
||||
el.simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
|
||||
|
||||
TestHelpers.draggable.restoreScroll('root');
|
||||
@ -750,16 +794,18 @@ test("{ opacity: 0.5 }", function() {
|
||||
|
||||
expect(1);
|
||||
|
||||
var opacity = null;
|
||||
|
||||
$("#draggable2").draggable({
|
||||
var opacity = null,
|
||||
el = $("#draggable2").draggable({
|
||||
opacity: 0.5,
|
||||
start: function() {
|
||||
opacity = $(this).css("opacity");
|
||||
}
|
||||
});
|
||||
|
||||
TestHelpers.draggable.drag("#draggable2", -1, -1);
|
||||
el.simulate( "drag", {
|
||||
dx: -1,
|
||||
dy: -1
|
||||
});
|
||||
|
||||
equal(opacity, 0.5, "start callback: opacity is");
|
||||
|
||||
@ -770,16 +816,18 @@ test("{ zIndex: 10 }", function() {
|
||||
expect(1);
|
||||
|
||||
var actual,
|
||||
expected = 10;
|
||||
|
||||
$("#draggable2").draggable({
|
||||
expected = 10,
|
||||
el = $("#draggable2").draggable({
|
||||
zIndex: expected,
|
||||
start: function() {
|
||||
actual = $(this).css("zIndex");
|
||||
}
|
||||
});
|
||||
|
||||
TestHelpers.draggable.drag("#draggable2", -1, -1);
|
||||
el.simulate( "drag", {
|
||||
dx: -1,
|
||||
dy: -1
|
||||
});
|
||||
|
||||
equal(actual, expected, "start callback: zIndex is");
|
||||
|
||||
|
@ -1,17 +1,14 @@
|
||||
TestHelpers.draggable = {
|
||||
// todo: remove the unreliable offset hacks
|
||||
unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
|
||||
drag: function(handle, dx, dy) {
|
||||
$(handle).simulate("drag", {
|
||||
dx: dx || 0,
|
||||
dy: dy || 0
|
||||
});
|
||||
},
|
||||
testDrag: function(el, handle, dx, dy, expectedDX, expectedDY, msg) {
|
||||
var offsetAfter, actual, expected,
|
||||
offsetBefore = el.offset();
|
||||
|
||||
TestHelpers.draggable.drag(handle, dx, dy);
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: dx,
|
||||
dy: dy
|
||||
});
|
||||
offsetAfter = el.offset();
|
||||
|
||||
actual = { left: offsetAfter.left, top: offsetAfter.top },
|
||||
|
@ -87,7 +87,7 @@ asyncTest( "handle blur via click outside", function() {
|
||||
});
|
||||
});
|
||||
|
||||
test( "handle focus of menu with active item", function() {
|
||||
asyncTest( "handle focus of menu with active item", function() {
|
||||
expect( 1 );
|
||||
var element = $( "#menu1" ).menu({
|
||||
focus: function( event ) {
|
||||
@ -96,11 +96,19 @@ test( "handle focus of menu with active item", function() {
|
||||
});
|
||||
|
||||
log( "focus", true );
|
||||
element.focus();
|
||||
element[0].focus();
|
||||
setTimeout(function() {
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
element.focus();
|
||||
element[0].blur();
|
||||
setTimeout(function() {
|
||||
element[0].focus();
|
||||
setTimeout(function() {
|
||||
equal( logOutput(), "focus,0,1,2,2", "current active item remains active" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "handle submenu auto collapse: mouseleave", function() {
|
||||
@ -162,7 +170,7 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
|
||||
});
|
||||
|
||||
|
||||
test( "handle keyboard navigation on menu without scroll and without submenus", function() {
|
||||
asyncTest( "handle keyboard navigation on menu without scroll and without submenus", function() {
|
||||
expect( 12 );
|
||||
var element = $( "#menu1" ).menu({
|
||||
select: function( event, ui ) {
|
||||
@ -174,7 +182,8 @@ test( "handle keyboard navigation on menu without scroll and without submenus",
|
||||
});
|
||||
|
||||
log( "keydown", true );
|
||||
element.focus();
|
||||
element[0].focus();
|
||||
setTimeout(function() {
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
|
||||
@ -222,6 +231,9 @@ test( "handle keyboard navigation on menu without scroll and without submenus",
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
||||
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
|
||||
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "handle keyboard navigation on menu without scroll and with submenus", function() {
|
||||
@ -344,7 +356,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
|
||||
}
|
||||
});
|
||||
|
||||
test( "handle keyboard navigation on menu with scroll and without submenus", function() {
|
||||
asyncTest( "handle keyboard navigation on menu with scroll and without submenus", function() {
|
||||
expect( 14 );
|
||||
var element = $( "#menu3" ).menu({
|
||||
select: function( event, ui ) {
|
||||
@ -356,7 +368,8 @@ test( "handle keyboard navigation on menu with scroll and without submenus", fun
|
||||
});
|
||||
|
||||
log( "keydown", true );
|
||||
element.focus();
|
||||
element[0].focus();
|
||||
setTimeout(function() {
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
|
||||
@ -413,6 +426,9 @@ test( "handle keyboard navigation on menu with scroll and without submenus", fun
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
||||
equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
|
||||
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "handle keyboard navigation on menu with scroll and with submenus", function() {
|
||||
@ -561,7 +577,7 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite
|
||||
}
|
||||
});
|
||||
|
||||
test( "handle keyboard navigation with spelling of menu items", function() {
|
||||
asyncTest( "handle keyboard navigation with spelling of menu items", function() {
|
||||
expect( 2 );
|
||||
var element = $( "#menu2" ).menu({
|
||||
focus: function( event ) {
|
||||
@ -577,8 +593,9 @@ test( "handle keyboard navigation with spelling of menu items", function() {
|
||||
equal( logOutput(), "keydown,0,1,3", "Keydown focus Addyston by spelling the first 3 letters" );
|
||||
element.simulate( "keydown", { keyCode: 68 } );
|
||||
equal( logOutput(), "keydown,0,1,3,4", "Keydown focus Delphi by repeating the 'd' again" );
|
||||
start();
|
||||
});
|
||||
element.focus();
|
||||
element[0].focus();
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
@ -1,10 +1,12 @@
|
||||
TestHelpers.commonWidgetTests( "progressbar", {
|
||||
defaults: {
|
||||
disabled: false,
|
||||
value: 0,
|
||||
max: 100,
|
||||
value: 0,
|
||||
|
||||
//callbacks
|
||||
change: null,
|
||||
complete: null,
|
||||
create: null
|
||||
}
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
module( "progressbar: core" );
|
||||
|
||||
test( "accessibility", function() {
|
||||
expect( 7 );
|
||||
expect( 11 );
|
||||
var element = $( "#progressbar" ).progressbar();
|
||||
|
||||
equal( element.attr( "role" ), "progressbar", "aria role" );
|
||||
@ -12,9 +12,17 @@ test( "accessibility", function() {
|
||||
element.progressbar( "value", 77 );
|
||||
equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" );
|
||||
|
||||
element.progressbar( "option", "max", 150 );
|
||||
equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
|
||||
|
||||
element.progressbar( "disable" );
|
||||
equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" );
|
||||
|
||||
element.progressbar( "enable" );
|
||||
equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" );
|
||||
|
||||
element.progressbar( "option", "value", false );
|
||||
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
|
||||
equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
|
||||
strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow" );
|
||||
});
|
||||
|
@ -5,34 +5,40 @@ test( "create", function() {
|
||||
$( "#progressbar" ).progressbar({
|
||||
value: 5,
|
||||
create: function() {
|
||||
deepEqual( 5, $( this ).progressbar( "value" ) );
|
||||
equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
|
||||
},
|
||||
change: function() {
|
||||
ok( false, "create() has triggered change()" );
|
||||
ok( false, "create has triggered change()" );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test( "change", function() {
|
||||
expect( 1 );
|
||||
$( "#progressbar" ).progressbar({
|
||||
change: function() {
|
||||
deepEqual( 5, $( this ).progressbar( "value" ) );
|
||||
}
|
||||
}).progressbar( "value", 5 );
|
||||
expect( 2 );
|
||||
var element = $( "#progressbar" ).progressbar();
|
||||
|
||||
element.one( "progressbarchange", function() {
|
||||
equal( element.progressbar( "value" ), 5, "change triggered for middle value" );
|
||||
});
|
||||
element.progressbar( "value", 5 );
|
||||
element.one( "progressbarchange", function() {
|
||||
equal( element.progressbar( "value" ), 100, "change triggered for final value" );
|
||||
});
|
||||
element.progressbar( "value", 100 );
|
||||
});
|
||||
|
||||
test( "complete", function() {
|
||||
expect( 4 );
|
||||
expect( 5 );
|
||||
var value,
|
||||
changes = 0,
|
||||
element = $( "#progressbar" ).progressbar({
|
||||
change: function() {
|
||||
changes++;
|
||||
deepEqual( element.progressbar( "value" ), value, "change at " + value );
|
||||
equal( element.progressbar( "value" ), value, "change at " + value );
|
||||
},
|
||||
complete: function() {
|
||||
equal( changes, 3, "complete triggered after change and not on indeterminate" );
|
||||
equal( element.progressbar( "value" ), 100, "value is 100" );
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -12,7 +12,7 @@ test( "value", function() {
|
||||
|
||||
var element = $( "<div>" ).progressbar({ value: 20 });
|
||||
equal( element.progressbar( "value" ), 20, "correct value as getter" );
|
||||
equal( element.progressbar( "value", 30), element, "chainable as setter" );
|
||||
strictEqual( element.progressbar( "value", 30 ), element, "chainable as setter" );
|
||||
equal( element.progressbar( "option", "value" ), 30, "correct value after setter" );
|
||||
});
|
||||
|
||||
|
@ -3,12 +3,12 @@ module( "progressbar: options" );
|
||||
test( "{ value: 0 }, default", function() {
|
||||
expect( 1 );
|
||||
$( "#progressbar" ).progressbar();
|
||||
equal( 0, $( "#progressbar" ).progressbar( "value" ) );
|
||||
equal( $( "#progressbar" ).progressbar( "value" ), 0 );
|
||||
});
|
||||
|
||||
// Ticket #7231 - valueDiv should be hidden when value is at 0%
|
||||
test( "value: visibility of valueDiv", function() {
|
||||
expect( 5 );
|
||||
expect( 4 );
|
||||
var element = $( "#progressbar" ).progressbar({
|
||||
value: 0
|
||||
});
|
||||
@ -23,9 +23,6 @@ test( "value: visibility of valueDiv", function() {
|
||||
element.progressbar( "value", 0 );
|
||||
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
|
||||
"valueDiv hidden when value is set to 0" );
|
||||
element.progressbar( "value", -1 );
|
||||
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
|
||||
"valueDiv hidden when value set to -1 (normalizes to 0)" );
|
||||
});
|
||||
|
||||
test( "{ value: 5 }", function() {
|
||||
@ -33,7 +30,7 @@ test( "{ value : 5 }", function() {
|
||||
$( "#progressbar" ).progressbar({
|
||||
value: 5
|
||||
});
|
||||
equal( 5, $( "#progressbar" ).progressbar( "value" ) );
|
||||
equal( $( "#progressbar" ).progressbar( "value" ), 5 );
|
||||
});
|
||||
|
||||
test( "{ value: -5 }", function() {
|
||||
@ -41,7 +38,8 @@ test( "{ value : -5 }", function() {
|
||||
$( "#progressbar" ).progressbar({
|
||||
value: -5
|
||||
});
|
||||
deepEqual( 0, $( "#progressbar" ).progressbar( "value" ) );
|
||||
equal( $( "#progressbar" ).progressbar( "value" ), 0,
|
||||
"value constrained at min" );
|
||||
});
|
||||
|
||||
test( "{ value: 105 }", function() {
|
||||
@ -49,16 +47,8 @@ test( "{ value : 105 }", function() {
|
||||
$( "#progressbar" ).progressbar({
|
||||
value: 105
|
||||
});
|
||||
deepEqual( 100, $( "#progressbar" ).progressbar( "value" ) );
|
||||
});
|
||||
|
||||
test( "{ max : 5, value : 10 }", function() {
|
||||
expect( 1 );
|
||||
$("#progressbar").progressbar({
|
||||
max: 5,
|
||||
value: 10
|
||||
});
|
||||
deepEqual( 5, $( "#progressbar" ).progressbar( "value" ) );
|
||||
equal( $( "#progressbar" ).progressbar( "value" ), 100,
|
||||
"value constrained at max" );
|
||||
});
|
||||
|
||||
test( "{ value: 10, max: 5 }", function() {
|
||||
@ -67,14 +57,16 @@ test( "{ value : 10, max : 5 }", function() {
|
||||
max: 5,
|
||||
value: 10
|
||||
});
|
||||
deepEqual( 5, $( "#progressbar" ).progressbar( "value" ) );
|
||||
equal( $( "#progressbar" ).progressbar( "value" ), 5,
|
||||
"value constrained at max" );
|
||||
});
|
||||
|
||||
test( "{ max : 5 }", function() {
|
||||
test( "change max below value", function() {
|
||||
expect( 1 );
|
||||
$("#progressbar").progressbar({
|
||||
max: 10,
|
||||
value: 10
|
||||
}).progressbar( "option", "max", 5 );
|
||||
deepEqual( 5, $( "#progressbar" ).progressbar( "value" ) );
|
||||
equal( $( "#progressbar" ).progressbar( "value" ), 5,
|
||||
"value constrained at max" );
|
||||
});
|
||||
|
@ -31,6 +31,10 @@
|
||||
<script src="../swarminject.js"></script>
|
||||
|
||||
<style>
|
||||
#container {
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
}
|
||||
#resizable1 {
|
||||
background: green;
|
||||
height: 100px;
|
||||
@ -51,7 +55,9 @@
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
<div id="container">
|
||||
<div id="resizable1">I'm a resizable.</div>
|
||||
</div>
|
||||
<img src="images/test.jpg" id="resizable2" alt="solid gray">
|
||||
|
||||
</div>
|
||||
|
@ -40,8 +40,8 @@ test("resize", function() {
|
||||
handles: "all",
|
||||
resize: function( event, ui ) {
|
||||
if ( count === 0 ) {
|
||||
equal( ui.size.width, 101, "compare width" );
|
||||
equal( ui.size.height, 101, "compare height" );
|
||||
equal( ui.size.width, 125, "compare width" );
|
||||
equal( ui.size.height, 125, "compare height" );
|
||||
equal( ui.originalSize.width, 100, "compare original width" );
|
||||
equal( ui.originalSize.height, 100, "compare original height" );
|
||||
} else {
|
||||
@ -82,7 +82,7 @@ test("resize (min/max dimensions)", function() {
|
||||
}
|
||||
});
|
||||
|
||||
TestHelpers.resizable.drag(handle, -50, -50);
|
||||
TestHelpers.resizable.drag( handle, -200, -200 );
|
||||
|
||||
equal( count, 1, "resize callback should happen exactly once per size adjustment" );
|
||||
|
||||
@ -103,15 +103,19 @@ test("resize (containment)", function() {
|
||||
handles: "all",
|
||||
containment: container,
|
||||
resize: function( event, ui ) {
|
||||
equal( ui.size.width, 50, "compare width" );
|
||||
equal( ui.size.height, 50, "compare height" );
|
||||
equal( ui.size.width, 10, "compare width" );
|
||||
equal( ui.size.height, 10, "compare height" );
|
||||
equal( ui.originalSize.width, 100, "compare original width" );
|
||||
equal( ui.originalSize.height, 100, "compare original height" );
|
||||
count++;
|
||||
}
|
||||
});
|
||||
|
||||
TestHelpers.resizable.drag(handle, -50, -50);
|
||||
// Prove you can't resize outside containment by dragging southeast corner southeast
|
||||
TestHelpers.resizable.drag( handle, 100, 100 );
|
||||
|
||||
// Prove you can't resize outside containment by dragging southeast corner northwest
|
||||
TestHelpers.resizable.drag( handle, -200, -200 );
|
||||
|
||||
equal( count, 1, "resize callback should happen exactly once per size adjustment" );
|
||||
|
||||
|
@ -5,6 +5,26 @@
|
||||
|
||||
module("resizable: options");
|
||||
|
||||
test( "alsoResize", function() {
|
||||
expect( 2 );
|
||||
|
||||
var other = $( "<div>" )
|
||||
.css({
|
||||
width: 50,
|
||||
height: 50
|
||||
})
|
||||
.appendTo( "body" ),
|
||||
element = $( "#resizable1" ).resizable({
|
||||
alsoResize: other
|
||||
}),
|
||||
handle = ".ui-resizable-e";
|
||||
|
||||
TestHelpers.resizable.drag( handle, 80 );
|
||||
equal( element.width(), 180, "resizable width" );
|
||||
equal( other.width(), 130, "alsoResize width" );
|
||||
});
|
||||
|
||||
|
||||
test("aspectRatio: 'preserve' (e)", function() {
|
||||
expect(4);
|
||||
|
||||
@ -103,6 +123,21 @@ test("aspectRatio: 'preserve' (ne)", function() {
|
||||
equal( target.height(), 70, "compare minHeight");
|
||||
});
|
||||
|
||||
test( "containment", function() {
|
||||
expect( 4 );
|
||||
var element = $( "#resizable1" ).resizable({
|
||||
containment: "#container"
|
||||
});
|
||||
|
||||
TestHelpers.resizable.drag( ".ui-resizable-se", 20, 30 );
|
||||
equal( element.width(), 120, "unconstrained width within container" );
|
||||
equal( element.height(), 130, "unconstrained height within container" );
|
||||
|
||||
TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 );
|
||||
equal( element.width(), 300, "constrained width at containment edge" );
|
||||
equal( element.height(), 200, "constrained height at containment edge" );
|
||||
});
|
||||
|
||||
test("grid", function() {
|
||||
expect(4);
|
||||
|
||||
@ -210,4 +245,24 @@ test("zIndex, applied to all handles", function() {
|
||||
});
|
||||
});
|
||||
|
||||
test( "alsoResize + containment", function() {
|
||||
expect( 4 );
|
||||
var other = $( "<div>" )
|
||||
.css({
|
||||
width: 50,
|
||||
height: 50
|
||||
})
|
||||
.appendTo( "body" ),
|
||||
element = $( "#resizable1" ).resizable({
|
||||
alsoResize: other,
|
||||
containment: "#container"
|
||||
});
|
||||
|
||||
TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 );
|
||||
equal( element.width(), 300, "resizable constrained width at containment edge" );
|
||||
equal( element.height(), 200, "resizable constrained height at containment edge" );
|
||||
equal( other.width(), 250, "alsoResize constrained width at containment edge" );
|
||||
equal( other.height(), 150, "alsoResize constrained height at containment edge" );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -1,15 +1,11 @@
|
||||
TestHelpers.resizable = {
|
||||
drag: function(el, dx, dy, complete) {
|
||||
|
||||
// speed = sync -> Drag syncrhonously.
|
||||
// speed = fast|slow -> Drag asyncrhonously - animated.
|
||||
|
||||
drag: function( el, dx, dy ) {
|
||||
// this mouseover is to work around a limitation in resizable
|
||||
// TODO: fix resizable so handle doesn't require mouseover in order to be used
|
||||
$(el).simulate("mouseover");
|
||||
|
||||
return $(el).simulate("drag", {
|
||||
dx: dx||0, dy: dy||0, speed: 'sync', complete: complete
|
||||
$( el ).simulate("mouseover").simulate( "drag", {
|
||||
moves: 2,
|
||||
dx: dx,
|
||||
dy: dy
|
||||
});
|
||||
}
|
||||
};
|
@ -14,7 +14,10 @@ test("start", function() {
|
||||
equal( this, el[0], "context of callback" );
|
||||
}
|
||||
});
|
||||
el.simulate("drag", 20, 20);
|
||||
el.simulate( "drag", {
|
||||
dx: 20,
|
||||
dy: 20
|
||||
});
|
||||
});
|
||||
|
||||
test( "stop", function() {
|
||||
@ -26,7 +29,10 @@ test("stop", function() {
|
||||
equal( this, el[0], "context of callback" );
|
||||
}
|
||||
});
|
||||
el.simulate("drag", 20, 20);
|
||||
el.simulate( "drag", {
|
||||
dx: 20,
|
||||
dy: 20
|
||||
});
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
@ -53,10 +53,16 @@ test("enable", function() {
|
||||
disabled: true,
|
||||
start: function() { fired = true; }
|
||||
});
|
||||
el.simulate("drag", 20, 20);
|
||||
el.simulate( "drag", {
|
||||
dx: 20,
|
||||
dy: 20
|
||||
});
|
||||
equal(fired, false, "start fired");
|
||||
el.selectable("enable");
|
||||
el.simulate("drag", 20, 20);
|
||||
el.simulate( "drag", {
|
||||
dx: 20,
|
||||
dy: 20
|
||||
});
|
||||
equal(fired, true, "start fired");
|
||||
el.selectable("destroy");
|
||||
|
||||
@ -75,11 +81,18 @@ test("disable", function() {
|
||||
disabled: false,
|
||||
start: function() { fired = true; }
|
||||
});
|
||||
el.simulate("drag", 20, 20);
|
||||
el.simulate( "drag", {
|
||||
dx: 20,
|
||||
dy: 20
|
||||
});
|
||||
equal(fired, true, "start fired");
|
||||
el.selectable("disable");
|
||||
fired = false;
|
||||
el.simulate("drag", 20, 20);
|
||||
|
||||
el.simulate( "drag", {
|
||||
dx: 20,
|
||||
dy: 20
|
||||
});
|
||||
equal(fired, false, "start fired");
|
||||
el.selectable("destroy");
|
||||
|
||||
|
@ -15,7 +15,10 @@ test("autoRefresh", function() {
|
||||
|
||||
el = $("#selectable1").selectable({ autoRefresh: false, selected: selected });
|
||||
sel.hide();
|
||||
TestHelpers.selectable.drag(el, 1000, 1000);
|
||||
el.simulate( "drag", {
|
||||
dx: 1000,
|
||||
dy: 1000
|
||||
});
|
||||
equal(actual, sel.length);
|
||||
el.selectable("destroy");
|
||||
|
||||
@ -23,11 +26,19 @@ test("autoRefresh", function() {
|
||||
sel.show();
|
||||
el = $("#selectable1").selectable({ autoRefresh: true, selected: selected });
|
||||
sel.hide();
|
||||
TestHelpers.selectable.drag(el, 1000, 1000);
|
||||
el.simulate( "drag", {
|
||||
dx: 1000,
|
||||
dy: 1000
|
||||
});
|
||||
equal(actual, 0);
|
||||
|
||||
sel.show();
|
||||
TestHelpers.selectable.drag( sel[ 0 ], 1000, 1000 );
|
||||
$( sel[ 0 ] ).simulate( "drag", {
|
||||
dx: 1000,
|
||||
dy: 1000
|
||||
});
|
||||
equal(actual, sel.length);
|
||||
|
||||
el.selectable("destroy");
|
||||
sel.show();
|
||||
});
|
||||
@ -42,7 +53,10 @@ test("filter", function() {
|
||||
|
||||
|
||||
el = $("#selectable1").selectable({ filter: '.special', selected: selected });
|
||||
TestHelpers.selectable.drag(el, 1000, 1000);
|
||||
el.simulate( "drag", {
|
||||
dx: 1000,
|
||||
dy: 1000
|
||||
});
|
||||
ok(sel.length !== 1, "this test assumes more than 1 selectee");
|
||||
equal(actual, 1);
|
||||
el.selectable("destroy");
|
||||
|
@ -1,8 +0,0 @@
|
||||
TestHelpers.selectable = {
|
||||
drag: function( el, dx, dy ) {
|
||||
$( el ).simulate( "drag", {
|
||||
dx: dx || 0,
|
||||
dy: dy || 0
|
||||
});
|
||||
}
|
||||
};
|
@ -9,9 +9,13 @@ test("start", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
.sortable({ start: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
|
||||
$("#sortable").sortable({
|
||||
start: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dy: 10
|
||||
});
|
||||
|
||||
ok(hash, 'start event triggered');
|
||||
ok(hash.helper, 'UI hash includes: helper');
|
||||
@ -30,9 +34,13 @@ test("sort", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
.sortable({ sort: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
|
||||
$("#sortable").sortable({
|
||||
sort: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dy: 10
|
||||
});
|
||||
|
||||
ok(hash, 'sort event triggered');
|
||||
ok(hash.helper, 'UI hash includes: helper');
|
||||
@ -48,15 +56,24 @@ test("change", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
.sortable({ change: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
|
||||
$("#sortable").sortable({
|
||||
change: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
|
||||
ok(!hash, '1px drag, change event should not be triggered');
|
||||
|
||||
$("#sortable")
|
||||
.sortable({ change: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 22 });
|
||||
$("#sortable").sortable({
|
||||
change: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dy: 22
|
||||
});
|
||||
|
||||
ok(hash, 'change event triggered');
|
||||
ok(hash.helper, 'UI hash includes: helper');
|
||||
@ -72,9 +89,13 @@ test("beforeStop", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
.sortable({ beforeStop: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
||||
$("#sortable").sortable({
|
||||
beforeStop: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dy: 20
|
||||
});
|
||||
|
||||
ok(hash, 'beforeStop event triggered');
|
||||
ok(hash.helper, 'UI hash includes: helper');
|
||||
@ -90,9 +111,13 @@ test("stop", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
.sortable({ stop: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
||||
$("#sortable").sortable({
|
||||
stop: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dy: 20
|
||||
});
|
||||
|
||||
ok(hash, 'stop event triggered');
|
||||
ok(!hash.helper, 'UI should not include: helper');
|
||||
@ -108,15 +133,24 @@ test("update", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash;
|
||||
$("#sortable")
|
||||
.sortable({ update: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
|
||||
$("#sortable").sortable({
|
||||
update: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
|
||||
ok(!hash, '1px drag, update event should not be triggered');
|
||||
|
||||
$("#sortable")
|
||||
.sortable({ update: function(e, ui) { hash = ui; } })
|
||||
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 22 });
|
||||
$("#sortable").sortable({
|
||||
update: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dy: 22
|
||||
});
|
||||
|
||||
ok(hash, 'update event triggered');
|
||||
ok(!hash.helper, 'UI hash should not include: helper');
|
||||
@ -128,6 +162,67 @@ test("update", function() {
|
||||
|
||||
});
|
||||
|
||||
test("#3019: Stop fires too early", function() {
|
||||
expect(2);
|
||||
|
||||
var helper = null,
|
||||
el = $("#sortable").sortable({
|
||||
stop: function(event, ui) {
|
||||
helper = ui.helper;
|
||||
}
|
||||
});
|
||||
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable');
|
||||
equal(helper, null, "helper should be false");
|
||||
|
||||
});
|
||||
|
||||
test('#4752: link event firing on sortable with connect list', function () {
|
||||
expect( 10 );
|
||||
|
||||
var fired = {},
|
||||
hasFired = function (type) { return (type in fired) && (true === fired[type]); };
|
||||
|
||||
$('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable');
|
||||
|
||||
$('#qunit-fixture ul').sortable({
|
||||
connectWith: '#qunit-fixture ul',
|
||||
change: function () {
|
||||
fired.change = true;
|
||||
},
|
||||
receive: function () {
|
||||
fired.receive = true;
|
||||
},
|
||||
remove: function () {
|
||||
fired.remove = true;
|
||||
}
|
||||
});
|
||||
|
||||
$('#qunit-fixture ul').bind('click.ui-sortable-test', function () {
|
||||
fired.click = true;
|
||||
});
|
||||
|
||||
$('#sortable li:eq(0)').simulate('click');
|
||||
ok(!hasFired('change'), 'Click only, change event should not have fired');
|
||||
ok(hasFired('click'), 'Click event should have fired');
|
||||
|
||||
// Drag an item within the first list
|
||||
fired = {};
|
||||
$('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 });
|
||||
ok(hasFired('change'), '40px drag, change event should have fired');
|
||||
ok(!hasFired('receive'), 'Receive event should not have fired');
|
||||
ok(!hasFired('remove'), 'Remove event should not have fired');
|
||||
ok(!hasFired('click'), 'Click event should not have fired');
|
||||
|
||||
// Drag an item from the first list to the second, connected list
|
||||
fired = {};
|
||||
$('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 });
|
||||
ok(hasFired('change'), '150px drag, change event should have fired');
|
||||
ok(hasFired('receive'), 'Receive event should have fired');
|
||||
ok(hasFired('remove'), 'Remove event should have fired');
|
||||
ok(!hasFired('click'), 'Click event should not have fired');
|
||||
});
|
||||
|
||||
/*
|
||||
test("receive", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
|
@ -1,8 +1,8 @@
|
||||
TestHelpers.sortable = {
|
||||
sort: function( handle, dx, dy, index, msg ) {
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: dx || 0,
|
||||
dy: dy || 0
|
||||
dx: dx,
|
||||
dy: dy
|
||||
});
|
||||
equal( $( handle ).parent().children().index( handle ), index, msg );
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* sortable_tickets.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
module("sortable: tickets");
|
||||
|
||||
test("#3019: Stop fires too early", function() {
|
||||
expect(2);
|
||||
|
||||
var helper = null,
|
||||
el = $("#sortable").sortable({
|
||||
stop: function(event, ui) {
|
||||
helper = ui.helper;
|
||||
}
|
||||
});
|
||||
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable');
|
||||
equal(helper, null, "helper should be false");
|
||||
|
||||
});
|
||||
|
||||
test('#4752: link event firing on sortable with connect list', function () {
|
||||
expect( 10 );
|
||||
|
||||
var fired = {},
|
||||
hasFired = function (type) { return (type in fired) && (true === fired[type]); };
|
||||
|
||||
$('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable');
|
||||
|
||||
$('#qunit-fixture ul').sortable({
|
||||
connectWith: '#qunit-fixture ul',
|
||||
change: function () {
|
||||
fired.change = true;
|
||||
},
|
||||
receive: function () {
|
||||
fired.receive = true;
|
||||
},
|
||||
remove: function () {
|
||||
fired.remove = true;
|
||||
}
|
||||
});
|
||||
|
||||
$('#qunit-fixture ul').bind('click.ui-sortable-test', function () {
|
||||
fired.click = true;
|
||||
});
|
||||
|
||||
$('#sortable li:eq(0)').simulate('click');
|
||||
ok(!hasFired('change'), 'Click only, change event should not have fired');
|
||||
ok(hasFired('click'), 'Click event should have fired');
|
||||
|
||||
// Drag an item within the first list
|
||||
fired = {};
|
||||
$('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 });
|
||||
ok(hasFired('change'), '40px drag, change event should have fired');
|
||||
ok(!hasFired('receive'), 'Receive event should not have fired');
|
||||
ok(!hasFired('remove'), 'Remove event should not have fired');
|
||||
ok(!hasFired('click'), 'Click event should not have fired');
|
||||
|
||||
// Drag an item from the first list to the second, connected list
|
||||
fired = {};
|
||||
$('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 });
|
||||
ok(hasFired('change'), '150px drag, change event should have fired');
|
||||
ok(hasFired('receive'), 'Receive event should have fired');
|
||||
ok(hasFired('remove'), 'Remove event should have fired');
|
||||
ok(!hasFired('click'), 'Click event should not have fired');
|
||||
});
|
||||
|
||||
})(jQuery);
|
@ -131,30 +131,51 @@ asyncTest( "change", function() {
|
||||
});
|
||||
}
|
||||
|
||||
element.focus();
|
||||
function focusWrap( fn, next ) {
|
||||
element[0].focus();
|
||||
setTimeout( function() {
|
||||
fn();
|
||||
setTimeout(function() {
|
||||
element[0].blur();
|
||||
setTimeout( next );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function step1() {
|
||||
focusWrap(function() {
|
||||
shouldChange( false, "key UP, before blur" );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.UP );
|
||||
shouldChange( true, "blur after key UP" );
|
||||
element.blur();
|
||||
}, step2 );
|
||||
}
|
||||
|
||||
element.focus();
|
||||
function step2() {
|
||||
focusWrap(function() {
|
||||
shouldChange( false, "key DOWN, before blur" );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.DOWN );
|
||||
shouldChange( true, "blur after key DOWN" );
|
||||
element.blur();
|
||||
}, step3 );
|
||||
}
|
||||
|
||||
element.focus();
|
||||
function step3() {
|
||||
focusWrap(function() {
|
||||
shouldChange( false, "key PAGE_UP, before blur" );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
|
||||
shouldChange( true, "blur after key PAGE_UP" );
|
||||
element.blur();
|
||||
}, step4 );
|
||||
}
|
||||
|
||||
element.focus();
|
||||
function step4() {
|
||||
focusWrap(function() {
|
||||
shouldChange( false, "key PAGE_DOWN, before blur" );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
|
||||
shouldChange( true, "blur after key PAGE_DOWN" );
|
||||
element.blur();
|
||||
}, step5 );
|
||||
}
|
||||
|
||||
function step5() {
|
||||
focusWrap(function() {
|
||||
shouldChange( false, "many keys, before blur" );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.UP );
|
||||
@ -162,8 +183,11 @@ asyncTest( "change", function() {
|
||||
simulateKeyDownUp( element, $.ui.keyCode.UP );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.DOWN );
|
||||
shouldChange( true, "blur after many keys" );
|
||||
element.blur();
|
||||
}, step6 );
|
||||
}
|
||||
|
||||
function step6() {
|
||||
focusWrap(function() {
|
||||
shouldChange( false, "many keys, same final value, before blur" );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.UP );
|
||||
simulateKeyDownUp( element, $.ui.keyCode.UP );
|
||||
@ -174,23 +198,29 @@ asyncTest( "change", function() {
|
||||
shouldChange( false, "button up, before blur" );
|
||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
||||
shouldChange( true, "blur after button up" );
|
||||
setTimeout(function() {
|
||||
element.blur();
|
||||
}, step7 );
|
||||
}
|
||||
|
||||
function step7() {
|
||||
focusWrap(function() {
|
||||
shouldChange( false, "button down, before blur" );
|
||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
||||
shouldChange( true, "blur after button down" );
|
||||
setTimeout(function() {
|
||||
element.blur();
|
||||
}, step8 );
|
||||
}
|
||||
|
||||
function step8() {
|
||||
focusWrap(function() {
|
||||
shouldChange( false, "many buttons, same final value, before blur" );
|
||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
||||
shouldChange( false, "blur after many buttons, same final value" );
|
||||
element.blur();
|
||||
setTimeout(function() {
|
||||
}, step9 );
|
||||
}
|
||||
|
||||
function step9() {
|
||||
shouldChange( true, "stepUp" );
|
||||
element.spinner( "stepUp" );
|
||||
|
||||
@ -220,11 +250,10 @@ asyncTest( "change", function() {
|
||||
|
||||
shouldChange( false, "min, value not changed" );
|
||||
element.spinner( "option", "min", 200 );
|
||||
shouldChange( true, "cleanup" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout( step1 );
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
@ -600,7 +600,7 @@ test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", funct
|
||||
expect( 2 );
|
||||
|
||||
var element = $("<div><ul><li><a href='#tab'>Tab</a></li></ul><div id='tab'></div></div>");
|
||||
element.appendTo( "#main" );
|
||||
element.appendTo("#qunit-fixture");
|
||||
element.tabs({
|
||||
beforeLoad: function() {
|
||||
event.preventDefault();
|
||||
|
@ -212,7 +212,7 @@ window.domEqual = function( selector, modifier, message ) {
|
||||
"tabIndex",
|
||||
"title"
|
||||
];
|
||||
/*
|
||||
|
||||
function getElementStyles( elem ) {
|
||||
var key, len,
|
||||
style = elem.ownerDocument.defaultView ?
|
||||
@ -239,7 +239,7 @@ window.domEqual = function( selector, modifier, message ) {
|
||||
|
||||
return styles;
|
||||
}
|
||||
*/
|
||||
|
||||
function extract( elem ) {
|
||||
if ( !elem || !elem.length ) {
|
||||
QUnit.push( false, actual, expected,
|
||||
@ -257,8 +257,7 @@ window.domEqual = function( selector, modifier, message ) {
|
||||
var value = elem.attr( attr );
|
||||
result[ attr ] = value !== undefined ? value : "";
|
||||
});
|
||||
// TODO: Enable when we can figure out what's happening with accordion
|
||||
//result.style = getElementStyles( elem[ 0 ] );
|
||||
result.style = getElementStyles( elem[ 0 ] );
|
||||
result.events = $._data( elem[ 0 ], "events" );
|
||||
result.data = $.extend( {}, elem.data() );
|
||||
delete result.data[ $.expando ];
|
||||
|
@ -13,18 +13,23 @@ TestHelpers.testJshint( "widget" );
|
||||
|
||||
test( "widget creation", function() {
|
||||
expect( 5 );
|
||||
var myPrototype = {
|
||||
_create: function() {},
|
||||
creationTest: function() {}
|
||||
var method,
|
||||
myPrototype = {
|
||||
_create: function() {
|
||||
equal( method, "_create", "create function is copied over" );
|
||||
},
|
||||
creationTest: function() {
|
||||
equal( method, "creationTest", "random function is copied over" );
|
||||
}
|
||||
};
|
||||
|
||||
$.widget( "ui.testWidget", myPrototype );
|
||||
ok( $.isFunction( $.ui.testWidget ), "constructor was created" );
|
||||
equal( "object", typeof $.ui.testWidget.prototype, "prototype was created" );
|
||||
equal( $.ui.testWidget.prototype._create, myPrototype._create,
|
||||
"create function is copied over" );
|
||||
equal( $.ui.testWidget.prototype.creationTest, myPrototype.creationTest,
|
||||
"random function is copied over" );
|
||||
equal( typeof $.ui.testWidget.prototype, "object", "prototype was created" );
|
||||
method = "_create";
|
||||
$.ui.testWidget.prototype._create();
|
||||
method = "creationTest";
|
||||
$.ui.testWidget.prototype.creationTest();
|
||||
equal( $.ui.testWidget.prototype.option, $.Widget.prototype.option,
|
||||
"option method copied over from base widget" );
|
||||
});
|
||||
@ -1324,6 +1329,34 @@ test( "redefine - widgetEventPrefix", function() {
|
||||
|
||||
});
|
||||
|
||||
test( "mixins", function() {
|
||||
expect( 2 );
|
||||
|
||||
var mixin = {
|
||||
method: function() {
|
||||
return "mixed " + this._super();
|
||||
}
|
||||
};
|
||||
|
||||
$.widget( "ui.testWidget1", {
|
||||
method: function() {
|
||||
return "testWidget1";
|
||||
}
|
||||
});
|
||||
$.widget( "ui.testWidget2", {
|
||||
method: function() {
|
||||
return "testWidget2";
|
||||
}
|
||||
});
|
||||
$.widget( "ui.testWidget1", $.ui.testWidget1, mixin );
|
||||
$.widget( "ui.testWidget2", $.ui.testWidget2, mixin );
|
||||
|
||||
equal( $( "<div>" ).testWidget1().testWidget1( "method" ),
|
||||
"mixed testWidget1", "testWidget1 mixin successful" );
|
||||
equal( $( "<div>" ).testWidget2().testWidget2( "method" ),
|
||||
"mixed testWidget2", "testWidget2 mixin successful" );
|
||||
});
|
||||
|
||||
asyncTest( "_delay", function() {
|
||||
expect( 6 );
|
||||
var order = 0,
|
||||
|
@ -20,6 +20,11 @@
|
||||
<script src="../../../ui/jquery.ui.autocomplete.js"></script>
|
||||
<script src="../../../ui/jquery.ui.tooltip.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-size: 62.5%;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
$(function() {
|
||||
var dialog = $( "#dialog" ).dialog({
|
||||
@ -98,7 +103,7 @@
|
||||
|
||||
<button id="open-dialog">Reopen dialog</button>
|
||||
|
||||
<div id="dialog" title="Basic dialog">
|
||||
<div id="dialog" title="Basic dialog, but with a really long title that doesn't quite fit.">
|
||||
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
|
||||
<p><button id="open-datepicker">Open another window with a datepicker.</button></p>
|
||||
<p><button id="destroy-dialog">Self destruct</button></p>
|
||||
|
3
themes/base/jquery.ui.accordion.css
vendored
3
themes/base/jquery.ui.accordion.css
vendored
@ -14,7 +14,7 @@
|
||||
position: relative;
|
||||
margin-top: 2px;
|
||||
padding: .5em .5em .5em .7em;
|
||||
zoom: 1;
|
||||
min-height: 0; /* support: IE7 */
|
||||
}
|
||||
.ui-accordion .ui-accordion-icons {
|
||||
padding-left: 2.2em;
|
||||
@ -35,5 +35,4 @@
|
||||
padding: 1em 2.2em;
|
||||
border-top: 0;
|
||||
overflow: auto;
|
||||
zoom: 1;
|
||||
}
|
||||
|
10
themes/base/jquery.ui.button.css
vendored
10
themes/base/jquery.ui.button.css
vendored
@ -12,10 +12,11 @@
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
padding: 0;
|
||||
line-height: normal;
|
||||
margin-right: .1em;
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
zoom: 1;
|
||||
overflow: visible; /* removes extra width in IE */
|
||||
}
|
||||
.ui-button,
|
||||
@ -42,8 +43,8 @@ button.ui-button-icons-only {
|
||||
|
||||
/* button text element */
|
||||
.ui-button .ui-button-text {
|
||||
display: inline-block;
|
||||
line-height: 1.4;
|
||||
display: block;
|
||||
line-height: normal;
|
||||
}
|
||||
.ui-button-text-only .ui-button-text {
|
||||
padding: .4em 1em;
|
||||
@ -105,7 +106,8 @@ input.ui-button {
|
||||
}
|
||||
|
||||
/* workarounds */
|
||||
/* reset extra padding in Firefox */
|
||||
/* reset extra padding in Firefox, see h5bp.com/l */
|
||||
input.ui-button::-moz-focus-inner,
|
||||
button.ui-button::-moz-focus-inner {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
|
2
themes/base/jquery.ui.core.css
vendored
2
themes/base/jquery.ui.core.css
vendored
@ -43,7 +43,7 @@
|
||||
clear: both;
|
||||
}
|
||||
.ui-helper-clearfix {
|
||||
zoom: 1;
|
||||
min-height: 0; /* support: IE7 */
|
||||
}
|
||||
.ui-helper-zfix {
|
||||
width: 100%;
|
||||
|
15
themes/base/jquery.ui.dialog.css
vendored
15
themes/base/jquery.ui.dialog.css
vendored
@ -23,7 +23,11 @@
|
||||
}
|
||||
.ui-dialog .ui-dialog-title {
|
||||
float: left;
|
||||
margin: .1em 16px .1em 0;
|
||||
margin: .1em 0;
|
||||
white-space: nowrap;
|
||||
width: 90%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.ui-dialog .ui-dialog-titlebar-close {
|
||||
position: absolute;
|
||||
@ -40,7 +44,6 @@
|
||||
padding: .5em 1em;
|
||||
background: none;
|
||||
overflow: auto;
|
||||
zoom: 1;
|
||||
}
|
||||
.ui-dialog .ui-dialog-buttonpane {
|
||||
text-align: left;
|
||||
@ -57,10 +60,10 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
.ui-dialog .ui-resizable-se {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
right: 3px;
|
||||
bottom: 3px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
right: -5px;
|
||||
bottom: -5px;
|
||||
}
|
||||
.ui-draggable .ui-dialog-titlebar {
|
||||
cursor: move;
|
||||
|
3
themes/base/jquery.ui.menu.css
vendored
3
themes/base/jquery.ui.menu.css
vendored
@ -22,7 +22,6 @@
|
||||
.ui-menu .ui-menu-item {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
zoom: 1;
|
||||
width: 100%;
|
||||
}
|
||||
.ui-menu .ui-menu-divider {
|
||||
@ -37,7 +36,7 @@
|
||||
display: block;
|
||||
padding: 2px .4em;
|
||||
line-height: 1.5;
|
||||
zoom: 1;
|
||||
min-height: 0; /* support: IE7 */
|
||||
font-weight: normal;
|
||||
}
|
||||
.ui-menu .ui-menu-item a.ui-state-focus,
|
||||
|
1
themes/base/jquery.ui.tabs.css
vendored
1
themes/base/jquery.ui.tabs.css
vendored
@ -11,7 +11,6 @@
|
||||
.ui-tabs {
|
||||
position: relative;/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
|
||||
padding: .2em;
|
||||
zoom: 1;
|
||||
}
|
||||
.ui-tabs .ui-tabs-nav {
|
||||
margin: 0;
|
||||
|
5
themes/base/jquery.ui.theme.css
vendored
5
themes/base/jquery.ui.theme.css
vendored
@ -41,9 +41,10 @@
|
||||
background: #cccccc/*{bgColorHeader}*/ url(images/ui-bg_highlight-soft_75_cccccc_1x100.png)/*{bgImgUrlHeader}*/ 50%/*{bgHeaderXPos}*/ 50%/*{bgHeaderYPos}*/ repeat-x/*{bgHeaderRepeat}*/;
|
||||
color: #222222/*{fcHeader}*/;
|
||||
font-weight: bold;
|
||||
zoom: 1;
|
||||
}
|
||||
.ui-widget-header a { color: #222222/*{fcHeader}*/; }
|
||||
.ui-widget-header a {
|
||||
color: #222222/*{fcHeader}*/;
|
||||
}
|
||||
|
||||
/* Interaction states
|
||||
----------------------------------*/
|
||||
|
23
ui/i18n/jquery.ui.datepicker-be.js
vendored
Normal file
23
ui/i18n/jquery.ui.datepicker-be.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/* Belarusian initialisation for the jQuery UI date picker plugin. */
|
||||
/* Written by Pavel Selitskas <p.selitskas@gmail.com> */
|
||||
jQuery(function($){
|
||||
$.datepicker.regional['be'] = {
|
||||
closeText: 'Зачыніць',
|
||||
prevText: '←Папяр.',
|
||||
nextText: 'Наст.→',
|
||||
currentText: 'Сёньня',
|
||||
monthNames: ['Студзень','Люты','Сакавік','Красавік','Травень','Чэрвень',
|
||||
'Ліпень','Жнівень','Верасень','Кастрычнік','Лістапад','Сьнежань'],
|
||||
monthNamesShort: ['Сту','Лют','Сак','Кра','Тра','Чэр',
|
||||
'Ліп','Жні','Вер','Кас','Ліс','Сьн'],
|
||||
dayNames: ['нядзеля','панядзелак','аўторак','серада','чацьвер','пятніца','субота'],
|
||||
dayNamesShort: ['ндз','пнд','аўт','срд','чцв','птн','сбт'],
|
||||
dayNamesMin: ['Нд','Пн','Аў','Ср','Чц','Пт','Сб'],
|
||||
weekHeader: 'Тд',
|
||||
dateFormat: 'dd.mm.yy',
|
||||
firstDay: 1,
|
||||
isRTL: false,
|
||||
showMonthAfterYear: false,
|
||||
yearSuffix: ''};
|
||||
$.datepicker.setDefaults($.datepicker.regional['be']);
|
||||
});
|
22
ui/i18n/jquery.ui.datepicker-nb.js
vendored
Normal file
22
ui/i18n/jquery.ui.datepicker-nb.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/* Norwegian Bokmål initialisation for the jQuery UI date picker plugin. */
|
||||
/* Written by Bjørn Johansen (post@bjornjohansen.no). */
|
||||
jQuery(function($){
|
||||
$.datepicker.regional['nb'] = {
|
||||
closeText: 'Lukk',
|
||||
prevText: '«Forrige',
|
||||
nextText: 'Neste»',
|
||||
currentText: 'I dag',
|
||||
monthNames: ['januar','februar','mars','april','mai','juni','juli','august','september','oktober','november','desember'],
|
||||
monthNamesShort: ['jan','feb','mar','apr','mai','jun','jul','aug','sep','okt','nov','des'],
|
||||
dayNamesShort: ['søn','man','tir','ons','tor','fre','lør'],
|
||||
dayNames: ['søndag','mandag','tirsdag','onsdag','torsdag','fredag','lørdag'],
|
||||
dayNamesMin: ['sø','ma','ti','on','to','fr','lø'],
|
||||
weekHeader: 'Uke',
|
||||
dateFormat: 'dd.mm.yy',
|
||||
firstDay: 1,
|
||||
isRTL: false,
|
||||
showMonthAfterYear: false,
|
||||
yearSuffix: ''
|
||||
};
|
||||
$.datepicker.setDefaults($.datepicker.regional['nb']);
|
||||
});
|
22
ui/i18n/jquery.ui.datepicker-nn.js
vendored
Normal file
22
ui/i18n/jquery.ui.datepicker-nn.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/* Norwegian Nynorsk initialisation for the jQuery UI date picker plugin. */
|
||||
/* Written by Bjørn Johansen (post@bjornjohansen.no). */
|
||||
jQuery(function($){
|
||||
$.datepicker.regional['nn'] = {
|
||||
closeText: 'Lukk',
|
||||
prevText: '«Førre',
|
||||
nextText: 'Neste»',
|
||||
currentText: 'I dag',
|
||||
monthNames: ['januar','februar','mars','april','mai','juni','juli','august','september','oktober','november','desember'],
|
||||
monthNamesShort: ['jan','feb','mar','apr','mai','jun','jul','aug','sep','okt','nov','des'],
|
||||
dayNamesShort: ['sun','mån','tys','ons','tor','fre','lau'],
|
||||
dayNames: ['sundag','måndag','tysdag','onsdag','torsdag','fredag','laurdag'],
|
||||
dayNamesMin: ['su','må','ty','on','to','fr','la'],
|
||||
weekHeader: 'Veke',
|
||||
dateFormat: 'dd.mm.yy',
|
||||
firstDay: 1,
|
||||
isRTL: false,
|
||||
showMonthAfterYear: false,
|
||||
yearSuffix: ''
|
||||
};
|
||||
$.datepicker.setDefaults($.datepicker.regional['nn']);
|
||||
});
|
1
ui/jquery.ui.accordion.js
vendored
1
ui/jquery.ui.accordion.js
vendored
@ -166,6 +166,7 @@ $.widget( "ui.accordion", {
|
||||
},
|
||||
|
||||
_keydown: function( event ) {
|
||||
/*jshint maxcomplexity:15*/
|
||||
if ( event.altKey || event.ctrlKey ) {
|
||||
return;
|
||||
}
|
||||
|
3
ui/jquery.ui.autocomplete.js
vendored
3
ui/jquery.ui.autocomplete.js
vendored
@ -66,6 +66,7 @@ $.widget( "ui.autocomplete", {
|
||||
|
||||
this._on( this.element, {
|
||||
keydown: function( event ) {
|
||||
/*jshint maxcomplexity:15*/
|
||||
if ( this.element.prop( "readOnly" ) ) {
|
||||
suppressKeyPress = true;
|
||||
suppressInput = true;
|
||||
@ -313,7 +314,7 @@ $.widget( "ui.autocomplete", {
|
||||
this._initSource();
|
||||
}
|
||||
if ( key === "appendTo" ) {
|
||||
this.menu.element.appendTo( this.document.find( value || "body" )[0] );
|
||||
this.menu.element.appendTo( this._appendTo() );
|
||||
}
|
||||
if ( key === "disabled" && value && this.xhr ) {
|
||||
this.xhr.abort();
|
||||
|
12
ui/jquery.ui.core.js
vendored
12
ui/jquery.ui.core.js
vendored
@ -289,8 +289,6 @@ $.extend( $.ui, {
|
||||
}
|
||||
},
|
||||
|
||||
contains: $.contains,
|
||||
|
||||
// only used by resizable
|
||||
hasScroll: function( el, a ) {
|
||||
|
||||
@ -313,16 +311,6 @@ $.extend( $.ui, {
|
||||
has = ( el[ scroll ] > 0 );
|
||||
el[ scroll ] = 0;
|
||||
return has;
|
||||
},
|
||||
|
||||
// these are odd functions, fix the API or move into individual plugins
|
||||
isOverAxis: function( x, reference, size ) {
|
||||
//Determines when x coordinate is over "b" element axis
|
||||
return ( x > reference ) && ( x < ( reference + size ) );
|
||||
},
|
||||
isOver: function( y, x, top, left, height, width ) {
|
||||
//Determines when x, y coordinates is over "b" element
|
||||
return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
|
||||
}
|
||||
});
|
||||
|
||||
|
7
ui/jquery.ui.datepicker.js
vendored
7
ui/jquery.ui.datepicker.js
vendored
@ -497,6 +497,13 @@ $.extend(Datepicker.prototype, {
|
||||
if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
|
||||
inst.settings.maxDate = this._formatDate(inst, maxDate);
|
||||
}
|
||||
if ( "disabled" in settings ) {
|
||||
if ( settings.disabled ) {
|
||||
this._disableDatepicker(target);
|
||||
} else {
|
||||
this._enableDatepicker(target);
|
||||
}
|
||||
}
|
||||
this._attachments($(target), inst);
|
||||
this._autoSize(inst);
|
||||
this._setDate(inst, date);
|
||||
|
198
ui/jquery.ui.dialog.js
vendored
198
ui/jquery.ui.dialog.js
vendored
@ -19,8 +19,7 @@
|
||||
*/
|
||||
(function( $, undefined ) {
|
||||
|
||||
var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ",
|
||||
sizeRelatedOptions = {
|
||||
var sizeRelatedOptions = {
|
||||
buttons: true,
|
||||
height: true,
|
||||
maxHeight: true,
|
||||
@ -39,16 +38,17 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ui-fr
|
||||
$.widget( "ui.dialog", {
|
||||
version: "@VERSION",
|
||||
options: {
|
||||
appendTo: "body",
|
||||
autoOpen: true,
|
||||
buttons: {},
|
||||
buttons: [],
|
||||
closeOnEscape: true,
|
||||
closeText: "close",
|
||||
dialogClass: "",
|
||||
draggable: true,
|
||||
hide: null,
|
||||
height: "auto",
|
||||
maxHeight: false,
|
||||
maxWidth: false,
|
||||
maxHeight: null,
|
||||
maxWidth: null,
|
||||
minHeight: 150,
|
||||
minWidth: 150,
|
||||
modal: false,
|
||||
@ -57,7 +57,7 @@ $.widget("ui.dialog", {
|
||||
at: "center",
|
||||
of: window,
|
||||
collision: "fit",
|
||||
// ensure that the titlebar is never outside the document
|
||||
// Ensure the titlebar is always visible
|
||||
using: function( pos ) {
|
||||
var topOffset = $( this ).css( pos ).offset().top;
|
||||
if ( topOffset < 0 ) {
|
||||
@ -84,12 +84,19 @@ $.widget("ui.dialog", {
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
this.originalTitle = this.element.attr( "title" );
|
||||
this.options.title = this.options.title || this.originalTitle;
|
||||
this.oldPosition = {
|
||||
this.originalCss = {
|
||||
display: this.element[0].style.display,
|
||||
width: this.element[0].style.width,
|
||||
minHeight: this.element[0].style.minHeight,
|
||||
maxHeight: this.element[0].style.maxHeight,
|
||||
height: this.element[0].style.height
|
||||
};
|
||||
this.originalPosition = {
|
||||
parent: this.element.parent(),
|
||||
index: this.element.parent().children().index( this.element )
|
||||
};
|
||||
this.originalTitle = this.element.attr("title");
|
||||
this.options.title = this.options.title || this.originalTitle;
|
||||
|
||||
this._createWrapper();
|
||||
|
||||
@ -118,31 +125,39 @@ $.widget("ui.dialog", {
|
||||
}
|
||||
},
|
||||
|
||||
_appendTo: function() {
|
||||
var element = this.options.appendTo;
|
||||
if ( element && (element.jquery || element.nodeType) ) {
|
||||
return $( element );
|
||||
}
|
||||
return this.document.find( element || "body" ).eq( 0 );
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
var next,
|
||||
oldPosition = this.oldPosition;
|
||||
originalPosition = this.originalPosition;
|
||||
|
||||
this._destroyOverlay();
|
||||
|
||||
this.element
|
||||
.removeUniqueId()
|
||||
.removeClass("ui-dialog-content ui-widget-content")
|
||||
.hide()
|
||||
// without detaching first, the following becomes really slow
|
||||
.css( this.originalCss )
|
||||
// Without detaching first, the following becomes really slow
|
||||
.detach();
|
||||
|
||||
this.uiDialog.remove();
|
||||
this.uiDialog.stop( true, true ).remove();
|
||||
|
||||
if ( this.originalTitle ) {
|
||||
this.element.attr( "title", this.originalTitle );
|
||||
}
|
||||
|
||||
next = oldPosition.parent.children().eq( oldPosition.index );
|
||||
next = originalPosition.parent.children().eq( originalPosition.index );
|
||||
// Don't try to place the dialog next to itself (#8613)
|
||||
if ( next.length && next[0] !== this.element[0] ) {
|
||||
next.before( this.element );
|
||||
} else {
|
||||
oldPosition.parent.append( this.element );
|
||||
originalPosition.parent.append( this.element );
|
||||
}
|
||||
},
|
||||
|
||||
@ -156,16 +171,11 @@ $.widget("ui.dialog", {
|
||||
close: function( event ) {
|
||||
var that = this;
|
||||
|
||||
if ( !this._isOpen ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this._trigger( "beforeClose", event ) === false ) {
|
||||
if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isOpen = false;
|
||||
|
||||
this._destroyOverlay();
|
||||
|
||||
if ( !this.opener.filter(":focusable").focus().length ) {
|
||||
@ -190,7 +200,7 @@ $.widget("ui.dialog", {
|
||||
|
||||
_moveToTop: function( event, silent ) {
|
||||
var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
|
||||
if ( !silent && moved ) {
|
||||
if ( moved && !silent ) {
|
||||
this._trigger( "focus", event );
|
||||
}
|
||||
return moved;
|
||||
@ -217,30 +227,28 @@ $.widget("ui.dialog", {
|
||||
this._isOpen = true;
|
||||
this._trigger("open");
|
||||
this._trigger("focus");
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_focusTabbable: function() {
|
||||
// set focus to the first match:
|
||||
// 1. first element inside the dialog matching [autofocus]
|
||||
// 2. tabbable element inside the content element
|
||||
// 3. tabbable element inside the buttonpane
|
||||
// 4. the close button
|
||||
// 5. the dialog itself
|
||||
// Set focus to the first match:
|
||||
// 1. First element inside the dialog matching [autofocus]
|
||||
// 2. Tabbable element inside the content element
|
||||
// 3. Tabbable element inside the buttonpane
|
||||
// 4. The close button
|
||||
// 5. The dialog itself
|
||||
var hasFocus = this.element.find("[autofocus]");
|
||||
if ( !hasFocus.length ) {
|
||||
hasFocus = this.element.find(":tabbable");
|
||||
}
|
||||
if ( !hasFocus.length ) {
|
||||
hasFocus = this.uiDialogButtonPane.find(":tabbable");
|
||||
}
|
||||
if ( !hasFocus.length ) {
|
||||
hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
|
||||
}
|
||||
if ( !hasFocus.length ) {
|
||||
hasFocus = this.uiDialog;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hasFocus.eq( 0 ).focus();
|
||||
},
|
||||
|
||||
@ -263,14 +271,15 @@ $.widget("ui.dialog", {
|
||||
|
||||
_createWrapper: function() {
|
||||
this.uiDialog = $("<div>")
|
||||
.addClass( uiDialogClasses + this.options.dialogClass )
|
||||
.addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
|
||||
this.options.dialogClass )
|
||||
.hide()
|
||||
.attr({
|
||||
// setting tabIndex makes the div focusable
|
||||
// Setting tabIndex makes the div focusable
|
||||
tabIndex: -1,
|
||||
role: "dialog"
|
||||
})
|
||||
.appendTo( this.document[ 0 ].body );
|
||||
.appendTo( this._appendTo() );
|
||||
|
||||
this._on( this.uiDialog, {
|
||||
keydown: function( event ) {
|
||||
@ -291,10 +300,10 @@ $.widget("ui.dialog", {
|
||||
|
||||
if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
|
||||
first.focus( 1 );
|
||||
return false;
|
||||
event.preventDefault();
|
||||
} else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
|
||||
last.focus( 1 );
|
||||
return false;
|
||||
event.preventDefault();
|
||||
}
|
||||
},
|
||||
mousedown: function( event ) {
|
||||
@ -343,7 +352,7 @@ $.widget("ui.dialog", {
|
||||
.addClass("ui-dialog-titlebar-close")
|
||||
.appendTo( this.uiDialogTitlebar );
|
||||
this._on( this.uiDialogTitlebarClose, {
|
||||
"click": function( event ) {
|
||||
click: function( event ) {
|
||||
event.preventDefault();
|
||||
this.close( event );
|
||||
}
|
||||
@ -368,12 +377,12 @@ $.widget("ui.dialog", {
|
||||
},
|
||||
|
||||
_createButtonPane: function() {
|
||||
var uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
|
||||
this.uiDialogButtonPane = $("<div>")
|
||||
.addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
|
||||
|
||||
this.uiButtonSet = $("<div>")
|
||||
.addClass("ui-dialog-buttonset")
|
||||
.appendTo( uiDialogButtonPane );
|
||||
.appendTo( this.uiDialogButtonPane );
|
||||
|
||||
this._createButtons();
|
||||
},
|
||||
@ -386,7 +395,11 @@ $.widget("ui.dialog", {
|
||||
this.uiDialogButtonPane.remove();
|
||||
this.uiButtonSet.empty();
|
||||
|
||||
if ( !$.isEmptyObject( buttons ) ) {
|
||||
if ( $.isEmptyObject( buttons ) ) {
|
||||
this.uiDialog.removeClass("ui-dialog-buttons");
|
||||
return;
|
||||
}
|
||||
|
||||
$.each( buttons, function( name, props ) {
|
||||
var click, buttonOptions;
|
||||
props = $.isFunction( props ) ?
|
||||
@ -411,9 +424,6 @@ $.widget("ui.dialog", {
|
||||
});
|
||||
this.uiDialog.addClass("ui-dialog-buttons");
|
||||
this.uiDialogButtonPane.appendTo( this.uiDialog );
|
||||
} else {
|
||||
this.uiDialog.removeClass( "ui-dialog-buttons" );
|
||||
}
|
||||
},
|
||||
|
||||
_makeDraggable: function() {
|
||||
@ -432,8 +442,7 @@ $.widget("ui.dialog", {
|
||||
handle: ".ui-dialog-titlebar",
|
||||
containment: "document",
|
||||
start: function( event, ui ) {
|
||||
$( this )
|
||||
.addClass( "ui-dialog-dragging" );
|
||||
$( this ).addClass("ui-dialog-dragging");
|
||||
that._trigger( "dragStart", event, filteredUi( ui ) );
|
||||
},
|
||||
drag: function( event, ui ) {
|
||||
@ -444,8 +453,7 @@ $.widget("ui.dialog", {
|
||||
ui.position.left - that.document.scrollLeft(),
|
||||
ui.position.top - that.document.scrollTop()
|
||||
];
|
||||
$( this )
|
||||
.removeClass( "ui-dialog-dragging" );
|
||||
$( this ).removeClass("ui-dialog-dragging");
|
||||
that._trigger( "dragStop", event, filteredUi( ui ) );
|
||||
}
|
||||
});
|
||||
@ -488,29 +496,25 @@ $.widget("ui.dialog", {
|
||||
that._trigger( "resize", event, filteredUi( ui ) );
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
$( this ).removeClass( "ui-dialog-resizing" );
|
||||
options.height = $( this ).height();
|
||||
options.width = $( this ).width();
|
||||
$( this ).removeClass("ui-dialog-resizing");
|
||||
that._trigger( "resizeStop", event, filteredUi( ui ) );
|
||||
}
|
||||
})
|
||||
.css( "position", position )
|
||||
.find( ".ui-resizable-se" )
|
||||
.addClass( "ui-icon ui-icon-grip-diagonal-se" );
|
||||
.css( "position", position );
|
||||
},
|
||||
|
||||
_minHeight: function() {
|
||||
var options = this.options;
|
||||
|
||||
if ( options.height === "auto" ) {
|
||||
return options.minHeight;
|
||||
} else {
|
||||
return Math.min( options.minHeight, options.height );
|
||||
}
|
||||
return options.height === "auto" ?
|
||||
options.minHeight :
|
||||
Math.min( options.minHeight, options.height );
|
||||
},
|
||||
|
||||
_position: function() {
|
||||
// need to show the dialog to get the actual offset in the position plugin
|
||||
// Need to show the dialog to get the actual offset in the position plugin
|
||||
var isVisible = this.uiDialog.is(":visible");
|
||||
if ( !isVisible ) {
|
||||
this.uiDialog.show();
|
||||
@ -523,8 +527,8 @@ $.widget("ui.dialog", {
|
||||
|
||||
_setOptions: function( options ) {
|
||||
var that = this,
|
||||
resizableOptions = {},
|
||||
resize = false;
|
||||
resize = false,
|
||||
resizableOptions = {};
|
||||
|
||||
$.each( options, function( key, value ) {
|
||||
that._setOption( key, value );
|
||||
@ -547,6 +551,7 @@ $.widget("ui.dialog", {
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
/*jshint maxcomplexity:15*/
|
||||
var isDraggable, isResizable,
|
||||
uiDialog = this.uiDialog;
|
||||
|
||||
@ -562,13 +567,17 @@ $.widget("ui.dialog", {
|
||||
|
||||
this._super( key, value );
|
||||
|
||||
if ( key === "appendTo" ) {
|
||||
this.uiDialog.appendTo( this._appendTo() );
|
||||
}
|
||||
|
||||
if ( key === "buttons" ) {
|
||||
this._createButtons();
|
||||
}
|
||||
|
||||
if ( key === "closeText" ) {
|
||||
this.uiDialogTitlebarClose.button({
|
||||
// ensure that we always pass a string
|
||||
// Ensure that we always pass a string
|
||||
label: "" + value
|
||||
});
|
||||
}
|
||||
@ -612,16 +621,16 @@ $.widget("ui.dialog", {
|
||||
},
|
||||
|
||||
_size: function() {
|
||||
|
||||
// If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
|
||||
// divs will both have width and height set, so we need to reset them
|
||||
var nonContentHeight, minContentHeight,
|
||||
var nonContentHeight, minContentHeight, maxContentHeight,
|
||||
options = this.options;
|
||||
|
||||
// reset content sizing
|
||||
// Reset content sizing
|
||||
this.element.show().css({
|
||||
width: "auto",
|
||||
minHeight: 0,
|
||||
maxHeight: "none",
|
||||
height: 0
|
||||
});
|
||||
|
||||
@ -637,14 +646,18 @@ $.widget("ui.dialog", {
|
||||
})
|
||||
.outerHeight();
|
||||
minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
|
||||
maxContentHeight = typeof options.maxHeight === "number" ?
|
||||
Math.max( 0, options.maxHeight - nonContentHeight ) :
|
||||
"none";
|
||||
|
||||
if ( options.height === "auto" ) {
|
||||
this.element.css({
|
||||
minHeight: minContentHeight,
|
||||
maxHeight: maxContentHeight,
|
||||
height: "auto"
|
||||
});
|
||||
} else {
|
||||
this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
|
||||
this.element.height( Math.max( 0, options.height - nonContentHeight ) );
|
||||
}
|
||||
|
||||
if (this.uiDialog.is(":data(ui-resizable)") ) {
|
||||
@ -656,57 +669,50 @@ $.widget("ui.dialog", {
|
||||
if ( !this.options.modal ) {
|
||||
return;
|
||||
}
|
||||
if ( $.ui.dialog.overlay.instances.length === 0 ) {
|
||||
// prevent use of anchors and inputs
|
||||
// we use a setTimeout in case the overlay is created from an
|
||||
// event that we're going to be cancelling (see #2804)
|
||||
setTimeout(function() {
|
||||
// handle $(el).dialog().dialog('close') (see #4065)
|
||||
if ( $.ui.dialog.overlay.instances.length ) {
|
||||
$( document ).bind( "focusin.dialog-overlay", function( event ) {
|
||||
|
||||
if ( !$.ui.dialog.overlayInstances ) {
|
||||
// Prevent use of anchors and inputs.
|
||||
// We use a delay in case the overlay is created from an
|
||||
// event that we're going to be cancelling. (#2804)
|
||||
this._delay(function() {
|
||||
// Handle .dialog().dialog("close") (#4065)
|
||||
if ( $.ui.dialog.overlayInstances ) {
|
||||
this._on( this.document, {
|
||||
focusin: function( event ) {
|
||||
if ( !$( event.target ).closest(".ui-dialog").length ) {
|
||||
event.preventDefault();
|
||||
$( ".ui-dialog:visible:last .ui-dialog-content" ).data( "ui-dialog" )._focusTabbable();
|
||||
$(".ui-dialog:visible:last .ui-dialog-content")
|
||||
.data("ui-dialog")._focusTabbable();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 1 );
|
||||
});
|
||||
}
|
||||
|
||||
// reuse old instances due to IE memory leak with alpha transparency (see #5185)
|
||||
var $el = this.overlay = ( $.ui.dialog.overlay.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay ui-front" ) );
|
||||
|
||||
$el.appendTo( document.body );
|
||||
|
||||
this._on( $el, {
|
||||
this.overlay = $("<div>")
|
||||
.addClass("ui-widget-overlay ui-front")
|
||||
.appendTo( this.document[0].body );
|
||||
this._on( this.overlay, {
|
||||
mousedown: "_keepFocus"
|
||||
});
|
||||
|
||||
$.ui.dialog.overlay.instances.push( $el );
|
||||
$.ui.dialog.overlayInstances++;
|
||||
},
|
||||
|
||||
_destroyOverlay: function() {
|
||||
if ( !this.options.modal ) {
|
||||
return;
|
||||
}
|
||||
var indexOf = $.inArray( this.overlay, $.ui.dialog.overlay.instances );
|
||||
|
||||
if ( indexOf !== -1 ) {
|
||||
$.ui.dialog.overlay.oldInstances.push( $.ui.dialog.overlay.instances.splice( indexOf, 1 )[ 0 ] );
|
||||
$.ui.dialog.overlayInstances--;
|
||||
if ( !$.ui.dialog.overlayInstances ) {
|
||||
this._off( this.document, "focusin" );
|
||||
}
|
||||
|
||||
if ( $.ui.dialog.overlay.instances.length === 0 ) {
|
||||
$( [ document, window ] ).unbind( ".dialog-overlay" );
|
||||
}
|
||||
|
||||
this.overlay.remove();
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.dialog.overlay = {
|
||||
instances: [],
|
||||
oldInstances: []
|
||||
};
|
||||
$.ui.dialog.overlayInstances = 0;
|
||||
|
||||
// DEPRECATED
|
||||
if ( $.uiBackCompat !== false ) {
|
||||
|
6
ui/jquery.ui.droppable.js
vendored
6
ui/jquery.ui.droppable.js
vendored
@ -16,6 +16,10 @@
|
||||
*/
|
||||
(function( $, undefined ) {
|
||||
|
||||
function isOverAxis( x, reference, size ) {
|
||||
return ( x > reference ) && ( x < ( reference + size ) );
|
||||
}
|
||||
|
||||
$.widget("ui.droppable", {
|
||||
version: "@VERSION",
|
||||
widgetEventPrefix: "drop",
|
||||
@ -203,7 +207,7 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) {
|
||||
case 'pointer':
|
||||
draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
|
||||
draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
|
||||
return $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
|
||||
return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
|
||||
case 'touch':
|
||||
return (
|
||||
(y1 >= t && y1 <= b) || // Top edge touching
|
||||
|
1
ui/jquery.ui.menu.js
vendored
1
ui/jquery.ui.menu.js
vendored
@ -173,6 +173,7 @@ $.widget( "ui.menu", {
|
||||
},
|
||||
|
||||
_keydown: function( event ) {
|
||||
/*jshint maxcomplexity:20*/
|
||||
var match, prev, character, skip, regex,
|
||||
preventDefault = true;
|
||||
|
||||
|
54
ui/jquery.ui.position.js
vendored
54
ui/jquery.ui.position.js
vendored
@ -29,10 +29,41 @@ function getOffsets( offsets, width, height ) {
|
||||
parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
|
||||
];
|
||||
}
|
||||
|
||||
function parseCss( element, property ) {
|
||||
return parseInt( $.css( element, property ), 10 ) || 0;
|
||||
}
|
||||
|
||||
function getDimensions( elem ) {
|
||||
var raw = elem[0];
|
||||
if ( raw.nodeType === 9 ) {
|
||||
return {
|
||||
width: elem.width(),
|
||||
height: elem.height(),
|
||||
offset: { top: 0, left: 0 }
|
||||
};
|
||||
}
|
||||
if ( $.isWindow( raw ) ) {
|
||||
return {
|
||||
width: elem.width(),
|
||||
height: elem.height(),
|
||||
offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
|
||||
};
|
||||
}
|
||||
if ( raw.preventDefault ) {
|
||||
return {
|
||||
width: 0,
|
||||
height: 0,
|
||||
offset: { top: raw.pageY, left: raw.pageX }
|
||||
};
|
||||
}
|
||||
return {
|
||||
width: elem.outerWidth(),
|
||||
height: elem.outerHeight(),
|
||||
offset: elem.offset()
|
||||
};
|
||||
}
|
||||
|
||||
$.position = {
|
||||
scrollbarWidth: function() {
|
||||
if ( cachedScrollbarWidth !== undefined ) {
|
||||
@ -91,32 +122,21 @@ $.fn.position = function( options ) {
|
||||
// make a copy, we don't want to modify arguments
|
||||
options = $.extend( {}, options );
|
||||
|
||||
var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
|
||||
var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
|
||||
target = $( options.of ),
|
||||
within = $.position.getWithinInfo( options.within ),
|
||||
scrollInfo = $.position.getScrollInfo( within ),
|
||||
targetElem = target[0],
|
||||
collision = ( options.collision || "flip" ).split( " " ),
|
||||
offsets = {};
|
||||
|
||||
if ( targetElem.nodeType === 9 ) {
|
||||
targetWidth = target.width();
|
||||
targetHeight = target.height();
|
||||
targetOffset = { top: 0, left: 0 };
|
||||
} else if ( $.isWindow( targetElem ) ) {
|
||||
targetWidth = target.width();
|
||||
targetHeight = target.height();
|
||||
targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
|
||||
} else if ( targetElem.preventDefault ) {
|
||||
dimensions = getDimensions( target );
|
||||
if ( target[0].preventDefault ) {
|
||||
// force left top to allow flipping
|
||||
options.at = "left top";
|
||||
targetWidth = targetHeight = 0;
|
||||
targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
|
||||
} else {
|
||||
targetWidth = target.outerWidth();
|
||||
targetHeight = target.outerHeight();
|
||||
targetOffset = target.offset();
|
||||
}
|
||||
targetWidth = dimensions.width;
|
||||
targetHeight = dimensions.height;
|
||||
targetOffset = dimensions.offset;
|
||||
// clone to reuse original targetOffset later
|
||||
basePosition = $.extend( {}, targetOffset );
|
||||
|
||||
|
95
ui/jquery.ui.progressbar.js
vendored
95
ui/jquery.ui.progressbar.js
vendored
@ -17,29 +17,31 @@
|
||||
$.widget( "ui.progressbar", {
|
||||
version: "@VERSION",
|
||||
options: {
|
||||
max: 100,
|
||||
value: 0,
|
||||
max: 100
|
||||
|
||||
change: null,
|
||||
complete: null
|
||||
},
|
||||
|
||||
min: 0,
|
||||
|
||||
_create: function() {
|
||||
// Constrain initial value
|
||||
this.options.value = this._constrainedValue();
|
||||
this.oldValue = this.options.value = this._constrainedValue();
|
||||
|
||||
this.element
|
||||
.addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
|
||||
.attr({
|
||||
// Only set static values, aria-valuenow and aria-valuemax are
|
||||
// set inside _refreshValue()
|
||||
role: "progressbar",
|
||||
"aria-valuemin": this.min,
|
||||
"aria-valuemax": this.options.max,
|
||||
"aria-valuenow": this.options.value
|
||||
"aria-valuemin": this.min
|
||||
});
|
||||
|
||||
this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'><div></div></div>" )
|
||||
this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
|
||||
.appendTo( this.element );
|
||||
|
||||
this.oldValue = this.options.value;
|
||||
this._refreshValue();
|
||||
},
|
||||
|
||||
@ -59,66 +61,75 @@ $.widget( "ui.progressbar", {
|
||||
return this.options.value;
|
||||
}
|
||||
|
||||
this._setOption( "value", this._constrainedValue( newValue ) );
|
||||
return this;
|
||||
this.options.value = this._constrainedValue( newValue );
|
||||
this._refreshValue();
|
||||
},
|
||||
|
||||
_constrainedValue: function( newValue ) {
|
||||
var val;
|
||||
if ( newValue === undefined ) {
|
||||
val = this.options.value;
|
||||
} else {
|
||||
val = newValue;
|
||||
newValue = this.options.value;
|
||||
}
|
||||
|
||||
this.indeterminate = val === false;
|
||||
this.indeterminate = newValue === false;
|
||||
|
||||
// sanitize value
|
||||
if ( typeof val !== "number" ) {
|
||||
val = 0;
|
||||
if ( typeof newValue !== "number" ) {
|
||||
newValue = 0;
|
||||
}
|
||||
return this.indeterminate ? false : Math.min( this.options.max, Math.max( this.min, val ) );
|
||||
|
||||
return this.indeterminate ? false :
|
||||
Math.min( this.options.max, Math.max( this.min, newValue ) );
|
||||
},
|
||||
|
||||
_setOptions: function( options ) {
|
||||
var val = options.value;
|
||||
|
||||
// Ensure "value" option is set after other values (like max)
|
||||
var value = options.value;
|
||||
delete options.value;
|
||||
|
||||
this._super( options );
|
||||
|
||||
if ( val !== undefined ) {
|
||||
this._setOption( "value", val );
|
||||
}
|
||||
this.options.value = this._constrainedValue( value );
|
||||
this._refreshValue();
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
if ( key === "max" ) {
|
||||
// Don't allow a max less than min
|
||||
this.options.max = Math.max( this.min, value );
|
||||
this.options.value = this._constrainedValue();
|
||||
}
|
||||
if ( key === "value" ) {
|
||||
this.options.value = this._constrainedValue( value );
|
||||
}
|
||||
else {
|
||||
this._super( key, value );
|
||||
value = Math.max( this.min, value );
|
||||
}
|
||||
|
||||
this._refreshValue();
|
||||
this._super( key, value );
|
||||
},
|
||||
|
||||
_percentage: function() {
|
||||
return this.indeterminate ? 100 : 100 * this.options.value / this.options.max;
|
||||
return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
|
||||
},
|
||||
|
||||
_refreshValue: function() {
|
||||
var value = this.options.value,
|
||||
percentage = this._percentage(),
|
||||
overlay = this.valueDiv.children().eq( 0 );
|
||||
percentage = this._percentage();
|
||||
|
||||
overlay.toggleClass( "ui-progressbar-overlay", this.indeterminate );
|
||||
this.valueDiv.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
|
||||
this.valueDiv
|
||||
.toggle( this.indeterminate || value > this.min )
|
||||
.toggleClass( "ui-corner-right", value === this.options.max )
|
||||
.toggleClass( "ui-progressbar-indeterminate", this.indeterminate )
|
||||
.width( percentage.toFixed(0) + "%" );
|
||||
|
||||
if ( this.indeterminate ) {
|
||||
this.element.removeAttr( "aria-valuenow" );
|
||||
if ( !this.overlayDiv ) {
|
||||
this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
|
||||
}
|
||||
} else {
|
||||
this.element.attr({
|
||||
"aria-valuemax": this.options.max,
|
||||
"aria-valuenow": value
|
||||
});
|
||||
if ( this.overlayDiv ) {
|
||||
this.overlayDiv.remove();
|
||||
this.overlayDiv = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.oldValue !== value ) {
|
||||
this.oldValue = value;
|
||||
@ -127,18 +138,6 @@ $.widget( "ui.progressbar", {
|
||||
if ( value === this.options.max ) {
|
||||
this._trigger( "complete" );
|
||||
}
|
||||
|
||||
this.valueDiv
|
||||
.toggle( this.indeterminate || value > this.min )
|
||||
.toggleClass( "ui-corner-right", value === this.options.max )
|
||||
.width( percentage.toFixed(0) + "%" );
|
||||
if ( this.indeterminate ) {
|
||||
this.element.removeAttr( "aria-valuemax" );
|
||||
this.element.removeAttr( "aria-valuenow" );
|
||||
} else {
|
||||
this.element.attr( "aria-valuemax", this.options.max );
|
||||
this.element.attr( "aria-valuenow", value );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
122
ui/jquery.ui.resizable.js
vendored
122
ui/jquery.ui.resizable.js
vendored
@ -643,67 +643,6 @@ $.widget("ui.resizable", $.ui.mouse, {
|
||||
* Resizable Extensions
|
||||
*/
|
||||
|
||||
$.ui.plugin.add("resizable", "alsoResize", {
|
||||
|
||||
start: function () {
|
||||
var that = $(this).data("ui-resizable"),
|
||||
o = that.options,
|
||||
_store = function (exp) {
|
||||
$(exp).each(function() {
|
||||
var el = $(this);
|
||||
el.data("ui-resizable-alsoresize", {
|
||||
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
|
||||
left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof(o.alsoResize) === 'object' && !o.alsoResize.parentNode) {
|
||||
if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
|
||||
else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
|
||||
}else{
|
||||
_store(o.alsoResize);
|
||||
}
|
||||
},
|
||||
|
||||
resize: function (event, ui) {
|
||||
var that = $(this).data("ui-resizable"),
|
||||
o = that.options,
|
||||
os = that.originalSize,
|
||||
op = that.originalPosition,
|
||||
delta = {
|
||||
height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
|
||||
top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
|
||||
},
|
||||
|
||||
_alsoResize = function (exp, c) {
|
||||
$(exp).each(function() {
|
||||
var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
|
||||
css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
|
||||
|
||||
$.each(css, function (i, prop) {
|
||||
var sum = (start[prop]||0) + (delta[prop]||0);
|
||||
if (sum && sum >= 0) {
|
||||
style[prop] = sum || null;
|
||||
}
|
||||
});
|
||||
|
||||
el.css(style);
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof(o.alsoResize) === 'object' && !o.alsoResize.nodeType) {
|
||||
$.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
|
||||
}else{
|
||||
_alsoResize(o.alsoResize);
|
||||
}
|
||||
},
|
||||
|
||||
stop: function () {
|
||||
$(this).removeData("resizable-alsoresize");
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("resizable", "animate", {
|
||||
|
||||
stop: function( event ) {
|
||||
@ -871,6 +810,67 @@ $.ui.plugin.add("resizable", "containment", {
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("resizable", "alsoResize", {
|
||||
|
||||
start: function () {
|
||||
var that = $(this).data("ui-resizable"),
|
||||
o = that.options,
|
||||
_store = function (exp) {
|
||||
$(exp).each(function() {
|
||||
var el = $(this);
|
||||
el.data("ui-resizable-alsoresize", {
|
||||
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
|
||||
left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof(o.alsoResize) === 'object' && !o.alsoResize.parentNode) {
|
||||
if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
|
||||
else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
|
||||
}else{
|
||||
_store(o.alsoResize);
|
||||
}
|
||||
},
|
||||
|
||||
resize: function (event, ui) {
|
||||
var that = $(this).data("ui-resizable"),
|
||||
o = that.options,
|
||||
os = that.originalSize,
|
||||
op = that.originalPosition,
|
||||
delta = {
|
||||
height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
|
||||
top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
|
||||
},
|
||||
|
||||
_alsoResize = function (exp, c) {
|
||||
$(exp).each(function() {
|
||||
var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
|
||||
css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
|
||||
|
||||
$.each(css, function (i, prop) {
|
||||
var sum = (start[prop]||0) + (delta[prop]||0);
|
||||
if (sum && sum >= 0) {
|
||||
style[prop] = sum || null;
|
||||
}
|
||||
});
|
||||
|
||||
el.css(style);
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof(o.alsoResize) === 'object' && !o.alsoResize.nodeType) {
|
||||
$.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
|
||||
}else{
|
||||
_alsoResize(o.alsoResize);
|
||||
}
|
||||
},
|
||||
|
||||
stop: function () {
|
||||
$(this).removeData("resizable-alsoresize");
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.plugin.add("resizable", "ghost", {
|
||||
|
||||
start: function() {
|
||||
|
1
ui/jquery.ui.slider.js
vendored
1
ui/jquery.ui.slider.js
vendored
@ -119,6 +119,7 @@ $.widget( "ui.slider", $.ui.mouse, {
|
||||
|
||||
this._on( this.handles, {
|
||||
keydown: function( event ) {
|
||||
/*jshint maxcomplexity:25*/
|
||||
var allowed, curVal, newVal, step,
|
||||
index = $( event.target ).data( "ui-slider-handle-index" );
|
||||
|
||||
|
12
ui/jquery.ui.sortable.js
vendored
12
ui/jquery.ui.sortable.js
vendored
@ -17,6 +17,10 @@
|
||||
|
||||
/*jshint loopfunc: true */
|
||||
|
||||
function isOverAxis( x, reference, size ) {
|
||||
return ( x > reference ) && ( x < ( reference + size ) );
|
||||
}
|
||||
|
||||
$.widget("ui.sortable", $.ui.mouse, {
|
||||
version: "@VERSION",
|
||||
widgetEventPrefix: "sort",
|
||||
@ -536,8 +540,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
_intersectsWithPointer: function(item) {
|
||||
|
||||
var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
|
||||
isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
|
||||
var isOverElementHeight = (this.options.axis === 'x') || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
|
||||
isOverElementWidth = (this.options.axis === 'y') || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
|
||||
isOverElement = isOverElementHeight && isOverElementWidth,
|
||||
verticalDirection = this._getDragVerticalDirection(),
|
||||
horizontalDirection = this._getDragHorizontalDirection();
|
||||
@ -554,8 +558,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
_intersectsWithSides: function(item) {
|
||||
|
||||
var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
|
||||
isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
|
||||
var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
|
||||
isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
|
||||
verticalDirection = this._getDragVerticalDirection(),
|
||||
horizontalDirection = this._getDragHorizontalDirection();
|
||||
|
||||
|
73
ui/jquery.ui.tabs.js
vendored
73
ui/jquery.ui.tabs.js
vendored
@ -23,12 +23,8 @@ function getNextTabId() {
|
||||
|
||||
function isLocal( anchor ) {
|
||||
return anchor.hash.length > 1 &&
|
||||
anchor.href.replace( rhash, "" ) ===
|
||||
location.href.replace( rhash, "" )
|
||||
// support: Safari 5.1
|
||||
// Safari 5.1 doesn't encode spaces in window.location
|
||||
// but it does encode spaces from anchors (#8777)
|
||||
.replace( /\s/g, "%20" );
|
||||
decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
|
||||
decodeURIComponent( location.href.replace( rhash, "" ) );
|
||||
}
|
||||
|
||||
$.widget( "ui.tabs", {
|
||||
@ -51,9 +47,7 @@ $.widget( "ui.tabs", {
|
||||
|
||||
_create: function() {
|
||||
var that = this,
|
||||
options = this.options,
|
||||
active = options.active,
|
||||
locationHash = location.hash.substring( 1 );
|
||||
options = this.options;
|
||||
|
||||
this.running = false;
|
||||
|
||||
@ -79,6 +73,36 @@ $.widget( "ui.tabs", {
|
||||
});
|
||||
|
||||
this._processTabs();
|
||||
options.active = this._initialActive();
|
||||
|
||||
// Take disabling tabs via class attribute from HTML
|
||||
// into account and update option properly.
|
||||
if ( $.isArray( options.disabled ) ) {
|
||||
options.disabled = $.unique( options.disabled.concat(
|
||||
$.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
|
||||
return that.tabs.index( li );
|
||||
})
|
||||
) ).sort();
|
||||
}
|
||||
|
||||
// check for length avoids error when initializing empty list
|
||||
if ( this.options.active !== false && this.anchors.length ) {
|
||||
this.active = this._findActive( options.active );
|
||||
} else {
|
||||
this.active = $();
|
||||
}
|
||||
|
||||
this._refresh();
|
||||
|
||||
if ( this.active.length ) {
|
||||
this.load( options.active );
|
||||
}
|
||||
},
|
||||
|
||||
_initialActive: function() {
|
||||
var active = this.options.active,
|
||||
collapsible = this.options.collapsible,
|
||||
locationHash = location.hash.substring( 1 );
|
||||
|
||||
if ( active === null ) {
|
||||
// check the fragment identifier in the URL
|
||||
@ -106,38 +130,16 @@ $.widget( "ui.tabs", {
|
||||
if ( active !== false ) {
|
||||
active = this.tabs.index( this.tabs.eq( active ) );
|
||||
if ( active === -1 ) {
|
||||
active = options.collapsible ? false : 0;
|
||||
active = collapsible ? false : 0;
|
||||
}
|
||||
}
|
||||
options.active = active;
|
||||
|
||||
// don't allow collapsible: false and active: false
|
||||
if ( !options.collapsible && options.active === false && this.anchors.length ) {
|
||||
options.active = 0;
|
||||
if ( !collapsible && active === false && this.anchors.length ) {
|
||||
active = 0;
|
||||
}
|
||||
|
||||
// Take disabling tabs via class attribute from HTML
|
||||
// into account and update option properly.
|
||||
if ( $.isArray( options.disabled ) ) {
|
||||
options.disabled = $.unique( options.disabled.concat(
|
||||
$.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
|
||||
return that.tabs.index( li );
|
||||
})
|
||||
) ).sort();
|
||||
}
|
||||
|
||||
// check for length avoids error when initializing empty list
|
||||
if ( this.options.active !== false && this.anchors.length ) {
|
||||
this.active = this._findActive( this.options.active );
|
||||
} else {
|
||||
this.active = $();
|
||||
}
|
||||
|
||||
this._refresh();
|
||||
|
||||
if ( this.active.length ) {
|
||||
this.load( options.active );
|
||||
}
|
||||
return active;
|
||||
},
|
||||
|
||||
_getCreateEventData: function() {
|
||||
@ -148,6 +150,7 @@ $.widget( "ui.tabs", {
|
||||
},
|
||||
|
||||
_tabKeydown: function( event ) {
|
||||
/*jshint maxcomplexity:15*/
|
||||
var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
|
||||
selectedIndex = this.tabs.index( focusedTab ),
|
||||
goingForward = true;
|
||||
|
13
ui/jquery.ui.widget.js
vendored
13
ui/jquery.ui.widget.js
vendored
@ -25,6 +25,9 @@ $.cleanData = function( elems ) {
|
||||
|
||||
$.widget = function( name, base, prototype ) {
|
||||
var fullName, existingConstructor, constructor, basePrototype,
|
||||
// proxiedPrototype allows the provided prototype to remain unmodified
|
||||
// so that it can be used as a mixin for multiple widgets (#8876)
|
||||
proxiedPrototype = {},
|
||||
namespace = name.split( "." )[ 0 ];
|
||||
|
||||
name = name.split( "." )[ 1 ];
|
||||
@ -71,8 +74,11 @@ $.widget = function( name, base, prototype ) {
|
||||
// inheriting from
|
||||
basePrototype.options = $.widget.extend( {}, basePrototype.options );
|
||||
$.each( prototype, function( prop, value ) {
|
||||
if ( $.isFunction( value ) ) {
|
||||
prototype[ prop ] = (function() {
|
||||
if ( !$.isFunction( value ) ) {
|
||||
proxiedPrototype[ prop ] = value;
|
||||
return;
|
||||
}
|
||||
proxiedPrototype[ prop ] = (function() {
|
||||
var _super = function() {
|
||||
return base.prototype[ prop ].apply( this, arguments );
|
||||
},
|
||||
@ -95,14 +101,13 @@ $.widget = function( name, base, prototype ) {
|
||||
return returnValue;
|
||||
};
|
||||
})();
|
||||
}
|
||||
});
|
||||
constructor.prototype = $.widget.extend( basePrototype, {
|
||||
// TODO: remove support for widgetEventPrefix
|
||||
// always use the name + a colon as the prefix, e.g., draggable:start
|
||||
// don't prefix for widgets that aren't DOM-based
|
||||
widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
|
||||
}, prototype, {
|
||||
}, proxiedPrototype, {
|
||||
constructor: constructor,
|
||||
namespace: namespace,
|
||||
widgetName: name,
|
||||
|
Loading…
Reference in New Issue
Block a user