From f5aaf874e9563ef90a1dec35700732acd58e8b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 12 Dec 2012 11:21:49 -0500 Subject: [PATCH 1/9] Progressbar: Moved .ui-progressbar-indeterminate to main element. Added tests for markup structure. --- tests/unit/progressbar/progressbar_core.js | 25 ++++++++++++++++++++++ themes/base/jquery.ui.progressbar.css | 4 ++-- ui/jquery.ui.progressbar.js | 3 ++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/tests/unit/progressbar/progressbar_core.js b/tests/unit/progressbar/progressbar_core.js index cffd84d21..8f4a138ce 100644 --- a/tests/unit/progressbar/progressbar_core.js +++ b/tests/unit/progressbar/progressbar_core.js @@ -1,5 +1,30 @@ module( "progressbar: core" ); +test( "markup structure", function() { + expect( 5 ); + var element = $( "#progressbar" ).progressbar(); + ok( element.hasClass( "ui-progressbar" ), "main element is .ui-progressbar" ); + ok( !element.hasClass( "ui-progressbar-indeterminate" ), + "main element is not .ui-progressbar-indeterminate" ); + equal( element.children().length, 1, "main element contains one child" ); + ok( element.children().eq( 0 ).hasClass( "ui-progressbar-value" ), + "child is .ui-progressbar-value" ); + equal( element.children().children().length, 0, "no overlay div" ); +}); + +test( "markup structure - indeterminate", function() { + expect( 5 ); + var element = $( "#progressbar" ).progressbar({ value: false }); + ok( element.hasClass( "ui-progressbar" ), "main element is .ui-progressbar" ); + ok( element.hasClass( "ui-progressbar-indeterminate" ), + "main element is .ui-progressbar-indeterminate" ); + equal( element.children().length, 1, "main element contains one child" ); + ok( element.children().eq( 0 ).hasClass( "ui-progressbar-value" ), + "child is .ui-progressbar-value" ); + equal( element.children().children( ".ui-progressbar-overlay" ).length, 1, + ".ui-progressbar-value has .ui-progressbar-overlay" ); +}); + test( "accessibility", function() { expect( 11 ); var element = $( "#progressbar" ).progressbar(); diff --git a/themes/base/jquery.ui.progressbar.css b/themes/base/jquery.ui.progressbar.css index 349cc6d72..5d4c35f07 100644 --- a/themes/base/jquery.ui.progressbar.css +++ b/themes/base/jquery.ui.progressbar.css @@ -17,12 +17,12 @@ margin: -1px; height: 100%; } -.ui-progressbar .ui-progressbar-value .ui-progressbar-overlay { +.ui-progressbar .ui-progressbar-overlay { background: url("images/animated-overlay.gif"); height: 100%; filter: alpha(opacity=25); opacity: 0.25; } -.ui-progressbar .ui-progressbar-indeterminate { +.ui-progressbar-indeterminate .ui-progressbar-value { background-image: none; } diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 163bb06cd..e8b9b911a 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -112,9 +112,10 @@ $.widget( "ui.progressbar", { 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) + "%" ); + this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate ); + if ( this.indeterminate ) { this.element.removeAttr( "aria-valuenow" ); if ( !this.overlayDiv ) { From ff78d0bbce07e4fc45caff84a740408af4909d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 12 Dec 2012 11:22:08 -0500 Subject: [PATCH 2/9] Core: Moved selectstart support test to deprecated section. --- ui/jquery.ui.core.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index bd3e30758..4ad4f8a09 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -180,9 +180,6 @@ $.extend( $.expr[ ":" ], { } }); -// support -$.support.selectstart = "onselectstart" in document.createElement( "div" ); - // support: jQuery <1.8 if ( !$( "" ).outerWidth( 1 ).jquery ) { $.each( [ "Width", "Height" ], function( i, name ) { @@ -250,6 +247,7 @@ if ( $( "" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { // deprecated $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); +$.support.selectstart = "onselectstart" in document.createElement( "div" ); $.fn.extend({ disableSelection: function() { return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) + From f48964556502c1f89e284c42c670b49a2e59a59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 12 Dec 2012 15:21:36 -0500 Subject: [PATCH 3/9] Added CONTRIBUTING.md. --- CONTRIBUTING.md | 205 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..7b92529f4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,205 @@ +# Contributing to jQuery UI + +1. [Getting Involved](#getting-involved) +2. [Discussion](#discussion) +3. [How To Report Bugs](#how-to-report-bugs) +4. [jQuery UI Coding Standards](#jquery-ui-coding-standards) +5. [Tips For Bug Patching](#tips-for-bug-patching) + + + +## Getting Involved + +There are a number of ways to get involved with the development of jQuery UI. Even if you've never contributed code to an Open Source project before, we're always looking for help identifying bugs, writing and reducing test cases and documentation. + +This is the best way to contribute to jQuery UI. Please read through the full guide detailing [How to Report Bugs](#how-to-report-bugs). + +## Discussion + +### Forum and IRC + +The jQuery UI development team frequently tracks posts on the [Developing jQuery UI Forum](http://forum.jquery.com/developing-jquery-ui). If you have longer posts or questions please feel free to post them there. If you think you've found a bug please [file it in the bug tracker](#how-to-report-bugs). + +Additionally most of the jQuery UI development team can be found in the [#jqueryui-dev](http://webchat.freenode.net/?channels=jqueryui-dev) IRC channel on irc.freenode.net. + +### Weekly Status Meetings + +Every week (unless otherwise noted) the jQuery UI dev team has a meeting to discuss the progress of current work and to bring forward possible new blocker bugs for discussion. + +The meeting is held in the [#jquery-meeting](http://webchat.freenode.net/?channels=jquery-meeting) IRC channel on irc.freenode.net at [Noon EST](http://www.timeanddate.com/worldclock/fixedtime.html?month=1&day=17&year=2011&hour=12&min=0&sec=0&p1=43) on Wednesdays. + +Past Meeting Notes: +[2008 - 2011](https://docs.google.com/spreadsheet/ccc?key=0AusvKVL7jmFUcHVBQk9tMUxkRGl0emVwZGdLd0QtUlE), +[2012 - current](https://docs.google.com/spreadsheet/ccc?key=0ArIM4UVbwE-3dFg1T0k4VlE1bF82Nm9tbW90cVNxN0E) + + +## How to Report Bugs + +### Make sure it is a jQuery UI bug + +Many bugs reported to our bug tracker are actually bugs in user code, not in jQuery UI code. Keep in mind that just because your code throws an error and the console points to a line number inside of jQuery or jQuery UI, this does *not* mean the bug is a jQuery UI bug. + +If you are new to jQuery and/or jQuery UI, it is usually a much better idea to ask for help first in the [Using jQuery Forum](http://forum.jquery.com/using-jquery), the [Using jQuery UI Forum](http://forum.jquery.com/using-jquery-ui) or the [jQuery IRC channel](http://webchat.freenode.net/?channels=%23jquery). You will get much quicker support, and you will help avoid tying up the jQuery UI team with invalid bug reports. These same resources can also be useful if you want to confirm that your bug is indeed a bug in jQuery UI before filing any tickets. + + +### Disable any browser extensions + +Make sure you have reproduced the bug with all browser extensions and add-ons disabled, as these can sometimes cause things to break in interesting and unpredictable ways. Try using incognito, stealth or anonymous browsing modes. + + +### Try the latest version of jQuery UI + +Bugs in old versions of jQuery UI may have already been fixed. In order to avoid reporting known issues, make sure you are always testing against the latest stable release. + +### Try an older version of jQuery UI + +Sometimes, bugs are introduced in newer versions of jQuery UI that do not exist in previous versions. When possible, it can be useful to try testing with an older release. + +### Reduce, reduce, reduce! + +When you are experiencing a problem, the most useful thing you can possibly do is to [reduce your code](http://webkit.org/quality/reduction.html) to the bare minimum required to reproduce the issue. This makes it *much* easier to isolate and fix the offending code. Bugs that are reported without reduced test cases generally take much longer to fix than bugs that are submitted with them, so you really should try to do this if at all possible. + +## jQuery UI Coding Standards + +See: [jQuery UI Coding Standards](http://wiki.jqueryui.com/w/page/12137737/Coding%20standards) + +## Tips For Bug Patching + + +### Environment: localhost w/ PHP, Node & Grunt + +jQuery UI uses node & gruntjs to automate the building and validation of source code. + +Some tests depend on PHP running locally, so make sure you have the following installed: + +* Some kind of localhost server program that supports PHP (any will do) +* Node.js +* NPM (comes with the latest version of Node.js) +* Grunt (install with: `npm install grunt -g` + + +Maintaining a list of platform specific instructions is outside of the scope of this document and there is plenty of existing documentation for the above technologies. + + +### Build a Local Copy of jQuery UI + +Create a fork of the jQuery UI repo on github at http://github.com/jquery/jquery-ui + +Change directory to your web root directory, whatever that might be: + +```bash +$ cd /path/to/your/www/root/ +``` + +Clone your jQuery UI fork to work locally + +```bash +$ git clone git@github.com:username/jquery-ui.git +``` + +Change directory to the newly created dir jquery-ui/ + +```bash +$ cd jquery-ui +``` + +Add the jQuery master as a remote. I label mine "upstream" + +```bash +$ git remote add upstream git://github.com/jquery/jquery-ui.git +``` + +Get in the habit of pulling in the "upstream" master to stay up to date as jQuery UI receives new commits + +```bash +$ git pull upstream master +``` + +To lint the JavaScript, HTML, and CSS, as well as run a smoke test in PhantomJS, run grunt: + +```bash +$ grunt +``` + +To run the tests for a specific plugin in your browser, open the approriate file from the /tests/unit/ directory, for example: http://localhost/tests/unit/accordion/accordion.html. The domain will be dependent on your local server configuation; if there is a port, be sure to include it. + +Success! You just tested jQuery UI! + + +### Fix a bug from a ticket filed at bugs.jqueryui.com: + +**NEVER write your patches to the master branch** - it gets messy (I say this from experience!) + +**ALWAYS USE A "TOPIC" BRANCH!** Like so (#### = the ticket #)... + +Make sure you start with your up-to-date master: + +```bash +$ git checkout master +``` + +Create and checkout a new branch that includes the ticket # + +```bash +$ git checkout -b bug_#### + +# ( Explanation: this useful command will: +# "checkout" a "-b" (branch) by the name of "bug_####" +# or create it if it doesn't exist ) +``` + +Now you're on branch: bug_#### + +Determine the file you'll be working in... + +Open up the corresponding /tests/unit/?????.js and add the initial failing unit tests. This may seem awkward at first, but in the long run it will make sense. To truly and efficiently patch a bug, you need to be working against that bug. + +Next, open the source files and make your changes + +Run http://localhost/tests/unit/???? --> **ALL TESTS MUST PASS** + +Once you're satisfied with your patch... + +Stage the files to be tracked: + +```bash +$ git add filename +# (you can use "git status" to list the files you've changed) +``` + + +( I recommend NEVER, EVER using "git add . " ) + +Once you've staged all of your changed files, go ahead and commit them + +```bash +$ git commit -m "Component: Brief description of fix. Fixes #0000 - Ticket description." +``` + +See the [commit message style guide](http://wiki.jqueryui.com/w/page/25941597/Commit%20Message%20Style%20Guide) for more details on how to format your commit message. + +For a multiple line commit message, leave off the `-m "description"`. + +You will then be led into vi (or the text editor that you have set up) to complete your commit message. + +Then, push your branch with the bug fix commits to your github fork + +```bash +$ git push origin -u bug_#### +``` + +Before you tackle your next bug patch, return to the master: + +```bash +$ git checkout master +``` + + + +### jQuery UI supports the following browsers: + +* Chrome Current-1 +* Safari Current-1 +* Firefox Current-1 +* Opera Current-1 +* IE 7+ From 7a45a47b7edf6db0a152166abfd8c266c1b74ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 13 Dec 2012 09:50:27 -0500 Subject: [PATCH 4/9] Updated AUTHORS.txt. --- AUTHORS.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 1da44ef23..850996358 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -224,3 +224,8 @@ Juan Pablo Kaniefsky Roman Salnikov Anika Henke Samuel Bovée +Fabrício Matté +Viktor Kojouharov +Pawel Maruszczyk +Pavel Selitskas +Bjørn Johansen From 1f5dd8d68ef568ea4ec28c3881ba438e4f946f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 13 Dec 2012 11:35:41 -0500 Subject: [PATCH 5/9] Release: Add support for pre-releases. --- build/release/release.js | 87 ++++++++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 22 deletions(-) diff --git a/build/release/release.js b/build/release/release.js index 4efa1d2b7..60abf61ec 100644 --- a/build/release/release.js +++ b/build/release/release.js @@ -1,9 +1,13 @@ #!/usr/bin/env node /*global cat:true cd:true echo:true exec:true exit:true*/ +// Usage: +// stable release: node release.js +// pre-release: node release.js --pre-release {version} + "use strict"; -var baseDir, repoDir, prevVersion, newVersion, nextVersion, tagTime, +var baseDir, repoDir, prevVersion, newVersion, nextVersion, tagTime, preRelease, fs = require( "fs" ), path = require( "path" ), // support: node <0.8 @@ -67,8 +71,12 @@ function cloneRepo() { if ( exec( "npm install" ).code !== 0 ) { abort( "Error installing dependencies." ); } - if ( exec( "npm install download.jqueryui.com" ).code !== 0 ) { - abort( "Error installing dependencies." ); + // We need download.jqueryui.com in order to generate themes. + // We only generate themes for stable releases. + if ( !preRelease ) { + if ( exec( "npm install download.jqueryui.com" ).code !== 0 ) { + abort( "Error installing dependencies." ); + } } echo(); } @@ -104,32 +112,37 @@ function getVersions() { abort( "The version must be a pre version." ); } - newVersion = currentVersion.substr( 0, currentVersion.length - 3 ); - parts = newVersion.split( "." ); - major = parseInt( parts[ 0 ], 10 ); - minor = parseInt( parts[ 1 ], 10 ); - patch = parseInt( parts[ 2 ], 10 ); + if ( preRelease ) { + newVersion = preRelease; + // Note: prevVersion is not currently used for pre-releases. The TODO + // below about 1.10.0 applies here as well. + prevVersion = nextVersion = currentVersion; + } else { + newVersion = currentVersion.substr( 0, currentVersion.length - 3 ); + parts = newVersion.split( "." ); + major = parseInt( parts[ 0 ], 10 ); + minor = parseInt( parts[ 1 ], 10 ); + patch = parseInt( parts[ 2 ], 10 ); - // TODO: handle 2.0.0 - if ( minor === 0 ) { - abort( "This script is not smart enough to handle the 2.0.0 release." ); - } + // TODO: handle 1.10.0 + // Also see comment above about pre-releases + if ( minor === 0 ) { + abort( "This script is not smart enough to handle the 1.10.0 release." ); + } - prevVersion = patch === 0 ? - [ major, minor - 1, 0 ].join( "." ) : - [ major, minor, patch - 1 ].join( "." ); - // TODO: Remove version hack after 1.9.0 release - if ( prevVersion === "1.8.0" ) { - prevVersion = "1.8"; + prevVersion = patch === 0 ? + [ major, minor - 1, 0 ].join( "." ) : + [ major, minor, patch - 1 ].join( "." ); + nextVersion = [ major, minor, patch + 1 ].join( "." ) + "pre"; } - nextVersion = [ major, minor, patch + 1 ].join( "." ) + "pre"; echo( "We are going from " + prevVersion.cyan + " to " + newVersion.cyan + "." ); echo( "After the release, the version will be " + nextVersion.cyan + "." ); } function buildRelease() { - var pkg; + var pkg, + releaseTask = preRelease ? "release" : "release_cdn"; echo( "Creating " + "release".cyan + " branch..." ); git( "checkout -b release", "Error creating release branch." ); @@ -151,7 +164,7 @@ function buildRelease() { echo(); echo( "Building release..." ); - if ( exec( "grunt release_cdn" ).code !== 0 ) { + if ( exec( "grunt " + releaseTask ).code !== 0 ) { abort( "Error building release." ); } echo(); @@ -173,6 +186,11 @@ function pushRelease() { } function updateBranchVersion() { + // Pre-releases don't change the master version + if ( preRelease ) { + return; + } + var pkg; echo( "Checking out " + branch.cyan + " branch..." ); @@ -189,11 +207,20 @@ function updateBranchVersion() { } function pushBranch() { + // Pre-releases don't change the master version + if ( preRelease ) { + return; + } + echo( "Pushing " + branch.cyan + " to GitHub..." ); git( "push", "Error pushing to GitHub." ); } function generateChangelog() { + if ( preRelease ) { + return; + } + var commits, changelogPath = baseDir + "/changelog", changelog = cat( "build/release/changelog-shell" ) + "\n", @@ -232,6 +259,10 @@ function generateChangelog() { } function gatherContributors() { + if ( preRelease ) { + return; + } + var contributors, contributorsPath = baseDir + "/contributors"; @@ -262,7 +293,9 @@ function gatherContributors() { function updateTrac() { echo( newVersion.cyan + " was tagged at " + tagTime.cyan + "." ); - echo( "Close the " + newVersion.cyan + " Milestone." ); + if ( !preRelease ) { + echo( "Close the " + newVersion.cyan + " Milestone." ); + } echo( "Create the " + newVersion.cyan + " Version." ); echo( "When Trac asks for date and time, match the above. Should only change minutes and seconds." ); echo( "Create a Milestone for the next minor release." ); @@ -329,6 +362,16 @@ function writePackage( pkg ) { } function bootstrap( fn ) { + console.log( "Determining release type..." ); + preRelease = process.argv.indexOf( "--pre-release" ); + if ( preRelease !== -1 ) { + preRelease = process.argv[ preRelease + 1 ]; + console.log( "pre-release" ); + } else { + preRelease = null; + console.log( "stable release" ); + } + console.log( "Determining directories..." ); baseDir = process.cwd() + "/__release"; repoDir = baseDir + "/repo"; From f6e99d2021bf9865673d08a4cef4d67ba7c586a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 13 Dec 2012 16:55:14 -0500 Subject: [PATCH 6/9] Autocomplete: Combobox demo - Collapse menu when clicking button. --- demos/autocomplete/combobox.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 6229d47b2..38c75e157 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -39,6 +39,7 @@ _create: function() { var input, that = this, + wasOpen = false, select = this.element.hide(), selected = select.children( ":selected" ), value = selected.val() ? selected.text() : "", @@ -129,20 +130,19 @@ }) .removeClass( "ui-corner-all" ) .addClass( "ui-corner-right ui-combobox-toggle" ) + .mousedown(function() { + wasOpen = input.autocomplete( "widget" ).is( ":visible" ); + }) .click(function() { + input.focus(); + // close if already visible - if ( input.autocomplete( "widget" ).is( ":visible" ) ) { - input.autocomplete( "close" ); - removeIfInvalid( input ); + if ( wasOpen ) { return; } - // work around a bug (likely same cause as #5265) - $( this ).blur(); - // pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); - input.focus(); }); input.tooltip({ From 2c1643509aee3cdeb0b5b7cc86a3cfa5ceb9fb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 14 Dec 2012 08:43:56 -0500 Subject: [PATCH 7/9] Dialog: Removed unnecessary style properties. --- themes/base/jquery.ui.dialog.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/themes/base/jquery.ui.dialog.css b/themes/base/jquery.ui.dialog.css index 563074a87..f377a2565 100644 --- a/themes/base/jquery.ui.dialog.css +++ b/themes/base/jquery.ui.dialog.css @@ -13,8 +13,6 @@ top: 0; left: 0; padding: .2em; - width: 300px; - overflow: hidden; outline: 0; } .ui-dialog .ui-dialog-titlebar { @@ -49,7 +47,7 @@ text-align: left; border-width: 1px 0 0 0; background-image: none; - margin: .5em 0 0 0; + margin-top: .5em; padding: .3em 1em .5em .4em; } .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { @@ -64,6 +62,7 @@ height: 12px; right: -5px; bottom: -5px; + background-position: 16px 16px; } .ui-draggable .ui-dialog-titlebar { cursor: move; From 80e46c93a84c8720cbd4aa206c46e4ac2a2d84f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 14 Dec 2012 09:10:32 -0500 Subject: [PATCH 8/9] Autocomplete: Append to closest .ui-front if available. --- .../unit/autocomplete/autocomplete_common.js | 2 +- .../unit/autocomplete/autocomplete_options.js | 8 ++++---- ui/jquery.ui.autocomplete.js | 20 +++++++++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/unit/autocomplete/autocomplete_common.js b/tests/unit/autocomplete/autocomplete_common.js index e1d24ef8d..63b24d384 100644 --- a/tests/unit/autocomplete/autocomplete_common.js +++ b/tests/unit/autocomplete/autocomplete_common.js @@ -1,6 +1,6 @@ TestHelpers.commonWidgetTests( "autocomplete", { defaults: { - appendTo: "body", + appendTo: null, autoFocus: false, delay: 300, disabled: false, diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index 913f5bc28..9f0bd2d43 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -18,11 +18,11 @@ test( "appendTo", function() { equal( $( "#ac-wrap2 .ui-autocomplete" ).length, 0, "only appends to one element" ); element.autocomplete( "destroy" ); - element.autocomplete({ - appendTo: null - }); - equal( element.autocomplete( "widget" ).parent()[0], document.body, "null" ); + $( "#ac-wrap2" ).addClass( "ui-front" ); + element.autocomplete(); + equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap2" )[0], "null, inside .ui-front" ); element.autocomplete( "destroy" ); + $( "#ac-wrap2" ).removeClass( "ui-front" ); element.autocomplete().autocomplete( "option", "appendTo", "#ac-wrap1" ); equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "modified after init" ); diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index a858b3382..65f702a28 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -23,7 +23,7 @@ $.widget( "ui.autocomplete", { version: "@VERSION", defaultElement: "", options: { - appendTo: "body", + appendTo: null, autoFocus: false, delay: 300, minLength: 1, @@ -323,10 +323,22 @@ $.widget( "ui.autocomplete", { _appendTo: function() { var element = this.options.appendTo; - if ( element && (element.jquery || element.nodeType) ) { - return $( element ); + + if ( element ) { + element = element.jquery || element.nodeType ? + $( element ) : + this.document.find( element ).eq( 0 ); } - return this.document.find( element || "body" ).eq( 0 ); + + if ( !element ) { + element = this.element.closest( ".ui-front" ); + } + + if ( !element.length ) { + element = this.document[0].body; + } + + return element; }, _isMultiLine: function() { From 8ec7a1b69ffd86edbef06e30ca4368600531e649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 14 Dec 2012 11:13:46 -0500 Subject: [PATCH 9/9] All: Use .addBack() instead of .andSelf(). --- tests/unit/button/button_core.js | 2 +- tests/unit/menu/menu_methods.js | 2 +- ui/jquery.ui.core.js | 11 ++++++++++- ui/jquery.ui.draggable.js | 2 +- ui/jquery.ui.droppable.js | 2 +- ui/jquery.ui.effect.js | 2 +- ui/jquery.ui.menu.js | 2 +- ui/jquery.ui.selectable.js | 2 +- ui/jquery.ui.slider.js | 2 +- ui/jquery.ui.sortable.js | 2 +- ui/jquery.ui.tooltip.js | 4 ++-- 11 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index 6d0bbbe88..dbc079818 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -138,7 +138,7 @@ test( "#7092 - button creation that requires a matching label does not find labe test( "#5946 - buttonset should ignore buttons that are not :visible", function() { expect( 2 ); - $( "#radio01" ).next().andSelf().hide(); + $( "#radio01" ).next().addBack().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" ) ); diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js index a7e78ea69..c51d123c2 100644 --- a/tests/unit/menu/menu_methods.js +++ b/tests/unit/menu/menu_methods.js @@ -64,7 +64,7 @@ test( "refresh submenu", function() { expect( 2 ); var element = $( "#menu2" ).menu(); equal( element.find( "ul:first .ui-menu-item" ).length, 3 ); - element.find( "ul" ).andSelf().append( "
  • New Item
  • " ); + element.find( "ul" ).addBack().append( "
  • New Item
  • " ); element.menu("refresh"); equal( element.find( "ul:first .ui-menu-item" ).length, 4 ); }); diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 4ad4f8a09..694cb1bef 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -152,7 +152,7 @@ function focusable( element, isTabIndexNotNaN ) { function visible( element ) { return $.expr.filters.visible( element ) && - !$( element ).parents().andSelf().filter(function() { + !$( element ).parents().addBack().filter(function() { return $.css( this, "visibility" ) === "hidden"; }).length; } @@ -227,6 +227,15 @@ if ( !$( "" ).outerWidth( 1 ).jquery ) { }); } +// support: jQuery <1.8 +if ( !$.fn.addBack ) { + $.fn.addBack = function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter( selector ) + ); + }; +} + // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413) if ( $( "" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { $.fn.removeData = (function( removeData ) { diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index b982ac6be..63a9b9114 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -280,7 +280,7 @@ $.widget("ui.draggable", $.ui.mouse, { var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; $(this.options.handle, this.element) .find("*") - .andSelf() + .addBack() .each(function() { if(this === event.target) { handle = true; diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index e2da0b9f6..a6959fd0f 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -235,7 +235,7 @@ $.ui.ddmanager = { var i, j, m = $.ui.ddmanager.droppables[t.options.scope] || [], type = event ? event.type : null, // workaround for #2317 - list = (t.currentItem || t.element).find(":data(ui-droppable)").andSelf(); + list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack(); droppablesLoop: for (i = 0; i < m.length; i++) { diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index d8d32e932..83d78a9b4 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -761,7 +761,7 @@ $.effects.animateClass = function( value, duration, easing, callback ) { var animated = $( this ), baseClass = animated.attr( "class" ) || "", applyClassChange, - allAnimations = o.children ? animated.find( "*" ).andSelf() : animated; + allAnimations = o.children ? animated.find( "*" ).addBack() : animated; // map the animated objects to store the original styles. allAnimations = allAnimations.map(function() { diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 41a69c472..7f37b6b06 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -139,7 +139,7 @@ $.widget( "ui.menu", { // Destroy (sub)menus this.element .removeAttr( "aria-activedescendant" ) - .find( ".ui-menu" ).andSelf() + .find( ".ui-menu" ).addBack() .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" ) .removeAttr( "role" ) .removeAttr( "tabIndex" ) diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js index a9b15b20b..164862d14 100644 --- a/ui/jquery.ui.selectable.js +++ b/ui/jquery.ui.selectable.js @@ -113,7 +113,7 @@ $.widget("ui.selectable", $.ui.mouse, { } }); - $(event.target).parents().andSelf().each(function() { + $(event.target).parents().addBack().each(function() { var doSelect, selectee = $.data(this, "selectable-item"); if (selectee) { diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 02fee8364..4054f1848 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -256,7 +256,7 @@ $.widget( "ui.slider", $.ui.mouse, { .focus(); offset = closestHandle.offset(); - mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" ); + mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" ); this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { left: event.pageX - offset.left - ( closestHandle.width() / 2 ), top: event.pageY - offset.top - diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index e142a0ede..08de5b22a 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -126,7 +126,7 @@ $.widget("ui.sortable", $.ui.mouse, { return false; } if(this.options.handle && !overrideHandle) { - $(this.options.handle, currentItem).find("*").andSelf().each(function() { + $(this.options.handle, currentItem).find("*").addBack().each(function() { if(this === event.target) { validHandle = true; } diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index ab8d5173c..3984826ce 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -113,7 +113,7 @@ $.widget( "ui.tooltip", { }); // remove title attributes to prevent native tooltips - this.element.find( this.options.items ).andSelf().each(function() { + this.element.find( this.options.items ).addBack().each(function() { var element = $( this ); if ( element.is( "[title]" ) ) { element @@ -125,7 +125,7 @@ $.widget( "ui.tooltip", { _enable: function() { // restore title attributes - this.element.find( this.options.items ).andSelf().each(function() { + this.element.find( this.options.items ).addBack().each(function() { var element = $( this ); if ( element.data( "ui-tooltip-title" ) ) { element.attr( "title", element.data( "ui-tooltip-title" ) );