From 176e0ed0e67f5a0f7a334d5d7b65638017a65349 Mon Sep 17 00:00:00 2001 From: Dominic Barnes Date: Tue, 8 Jan 2013 12:19:16 -0600 Subject: [PATCH 01/80] Slider: Moved events to named functions (to allow extended plugins to hook in). --- ui/jquery.ui.slider.js | 154 +++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 76 deletions(-) diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 658df7b2f..9640361a1 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -124,82 +124,7 @@ $.widget( "ui.slider", $.ui.mouse, { this._setOption( "disabled", o.disabled ); - this._on( this.handles, { - keydown: function( event ) { - /*jshint maxcomplexity:25*/ - var allowed, curVal, newVal, step, - index = $( event.target ).data( "ui-slider-handle-index" ); - - switch ( event.keyCode ) { - case $.ui.keyCode.HOME: - case $.ui.keyCode.END: - case $.ui.keyCode.PAGE_UP: - case $.ui.keyCode.PAGE_DOWN: - case $.ui.keyCode.UP: - case $.ui.keyCode.RIGHT: - case $.ui.keyCode.DOWN: - case $.ui.keyCode.LEFT: - event.preventDefault(); - if ( !this._keySliding ) { - this._keySliding = true; - $( event.target ).addClass( "ui-state-active" ); - allowed = this._start( event, index ); - if ( allowed === false ) { - return; - } - } - break; - } - - step = this.options.step; - if ( this.options.values && this.options.values.length ) { - curVal = newVal = this.values( index ); - } else { - curVal = newVal = this.value(); - } - - switch ( event.keyCode ) { - case $.ui.keyCode.HOME: - newVal = this._valueMin(); - break; - case $.ui.keyCode.END: - newVal = this._valueMax(); - break; - case $.ui.keyCode.PAGE_UP: - newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) ); - break; - case $.ui.keyCode.PAGE_DOWN: - newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) ); - break; - case $.ui.keyCode.UP: - case $.ui.keyCode.RIGHT: - if ( curVal === this._valueMax() ) { - return; - } - newVal = this._trimAlignValue( curVal + step ); - break; - case $.ui.keyCode.DOWN: - case $.ui.keyCode.LEFT: - if ( curVal === this._valueMin() ) { - return; - } - newVal = this._trimAlignValue( curVal - step ); - break; - } - - this._slide( event, index, newVal ); - }, - keyup: function( event ) { - var index = $( event.target ).data( "ui-slider-handle-index" ); - - if ( this._keySliding ) { - this._keySliding = false; - this._stop( event, index ); - this._change( event, index ); - $( event.target ).removeClass( "ui-state-active" ); - } - } - }); + this._on( this.handles, this._handleEvents ); this._refreshValue(); @@ -640,6 +565,83 @@ $.widget( "ui.slider", $.ui.mouse, { this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } ); } } + }, + + _handleEvents: { + keydown: function( event ) { + /*jshint maxcomplexity:25*/ + var allowed, curVal, newVal, step, + index = $( event.target ).data( "ui-slider-handle-index" ); + + switch ( event.keyCode ) { + case $.ui.keyCode.HOME: + case $.ui.keyCode.END: + case $.ui.keyCode.PAGE_UP: + case $.ui.keyCode.PAGE_DOWN: + case $.ui.keyCode.UP: + case $.ui.keyCode.RIGHT: + case $.ui.keyCode.DOWN: + case $.ui.keyCode.LEFT: + event.preventDefault(); + if ( !this._keySliding ) { + this._keySliding = true; + $( event.target ).addClass( "ui-state-active" ); + allowed = this._start( event, index ); + if ( allowed === false ) { + return; + } + } + break; + } + + step = this.options.step; + if ( this.options.values && this.options.values.length ) { + curVal = newVal = this.values( index ); + } else { + curVal = newVal = this.value(); + } + + switch ( event.keyCode ) { + case $.ui.keyCode.HOME: + newVal = this._valueMin(); + break; + case $.ui.keyCode.END: + newVal = this._valueMax(); + break; + case $.ui.keyCode.PAGE_UP: + newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) ); + break; + case $.ui.keyCode.PAGE_DOWN: + newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) ); + break; + case $.ui.keyCode.UP: + case $.ui.keyCode.RIGHT: + if ( curVal === this._valueMax() ) { + return; + } + newVal = this._trimAlignValue( curVal + step ); + break; + case $.ui.keyCode.DOWN: + case $.ui.keyCode.LEFT: + if ( curVal === this._valueMin() ) { + return; + } + newVal = this._trimAlignValue( curVal - step ); + break; + } + + this._slide( event, index, newVal ); + }, + keyup: function( event ) { + var index = $( event.target ).data( "ui-slider-handle-index" ); + + if ( this._keySliding ) { + this._keySliding = false; + this._stop( event, index ); + this._change( event, index ); + $( event.target ).removeClass( "ui-state-active" ); + } + } } }); From d403e5a50fade2eaf6508ac7cc050363f1006904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Mon, 14 Jan 2013 21:06:53 +0100 Subject: [PATCH 02/80] Build: Fix generate_themes task to adopt to changes in download builder. --- build/tasks/build.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 18e427a56..75cbca4a0 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -175,9 +175,10 @@ grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", fun }); grunt.registerTask( "generate_themes", function() { - var download, files, done, + var download, files, done, configContent, target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/", - distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ); + distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ), + configFile = "node_modules/download.jqueryui.com/config.json"; try { require.resolve( "download.jqueryui.com" ); } catch( error ) { @@ -186,8 +187,12 @@ grunt.registerTask( "generate_themes", function() { // copy release files into download builder to avoid cloning again grunt.file.expandFiles( distFolder + "/**" ).forEach(function( file ) { - grunt.file.copy( file, "node_modules/download.jqueryui.com/release/" + file.replace(/^dist/, "") ); + grunt.file.copy( file, "node_modules/download.jqueryui.com/release/" + file.replace(/^dist\/jquery-ui-/, "") ); }); + // make it look for the right version + configContent = grunt.file.readJSON( configFile ); + configContent.jqueryUi.stable.version = grunt.config( "pkg.version" ); + grunt.file.write( configFile, JSON.stringify( configContent, null, "\t" ) + "\n" ); download = new ( require( "download.jqueryui.com" ) )(); From 20cf7abef11e8d2bdbbbdbdb3c320f7f8aa871fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Mon, 14 Jan 2013 21:16:43 +0100 Subject: [PATCH 03/80] Updating the master version to 1.10.1pre. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eecb5f15d..e02dac05b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-ui", "title": "jQuery UI", "description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.", - "version": "1.10.0pre", + "version": "1.10.1pre", "homepage": "http://jqueryui.com", "author": { "name": "jQuery Foundation and other contributors", From 5549dfabba3bb876759531b09433ee0b9b0ad300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Mon, 14 Jan 2013 21:19:09 +0100 Subject: [PATCH 04/80] Revert "Updating the master version to 1.10.1pre." This reverts commit 20cf7abef11e8d2bdbbbdbdb3c320f7f8aa871fd. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e02dac05b..eecb5f15d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-ui", "title": "jQuery UI", "description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.", - "version": "1.10.1pre", + "version": "1.10.0pre", "homepage": "http://jqueryui.com", "author": { "name": "jQuery Foundation and other contributors", From d3d1e31e9fb8b264818bb711c35bdcb973687179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 15 Jan 2013 09:25:00 -0500 Subject: [PATCH 05/80] Spinner: Inherit font color since we inherit background color. Fixes #8950 - Spinner: value can't be seen in dark themes. --- themes/base/jquery.ui.spinner.css | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/base/jquery.ui.spinner.css b/themes/base/jquery.ui.spinner.css index db3f4100c..1504fc3f7 100644 --- a/themes/base/jquery.ui.spinner.css +++ b/themes/base/jquery.ui.spinner.css @@ -18,6 +18,7 @@ .ui-spinner-input { border: none; background: none; + color: inherit; padding: 0; margin: .2em 0; vertical-align: middle; From 722c4bed99485710df4123573b87362d7ed391ab Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Wed, 16 Jan 2013 11:15:16 -0600 Subject: [PATCH 06/80] Updating to jQuery Color 2.1.2 --- ui/jquery.ui.effect.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index 1609942f9..c6623a0a1 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -17,14 +17,14 @@ $.effects = { }; /*! - * jQuery Color Animations v2.1.2pre@b11ed286205199b8db74220cd237c4f045050e63 + * jQuery Color Animations v2.1.2 * https://github.com/jquery/jquery-color * - * Copyright 2012 jQuery Foundation and other contributors + * Copyright 2013 jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * - * Date: Thu Jan 3 14:21:32 2013 -0500 + * Date: Wed Jan 16 08:47:09 2013 -0600 */ (function( jQuery, undefined ) { From 1f65b3bca94d7b7d9f0a781bf7fe40979a6c6789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 16 Jan 2013 13:45:54 -0500 Subject: [PATCH 07/80] Whitespace. --- tests/unit/testsuite.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 42fdf4f9e..d2403beeb 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -28,9 +28,9 @@ QUnit.reset = function() { QUnit.config.requireExpects = true; QUnit.config.urlConfig.push({ - id: "min", - label: "Minified source", - tooltip: "Load minified source files instead of the regular unminified ones." + id: "min", + label: "Minified source", + tooltip: "Load minified source files instead of the regular unminified ones." }); TestHelpers.loadResources = QUnit.urlParams.min ? From 92bcef9305baf6d496d743f16e125d12820140cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 16 Jan 2013 13:59:27 -0500 Subject: [PATCH 08/80] Build: Check patch instead of minor to detect major releases. --- build/release/release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/release/release.js b/build/release/release.js index 3470b6575..2eab5283f 100644 --- a/build/release/release.js +++ b/build/release/release.js @@ -121,7 +121,7 @@ function getVersions() { // TODO: handle 1.10.0 // Also see comment above about pre-releases - if ( minor === 0 ) { + if ( patch === 0 ) { abort( "This script is not smart enough to handle the 1.10.0 release." ); } From 34409e7ddd58b3ccfed8175f7febd896ffea9e82 Mon Sep 17 00:00:00 2001 From: Kris Borchers Date: Thu, 17 Jan 2013 00:28:41 -0600 Subject: [PATCH 09/80] Updating to jQuery 1.9.0 --- build/tasks/testswarm.js | 1 + demos/accordion/collapsible.html | 2 +- demos/accordion/custom-icons.html | 2 +- demos/accordion/default.html | 2 +- demos/accordion/fillspace.html | 2 +- demos/accordion/hoverintent.html | 2 +- demos/accordion/no-auto-height.html | 2 +- demos/accordion/sortable.html | 2 +- demos/addClass/default.html | 2 +- demos/animate/default.html | 2 +- demos/autocomplete/categories.html | 2 +- demos/autocomplete/combobox.html | 2 +- demos/autocomplete/custom-data.html | 2 +- demos/autocomplete/default.html | 2 +- demos/autocomplete/folding.html | 2 +- demos/autocomplete/maxheight.html | 2 +- demos/autocomplete/multiple-remote.html | 2 +- demos/autocomplete/multiple.html | 2 +- demos/autocomplete/remote-jsonp.html | 2 +- demos/autocomplete/remote-with-cache.html | 2 +- demos/autocomplete/remote.html | 2 +- demos/autocomplete/xml.html | 2 +- demos/button/checkbox.html | 2 +- demos/button/default.html | 2 +- demos/button/icons.html | 2 +- demos/button/radio.html | 2 +- demos/button/splitbutton.html | 2 +- demos/button/toolbar.html | 2 +- demos/datepicker/alt-field.html | 2 +- demos/datepicker/animation.html | 2 +- demos/datepicker/buttonbar.html | 2 +- demos/datepicker/date-formats.html | 2 +- demos/datepicker/date-range.html | 2 +- demos/datepicker/default.html | 2 +- demos/datepicker/dropdown-month-year.html | 2 +- demos/datepicker/icon-trigger.html | 2 +- demos/datepicker/inline.html | 2 +- demos/datepicker/localization.html | 2 +- demos/datepicker/min-max.html | 2 +- demos/datepicker/multiple-calendars.html | 2 +- demos/datepicker/other-months.html | 2 +- demos/datepicker/show-week.html | 2 +- demos/dialog/animated.html | 2 +- demos/dialog/default.html | 2 +- demos/dialog/modal-confirmation.html | 2 +- demos/dialog/modal-form.html | 2 +- demos/dialog/modal-message.html | 2 +- demos/dialog/modal.html | 2 +- demos/draggable/constrain-movement.html | 2 +- demos/draggable/cursor-style.html | 2 +- demos/draggable/default.html | 2 +- demos/draggable/delay-start.html | 2 +- demos/draggable/events.html | 2 +- demos/draggable/handle.html | 2 +- demos/draggable/revert.html | 2 +- demos/draggable/scroll.html | 2 +- demos/draggable/snap-to.html | 2 +- demos/draggable/sortable.html | 2 +- demos/draggable/visual-feedback.html | 2 +- demos/droppable/accepted-elements.html | 2 +- demos/droppable/default.html | 2 +- demos/droppable/photo-manager.html | 2 +- demos/droppable/propagation.html | 2 +- demos/droppable/revert.html | 2 +- demos/droppable/shopping-cart.html | 2 +- demos/droppable/visual-feedback.html | 2 +- demos/effect/default.html | 2 +- demos/effect/easing.html | 2 +- demos/hide/default.html | 4 +- demos/menu/default.html | 2 +- demos/menu/icons.html | 2 +- demos/position/cycler.html | 2 +- demos/position/default.html | 2 +- demos/progressbar/default.html | 2 +- demos/progressbar/indeterminate.html | 2 +- demos/progressbar/label.html | 2 +- demos/removeClass/default.html | 4 +- demos/resizable/animate.html | 2 +- demos/resizable/aspect-ratio.html | 2 +- demos/resizable/constrain-area.html | 2 +- demos/resizable/default.html | 2 +- demos/resizable/delay-start.html | 2 +- demos/resizable/helper.html | 2 +- demos/resizable/max-min.html | 2 +- demos/resizable/snap-to-grid.html | 2 +- demos/resizable/synchronous-resize.html | 2 +- demos/resizable/textarea.html | 2 +- demos/resizable/visual-feedback.html | 2 +- demos/selectable/default.html | 2 +- demos/selectable/display-grid.html | 2 +- demos/selectable/serialize.html | 2 +- demos/show/default.html | 2 +- demos/slider/colorpicker.html | 2 +- demos/slider/default.html | 2 +- demos/slider/hotelrooms.html | 2 +- demos/slider/multiple-vertical.html | 2 +- demos/slider/range-vertical.html | 2 +- demos/slider/range.html | 2 +- demos/slider/rangemax.html | 2 +- demos/slider/rangemin.html | 2 +- demos/slider/side-scroll.html | 16 +- demos/slider/slider-vertical.html | 2 +- demos/slider/steps.html | 2 +- .../sortable/connect-lists-through-tabs.html | 2 +- demos/sortable/connect-lists.html | 2 +- demos/sortable/default.html | 2 +- demos/sortable/delay-start.html | 2 +- demos/sortable/display-grid.html | 2 +- demos/sortable/empty-lists.html | 2 +- demos/sortable/items.html | 4 +- demos/sortable/placeholder.html | 2 +- demos/sortable/portlets.html | 2 +- demos/spinner/currency.html | 2 +- demos/spinner/decimal.html | 2 +- demos/spinner/default.html | 2 +- demos/spinner/latlong.html | 2 +- demos/spinner/overflow.html | 2 +- demos/spinner/time.html | 2 +- demos/switchClass/default.html | 4 +- demos/tabs/ajax.html | 2 +- demos/tabs/bottom.html | 2 +- demos/tabs/collapsible.html | 2 +- demos/tabs/default.html | 2 +- demos/tabs/manipulation.html | 2 +- demos/tabs/mouseover.html | 2 +- demos/tabs/sortable.html | 2 +- demos/tabs/vertical.html | 2 +- demos/toggle/default.html | 2 +- demos/toggleClass/default.html | 4 +- demos/tooltip/custom-animation.html | 2 +- demos/tooltip/custom-content.html | 2 +- demos/tooltip/custom-style.html | 2 +- demos/tooltip/default.html | 2 +- demos/tooltip/forms.html | 2 +- demos/tooltip/tracking.html | 2 +- demos/tooltip/video-player.html | 2 +- demos/widget/default.html | 2 +- jquery-1.8.3.js => jquery-1.9.0.js | 5493 +++++----- tests/index.html | 2 +- tests/jquery-1.9.0.js | 9555 +++++++++++++++++ tests/jquery.js | 2 +- tests/unit/accordion/all.html | 2 +- tests/unit/all.html | 2 +- tests/unit/autocomplete/all.html | 2 +- tests/unit/button/all.html | 2 +- tests/unit/core/all.html | 2 +- tests/unit/datepicker/all.html | 2 +- tests/unit/dialog/all.html | 2 +- tests/unit/draggable/all.html | 2 +- tests/unit/droppable/all.html | 2 +- tests/unit/effects/all.html | 2 +- tests/unit/index.html | 2 +- tests/unit/menu/all.html | 2 +- tests/unit/position/all.html | 2 +- tests/unit/progressbar/all.html | 2 +- tests/unit/resizable/all.html | 2 +- tests/unit/selectable/all.html | 2 +- tests/unit/slider/all.html | 2 +- tests/unit/sortable/all.html | 2 +- tests/unit/spinner/all.html | 2 +- tests/unit/subsuite.js | 1 + tests/unit/tabs/all.html | 2 +- tests/unit/tooltip/all.html | 2 +- tests/unit/widget/all.html | 2 +- tests/visual/accordion/icons.html | 2 +- tests/visual/addClass/queue.html | 2 +- tests/visual/button/button.html | 2 +- tests/visual/button/performance.html | 2 +- tests/visual/compound/accordion_tabs.html | 2 +- tests/visual/compound/datepicker_dialog.html | 2 +- tests/visual/compound/dialog_widgets.html | 2 +- .../visual/compound/draggable_accordion.html | 2 +- ...le_accordion_accordion_tabs_draggable.html | 2 +- .../sortable_accordion_sortable_tabs.html | 2 +- tests/visual/compound/tabs_tabs.html | 2 +- tests/visual/compound/tabs_tooltips.html | 2 +- tests/visual/dialog/animated.html | 2 +- tests/visual/dialog/complex-dialogs.html | 2 +- tests/visual/dialog/form.html | 2 +- tests/visual/dialog/performance.html | 4 +- tests/visual/effects/all.html | 2 +- tests/visual/effects/scale.html | 4 +- tests/visual/index.html | 2 +- tests/visual/menu/menu.html | 4 +- tests/visual/position/position.html | 2 +- tests/visual/position/position_feedback.html | 2 +- tests/visual/theme.html | 2 +- tests/visual/tooltip/animations.html | 2 +- tests/visual/tooltip/tooltip.html | 2 +- 189 files changed, 12545 insertions(+), 2905 deletions(-) rename jquery-1.8.3.js => jquery-1.9.0.js (71%) create mode 100644 tests/jquery-1.9.0.js diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index 8e88007bb..cbc502bc3 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -4,6 +4,7 @@ module.exports = function( grunt ) { var versions = { "git": "git", + "1.9": "1.9.0", "1.8": "1.8.0 1.8.1 1.8.2 1.8.3", "1.7": "1.7 1.7.1 1.7.2", "1.6": "1.6 1.6.1 1.6.2 1.6.3 1.6.4" diff --git a/demos/accordion/collapsible.html b/demos/accordion/collapsible.html index 358ff618c..47c2cbff9 100644 --- a/demos/accordion/collapsible.html +++ b/demos/accordion/collapsible.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Collapse content - + diff --git a/demos/accordion/custom-icons.html b/demos/accordion/custom-icons.html index 56a9d450c..48b0ea745 100644 --- a/demos/accordion/custom-icons.html +++ b/demos/accordion/custom-icons.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Customize icons - + diff --git a/demos/accordion/default.html b/demos/accordion/default.html index 311717a40..e64159e37 100644 --- a/demos/accordion/default.html +++ b/demos/accordion/default.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Default functionality - + diff --git a/demos/accordion/fillspace.html b/demos/accordion/fillspace.html index 1e7df6596..5baf6c5d2 100644 --- a/demos/accordion/fillspace.html +++ b/demos/accordion/fillspace.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Fill space - + diff --git a/demos/accordion/hoverintent.html b/demos/accordion/hoverintent.html index ce195c05f..158645519 100644 --- a/demos/accordion/hoverintent.html +++ b/demos/accordion/hoverintent.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Open on hoverintent - + diff --git a/demos/accordion/no-auto-height.html b/demos/accordion/no-auto-height.html index 2edaa10ea..679444ae7 100644 --- a/demos/accordion/no-auto-height.html +++ b/demos/accordion/no-auto-height.html @@ -4,7 +4,7 @@ jQuery UI Accordion - No auto height - + diff --git a/demos/accordion/sortable.html b/demos/accordion/sortable.html index 56020efbe..1596ed34b 100644 --- a/demos/accordion/sortable.html +++ b/demos/accordion/sortable.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Sortable - + diff --git a/demos/addClass/default.html b/demos/addClass/default.html index a0c1ceb14..db2bd7e53 100644 --- a/demos/addClass/default.html +++ b/demos/addClass/default.html @@ -4,7 +4,7 @@ jQuery UI Effects - addClass demo - + + @@ -39,13 +45,14 @@

    -
    Relative
    Absolute
    +
    +
    diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index a3f7169f2..8496d6182 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -723,4 +723,39 @@ test("{ zIndex: 10 }", function() { }); +test( "{ stack }", function() { + expect( 4 ); + + var draggable1 = $( "#draggable1" ), + draggable2 = $( "#draggable2" ), + draggable3 = $( "#draggable3" ), + draggable4 = $( "#draggable4" ); + + // Set z-index as an inline style. + $( "#draggable1, #draggable2" ) + .css( "zIndex", 100 ) + .draggable({ + stack: "#draggable1, #draggable2" + }); + // Have z-index applied via CSS, see #9077 + $( "#draggable3, #draggable4" ) + .draggable({ + stack: "#draggable3, #draggable4" + }); + + draggable1.simulate( "drag", { + dx: 1, + dy: 1 + }); + draggable3.simulate( "drag", { + dx: 1, + dy: 1 + }); + + equal( draggable1.css( "zIndex" ), 102); + equal( draggable2.css( "zIndex" ), 101); + equal( draggable3.css( "zIndex" ), 102); + equal( draggable4.css( "zIndex" ), 101); +}); + })(jQuery); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 9a31add7c..b8d21bd80 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -917,13 +917,12 @@ $.ui.plugin.add("draggable", "stack", { if (!group.length) { return; } - min = parseInt(group[0].style.zIndex, 10) || 0; + min = parseInt($(group[0]).css("zIndex"), 10) || 0; $(group).each(function(i) { - this.style.zIndex = min + i; + $(this).css("zIndex", min + i); }); - this[0].style.zIndex = min + group.length; - + $(this[0]).css("zIndex", (min + group.length)); } }); From c958b211db2632a02f26e14f57c0862c57870aee Mon Sep 17 00:00:00 2001 From: David Petersen Date: Mon, 11 Feb 2013 20:04:28 -0600 Subject: [PATCH 47/80] Position: Handle decimal percentage offsets. Fixes #9076: percentage offset does not support decimal --- tests/unit/position/position_core.js | 26 +++++++++++++++++++++++++- ui/jquery.ui.position.js | 6 +++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 7b51223ac..cefd7929c 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -221,7 +221,7 @@ test( "of", function() { }); test( "offsets", function() { - expect( 4 ); + expect( 7 ); $( "#elx" ).position({ my: "left top", @@ -254,6 +254,30 @@ test( "offsets", function() { collision: "none" }); deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "percentage offsets in my" ); + + $( "#elx" ).position({ + my: "left-30.001% top+50.0%", + at: "left bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "decimal percentage offsets in my" ); + + $( "#elx" ).position({ + my: "left+10.4 top-10.6", + at: "left bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 49, left: 50 }, "decimal offsets in my" ); + + $( "#elx" ).position({ + my: "left+right top-left", + at: "left-top bottom-bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 60, left: 40 }, "invalid offsets" ); }); test( "using", function() { diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 0209b442c..81f1e4e8a 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -18,15 +18,15 @@ var cachedScrollbarWidth, round = Math.round, rhorizontal = /left|center|right/, rvertical = /top|center|bottom/, - roffset = /[\+\-]\d+%?/, + roffset = /[\+\-]\d+(\.[\d]+)?%?/, rposition = /^\w+/, rpercent = /%$/, _position = $.fn.position; function getOffsets( offsets, width, height ) { return [ - parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), - parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) + parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), + parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) ]; } From bce9da420646b6cee859475af6616aa9107f0158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 12 Feb 2013 09:57:29 -0500 Subject: [PATCH 48/80] Datepicker i18n: Change Slovak day/month names to lowercase. Fixes #9078 - Datepicker Slovak localisation - name of day/month is always lowercase. --- ui/i18n/jquery.ui.datepicker-sk.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/i18n/jquery.ui.datepicker-sk.js b/ui/i18n/jquery.ui.datepicker-sk.js index 83ae8e811..0cb76c4e8 100644 --- a/ui/i18n/jquery.ui.datepicker-sk.js +++ b/ui/i18n/jquery.ui.datepicker-sk.js @@ -6,11 +6,11 @@ jQuery(function($){ prevText: '<Predchádzajúci', nextText: 'Nasledujúci>', currentText: 'Dnes', - monthNames: ['Január','Február','Marec','Apríl','Máj','Jún', - 'Júl','August','September','Október','November','December'], + monthNames: ['január','február','marec','apríl','máj','jún', + 'júl','august','september','október','november','december'], monthNamesShort: ['Jan','Feb','Mar','Apr','Máj','Jún', 'Júl','Aug','Sep','Okt','Nov','Dec'], - dayNames: ['Nedeľa','Pondelok','Utorok','Streda','Štvrtok','Piatok','Sobota'], + dayNames: ['nedeľa','pondelok','utorok','streda','štvrtok','piatok','sobota'], dayNamesShort: ['Ned','Pon','Uto','Str','Štv','Pia','Sob'], dayNamesMin: ['Ne','Po','Ut','St','Št','Pia','So'], weekHeader: 'Ty', From 3d39d8c32f7b4777c8272fbdd9d24d54ca00dffc Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Tue, 12 Feb 2013 21:27:21 -0500 Subject: [PATCH 49/80] Removing unnecessary wrapping of this in draggable's stack option handling. --- ui/jquery.ui.draggable.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index b8d21bd80..8b388d166 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -908,9 +908,8 @@ $.ui.plugin.add("draggable", "snap", { $.ui.plugin.add("draggable", "stack", { start: function() { - var min, - o = $(this).data("ui-draggable").options, + o = this.data("ui-draggable").options, group = $.makeArray($(o.stack)).sort(function(a,b) { return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); }); @@ -921,8 +920,7 @@ $.ui.plugin.add("draggable", "stack", { $(group).each(function(i) { $(this).css("zIndex", min + i); }); - - $(this[0]).css("zIndex", (min + group.length)); + this.css("zIndex", (min + group.length)); } }); From cb42ee7ccdf6e32be14341a34a037c7f4508c157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 13 Feb 2013 09:06:02 -0500 Subject: [PATCH 50/80] Theme: Collapse border in .ui-helper-cleafix. Fixes #8442 - CSS: ui-helper-clearfix bug within table with border spacing. --- themes/base/jquery.ui.core.css | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/base/jquery.ui.core.css b/themes/base/jquery.ui.core.css index dc1216f70..c644bb30f 100644 --- a/themes/base/jquery.ui.core.css +++ b/themes/base/jquery.ui.core.css @@ -38,6 +38,7 @@ .ui-helper-clearfix:after { content: ""; display: table; + border-collapse: collapse; } .ui-helper-clearfix:after { clear: both; From 0be269d32cbaac3f166da8a714ddb6e1d919db53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 13 Feb 2013 10:30:08 -0500 Subject: [PATCH 51/80] Updated AUTHORS.txt. --- AUTHORS.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index bc7c89d79..2a7a396c8 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -231,3 +231,8 @@ Pavel Selitskas Bjørn Johansen Matthieu Penant Dominic Barnes +David Sullivan +Thomas Jaggi +Vahid Sohrabloo +Travis Carden +Bruno M. Custódio From 822520ece7520457c045b1dae77b6ffc5b96654a Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Wed, 13 Feb 2013 18:56:35 -0200 Subject: [PATCH 52/80] Grunt: update generate_themes task to use the new DownloadBuilder API - DownloadBuilder accepts the config file as an option. It's not necessary to workaround it by changing the DownloadBuilder config file anymore; - DownloadBuilder has exposed a method to generate the theme gallery bundle; --- build/tasks/build.js | 71 ++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 75cbca4a0..cef984198 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -175,67 +175,42 @@ grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", fun }); grunt.registerTask( "generate_themes", function() { - var download, files, done, configContent, - target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/", + var download, done, distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ), - configFile = "node_modules/download.jqueryui.com/config.json"; + target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/"; + try { require.resolve( "download.jqueryui.com" ); } catch( error ) { throw new Error( "You need to manually install download.jqueryui.com for this task to work" ); } - // copy release files into download builder to avoid cloning again - grunt.file.expandFiles( distFolder + "/**" ).forEach(function( file ) { - grunt.file.copy( file, "node_modules/download.jqueryui.com/release/" + file.replace(/^dist\/jquery-ui-/, "") ); - }); - // make it look for the right version - configContent = grunt.file.readJSON( configFile ); - configContent.jqueryUi.stable.version = grunt.config( "pkg.version" ); - grunt.file.write( configFile, JSON.stringify( configContent, null, "\t" ) + "\n" ); - - download = new ( require( "download.jqueryui.com" ) )(); - - files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" ); - files.forEach(function( fileName ) { - grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) ); + download = require( "download.jqueryui.com" )({ + config: { + "jqueryUi": { + "stable": { "path": path.resolve( __dirname + "/../../" + distFolder ) } + }, + "jquery": "skip" + } }); done = this.async(); - grunt.utils.async.forEach( download.themeroller.gallery(), function( theme, done ) { - var folderName = theme.folderName(), - concatTarget = "css-" + folderName, - cssContent = theme.css(), - cssFolderName = target + "themes/" + folderName + "/", - cssFileName = cssFolderName + "jquery.ui.theme.css", - cssFiles = grunt.config.get( "concat.css.src" )[ 1 ].slice(); - - grunt.file.write( cssFileName, cssContent ); - - // get css components, replace the last file with the current theme - cssFiles.splice(-1); - cssFiles.push( "" ); - grunt.config.get( "concat" )[ concatTarget ] = { - src: [ "", cssFiles ], - dest: cssFolderName + "jquery-ui.css" - }; - grunt.task.run( "concat:" + concatTarget ); - - theme.fetchImages(function( err, files ) { - if ( err ) { - done( err ); - return; - } - files.forEach(function( file ) { - grunt.file.write( cssFolderName + "images/" + file.path, file.data ); - }); - done(); - }); - }, function( err ) { + download.buildThemesBundle(function( err, files ) { if ( err ) { grunt.log.error( err ); + return done( false ); } - done( !err ); + done( + files.every(function( file ) { + try { + grunt.file.write( target + file.path, file.data ); + } catch( err ) { + grunt.log.error( err ); + return false; + } + return true; + }) && grunt.log.writeln( "Generated at " + target ) + ); }); }); From 56de05cf9d8a0b5fbab66c9dd868221e022738f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 15 Feb 2013 12:41:18 -0500 Subject: [PATCH 53/80] Build: Cleanup. --- build/tasks/build.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index cef984198..34f6ece29 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -178,7 +178,7 @@ grunt.registerTask( "generate_themes", function() { var download, done, distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ), target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/"; - + try { require.resolve( "download.jqueryui.com" ); } catch( error ) { @@ -195,11 +195,12 @@ grunt.registerTask( "generate_themes", function() { }); done = this.async(); - download.buildThemesBundle(function( err, files ) { - if ( err ) { - grunt.log.error( err ); + download.buildThemesBundle(function( error, files ) { + if ( error ) { + grunt.log.error( error ); return done( false ); } + done( files.every(function( file ) { try { From 6fe3c62e08dff0dde014e42a544afe1ced4ec91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 15 Feb 2013 12:41:39 -0500 Subject: [PATCH 54/80] Build: Use fs.existsSync() instead of path.existsSync(). --- build/tasks/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 34f6ece29..a8f25f98f 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -159,7 +159,7 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { // remove dest file before creating it, to make sure itself is not included - if ( path.existsSync( this.file.dest ) ) { + if ( fs.existsSync( this.file.dest ) ) { fs.unlinkSync( this.file.dest ); } var crypto = require( "crypto" ), From f78c8ca22c12fbfc72f6b9b1964739f864f90dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 15 Feb 2013 15:07:15 -0500 Subject: [PATCH 55/80] Updating the master version to 1.10.2pre. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 15fe7daff..ae8b13dc8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-ui", "title": "jQuery UI", "description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.", - "version": "1.10.1pre", + "version": "1.10.2pre", "homepage": "http://jqueryui.com", "author": { "name": "jQuery Foundation and other contributors", From a692bf9b70305de5e9893e717fc71e1e74fb86ac Mon Sep 17 00:00:00 2001 From: Nathanael Silverman Date: Wed, 13 Feb 2013 17:34:52 +0100 Subject: [PATCH 56/80] Sortable: Inject a CSS rule to style the cursor. Fixed #7389 - sortable: 'cursor' option didn't override CSS cursor settings. --- ui/jquery.ui.sortable.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 211ff272e..c9b503bd0 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -158,7 +158,7 @@ $.widget("ui.sortable", $.ui.mouse, { _mouseStart: function(event, overrideHandle, noActivation) { - var i, + var i, body, o = this.options; this.currentContainer = this; @@ -228,11 +228,14 @@ $.widget("ui.sortable", $.ui.mouse, { this._setContainment(); } - if(o.cursor) { // cursor option - if ($("body").css("cursor")) { - this._storedCursor = $("body").css("cursor"); - } - $("body").css("cursor", o.cursor); + if( o.cursor && o.cursor !== "auto" ) { // cursor option + body = this.document.find( "body" ); + + // support: IE + this.storedCursor = body.css( "cursor" ); + body.css( "cursor", o.cursor ); + + this.storedStylesheet = $( "" ).appendTo( body ); } if(o.opacity) { // opacity option @@ -1178,8 +1181,9 @@ $.widget("ui.sortable", $.ui.mouse, { } //Do what was originally in plugins - if(this._storedCursor) { - $("body").css("cursor", this._storedCursor); + if ( this.storedCursor ) { + this.document.find( "body" ).css( "cursor", this.storedCursor ); + this.storedStylesheet.remove(); } if(this._storedOpacity) { this.helper.css("opacity", this._storedOpacity); From 5e1b8dc71a72d5753a95c49c844857b91fbdbade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 18 Feb 2013 16:07:15 -0500 Subject: [PATCH 57/80] Dialog: Don't hard-code widget data key. Fixes #9097 - UI dialog inheritance. --- ui/jquery.ui.dialog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 85dbddda2..9d61cf745 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -697,6 +697,7 @@ $.widget( "ui.dialog", { return; } + var widgetFullName = this.widgetFullName; if ( !$.ui.dialog.overlayInstances ) { // Prevent use of anchors and inputs. // We use a delay in case the overlay is created from an @@ -711,7 +712,7 @@ $.widget( "ui.dialog", { !$( event.target ).closest(".ui-datepicker").length ) { event.preventDefault(); $(".ui-dialog:visible:last .ui-dialog-content") - .data("ui-dialog")._focusTabbable(); + .data( widgetFullName )._focusTabbable(); } }); } From 10ca48308fea6a9b30d2457fbf5a1b6e0ed5966c Mon Sep 17 00:00:00 2001 From: Christian Wenz Date: Mon, 18 Feb 2013 18:35:10 -0800 Subject: [PATCH 58/80] Datepicker: Updated German locale. Fixes #9098 - Datepicker German localization - make casing of previous/next/today consistent. --- ui/i18n/jquery.ui.datepicker-de.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/i18n/jquery.ui.datepicker-de.js b/ui/i18n/jquery.ui.datepicker-de.js index cfe91759b..abe75c4e4 100644 --- a/ui/i18n/jquery.ui.datepicker-de.js +++ b/ui/i18n/jquery.ui.datepicker-de.js @@ -2,10 +2,10 @@ /* Written by Milian Wolff (mail@milianw.de). */ jQuery(function($){ $.datepicker.regional['de'] = { - closeText: 'schließen', - prevText: '<zurück', + closeText: 'Schließen', + prevText: '<Zurück', nextText: 'Vor>', - currentText: 'heute', + currentText: 'Heute', monthNames: ['Januar','Februar','März','April','Mai','Juni', 'Juli','August','September','Oktober','November','Dezember'], monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun', From 51eb28e76e372fe0af12724edff0b5780b5e5ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 20 Feb 2013 17:35:48 -0500 Subject: [PATCH 59/80] Dialog: Extract check for which elements can gain focus into its own method for overriding. Fixes #9087 - Dialog: Allow registering elements outside a dialog for use when a modal dialog is open. --- ui/jquery.ui.dialog.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 9d61cf745..b35c0ffcf 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -692,12 +692,23 @@ $.widget( "ui.dialog", { } }, + _allowInteraction: function( event ) { + 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; + }, + _createOverlay: function() { if ( !this.options.modal ) { return; } - var widgetFullName = this.widgetFullName; + var that = this, + widgetFullName = this.widgetFullName; if ( !$.ui.dialog.overlayInstances ) { // Prevent use of anchors and inputs. // We use a delay in case the overlay is created from an @@ -706,10 +717,7 @@ $.widget( "ui.dialog", { // Handle .dialog().dialog("close") (#4065) if ( $.ui.dialog.overlayInstances ) { this.document.bind( "focusin.dialog", function( event ) { - if ( !$( event.target ).closest(".ui-dialog").length && - // TODO: Remove hack when datepicker implements - // the .ui-front logic (#8989) - !$( event.target ).closest(".ui-datepicker").length ) { + if ( !that._allowInteraction( event ) ) { event.preventDefault(); $(".ui-dialog:visible:last .ui-dialog-content") .data( widgetFullName )._focusTabbable(); From bd47bd4ace3789d9eb302b0dce6f6e042d08a7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 20 Feb 2013 20:16:29 -0500 Subject: [PATCH 60/80] Sortable: When sorting table rows, create a td to force dimensions. Fixes #4765 - Sortable: Placeholder not displayed when sorting table rows. --- tests/unit/sortable/sortable.html | 21 +++++++++++++++ tests/unit/sortable/sortable_options.js | 34 +++++++++++++++++++++++-- ui/jquery.ui.sortable.js | 20 ++++++++++----- 3 files changed, 67 insertions(+), 8 deletions(-) diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index c23a15854..6e326a865 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -63,6 +63,27 @@
  1. Item 5
  2. + + + + + + + + + + + + + + + + + + + +
    12
    34
    56
    78
    + diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index cf35aedb1..fe50be002 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -185,11 +185,41 @@ test("{ opacity: 1 }", function() { test("{ placeholder: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); +*/ +test( "{ placeholder: String }", function() { + expect( 1 ); -test("{ placeholder: String }", function() { - ok(false, "missing test - untested code is broken code."); + var element = $( "#sortable" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); + } + }); + + element.find( "li" ).eq( 0 ).simulate( "drag", { + dy: 1 + }); }); +test( "{ placholder: String } tr", function() { + expect( 3 ); + + var element = $( "#sortable-table tbody" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); + equal( ui.placeholder.children().length, 1, "placeholder tr contains a td" ); + equal( ui.placeholder.children().html(), $( " " ).html(), + "placeholder td has content for forced dimensions" ); + } + }); + + element.find( "tr" ).eq( 0 ).simulate( "drag", { + dy: 1 + }); +}); + +/* test("{ revert: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index c9b503bd0..f095ce9c5 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -752,15 +752,23 @@ $.widget("ui.sortable", $.ui.mouse, { o.placeholder = { element: function() { - var el = $(document.createElement(that.currentItem[0].nodeName)) - .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") - .removeClass("ui-sortable-helper")[0]; + var nodeName = that.currentItem[0].nodeName.toLowerCase(), + element = $( that.document[0].createElement( nodeName ) ) + .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") + .removeClass("ui-sortable-helper"); - if(!className) { - el.style.visibility = "hidden"; + if ( nodeName === "tr" ) { + // Use a high colspan to force the td to expand the full + // width of the table (browsers are smart enough to + // handle this properly) + element.append( " " ); } - return el; + if ( !className ) { + element.css( "visibility", "hidden" ); + } + + return element; }, update: function(container, p) { From a924af12b6743408903c642f84a00b0766cd17b7 Mon Sep 17 00:00:00 2001 From: Steve Urmston Date: Tue, 19 Feb 2013 22:58:31 +0000 Subject: [PATCH 61/80] Draggable: Revert flag honours Sortable revert speed. Fixed #9103 Draggable: revert option reset after being added to a connectedSortable. --- ui/jquery.ui.draggable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 8b388d166..27b6b4ef0 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -600,7 +600,7 @@ $.ui.plugin.add("draggable", "connectToSortable", { //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid" if(this.shouldRevert) { - this.instance.options.revert = true; + this.instance.options.revert = this.shouldRevert; } //Trigger the stop of the sortable From 1c5171c2547130a76710dd20108b35774551e333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 22 Feb 2013 08:53:03 -0500 Subject: [PATCH 62/80] Tabs: Use border-bottom-width instead of border-bottom to remove the border on tabs. Fixes #9111 - Tabs: Can't inherit border-bottom-color for vertical tabs. --- themes/base/jquery.ui.tabs.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/base/jquery.ui.tabs.css b/themes/base/jquery.ui.tabs.css index 6c35e193e..b8f77b040 100644 --- a/themes/base/jquery.ui.tabs.css +++ b/themes/base/jquery.ui.tabs.css @@ -22,7 +22,7 @@ position: relative; top: 0; margin: 1px .2em 0 0; - border-bottom: 0; + border-bottom-width: 0; padding: 0; white-space: nowrap; } From 2348fb8eb9ec1297a2588a23cf3447c5374bcb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 22 Feb 2013 09:15:43 -0500 Subject: [PATCH 63/80] Spinner: Call _stop() on blur. Fixes #9112 - Spinner keeps changing after losing focus. --- tests/unit/spinner/spinner_core.js | 27 +++++++++++++++++++++++++++ ui/jquery.ui.spinner.js | 1 + 2 files changed, 28 insertions(+) diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js index a1179bb35..bea5f9122 100644 --- a/tests/unit/spinner/spinner_core.js +++ b/tests/unit/spinner/spinner_core.js @@ -80,6 +80,33 @@ test( "keydown PAGE_DOWN on input, decreases value not less than min", function( equal( element.val(), 20 ); }); +asyncTest( "blur input while spinning with UP", function() { + expect( 3 ); + var value, + element = $( "#spin" ).val( 10 ).spinner(); + + function step1() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal( element.val(), 11 ); + setTimeout( step2, 750 ); + } + + function step2() { + value = element.val(); + ok( value > 11, "repeating while key is down" ); + element[0].blur(); + setTimeout( step3, 250 ); + } + + function step3() { + equal( element.val(), value, "stopped repeating on blur" ); + start(); + } + + element[ 0 ].focus(); + setTimeout( step1 ); +}); + test( "mouse click on up button, increases value not greater than max", function() { expect( 3 ); var element = $( "#spin" ).val( 18 ).spinner({ diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index c14ef9370..644b65239 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -102,6 +102,7 @@ $.widget( "ui.spinner", { return; } + this._stop(); this._refresh(); if ( this.previous !== this.element.val() ) { this._trigger( "change", event ); From ba96cb47725dc6639ae366bd381f089c1750c8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 19 Feb 2013 14:46:30 -0500 Subject: [PATCH 64/80] Autocomplete demo (Combobox): Don't highlight term matches. Fixes #9086 - Autocomplete: Incorrect escaping in combobox demo. --- demos/autocomplete/combobox.html | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 0d59db670..c5ef93576 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -48,11 +48,10 @@ .insertAfter( select ); function removeIfInvalid( element ) { - var value = $( element ).val(), - matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( value ) + "$", "i" ), + var value = $( element ).val().toLowerCase(), valid = false; select.children( "option" ).each(function() { - if ( $( this ).text().match( matcher ) ) { + if ( $( this ).text().toLowerCase() === value ) { this.selected = valid = true; return false; } @@ -86,12 +85,7 @@ var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { - label: text.replace( - new RegExp( - "(?![^&;]+;)(?!<[^<>]*)(" + - $.ui.autocomplete.escapeRegex(request.term) + - ")(?![^<>]*>)(?![^&;]+;)", "gi" - ), "$1" ), + label: text, value: text, option: this }; @@ -111,12 +105,6 @@ }) .addClass( "ui-widget ui-widget-content ui-corner-left" ); - input.data( "ui-autocomplete" )._renderItem = function( ul, item ) { - return $( "
  3. " ) - .append( "" + item.label + "" ) - .appendTo( ul ); - }; - $( "" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) From 5546e76354e80adccddd8ccb29c9c6a746c9968b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 19 Feb 2013 14:47:14 -0500 Subject: [PATCH 65/80] Autocomplete demo (Combobox): Rename selected event to select. --- demos/autocomplete/combobox.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index c5ef93576..3e17a1dca 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -93,7 +93,7 @@ }, select: function( event, ui ) { ui.item.option.selected = true; - that._trigger( "selected", event, { + that._trigger( "select", event, { item: ui.item.option }); }, From c1d04def4220162f13b791d55c05f07ce9c6278b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 19 Feb 2013 15:10:02 -0500 Subject: [PATCH 66/80] Autocomplete demo (Combobox): Split code into smaller functions. --- demos/autocomplete/combobox.html | 143 +++++++++++++++++-------------- 1 file changed, 80 insertions(+), 63 deletions(-) diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 3e17a1dca..f89f260eb 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -37,79 +37,52 @@ (function( $ ) { $.widget( "ui.combobox", { _create: function() { - var input, - that = this, - wasOpen = false, - select = this.element.hide(), - selected = select.children( ":selected" ), - value = selected.val() ? selected.text() : "", - wrapper = this.wrapper = $( "" ) - .addClass( "ui-combobox" ) - .insertAfter( select ); + this.wrapper = $( "" ) + .addClass( "ui-combobox" ) + .insertAfter( this.element ); - function removeIfInvalid( element ) { - var value = $( element ).val().toLowerCase(), - valid = false; - select.children( "option" ).each(function() { - if ( $( this ).text().toLowerCase() === value ) { - this.selected = valid = true; - return false; - } - }); + this._createAutocomplete(); + this._createShowAllButton(); + }, - if ( !valid ) { - // remove invalid value, as it didn't match anything - $( element ) - .val( "" ) - .attr( "title", value + " didn't match any item" ) - .tooltip( "open" ); - select.val( "" ); - setTimeout(function() { - input.tooltip( "close" ).attr( "title", "" ); - }, 2500 ); - input.data( "ui-autocomplete" ).term = ""; - } - } + _createAutocomplete: function() { + var selected = this.element.children( ":selected" ), + value = selected.val() ? selected.text() : ""; - input = $( "" ) - .appendTo( wrapper ) + this.input = $( "" ) + .appendTo( this.wrapper ) .val( value ) .attr( "title", "" ) - .addClass( "ui-state-default ui-combobox-input" ) + .addClass( "ui-state-default ui-combobox-input ui-widget ui-widget-content ui-corner-left" ) .autocomplete({ delay: 0, minLength: 0, - source: function( request, response ) { - var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); - response( select.children( "option" ).map(function() { - var text = $( this ).text(); - if ( this.value && ( !request.term || matcher.test(text) ) ) - return { - label: text, - value: text, - option: this - }; - }) ); - }, - select: function( event, ui ) { - ui.item.option.selected = true; - that._trigger( "select", event, { - item: ui.item.option - }); - }, - change: function( event, ui ) { - if ( !ui.item ) { - removeIfInvalid( this ); - } - } + source: $.proxy( this, "_source" ) }) - .addClass( "ui-widget ui-widget-content ui-corner-left" ); + .tooltip({ + tooltipClass: "ui-state-highlight" + }); + + this._on( this.input, { + autocompleteselect: function( event, ui ) { + ui.item.option.selected = true; + this._trigger( "select", event, { + item: ui.item.option + }); + }, + + autocompletechange: "_removeIfInvalid" + }); + }, + + _createShowAllButton: function() { + var wasOpen = false; $( "" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .tooltip() - .appendTo( wrapper ) + .appendTo( this.wrapper ) .button({ icons: { primary: "ui-icon-triangle-1-s" @@ -124,18 +97,62 @@ .click(function() { input.focus(); - // close if already visible + // Close if already visible if ( wasOpen ) { return; } - // pass empty string as value to search for, displaying all results + // Pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); }); + }, - input.tooltip({ - tooltipClass: "ui-state-highlight" + _source: function( request, response ) { + var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); + response( this.element.children( "option" ).map(function() { + var text = $( this ).text(); + if ( this.value && ( !request.term || matcher.test(text) ) ) + return { + label: text, + value: text, + option: this + }; + }) ); + }, + + _removeIfInvalid: function( event, ui ) { + + // Selected an item, nothing to do + if ( ui.item ) { + return; + } + + // Search for a match (case-insensitive) + var value = this.input.val(), + valueLowerCase = value.toLowerCase(), + valid = false; + this.element.children( "option" ).each(function() { + if ( $( this ).text().toLowerCase() === valueLowerCase ) { + this.selected = valid = true; + return false; + } }); + + // Found a match, nothing to do + if ( valid ) { + return; + } + + // Remove invalid value + this.input + .val( "" ) + .attr( "title", value + " didn't match any item" ) + .tooltip( "open" ); + this.element.val( "" ); + this._delay(function() { + this.input.tooltip( "close" ).attr( "title", "" ); + }, 2500 ); + this.input.data( "ui-autocomplete" ).term = ""; }, _destroy: function() { From bcae4fb9f1d84e0d0e6e7afb11002b28e5dc5ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 22 Feb 2013 17:28:45 -0500 Subject: [PATCH 67/80] Upgrade mousewheel to 3.1.0. --- external/jquery.mousewheel.js | 137 +++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 60 deletions(-) diff --git a/external/jquery.mousewheel.js b/external/jquery.mousewheel.js index bf766be6d..8c603041b 100644 --- a/external/jquery.mousewheel.js +++ b/external/jquery.mousewheel.js @@ -1,84 +1,101 @@ -/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net) +/*! Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net) * Licensed under the MIT License (LICENSE.txt). * * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * - * Version: 3.0.6 + * Version: 3.1.0 * * Requires: 1.2.2+ */ -(function($) { - -var types = ['DOMMouseScroll', 'mousewheel']; - -if ($.event.fixHooks) { - for ( var i=types.length; i; ) { - $.event.fixHooks[ types[--i] ] = $.event.mouseHooks; +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else { + // Browser globals + factory(jQuery); } -} +}(function ($) { -$.event.special.mousewheel = { - setup: function() { - if ( this.addEventListener ) { - for ( var i=types.length; i; ) { - this.addEventListener( types[--i], handler, false ); - } - } else { - this.onmousewheel = handler; - } - }, + var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll']; + var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll']; + var lowestDelta, lowestDeltaXY; - teardown: function() { - if ( this.removeEventListener ) { - for ( var i=types.length; i; ) { - this.removeEventListener( types[--i], handler, false ); - } - } else { - this.onmousewheel = null; + if ($.event.fixHooks) { + for ( var i=toFix.length; i; ) { + $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks; } } -}; -$.fn.extend({ - mousewheel: function(fn) { - return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); - }, + $.event.special.mousewheel = { + setup: function() { + if ( this.addEventListener ) { + for ( var i=toBind.length; i; ) { + this.addEventListener( toBind[--i], handler, false ); + } + } else { + this.onmousewheel = handler; + } + }, - unmousewheel: function(fn) { - return this.unbind("mousewheel", fn); - } -}); + teardown: function() { + if ( this.removeEventListener ) { + for ( var i=toBind.length; i; ) { + this.removeEventListener( toBind[--i], handler, false ); + } + } else { + this.onmousewheel = null; + } + } + }; + + $.fn.extend({ + mousewheel: function(fn) { + return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + }, + + unmousewheel: function(fn) { + return this.unbind("mousewheel", fn); + } + }); -function handler(event) { - var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; - event = $.event.fix(orgEvent); - event.type = "mousewheel"; + function handler(event) { + var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, deltaX = 0, deltaY = 0, absDelta = 0, absDeltaXY = 0; + event = $.event.fix(orgEvent); + event.type = "mousewheel"; - // Old school scrollwheel delta - if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; } - if ( orgEvent.detail ) { delta = -orgEvent.detail/3; } + // Old school scrollwheel delta + if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; } + if ( orgEvent.detail ) { delta = orgEvent.detail * -1; } - // New school multidimensional scroll (touchpads) deltas - deltaY = delta; + // New school wheel delta (wheel event) + if ( orgEvent.deltaY ) { + deltaY = orgEvent.deltaY * -1; + delta = deltaY; + } + if ( orgEvent.deltaX ) { + deltaX = orgEvent.deltaX; + delta = deltaX * -1; + } - // Gecko - if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { - deltaY = 0; - deltaX = -1*delta; + // Webkit + if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; } + if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; } + + absDelta = Math.abs(delta); + if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; } + + absDeltaXY = Math.max( Math.abs(deltaY), Math.abs(deltaX) ); + if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; } + + // Add event and delta to the front of the arguments + args.unshift(event, Math.floor(delta/lowestDelta), Math.floor(deltaX/lowestDeltaXY), Math.floor(deltaY/lowestDeltaXY)); + + return ($.event.dispatch || $.event.handle).apply(this, args); } - // Webkit - if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } - if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } - - // Add event and delta to the front of the arguments - args.unshift(event, delta, deltaX, deltaY); - - return ($.event.dispatch || $.event.handle).apply(this, args); -} - -})(jQuery); \ No newline at end of file +})); From d5d3a745b00dd476195cf25b35cc02f3bc31f814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 25 Feb 2013 15:36:08 -0500 Subject: [PATCH 68/80] Autocomplete: Set isNewMenu flag on every suggestion. Fixes #9118 - Autocomplete: Mouse auto-highlights option in Firefox. --- ui/jquery.ui.autocomplete.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 1b0f2138f..b3a05da0b 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -234,7 +234,8 @@ $.widget( "ui.autocomplete", { } }, menufocus: function( event, ui ) { - // #7024 - Prevent accidental activation of menu items in Firefox + // support: Firefox + // Prevent accidental activation of menu items in Firefox (#7024 #9118) if ( this.isNewMenu ) { this.isNewMenu = false; if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) { @@ -490,6 +491,7 @@ $.widget( "ui.autocomplete", { _suggest: function( items ) { var ul = this.menu.element.empty(); this._renderMenu( ul, items ); + this.isNewMenu = true; this.menu.refresh(); // size and position menu From e9c04bfa430eb6b18e7fe1be2f8d162e01181a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 26 Feb 2013 08:59:28 -0500 Subject: [PATCH 69/80] Position: Fix orientation check for scrollbar widths. Fixes #8763 - Position: getScrollInfo() swapped width and height. --- ui/jquery.ui.position.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 81f1e4e8a..2d3451c06 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -95,8 +95,8 @@ $.position = { hasOverflowY = overflowY === "scroll" || ( overflowY === "auto" && within.height < within.element[0].scrollHeight ); return { - width: hasOverflowX ? $.position.scrollbarWidth() : 0, - height: hasOverflowY ? $.position.scrollbarWidth() : 0 + width: hasOverflowY ? $.position.scrollbarWidth() : 0, + height: hasOverflowX ? $.position.scrollbarWidth() : 0 }; }, getWithinInfo: function( element ) { From 1c80735acb20a468300a53f85ef49b065d40af3e Mon Sep 17 00:00:00 2001 From: Zaven Muradyan Date: Sat, 23 Feb 2013 21:55:29 -0800 Subject: [PATCH 70/80] Droppable: Changed drop event to loop over a copied array instead of the droppables directly. Fixed #9116 - Droppable: Drop event can cause droppables to remain active if any droppable is created/destroyed in the event handler. --- tests/unit/droppable/droppable.html | 1 + tests/unit/droppable/droppable_events.js | 33 ++++++++++++++++++++++++ ui/jquery.ui.droppable.js | 3 ++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index 7cd5eb0f5..d084464c2 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -42,6 +42,7 @@
    Draggable
    Droppable
    +
    Droppable
     
    diff --git a/tests/unit/droppable/droppable_events.js b/tests/unit/droppable/droppable_events.js index 8f842e942..707eea1f4 100644 --- a/tests/unit/droppable/droppable_events.js +++ b/tests/unit/droppable/droppable_events.js @@ -5,6 +5,39 @@ module("droppable: events"); +test( "droppable destruction/recreation on drop event", function() { + expect( 1 ); + + var config = { + activeClass: "active", + drop: function() { + var element = $( this ), + newDroppable = $( "
    " ) + .css({ width: 100, height: 100 }) + .text( "Droppable" ); + element.after( newDroppable ); + element.remove(); + newDroppable.droppable( config ); + } + }, + + draggable = $( "#draggable1" ).draggable(), + droppable1 = $( "#droppable1" ).droppable( config ), + droppable2 = $( "#droppable2" ).droppable( config ), + + droppableOffset = droppable1.offset(), + draggableOffset = draggable.offset(), + dx = droppableOffset.left - draggableOffset.left, + dy = droppableOffset.top - draggableOffset.top; + + draggable.simulate( "drag", { + dx: dx, + dy: dy + }); + + ok( !droppable2.hasClass( "active" ), "subsequent droppable no longer active" ); +}); + // this is here to make JSHint pass "unused", and we don't want to // remove the parameter for when we finally implement $.noop(); diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 4fbfcde06..552b24a58 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -278,7 +278,8 @@ $.ui.ddmanager = { drop: function(draggable, event) { var dropped = false; - $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { + // Create a copy of the droppables in case the list changes during the drop (#9116) + $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() { if(!this.options) { return; From d0ad572349beadc99810ecd53a532bf5f261343d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 26 Feb 2013 10:13:42 -0500 Subject: [PATCH 71/80] Droppable tests: Cleanup. --- tests/unit/droppable/droppable_events.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/unit/droppable/droppable_events.js b/tests/unit/droppable/droppable_events.js index 707eea1f4..4b8fe5acd 100644 --- a/tests/unit/droppable/droppable_events.js +++ b/tests/unit/droppable/droppable_events.js @@ -1,9 +1,6 @@ -/* - * droppable_events.js - */ -(function($) { +(function( $ ) { -module("droppable: events"); +module( "droppable: events" ); test( "droppable destruction/recreation on drop event", function() { expect( 1 ); @@ -38,9 +35,7 @@ test( "droppable destruction/recreation on drop event", function() { ok( !droppable2.hasClass( "active" ), "subsequent droppable no longer active" ); }); -// this is here to make JSHint pass "unused", and we don't want to -// remove the parameter for when we finally implement -$.noop(); + // todo: comment the following in when ready to actually test /* @@ -65,4 +60,4 @@ test("drop", function() { }); */ -})(jQuery); +})( jQuery ); From 948563b8b55802c6d4c513065f1b78bbdcff104c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 26 Feb 2013 10:36:03 -0500 Subject: [PATCH 72/80] Effects: Delegate to core show/hide when the element is already in the correct final state. This forces the element to go through the olddisplay tracking and forces styles on elements even if they're hidden via an ancestor. Fixes #9120 - Effects: .hide() inconsistent with core with a hidden parent. --- tests/unit/effects/effects.html | 4 +++- tests/unit/effects/effects_core.js | 8 ++++++++ ui/jquery.ui.effect.js | 5 +++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index c283eabff..7ddacf7bb 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -96,7 +96,9 @@

      - +

      Child Element Test

      diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js index c9b1e1b4a..928d4c15b 100644 --- a/tests/unit/effects/effects_core.js +++ b/tests/unit/effects/effects_core.js @@ -28,6 +28,14 @@ test( "Immediate Return Conditions", function() { equal( ++count, 3, "Both Functions worked properly" ); }); +test( ".hide() with hidden parent", function() { + expect( 1 ); + var element = $( "div.hidden" ).children(); + element.hide( "blind", function() { + equal( element.css( "display" ), "none", "display: none" ); + }); +}); + asyncTest( "Parse of null for options", function() { var hidden = $( "div.hidden" ), count = 0; diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index 97f006ee0..41aeb4819 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -1150,9 +1150,10 @@ $.fn.extend({ } } - // if the element is hiddden and mode is hide, - // or element is visible and mode is show + // If the element already has the correct final state, delegate to + // the core methods so the internal tracking of "olddisplay" works. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { + elem[ mode ](); done(); } else { effectMethod.call( elem[0], args, done ); From 0cf875e5e34e4b2c11802eb856190e6cca649bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 27 Feb 2013 11:27:44 -0500 Subject: [PATCH 73/80] Accordion demo: Clean up hoverintent implementation to avoid using jQuery.event.handle. Thanks Drew Waddell for pointing out the use of an undocumented/deprecated method. --- demos/accordion/hoverintent.html | 61 ++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/demos/accordion/hoverintent.html b/demos/accordion/hoverintent.html index 023682d4b..0ff63a321 100644 --- a/demos/accordion/hoverintent.html +++ b/demos/accordion/hoverintent.html @@ -16,11 +16,11 @@ }); }); - var cfg = ($.hoverintent = { - sensitivity: 7, - interval: 100 - }); - + /* + * hoverIntent | Copyright 2011 Brian Cherne + * http://cherne.net/brian/resources/jquery.hoverIntent.html + * modified by the jQuery UI team + */ $.event.special.hoverintent = { setup: function() { $( this ).bind( "mouseover", jQuery.event.special.hoverintent.handler ); @@ -29,41 +29,56 @@ $( this ).unbind( "mouseover", jQuery.event.special.hoverintent.handler ); }, handler: function( event ) { - var that = this, + var currentX, currentY, timeout, args = arguments, target = $( event.target ), - cX, cY, pX, pY; + previousX = event.pageX, + previousY = event.pageY; function track( event ) { - cX = event.pageX; - cY = event.pageY; + currentX = event.pageX; + currentY = event.pageY; }; - pX = event.pageX; - pY = event.pageY; + function clear() { target .unbind( "mousemove", track ) - .unbind( "mouseout", arguments.callee ); + .unbind( "mouseout", clear ); clearTimeout( timeout ); } + function handler() { - if ( ( Math.abs( pX - cX ) + Math.abs( pY - cY ) ) < cfg.sensitivity ) { + var prop, + orig = event; + + if ( ( Math.abs( previousX - currentX ) + + Math.abs( previousY - currentY ) ) < 7 ) { clear(); - event.type = "hoverintent"; - // prevent accessing the original event since the new event + + event = $.Event( "hoverintent" ); + for ( prop in orig ) { + if ( !( prop in event ) ) { + event[ prop ] = orig[ prop ]; + } + } + // Prevent accessing the original event since the new event // is fired asynchronously and the old event is no longer // usable (#6028) - event.originalEvent = {}; - jQuery.event.handle.apply( that, args ); + delete event.originalEvent; + + target.trigger( event ); } else { - pX = cX; - pY = cY; - timeout = setTimeout( handler, cfg.interval ); + previousX = currentX; + previousY = currentY; + timeout = setTimeout( handler, 100 ); } } - var timeout = setTimeout( handler, cfg.interval ); - target.mousemove( track ).mouseout( clear ); - return true; + + timeout = setTimeout( handler, 100 ); + target.bind({ + mousemove: track, + mouseout: clear + }); } }; From 6f2957743659387f66c9b8953bba9fac5617a440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 28 Feb 2013 13:34:49 -0500 Subject: [PATCH 74/80] Effects: Handle the .hide/show/toggle( options ) signatures from core properly. Fixes #9126 - .show()/.hide() do not support all of core's options. --- tests/unit/effects/effects.html | 2 + tests/unit/effects/effects_core.js | 18 ++++++ ui/jquery.ui.effect.js | 89 ++++++++++++++++++------------ 3 files changed, 73 insertions(+), 36 deletions(-) diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index 7ddacf7bb..4538ecb03 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -96,6 +96,8 @@

        +
        +
        diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js index 928d4c15b..11e9d0b45 100644 --- a/tests/unit/effects/effects_core.js +++ b/tests/unit/effects/effects_core.js @@ -16,6 +16,24 @@ var minDuration = 15, module( "effects.core" ); +// TODO: test all signatures of .show(), .hide(), .toggle(). +// Look at core's signatures and UI's signatures. +asyncTest( ".hide() with step", function() { + expect( 1 ); + var element = $( "#elem" ), + step = function() { + ok( true, "step callback invoked" ); + step = $.noop; + }; + + element.hide({ + step: function() { + step(); + }, + complete: start + }); +}); + test( "Immediate Return Conditions", function() { var hidden = $( "div.hidden" ), count = 0; diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index 41aeb4819..f3d9929b0 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -1106,14 +1106,29 @@ function _normalizeArguments( effect, options, speed, callback ) { return effect; } -function standardSpeed( speed ) { - // valid standard speeds - if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) { +function standardAnimationOption( option ) { + // Valid standard speeds (nothing, number, named speed) + if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { return true; } - // invalid strings - treat as "normal" speed - return typeof speed === "string" && !$.effects.effect[ speed ]; + // Invalid strings - treat as "normal" speed + if ( typeof option === "string" && !$.effects.effect[ option ] ) { + return true; + } + + // Complete callback + if ( $.isFunction( option ) ) { + return true; + } + + // Options hash (but not naming an effect) + if ( typeof option === "object" && !option.effect ) { + return true; + } + + // Didn't match any standard API + return false; } $.fn.extend({ @@ -1163,39 +1178,41 @@ $.fn.extend({ return queue === false ? this.each( run ) : this.queue( queue || "fx", run ); }, - _show: $.fn.show, - show: function( speed ) { - if ( standardSpeed( speed ) ) { - return this._show.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "show"; - return this.effect.call( this, args ); - } - }, + show: (function( orig ) { + return function( option ) { + if ( standardAnimationOption( option ) ) { + return orig.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "show"; + return this.effect.call( this, args ); + } + }; + })( $.fn.show ), - _hide: $.fn.hide, - hide: function( speed ) { - if ( standardSpeed( speed ) ) { - return this._hide.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "hide"; - return this.effect.call( this, args ); - } - }, + hide: (function( orig ) { + return function( option ) { + if ( standardAnimationOption( option ) ) { + return orig.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "hide"; + return this.effect.call( this, args ); + } + }; + })( $.fn.hide ), - // jQuery core overloads toggle and creates _toggle - __toggle: $.fn.toggle, - toggle: function( speed ) { - if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) { - return this.__toggle.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "toggle"; - return this.effect.call( this, args ); - } - }, + toggle: (function( orig ) { + return function( option ) { + if ( standardAnimationOption( option ) || typeof option === "boolean" ) { + return orig.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "toggle"; + return this.effect.call( this, args ); + } + }; + })( $.fn.toggle ), // helper functions cssUnit: function(key) { From 8655d91ac68538c37da4d94ecc287df8c90a96ae Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Wed, 27 Feb 2013 22:35:53 -0500 Subject: [PATCH 75/80] Sortable: Adding a min-width to the body on the portlet demo. Fixed #4485: Portlet demo is buggy. --- demos/sortable/portlets.html | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/sortable/portlets.html b/demos/sortable/portlets.html index 24582f502..5a3f2b662 100644 --- a/demos/sortable/portlets.html +++ b/demos/sortable/portlets.html @@ -11,6 +11,7 @@ - + @@ -23,7 +23,8 @@ "ui/jquery.ui.widget.js", "ui/jquery.ui.mouse.js", "ui/jquery.ui.resizable.js", - "ui/jquery.ui.draggable.js" + "ui/jquery.ui.draggable.js", + "ui/jquery.ui.droppable.js" ] }); @@ -45,15 +46,12 @@

          -
          - -
          Relative
          -
          Absolute
          -
          -
          -
          -
          - +
          +
          Relative
          +
          Absolute
          +
          Absolute
          +
          +
          diff --git a/tests/unit/draggable/draggable_common.js b/tests/unit/draggable/draggable_common.js index 7c6961af2..5abd09e49 100644 --- a/tests/unit/draggable/draggable_common.js +++ b/tests/unit/draggable/draggable_common.js @@ -1,6 +1,5 @@ TestHelpers.commonWidgetTests( "draggable", { defaults: { - addClasses: true, appendTo: "parent", axis: false, cancel: "input,textarea,button,select,option", @@ -8,13 +7,10 @@ TestHelpers.commonWidgetTests( "draggable", { containment: false, cursor: "auto", cursorAt: false, - delay: 0, disabled: false, - distance: 1, grid: false, handle: false, helper: "original", - iframeFix: false, opacity: false, refreshPositions: false, revert: false, @@ -29,6 +25,12 @@ TestHelpers.commonWidgetTests( "draggable", { stack: false, zIndex: false, + //todo: remove the following option checks when interactions are rewritten: + addClasses: true, + delay: 0, + distance: 1, + iframeFix: false, + // callbacks create: null, drag: null, diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 00d914194..2090f2fd9 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -2,24 +2,40 @@ * draggable_core.js */ -(function($) { +(function( $ ) { -module("draggable"); +var relativeElement, absoluteElement; -test("element types", function() { - var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" + - ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" + - ",acronym,code,samp,kbd,var,img,hr" + - ",input,button,label,select,iframe").split(","); +module( "draggable: core", { + setup: function() { + relativeElement = $("
          Relative
          ").appendTo("#qunit-fixture"); + absoluteElement = $("
          Absolute
          ").appendTo("#qunit-fixture"); + }, + teardown: function() { + relativeElement.remove(); + absoluteElement.remove(); + } +}); + +test( "element types", function() { + var typeNames = ( + "p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" + + ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" + + ",acronym,code,samp,kbd,var,img,hr" + + ",input,button,label,select,iframe" + ).split(","); expect( typeNames.length * 2 ); - $.each(typeNames, function(i) { + $.each( typeNames, function( i ) { var offsetBefore, offsetAfter, - typeName = typeNames[i], - el = $(document.createElement(typeName)).appendTo("#qunit-fixture"); + typeName = typeNames[ i ], + el = $( document.createElement( typeName ) ).appendTo("#qunit-fixture"); + + if ( typeName === "table" ) { + el.append("content"); + } - (typeName === "table" && el.append("content")); el.draggable({ cancel: "" }); offsetBefore = el.offset(); el.simulate( "drag", { @@ -27,39 +43,38 @@ test("element types", function() { 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 + ">"); - closeEnough(offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + ">"); + + // Support: FF, Chrome, and IE9, + // there are some rounding errors in so we can't say equal, we have to settle for close enough + closeEnough( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">" ); + closeEnough( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + ">" ); el.draggable("destroy"); el.remove(); }); }); -test("No options, relative", function() { +test( "No options, relative", function() { expect( 1 ); - var el = $("#draggable1").draggable(); - TestHelpers.draggable.shouldMove(el); + TestHelpers.draggable.shouldMove( relativeElement.draggable() ); }); -test("No options, absolute", function() { +test( "No options, absolute", function() { expect( 1 ); - var el = $("#draggable2").draggable(); - TestHelpers.draggable.shouldMove(el); + TestHelpers.draggable.shouldMove( absoluteElement.draggable() ); }); -test("resizable handle with complex markup (#8756 / #8757)", function() { +test( "resizable handle with complex markup (#8756 / #8757)", function() { expect( 2 ); - $("#draggable1") + relativeElement .append( $("
          ") - .addClass("ui-resizable-handle") - .addClass("ui-resizable-w") - .append($("
          ")) + .addClass("ui-resizable-handle ui-resizable-w") + .append( $("
          ") ) ); var handle = $(".ui-resizable-w div"), - target = $("#draggable1").draggable().resizable({ handles: "all" }); + target = relativeElement.draggable().resizable({ handles: "all" }); // todo: fix resizable so it doesn't require a mouseover handle.simulate("mouseover").simulate( "drag", { dx: -50 } ); @@ -70,4 +85,4 @@ test("resizable handle with complex markup (#8756 / #8757)", function() { equal( target.width(), 200, "compare width" ); }); -})(jQuery); +})( jQuery ); diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js index f4ab3a8ea..199561be3 100644 --- a/tests/unit/draggable/draggable_events.js +++ b/tests/unit/draggable/draggable_events.js @@ -1,99 +1,125 @@ /* * draggable_events.js */ -(function($) { +(function( $ ) { -module("draggable: events"); +var element; -test("callbacks occurrence count", function() { +module( "draggable: events", { + setup: function() { + element = $("
          ").appendTo("#qunit-fixture"); + }, + teardown: function() { + element.draggable("destroy"); + } +}); - expect(3); +test( "callbacks occurrence count", function() { + expect( 3 ); var start = 0, stop = 0, - dragc = 0, - el = $("#draggable2").draggable({ - start: function() { start++; }, - drag: function() { dragc++; }, - stop: function() { stop++; } - }); + dragc = 0; - el.simulate( "drag", { + element.draggable({ + start: function() { + start++; + }, + drag: function() { + dragc++; + }, + stop: function() { + stop++; + } + }); + + element.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"); - equal(stop, 1, "stop callback should happen exactly once"); - + equal( start, 1, "start callback should happen exactly once" ); + equal( dragc, 3, "drag callback should happen exactly once per mousemove" ); + equal( stop, 1, "stop callback should happen exactly once" ); }); -test("stopping the start callback", function() { - - expect(3); +test( "stopping the start callback", function() { + expect( 3 ); var start = 0, stop = 0, - dragc = 0, - el = $("#draggable2").draggable({ - start: function() { start++; return false; }, - drag: function() { dragc++; }, - stop: function() { stop++; } - }); + dragc = 0; - el.simulate( "drag", { + element.draggable({ + start: function() { + start++; + return false; + }, + drag: function() { + dragc++; + }, + stop: function() { + stop++; + } + }); + + element.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"); - equal(stop, 0, "stop callback should not happen if there wasnt even a start"); - + equal( start, 1, "start callback should happen exactly once" ); + equal( dragc, 0, "drag callback should not happen at all" ); + equal( stop, 0, "stop callback should not happen if there wasnt even a start" ); }); -test("stopping the drag callback", function() { - - expect(3); +test( "stopping the drag callback", function() { + expect( 2 ); var start = 0, stop = 0, - dragc = 0, - el = $("#draggable2").draggable({ - start: function() { start++;}, - drag: function() { dragc++; return false; }, - stop: function() { stop++; } - }); + dragc = 0; - el.simulate( "drag", { + element.draggable({ + start: function() { + start++; + }, + drag: function() { + dragc++; + return false; + }, + stop: function() { + stop++; + } + }); + + element.simulate( "drag", { dx: 10, dy: 10 }); - equal(start, 1, "start callback should happen exactly once"); - equal(dragc, 1, "drag callback should happen exactly once"); - equal(stop, 1, "stop callback should happen, as we need to actively stop the drag"); - + equal( start, 1, "start callback should happen exactly once" ); + equal( stop, 1, "stop callback should happen, as we need to actively stop the drag" ); }); -test("stopping the stop callback", function() { +test( "stopping the stop callback", function() { + expect( 1 ); - expect(1); - - var el = $("#draggable2").draggable({ + element.draggable({ helper: "clone", - stop: function() { return false; } + stop: function() { + return false; + } }); - el.simulate( "drag", { + element.simulate( "drag", { dx: 10, dy: 10 }); - ok($("#draggable2").data("ui-draggable").helper, "the clone should not be deleted if the stop callback is stopped"); + ok( element.data("ui-draggable").helper, "the clone should not be deleted if the stop callback is stopped" ); }); -})(jQuery); +})( jQuery ); diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js index 43db285ce..901c261d6 100644 --- a/tests/unit/draggable/draggable_methods.js +++ b/tests/unit/draggable/draggable_methods.js @@ -1,94 +1,99 @@ /* * draggable_methods.js */ -(function($) { +(function( $ ) { -module("draggable: methods"); +var element; -test("init", function() { - expect(5); +module( "draggable: methods", { + setup: function() { + element = $("
          Absolute
          ").appendTo("#qunit-fixture"); + }, + teardown: function() { + element.remove(); + } +}); - $("
          ").appendTo("body").draggable().remove(); - ok(true, ".draggable() called on element"); +test( "init", function() { + expect( 5 ); + + element.draggable(); + ok( true, ".draggable() called on element" ); $([]).draggable(); - ok(true, ".draggable() called on empty collection"); + ok( true, ".draggable() called on empty collection" ); $("
          ").draggable(); - ok(true, ".draggable() called on disconnected DOMElement"); + ok( true, ".draggable() called on disconnected DOMElement" ); - $("
          ").draggable().draggable("option", "foo"); - ok(true, "arbitrary option getter after init"); + element.draggable( "option", "foo" ); + ok( true, "arbitrary option getter after init" ); - $("
          ").draggable().draggable("option", "foo", "bar"); - ok(true, "arbitrary option setter after init"); + element.draggable( "option", "foo", "bar" ); + ok( true, "arbitrary option setter after init" ); }); -test("destroy", function() { - expect(4); - $("
          ").appendTo("body").draggable().draggable("destroy").remove(); - ok(true, ".draggable('destroy') called on element"); +test( "destroy", function() { + expect( 4 ); + + element.draggable().draggable("destroy"); + ok( true, ".draggable('destroy') called on element" ); $([]).draggable().draggable("destroy"); - ok(true, ".draggable('destroy') called on empty collection"); + ok( true, ".draggable('destroy') called on empty collection" ); - $("
          ").draggable().draggable("destroy"); - ok(true, ".draggable('destroy') called on disconnected DOMElement"); + element.draggable().draggable("destroy"); + ok( true, ".draggable('destroy') called on disconnected DOMElement" ); - var expected = $("
          ").draggable(), + var expected = element.draggable(), actual = expected.draggable("destroy"); - equal(actual, expected, "destroy is chainable"); + equal( actual, expected, "destroy is chainable" ); }); -test("enable", function() { - expect(7); +test( "enable", function() { + expect( 7 ); - var expected, actual, el; + element.draggable({ disabled: true }); + TestHelpers.draggable.shouldNotMove( element, ".draggable({ disabled: true })" ); - el = $("#draggable2").draggable({ disabled: true }); - TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })"); + element.draggable("enable"); + TestHelpers.draggable.shouldMove( element, ".draggable('enable')" ); + equal( element.draggable( "option", "disabled" ), false, "disabled option getter" ); - el.draggable("enable"); - TestHelpers.draggable.shouldMove(el, ".draggable('enable')"); - equal(el.draggable("option", "disabled"), false, "disabled option getter"); + element.draggable("destroy"); + element.draggable({ disabled: true }); + TestHelpers.draggable.shouldNotMove( element, ".draggable({ disabled: true })" ); - el.draggable("destroy"); - el.draggable({ disabled: true }); - TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })"); + element.draggable( "option", "disabled", false ); + equal(element.draggable( "option", "disabled" ), false, "disabled option setter" ); + TestHelpers.draggable.shouldMove( element, ".draggable('option', 'disabled', false)" ); - el.draggable("option", "disabled", false); - equal(el.draggable("option", "disabled"), false, "disabled option setter"); - TestHelpers.draggable.shouldMove(el, ".draggable('option', 'disabled', false)"); - - expected = $("
          ").draggable(), - actual = expected.draggable("enable"); - equal(actual, expected, "enable is chainable"); + var expected = element.draggable(), + actual = expected.draggable("enable"); + equal( actual, expected, "enable is chainable" ); }); -test("disable", function() { - expect(7); +test( "disable", function() { + expect( 7 ); - var expected, actual, el; + element = $("#draggable2").draggable({ disabled: false }); + TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); - el = $("#draggable2").draggable({ disabled: false }); - TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })"); + element.draggable("disable"); + TestHelpers.draggable.shouldNotMove( element, ".draggable('disable')" ); + equal( element.draggable( "option", "disabled" ), true, "disabled option getter" ); - el.draggable("disable"); - TestHelpers.draggable.shouldNotMove(el, ".draggable('disable')"); - equal(el.draggable("option", "disabled"), true, "disabled option getter"); + element.draggable("destroy"); + element.draggable({ disabled: false }); + TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); - el.draggable("destroy"); + element.draggable( "option", "disabled", true ); + equal( element.draggable( "option", "disabled" ), true, "disabled option setter" ); + TestHelpers.draggable.shouldNotMove( element, ".draggable('option', 'disabled', true)" ); - el.draggable({ disabled: false }); - TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })"); - - el.draggable("option", "disabled", true); - equal(el.draggable("option", "disabled"), true, "disabled option setter"); - TestHelpers.draggable.shouldNotMove(el, ".draggable('option', 'disabled', true)"); - - expected = $("
          ").draggable(), - actual = expected.draggable("disable"); - equal(actual, expected, "disable is chainable"); + var expected = element.draggable(), + actual = expected.draggable("disable"); + equal( actual, expected, "disable is chainable" ); }); -})(jQuery); +})( jQuery ); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 8496d6182..0ab41b1f1 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -5,23 +5,8 @@ module("draggable: options"); -test("{ addClasses: true }, default", function() { - expect( 1 ); - var el = $("
          ").draggable({ addClasses: true }); - ok(el.is(".ui-draggable"), "'ui-draggable' class added"); - - el.draggable("destroy"); -}); - -test("{ addClasses: false }", function() { - expect( 1 ); - var el = $("
          ").draggable({ addClasses: false }); - ok(!el.is(".ui-draggable"), "'ui-draggable' class not added"); - - el.draggable("destroy"); -}); - -test("{ appendTo: 'parent' }, default", function() { +// TODO: This doesn't actually test whether append happened, possibly remove +test("{ appendTo: 'parent' }, default, no clone", function() { expect( 2 ); var el = $("#draggable2").draggable({ appendTo: "parent" }); TestHelpers.draggable.shouldMove(el); @@ -31,16 +16,19 @@ test("{ appendTo: 'parent' }, default", function() { }); -test("{ appendTo: Element }", function() { +// TODO: This doesn't actually test whether append happened, possibly remove +test("{ appendTo: Element }, no clone", function() { expect( 2 ); - var el = $("#draggable2").draggable({ appendTo: $("#draggable2").parent()[0] }); + var el = $("#draggable2").draggable({appendTo: $("#draggable2").parent()[0] }); + TestHelpers.draggable.shouldMove(el); el = $("#draggable1").draggable({ appendTo: $("#draggable2").parent()[0] }); TestHelpers.draggable.shouldMove(el); }); -test("{ appendTo: Selector }", function() { +// TODO: This doesn't actually test whether append happened, possibly remove +test("{ appendTo: Selector }, no clone", function() { expect( 2 ); var el = $("#draggable2").draggable({ appendTo: "#main" }); TestHelpers.draggable.shouldMove(el); @@ -49,6 +37,83 @@ test("{ appendTo: Selector }", function() { TestHelpers.draggable.shouldMove(el); }); +test("{ appendTo: 'parent' }, default", function() { + + expect(2); + + var el = $("#draggable1").draggable(); + + TestHelpers.draggable.trackAppendedParent(el); + + equal( el.draggable( "option", "appendTo" ), "parent" ); + + TestHelpers.draggable.move(el, 1, 1); + equal( el.data("last_dragged_parent"), $("#qunit-fixture")[0] ); + +}); + +test("{ appendTo: Element }", function() { + + expect(1); + + var appendTo = $("#draggable2").parent()[0], + el = $("#draggable1").draggable({ appendTo: appendTo }); + + TestHelpers.draggable.trackAppendedParent(el); + + TestHelpers.draggable.move(el, 1, 1); + equal( el.data("last_dragged_parent"), appendTo ); + +}); + +test("{ appendTo: jQuery }", function() { + + expect(1); + + var appendTo = $("#draggable2").parent(), + el = $("#draggable1").draggable({ appendTo: appendTo }); + + TestHelpers.draggable.trackAppendedParent(el); + + TestHelpers.draggable.move(el, 1, 1); + equal( el.data("last_dragged_parent"), appendTo[0] ); + +}); +test("{ appendTo: Selector }", function() { + + expect(1); + + + var appendTo = "#main", + el = $("#draggable1").draggable({ appendTo: appendTo }); + + TestHelpers.draggable.trackAppendedParent(el); + + TestHelpers.draggable.move(el, 1, 1); + equal( el.data("last_dragged_parent"), $(appendTo)[0] ); + +}); + + +test("appendTo, default, switching after initialization", function() { + + expect(2); + + var el = $("#draggable1").draggable({ helper : "clone" }); + + TestHelpers.draggable.trackAppendedParent(el); + + // Move and make sure el was appended to fixture + TestHelpers.draggable.move(el, 1, 1); + equal( el.data("last_dragged_parent"), $("#qunit-fixture")[0] ); + + // Move and make sure el was appended to main + el.draggable( "option", "appendTo", $("#main") ); + TestHelpers.draggable.move(el, 2, 2); + equal( el.data("last_dragged_parent"), $("#main")[0] ); + +}); + test("{ axis: false }, default", function() { expect( 1 ); var el = $("#draggable2").draggable({ axis: false }); @@ -87,6 +152,26 @@ test("{ axis: ? }, unexpected", function() { }); }); +test("axis, default, switching after initialization", function() { + + expect(3); + + var el; + + // Any direction + el = $("#draggable1").draggable({ axis : false }); + TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); + + // Only horizontal + el.draggable("option", "axis", "x"); + TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 0); + + // Vertical only + el.draggable("option", "axis", "y"); + TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 50); + +}); + test("{ cancel: 'input,textarea,button,select,option' }, default", function() { expect( 2 ); @@ -114,7 +199,9 @@ test("{ cancel: 'span' }", function() { TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 0, 0); }); -test("{ cancel: ? }, unexpected", function() { +test( "{ cancel: ? }, unexpected", function() { + expect( 6 ); + var el, unexpected = { "true": true, @@ -122,35 +209,121 @@ test("{ cancel: ? }, unexpected", function() { "{}": {}, "[]": [], "null": null, - "undefined": undefined, - "function() {return '';}": function() {return "";}, - "function() {return true;}": function() {return true;}, - "function() {return false;}": function() {return false;} + "undefined": undefined }; - expect( 9 ); - - $.each(unexpected, function(key, val) { + $.each( unexpected, function( key, val ) { el = $("#draggable2").draggable({ cancel: val }); - TestHelpers.draggable.shouldMove(el, "cancel: " + key); + TestHelpers.draggable.shouldMove( el, "cancel: " + key ); el.draggable("destroy"); }); }); -/* -test("{ containment: false }, default", function() { - expect( 1 ); +/** +test("{ cancel: Selectors }, matching parent selector", function() { + + expect( 5 ); + + var el = $("#draggable2").draggable({ cancel: "span a" }); + + $("#qunit-fixture").append( "
          " ); + + el.find( "span" ).append( "" ); + + $("#wrapping a").append( el ); + + TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50, "drag span child"); + TestHelpers.draggable.shouldNotMove( $("#draggable2 span a") ); + TestHelpers.draggable.shouldNotMove( $("#wrapping a") ); + + $("#draggable2").draggable( "option", "cancel", "span > a" ); + $("#draggable2").find( "a" ).append( "" ); + + + TestHelpers.draggable.testDrag(el, $("#draggable2 span a").last(), 50, 50, 50, 50, "drag span child"); + TestHelpers.draggable.shouldNotMove( $("#draggable2 span a").first() ); + +}); +*/ + +test("cancel, default, switching after initialization", function() { + expect( 3 ); + + $("
          ").appendTo("#main"); + + var input = $("#draggable-option-cancel-default input"), + el = $("#draggable-option-cancel-default").draggable(); + + TestHelpers.draggable.testDrag(el, input, 50, 50, 0, 0); + + el.draggable("option", "cancel", "textarea" ); + TestHelpers.draggable.testDrag(el, input, 50, 50, 50, 50); + + el.draggable("option", "cancel", "input" ); + TestHelpers.draggable.testDrag(el, input, 50, 50, 0, 0); - ok(false, "missing test - untested code is broken code"); }); -test("{ containment: Element }", function() { +/* + +test("{ connectToSortable: selector }, default", function() { expect( 1 ); ok(false, "missing test - untested code is broken code"); }); */ +test( "{ containment: Element }", function() { + expect( 1 ); + + var offsetAfter, + el = $( "#draggable1" ).draggable({ containment: $( "#draggable1" ).parent()[ 0 ] }), + p = el.parent(), + po = p.offset(), + expected = { + 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") + }; + + el.simulate( "drag", { + dx: -100, + dy: -100 + }); + offsetAfter = el.offset(); + deepEqual(offsetAfter, expected, "compare offset to parent"); +}); + +test( "{ containment: Selector }", function() { + expect( 1 ); + + var offsetAfter, + el = $( "#draggable1" ).draggable({ containment: $( "#qunit-fixture" ) }), + p = el.parent(), + po = p.offset(), + expected = { + 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") + }; + + el.simulate( "drag", { + dx: -100, + dy: -100 + }); + offsetAfter = el.offset(); + deepEqual(offsetAfter, expected, "compare offset to parent"); +}); + +test( "{ containment: [x1, y1, x2, y2] }", function() { + expect( 1 ); + + var el = $( "#draggable1" ).draggable(), + eo = el.offset(); + + el.draggable( "option", "containment", [ eo.left, eo.top, eo.left + el.width() + 5, eo.left + el.width() + 5 ] ); + + TestHelpers.draggable.testDrag( el, el, -100, -100, 0, 0 ); +}); + test("{ containment: 'parent' }, relative", function() { expect( 1 ); @@ -191,32 +364,25 @@ test("{ containment: 'parent' }, absolute", function() { deepEqual(offsetAfter, expected, "compare offset to parent"); }); -/* -test("{ containment: 'document' }", function() { - expect( 1 ); +test("containment, default, switching after initialization", function() { + expect( 2 ); + + var el = $("#draggable1").draggable({ containment: false }); + + TestHelpers.draggable.testDrag(el, el, -100, -100, -100, -100); + + el.draggable( "option", "containment", "parent" ) + .css({top:0,left:0}) + .appendTo( $("#main") ); + + TestHelpers.draggable.testDrag(el, el, -100, -100, 0, 0); + + // TODO: Switching back to false does not update to false + // el.draggable( "option", "containment", false ); + // TestHelpers.draggable.testDrag(el, el, -100, -100, -100, -100); - ok(false, "missing test - untested code is broken code"); }); -test("{ containment: 'window' }", function() { - expect( 1 ); - - ok(false, "missing test - untested code is broken code"); -}); - -test("{ containment: Selector }", function() { - expect( 1 ); - - ok(false, "missing test - untested code is broken code"); -}); - -test("{ containment: [x1, y1, x2, y2] }", function() { - expect( 1 ); - - ok(false, "missing test - untested code is broken code"); -}); -*/ - test("{ cursor: 'auto' }, default", function() { function getCursor() { return $("#draggable2").css("cursor"); } @@ -270,6 +436,27 @@ test("{ cursor: 'move' }", function() { }); +test("cursor, default, switching after initialization", function() { + + expect(3); + + var el = $("#draggable1").draggable(); + + TestHelpers.draggable.trackMouseCss( el ); + + TestHelpers.draggable.move( el, 1, 1 ); + equal( el.data("last_dragged_cursor"), "auto" ); + + el.draggable( "option", "cursor", "move" ); + TestHelpers.draggable.move( el, 1, 1 ); + equal( el.data("last_dragged_cursor"), "move" ); + + el.draggable( "option", "cursor", "ns-resize" ); + TestHelpers.draggable.move( el, 1, 1 ); + equal( el.data("last_dragged_cursor"), "ns-resize" ); + +}); + test( "cursorAt", function() { expect( 24 ); @@ -311,15 +498,67 @@ test( "cursorAt", function() { }); }); -test("{ distance: 10 }", function() { +test( "cursorAt, switching after initialization", function() { + + expect( 24 ); + + var deltaX = -3, + deltaY = -3, + tests = { + "false": { cursorAt : false }, + "{ left: -5, top: -5 }": { x: -5, y: -5, cursorAt : { left: -5, top: -5 } }, + "[ 10, 20 ]": { x: 10, y: 20, cursorAt : [ 10, 20 ] }, + "'10 20'": { x: 10, y: 20, cursorAt : "10 20" }, + "{ left: 20, top: 40 }": { x: 20, y: 40, cursorAt : { left: 20, top: 40 } }, + "{ right: 10, bottom: 20 }": { x: 10, y: 20, cursorAt : { right: 10, bottom: 20 } } + }; + + $.each( tests, function( testName, testData ) { + $.each( [ "relative", "absolute" ], function( i, position ) { + var el = $( "#draggable" + ( i + 1 ) ); + + el.draggable({ + drag: function( event, ui ) { + if( !testData.cursorAt ) { + equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); + equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" ); + } else if( testData.cursorAt.right ) { + equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" ); + equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + " " +position + " top" ); + } else { + equal( event.clientX - ui.offset.left, testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" ); + equal( event.clientY - ui.offset.top, testData.y + TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" ); + } + } + }); + + el.draggable( "option", "cursorAt", false ); + el.draggable( "option", "cursorAt", testData.cursorAt ); + + el.simulate( "drag", { + moves: 1, + dx: deltaX, + dy: deltaY + }); + }); + }); + +}); + + +test( "disabled", function() { + expect( 3 ); - var el = $("#draggable2").draggable({ distance: 10 }); - TestHelpers.draggable.testDrag(el, el, -9, -9, 0, 0, "distance not met"); + var el = $("#draggable1").draggable(); - TestHelpers.draggable.testDrag(el, el, -10, -10, -10, -10, "distance met"); + TestHelpers.draggable.shouldMove(el); - TestHelpers.draggable.testDrag(el, el, 9, 9, 0, 0, "distance not met"); + el.draggable( "option", "disabled", true ); + TestHelpers.draggable.shouldNotMove(el); + + el.draggable( "option", "disabled", false ); + TestHelpers.draggable.shouldMove(el); }); @@ -339,6 +578,22 @@ test("{ grid: [50, 50] }, absolute", function() { TestHelpers.draggable.testDrag(el, el, 26, 25, 50, 50); }); +test("grid, switching after initialization", function() { + + expect( 4 ); + + var el = $("#draggable1").draggable(); + // Forward + TestHelpers.draggable.testDrag(el, el, 24, 24, 24, 24); + TestHelpers.draggable.testDrag(el, el, 0, 0, 0, 0); + + el.draggable( "option", "grid", [50,50] ); + + TestHelpers.draggable.testDrag(el, el, 24, 24, 0, 0); + TestHelpers.draggable.testDrag(el, el, 26, 25, 50, 50); + +}); + test("{ handle: 'span' }", function() { expect( 2 ); @@ -348,6 +603,65 @@ test("{ handle: 'span' }", function() { TestHelpers.draggable.shouldNotMove(el, "drag element"); }); +/* +test("{ handle: Selectors }, matching parent selector", function() { + + expect( 4 ); + + var el = $("#draggable2").draggable({ handle: "span a" }); + + $("#qunit-fixture").append( "
          " ); + + el.find( "span" ).append( "" ); + + $("#wrapping a").append( el ); + + TestHelpers.draggable.testDrag(el, "#draggable2 span a", 50, 50, 50, 50, "drag span child"); + TestHelpers.draggable.shouldNotMove( $("#wrapping a") ); + + $("#draggable2").draggable( "option", "handle", "span > a" ); + $("#draggable2").find( "a" ).append( "" ); + + TestHelpers.draggable.testDrag(el, $("#draggable2 span a").first(), 50, 50, 50, 50, "drag span child"); + TestHelpers.draggable.shouldNotMove( $("#draggable2 span a").last() ); + +}); +*/ + +test("handle, default, switching after initialization", function() { + expect( 6 ); + + var el = $("#draggable2").draggable(); + + TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); + TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); + + // Switch + el.draggable( "option", "handle", "span" ); + TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 0); + TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); + + // And back + el.draggable( "option", "handle", false ); + TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); + TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); + +}); + +test("helper, default, switching after initialization", function() { + expect( 3 ); + + var el = $("#draggable1").draggable(); + TestHelpers.draggable.shouldMove(el); + + el.draggable( "option", "helper", "clone" ); + TestHelpers.draggable.shouldNotMove(el); + + el.draggable( "option", "helper", "original" ); + TestHelpers.draggable.shouldMove(el); + +}); + test("{ helper: 'clone' }, relative", function() { expect( 1 ); @@ -701,8 +1015,267 @@ test("{ opacity: 0.5 }", function() { }); -test("{ zIndex: 10 }", function() { +test("opacity, default, switching after initialization", function() { + expect(3); + + var opacity = null, + el = $("#draggable2").draggable({ + start: function() { + opacity = $(this).css("opacity"); + } + }); + + TestHelpers.draggable.move( el, 1, 1 ); + equal( opacity, 1 ); + + el.draggable( "option", "opacity", 0.5 ); + TestHelpers.draggable.move( el, 2, 1 ); + equal( opacity, 0.5 ); + + el.draggable( "option", "opacity", false ); + TestHelpers.draggable.move( el, 3, 1 ); + equal( opacity, 1 ); + +}); + +asyncTest( "revert and revertDuration", function() { + expect( 4 ); + + var el = $( "#draggable2" ).draggable({ + revert: true, + revertDuration: 0 + }); + TestHelpers.draggable.shouldNotMove( el, "revert: true, revertDuration: 0 should revert immediately" ); + + $( "#draggable2" ).draggable( "option", "revert", "invalid" ); + TestHelpers.draggable.shouldNotMove( el, "revert: invalid, revertDuration: 0 should revert immediately" ); + + $( "#draggable2" ).draggable( "option", "revert", false ); + TestHelpers.draggable.shouldMove( el, "revert: false should allow movement" ); + + $( "#draggable2" ).draggable( "option", { + revert: true, + revertDuration: 200, + stop: function() { + start(); + } + }); + // animation are async, so test for it asynchronously + TestHelpers.draggable.move( el, 50, 50 ); + setTimeout( function() { + ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" ); + }); +}); + +test( "revert: valid", function() { + expect( 1 ); + + var el = $( "#draggable2" ).draggable({ + revert: "valid", + revertDuration: 0 + }); + + $( "#droppable" ).droppable(); + + TestHelpers.draggable.testDrag( el, el, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); +}); + +test( "scope", function() { + expect( 2 ); + + var el = $( "#draggable2" ).draggable({ + scope: "tasks", + revert: "valid", + revertDuration: 0 + }); + + $( "#droppable" ).droppable({ scope: "tasks" }); + + TestHelpers.draggable.testDrag( el, el, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); + + $( "#droppable" ).droppable("destroy").droppable({ scope: "nottasks" }); + + TestHelpers.draggable.testDrag( el, el, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable" ); +}); + +test( "scroll, scrollSensitivity, and scrollSpeed", function() { + expect( 2 ); + + var viewportHeight = $( window ).height(), + el = $( "#draggable1" ).draggable({ scroll: true }), + scrollSensitivity = el.draggable( "option", "scrollSensitivity" ), + scrollSpeed = el.draggable( "option", "scrollSpeed" ); + + el.offset({ + top: viewportHeight - scrollSensitivity - 1, + left: 1 + }); + + el.simulate( "drag", { + dx: 1, + y: viewportHeight - scrollSensitivity - 1, + moves: 1 + }); + + ok( $( window ).scrollTop() === 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" ); + + el.draggable( "option", "scrollSensitivity", scrollSensitivity + 10 ); + + el.offset({ + top: viewportHeight - scrollSensitivity - 1, + left: 1 + }); + + el.simulate( "drag", { + dx: 1, + y: viewportHeight - scrollSensitivity - 1, + moves: 1 + }); + + ok( $( window ).scrollTop() === scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" ); + + TestHelpers.draggable.restoreScroll( document ); +}); + +test( "snap, snapMode, and snapTolerance", function() { + expect( 9 ); + + var newX, newY, + snapTolerance = 15, + el = $( "#draggable1" ).draggable({ + snap: true, + snapMode: "both", + snapTolerance: snapTolerance + }), + element2 = $( "#draggable2" ).draggable(); + + el.offset({ + top: 1, + left: 1 + }); + + newX = element2.offset().left - el.outerWidth() - snapTolerance - 1; + newY = element2.offset().top; + + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap outside the snapTolerance" ); + + newX += 2; + + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + notDeepEqual( el.offset(), { top: newY, left: newX }, "snaps inside the snapTolerance" ); + + el.draggable( "option", "snap", "#draggable2" ); + + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + notDeepEqual( el.offset(), { top: newY, left: newX }, "snaps based on selector" ); + + el.draggable( "option", "snap", "#draggable3" ); + + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap based on invalid selector" ); + + el.draggable( "option", "snap", true ); + el.draggable( "option", "snapTolerance", snapTolerance - 2 ); + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap outside the modified snapTolerance" ); + + el.draggable( "option", "snapTolerance", snapTolerance ); + el.draggable( "option", "snapMode", "inner" ); + + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" ); + + newX = element2.offset().left - snapTolerance - 1; + newY = element2.offset().top; + + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" ); + + newX++; + + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + notDeepEqual( el.offset(), { top: newY, left: newX }, "snaps inside the inner snapTolerance area when snapMode is inner" ); + + el.draggable( "option", "snapMode", "outer" ); + + el.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" ); +}); + +test( "stack", function() { + expect( 2 ); + + var element = $( "#draggable1" ).draggable({ + stack: "#draggable1, #draggable2" + }), + element2 = $( "#draggable2" ).draggable({ + stack: "#draggable1, #draggable2" + }); + + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" ); + + TestHelpers.draggable.move( element2, 1, 1 ); + equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" ); +}); + +test("{ zIndex: 10 }", function() { expect(1); var actual, @@ -723,39 +1296,30 @@ test("{ zIndex: 10 }", function() { }); -test( "{ stack }", function() { - expect( 4 ); +test("zIndex, default, switching after initialization", function() { - var draggable1 = $( "#draggable1" ), - draggable2 = $( "#draggable2" ), - draggable3 = $( "#draggable3" ), - draggable4 = $( "#draggable4" ); + expect(3); - // Set z-index as an inline style. - $( "#draggable1, #draggable2" ) - .css( "zIndex", 100 ) - .draggable({ - stack: "#draggable1, #draggable2" - }); - // Have z-index applied via CSS, see #9077 - $( "#draggable3, #draggable4" ) - .draggable({ - stack: "#draggable3, #draggable4" + var zindex = null, + el = $("#draggable2").draggable({ + start: function() { + zindex = $(this).css("z-index"); + } }); - draggable1.simulate( "drag", { - dx: 1, - dy: 1 - }); - draggable3.simulate( "drag", { - dx: 1, - dy: 1 - }); + el.css( "z-index", 1 ); + + TestHelpers.draggable.move( el, 1, 1 ); + equal( zindex, 1 ); + + el.draggable( "option", "zIndex", 5 ); + TestHelpers.draggable.move( el, 2, 1 ); + equal( zindex, 5 ); + + el.draggable( "option", "zIndex", false ); + TestHelpers.draggable.move( el, 3, 1 ); + equal( zindex, 1 ); - equal( draggable1.css( "zIndex" ), 102); - equal( draggable2.css( "zIndex" ), 101); - equal( draggable3.css( "zIndex" ), 102); - equal( draggable4.css( "zIndex" ), 101); }); })(jQuery); diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index c1ac0ab88..e1c79c6cc 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -11,7 +11,7 @@ TestHelpers.draggable = { }); offsetAfter = el.offset(); - actual = { left: offsetAfter.left, top: offsetAfter.top }, + actual = { left: offsetAfter.left, top: offsetAfter.top }; expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY }; msg = msg ? msg + "." : ""; @@ -50,5 +50,29 @@ TestHelpers.draggable = { }, margin: function(el, side) { return parseInt(el.css("margin-" + side), 10) || 0; + }, + move: function( el, x, y ) { + + $( el ).simulate( "drag", { + dx: x, + dy: y + }); + + }, + trackMouseCss : function( el ) { + el.on( "drag", function() { + el.data( "last_dragged_cursor", $("body").css("cursor") ); + }); + }, + trackAppendedParent : function( el ) { + + // appendTo ignored without being clone + el.draggable( "option", "helper", "clone" ); + + el.on( "drag", function(e,ui) { + // Get what parent is at time of drag + el.data( "last_dragged_parent", ui.helper.parent()[0] ); + }); + } }; \ No newline at end of file diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 27b6b4ef0..7c1fb3361 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -283,14 +283,12 @@ $.widget("ui.draggable", $.ui.mouse, { _getHandle: function(event) { var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; - $(this.options.handle, this.element) - .find("*") - .addBack() - .each(function() { - if(this === event.target) { - handle = true; - } - }); + + this.element.find( this.options.handle ).each(function() { + if(this === event.target) { + handle = true; + } + }); return handle; From dd16205a3fe709a19d7a76342d8dd7f960cccace Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Mon, 4 Mar 2013 01:32:23 -0500 Subject: [PATCH 79/80] Draggable Tests: Style Sweep --- tests/unit/draggable/draggable_options.js | 1148 ++++++++++----------- 1 file changed, 553 insertions(+), 595 deletions(-) diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 0ab41b1f1..b996c644c 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1,139 +1,124 @@ -/* - * draggable_options.js - */ -(function($) { +(function( $ ) { -module("draggable: options"); +module( "draggable: options" ); // TODO: This doesn't actually test whether append happened, possibly remove -test("{ appendTo: 'parent' }, default, no clone", function() { +test( "{ appendTo: 'parent' }, default, no clone", function() { expect( 2 ); - var el = $("#draggable2").draggable({ appendTo: "parent" }); - TestHelpers.draggable.shouldMove(el); - - el = $("#draggable1").draggable({ appendTo: "parent" }); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable2" ).draggable({ appendTo: "parent" }); + TestHelpers.draggable.shouldMove( element ); + element = $( "#draggable1" ).draggable({ appendTo: "parent" }); + TestHelpers.draggable.shouldMove( element ); }); // TODO: This doesn't actually test whether append happened, possibly remove -test("{ appendTo: Element }, no clone", function() { +test( "{ appendTo: Element }, no clone", function() { expect( 2 ); - var el = $("#draggable2").draggable({appendTo: $("#draggable2").parent()[0] }); + var element = $( "#draggable2" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] }); - TestHelpers.draggable.shouldMove(el); + TestHelpers.draggable.shouldMove( element ); - el = $("#draggable1").draggable({ appendTo: $("#draggable2").parent()[0] }); - TestHelpers.draggable.shouldMove(el); + element = $( "#draggable1" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] }); + TestHelpers.draggable.shouldMove( element ); }); // TODO: This doesn't actually test whether append happened, possibly remove -test("{ appendTo: Selector }, no clone", function() { +test( "{ appendTo: Selector }, no clone", function() { expect( 2 ); - var el = $("#draggable2").draggable({ appendTo: "#main" }); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable2" ).draggable({ appendTo: "#main" }); + TestHelpers.draggable.shouldMove( element ); - el = $("#draggable1").draggable({ appendTo: "#main" }); - TestHelpers.draggable.shouldMove(el); + element = $( "#draggable1" ).draggable({ appendTo: "#main" }); + TestHelpers.draggable.shouldMove( element ); }); -test("{ appendTo: 'parent' }, default", function() { +test( "{ appendTo: 'parent' }, default", function() { + expect( 2 ); - expect(2); + var element = $( "#draggable1" ).draggable(); - var el = $("#draggable1").draggable(); + TestHelpers.draggable.trackAppendedParent( element ); - TestHelpers.draggable.trackAppendedParent(el); - - equal( el.draggable( "option", "appendTo" ), "parent" ); - - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), $("#qunit-fixture")[0] ); + equal( element.draggable( "option", "appendTo" ), "parent" ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] ); }); -test("{ appendTo: Element }", function() { +test( "{ appendTo: Element }", function() { + expect( 1 ); - expect(1); + var appendTo = $( "#draggable2" ).parent()[ 0 ], + element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - var appendTo = $("#draggable2").parent()[0], - el = $("#draggable1").draggable({ appendTo: appendTo }); - - TestHelpers.draggable.trackAppendedParent(el); - - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), appendTo ); + TestHelpers.draggable.trackAppendedParent( element ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), appendTo ); }); -test("{ appendTo: jQuery }", function() { +test( "{ appendTo: jQuery }", function() { + expect( 1 ); - expect(1); + var appendTo = $( "#draggable2" ).parent(), + element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - var appendTo = $("#draggable2").parent(), - el = $("#draggable1").draggable({ appendTo: appendTo }); - - TestHelpers.draggable.trackAppendedParent(el); - - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), appendTo[0] ); + TestHelpers.draggable.trackAppendedParent( element ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] ); }); -test("{ appendTo: Selector }", function() { - - expect(1); +test( "{ appendTo: Selector }", function() { + expect( 1 ); var appendTo = "#main", - el = $("#draggable1").draggable({ appendTo: appendTo }); + element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - TestHelpers.draggable.trackAppendedParent(el); - - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), $(appendTo)[0] ); + TestHelpers.draggable.trackAppendedParent( element ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), $(appendTo)[ 0 ] ); }); +test( "appendTo, default, switching after initialization", function() { + expect( 2 ); -test("appendTo, default, switching after initialization", function() { + var element = $( "#draggable1" ).draggable({ helper : "clone" }); - expect(2); + TestHelpers.draggable.trackAppendedParent( element ); - var el = $("#draggable1").draggable({ helper : "clone" }); - - TestHelpers.draggable.trackAppendedParent(el); - - // Move and make sure el was appended to fixture - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), $("#qunit-fixture")[0] ); - - // Move and make sure el was appended to main - el.draggable( "option", "appendTo", $("#main") ); - TestHelpers.draggable.move(el, 2, 2); - equal( el.data("last_dragged_parent"), $("#main")[0] ); + // Move and make sure element was appended to fixture + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] ); + // Move and make sure element was appended to main + element.draggable( "option", "appendTo", $( "#main" ) ); + TestHelpers.draggable.move( element, 2, 2 ); + equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] ); }); -test("{ axis: false }, default", function() { +test( "{ axis: false }, default", function() { expect( 1 ); - var el = $("#draggable2").draggable({ axis: false }); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable2" ).draggable({ axis: false }); + TestHelpers.draggable.shouldMove( element ); }); -test("{ axis: 'x' }", function() { +test( "{ axis: 'x' }", function() { expect( 1 ); - var el = $("#draggable2").draggable({ axis: "x" }); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 0); + var element = $( "#draggable2" ).draggable({ axis: "x" }); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0 ); }); -test("{ axis: 'y' }", function() { +test( "{ axis: 'y' }", function() { expect( 1 ); - var el = $("#draggable2").draggable({ axis: "y" }); - TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 50); + var element = $( "#draggable2" ).draggable({ axis: "y" }); + TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50 ); }); -test("{ axis: ? }, unexpected", function() { - var el, +test( "{ axis: ? }, unexpected", function() { + var element, unexpected = { "true": true, "{}": {}, @@ -146,63 +131,61 @@ test("{ axis: ? }, unexpected", function() { expect( 6 ); $.each(unexpected, function(key, val) { - el = $("#draggable2").draggable({ axis: val }); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50, "axis: " + key); - el.draggable("destroy"); + element = $( "#draggable2" ).draggable({ axis: val }); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50, "axis: " + key ); + element.draggable( "destroy" ); }); }); -test("axis, default, switching after initialization", function() { +test( "axis, default, switching after initialization", function() { + expect( 3 ); - expect(3); + var element = $( "#draggable1" ).draggable({ axis : false }); - var el; - - // Any direction - el = $("#draggable1").draggable({ axis : false }); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); + // Any Direction + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 ); // Only horizontal - el.draggable("option", "axis", "x"); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 0); + element.draggable( "option", "axis", "x" ); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0 ); // Vertical only - el.draggable("option", "axis", "y"); - TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 50); + element.draggable( "option", "axis", "y" ); + TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50 ); }); -test("{ cancel: 'input,textarea,button,select,option' }, default", function() { +test( "{ cancel: 'input,textarea,button,select,option' }, default", function() { expect( 2 ); - $("
          ").appendTo("#main"); + $( "
          " ).appendTo( "#main" ); - var el = $("#draggable-option-cancel-default").draggable({ cancel: "input,textarea,button,select,option" }); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); + TestHelpers.draggable.shouldMove( element ); - el.draggable("destroy"); + element.draggable( "destroy" ); - el = $("#draggable-option-cancel-default").draggable({ cancel: "input,textarea,button,select,option" }); - TestHelpers.draggable.testDrag(el, "#draggable-option-cancel-default input", 50, 50, 0, 0); - el.draggable("destroy"); + element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); + TestHelpers.draggable.testDrag( element, "#draggable-option-cancel-default input", 50, 50, 0, 0 ); + element.draggable( "destroy" ); }); -test("{ cancel: 'span' }", function() { +test( "{ cancel: 'span' }", function() { expect( 2 ); - var el = $("#draggable2").draggable(); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50); + var element = $( "#draggable2" ).draggable(); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50 ); - el.draggable("destroy"); + element.draggable( "destroy" ); - el = $("#draggable2").draggable({ cancel: "span" }); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 0, 0); + element = $( "#draggable2" ).draggable({ cancel: "span" }); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 0, 0 ); }); test( "{ cancel: ? }, unexpected", function() { expect( 6 ); - var el, + var element, unexpected = { "true": true, "false": false, @@ -213,63 +196,62 @@ test( "{ cancel: ? }, unexpected", function() { }; $.each( unexpected, function( key, val ) { - el = $("#draggable2").draggable({ cancel: val }); - TestHelpers.draggable.shouldMove( el, "cancel: " + key ); - el.draggable("destroy"); + element = $( "#draggable2" ).draggable({ cancel: val }); + TestHelpers.draggable.shouldMove( element, "cancel: " + key ); + element.draggable( "destroy" ); }); }); /** -test("{ cancel: Selectors }, matching parent selector", function() { +test( "{ cancel: Selectors }, matching parent selector", function() { expect( 5 ); - var el = $("#draggable2").draggable({ cancel: "span a" }); + var element = $( "#draggable2" ).draggable({ cancel: "span a" }); - $("#qunit-fixture").append( "
          " ); + $( "#qunit-fixture" ).append( "" ); - el.find( "span" ).append( "" ); + element.find( "span" ).append( "" ); - $("#wrapping a").append( el ); + $( "#wrapping a" ).append( element ); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50, "drag span child"); - TestHelpers.draggable.shouldNotMove( $("#draggable2 span a") ); - TestHelpers.draggable.shouldNotMove( $("#wrapping a") ); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span child" ); + TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ) ); + TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) ); - $("#draggable2").draggable( "option", "cancel", "span > a" ); - $("#draggable2").find( "a" ).append( "" ); + $( "#draggable2" ).draggable( "option", "cancel", "span > a" ); + $( "#draggable2" ).find( "a" ).append( "" ); - TestHelpers.draggable.testDrag(el, $("#draggable2 span a").last(), 50, 50, 50, 50, "drag span child"); - TestHelpers.draggable.shouldNotMove( $("#draggable2 span a").first() ); + TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).last(), 50, 50, 50, 50, "drag span child" ); + TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).first() ); }); */ -test("cancel, default, switching after initialization", function() { +test( "cancelement, default, switching after initialization", function() { expect( 3 ); - $("
          ").appendTo("#main"); + $( "
          " ).appendTo( "#main" ); - var input = $("#draggable-option-cancel-default input"), - el = $("#draggable-option-cancel-default").draggable(); + var input = $( "#draggable-option-cancel-default input" ), + element = $( "#draggable-option-cancel-default" ).draggable(); - TestHelpers.draggable.testDrag(el, input, 50, 50, 0, 0); + TestHelpers.draggable.testDrag( element, input, 50, 50, 0, 0 ); - el.draggable("option", "cancel", "textarea" ); - TestHelpers.draggable.testDrag(el, input, 50, 50, 50, 50); - - el.draggable("option", "cancel", "input" ); - TestHelpers.draggable.testDrag(el, input, 50, 50, 0, 0); + element.draggable( "option", "cancel", "textarea" ); + TestHelpers.draggable.testDrag( element, input, 50, 50, 50, 50 ); + element.draggable( "option", "cancel", "input" ); + TestHelpers.draggable.testDrag( element, input, 50, 50, 0, 0 ); }); /* -test("{ connectToSortable: selector }, default", function() { +test( "{ connectToSortable: selector }, default", function() { expect( 1 ); - ok(false, "missing test - untested code is broken code"); + ok(false, "missing test - untested code is broken code" ); }); */ @@ -277,184 +259,185 @@ test( "{ containment: Element }", function() { expect( 1 ); var offsetAfter, - el = $( "#draggable1" ).draggable({ containment: $( "#draggable1" ).parent()[ 0 ] }), - p = el.parent(), + element = $( "#draggable1" ).draggable({ containment: $( "#draggable1" ).parent()[ 0 ] }), + p = element.parent(), po = p.offset(), expected = { - 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") + left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), + top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) }; - el.simulate( "drag", { + element.simulate( "drag", { dx: -100, dy: -100 }); - offsetAfter = el.offset(); - deepEqual(offsetAfter, expected, "compare offset to parent"); + offsetAfter = element.offset(); + deepEqual( offsetAfter, expected, "compare offset to parent" ); }); test( "{ containment: Selector }", function() { expect( 1 ); var offsetAfter, - el = $( "#draggable1" ).draggable({ containment: $( "#qunit-fixture" ) }), - p = el.parent(), + element = $( "#draggable1" ).draggable({ containment: $( "#qunit-fixture" ) }), + p = element.parent(), po = p.offset(), expected = { - 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") + left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), + top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) }; - el.simulate( "drag", { + element.simulate( "drag", { dx: -100, dy: -100 }); - offsetAfter = el.offset(); - deepEqual(offsetAfter, expected, "compare offset to parent"); + offsetAfter = element.offset(); + deepEqual( offsetAfter, expected, "compare offset to parent" ); }); test( "{ containment: [x1, y1, x2, y2] }", function() { expect( 1 ); - var el = $( "#draggable1" ).draggable(), - eo = el.offset(); + var element = $( "#draggable1" ).draggable(), + eo = element.offset(); - el.draggable( "option", "containment", [ eo.left, eo.top, eo.left + el.width() + 5, eo.left + el.width() + 5 ] ); + element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.left + element.width() + 5 ] ); - TestHelpers.draggable.testDrag( el, el, -100, -100, 0, 0 ); + TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 ); }); -test("{ containment: 'parent' }, relative", function() { +test( "{ containment: 'parent' }, relative", function() { expect( 1 ); var offsetAfter, - el = $("#draggable1").draggable({ containment: "parent" }), - p = el.parent(), + element = $( "#draggable1" ).draggable({ containment: "parent" }), + p = element.parent(), po = p.offset(), expected = { - 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") + left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), + top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) }; - el.simulate( "drag", { + element.simulate( "drag", { dx: -100, dy: -100 }); - offsetAfter = el.offset(); - deepEqual(offsetAfter, expected, "compare offset to parent"); + offsetAfter = element.offset(); + deepEqual( offsetAfter, expected, "compare offset to parent" ); }); -test("{ containment: 'parent' }, absolute", function() { +test( "{ containment: 'parent' }, absolute", function() { expect( 1 ); var offsetAfter, - el = $("#draggable2").draggable({ containment: "parent" }), - p = el.parent(), + element = $( "#draggable2" ).draggable({ containment: "parent" }), + p = element.parent(), po = p.offset(), expected = { - 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") + left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), + top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) }; - el.simulate( "drag", { + element.simulate( "drag", { dx: -100, dy: -100 }); - offsetAfter = el.offset(); - deepEqual(offsetAfter, expected, "compare offset to parent"); + offsetAfter = element.offset(); + deepEqual( offsetAfter, expected, "compare offset to parent" ); }); -test("containment, default, switching after initialization", function() { +test( "containment, default, switching after initialization", function() { expect( 2 ); - var el = $("#draggable1").draggable({ containment: false }); + var element = $( "#draggable1" ).draggable({ containment: false }); - TestHelpers.draggable.testDrag(el, el, -100, -100, -100, -100); + TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 ); - el.draggable( "option", "containment", "parent" ) - .css({top:0,left:0}) - .appendTo( $("#main") ); + element.draggable( "option", "containment", "parent" ) + .css({ + top: 0, + left: 0 + }) + .appendTo( $( "#main" ) ); - TestHelpers.draggable.testDrag(el, el, -100, -100, 0, 0); + TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 ); // TODO: Switching back to false does not update to false - // el.draggable( "option", "containment", false ); - // TestHelpers.draggable.testDrag(el, el, -100, -100, -100, -100); - + // element.draggable( "option", "containment", false ); + // TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 ); }); -test("{ cursor: 'auto' }, default", function() { - function getCursor() { return $("#draggable2").css("cursor"); } +test( "{ cursor: 'auto' }, default", function() { + function getCursor() { + return $( "#draggable2" ).css( "cursor" ); + } - expect(2); + expect( 2 ); - var actual, before, after, + var actual, after, expected = "auto", - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ cursor: expected, start: function() { actual = getCursor(); } - }); + }), + before = getCursor(); - before = getCursor(); - el.simulate( "drag", { + element.simulate( "drag", { dx: -1, dy: -1 }); after = getCursor(); - equal(actual, expected, "start callback: cursor '" + expected + "'"); - equal(after, before, "after drag: cursor restored"); - + equal( actual, expected, "start callback: cursor '" + expected + "'" ); + equal( after, before, "after drag: cursor restored" ); }); -test("{ cursor: 'move' }", function() { +test( "{ cursor: 'move' }", function() { + function getCursor() { + return $( "body" ).css( "cursor" ); + } - function getCursor() { return $("body").css("cursor"); } + expect( 2 ); - expect(2); - - var actual, before, after, + var actual, after, expected = "move", - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ cursor: expected, start: function() { actual = getCursor(); } - }); + }), + before = getCursor(); - before = getCursor(); - el.simulate( "drag", { + element.simulate( "drag", { dx: -1, dy: -1 }); after = getCursor(); - equal(actual, expected, "start callback: cursor '" + expected + "'"); - equal(after, before, "after drag: cursor restored"); - + equal( actual, expected, "start callback: cursor '" + expected + "'" ); + equal( after, before, "after drag: cursor restored" ); }); -test("cursor, default, switching after initialization", function() { +test( "cursor, default, switching after initialization", function() { + expect( 3 ); - expect(3); + var element = $( "#draggable1" ).draggable(); - var el = $("#draggable1").draggable(); + TestHelpers.draggable.trackMouseCss( element ); - TestHelpers.draggable.trackMouseCss( el ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_cursor" ), "auto" ); - TestHelpers.draggable.move( el, 1, 1 ); - equal( el.data("last_dragged_cursor"), "auto" ); - - el.draggable( "option", "cursor", "move" ); - TestHelpers.draggable.move( el, 1, 1 ); - equal( el.data("last_dragged_cursor"), "move" ); - - el.draggable( "option", "cursor", "ns-resize" ); - TestHelpers.draggable.move( el, 1, 1 ); - equal( el.data("last_dragged_cursor"), "ns-resize" ); + element.draggable( "option", "cursor", "move" ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_cursor" ), "move" ); + element.draggable( "option", "cursor", "ns-resize" ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_cursor" ), "ns-resize" ); }); test( "cursorAt", function() { @@ -473,7 +456,7 @@ test( "cursorAt", function() { $.each( tests, function( testName, testData ) { $.each( [ "relative", "absolute" ], function( i, position ) { - var el = $( "#draggable" + ( i + 1 ) ).draggable({ + var element = $( "#draggable" + ( i + 1 ) ).draggable({ cursorAt: testData.cursorAt, drag: function( event, ui ) { if( !testData.cursorAt ) { @@ -489,7 +472,7 @@ test( "cursorAt", function() { } }); - el.simulate( "drag", { + element.simulate( "drag", { moves: 1, dx: deltaX, dy: deltaY @@ -499,7 +482,6 @@ test( "cursorAt", function() { }); test( "cursorAt, switching after initialization", function() { - expect( 24 ); var deltaX = -3, @@ -515,9 +497,9 @@ test( "cursorAt, switching after initialization", function() { $.each( tests, function( testName, testData ) { $.each( [ "relative", "absolute" ], function( i, position ) { - var el = $( "#draggable" + ( i + 1 ) ); + var element = $( "#draggable" + ( i + 1 ) ); - el.draggable({ + element.draggable({ drag: function( event, ui ) { if( !testData.cursorAt ) { equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); @@ -532,527 +514,502 @@ test( "cursorAt, switching after initialization", function() { } }); - el.draggable( "option", "cursorAt", false ); - el.draggable( "option", "cursorAt", testData.cursorAt ); + element.draggable( "option", "cursorAt", false ); + element.draggable( "option", "cursorAt", testData.cursorAt ); - el.simulate( "drag", { + element.simulate( "drag", { moves: 1, dx: deltaX, dy: deltaY }); }); }); - }); - test( "disabled", function() { - expect( 3 ); - var el = $("#draggable1").draggable(); + var element = $( "#draggable1" ).draggable(); - TestHelpers.draggable.shouldMove(el); + TestHelpers.draggable.shouldMove( element ); - el.draggable( "option", "disabled", true ); - TestHelpers.draggable.shouldNotMove(el); - - el.draggable( "option", "disabled", false ); - TestHelpers.draggable.shouldMove(el); + element.draggable( "option", "disabled", true ); + TestHelpers.draggable.shouldNotMove( element ); + element.draggable( "option", "disabled", false ); + TestHelpers.draggable.shouldMove( element ); }); -test("{ grid: [50, 50] }, relative", function() { +test( "{ grid: [50, 50] }, relative", function() { expect( 2 ); - var el = $("#draggable1").draggable({ grid: [50, 50] }); - TestHelpers.draggable.testDrag(el, el, 24, 24, 0, 0); - TestHelpers.draggable.testDrag(el, el, 26, 25, 50, 50); + var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] }); + TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 ); + TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 ); }); -test("{ grid: [50, 50] }, absolute", function() { +test( "{ grid: [50, 50] }, absolute", function() { expect( 2 ); - var el = $("#draggable2").draggable({ grid: [50, 50] }); - TestHelpers.draggable.testDrag(el, el, 24, 24, 0, 0); - TestHelpers.draggable.testDrag(el, el, 26, 25, 50, 50); + var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] }); + TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 ); + TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 ); }); -test("grid, switching after initialization", function() { - +test( "grid, switching after initialization", function() { expect( 4 ); - var el = $("#draggable1").draggable(); + var element = $( "#draggable1" ).draggable(); + // Forward - TestHelpers.draggable.testDrag(el, el, 24, 24, 24, 24); - TestHelpers.draggable.testDrag(el, el, 0, 0, 0, 0); + TestHelpers.draggable.testDrag( element, element, 24, 24, 24, 24 ); + TestHelpers.draggable.testDrag( element, element, 0, 0, 0, 0 ); - el.draggable( "option", "grid", [50,50] ); - - TestHelpers.draggable.testDrag(el, el, 24, 24, 0, 0); - TestHelpers.draggable.testDrag(el, el, 26, 25, 50, 50); + element.draggable( "option", "grid", [ 50,50 ] ); + TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 ); + TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 ); }); -test("{ handle: 'span' }", function() { +test( "{ handle: 'span' }", function() { expect( 2 ); - var el = $("#draggable2").draggable({ handle: "span" }); + var element = $( "#draggable2" ).draggable({ handle: "span" }); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50, "drag span"); - TestHelpers.draggable.shouldNotMove(el, "drag element"); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span" ); + TestHelpers.draggable.shouldNotMove( element, "drag element" ); }); /* -test("{ handle: Selectors }, matching parent selector", function() { +test( "{ handle: Selectors }, matching parent selector", function() { expect( 4 ); - var el = $("#draggable2").draggable({ handle: "span a" }); + var element = $( "#draggable2" ).draggable({ handle: "span a" }); - $("#qunit-fixture").append( "
          " ); + $( "#qunit-fixture" ).append( "" ); - el.find( "span" ).append( "" ); + element.find( "span" ).append( "" ); - $("#wrapping a").append( el ); + $( "#wrapping a" ).append( element ); - TestHelpers.draggable.testDrag(el, "#draggable2 span a", 50, 50, 50, 50, "drag span child"); - TestHelpers.draggable.shouldNotMove( $("#wrapping a") ); + TestHelpers.draggable.testDrag( element, "#draggable2 span a", 50, 50, 50, 50, "drag span child" ); + TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) ); - $("#draggable2").draggable( "option", "handle", "span > a" ); - $("#draggable2").find( "a" ).append( "" ); + $( "#draggable2" ).draggable( "option", "handle", "span > a" ); + $( "#draggable2" ).find( "a" ).append( "" ); - TestHelpers.draggable.testDrag(el, $("#draggable2 span a").first(), 50, 50, 50, 50, "drag span child"); - TestHelpers.draggable.shouldNotMove( $("#draggable2 span a").last() ); + TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).first(), 50, 50, 50, 50, "drag span child" ); + TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).last() ); }); */ -test("handle, default, switching after initialization", function() { +test( "handle, default, switching after initialization", function() { expect( 6 ); - var el = $("#draggable2").draggable(); + var element = $( "#draggable2" ).draggable(); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 ); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 ); // Switch - el.draggable( "option", "handle", "span" ); - TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 0); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); + element.draggable( "option", "handle", "span" ); + TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 0 ); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 ); // And back - el.draggable( "option", "handle", false ); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); - + element.draggable( "option", "handle", false ); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 ); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 ); }); -test("helper, default, switching after initialization", function() { +test( "helper, default, switching after initialization", function() { expect( 3 ); - var el = $("#draggable1").draggable(); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable1" ).draggable(); + TestHelpers.draggable.shouldMove( element ); - el.draggable( "option", "helper", "clone" ); - TestHelpers.draggable.shouldNotMove(el); - - el.draggable( "option", "helper", "original" ); - TestHelpers.draggable.shouldMove(el); + element.draggable( "option", "helper", "clone" ); + TestHelpers.draggable.shouldNotMove( element ); + element.draggable( "option", "helper", "original" ); + TestHelpers.draggable.shouldMove( element ); }); -test("{ helper: 'clone' }, relative", function() { +test( "{ helper: 'clone' }, relative", function() { expect( 1 ); - var el = $("#draggable1").draggable({ helper: "clone" }); - TestHelpers.draggable.shouldNotMove(el); + var element = $( "#draggable1" ).draggable({ helper: "clone" }); + TestHelpers.draggable.shouldNotMove( element ); }); -test("{ helper: 'clone' }, absolute", function() { +test( "{ helper: 'clone' }, absolute", function() { expect( 1 ); - var el = $("#draggable2").draggable({ helper: "clone" }); - TestHelpers.draggable.shouldNotMove(el); + var element = $( "#draggable2" ).draggable({ helper: "clone" }); + TestHelpers.draggable.shouldNotMove( element ); }); -test("{ helper: 'original' }, relative, with scroll offset on parent", function() { +test( "{ helper: 'original' }, relative, with scroll offset on parent", function() { expect( 3 ); - var el = $("#draggable1").draggable({ helper: "original" }); + var element = $( "#draggable1" ).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - }); -test("{ helper: 'original' }, relative, with scroll offset on root", function() { +test( "{ helper: 'original' }, relative, with scroll offset on root", function() { expect( 3 ); - var el = $("#draggable1").draggable({ helper: "original" }); + var element = $( "#draggable1" ).draggable({ helper: "original" }); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); - - TestHelpers.draggable.restoreScroll("root"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, relative, with scroll offset on root and parent", function() { +test( "{ helper: 'original' }, relative, with scroll offset on root and parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").draggable({ helper: "original" }); + var element = $( "#draggable1" ).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll("root"); - + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, absolute, with scroll offset on parent", function() { +test( "{ helper: 'original' }, absolute, with scroll offset on parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); + var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - }); -test("{ helper: 'original' }, absolute, with scroll offset on root", function() { +test( "{ helper: 'original' }, absolute, with scroll offset on root", function() { + expect( 3 ); - expect(3); + var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); - var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); - - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); - - TestHelpers.draggable.restoreScroll("root"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, absolute, with scroll offset on root and parent", function() { +test( "{ helper: 'original' }, absolute, with scroll offset on root and parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); + var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll("root"); - + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, fixed, with scroll offset on parent", function() { +test( "{ helper: 'original' }, fixed, with scroll offset on parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); + var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - }); -test("{ helper: 'original' }, fixed, with scroll offset on root", function() { +test( "{ helper: 'original' }, fixed, with scroll offset on root", function() { + expect( 3 ); - expect(3); + var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); - var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); - - TestHelpers.draggable.restoreScroll("root"); + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, fixed, with scroll offset on root and parent", function() { +test( "{ helper: 'original' }, fixed, with scroll offset on root and parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); + var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll("root"); - + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'clone' }, absolute", function() { - - expect(1); +test( "{ helper: 'clone' }, absolute", function() { + expect( 1 ); var helperOffset = null, - origOffset = $("#draggable1").offset(), - el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { + origOffset = $( "#draggable1" ).offset(), + element = $( "#draggable1" ).draggable({ helper: "clone", drag: function( event, ui) { helperOffset = ui.helper.offset(); } }); - el.simulate( "drag", { + element.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); }); -test("{ helper: 'clone' }, absolute with scroll offset on parent", function() { - - expect(3); +test( "{ helper: 'clone' }, absolute with scroll offset on parent", function() { + expect( 3 ); TestHelpers.draggable.setScroll(); var helperOffset = null, origOffset = null, - el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { - helperOffset = ui.helper.offset(); - } }); - - $("#main").css("position", "relative"); - origOffset = $("#draggable1").offset(); - 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(); - 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(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - TestHelpers.draggable.restoreScroll(); - -}); - -test("{ helper: 'clone' }, absolute with scroll offset on root", function() { - - expect(3); - - TestHelpers.draggable.setScroll("root"); - var helperOffset = null, - origOffset = null, - el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { - helperOffset = ui.helper.offset(); - } }); - - $("#main").css("position", "relative"); - origOffset = $("#draggable1").offset(); - 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(); - 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(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - TestHelpers.draggable.restoreScroll("root"); - -}); - -test("{ helper: 'clone' }, absolute with scroll offset on root and parent", function() { - - expect(3); - - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.setScroll(); - - var helperOffset = null, - origOffset = null, - el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { - helperOffset = ui.helper.offset(); - } }); - - $("#main").css("position", "relative"); - origOffset = $("#draggable1").offset(); - 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(); - 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(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - TestHelpers.draggable.restoreScroll("root"); - TestHelpers.draggable.restoreScroll(); - -}); - -test("{ opacity: 0.5 }", function() { - - expect(1); - - var opacity = null, - el = $("#draggable2").draggable({ - opacity: 0.5, - start: function() { - opacity = $(this).css("opacity"); + element = $( "#draggable1" ).draggable({ + helper: "clone", + drag: function( event, ui) { + helperOffset = ui.helper.offset(); } }); - el.simulate( "drag", { + $( "#main" ).css( "position", "relative" ); + origOffset = $( "#draggable1" ).offset(); + element.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(); + element.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(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + TestHelpers.draggable.restoreScroll(); +}); + +test( "{ helper: 'clone' }, absolute with scroll offset on root", function() { + expect( 3 ); + + TestHelpers.draggable.setScroll( "root" ); + var helperOffset = null, + origOffset = null, + element = $( "#draggable1" ).draggable({ + helper: "clone", + drag: function( event, ui) { + helperOffset = ui.helper.offset(); + } + }); + + $( "#main" ).css( "position", "relative" ); + origOffset = $( "#draggable1" ).offset(); + element.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(); + element.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(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + TestHelpers.draggable.restoreScroll( "root" ); +}); + +test( "{ helper: 'clone' }, absolute with scroll offset on root and parent", function() { + expect( 3 ); + + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.setScroll(); + + var helperOffset = null, + origOffset = null, + element = $( "#draggable1" ).draggable({ + helper: "clone", + drag: function( event, ui) { + helperOffset = ui.helper.offset(); + } + }); + + $( "#main" ).css( "position", "relative" ); + origOffset = $( "#draggable1" ).offset(); + element.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(); + element.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(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + TestHelpers.draggable.restoreScroll( "root" ); + TestHelpers.draggable.restoreScroll(); +}); + +test( "{ opacity: 0.5 }", function() { + expect( 1 ); + + var opacity = null, + element = $( "#draggable2" ).draggable({ + opacity: 0.5, + start: function() { + opacity = $(this).css( "opacity" ); + } + }); + + element.simulate( "drag", { dx: -1, dy: -1 }); - equal(opacity, 0.5, "start callback: opacity is"); - + equal( opacity, 0.5, "start callback: opacity is" ); }); -test("opacity, default, switching after initialization", function() { - - expect(3); +test( "opacity, default, switching after initialization", function() { + expect( 3 ); var opacity = null, - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ start: function() { - opacity = $(this).css("opacity"); + opacity = $(this).css( "opacity" ); } }); - TestHelpers.draggable.move( el, 1, 1 ); + TestHelpers.draggable.move( element, 1, 1 ); equal( opacity, 1 ); - el.draggable( "option", "opacity", 0.5 ); - TestHelpers.draggable.move( el, 2, 1 ); + element.draggable( "option", "opacity", 0.5 ); + TestHelpers.draggable.move( element, 2, 1 ); equal( opacity, 0.5 ); - el.draggable( "option", "opacity", false ); - TestHelpers.draggable.move( el, 3, 1 ); + element.draggable( "option", "opacity", false ); + TestHelpers.draggable.move( element, 3, 1 ); equal( opacity, 1 ); - }); asyncTest( "revert and revertDuration", function() { expect( 4 ); - var el = $( "#draggable2" ).draggable({ + var element = $( "#draggable2" ).draggable({ revert: true, revertDuration: 0 }); - TestHelpers.draggable.shouldNotMove( el, "revert: true, revertDuration: 0 should revert immediately" ); + TestHelpers.draggable.shouldNotMove( element, "revert: true, revertDuration: 0 should revert immediately" ); $( "#draggable2" ).draggable( "option", "revert", "invalid" ); - TestHelpers.draggable.shouldNotMove( el, "revert: invalid, revertDuration: 0 should revert immediately" ); + TestHelpers.draggable.shouldNotMove( element, "revert: invalid, revertDuration: 0 should revert immediately" ); $( "#draggable2" ).draggable( "option", "revert", false ); - TestHelpers.draggable.shouldMove( el, "revert: false should allow movement" ); + TestHelpers.draggable.shouldMove( element, "revert: false should allow movement" ); $( "#draggable2" ).draggable( "option", { revert: true, @@ -1061,8 +1018,9 @@ asyncTest( "revert and revertDuration", function() { start(); } }); + // animation are async, so test for it asynchronously - TestHelpers.draggable.move( el, 50, 50 ); + TestHelpers.draggable.move( element, 50, 50 ); setTimeout( function() { ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" ); }); @@ -1071,20 +1029,20 @@ asyncTest( "revert and revertDuration", function() { test( "revert: valid", function() { expect( 1 ); - var el = $( "#draggable2" ).draggable({ + var element = $( "#draggable2" ).draggable({ revert: "valid", revertDuration: 0 }); $( "#droppable" ).droppable(); - TestHelpers.draggable.testDrag( el, el, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); + TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); }); test( "scope", function() { expect( 2 ); - var el = $( "#draggable2" ).draggable({ + var element = $( "#draggable2" ).draggable({ scope: "tasks", revert: "valid", revertDuration: 0 @@ -1092,27 +1050,27 @@ test( "scope", function() { $( "#droppable" ).droppable({ scope: "tasks" }); - TestHelpers.draggable.testDrag( el, el, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); + TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); - $( "#droppable" ).droppable("destroy").droppable({ scope: "nottasks" }); + $( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" }); - TestHelpers.draggable.testDrag( el, el, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable" ); + TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable" ); }); test( "scroll, scrollSensitivity, and scrollSpeed", function() { expect( 2 ); var viewportHeight = $( window ).height(), - el = $( "#draggable1" ).draggable({ scroll: true }), - scrollSensitivity = el.draggable( "option", "scrollSensitivity" ), - scrollSpeed = el.draggable( "option", "scrollSpeed" ); + element = $( "#draggable1" ).draggable({ scroll: true }), + scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), + scrollSpeed = element.draggable( "option", "scrollSpeed" ); - el.offset({ + element.offset({ top: viewportHeight - scrollSensitivity - 1, left: 1 }); - el.simulate( "drag", { + element.simulate( "drag", { dx: 1, y: viewportHeight - scrollSensitivity - 1, moves: 1 @@ -1120,14 +1078,14 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() { ok( $( window ).scrollTop() === 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" ); - el.draggable( "option", "scrollSensitivity", scrollSensitivity + 10 ); + element.draggable( "option", "scrollSensitivity", scrollSensitivity + 10 ); - el.offset({ + element.offset({ top: viewportHeight - scrollSensitivity - 1, left: 1 }); - el.simulate( "drag", { + element.simulate( "drag", { dx: 1, y: viewportHeight - scrollSensitivity - 1, moves: 1 @@ -1143,119 +1101,119 @@ test( "snap, snapMode, and snapTolerance", function() { var newX, newY, snapTolerance = 15, - el = $( "#draggable1" ).draggable({ + element = $( "#draggable1" ).draggable({ snap: true, snapMode: "both", snapTolerance: snapTolerance }), element2 = $( "#draggable2" ).draggable(); - el.offset({ + element.offset({ top: 1, left: 1 }); - newX = element2.offset().left - el.outerWidth() - snapTolerance - 1; + newX = element2.offset().left - element.outerWidth() - snapTolerance - 1; newY = element2.offset().top; - el.simulate( "drag", { + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap outside the snapTolerance" ); + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the snapTolerance" ); newX += 2; - el.simulate( "drag", { + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - notDeepEqual( el.offset(), { top: newY, left: newX }, "snaps inside the snapTolerance" ); + notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the snapTolerance" ); - el.draggable( "option", "snap", "#draggable2" ); + element.draggable( "option", "snap", "#draggable2" ); - el.simulate( "drag", { + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - notDeepEqual( el.offset(), { top: newY, left: newX }, "snaps based on selector" ); + notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps based on selector" ); - el.draggable( "option", "snap", "#draggable3" ); + element.draggable( "option", "snap", "#draggable3" ); - el.simulate( "drag", { + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap based on invalid selector" ); + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap based on invalid selector" ); - el.draggable( "option", "snap", true ); - el.draggable( "option", "snapTolerance", snapTolerance - 2 ); - el.simulate( "drag", { + element.draggable( "option", "snap", true ); + element.draggable( "option", "snapTolerance", snapTolerance - 2 ); + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap outside the modified snapTolerance" ); + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the modified snapTolerance" ); - el.draggable( "option", "snapTolerance", snapTolerance ); - el.draggable( "option", "snapMode", "inner" ); + element.draggable( "option", "snapTolerance", snapTolerance ); + element.draggable( "option", "snapMode", "inner" ); - el.simulate( "drag", { + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" ); + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" ); newX = element2.offset().left - snapTolerance - 1; newY = element2.offset().top; - el.simulate( "drag", { + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" ); + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" ); newX++; - el.simulate( "drag", { + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - notDeepEqual( el.offset(), { top: newY, left: newX }, "snaps inside the inner snapTolerance area when snapMode is inner" ); + notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the inner snapTolerance area when snapMode is inner" ); - el.draggable( "option", "snapMode", "outer" ); + element.draggable( "option", "snapMode", "outer" ); - el.simulate( "drag", { + element.simulate( "drag", { handle: "corner", x: newX, y: newY, moves: 1 }); - deepEqual( el.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" ); + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" ); }); test( "stack", function() { @@ -1275,51 +1233,51 @@ test( "stack", function() { equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" ); }); -test("{ zIndex: 10 }", function() { - expect(1); +test( "{ zIndex: 10 }", function() { + expect( 1 ); var actual, expected = 10, - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ zIndex: expected, start: function() { - actual = $(this).css("zIndex"); + actual = $(this).css( "zIndex" ); } }); - el.simulate( "drag", { + element.simulate( "drag", { dx: -1, dy: -1 }); - equal(actual, expected, "start callback: zIndex is"); + equal( actual, expected, "start callback: zIndex is" ); }); -test("zIndex, default, switching after initialization", function() { +test( "zIndex, default, switching after initialization", function() { - expect(3); + expect( 3 ); var zindex = null, - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ start: function() { - zindex = $(this).css("z-index"); + zindex = $(this).css( "z-index" ); } }); - el.css( "z-index", 1 ); + element.css( "z-index", 1 ); - TestHelpers.draggable.move( el, 1, 1 ); + TestHelpers.draggable.move( element, 1, 1 ); equal( zindex, 1 ); - el.draggable( "option", "zIndex", 5 ); - TestHelpers.draggable.move( el, 2, 1 ); + element.draggable( "option", "zIndex", 5 ); + TestHelpers.draggable.move( element, 2, 1 ); equal( zindex, 5 ); - el.draggable( "option", "zIndex", false ); - TestHelpers.draggable.move( el, 3, 1 ); + element.draggable( "option", "zIndex", false ); + TestHelpers.draggable.move( element, 3, 1 ); equal( zindex, 1 ); }); -})(jQuery); +})( jQuery ); From 5a04d237ddeb9f290ad1293c97a2e823e116fceb Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Mon, 4 Mar 2013 09:58:23 -0500 Subject: [PATCH 80/80] Draggable Tests: Fix snap test failures in IE8 --- tests/unit/draggable/draggable_options.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index b996c644c..c000a136b 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1113,7 +1113,7 @@ test( "snap, snapMode, and snapTolerance", function() { left: 1 }); - newX = element2.offset().left - element.outerWidth() - snapTolerance - 1; + newX = element2.offset().left - element.outerWidth() - snapTolerance - 2; newY = element2.offset().top; element.simulate( "drag", { @@ -1125,7 +1125,7 @@ test( "snap, snapMode, and snapTolerance", function() { deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the snapTolerance" ); - newX += 2; + newX += 3; element.simulate( "drag", { handle: "corner",