mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Merge branch 'master' into selectmenu
This commit is contained in:
commit
43772f3e5b
23
.jscs.json
Normal file
23
.jscs.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"requireCurlyBraces": [ "if", "else", "for", "while", "do" ],
|
||||
"requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return" ],
|
||||
"requireSpacesInFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"requireMultipleVarDecl": true,
|
||||
"requireSpacesInsideObjectBrackets": "all",
|
||||
"requireSpacesInsideArrayBrackets": "all",
|
||||
"disallowLeftStickedOperators": [ "?", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<=" ],
|
||||
"disallowRightStickedOperators": [ "?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
|
||||
"requireRightStickedOperators": [ "!" ],
|
||||
"requireLeftStickedOperators": [ "," ],
|
||||
"disallowKeywords": [ "with" ],
|
||||
"disallowMultipleLineBreaks": true,
|
||||
"disallowKeywordsOnNewLine": [ "else" ],
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
|
||||
"excludeFiles": [ "src/intro.js", "src/outro.js" ]
|
||||
}
|
10
Gruntfile.js
10
Gruntfile.js
@ -106,6 +106,7 @@ grunt.loadNpmTasks( "grunt-contrib-uglify" );
|
||||
grunt.loadNpmTasks( "grunt-contrib-concat" );
|
||||
grunt.loadNpmTasks( "grunt-contrib-qunit" );
|
||||
grunt.loadNpmTasks( "grunt-contrib-csslint" );
|
||||
grunt.loadNpmTasks( "grunt-jscs-checker" );
|
||||
grunt.loadNpmTasks( "grunt-html" );
|
||||
grunt.loadNpmTasks( "grunt-compare-size" );
|
||||
grunt.loadNpmTasks( "grunt-git-authors" );
|
||||
@ -162,6 +163,13 @@ grunt.initConfig({
|
||||
dest: "dist/jquery-ui.css"
|
||||
}
|
||||
},
|
||||
jscs: {
|
||||
// datepicker, sortable, resizable and draggable are getting rewritten, ignore until that's done
|
||||
ui: [ "ui/jquery.ui.*.js", "!ui/jquery.ui.datepicker.js", "!ui/jquery.ui.sortable.js", "!ui/jquery.ui.resizable.js", "!ui/jquery.ui.draggable.js" ],
|
||||
// TODO enable this once we have a tool that can help with fixing formatting of existing files
|
||||
// tests: "tests/unit/**/*.js",
|
||||
grunt: "Gruntfile.js"
|
||||
},
|
||||
uglify: minify,
|
||||
htmllint: {
|
||||
// ignore files that contain invalid html, used only for ajax content testing
|
||||
@ -198,7 +206,7 @@ grunt.initConfig({
|
||||
});
|
||||
|
||||
grunt.registerTask( "default", [ "lint", "test" ] );
|
||||
grunt.registerTask( "lint", [ "asciilint", "jshint", "csslint", "htmllint" ] );
|
||||
grunt.registerTask( "lint", [ "asciilint", "jshint", "jscs", "csslint", "htmllint" ] );
|
||||
grunt.registerTask( "test", [ "qunit" ] );
|
||||
grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] );
|
||||
grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] );
|
||||
|
@ -23,7 +23,7 @@
|
||||
$.widget( "custom.catcomplete", $.ui.autocomplete, {
|
||||
_create: function() {
|
||||
this._super();
|
||||
this.menu.option( "items", "> :not(.ui-autocomplete-category)" );
|
||||
this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
|
||||
},
|
||||
_renderMenu: function( ul, items ) {
|
||||
var that = this,
|
||||
|
@ -63,6 +63,7 @@
|
||||
"grunt-contrib-qunit": "0.2.0",
|
||||
"grunt-contrib-csslint": "0.1.1",
|
||||
"grunt-compare-size": "0.4.0-rc.3",
|
||||
"grunt-jscs-checker": "0.2.0",
|
||||
"grunt-html": "0.3.3",
|
||||
"grunt-git-authors": "1.2.0",
|
||||
"rimraf": "2.1.4",
|
||||
|
@ -52,6 +52,8 @@
|
||||
<div id="dialog1"></div>
|
||||
<div id="dialog2"></div>
|
||||
<div id="form-dialog" title="Profile Information">
|
||||
<!-- create a spacer to ensure there's enough space to scroll -->
|
||||
<div style="height: 250px;">...</div>
|
||||
<fieldset>
|
||||
<legend>Please share some personal information</legend>
|
||||
<label for="favorite-animal">Your favorite animal</label><input id="favorite-animal">
|
||||
|
@ -40,7 +40,7 @@ test("widget method", function() {
|
||||
});
|
||||
|
||||
asyncTest( "focus tabbable", function() {
|
||||
expect( 5 );
|
||||
expect( 6 );
|
||||
var element,
|
||||
options = {
|
||||
buttons: [{
|
||||
@ -50,6 +50,12 @@ asyncTest( "focus tabbable", function() {
|
||||
};
|
||||
|
||||
function checkFocus( markup, options, testFn, next ) {
|
||||
|
||||
// Support: IE8
|
||||
// For some reason the focus doesn't get set properly if we don't
|
||||
// focus the body first.
|
||||
$( "body" ).focus();
|
||||
|
||||
element = $( markup ).dialog( options );
|
||||
setTimeout(function() {
|
||||
testFn();
|
||||
@ -59,43 +65,57 @@ asyncTest( "focus tabbable", function() {
|
||||
}
|
||||
|
||||
function step1() {
|
||||
checkFocus( "<div><input><input autofocus></div>", options, function() {
|
||||
equal( document.activeElement, element.find( "input" )[ 1 ],
|
||||
"1. first element inside the dialog matching [autofocus]" );
|
||||
}, step2 );
|
||||
element = $( "<div><input><input></div>" ).dialog( options );
|
||||
setTimeout(function() {
|
||||
var input = element.find( "input:last" ).focus().blur();
|
||||
element.dialog( "instance" )._focusTabbable();
|
||||
setTimeout(function() {
|
||||
equal( document.activeElement, input[ 0 ],
|
||||
"1. an element that was focused previously." );
|
||||
element.remove();
|
||||
setTimeout( step2 );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function step2() {
|
||||
checkFocus( "<div><input><input></div>", options, function() {
|
||||
equal( document.activeElement, element.find( "input" )[ 0 ],
|
||||
"2. tabbable element inside the content element" );
|
||||
checkFocus( "<div><input><input autofocus></div>", options, function() {
|
||||
equal( document.activeElement, element.find( "input" )[ 1 ],
|
||||
"2. first element inside the dialog matching [autofocus]" );
|
||||
}, step3 );
|
||||
}
|
||||
|
||||
function step3() {
|
||||
checkFocus( "<div>text</div>", options, function() {
|
||||
equal( document.activeElement,
|
||||
element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ],
|
||||
"3. tabbable element inside the buttonpane" );
|
||||
checkFocus( "<div><input><input></div>", options, function() {
|
||||
equal( document.activeElement, element.find( "input" )[ 0 ],
|
||||
"3. tabbable element inside the content element" );
|
||||
}, step4 );
|
||||
}
|
||||
|
||||
function step4() {
|
||||
checkFocus( "<div>text</div>", {}, function() {
|
||||
checkFocus( "<div>text</div>", options, function() {
|
||||
equal( document.activeElement,
|
||||
element.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ],
|
||||
"4. the close button" );
|
||||
element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ],
|
||||
"4. tabbable element inside the buttonpane" );
|
||||
}, step5 );
|
||||
}
|
||||
|
||||
function step5() {
|
||||
checkFocus( "<div>text</div>", {}, function() {
|
||||
equal( document.activeElement,
|
||||
element.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ],
|
||||
"5. the close button" );
|
||||
}, step6 );
|
||||
}
|
||||
|
||||
function step6() {
|
||||
element = $( "<div>text</div>" ).dialog({
|
||||
autoOpen: false
|
||||
});
|
||||
element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
|
||||
element.dialog( "open" );
|
||||
setTimeout(function() {
|
||||
equal( document.activeElement, element.parent()[ 0 ], "5. the dialog itself" );
|
||||
equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" );
|
||||
element.remove();
|
||||
start();
|
||||
});
|
||||
|
@ -220,6 +220,11 @@ asyncTest( "#8958: dialog can be opened while opening", function() {
|
||||
}
|
||||
});
|
||||
|
||||
// Support: IE8
|
||||
// For some reason the #favorite-color input doesn't get focus if we don't
|
||||
// focus the body first, causing the test to hang.
|
||||
$( "body" ).focus();
|
||||
|
||||
$( "#favorite-animal" )
|
||||
// We focus the input to start the test. Once it receives focus, the
|
||||
// dialog will open. Opening the dialog, will cause an element inside
|
||||
|
@ -7,7 +7,7 @@ TestHelpers.commonWidgetTests( "menu", {
|
||||
items: "> *",
|
||||
menus: "ul",
|
||||
position: {
|
||||
my: "left top",
|
||||
my: "left-1 top",
|
||||
at: "right top"
|
||||
},
|
||||
role: "menu",
|
||||
|
@ -389,15 +389,15 @@ asyncTest( "handle keyboard navigation on menu with scroll and without submenus"
|
||||
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||
equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" );
|
||||
equal( logOutput(), "keydown,11", "Keydown PAGE_DOWN" );
|
||||
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||
equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" );
|
||||
equal( logOutput(), "keydown,22", "Keydown PAGE_DOWN" );
|
||||
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||
equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
|
||||
equal( logOutput(), "keydown,11", "Keydown PAGE_UP" );
|
||||
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||
@ -484,15 +484,15 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f
|
||||
function menukeyboard3() {
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||
equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" );
|
||||
equal( logOutput(), "keydown,11", "Keydown PAGE_DOWN" );
|
||||
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
||||
equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" );
|
||||
equal( logOutput(), "keydown,22", "Keydown PAGE_DOWN" );
|
||||
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||
equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
|
||||
equal( logOutput(), "keydown,11", "Keydown PAGE_UP" );
|
||||
|
||||
log( "keydown", true );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
||||
|
@ -66,13 +66,12 @@ test( "{ icons: { submenu: 'custom' } }", function() {
|
||||
test( "{ role: 'menu' } ", function() {
|
||||
var element = $( "#menu1" ).menu(),
|
||||
items = element.find( "li" );
|
||||
expect( 2 + 4 * items.length );
|
||||
expect( 2 + 3 * items.length );
|
||||
equal( element.attr( "role" ), "menu" );
|
||||
ok( items.length > 0, "number of menu items" );
|
||||
items.each(function( item ) {
|
||||
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
|
||||
equal( $( this ).attr( "role" ), "menuitem", "menu item ("+ item + ") role" );
|
||||
ok( $( this ).hasClass( "ui-corner-all" ), "class for menu item ("+ item + ")" );
|
||||
equal( $( this ).attr( "tabindex" ), "-1", "tabindex for menu item ("+ item + ")" );
|
||||
});
|
||||
});
|
||||
@ -82,13 +81,12 @@ test( "{ role: 'listbox' } ", function() {
|
||||
role: "listbox"
|
||||
}),
|
||||
items = element.find( "li" );
|
||||
expect( 2 + 4 * items.length );
|
||||
expect( 2 + 3 * items.length );
|
||||
equal( element.attr( "role" ), "listbox" );
|
||||
ok( items.length > 0, "number of menu items" );
|
||||
items.each(function( item ) {
|
||||
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
|
||||
equal( $( this ).attr( "role" ), "option", "menu item ("+ item + ") role" );
|
||||
ok( $( this ).hasClass( "ui-corner-all" ), "class for menu item ("+ item + ")" );
|
||||
equal( $( this ).attr( "tabindex" ), "-1", "tabindex for menu item ("+ item + ")" );
|
||||
});
|
||||
});
|
||||
@ -98,13 +96,12 @@ test( "{ role: null }", function() {
|
||||
role: null
|
||||
}),
|
||||
items = element.find( "li" );
|
||||
expect( 2 + 4 * items.length );
|
||||
expect( 2 + 3 * items.length );
|
||||
strictEqual( element.attr( "role" ), undefined );
|
||||
ok( items.length > 0, "number of menu items" );
|
||||
items.each(function( item ) {
|
||||
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
|
||||
equal( $( this ).attr( "role" ), undefined, "menu item ("+ item + ") role" );
|
||||
ok( $( this ).hasClass( "ui-corner-all" ), "class for menu item ("+ item + ")" );
|
||||
equal( $( this ).attr( "tabindex" ), "-1", "tabindex for menu item ("+ item + ")" );
|
||||
});
|
||||
});
|
||||
|
1
ui/jquery.ui.autocomplete.js
vendored
1
ui/jquery.ui.autocomplete.js
vendored
@ -570,7 +570,6 @@ $.extend( $.ui.autocomplete, {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// live region extension, adding a `messages` option
|
||||
// NOTE: This is an experimental API. We are still investigating
|
||||
// a full solution for string manipulation and internationalization.
|
||||
|
4
ui/jquery.ui.core.js
vendored
4
ui/jquery.ui.core.js
vendored
@ -211,10 +211,6 @@ if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
|
||||
})( $.fn.removeData );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// deprecated
|
||||
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
|
||||
|
||||
|
27
ui/jquery.ui.dialog.js
vendored
27
ui/jquery.ui.dialog.js
vendored
@ -118,6 +118,8 @@ $.widget( "ui.dialog", {
|
||||
}
|
||||
|
||||
this._isOpen = false;
|
||||
|
||||
this._trackFocus();
|
||||
},
|
||||
|
||||
_init: function() {
|
||||
@ -178,6 +180,7 @@ $.widget( "ui.dialog", {
|
||||
}
|
||||
|
||||
this._isOpen = false;
|
||||
this._focusedElement = null;
|
||||
this._destroyOverlay();
|
||||
|
||||
if ( !this.opener.filter( ":focusable" ).focus().length ) {
|
||||
@ -256,12 +259,16 @@ $.widget( "ui.dialog", {
|
||||
|
||||
_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
|
||||
var hasFocus = this.element.find("[autofocus]");
|
||||
// 1. An element that was focused previously
|
||||
// 2. First element inside the dialog matching [autofocus]
|
||||
// 3. Tabbable element inside the content element
|
||||
// 4. Tabbable element inside the buttonpane
|
||||
// 5. The close button
|
||||
// 6. The dialog itself
|
||||
var hasFocus = this._focusedElement;
|
||||
if ( !hasFocus ) {
|
||||
hasFocus = this.element.find( "[autofocus]" );
|
||||
}
|
||||
if ( !hasFocus.length ) {
|
||||
hasFocus = this.element.find( ":tabbable" );
|
||||
}
|
||||
@ -552,6 +559,14 @@ $.widget( "ui.dialog", {
|
||||
.css( "position", position );
|
||||
},
|
||||
|
||||
_trackFocus: function() {
|
||||
this._on( this.widget(), {
|
||||
"focusin": function( event ) {
|
||||
this._focusedElement = $( event.target );
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_minHeight: function() {
|
||||
var options = this.options;
|
||||
|
||||
|
4
ui/jquery.ui.effect.js
vendored
4
ui/jquery.ui.effect.js
vendored
@ -510,7 +510,6 @@ spaces.hsla.from = function ( hsla ) {
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
each( spaces, function( spaceName, space ) {
|
||||
var props = space.props,
|
||||
cache = space.cache,
|
||||
@ -680,7 +679,6 @@ colors = jQuery.Color.names = {
|
||||
|
||||
})( jQuery );
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/****************************** CLASS ANIMATIONS ******************************/
|
||||
/******************************************************************************/
|
||||
@ -735,7 +733,6 @@ function getElementStyles( elem ) {
|
||||
return styles;
|
||||
}
|
||||
|
||||
|
||||
function styleDifference( oldStyle, newStyle ) {
|
||||
var diff = {},
|
||||
name, value;
|
||||
@ -1040,7 +1037,6 @@ $.extend( $.effects, {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return element;
|
||||
},
|
||||
|
||||
|
8
ui/jquery.ui.mouse.js
vendored
8
ui/jquery.ui.mouse.js
vendored
@ -56,7 +56,9 @@ $.widget("ui.mouse", {
|
||||
|
||||
_mouseDown: function(event) {
|
||||
// don't let more than one widget handle mouseStart
|
||||
if( mouseHandled ) { return; }
|
||||
if ( mouseHandled ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we may have missed mouseup (out of window)
|
||||
(this._mouseStarted && this._mouseUp(event));
|
||||
@ -114,9 +116,9 @@ $.widget("ui.mouse", {
|
||||
// IE mouseup check - mouseup happened when mouse was out of window
|
||||
if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
|
||||
return this._mouseUp(event);
|
||||
}
|
||||
|
||||
// Iframe mouseup check - mouseup occurred in another document
|
||||
else if ( !event.which ) {
|
||||
} else if ( !event.which ) {
|
||||
return this._mouseUp( event );
|
||||
}
|
||||
|
||||
|
6
ui/jquery.ui.position.js
vendored
6
ui/jquery.ui.position.js
vendored
@ -400,8 +400,7 @@ $.ui.position = {
|
||||
if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
|
||||
position.left += myOffset + atOffset + offset;
|
||||
}
|
||||
}
|
||||
else if ( overRight > 0 ) {
|
||||
} else if ( overRight > 0 ) {
|
||||
newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
|
||||
if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
|
||||
position.left += myOffset + atOffset + offset;
|
||||
@ -435,8 +434,7 @@ $.ui.position = {
|
||||
if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
|
||||
position.top += myOffset + atOffset + offset;
|
||||
}
|
||||
}
|
||||
else if ( overBottom > 0 ) {
|
||||
} else if ( overBottom > 0 ) {
|
||||
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
|
||||
if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
|
||||
position.top += myOffset + atOffset + offset;
|
||||
|
Loading…
Reference in New Issue
Block a user