diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2013-11-16 12:25:21 +0100 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2013-11-16 12:25:21 +0100 |
commit | 43772f3e5bb531d917bec884bfbd0be196110fd8 (patch) | |
tree | d60d96a569eb47f901b8a800a8fc0f0f95e6c70e | |
parent | 0be76bbcfd7a2092aca1b4b01b90dab4e4fe00da (diff) | |
parent | 9fd0e86820dcea532d5357e0b814653746d62889 (diff) | |
download | jquery-ui-43772f3e5bb531d917bec884bfbd0be196110fd8.tar.gz jquery-ui-43772f3e5bb531d917bec884bfbd0be196110fd8.zip |
Merge branch 'master' into selectmenu
-rw-r--r-- | .jscs.json | 23 | ||||
-rw-r--r-- | Gruntfile.js | 10 | ||||
-rw-r--r-- | demos/autocomplete/categories.html | 2 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | tests/unit/dialog/dialog.html | 2 | ||||
-rw-r--r-- | tests/unit/dialog/dialog_core.js | 48 | ||||
-rw-r--r-- | tests/unit/dialog/dialog_methods.js | 5 | ||||
-rw-r--r-- | tests/unit/menu/menu_common.js | 2 | ||||
-rw-r--r-- | tests/unit/menu/menu_events.js | 12 | ||||
-rw-r--r-- | tests/unit/menu/menu_options.js | 9 | ||||
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 5 | ||||
-rw-r--r-- | ui/jquery.ui.core.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.dialog.js | 135 | ||||
-rw-r--r-- | ui/jquery.ui.droppable.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.effect-blind.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.effect-explode.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.effect-scale.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.effect-shake.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.effect-size.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.effect-transfer.js | 8 | ||||
-rw-r--r-- | ui/jquery.ui.effect.js | 26 | ||||
-rw-r--r-- | ui/jquery.ui.mouse.js | 8 | ||||
-rw-r--r-- | ui/jquery.ui.position.js | 8 | ||||
-rw-r--r-- | ui/jquery.ui.selectable.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.slider.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.spinner.js | 2 |
26 files changed, 198 insertions, 136 deletions
diff --git a/.jscs.json b/.jscs.json new file mode 100644 index 000000000..6540c8f39 --- /dev/null +++ b/.jscs.json @@ -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" ] +} diff --git a/Gruntfile.js b/Gruntfile.js index c6fcd3095..24b9632f0 100644 --- a/Gruntfile.js +++ b/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" ] ); diff --git a/demos/autocomplete/categories.html b/demos/autocomplete/categories.html index e3c59ba13..3c436efbd 100644 --- a/demos/autocomplete/categories.html +++ b/demos/autocomplete/categories.html @@ -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, diff --git a/package.json b/package.json index 02fbf7c5a..a802617b1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 7943b425b..d8506a1bd 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -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"> diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index e85759dc9..062d44576 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -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() { + 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 autofocus></div>", options, function() { equal( document.activeElement, element.find( "input" )[ 1 ], - "1. first element inside the dialog matching [autofocus]" ); - }, step2 ); + "2. first element inside the dialog matching [autofocus]" ); + }, step3 ); } - function step2() { + function step3() { checkFocus( "<div><input><input></div>", options, function() { equal( document.activeElement, element.find( "input" )[ 0 ], - "2. tabbable element inside the content element" ); - }, step3 ); + "3. tabbable element inside the content element" ); + }, step4 ); } - function step3() { + function step4() { checkFocus( "<div>text</div>", options, function() { equal( document.activeElement, element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], - "3. tabbable element inside the buttonpane" ); - }, step4 ); + "4. tabbable element inside the buttonpane" ); + }, step5 ); } - function step4() { + function step5() { checkFocus( "<div>text</div>", {}, function() { equal( document.activeElement, element.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], - "4. the close button" ); - }, step5 ); + "5. the close button" ); + }, step6 ); } - function step5() { + 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(); }); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 8918e8d36..d315e5fc3 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -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 diff --git a/tests/unit/menu/menu_common.js b/tests/unit/menu/menu_common.js index 2404ebe02..099dd091e 100644 --- a/tests/unit/menu/menu_common.js +++ b/tests/unit/menu/menu_common.js @@ -7,7 +7,7 @@ TestHelpers.commonWidgetTests( "menu", { items: "> *", menus: "ul", position: { - my: "left top", + my: "left-1 top", at: "right top" }, role: "menu", diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js index 0b89b86ac..9d74b4bbb 100644 --- a/tests/unit/menu/menu_events.js +++ b/tests/unit/menu/menu_events.js @@ -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 } ); diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js index 527cc4784..c76673345 100644 --- a/tests/unit/menu/menu_options.js +++ b/tests/unit/menu/menu_options.js @@ -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 + ")" ); }); }); diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 2b803b62f..aa6164c5c 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -86,7 +86,7 @@ $.widget( "ui.autocomplete", { suppressInput = false; suppressKeyPressRepeat = false; var keyCode = $.ui.keyCode; - switch( event.keyCode ) { + switch ( event.keyCode ) { case keyCode.PAGE_UP: suppressKeyPress = true; this._move( "previousPage", event ); @@ -149,7 +149,7 @@ $.widget( "ui.autocomplete", { // replicate some key handlers to allow them to repeat in Firefox and Opera var keyCode = $.ui.keyCode; - switch( event.keyCode ) { + switch ( event.keyCode ) { case keyCode.PAGE_UP: this._move( "previousPage", event ); break; @@ -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. diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 7faae0760..e789910df 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -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() ); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index c5bd42ab5..d3ce333f4 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -86,25 +86,25 @@ $.widget( "ui.dialog", { _create: function() { 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 + 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.originalTitle = this.element.attr( "title" ); this.options.title = this.options.title || this.originalTitle; this._createWrapper(); this.element .show() - .removeAttr("title") - .addClass("ui-dialog-content ui-widget-content") + .removeAttr( "title" ) + .addClass( "ui-dialog-content ui-widget-content" ) .appendTo( this.uiDialog ); this._createTitlebar(); @@ -118,6 +118,8 @@ $.widget( "ui.dialog", { } this._isOpen = false; + + this._trackFocus(); }, _init: function() { @@ -142,7 +144,7 @@ $.widget( "ui.dialog", { this.element .removeUniqueId() - .removeClass("ui-dialog-content ui-widget-content") + .removeClass( "ui-dialog-content ui-widget-content" ) .css( this.originalCss ) // Without detaching first, the following becomes really slow .detach(); @@ -155,7 +157,7 @@ $.widget( "ui.dialog", { 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] ) { + if ( next.length && next[ 0 ] !== this.element[ 0 ] ) { next.before( this.element ); } else { originalPosition.parent.append( this.element ); @@ -178,9 +180,10 @@ $.widget( "ui.dialog", { } this._isOpen = false; + this._focusedElement = null; this._destroyOverlay(); - if ( !this.opener.filter(":focusable").focus().length ) { + if ( !this.opener.filter( ":focusable" ).focus().length ) { // support: IE9 // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> @@ -240,7 +243,7 @@ $.widget( "ui.dialog", { } this._isOpen = true; - this.opener = $( this.document[0].activeElement ); + this.opener = $( this.document[ 0 ].activeElement ); this._size(); this._position(); @@ -248,28 +251,32 @@ $.widget( "ui.dialog", { this._moveToTop( null, true ); this._show( this.uiDialog, this.options.show, function() { that._focusTabbable(); - that._trigger("focus"); + that._trigger( "focus" ); }); - this._trigger("open"); + this._trigger( "open" ); }, _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"); + hasFocus = this.element.find( ":tabbable" ); } if ( !hasFocus.length ) { - hasFocus = this.uiDialogButtonPane.find(":tabbable"); + hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); } if ( !hasFocus.length ) { - hasFocus = this.uiDialogTitlebarClose.filter(":tabbable"); + hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" ); } if ( !hasFocus.length ) { hasFocus = this.uiDialog; @@ -319,9 +326,9 @@ $.widget( "ui.dialog", { if ( event.keyCode !== $.ui.keyCode.TAB ) { return; } - var tabbables = this.uiDialog.find(":tabbable"), - first = tabbables.filter(":first"), - last = tabbables.filter(":last"); + var tabbables = this.uiDialog.find( ":tabbable" ), + first = tabbables.filter( ":first" ), + last = tabbables.filter( ":last" ); if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) { first.focus( 1 ); @@ -341,9 +348,9 @@ $.widget( "ui.dialog", { // We assume that any existing aria-describedby attribute means // that the dialog content is marked up properly // otherwise we brute force the content as the description - if ( !this.element.find("[aria-describedby]").length ) { + if ( !this.element.find( "[aria-describedby]" ).length ) { this.uiDialog.attr({ - "aria-describedby": this.element.uniqueId().attr("id") + "aria-describedby": this.element.uniqueId().attr( "id" ) }); } }, @@ -351,15 +358,15 @@ $.widget( "ui.dialog", { _createTitlebar: function() { var uiDialogTitle; - this.uiDialogTitlebar = $("<div>") - .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix") + this.uiDialogTitlebar = $( "<div>" ) + .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" ) .prependTo( this.uiDialog ); this._on( this.uiDialogTitlebar, { mousedown: function( event ) { // Don't prevent click on close button (#8838) // Focusing a dialog that is partially scrolled out of view // causes the browser to scroll it into view, preventing the click event - if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) { + if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) { // Dialog isn't getting focus when dragging (#8063) this.uiDialog.focus(); } @@ -377,7 +384,7 @@ $.widget( "ui.dialog", { }, text: false }) - .addClass("ui-dialog-titlebar-close") + .addClass( "ui-dialog-titlebar-close" ) .appendTo( this.uiDialogTitlebar ); this._on( this.uiDialogTitlebarClose, { click: function( event ) { @@ -386,30 +393,30 @@ $.widget( "ui.dialog", { } }); - uiDialogTitle = $("<span>") + uiDialogTitle = $( "<span>" ) .uniqueId() - .addClass("ui-dialog-title") + .addClass( "ui-dialog-title" ) .prependTo( this.uiDialogTitlebar ); this._title( uiDialogTitle ); this.uiDialog.attr({ - "aria-labelledby": uiDialogTitle.attr("id") + "aria-labelledby": uiDialogTitle.attr( "id" ) }); }, _title: function( title ) { if ( !this.options.title ) { - title.html(" "); + title.html( " " ); } title.text( this.options.title ); }, _createButtonPane: function() { - this.uiDialogButtonPane = $("<div>") - .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"); + this.uiDialogButtonPane = $( "<div>" ) + .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); - this.uiButtonSet = $("<div>") - .addClass("ui-dialog-buttonset") + this.uiButtonSet = $( "<div>" ) + .addClass( "ui-dialog-buttonset" ) .appendTo( this.uiDialogButtonPane ); this._createButtons(); @@ -424,7 +431,7 @@ $.widget( "ui.dialog", { this.uiButtonSet.empty(); if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) { - this.uiDialog.removeClass("ui-dialog-buttons"); + this.uiDialog.removeClass( "ui-dialog-buttons" ); return; } @@ -438,7 +445,7 @@ $.widget( "ui.dialog", { // Change the context for the click callback to be the main element click = props.click; props.click = function() { - click.apply( that.element[0], arguments ); + click.apply( that.element[ 0 ], arguments ); }; buttonOptions = { icons: props.icons, @@ -450,7 +457,7 @@ $.widget( "ui.dialog", { .button( buttonOptions ) .appendTo( that.uiButtonSet ); }); - this.uiDialog.addClass("ui-dialog-buttons"); + this.uiDialog.addClass( "ui-dialog-buttons" ); this.uiDialogButtonPane.appendTo( this.uiDialog ); }, @@ -470,7 +477,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._blockFrames(); that._trigger( "dragStart", event, filteredUi( ui ) ); }, @@ -487,7 +494,7 @@ $.widget( "ui.dialog", { "top" + (top >= 0 ? "+" : "") + top, of: that.window }; - $( this ).removeClass("ui-dialog-dragging"); + $( this ).removeClass( "ui-dialog-dragging" ); that._unblockFrames(); that._trigger( "dragStop", event, filteredUi( ui ) ); } @@ -524,7 +531,7 @@ $.widget( "ui.dialog", { minHeight: this._minHeight(), handles: resizeHandles, start: function( event, ui ) { - $( this ).addClass("ui-dialog-resizing"); + $( this ).addClass( "ui-dialog-resizing" ); that._blockFrames(); that._trigger( "resizeStart", event, filteredUi( ui ) ); }, @@ -544,7 +551,7 @@ $.widget( "ui.dialog", { "top" + (top >= 0 ? "+" : "") + top, of: that.window }; - $( this ).removeClass("ui-dialog-resizing"); + $( this ).removeClass( "ui-dialog-resizing" ); that._unblockFrames(); that._trigger( "resizeStop", event, filteredUi( ui ) ); } @@ -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; @@ -562,7 +577,7 @@ $.widget( "ui.dialog", { _position: function() { // Need to show the dialog to get the actual offset in the position plugin - var isVisible = this.uiDialog.is(":visible"); + var isVisible = this.uiDialog.is( ":visible" ); if ( !isVisible ) { this.uiDialog.show(); } @@ -592,7 +607,7 @@ $.widget( "ui.dialog", { this._size(); this._position(); } - if ( this.uiDialog.is(":data(ui-resizable)") ) { + if ( this.uiDialog.is( ":data(ui-resizable)" ) ) { this.uiDialog.resizable( "option", resizableOptions ); } }, @@ -629,9 +644,9 @@ $.widget( "ui.dialog", { } if ( key === "draggable" ) { - isDraggable = uiDialog.is(":data(ui-draggable)"); + isDraggable = uiDialog.is( ":data(ui-draggable)" ); if ( isDraggable && !value ) { - uiDialog.draggable("destroy"); + uiDialog.draggable( "destroy" ); } if ( !isDraggable && value ) { @@ -645,9 +660,9 @@ $.widget( "ui.dialog", { if ( key === "resizable" ) { // currently resizable, becoming non-resizable - isResizable = uiDialog.is(":data(ui-resizable)"); + isResizable = uiDialog.is( ":data(ui-resizable)" ); if ( isResizable && !value ) { - uiDialog.resizable("destroy"); + uiDialog.resizable( "destroy" ); } // currently resizable, changing handles @@ -662,7 +677,7 @@ $.widget( "ui.dialog", { } if ( key === "title" ) { - this._title( this.uiDialogTitlebar.find(".ui-dialog-title") ); + this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) ); } }, @@ -706,7 +721,7 @@ $.widget( "ui.dialog", { this.element.height( Math.max( 0, options.height - nonContentHeight ) ); } - if (this.uiDialog.is(":data(ui-resizable)") ) { + if ( this.uiDialog.is( ":data(ui-resizable)" ) ) { this.uiDialog.resizable( "option", "minHeight", this._minHeight() ); } }, @@ -734,13 +749,13 @@ $.widget( "ui.dialog", { }, _allowInteraction: function( event ) { - if ( $( event.target ).closest(".ui-dialog").length ) { + if ( $( event.target ).closest( ".ui-dialog" ).length ) { return true; } // TODO: Remove hack when datepicker implements // the .ui-front logic (#8989) - return !!$( event.target ).closest(".ui-datepicker").length; + return !!$( event.target ).closest( ".ui-datepicker" ).length; }, _createOverlay: function() { @@ -775,8 +790,8 @@ $.widget( "ui.dialog", { }); } - this.overlay = $("<div>") - .addClass("ui-widget-overlay ui-front") + this.overlay = $( "<div>" ) + .addClass( "ui-widget-overlay ui-front" ) .appendTo( this._appendTo() ); this._on( this.overlay, { mousedown: "_keepFocus" @@ -807,4 +822,4 @@ $.widget( "ui.dialog", { } }); -}( jQuery ) ); +}( jQuery )); diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 0e4b65cc4..f9f2620da 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -284,7 +284,7 @@ $.ui.ddmanager = { } // Filter out elements in the current dragged item - for ( j=0; j < list.length; j++ ) { + for ( j = 0; j < list.length; j++ ) { if ( list[ j ] === m[ i ].element[ 0 ] ) { m[ i ].proportions().height = 0; continue droppablesLoop; @@ -362,7 +362,7 @@ $.ui.ddmanager = { if ( this.options.greedy ) { // find droppable parents with same scope scope = this.options.scope; - parent = this.element.parents( ":data(ui-droppable)" ).filter(function () { + parent = this.element.parents( ":data(ui-droppable)" ).filter(function() { return $( this ).droppable( "instance" ).options.scope === scope; }); diff --git a/ui/jquery.ui.effect-blind.js b/ui/jquery.ui.effect-blind.js index e6f4b8a4c..26aeab05c 100644 --- a/ui/jquery.ui.effect-blind.js +++ b/ui/jquery.ui.effect-blind.js @@ -56,7 +56,7 @@ $.effects.effect.blind = function( o, done ) { // start at 0 if we are showing if ( show ) { wrapper.css( ref, 0 ); - if ( ! motion ) { + if ( !motion ) { wrapper.css( ref2, margin + distance ); } } diff --git a/ui/jquery.ui.effect-explode.js b/ui/jquery.ui.effect-explode.js index 296cf96ea..e81ad9be0 100644 --- a/ui/jquery.ui.effect-explode.js +++ b/ui/jquery.ui.effect-explode.js @@ -41,11 +41,11 @@ $.effects.effect.explode = function( o, done ) { } // clone the element for each row and cell. - for( i = 0; i < rows ; i++ ) { // ===> + for ( i = 0; i < rows ; i++ ) { // ===> top = offset.top + i * height; my = i - ( rows - 1 ) / 2 ; - for( j = 0; j < cells ; j++ ) { // ||| + for ( j = 0; j < cells ; j++ ) { // ||| left = offset.left + j * width; mx = j - ( cells - 1 ) / 2 ; diff --git a/ui/jquery.ui.effect-scale.js b/ui/jquery.ui.effect-scale.js index a1fc4e247..42dc2281c 100644 --- a/ui/jquery.ui.effect-scale.js +++ b/ui/jquery.ui.effect-scale.js @@ -42,7 +42,7 @@ $.effects.effect.scale = function( o, done ) { // Set default origin and restore for show/hide if ( mode !== "effect" ) { - options.origin = origin || ["middle","center"]; + options.origin = origin || [ "middle", "center" ]; options.restore = true; } diff --git a/ui/jquery.ui.effect-shake.js b/ui/jquery.ui.effect-shake.js index 6ced33316..1e7e827e7 100644 --- a/ui/jquery.ui.effect-shake.js +++ b/ui/jquery.ui.effect-shake.js @@ -22,7 +22,7 @@ $.effects.effect.shake = function( o, done ) { distance = o.distance || 20, times = o.times || 3, anims = times * 2 + 1, - speed = Math.round(o.duration/anims), + speed = Math.round( o.duration / anims ), ref = (direction === "up" || direction === "down") ? "top" : "left", positiveMotion = (direction === "up" || direction === "left"), animation = {}, diff --git a/ui/jquery.ui.effect-size.js b/ui/jquery.ui.effect-size.js index 8643e5f0c..6bdbd433d 100644 --- a/ui/jquery.ui.effect-size.js +++ b/ui/jquery.ui.effect-size.js @@ -125,7 +125,7 @@ $.effects.effect.size = function( o, done ) { hProps = hProps.concat([ "marginLeft", "marginRight" ]); props2 = props0.concat(vProps).concat(hProps); - el.find( "*[width]" ).each( function(){ + el.find( "*[width]" ).each( function() { var child = $( this ), c_original = { height: child.height(), @@ -183,7 +183,7 @@ $.effects.effect.size = function( o, done ) { if ( el.to.opacity === 0 ) { el.css( "opacity", el.from.opacity ); } - if( mode === "hide" ) { + if ( mode === "hide" ) { el.hide(); } $.effects.restore( el, props ); diff --git a/ui/jquery.ui.effect-transfer.js b/ui/jquery.ui.effect-transfer.js index 3e49d1989..31fbfa219 100644 --- a/ui/jquery.ui.effect-transfer.js +++ b/ui/jquery.ui.effect-transfer.js @@ -22,8 +22,8 @@ $.effects.effect.transfer = function( o, done ) { fixLeft = targetFixed ? body.scrollLeft() : 0, endPosition = target.offset(), animation = { - top: endPosition.top - fixTop , - left: endPosition.left - fixLeft , + top: endPosition.top - fixTop, + left: endPosition.left - fixLeft, height: target.innerHeight(), width: target.innerWidth() }, @@ -32,8 +32,8 @@ $.effects.effect.transfer = function( o, done ) { .appendTo( document.body ) .addClass( o.className ) .css({ - top: startPosition.top - fixTop , - left: startPosition.left - fixLeft , + top: startPosition.top - fixTop, + left: startPosition.left - fixLeft, height: elem.innerHeight(), width: elem.innerWidth(), position: targetFixed ? "fixed" : "absolute" diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index 3d65b40c7..3852cf5be 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -33,7 +33,7 @@ $.effects = { // plusequals test for += 100 -= 100 rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, // a set of RE's that can match strings and generate color tuples. - stringParsers = [{ + stringParsers = [ { re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, parse: function( execResult ) { return [ @@ -84,7 +84,7 @@ $.effects = { execResult[ 4 ] ]; } - }], + } ], // jQuery.Color( ) color = jQuery.Color = function( color, green, blue, alpha ) { @@ -443,18 +443,18 @@ color.fn.parse.prototype = color.fn; function hue2rgb( p, q, h ) { h = ( h + 1 ) % 1; if ( h * 6 < 1 ) { - return p + (q - p) * h * 6; + return p + ( q - p ) * h * 6; } if ( h * 2 < 1) { return q; } if ( h * 3 < 2 ) { - return p + (q - p) * ((2/3) - h) * 6; + return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6; } return p; } -spaces.hsla.to = function ( rgba ) { +spaces.hsla.to = function( rgba ) { if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { return [ null, null, null, rgba[ 3 ] ]; } @@ -491,7 +491,7 @@ spaces.hsla.to = function ( rgba ) { return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; }; -spaces.hsla.from = function ( hsla ) { +spaces.hsla.from = function( hsla ) { if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { return [ null, null, null, hsla[ 3 ] ]; } @@ -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; @@ -897,7 +894,7 @@ $.extend( $.effects, { // Saves a set of properties in a data storage save: function( element, set ) { - for( var i=0; i < set.length; i++ ) { + for ( var i = 0; i < set.length; i++ ) { if ( set[ i ] !== null ) { element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); } @@ -907,7 +904,7 @@ $.extend( $.effects, { // Restores a set of previously saved properties from a data storage restore: function( element, set ) { var val, i; - for( i=0; i < set.length; i++ ) { + for ( i = 0; i < set.length; i++ ) { if ( set[ i ] !== null ) { val = element.data( dataSpace + set[ i ] ); // support: jQuery 1.6.2 @@ -1040,7 +1037,6 @@ $.extend( $.effects, { } } - return element; }, @@ -1250,10 +1246,10 @@ $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { }); $.extend( baseEasings, { - Sine: function ( p ) { + Sine: function( p ) { return 1 - Math.cos( p * Math.PI / 2 ); }, - Circ: function ( p ) { + Circ: function( p ) { return 1 - Math.sqrt( 1 - p * p ); }, Elastic: function( p ) { @@ -1263,7 +1259,7 @@ $.extend( baseEasings, { Back: function( p ) { return p * p * ( 3 * p - 2 ); }, - Bounce: function ( p ) { + Bounce: function( p ) { var pow2, bounce = 4; diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index ca774e3da..36b9f2ba0 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -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 ); } diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 15f168927..6ff37bd13 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -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; @@ -457,7 +455,7 @@ $.ui.position = { }; // fraction support test -(function () { +(function() { var testElement, testElementParent, testElementStyle, offsetLeft, i, body = document.getElementsByTagName( "body" )[ 0 ], div = document.createElement( "div" ); diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js index ab804a1df..7b9d7b209 100644 --- a/ui/jquery.ui.selectable.js +++ b/ui/jquery.ui.selectable.js @@ -83,7 +83,7 @@ $.widget("ui.selectable", $.ui.mouse, { var that = this, options = this.options; - this.opos = [event.pageX, event.pageY]; + this.opos = [ event.pageX, event.pageY ]; if (this.options.disabled) { return; @@ -166,7 +166,7 @@ $.widget("ui.selectable", $.ui.mouse, { if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; } if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; } - this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1}); + this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 }); this.selectees.each(function() { var selectee = $.data(this, "selectable-item"), diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 10efc4bf8..7c67221b3 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -423,7 +423,7 @@ $.widget( "ui.slider", $.ui.mouse, { this.options.value = this._values( 0 ); this.options.values = null; } else if ( value === "max" ) { - this.options.value = this._values( this.options.values.length-1 ); + this.options.value = this._values( this.options.values.length - 1 ); this.options.values = null; } } diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 870b3328a..30b5983a1 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -301,7 +301,7 @@ $.widget( "ui.spinner", { if ( incremental ) { return $.isFunction( incremental ) ? incremental( i ) : - Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 ); + Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 ); } return 1; |