From 948f874266271f6e02a5e9d88691742291fdd269 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 29 Nov 2012 09:08:48 -0500 Subject: Button tests: Work around a quirk in Opera. --- tests/unit/button/button_core.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index d53dedf90..991e4bceb 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -92,7 +92,7 @@ test("buttonset (rtl)", function() { // remove this when simulate properly simulates this // see http://yuilibrary.com/projects/yui2/ticket/2528826 fore more info if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) { - test( "ensure checked and aria after single click on checkbox label button, see #5518", function() { + asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function() { expect( 3 ); $("#check2").button().change( function() { @@ -100,7 +100,16 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) { ok( this.checked, "checked ok" ); ok( lbl.attr("aria-pressed") === "true", "aria ok" ); ok( lbl.hasClass("ui-state-active"), "ui-state-active ok" ); - }).button("widget").simulate("mousedown").simulate("click").simulate("mouseup"); + }); + + // support: Opera + // Opera doesn't trigger a change event when this is done synchronously. + // This seems to be a side effect of another test, but until that can be + // tracked down, this delay will have to do. + setTimeout(function() { + $("#check2").button("widget").simulate("click"); + start(); + }, 1 ); }); } -- cgit v1.2.3 From 840e0cd4a8cf1709724e6f0a266f39a7f56ad617 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 29 Nov 2012 09:49:25 -0500 Subject: Progressbar demos: Removed animated demo. --- demos/progressbar/animated.html | 34 ---------------------------------- demos/progressbar/index.html | 1 - 2 files changed, 35 deletions(-) delete mode 100644 demos/progressbar/animated.html diff --git a/demos/progressbar/animated.html b/demos/progressbar/animated.html deleted file mode 100644 index 5cb1872ed..000000000 --- a/demos/progressbar/animated.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - jQuery UI Progressbar - Animated - - - - - - - - - - -
- -
-

-This progressbar has an animated fill by setting the -ui-progressbar-overlay class -on the -.ui-progressbar-value -element's overlay div. -

-
- - diff --git a/demos/progressbar/index.html b/demos/progressbar/index.html index df3483816..2dcf6be9c 100644 --- a/demos/progressbar/index.html +++ b/demos/progressbar/index.html @@ -8,7 +8,6 @@ -- cgit v1.2.3 From eb938a67a1f8ee0151fd6414d22a9e260894c935 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 29 Nov 2012 09:51:04 -0500 Subject: Progressbar demos: Removed resize demo. --- demos/progressbar/index.html | 1 - demos/progressbar/resize.html | 33 --------------------------------- 2 files changed, 34 deletions(-) delete mode 100644 demos/progressbar/resize.html diff --git a/demos/progressbar/index.html b/demos/progressbar/index.html index 2dcf6be9c..3997d8f77 100644 --- a/demos/progressbar/index.html +++ b/demos/progressbar/index.html @@ -8,7 +8,6 @@ diff --git a/demos/progressbar/resize.html b/demos/progressbar/resize.html deleted file mode 100644 index eac40c0c0..000000000 --- a/demos/progressbar/resize.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - jQuery UI Progressbar - Resizable - - - - - - - - - - - - -
-
-
- -
-

The progress bar's widths are specified in percentages for flexible sizing so it will resize to fit its container. Try resizing the height and width of this bar to see how it maintains the correct proportions. (This is not necessarily a real-world example, but it's a good illustration of how flexibly all the plugins are coded.)

-
- - -- cgit v1.2.3 From 24d9141597f16fdc84b1412683a7e66388f5f622 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Thu, 29 Nov 2012 17:40:31 +0100 Subject: Dialog: Use consistent code for appending to body --- ui/jquery.ui.dialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 808d31d5b..46fc7adf4 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -676,7 +676,7 @@ $.widget("ui.dialog", { // reuse old instances due to IE memory leak with alpha transparency (see #5185) var $el = this.overlay = ( $.ui.dialog.overlay.oldInstances.pop() || $( "
" ).addClass( "ui-widget-overlay ui-front" ) ); - $el.appendTo( document.body ); + $el.appendTo( this.document[ 0 ].body ); this._on( $el, { mousedown: "_keepFocus" -- cgit v1.2.3 From a5d50da591fdf329f05cb38fb169627018093528 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 29 Nov 2012 12:06:22 -0500 Subject: Progressbar demos: Cleanup. --- demos/progressbar/indeterminate.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/demos/progressbar/indeterminate.html b/demos/progressbar/indeterminate.html index 34ce6da47..b07211496 100644 --- a/demos/progressbar/indeterminate.html +++ b/demos/progressbar/indeterminate.html @@ -16,27 +16,27 @@ }); $( "button" ).on( "click", function( event ) { var target = $( event.target ), - pbar = $( "#progressbar" ), - pbarValue = pbar.find( ".ui-progressbar-value" ); + progressbar = $( "#progressbar" ), + progressbarValue = progressbar.find( ".ui-progressbar-value" ); if ( target.is( "#numButton" ) ) { - pbar.progressbar( "option", { + progressbar.progressbar( "option", { value: Math.floor( Math.random() * 100 ) }); } else if ( target.is( "#colorButton" ) ) { - pbarValue.css({ + progressbarValue.css({ "background": '#' + Math.floor( Math.random() * 16777215 ).toString( 16 ) }); } else if ( target.is( "#falseButton" ) ) { - pbar.progressbar( "option", "value", false ); + progressbar.progressbar( "option", "value", false ); } }); }); -- cgit v1.2.3 From 83e2a59ace6f00b785dd6f46fd63b416d86e0cc2 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Thu, 29 Nov 2012 17:30:17 +0000 Subject: Button: fixed inconsistent button styling in most browsers. Fixes #7996 - Button: Inconsistent styling based on markup --- themes/base/jquery.ui.button.css | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/themes/base/jquery.ui.button.css b/themes/base/jquery.ui.button.css index 5588eb42c..602f93a92 100644 --- a/themes/base/jquery.ui.button.css +++ b/themes/base/jquery.ui.button.css @@ -12,8 +12,10 @@ display: inline-block; position: relative; padding: 0; + line-height: normal; margin-right: .1em; cursor: pointer; + vertical-align: middle; text-align: center; zoom: 1; overflow: visible; /* removes extra width in IE */ @@ -43,7 +45,7 @@ button.ui-button-icons-only { /* button text element */ .ui-button .ui-button-text { display: inline-block; - line-height: 1.4; + line-height: normal; } .ui-button-text-only .ui-button-text { padding: .4em 1em; @@ -105,7 +107,8 @@ input.ui-button { } /* workarounds */ -/* reset extra padding in Firefox */ +/* reset extra padding in Firefox, see h5bp.com/l */ +input.ui-button::-moz-focus-inner, button.ui-button::-moz-focus-inner { border: 0; padding: 0; -- cgit v1.2.3 From d7bff010691b542d918245bac11beac2b93b3462 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Thu, 29 Nov 2012 19:26:29 +0000 Subject: Theme: removed or changed occurrences of zoom. Fixes #7975 - Remove invalid CSS for legacy browsers Because of overlapping issues, this also reverts most of e77edc60 and fixes it in a different way. --- demos/button/toolbar.html | 14 +++++++------- themes/base/jquery.ui.accordion.css | 3 +-- themes/base/jquery.ui.button.css | 3 +-- themes/base/jquery.ui.core.css | 2 +- themes/base/jquery.ui.dialog.css | 1 - themes/base/jquery.ui.menu.css | 3 +-- themes/base/jquery.ui.tabs.css | 1 - themes/base/jquery.ui.theme.css | 5 +++-- 8 files changed, 14 insertions(+), 18 deletions(-) diff --git a/demos/button/toolbar.html b/demos/button/toolbar.html index 5be3668f6..62c1ca83a 100644 --- a/demos/button/toolbar.html +++ b/demos/button/toolbar.html @@ -11,12 +11,12 @@ + + + + + + + + + +
Loading...
+ +
+

Custom updated label demo.

+
+ + -- cgit v1.2.3 From 13505e5945e5532c3d56424d50ad109c665d205f Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 30 Nov 2012 13:08:56 +0100 Subject: Dialog: Ensure all animations finish and clean up themselve when destroying dialog. Fixes #5860 - Dialog: Destroying a dialog during animated close leaves .ui-effects-wrapper in DOM. --- tests/unit/dialog/dialog.html | 2 ++ tests/unit/dialog/dialog_options.js | 9 +++++++++ ui/jquery.ui.dialog.js | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 5413e7cc1..cdc846478 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -23,6 +23,8 @@ "ui/jquery.ui.draggable.js", "ui/jquery.ui.resizable.js", "ui/jquery.ui.button.js", + "ui/jquery.ui.effect.js", + "ui/jquery.ui.effect-clip.js", "ui/jquery.ui.dialog.js" ] }); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index f01a1a2a8..fd7d91827 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -212,6 +212,15 @@ test("height", function() { el.remove(); }); +asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() { + expect( 1 ); + $( "#dialog1" ).dialog({ hide: "clip" }).dialog( "close" ).dialog( "destroy" ); + setTimeout(function() { + equal( $( ".ui-effects-wrapper" ).length, 0 ); + start(); + }, 500); +}); + test("maxHeight", function() { expect(3); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 46fc7adf4..4a8b9964f 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -131,7 +131,7 @@ $.widget("ui.dialog", { // without detaching first, the following becomes really slow .detach(); - this.uiDialog.remove(); + this.uiDialog.stop( true, true ).remove(); if ( this.originalTitle ) { this.element.attr( "title", this.originalTitle ); -- cgit v1.2.3 From c6a755dd8c330de78f407dd037eb600a240f23ee Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sat, 17 Nov 2012 21:47:23 +0100 Subject: Grunt: Set testswarm/browserSets from JSON file. File on jq03.jquery.com is already updated. --- build/tasks/testswarm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index 96415aa74..8e88007bb 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -54,7 +54,7 @@ function submit( commit, tests, configFile, version, done ) { runMax: config.runMax, "runNames[]": Object.keys( tests ), "runUrls[]": testUrls, - "browserSets[]": [ "popular-no-ie6" ] + "browserSets[]": config.browserSets }); } -- cgit v1.2.3 From 5ba267e7c78f0bc257383c822d241c5369e8e49d Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 3 Dec 2012 10:36:55 -0500 Subject: Resizable: Respect containment for alsoResize option. Fixes #4603 - Resizable: alsoResize option doesn't work with containment. Fixes #5559 - Dialog: Content grows bigger than widget on resize at document edge. --- tests/unit/resizable/resizable.html | 26 ++++--- tests/unit/resizable/resizable_options.js | 55 ++++++++++++++ ui/jquery.ui.resizable.js | 122 +++++++++++++++--------------- 3 files changed, 132 insertions(+), 71 deletions(-) diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html index 0a27f2a80..255c98887 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.html @@ -31,15 +31,19 @@ @@ -51,7 +55,9 @@
    -
    I'm a resizable.
    +
    +
    I'm a resizable.
    +
    solid gray
    diff --git a/tests/unit/resizable/resizable_options.js b/tests/unit/resizable/resizable_options.js index 4b47762ab..d79523183 100644 --- a/tests/unit/resizable/resizable_options.js +++ b/tests/unit/resizable/resizable_options.js @@ -5,6 +5,26 @@ module("resizable: options"); +test( "alsoResize", function() { + expect( 2 ); + + var other = $( "
    " ) + .css({ + width: 50, + height: 50 + }) + .appendTo( "body" ), + element = $( "#resizable1" ).resizable({ + alsoResize: other + }), + handle = ".ui-resizable-e"; + + TestHelpers.resizable.drag( handle, 80 ); + equal( element.width(), 180, "resizable width" ); + equal( other.width(), 130, "alsoResize width" ); +}); + + test("aspectRatio: 'preserve' (e)", function() { expect(4); @@ -103,6 +123,21 @@ test("aspectRatio: 'preserve' (ne)", function() { equal( target.height(), 70, "compare minHeight"); }); +test( "containment", function() { + expect( 4 ); + var element = $( "#resizable1" ).resizable({ + containment: "#container" + }); + + TestHelpers.resizable.drag( ".ui-resizable-se", 20, 30 ); + equal( element.width(), 120, "unconstrained width within container" ); + equal( element.height(), 130, "unconstrained height within container" ); + + TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 ); + equal( element.width(), 300, "constrained width at containment edge" ); + equal( element.height(), 200, "constrained height at containment edge" ); +}); + test("grid", function() { expect(4); @@ -210,4 +245,24 @@ test("zIndex, applied to all handles", function() { }); }); +test( "alsoResize + containment", function() { + expect( 4 ); + var other = $( "
    " ) + .css({ + width: 50, + height: 50 + }) + .appendTo( "body" ), + element = $( "#resizable1" ).resizable({ + alsoResize: other, + containment: "#container" + }); + + TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 ); + equal( element.width(), 300, "resizable constrained width at containment edge" ); + equal( element.height(), 200, "resizable constrained height at containment edge" ); + equal( other.width(), 250, "alsoResize constrained width at containment edge" ); + equal( other.height(), 150, "alsoResize constrained height at containment edge" ); +}); + })(jQuery); diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index 4a019336e..b417288d8 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -643,67 +643,6 @@ $.widget("ui.resizable", $.ui.mouse, { * Resizable Extensions */ -$.ui.plugin.add("resizable", "alsoResize", { - - start: function () { - var that = $(this).data("ui-resizable"), - o = that.options, - _store = function (exp) { - $(exp).each(function() { - var el = $(this); - el.data("ui-resizable-alsoresize", { - width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), - left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10) - }); - }); - }; - - if (typeof(o.alsoResize) === 'object' && !o.alsoResize.parentNode) { - if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } - else { $.each(o.alsoResize, function (exp) { _store(exp); }); } - }else{ - _store(o.alsoResize); - } - }, - - resize: function (event, ui) { - var that = $(this).data("ui-resizable"), - o = that.options, - os = that.originalSize, - op = that.originalPosition, - delta = { - height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0, - top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0 - }, - - _alsoResize = function (exp, c) { - $(exp).each(function() { - var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {}, - css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left']; - - $.each(css, function (i, prop) { - var sum = (start[prop]||0) + (delta[prop]||0); - if (sum && sum >= 0) { - style[prop] = sum || null; - } - }); - - el.css(style); - }); - }; - - if (typeof(o.alsoResize) === 'object' && !o.alsoResize.nodeType) { - $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); }); - }else{ - _alsoResize(o.alsoResize); - } - }, - - stop: function () { - $(this).removeData("resizable-alsoresize"); - } -}); - $.ui.plugin.add("resizable", "animate", { stop: function( event ) { @@ -871,6 +810,67 @@ $.ui.plugin.add("resizable", "containment", { } }); +$.ui.plugin.add("resizable", "alsoResize", { + + start: function () { + var that = $(this).data("ui-resizable"), + o = that.options, + _store = function (exp) { + $(exp).each(function() { + var el = $(this); + el.data("ui-resizable-alsoresize", { + width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), + left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10) + }); + }); + }; + + if (typeof(o.alsoResize) === 'object' && !o.alsoResize.parentNode) { + if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } + else { $.each(o.alsoResize, function (exp) { _store(exp); }); } + }else{ + _store(o.alsoResize); + } + }, + + resize: function (event, ui) { + var that = $(this).data("ui-resizable"), + o = that.options, + os = that.originalSize, + op = that.originalPosition, + delta = { + height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0, + top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0 + }, + + _alsoResize = function (exp, c) { + $(exp).each(function() { + var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {}, + css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left']; + + $.each(css, function (i, prop) { + var sum = (start[prop]||0) + (delta[prop]||0); + if (sum && sum >= 0) { + style[prop] = sum || null; + } + }); + + el.css(style); + }); + }; + + if (typeof(o.alsoResize) === 'object' && !o.alsoResize.nodeType) { + $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); }); + }else{ + _alsoResize(o.alsoResize); + } + }, + + stop: function () { + $(this).removeData("resizable-alsoresize"); + } +}); + $.ui.plugin.add("resizable", "ghost", { start: function() { -- cgit v1.2.3 From bdb0fbe993ab4c716f3cbc6f2c08072bf512115f Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Sun, 2 Dec 2012 12:50:17 +0100 Subject: Dialog: Restrict title to a single line. Fixes #7773 - Dialog: If titlebar changes height during resize, button pane positioning changes. --- tests/visual/dialog/complex-dialogs.html | 7 ++++++- themes/base/jquery.ui.dialog.css | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/visual/dialog/complex-dialogs.html b/tests/visual/dialog/complex-dialogs.html index 5cd9271ae..9cc2d1416 100644 --- a/tests/visual/dialog/complex-dialogs.html +++ b/tests/visual/dialog/complex-dialogs.html @@ -20,6 +20,11 @@ + @@ -10,35 +10,36 @@ + @@ -100,6 +101,7 @@ + diff --git a/ui/i18n/jquery.ui.datepicker-be.js b/ui/i18n/jquery.ui.datepicker-be.js new file mode 100644 index 000000000..be605dab4 --- /dev/null +++ b/ui/i18n/jquery.ui.datepicker-be.js @@ -0,0 +1,23 @@ +/* Belarusian initialisation for the jQuery UI date picker plugin. */ +/* Written by Pavel Selitskas */ +jQuery(function($){ + $.datepicker.regional['be'] = { + closeText: 'Зачыніць', + prevText: '←Папяр.', + nextText: 'Наст.→', + currentText: 'Сёньня', + monthNames: ['Студзень','Люты','Сакавік','Красавік','Травень','Чэрвень', + 'Ліпень','Жнівень','Верасень','Кастрычнік','Лістапад','Сьнежань'], + monthNamesShort: ['Сту','Лют','Сак','Кра','Тра','Чэр', + 'Ліп','Жні','Вер','Кас','Ліс','Сьн'], + dayNames: ['нядзеля','панядзелак','аўторак','серада','чацьвер','пятніца','субота'], + dayNamesShort: ['ндз','пнд','аўт','срд','чцв','птн','сбт'], + dayNamesMin: ['Нд','Пн','Аў','Ср','Чц','Пт','Сб'], + weekHeader: 'Тд', + dateFormat: 'dd.mm.yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['be']); +}); -- cgit v1.2.3 From 70f5d18c715ba1c759393856f0f70acfddbee07a Mon Sep 17 00:00:00 2001 From: Bjørn Johansen Date: Mon, 3 Dec 2012 08:05:06 +0100 Subject: Datepicker: Added Norwegian Bokmål and Norwegian Nynorsk locales. Fixes #8886 - Datepicker: Add Norwegian Bokmål (nb) and Norwegian Nynorsk (nn) locales. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Johansen --- demos/datepicker/localization.html | 4 ++++ ui/i18n/jquery.ui.datepicker-nb.js | 22 ++++++++++++++++++++++ ui/i18n/jquery.ui.datepicker-nn.js | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 ui/i18n/jquery.ui.datepicker-nb.js create mode 100644 ui/i18n/jquery.ui.datepicker-nn.js diff --git a/demos/datepicker/localization.html b/demos/datepicker/localization.html index c7c415622..968196295 100644 --- a/demos/datepicker/localization.html +++ b/demos/datepicker/localization.html @@ -54,8 +54,10 @@ + + @@ -144,7 +146,9 @@ + + diff --git a/ui/i18n/jquery.ui.datepicker-nb.js b/ui/i18n/jquery.ui.datepicker-nb.js new file mode 100644 index 000000000..845a5052d --- /dev/null +++ b/ui/i18n/jquery.ui.datepicker-nb.js @@ -0,0 +1,22 @@ +/* Norwegian Bokmål initialisation for the jQuery UI date picker plugin. */ +/* Written by Bjørn Johansen (post@bjornjohansen.no). */ +jQuery(function($){ + $.datepicker.regional['nb'] = { + closeText: 'Lukk', + prevText: '«Forrige', + nextText: 'Neste»', + currentText: 'I dag', + monthNames: ['januar','februar','mars','april','mai','juni','juli','august','september','oktober','november','desember'], + monthNamesShort: ['jan','feb','mar','apr','mai','jun','jul','aug','sep','okt','nov','des'], + dayNamesShort: ['søn','man','tir','ons','tor','fre','lør'], + dayNames: ['søndag','mandag','tirsdag','onsdag','torsdag','fredag','lørdag'], + dayNamesMin: ['sø','ma','ti','on','to','fr','lø'], + weekHeader: 'Uke', + dateFormat: 'dd.mm.yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: '' + }; + $.datepicker.setDefaults($.datepicker.regional['nb']); +}); diff --git a/ui/i18n/jquery.ui.datepicker-nn.js b/ui/i18n/jquery.ui.datepicker-nn.js new file mode 100644 index 000000000..b55245ee6 --- /dev/null +++ b/ui/i18n/jquery.ui.datepicker-nn.js @@ -0,0 +1,22 @@ +/* Norwegian Nynorsk initialisation for the jQuery UI date picker plugin. */ +/* Written by Bjørn Johansen (post@bjornjohansen.no). */ +jQuery(function($){ + $.datepicker.regional['nn'] = { + closeText: 'Lukk', + prevText: '«Førre', + nextText: 'Neste»', + currentText: 'I dag', + monthNames: ['januar','februar','mars','april','mai','juni','juli','august','september','oktober','november','desember'], + monthNamesShort: ['jan','feb','mar','apr','mai','jun','jul','aug','sep','okt','nov','des'], + dayNamesShort: ['sun','mån','tys','ons','tor','fre','lau'], + dayNames: ['sundag','måndag','tysdag','onsdag','torsdag','fredag','laurdag'], + dayNamesMin: ['su','må','ty','on','to','fr','la'], + weekHeader: 'Veke', + dateFormat: 'dd.mm.yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: '' + }; + $.datepicker.setDefaults($.datepicker.regional['nn']); +}); -- cgit v1.2.3 From f59f5a8b12d50c87ba6e2fe47a1804a23535b3cf Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 5 Dec 2012 11:53:34 -0500 Subject: Dialog: Restore inline styles for dimensions/display. Fixes #8119 - Dialog: Destroying a dialog leaves some styles changed. --- tests/unit/dialog/dialog_methods.js | 15 +++++++++++---- ui/jquery.ui.dialog.js | 13 +++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 6eeb50273..92fe3d60f 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -34,12 +34,9 @@ test("init", function() { }); test("destroy", function() { - expect( 6 ); + expect( 7 ); - // Dialogs are expected to be hidden on destroy, so make sure they're hidden - // before the test $( "#dialog1, #form-dialog" ).hide(); - domEqual( "#dialog1", function() { var dialog = $( "#dialog1" ).dialog().dialog( "destroy" ); equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); @@ -50,6 +47,16 @@ test("destroy", function() { equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); equal( dialog.index(), 2 ); }); + + // Ensure dimensions are restored (#8119) + $( "#dialog1" ).show().css({ + width: "400px", + minHeight: "100px", + height: "200px" + }); + domEqual( "#dialog1", function() { + $( "#dialog1" ).dialog().dialog( "destroy" ); + }); }); test( "enable/disable disabled", function() { diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 96c998656..eac818fe0 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -84,6 +84,12 @@ $.widget("ui.dialog", { }, _create: function() { + this.originalCss = { + display: this.element[0].style.display, + width: this.element[0].style.width, + minHeight: this.element[0].style.minHeight, + height: this.element[0].style.height + }; this.originalTitle = this.element.attr( "title" ); this.options.title = this.options.title || this.originalTitle; this.oldPosition = { @@ -127,12 +133,7 @@ $.widget("ui.dialog", { this.element .removeUniqueId() .removeClass( "ui-dialog-content ui-widget-content" ) - .css({ - width: "", - minHeight: "", - height: "" - }) - .hide() + .css( this.originalCss ) // without detaching first, the following becomes really slow .detach(); -- cgit v1.2.3 From 1e5662ebe5a27d5ef0b8d60730b21771a2526547 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 5 Dec 2012 17:19:14 -0500 Subject: Tabs: Decode URIs before comparing. Fixes #8877 - Tabs: isLocal function issue in Safari 5.1.7. --- ui/jquery.ui.tabs.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index dcb0c2768..bce0585a0 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -23,12 +23,8 @@ function getNextTabId() { function isLocal( anchor ) { return anchor.hash.length > 1 && - anchor.href.replace( rhash, "" ) === - location.href.replace( rhash, "" ) - // support: Safari 5.1 - // Safari 5.1 doesn't encode spaces in window.location - // but it does encode spaces from anchors (#8777) - .replace( /\s/g, "%20" ); + decodeURIComponent( anchor.href.replace( rhash, "" ) ) === + decodeURIComponent( location.href.replace( rhash, "" ) ); } $.widget( "ui.tabs", { -- cgit v1.2.3 From 8c763cdf9836e9e97432167e92d0a5808e033ba2 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 09:21:25 -0500 Subject: Progressbar: Define defaults for callbacks. --- tests/unit/progressbar/progressbar_common.js | 2 ++ ui/jquery.ui.progressbar.js | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/unit/progressbar/progressbar_common.js b/tests/unit/progressbar/progressbar_common.js index 2f97a78bb..ceee3fbec 100644 --- a/tests/unit/progressbar/progressbar_common.js +++ b/tests/unit/progressbar/progressbar_common.js @@ -5,6 +5,8 @@ TestHelpers.commonWidgetTests( "progressbar", { max: 100, //callbacks + change: null, + complete: null, create: null } }); diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 0f97bc3fe..53c9508ed 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -17,8 +17,11 @@ $.widget( "ui.progressbar", { version: "@VERSION", options: { + max: 100, value: 0, - max: 100 + + change: null, + complete: null }, min: 0, -- cgit v1.2.3 From f1be88e7956fe9114ae20d19242cd8190a6ff399 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 09:35:41 -0500 Subject: Progressbar: Only remove aria-valuenow for indeterminate progressbars. Added more accessibility tests. --- tests/unit/progressbar/progressbar_common.js | 2 +- tests/unit/progressbar/progressbar_core.js | 10 +++++++++- ui/jquery.ui.progressbar.js | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/unit/progressbar/progressbar_common.js b/tests/unit/progressbar/progressbar_common.js index ceee3fbec..0768576f5 100644 --- a/tests/unit/progressbar/progressbar_common.js +++ b/tests/unit/progressbar/progressbar_common.js @@ -1,8 +1,8 @@ TestHelpers.commonWidgetTests( "progressbar", { defaults: { disabled: false, - value: 0, max: 100, + value: 0, //callbacks change: null, diff --git a/tests/unit/progressbar/progressbar_core.js b/tests/unit/progressbar/progressbar_core.js index 0a2ef895b..54a33cc9d 100644 --- a/tests/unit/progressbar/progressbar_core.js +++ b/tests/unit/progressbar/progressbar_core.js @@ -1,7 +1,7 @@ module( "progressbar: core" ); test( "accessibility", function() { - expect( 7 ); + expect( 11 ); var element = $( "#progressbar" ).progressbar(); equal( element.attr( "role" ), "progressbar", "aria role" ); @@ -12,9 +12,17 @@ test( "accessibility", function() { element.progressbar( "value", 77 ); equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" ); + element.progressbar( "option", "max", 150 ); + equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" ); + element.progressbar( "disable" ); equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" ); element.progressbar( "enable" ); equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" ); + + element.progressbar( "option", "value", false ); + equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" ); + equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" ); + strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow initially" ); }); diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 53c9508ed..348f1d061 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -33,10 +33,10 @@ $.widget( "ui.progressbar", { this.element .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) .attr({ + // Only set static values, aria-valuenow and aria-valuemax are + // set inside _refreshValue() role: "progressbar", - "aria-valuemin": this.min, - "aria-valuemax": this.options.max, - "aria-valuenow": this.options.value + "aria-valuemin": this.min }); this.valueDiv = $( "
    " ) @@ -126,7 +126,7 @@ $.widget( "ui.progressbar", { .width( percentage.toFixed(0) + "%" ); if ( this.indeterminate ) { - this.element.removeAttr( "aria-valuemax" ).removeAttr( "aria-valuenow" ); + this.element.removeAttr( "aria-valuenow" ); if ( !this.overlayDiv ) { this.overlayDiv = $( "
    " ).appendTo( this.valueDiv ); } -- cgit v1.2.3 From 9d0df536240f1b5e84d1f772ef95117280acd4d8 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 09:50:33 -0500 Subject: Progress tests: Cleanup. --- tests/unit/progressbar/progressbar_events.js | 26 ++++++++++------- tests/unit/progressbar/progressbar_methods.js | 2 +- tests/unit/progressbar/progressbar_options.js | 42 +++++++++++---------------- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/tests/unit/progressbar/progressbar_events.js b/tests/unit/progressbar/progressbar_events.js index fe05182a1..95effda75 100644 --- a/tests/unit/progressbar/progressbar_events.js +++ b/tests/unit/progressbar/progressbar_events.js @@ -5,34 +5,40 @@ test( "create", function() { $( "#progressbar" ).progressbar({ value: 5, create: function() { - deepEqual( 5, $( this ).progressbar( "value" ) ); + equal( $( this ).progressbar( "value" ), 5, "Correct value at create" ); }, change: function() { - ok( false, "create() has triggered change()" ); + ok( false, "create has triggered change()" ); } }); }); test( "change", function() { - expect( 1 ); - $( "#progressbar" ).progressbar({ - change: function() { - deepEqual( 5, $( this ).progressbar( "value" ) ); - } - }).progressbar( "value", 5 ); + expect( 2 ); + var element = $( "#progressbar" ).progressbar(); + + element.one( "progressbarchange", function() { + equal( element.progressbar( "value" ), 5, "change triggered for middle value" ); + }); + element.progressbar( "value", 5 ); + element.one( "progressbarchange", function() { + equal( element.progressbar( "value" ), 100, "change triggered for final value" ); + }); + element.progressbar( "value", 100 ); }); test( "complete", function() { - expect( 4 ); + expect( 5 ); var value, changes = 0, element = $( "#progressbar" ).progressbar({ change: function() { changes++; - deepEqual( element.progressbar( "value" ), value, "change at " + value ); + equal( element.progressbar( "value" ), value, "change at " + value ); }, complete: function() { equal( changes, 3, "complete triggered after change and not on indeterminate" ); + equal( element.progressbar( "value" ), 100, "value is 100" ); } }); diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/progressbar_methods.js index 990739c6e..cf7faf6af 100644 --- a/tests/unit/progressbar/progressbar_methods.js +++ b/tests/unit/progressbar/progressbar_methods.js @@ -12,7 +12,7 @@ test( "value", function() { var element = $( "
    " ).progressbar({ value: 20 }); equal( element.progressbar( "value" ), 20, "correct value as getter" ); - equal( element.progressbar( "value", 30), element, "chainable as setter" ); + strictEqual( element.progressbar( "value", 30 ), element, "chainable as setter" ); equal( element.progressbar( "option", "value" ), 30, "correct value after setter" ); }); diff --git a/tests/unit/progressbar/progressbar_options.js b/tests/unit/progressbar/progressbar_options.js index e4d9b7ab8..bc0b5d00d 100644 --- a/tests/unit/progressbar/progressbar_options.js +++ b/tests/unit/progressbar/progressbar_options.js @@ -1,14 +1,14 @@ module( "progressbar: options" ); -test( "{ value : 0 }, default", function() { +test( "{ value: 0 }, default", function() { expect( 1 ); $( "#progressbar" ).progressbar(); - equal( 0, $( "#progressbar" ).progressbar( "value" ) ); + equal( $( "#progressbar" ).progressbar( "value" ), 0 ); }); // Ticket #7231 - valueDiv should be hidden when value is at 0% test( "value: visibility of valueDiv", function() { - expect( 5 ); + expect( 4 ); var element = $( "#progressbar" ).progressbar({ value: 0 }); @@ -23,58 +23,50 @@ test( "value: visibility of valueDiv", function() { element.progressbar( "value", 0 ); ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ), "valueDiv hidden when value is set to 0" ); - element.progressbar( "value", -1 ); - ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ), - "valueDiv hidden when value set to -1 (normalizes to 0)" ); }); -test( "{ value : 5 }", function() { +test( "{ value: 5 }", function() { expect( 1 ); $( "#progressbar" ).progressbar({ value: 5 }); - equal( 5, $( "#progressbar" ).progressbar( "value" ) ); + equal( $( "#progressbar" ).progressbar( "value" ), 5 ); }); -test( "{ value : -5 }", function() { +test( "{ value: -5 }", function() { expect( 1 ); $( "#progressbar" ).progressbar({ value: -5 }); - deepEqual( 0, $( "#progressbar" ).progressbar( "value" ) ); + equal( $( "#progressbar" ).progressbar( "value" ), 0, + "value constrained at min" ); }); -test( "{ value : 105 }", function() { +test( "{ value: 105 }", function() { expect( 1 ); $( "#progressbar" ).progressbar({ value: 105 }); - deepEqual( 100, $( "#progressbar" ).progressbar( "value" ) ); -}); - -test( "{ max : 5, value : 10 }", function() { - expect( 1 ); - $("#progressbar").progressbar({ - max: 5, - value: 10 - }); - deepEqual( 5, $( "#progressbar" ).progressbar( "value" ) ); + equal( $( "#progressbar" ).progressbar( "value" ), 100, + "value constrained at max" ); }); -test( "{ value : 10, max : 5 }", function() { +test( "{ value: 10, max: 5 }", function() { expect( 1 ); $("#progressbar").progressbar({ max: 5, value: 10 }); - deepEqual( 5, $( "#progressbar" ).progressbar( "value" ) ); + equal( $( "#progressbar" ).progressbar( "value" ), 5, + "value constrained at max" ); }); -test( "{ max : 5 }", function() { +test( "change max below value", function() { expect( 1 ); $("#progressbar").progressbar({ max: 10, value: 10 }).progressbar( "option", "max", 5 ); - deepEqual( 5, $( "#progressbar" ).progressbar( "value" ) ); + equal( $( "#progressbar" ).progressbar( "value" ), 5, + "value constrained at max" ); }); -- cgit v1.2.3 From f7614706abfdbc653de53fbc31361f9aacab8821 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 10:10:07 -0500 Subject: Progressbar: Cleanup, byte shaving. --- tests/unit/progressbar/progressbar_core.js | 2 +- ui/jquery.ui.progressbar.js | 42 ++++++++++++------------------ 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/tests/unit/progressbar/progressbar_core.js b/tests/unit/progressbar/progressbar_core.js index 54a33cc9d..cffd84d21 100644 --- a/tests/unit/progressbar/progressbar_core.js +++ b/tests/unit/progressbar/progressbar_core.js @@ -24,5 +24,5 @@ test( "accessibility", function() { element.progressbar( "option", "value", false ); equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" ); equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" ); - strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow initially" ); + strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow" ); }); diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 348f1d061..46051d2c9 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -28,7 +28,7 @@ $.widget( "ui.progressbar", { _create: function() { // Constrain initial value - this.options.value = this._constrainedValue(); + this.oldValue = this.options.value = this._constrainedValue(); this.element .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) @@ -42,7 +42,6 @@ $.widget( "ui.progressbar", { this.valueDiv = $( "
    " ) .appendTo( this.element ); - this.oldValue = this.options.value; this._refreshValue(); }, @@ -62,53 +61,44 @@ $.widget( "ui.progressbar", { return this.options.value; } - this._setOption( "value", this._constrainedValue( newValue ) ); - return this; + this.options.value = this._constrainedValue( newValue ); + this._refreshValue(); }, _constrainedValue: function( newValue ) { - var val; if ( newValue === undefined ) { - val = this.options.value; - } else { - val = newValue; + newValue = this.options.value; } - this.indeterminate = val === false; + this.indeterminate = newValue === false; // sanitize value - if ( typeof val !== "number" ) { - val = 0; + if ( typeof newValue !== "number" ) { + newValue = 0; } - return this.indeterminate ? false : Math.min( this.options.max, Math.max( this.min, val ) ); + + return this.indeterminate ? false : + Math.min( this.options.max, Math.max( this.min, newValue ) ); }, _setOptions: function( options ) { - var val = options.value; - // Ensure "value" option is set after other values (like max) + var value = options.value; delete options.value; + this._super( options ); - if ( val !== undefined ) { - this._setOption( "value", val ); - } + this.options.value = this._constrainedValue( value ); + this._refreshValue(); }, _setOption: function( key, value ) { if ( key === "max" ) { // Don't allow a max less than min - this.options.max = Math.max( this.min, value ); - this.options.value = this._constrainedValue(); - } - if ( key === "value" ) { - this.options.value = this._constrainedValue( value ); - } - else { - this._super( key, value ); + value = Math.max( this.min, value ); } - this._refreshValue(); + this._super( key, value ); }, _percentage: function() { -- cgit v1.2.3 From 20a29dfd61f0f632c0d08aa0d1db3057668f3f7c Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 11:56:56 -0500 Subject: Datepicker: Run JSHint test in unit tests. --- tests/unit/datepicker/datepicker_core.js | 2 ++ tests/unit/datepicker/datepicker_options.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index 3c88059d1..67dd29eac 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -6,6 +6,8 @@ module("datepicker: core"); +TestHelpers.testJshint( "datepicker" ); + test("initialization - Reinitialization after body had been emptied.", function() { expect( 1 ); var bodyContent = $('body').children(), inp = $("#inp"); diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 4b09face5..06fde26e6 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -64,7 +64,8 @@ test( "disabled", function() { inp = TestHelpers.datepicker.init('#inp', { disabled: true }); ok(inp.datepicker('isDisabled'), 'Initially marked as disabled'); ok(inp[0].disabled, 'Field initially disabled'); -}) +}); + test('change', function() { expect( 12 ); var inp = TestHelpers.datepicker.init('#inp'), -- cgit v1.2.3 From b44375aef19f54e1b4ef5caee6c748b6d9058814 Mon Sep 17 00:00:00 2001 From: Kris Borchers Date: Thu, 6 Dec 2012 11:07:07 -0600 Subject: Progressbar: Take min into account when calculating percentage. --- ui/jquery.ui.progressbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 46051d2c9..163bb06cd 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -102,7 +102,7 @@ $.widget( "ui.progressbar", { }, _percentage: function() { - return this.indeterminate ? 100 : 100 * this.options.value / this.options.max; + return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min ); }, _refreshValue: function() { -- cgit v1.2.3 From 9deb71b71382e40a204bd50efeda2ace5b092932 Mon Sep 17 00:00:00 2001 From: Kris Borchers Date: Thu, 6 Dec 2012 11:07:25 -0600 Subject: Progressbar: Add link to custom label demo in demo index. --- demos/progressbar/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/progressbar/index.html b/demos/progressbar/index.html index 3997d8f77..cfc054aea 100644 --- a/demos/progressbar/index.html +++ b/demos/progressbar/index.html @@ -9,6 +9,7 @@ -- cgit v1.2.3 From ebf8a601871c70ed4a7fdf28505fee6781d21504 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 14:18:20 -0500 Subject: Tabs: Reduce cyclomatic complexity. --- ui/jquery.ui.tabs.js | 65 +++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index bce0585a0..fb66ec6a5 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -47,9 +47,7 @@ $.widget( "ui.tabs", { _create: function() { var that = this, - options = this.options, - active = options.active, - locationHash = location.hash.substring( 1 ); + options = this.options; this.running = false; @@ -75,6 +73,36 @@ $.widget( "ui.tabs", { }); this._processTabs(); + options.active = this._initialActive(); + + // Take disabling tabs via class attribute from HTML + // into account and update option properly. + if ( $.isArray( options.disabled ) ) { + options.disabled = $.unique( options.disabled.concat( + $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) { + return that.tabs.index( li ); + }) + ) ).sort(); + } + + // check for length avoids error when initializing empty list + if ( this.options.active !== false && this.anchors.length ) { + this.active = this._findActive( options.active ); + } else { + this.active = $(); + } + + this._refresh(); + + if ( this.active.length ) { + this.load( options.active ); + } + }, + + _initialActive: function() { + var active = this.options.active, + collapsible = this.options.collapsible, + locationHash = location.hash.substring( 1 ); if ( active === null ) { // check the fragment identifier in the URL @@ -102,38 +130,16 @@ $.widget( "ui.tabs", { if ( active !== false ) { active = this.tabs.index( this.tabs.eq( active ) ); if ( active === -1 ) { - active = options.collapsible ? false : 0; + active = collapsible ? false : 0; } } - options.active = active; // don't allow collapsible: false and active: false - if ( !options.collapsible && options.active === false && this.anchors.length ) { - options.active = 0; - } - - // Take disabling tabs via class attribute from HTML - // into account and update option properly. - if ( $.isArray( options.disabled ) ) { - options.disabled = $.unique( options.disabled.concat( - $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) { - return that.tabs.index( li ); - }) - ) ).sort(); + if ( !collapsible && active === false && this.anchors.length ) { + active = 0; } - // check for length avoids error when initializing empty list - if ( this.options.active !== false && this.anchors.length ) { - this.active = this._findActive( this.options.active ); - } else { - this.active = $(); - } - - this._refresh(); - - if ( this.active.length ) { - this.load( options.active ); - } + return active; }, _getCreateEventData: function() { @@ -144,6 +150,7 @@ $.widget( "ui.tabs", { }, _tabKeydown: function( event ) { + /*jshint maxcomplexity:15*/ var focusedTab = $( this.document[0].activeElement ).closest( "li" ), selectedIndex = this.tabs.index( focusedTab ), goingForward = true; -- cgit v1.2.3 From b239298946b466a0c87a0c1ead4ccd75141ed740 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 14:25:48 -0500 Subject: Allow higher cyclomatic complexity in functions that sanely use switch statements. --- ui/jquery.ui.accordion.js | 1 + ui/jquery.ui.autocomplete.js | 1 + ui/jquery.ui.dialog.js | 1 + ui/jquery.ui.menu.js | 1 + ui/jquery.ui.slider.js | 1 + 5 files changed, 5 insertions(+) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 7914f7c5f..60475b8ba 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -166,6 +166,7 @@ $.widget( "ui.accordion", { }, _keydown: function( event ) { + /*jshint maxcomplexity:15*/ if ( event.altKey || event.ctrlKey ) { return; } diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 5edb84d44..c049b8569 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -66,6 +66,7 @@ $.widget( "ui.autocomplete", { this._on( this.element, { keydown: function( event ) { + /*jshint maxcomplexity:15*/ if ( this.element.prop( "readOnly" ) ) { suppressKeyPress = true; suppressInput = true; diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index eac818fe0..b2b8be8c0 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -553,6 +553,7 @@ $.widget("ui.dialog", { }, _setOption: function( key, value ) { + /*jshint maxcomplexity:15*/ var isDraggable, isResizable, uiDialog = this.uiDialog; diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 45c1ec2e4..41a69c472 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -173,6 +173,7 @@ $.widget( "ui.menu", { }, _keydown: function( event ) { + /*jshint maxcomplexity:20*/ var match, prev, character, skip, regex, preventDefault = true; diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index d9fc1b132..02fee8364 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -119,6 +119,7 @@ $.widget( "ui.slider", $.ui.mouse, { this._on( this.handles, { keydown: function( event ) { + /*jshint maxcomplexity:25*/ var allowed, curVal, newVal, step, index = $( event.target ).data( "ui-slider-handle-index" ); -- cgit v1.2.3 From 3ec0c2e5728da9b9b9955dfe18073d3985e61a52 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 14:42:10 -0500 Subject: Core: Removed $.ui.isOver() and $.ui.isOverAxis(). Fixes #8891 - Remove $.ui.isOver() and $.ui.isOverAxis(). --- ui/jquery.ui.core.js | 10 ---------- ui/jquery.ui.droppable.js | 6 +++++- ui/jquery.ui.sortable.js | 12 ++++++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 288634376..17fad86b4 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -313,16 +313,6 @@ $.extend( $.ui, { has = ( el[ scroll ] > 0 ); el[ scroll ] = 0; return has; - }, - - // these are odd functions, fix the API or move into individual plugins - isOverAxis: function( x, reference, size ) { - //Determines when x coordinate is over "b" element axis - return ( x > reference ) && ( x < ( reference + size ) ); - }, - isOver: function( y, x, top, left, height, width ) { - //Determines when x, y coordinates is over "b" element - return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width ); } }); diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 9d904992d..aebca8fae 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -16,6 +16,10 @@ */ (function( $, undefined ) { +function isOverAxis( x, reference, size ) { + return ( x > reference ) && ( x < ( reference + size ) ); +} + $.widget("ui.droppable", { version: "@VERSION", widgetEventPrefix: "drop", @@ -203,7 +207,7 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) { case 'pointer': draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left); draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top); - return $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width); + return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width ) case 'touch': return ( (y1 >= t && y1 <= b) || // Top edge touching diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index b1fb642fe..e142a0ede 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -17,6 +17,10 @@ /*jshint loopfunc: true */ +function isOverAxis( x, reference, size ) { + return ( x > reference ) && ( x < ( reference + size ) ); +} + $.widget("ui.sortable", $.ui.mouse, { version: "@VERSION", widgetEventPrefix: "sort", @@ -536,8 +540,8 @@ $.widget("ui.sortable", $.ui.mouse, { _intersectsWithPointer: function(item) { - var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), - isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), + var isOverElementHeight = (this.options.axis === 'x') || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), + isOverElementWidth = (this.options.axis === 'y') || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), isOverElement = isOverElementHeight && isOverElementWidth, verticalDirection = this._getDragVerticalDirection(), horizontalDirection = this._getDragHorizontalDirection(); @@ -554,8 +558,8 @@ $.widget("ui.sortable", $.ui.mouse, { _intersectsWithSides: function(item) { - var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), - isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), + var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), + isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), verticalDirection = this._getDragVerticalDirection(), horizontalDirection = this._getDragHorizontalDirection(); -- cgit v1.2.3 From fb38c20763c637e4d05ca2a48e25db4b380754be Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 14:43:35 -0500 Subject: Droppable: Added missing semicolon. --- ui/jquery.ui.droppable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index aebca8fae..e2da0b9f6 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -207,7 +207,7 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) { case 'pointer': draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left); draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top); - return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width ) + return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width ); case 'touch': return ( (y1 >= t && y1 <= b) || // Top edge touching -- cgit v1.2.3 From a1eb9ca4befdabace88fc78aa59947dbf7c36e20 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 6 Dec 2012 15:00:42 -0500 Subject: Position: Split out dimension parsing. --- ui/jquery.ui.position.js | 54 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index a5dc31834..dbfadedd1 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -29,10 +29,41 @@ function getOffsets( offsets, width, height ) { parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) ]; } + function parseCss( element, property ) { return parseInt( $.css( element, property ), 10 ) || 0; } +function getDimensions( elem ) { + var raw = elem[0]; + if ( raw.nodeType === 9 ) { + return { + width: elem.width(), + height: elem.height(), + offset: { top: 0, left: 0 } + }; + } + if ( $.isWindow( raw ) ) { + return { + width: elem.width(), + height: elem.height(), + offset: { top: elem.scrollTop(), left: elem.scrollLeft() } + }; + } + if ( raw.preventDefault ) { + return { + width: 0, + height: 0, + offset: { top: raw.pageY, left: raw.pageX } + }; + } + return { + width: elem.outerWidth(), + height: elem.outerHeight(), + offset: elem.offset() + }; +} + $.position = { scrollbarWidth: function() { if ( cachedScrollbarWidth !== undefined ) { @@ -91,32 +122,21 @@ $.fn.position = function( options ) { // make a copy, we don't want to modify arguments options = $.extend( {}, options ); - var atOffset, targetWidth, targetHeight, targetOffset, basePosition, + var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, target = $( options.of ), within = $.position.getWithinInfo( options.within ), scrollInfo = $.position.getScrollInfo( within ), - targetElem = target[0], collision = ( options.collision || "flip" ).split( " " ), offsets = {}; - if ( targetElem.nodeType === 9 ) { - targetWidth = target.width(); - targetHeight = target.height(); - targetOffset = { top: 0, left: 0 }; - } else if ( $.isWindow( targetElem ) ) { - targetWidth = target.width(); - targetHeight = target.height(); - targetOffset = { top: target.scrollTop(), left: target.scrollLeft() }; - } else if ( targetElem.preventDefault ) { + dimensions = getDimensions( target ); + if ( target[0].preventDefault ) { // force left top to allow flipping options.at = "left top"; - targetWidth = targetHeight = 0; - targetOffset = { top: targetElem.pageY, left: targetElem.pageX }; - } else { - targetWidth = target.outerWidth(); - targetHeight = target.outerHeight(); - targetOffset = target.offset(); } + targetWidth = dimensions.width; + targetHeight = dimensions.height; + targetOffset = dimensions.offset; // clone to reuse original targetOffset later basePosition = $.extend( {}, targetOffset ); -- cgit v1.2.3 From d5e75ca1a17739416ef9134a4feb2382145023d1 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 7 Dec 2012 10:10:40 +0100 Subject: Build: Update grunt-junit, gets rid of the bogus xml files. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c3e73531..12d51ab03 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "grunt-css": "0.2.0", "grunt-compare-size": "0.1.4", "grunt-html": "0.1.1", - "grunt-junit": "0.1.4", + "grunt-junit": "0.1.5", "grunt-git-authors": "1.0.0", "rimraf": "2.0.1", "testswarm": "0.2.3" -- cgit v1.2.3 From 1481b080121bf15ef60f30162c345f0423f3986f Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 7 Dec 2012 10:51:44 +0100 Subject: Build: Update to node-testswarm 0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 12d51ab03..df0885b33 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "grunt-junit": "0.1.5", "grunt-git-authors": "1.0.0", "rimraf": "2.0.1", - "testswarm": "0.2.3" + "testswarm": "0.3.0" }, "keywords": [] } -- cgit v1.2.3 From da17a232ca554254eabd3583805b381f6b525ec5 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 7 Dec 2012 11:58:58 -0500 Subject: Autocomplete: Handle detached elements for appendTo after create. --- tests/unit/autocomplete/autocomplete_options.js | 6 +++++- ui/jquery.ui.autocomplete.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index d3a25d2fc..913f5bc28 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -5,7 +5,7 @@ module( "autocomplete: options" ); var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ]; test( "appendTo", function() { - expect( 7 ); + expect( 8 ); var detached = $( "
    " ), element = $( "#autocomplete" ).autocomplete(); equal( element.autocomplete( "widget" ).parent()[0], document.body, "defaults to body" ); @@ -39,6 +39,10 @@ test( "appendTo", function() { }); equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached DOM element" ); element.autocomplete( "destroy" ); + + element.autocomplete().autocomplete( "option", "appendTo", detached ); + equal( element.autocomplete( "widget" ).parent()[0], detached[0], "detached DOM element via option()" ); + element.autocomplete( "destroy" ); }); function autoFocusTest( afValue, focusedLength ) { diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index c049b8569..a858b3382 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -314,7 +314,7 @@ $.widget( "ui.autocomplete", { this._initSource(); } if ( key === "appendTo" ) { - this.menu.element.appendTo( this.document.find( value || "body" )[0] ); + this.menu.element.appendTo( this._appendTo() ); } if ( key === "disabled" && value && this.xhr ) { this.xhr.abort(); -- cgit v1.2.3 From 70b16ef445d8f9947fd414894d97673706ee8c6f Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 7 Dec 2012 14:54:21 -0500 Subject: Dialog: Added appendTo option. Fixes #7948 - Dialog: Allow dialog to be attached to a element other than body. --- tests/unit/dialog/dialog.html | 2 ++ tests/unit/dialog/dialog_common.js | 1 + tests/unit/dialog/dialog_options.js | 41 +++++++++++++++++++++++++++++++++++++ ui/jquery.ui.dialog.js | 15 +++++++++++++- 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index cdc846478..8f2583ce1 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -61,6 +61,8 @@
    +
    +
    diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js index 47fff1013..9657a9887 100644 --- a/tests/unit/dialog/dialog_common.js +++ b/tests/unit/dialog/dialog_common.js @@ -1,5 +1,6 @@ TestHelpers.commonWidgetTests( "dialog", { defaults: { + appendTo: "body", autoOpen: true, buttons: {}, closeOnEscape: true, diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index fd7d91827..19e69b29a 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -5,6 +5,47 @@ module("dialog: options"); +test( "appendTo", function() { + expect( 8 ); + var detached = $( "
    " ), + element = $( "#dialog1" ).dialog(); + equal( element.dialog( "widget" ).parent()[0], document.body, "defaults to body" ); + element.dialog( "destroy" ); + + element.dialog({ + appendTo: ".wrap" + }); + equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "first found element" ); + equal( $( "#wrap2 .ui-dialog" ).length, 0, "only appends to one element" ); + element.dialog( "destroy" ); + + element.dialog({ + appendTo: null + }); + equal( element.dialog( "widget" ).parent()[0], document.body, "null" ); + element.dialog( "destroy" ); + + element.dialog({ autoOpen: false }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" ); + equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" ); + element.dialog( "destroy" ); + + element.dialog({ + appendTo: detached + }); + equal( element.dialog( "widget" ).parent()[0], detached[0], "detached jQuery object" ); + element.dialog( "destroy" ); + + element.dialog({ + appendTo: detached[0] + }); + equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element" ); + element.dialog( "destroy" ); + + element.dialog({ autoOpen: false }).dialog( "option", "appendTo", detached ); + equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element via option()" ); + element.dialog( "destroy" ); +}); + test("autoOpen", function() { expect(2); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index b2b8be8c0..939571a68 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -39,6 +39,7 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ui-fr $.widget("ui.dialog", { version: "@VERSION", options: { + appendTo: "body", autoOpen: true, buttons: {}, closeOnEscape: true, @@ -124,6 +125,14 @@ $.widget("ui.dialog", { } }, + _appendTo: function() { + var element = this.options.appendTo; + if ( element && (element.jquery || element.nodeType) ) { + return $( element ); + } + return this.document.find( element || "body" ).eq( 0 ); + }, + _destroy: function() { var next, oldPosition = this.oldPosition; @@ -276,7 +285,7 @@ $.widget("ui.dialog", { tabIndex: -1, role: "dialog" }) - .appendTo( this.document[ 0 ].body ); + .appendTo( this._appendTo() ); this._on( this.uiDialog, { keydown: function( event ) { @@ -569,6 +578,10 @@ $.widget("ui.dialog", { this._super( key, value ); + if ( key === "appendTo" ) { + this.uiDialog.appendTo( this._appendTo() ); + } + if ( key === "buttons" ) { this._createButtons(); } -- cgit v1.2.3 From d4551bc3b8dfbfd925700dcb9f71e7729b125889 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 7 Dec 2012 16:57:03 -0500 Subject: Dialog: Respect maxHeight when determining size on open. Fixes #4820 - Dialog: Auto height does not respect the maxHeight option. --- tests/unit/dialog/dialog_common.js | 4 ++-- ui/jquery.ui.dialog.js | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js index 9657a9887..1a9b4e109 100644 --- a/tests/unit/dialog/dialog_common.js +++ b/tests/unit/dialog/dialog_common.js @@ -10,8 +10,8 @@ TestHelpers.commonWidgetTests( "dialog", { draggable: true, height: 'auto', hide: null, - maxHeight: false, - maxWidth: false, + maxHeight: null, + maxWidth: null, minHeight: 150, minWidth: 150, modal: false, diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 939571a68..2553109ba 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -48,8 +48,8 @@ $.widget("ui.dialog", { draggable: true, hide: null, height: "auto", - maxHeight: false, - maxWidth: false, + maxHeight: null, + maxWidth: null, minHeight: 150, minWidth: 150, modal: false, @@ -89,6 +89,7 @@ $.widget("ui.dialog", { display: this.element[0].style.display, width: this.element[0].style.width, minHeight: this.element[0].style.minHeight, + maxHeight: this.element[0].style.maxHeight, height: this.element[0].style.height }; this.originalTitle = this.element.attr( "title" ); @@ -632,16 +633,16 @@ $.widget("ui.dialog", { }, _size: function() { - // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content // divs will both have width and height set, so we need to reset them - var nonContentHeight, minContentHeight, + var nonContentHeight, minContentHeight, maxContentHeight, options = this.options; // reset content sizing this.element.show().css({ width: "auto", minHeight: 0, + maxHeight: "none", height: 0 }); @@ -657,14 +658,18 @@ $.widget("ui.dialog", { }) .outerHeight(); minContentHeight = Math.max( 0, options.minHeight - nonContentHeight ); + maxContentHeight = typeof options.maxHeight === "number" ? + Math.max( 0, options.maxHeight - nonContentHeight ) : + "none"; if ( options.height === "auto" ) { this.element.css({ minHeight: minContentHeight, + maxHeight: maxContentHeight, height: "auto" }); } else { - this.element.height( Math.max( options.height - nonContentHeight, 0 ) ); + this.element.height( Math.max( 0, options.height - nonContentHeight ) ); } if (this.uiDialog.is( ":data(ui-resizable)" ) ) { -- cgit v1.2.3 From e83a89dd7df3009d46ddd9e7e1cabf42e901e397 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Fri, 7 Dec 2012 20:06:29 -0500 Subject: Dev: Remove *_tickets.js test files and move the associated tests to the proper locations. --- tests/unit/button/button_core.js | 56 +++++++++++++++ tests/unit/button/button_options.js | 11 +++ tests/unit/button/button_tickets.js | 75 -------------------- tests/unit/dialog/dialog_core.js | 32 ++++++++- tests/unit/dialog/dialog_events.js | 14 ++++ tests/unit/dialog/dialog_methods.js | 48 +++++++++++++ tests/unit/dialog/dialog_options.js | 22 ++++++ tests/unit/dialog/dialog_tickets.js | 121 -------------------------------- tests/unit/sortable/sortable_events.js | 61 ++++++++++++++++ tests/unit/sortable/sortable_tickets.js | 69 ------------------ 10 files changed, 242 insertions(+), 267 deletions(-) delete mode 100644 tests/unit/button/button_tickets.js delete mode 100644 tests/unit/dialog/dialog_tickets.js delete mode 100644 tests/unit/sortable/sortable_tickets.js diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index 991e4bceb..460201f15 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -113,4 +113,60 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) { }); } +test( "#7092 - button creation that requires a matching label does not find label in all cases", function() { + expect( 5 ); + var group = $( "" ); + group.find( "input[type=checkbox]" ).button(); + ok( group.find( "label" ).is( ".ui-button" ) ); + + group = $( "" ); + group.filter( "input[type=checkbox]" ).button(); + ok( group.filter( "label" ).is( ".ui-button" ) ); + + group = $( "" ); + group.find( "input[type=checkbox]" ).button(); + ok( group.filter( "label" ).is( ".ui-button" ) ); + + group = $( "" ); + group.find( "input[type=checkbox]" ).button(); + ok( group.find( "label" ).is( ".ui-button" ) ); + + group = $( "" ); + group.filter( "input[type=checkbox]" ).button(); + ok( group.find( "label" ).is( ".ui-button" ) ); +}); + +test( "#5946 - buttonset should ignore buttons that are not :visible", function() { + expect( 2 ); + $( "#radio01" ).next().andSelf().hide(); + var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" }); + ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) ); + ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) ); +}); + +test( "#6262 - buttonset not applying ui-corner to invisible elements", function() { + expect( 3 ); + $( "#radio0" ).hide(); + var set = $( "#radio0" ).buttonset(); + ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) ); + ok( set.find( "label:eq(1)" ).is( ".ui-button" ) ); + ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); +}); + +test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { + expect( 2 ); + var check = $( "#check" ).button(), + label = $( "label[for='check']" ); + ok( !label.is( ".ui-state-focus" ) ); + check.focus(); + ok( label.is( ".ui-state-focus" ) ); +}); + +test( "#7534 - Button label selector works for ids with \":\"", function() { + expect( 1 ); + var group = $( "" ); + group.find( "input" ).button(); + ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); +}); + })(jQuery); diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js index eeb6e5527..e1931a54e 100644 --- a/tests/unit/button/button_options.js +++ b/tests/unit/button/button_options.js @@ -103,4 +103,15 @@ test("icons", function() { $("#button").button("destroy"); }); +test( "#5295 - button does not remove hoverstate if disabled" , function() { + expect( 1 ); + var btn = $("#button").button(); + btn.hover( function() { + btn.button( "disable" ); + }); + btn.trigger( "mouseenter" ); + btn.trigger( "mouseleave" ); + ok( !btn.is( ".ui-state-hover") ); +}); + })(jQuery); diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js deleted file mode 100644 index 1272d368f..000000000 --- a/tests/unit/button/button_tickets.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * button_tickets.js - */ -(function( $ ) { - -module( "button: tickets" ); - -test( "#5295 - button does not remove hoverstate if disabled" , function() { - expect( 1 ); - var btn = $("#button").button(); - btn.hover( function() { - btn.button( "disable" ); - }); - btn.trigger( "mouseenter" ); - btn.trigger( "mouseleave" ); - ok( !btn.is( ".ui-state-hover") ); -}); - -test( "#5946 - buttonset should ignore buttons that are not :visible", function() { - expect( 2 ); - $( "#radio01" ).next().andSelf().hide(); - var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" }); - ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) ); - ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) ); -}); - -test( "#6262 - buttonset not applying ui-corner to invisible elements", function() { - expect( 3 ); - $( "#radio0" ).hide(); - var set = $( "#radio0" ).buttonset(); - ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) ); - ok( set.find( "label:eq(1)" ).is( ".ui-button" ) ); - ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); -}); - -test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { - expect( 2 ); - var check = $( "#check" ).button(), - label = $( "label[for='check']" ); - ok( !label.is( ".ui-state-focus" ) ); - check.focus(); - ok( label.is( ".ui-state-focus" ) ); -}); - -test( "#7092 - button creation that requires a matching label does not find label in all cases", function() { - expect( 5 ); - var group = $( "" ); - group.find( "input[type=checkbox]" ).button(); - ok( group.find( "label" ).is( ".ui-button" ) ); - - group = $( "" ); - group.filter( "input[type=checkbox]" ).button(); - ok( group.filter( "label" ).is( ".ui-button" ) ); - - group = $( "" ); - group.find( "input[type=checkbox]" ).button(); - ok( group.filter( "label" ).is( ".ui-button" ) ); - - group = $( "" ); - group.find( "input[type=checkbox]" ).button(); - ok( group.find( "label" ).is( ".ui-button" ) ); - - group = $( "" ); - group.filter( "input[type=checkbox]" ).button(); - ok( group.find( "label" ).is( ".ui-button" ) ); -}); - -test( "#7534 - Button label selector works for ids with \":\"", function() { - expect( 1 ); - var group = $( "" ); - group.find( "input" ).button(); - ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); -}); - -})( jQuery ); diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 9c0e80825..700208dfc 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -80,8 +80,7 @@ test( "focus tabbable", function() { }, 13); }); -// #7960 -test( "resizable handles below modal overlays", function() { +test( "#7960: resizable handles below modal overlays", function() { expect( 1 ); var resizable = $( "
    " ).resizable(), @@ -93,4 +92,33 @@ test( "resizable handles below modal overlays", function() { dialog.dialog( "destroy" ); }); +asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { + expect( 3 ); + + var el = $( "
    " ).dialog({ modal: true }), + inputs = el.find( "input" ), + widget = el.dialog( "widget" )[ 0 ]; + + function checkTab() { + ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); + + // check shift tab + $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); + setTimeout( checkShiftTab, 2 ); + } + + function checkShiftTab() { + ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); + + el.remove(); + start(); + } + + inputs.eq( 1 ).focus(); + equal( document.activeElement, inputs[1], "Focus set on second input" ); + inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); + + setTimeout( checkTab, 2 ); +}); + })(jQuery); diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index cbeced0f8..19337ad5d 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -341,4 +341,18 @@ asyncTest("ensure dialog's container doesn't scroll on resize and focus", functi }, 500); }); +test("#5184: isOpen in dialogclose event is true", function() { + expect( 3 ); + + var el = $( "
    " ).dialog({ + close: function() { + ok( !el.dialog("isOpen"), "dialog is not open during close" ); + } + }); + ok( el.dialog("isOpen"), "dialog is open after init" ); + el.dialog( "close" ); + ok( !el.dialog("isOpen"), "dialog is not open after close" ); + el.remove(); +}); + })(jQuery); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 92fe3d60f..fbb649fbf 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -137,4 +137,52 @@ test("open", function() { ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called'); }); +// TODO merge this with the main destroy test +test("#4980: Destroy should place element back in original DOM position", function(){ + expect( 2 ); + var container = $('
    '), + modal = container.find('#modal'); + modal.dialog(); + ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); + modal.dialog('destroy'); + ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); +}); + +test("#6137: dialog('open') causes form elements to reset on IE7", function() { + expect(2); + + var d1 = $('
    ' + + 'b
    ').appendTo( "body" ).dialog({autoOpen: false}); + + d1.find('#b').prop( "checked", true ); + equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); + + d1.dialog('open'); + equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); + + d1.remove(); +}); + +test("#5531: dialog width should be at least minWidth on creation", function () { + expect( 4 ); + var el = $('
    ').dialog({ + width: 200, + minWidth: 300 + }); + + equal(el.dialog('option', 'width'), 300, "width is minWidth"); + el.dialog('option', 'width', 200); + equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth"); + el.dialog('option', 'width', 320); + equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth"); + el.remove(); + + el = $('
    ').dialog({ + minWidth: 300 + }); + ok(el.dialog('option', 'width') >= 300, "width is at least 300"); + el.remove(); + +}); + })(jQuery); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index 19e69b29a..2ccbed573 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -478,4 +478,26 @@ test("width", function() { el.remove(); }); +test("#4826: setting resizable false toggles resizable on dialog", function() { + expect(6); + var i, + el = $('
    ').dialog({ resizable: false }); + + TestHelpers.dialog.shouldResize(el, 0, 0, "[default]"); + for (i=0; i<2; i++) { + el.dialog('close').dialog('open'); + TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')'); + } + el.remove(); + + el = $('
    ').dialog({ resizable: true }); + TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); + for (i=0; i<2; i++) { + el.dialog('close').dialog('option', 'resizable', false).dialog('open'); + TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')'); + } + el.remove(); + +}); + })(jQuery); diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js deleted file mode 100644 index 389a243b3..000000000 --- a/tests/unit/dialog/dialog_tickets.js +++ /dev/null @@ -1,121 +0,0 @@ -/* - * dialog_tickets.js - */ -(function($) { - -module( "dialog: tickets" ); - -asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { - expect( 3 ); - - var el = $( "
    " ).dialog({ modal: true }), - inputs = el.find( "input" ), - widget = el.dialog( "widget" )[ 0 ]; - - function checkTab() { - ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); - - // check shift tab - $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); - setTimeout( checkShiftTab, 2 ); - } - - function checkShiftTab() { - ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); - - el.remove(); - start(); - } - - inputs.eq( 1 ).focus(); - equal( document.activeElement, inputs[1], "Focus set on second input" ); - inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); - - setTimeout( checkTab, 2 ); -}); - -test("#4826: setting resizable false toggles resizable on dialog", function() { - expect(6); - var i, - el = $('
    ').dialog({ resizable: false }); - - TestHelpers.dialog.shouldResize(el, 0, 0, "[default]"); - for (i=0; i<2; i++) { - el.dialog('close').dialog('open'); - TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')'); - } - el.remove(); - - el = $('
    ').dialog({ resizable: true }); - TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); - for (i=0; i<2; i++) { - el.dialog('close').dialog('option', 'resizable', false).dialog('open'); - TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')'); - } - el.remove(); - -}); - -test("#5184: isOpen in dialogclose event is true", function() { - expect( 3 ); - - var el = $( "
    " ).dialog({ - close: function() { - ok( !el.dialog("isOpen"), "dialog is not open during close" ); - } - }); - ok( el.dialog("isOpen"), "dialog is open after init" ); - el.dialog( "close" ); - ok( !el.dialog("isOpen"), "dialog is not open after close" ); - el.remove(); -}); - -test("#5531: dialog width should be at least minWidth on creation", function () { - expect( 4 ); - var el = $('
    ').dialog({ - width: 200, - minWidth: 300 - }); - - equal(el.dialog('option', 'width'), 300, "width is minWidth"); - el.dialog('option', 'width', 200); - equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth"); - el.dialog('option', 'width', 320); - equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth"); - el.remove(); - - el = $('
    ').dialog({ - minWidth: 300 - }); - ok(el.dialog('option', 'width') >= 300, "width is at least 300"); - el.remove(); - -}); - -test("#6137: dialog('open') causes form elements to reset on IE7", function() { - expect(2); - - var d1 = $('
    ' + - 'b
    ').appendTo( "body" ).dialog({autoOpen: false}); - - d1.find('#b').prop( "checked", true ); - equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); - - d1.dialog('open'); - equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); - - d1.remove(); -}); - -// TODO merge this with the main destroy test -test("#4980: Destroy should place element back in original DOM position", function(){ - expect( 2 ); - var container = $('
    '), - modal = container.find('#modal'); - modal.dialog(); - ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); - modal.dialog('destroy'); - ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); -}); - -})(jQuery); diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index 556f539e1..4245d64fa 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -128,6 +128,67 @@ test("update", function() { }); +test("#3019: Stop fires too early", function() { + expect(2); + + var helper = null, + el = $("#sortable").sortable({ + stop: function(event, ui) { + helper = ui.helper; + } + }); + + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable'); + equal(helper, null, "helper should be false"); + +}); + +test('#4752: link event firing on sortable with connect list', function () { + expect( 10 ); + + var fired = {}, + hasFired = function (type) { return (type in fired) && (true === fired[type]); }; + + $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); + + $('#qunit-fixture ul').sortable({ + connectWith: '#qunit-fixture ul', + change: function () { + fired.change = true; + }, + receive: function () { + fired.receive = true; + }, + remove: function () { + fired.remove = true; + } + }); + + $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { + fired.click = true; + }); + + $('#sortable li:eq(0)').simulate('click'); + ok(!hasFired('change'), 'Click only, change event should not have fired'); + ok(hasFired('click'), 'Click event should have fired'); + + // Drag an item within the first list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); + ok(hasFired('change'), '40px drag, change event should have fired'); + ok(!hasFired('receive'), 'Receive event should not have fired'); + ok(!hasFired('remove'), 'Remove event should not have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); + + // Drag an item from the first list to the second, connected list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); + ok(hasFired('change'), '150px drag, change event should have fired'); + ok(hasFired('receive'), 'Receive event should have fired'); + ok(hasFired('remove'), 'Remove event should have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); +}); + /* test("receive", function() { ok(false, "missing test - untested code is broken code."); diff --git a/tests/unit/sortable/sortable_tickets.js b/tests/unit/sortable/sortable_tickets.js deleted file mode 100644 index eebd8dc21..000000000 --- a/tests/unit/sortable/sortable_tickets.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * sortable_tickets.js - */ -(function($) { - -module("sortable: tickets"); - -test("#3019: Stop fires too early", function() { - expect(2); - - var helper = null, - el = $("#sortable").sortable({ - stop: function(event, ui) { - helper = ui.helper; - } - }); - - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable'); - equal(helper, null, "helper should be false"); - -}); - -test('#4752: link event firing on sortable with connect list', function () { - expect( 10 ); - - var fired = {}, - hasFired = function (type) { return (type in fired) && (true === fired[type]); }; - - $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); - - $('#qunit-fixture ul').sortable({ - connectWith: '#qunit-fixture ul', - change: function () { - fired.change = true; - }, - receive: function () { - fired.receive = true; - }, - remove: function () { - fired.remove = true; - } - }); - - $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { - fired.click = true; - }); - - $('#sortable li:eq(0)').simulate('click'); - ok(!hasFired('change'), 'Click only, change event should not have fired'); - ok(hasFired('click'), 'Click event should have fired'); - - // Drag an item within the first list - fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); - ok(hasFired('change'), '40px drag, change event should have fired'); - ok(!hasFired('receive'), 'Receive event should not have fired'); - ok(!hasFired('remove'), 'Remove event should not have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); - - // Drag an item from the first list to the second, connected list - fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); - ok(hasFired('change'), '150px drag, change event should have fired'); - ok(hasFired('receive'), 'Receive event should have fired'); - ok(hasFired('remove'), 'Remove event should have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); -}); - -})(jQuery); -- cgit v1.2.3 From 5dee8dee309564626393e1871991aa2a0e58dd74 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sat, 8 Dec 2012 13:19:36 -0500 Subject: Dev: Change incorrect references in test suite from #main to #qunit-fixture. --- tests/unit/dialog/dialog_core.js | 3 ++- tests/unit/draggable/draggable_core.js | 2 +- tests/unit/tabs/tabs_core.js | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 700208dfc..f10087912 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -34,8 +34,9 @@ test( "ARIA", function() { test("widget method", function() { expect( 1 ); - var dialog = $("
    ").appendTo("#main").dialog(); + var dialog = $("
    ").appendTo("#qunit-fixture").dialog(); deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]); + dialog.remove(); }); test( "focus tabbable", function() { diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 28a19f380..66628465b 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -17,7 +17,7 @@ test("element types", function() { $.each(typeNames, function(i) { var offsetBefore, offsetAfter, typeName = typeNames[i], - el = $(document.createElement(typeName)).appendTo('#main'); + el = $(document.createElement(typeName)).appendTo('#qunit-fixture'); (typeName === 'table' && el.append("content")); el.draggable({ cancel: '' }); diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js index 20364a37d..5f70206dc 100644 --- a/tests/unit/tabs/tabs_core.js +++ b/tests/unit/tabs/tabs_core.js @@ -599,8 +599,8 @@ test( "#3627 - Ajax tab with url containing a fragment identifier fails to load" test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", function() { expect( 2 ); - var element = $( "" ); - element.appendTo( "#main" ); + var element = $(""); + element.appendTo("#qunit-fixture"); element.tabs({ beforeLoad: function() { event.preventDefault(); @@ -608,7 +608,7 @@ test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", funct } }); - equal( element.find( ".ui-tabs-nav li" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" ); + equal( element.find(".ui-tabs-nav li").attr("aria-controls"), "tab", "aria-contorls attribute is correct" ); state( element, 1 ); }); -- cgit v1.2.3 From 9f764467751c1c5bdefa28421807eafc9868b37f Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sat, 8 Dec 2012 21:27:37 -0500 Subject: Dev: remove unnecessary simulated drag delegation in test suite --- tests/unit/dialog/dialog_test_helpers.js | 7 +- tests/unit/draggable/draggable_core.js | 23 ++- tests/unit/draggable/draggable_events.js | 20 ++- tests/unit/draggable/draggable_options.js | 144 ++++++++++++------ tests/unit/draggable/draggable_test_helpers.js | 11 +- tests/unit/resizable/resizable_test_helpers.js | 17 +-- tests/unit/selectable/selectable_events.js | 30 ++-- tests/unit/selectable/selectable_methods.js | 21 ++- tests/unit/selectable/selectable_options.js | 22 ++- tests/unit/selectable/selectable_test_helpers.js | 8 - tests/unit/sortable/sortable_events.js | 180 ++++++++++++++--------- tests/unit/sortable/sortable_test_helpers.js | 10 +- 12 files changed, 300 insertions(+), 193 deletions(-) delete mode 100644 tests/unit/selectable/selectable_test_helpers.js diff --git a/tests/unit/dialog/dialog_test_helpers.js b/tests/unit/dialog/dialog_test_helpers.js index bbf43f48f..ef0b9b6fa 100644 --- a/tests/unit/dialog/dialog_test_helpers.js +++ b/tests/unit/dialog/dialog_test_helpers.js @@ -3,10 +3,9 @@ TestHelpers.dialog = { var d = el.dialog('widget'); //this mouseover is to work around a limitation in resizable //TODO: fix resizable so handle doesn't require mouseover in order to be used - $(handle, d).simulate("mouseover"); - $(handle, d).simulate("drag", { - dx: dx || 0, - dy: dy || 0 + $( handle, d ).simulate("mouseover").simulate( "drag", { + dx: dx, + dy: dy }); }, testDrag: function(el, dx, dy, expectedDX, expectedDY, msg) { diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 66628465b..2bfccbfa6 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -22,7 +22,10 @@ test("element types", function() { (typeName === 'table' && el.append("content")); el.draggable({ cancel: '' }); offsetBefore = el.offset(); - TestHelpers.draggable.drag(el, 50, 50); + el.simulate( "drag", { + dx: 50, + dy: 50 + }); offsetAfter = el.offset(); // there are some rounding errors in FF, Chrome, and IE9, so we can't say equal, we have to settle for close enough closeEnough(offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">"); @@ -55,21 +58,15 @@ test("resizable handle with complex markup (#8756 / #8757)", function() { .append($('
    ')) ); - var handle = '.ui-resizable-w div', - target = $('#draggable1').draggable().resizable({ handles: 'all' }), - drag = function(el, dx) { - $(el) - .simulate("mouseover") - .simulate("drag", { - dx: dx || 0, - speed: 'sync' - }); - }; + var handle = $('.ui-resizable-w div'), + target = $('#draggable1').draggable().resizable({ handles: 'all' }); - drag(handle, -50); + // todo: fix resizable so it doesn't require a mouseover + handle.simulate("mouseover").simulate( "drag", { dx: -50 } ); equal( target.width(), 250, "compare width" ); - drag(handle, 50); + // todo: fix resizable so it doesn't require a mouseover + handle.simulate("mouseover").simulate( "drag", { dx: 50 } ); equal( target.width(), 200, "compare width" ); }); diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js index 5eab97713..07a53e22e 100644 --- a/tests/unit/draggable/draggable_events.js +++ b/tests/unit/draggable/draggable_events.js @@ -18,7 +18,10 @@ test("callbacks occurrence count", function() { stop: function() { stop++; } }); - TestHelpers.draggable.drag(el, 10, 10); + el.simulate( "drag", { + dx: 10, + dy: 10 + }); equal(start, 1, "start callback should happen exactly once"); equal(dragc, 3, "drag callback should happen exactly once per mousemove"); @@ -39,7 +42,10 @@ test("stopping the start callback", function() { stop: function() { stop++; } }); - TestHelpers.draggable.drag(el, 10, 10); + el.simulate( "drag", { + dx: 10, + dy: 10 + }); equal(start, 1, "start callback should happen exactly once"); equal(dragc, 0, "drag callback should not happen at all"); @@ -60,7 +66,10 @@ test("stopping the drag callback", function() { stop: function() { stop++; } }); - TestHelpers.draggable.drag(el, 10, 10); + el.simulate( "drag", { + dx: 10, + dy: 10 + }); equal(start, 1, "start callback should happen exactly once"); equal(dragc, 1, "drag callback should happen exactly once"); @@ -77,7 +86,10 @@ test("stopping the stop callback", function() { stop: function() { return false; } }); - TestHelpers.draggable.drag(el, 10, 10); + el.simulate( "drag", { + dx: 10, + dy: 10 + }); ok($("#draggable2").data('ui-draggable').helper, "the clone should not be deleted if the stop callback is stopped"); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 3f4592d31..d9a7038f7 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -162,7 +162,11 @@ test("{ containment: 'parent' }, relative", function() { left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'), top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top') }; - TestHelpers.draggable.drag(el, -100, -100); + + el.simulate( "drag", { + dx: -100, + dy: -100 + }); offsetAfter = el.offset(); deepEqual(offsetAfter, expected, 'compare offset to parent'); }); @@ -178,7 +182,11 @@ test("{ containment: 'parent' }, absolute", function() { left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'), top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top') }; - TestHelpers.draggable.drag(el, -100, -100); + + el.simulate( "drag", { + dx: -100, + dy: -100 + }); offsetAfter = el.offset(); deepEqual(offsetAfter, expected, 'compare offset to parent'); }); @@ -214,17 +222,20 @@ test("{ cursor: 'auto' }, default", function() { expect(2); - var expected = "auto", actual, before, after; - - $("#draggable2").draggable({ - cursor: expected, - start: function() { - actual = getCursor(); - } - }); + var actual, before, after, + expected = "auto", + el = $("#draggable2").draggable({ + cursor: expected, + start: function() { + actual = getCursor(); + } + }); before = getCursor(); - TestHelpers.draggable.drag("#draggable2", -1, -1); + el.simulate( "drag", { + dx: -1, + dy: -1 + }); after = getCursor(); equal(actual, expected, "start callback: cursor '" + expected + "'"); @@ -238,17 +249,20 @@ test("{ cursor: 'move' }", function() { expect(2); - var expected = "move", actual, before, after; - - $("#draggable2").draggable({ - cursor: expected, - start: function() { - actual = getCursor(); - } - }); + var actual, before, after, + expected = "move", + el = $("#draggable2").draggable({ + cursor: expected, + start: function() { + actual = getCursor(); + } + }); before = getCursor(); - TestHelpers.draggable.drag("#draggable2", -1, -1); + el.simulate( "drag", { + dx: -1, + dy: -1 + }); after = getCursor(); equal(actual, expected, "start callback: cursor '" + expected + "'"); @@ -648,7 +662,10 @@ test("{ helper: 'clone' }, absolute", function() { helperOffset = ui.helper.offset(); } }); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); }); @@ -666,17 +683,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() { $("#main").css('position', 'relative'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'static'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'absolute'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); TestHelpers.draggable.restoreScroll(); @@ -696,17 +722,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on root", function() { $("#main").css('position', 'relative'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'static'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'absolute'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); TestHelpers.draggable.restoreScroll('root'); @@ -728,17 +763,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func $("#main").css('position', 'relative'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'static'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'absolute'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); TestHelpers.draggable.restoreScroll('root'); @@ -750,17 +794,19 @@ test("{ opacity: 0.5 }", function() { expect(1); - var opacity = null; - - $("#draggable2").draggable({ - opacity: 0.5, - start: function() { - opacity = $(this).css("opacity"); - } + var opacity = null, + el = $("#draggable2").draggable({ + opacity: 0.5, + start: function() { + opacity = $(this).css("opacity"); + } + }); + + el.simulate( "drag", { + dx: -1, + dy: -1 }); - TestHelpers.draggable.drag("#draggable2", -1, -1); - equal(opacity, 0.5, "start callback: opacity is"); }); @@ -770,17 +816,19 @@ test("{ zIndex: 10 }", function() { expect(1); var actual, - expected = 10; - - $("#draggable2").draggable({ - zIndex: expected, - start: function() { - actual = $(this).css("zIndex"); - } + expected = 10, + el = $("#draggable2").draggable({ + zIndex: expected, + start: function() { + actual = $(this).css("zIndex"); + } + }); + + el.simulate( "drag", { + dx: -1, + dy: -1 }); - TestHelpers.draggable.drag("#draggable2", -1, -1); - equal(actual, expected, "start callback: zIndex is"); }); diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index 7057df1f8..9a6355b2e 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -1,17 +1,14 @@ TestHelpers.draggable = { // todo: remove the unreliable offset hacks unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0, - drag: function(handle, dx, dy) { - $(handle).simulate("drag", { - dx: dx || 0, - dy: dy || 0 - }); - }, testDrag: function(el, handle, dx, dy, expectedDX, expectedDY, msg) { var offsetAfter, actual, expected, offsetBefore = el.offset(); - TestHelpers.draggable.drag(handle, dx, dy); + $( handle ).simulate( "drag", { + dx: dx, + dy: dy + }); offsetAfter = el.offset(); actual = { left: offsetAfter.left, top: offsetAfter.top }, diff --git a/tests/unit/resizable/resizable_test_helpers.js b/tests/unit/resizable/resizable_test_helpers.js index fe6c84900..88f2bc57b 100644 --- a/tests/unit/resizable/resizable_test_helpers.js +++ b/tests/unit/resizable/resizable_test_helpers.js @@ -1,15 +1,10 @@ TestHelpers.resizable = { - drag: function(el, dx, dy, complete) { - - // speed = sync -> Drag syncrhonously. - // speed = fast|slow -> Drag asyncrhonously - animated. - - //this mouseover is to work around a limitation in resizable - //TODO: fix resizable so handle doesn't require mouseover in order to be used - $(el).simulate("mouseover"); - - return $(el).simulate("drag", { - dx: dx||0, dy: dy||0, speed: 'sync', complete: complete + drag: function( el, dx, dy ) { + // this mouseover is to work around a limitation in resizable + // TODO: fix resizable so handle doesn't require mouseover in order to be used + $( el ).simulate("mouseover").simulate( "drag", { + dx: dx, + dy: dy }); } }; \ No newline at end of file diff --git a/tests/unit/selectable/selectable_events.js b/tests/unit/selectable/selectable_events.js index 331bae146..984fd1862 100644 --- a/tests/unit/selectable/selectable_events.js +++ b/tests/unit/selectable/selectable_events.js @@ -1,32 +1,38 @@ /* * selectable_events.js */ -(function($) { +(function( $ ) { module("selectable: events"); -test("start", function() { - expect(2); +test( "start", function() { + expect( 2 ); var el = $("#selectable1"); el.selectable({ start: function() { - ok(true, "drag fired start callback"); - equal(this, el[0], "context of callback"); + ok( true, "drag fired start callback" ); + equal( this, el[0], "context of callback" ); } }); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); }); -test("stop", function() { - expect(2); +test( "stop", function() { + expect( 2 ); var el = $("#selectable1"); el.selectable({ start: function() { - ok(true, "drag fired stop callback"); - equal(this, el[0], "context of callback"); + ok( true, "drag fired stop callback" ); + equal( this, el[0], "context of callback" ); } }); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); }); -})(jQuery); +})( jQuery ); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index aa8924176..d894a13e4 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -53,10 +53,16 @@ test("enable", function() { disabled: true, start: function() { fired = true; } }); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); equal(fired, false, "start fired"); el.selectable("enable"); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); equal(fired, true, "start fired"); el.selectable("destroy"); @@ -75,11 +81,18 @@ test("disable", function() { disabled: false, start: function() { fired = true; } }); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); equal(fired, true, "start fired"); el.selectable("disable"); fired = false; - el.simulate("drag", 20, 20); + + el.simulate( "drag", { + dx: 20, + dy: 20 + }); equal(fired, false, "start fired"); el.selectable("destroy"); diff --git a/tests/unit/selectable/selectable_options.js b/tests/unit/selectable/selectable_options.js index 50e047427..a2455fdca 100644 --- a/tests/unit/selectable/selectable_options.js +++ b/tests/unit/selectable/selectable_options.js @@ -15,7 +15,10 @@ test("autoRefresh", function() { el = $("#selectable1").selectable({ autoRefresh: false, selected: selected }); sel.hide(); - TestHelpers.selectable.drag(el, 1000, 1000); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); equal(actual, sel.length); el.selectable("destroy"); @@ -23,11 +26,19 @@ test("autoRefresh", function() { sel.show(); el = $("#selectable1").selectable({ autoRefresh: true, selected: selected }); sel.hide(); - TestHelpers.selectable.drag(el, 1000, 1000); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); equal(actual, 0); + sel.show(); - TestHelpers.selectable.drag( sel[ 0 ], 1000, 1000 ); + $( sel[ 0 ] ).simulate( "drag", { + dx: 1000, + dy: 1000 + }); equal(actual, sel.length); + el.selectable("destroy"); sel.show(); }); @@ -42,7 +53,10 @@ test("filter", function() { el = $("#selectable1").selectable({ filter: '.special', selected: selected }); - TestHelpers.selectable.drag(el, 1000, 1000); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); ok(sel.length !== 1, "this test assumes more than 1 selectee"); equal(actual, 1); el.selectable("destroy"); diff --git a/tests/unit/selectable/selectable_test_helpers.js b/tests/unit/selectable/selectable_test_helpers.js deleted file mode 100644 index 6f87efbb3..000000000 --- a/tests/unit/selectable/selectable_test_helpers.js +++ /dev/null @@ -1,8 +0,0 @@ -TestHelpers.selectable = { - drag: function( el, dx, dy ) { - $( el ).simulate( "drag", { - dx: dx || 0, - dy: dy || 0 - }); - } -}; \ No newline at end of file diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index 4245d64fa..b9ee078f5 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -9,9 +9,13 @@ test("start", function() { expect( 7 ); var hash; - $("#sortable") - .sortable({ start: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 }); + $("#sortable").sortable({ + start: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 10 + }); ok(hash, 'start event triggered'); ok(hash.helper, 'UI hash includes: helper'); @@ -30,9 +34,13 @@ test("sort", function() { expect( 7 ); var hash; - $("#sortable") - .sortable({ sort: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 }); + $("#sortable").sortable({ + sort: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 10 + }); ok(hash, 'sort event triggered'); ok(hash.helper, 'UI hash includes: helper'); @@ -48,15 +56,24 @@ test("change", function() { expect( 8 ); var hash; - $("#sortable") - .sortable({ change: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 }); + $("#sortable").sortable({ + change: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dx: 1, + dy: 1 + }); ok(!hash, '1px drag, change event should not be triggered'); - $("#sortable") - .sortable({ change: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 22 }); + $("#sortable").sortable({ + change: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 22 + }); ok(hash, 'change event triggered'); ok(hash.helper, 'UI hash includes: helper'); @@ -72,9 +89,13 @@ test("beforeStop", function() { expect( 7 ); var hash; - $("#sortable") - .sortable({ beforeStop: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); + $("#sortable").sortable({ + beforeStop: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 20 + }); ok(hash, 'beforeStop event triggered'); ok(hash.helper, 'UI hash includes: helper'); @@ -90,9 +111,13 @@ test("stop", function() { expect( 7 ); var hash; - $("#sortable") - .sortable({ stop: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); + $("#sortable").sortable({ + stop: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 20 + }); ok(hash, 'stop event triggered'); ok(!hash.helper, 'UI should not include: helper'); @@ -108,15 +133,24 @@ test("update", function() { expect( 8 ); var hash; - $("#sortable") - .sortable({ update: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 }); + $("#sortable").sortable({ + update: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dx: 1, + dy: 1 + }); ok(!hash, '1px drag, update event should not be triggered'); - $("#sortable") - .sortable({ update: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 22 }); + $("#sortable").sortable({ + update: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 22 + }); ok(hash, 'update event triggered'); ok(!hash.helper, 'UI hash should not include: helper'); @@ -129,14 +163,14 @@ test("update", function() { }); test("#3019: Stop fires too early", function() { - expect(2); + expect(2); var helper = null, - el = $("#sortable").sortable({ - stop: function(event, ui) { - helper = ui.helper; - } - }); + el = $("#sortable").sortable({ + stop: function(event, ui) { + helper = ui.helper; + } + }); TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable'); equal(helper, null, "helper should be false"); @@ -144,49 +178,49 @@ test("#3019: Stop fires too early", function() { }); test('#4752: link event firing on sortable with connect list', function () { - expect( 10 ); - - var fired = {}, - hasFired = function (type) { return (type in fired) && (true === fired[type]); }; - - $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); - - $('#qunit-fixture ul').sortable({ - connectWith: '#qunit-fixture ul', - change: function () { - fired.change = true; - }, - receive: function () { - fired.receive = true; - }, - remove: function () { - fired.remove = true; - } - }); - - $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { - fired.click = true; - }); - - $('#sortable li:eq(0)').simulate('click'); - ok(!hasFired('change'), 'Click only, change event should not have fired'); - ok(hasFired('click'), 'Click event should have fired'); - - // Drag an item within the first list - fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); - ok(hasFired('change'), '40px drag, change event should have fired'); - ok(!hasFired('receive'), 'Receive event should not have fired'); - ok(!hasFired('remove'), 'Remove event should not have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); - - // Drag an item from the first list to the second, connected list - fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); - ok(hasFired('change'), '150px drag, change event should have fired'); - ok(hasFired('receive'), 'Receive event should have fired'); - ok(hasFired('remove'), 'Remove event should have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); + expect( 10 ); + + var fired = {}, + hasFired = function (type) { return (type in fired) && (true === fired[type]); }; + + $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); + + $('#qunit-fixture ul').sortable({ + connectWith: '#qunit-fixture ul', + change: function () { + fired.change = true; + }, + receive: function () { + fired.receive = true; + }, + remove: function () { + fired.remove = true; + } + }); + + $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { + fired.click = true; + }); + + $('#sortable li:eq(0)').simulate('click'); + ok(!hasFired('change'), 'Click only, change event should not have fired'); + ok(hasFired('click'), 'Click event should have fired'); + + // Drag an item within the first list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); + ok(hasFired('change'), '40px drag, change event should have fired'); + ok(!hasFired('receive'), 'Receive event should not have fired'); + ok(!hasFired('remove'), 'Remove event should not have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); + + // Drag an item from the first list to the second, connected list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); + ok(hasFired('change'), '150px drag, change event should have fired'); + ok(hasFired('receive'), 'Receive event should have fired'); + ok(hasFired('remove'), 'Remove event should have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); }); /* diff --git a/tests/unit/sortable/sortable_test_helpers.js b/tests/unit/sortable/sortable_test_helpers.js index 7569b5797..12e4829ea 100644 --- a/tests/unit/sortable/sortable_test_helpers.js +++ b/tests/unit/sortable/sortable_test_helpers.js @@ -1,9 +1,9 @@ TestHelpers.sortable = { - sort: function(handle, dx, dy, index, msg) { - $(handle).simulate("drag", { - dx: dx || 0, - dy: dy || 0 + sort: function( handle, dx, dy, index, msg ) { + $( handle ).simulate( "drag", { + dx: dx, + dy: dy }); - equal($(handle).parent().children().index(handle), index, msg); + equal( $( handle ).parent().children().index( handle ), index, msg ); } }; \ No newline at end of file -- cgit v1.2.3 From 0f0ec001aac23acb4b7f8cd8fc5e549b541a685d Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 10 Dec 2012 08:52:54 -0500 Subject: Dialog tests: Updated markup for deprecated tests to match standard tests. --- tests/unit/dialog/dialog_deprecated.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/dialog/dialog_deprecated.html b/tests/unit/dialog/dialog_deprecated.html index 2a876ac73..3360e6ef7 100644 --- a/tests/unit/dialog/dialog_deprecated.html +++ b/tests/unit/dialog/dialog_deprecated.html @@ -57,6 +57,8 @@
    +
    +
    -- cgit v1.2.3 From 2841541362fe121977181888c3181676f0b796e4 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 10 Dec 2012 10:34:44 -0500 Subject: Core tests: Handle async focus in IE. --- tests/unit/core/core.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index 5ebb9e9f4..86b95e157 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -4,11 +4,12 @@ module( "core - jQuery extensions" ); TestHelpers.testJshint( "core" ); -test( "focus - original functionality", function() { +asyncTest( "focus - original functionality", function() { expect( 1 ); $( "#inputTabindex0" ) - .focus(function() { + .one( "focus", function() { ok( true, "event triggered" ); + start(); }) .focus(); }); @@ -16,12 +17,10 @@ test( "focus - original functionality", function() { asyncTest( "focus", function() { expect( 2 ); $( "#inputTabindex0" ) - .focus(function() { + .one( "focus", function() { ok( true, "event triggered" ); }) .focus( 500, function() { - // prevent double focus event in IE - $( this ).unbind( "focus" ); ok( true, "callback triggered" ); start(); }); -- cgit v1.2.3 From fbc7956b9fbbc14f7854588341177075282d56b5 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 10 Dec 2012 10:35:01 -0500 Subject: Button tests: Handle async focus in IE. --- tests/unit/button/button_core.js | 7 +++++-- tests/unit/button/button_events.js | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index 460201f15..6d0bbbe88 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -153,13 +153,16 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); }); -test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { +asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { expect( 2 ); var check = $( "#check" ).button(), label = $( "label[for='check']" ); ok( !label.is( ".ui-state-focus" ) ); check.focus(); - ok( label.is( ".ui-state-focus" ) ); + setTimeout(function() { + ok( label.is( ".ui-state-focus" ) ); + start(); + }); }); test( "#7534 - Button label selector works for ids with \":\"", function() { diff --git a/tests/unit/button/button_events.js b/tests/unit/button/button_events.js index 7b79c41ea..2fd038325 100644 --- a/tests/unit/button/button_events.js +++ b/tests/unit/button/button_events.js @@ -13,14 +13,24 @@ test("buttonset works with single-quote named elements (#7505)", function() { }).click(); }); -test( "when button loses focus, ensure active state is removed (#8559)", function() { +asyncTest( "when button loses focus, ensure active state is removed (#8559)", function() { expect( 1 ); - $("#button").button().keypress( function() { - $("#button").one( "blur", function() { - ok( !$("#button").is(".ui-state-active"), "button loses active state appropriately" ); + var element = $( "#button" ).button(); + + element.one( "keypress", function() { + element.one( "blur", function() { + ok( !element.is(".ui-state-active"), "button loses active state appropriately" ); + start(); }).blur(); - }).focus().simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ).simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } ); + }); + + element.focus(); + setTimeout(function() { + element + .simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ) + .simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } ); + }); }); })(jQuery); -- cgit v1.2.3 From d5f06c319a0508bfa342717cb7b50b97acddfb15 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 10 Dec 2012 10:35:28 -0500 Subject: Spinner tests: Better handling of async focus in IE. --- tests/unit/spinner/spinner_events.js | 171 ++++++++++++++++++++--------------- 1 file changed, 100 insertions(+), 71 deletions(-) diff --git a/tests/unit/spinner/spinner_events.js b/tests/unit/spinner/spinner_events.js index 64f510de0..7da16c371 100644 --- a/tests/unit/spinner/spinner_events.js +++ b/tests/unit/spinner/spinner_events.js @@ -131,100 +131,129 @@ asyncTest( "change", function() { }); } - element.focus(); - shouldChange( false, "key UP, before blur" ); - simulateKeyDownUp( element, $.ui.keyCode.UP ); - shouldChange( true, "blur after key UP" ); - element.blur(); + function focusWrap( fn, next ) { + element[0].focus(); + setTimeout( function() { + fn(); + setTimeout(function() { + element[0].blur(); + setTimeout( next ); + }); + }); + } - element.focus(); - shouldChange( false, "key DOWN, before blur" ); - simulateKeyDownUp( element, $.ui.keyCode.DOWN ); - shouldChange( true, "blur after key DOWN" ); - element.blur(); + function step1() { + focusWrap(function() { + shouldChange( false, "key UP, before blur" ); + simulateKeyDownUp( element, $.ui.keyCode.UP ); + shouldChange( true, "blur after key UP" ); + }, step2 ); + } - element.focus(); - shouldChange( false, "key PAGE_UP, before blur" ); - simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); - shouldChange( true, "blur after key PAGE_UP" ); - element.blur(); + function step2() { + focusWrap(function() { + shouldChange( false, "key DOWN, before blur" ); + simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + shouldChange( true, "blur after key DOWN" ); + }, step3 ); + } - element.focus(); - shouldChange( false, "key PAGE_DOWN, before blur" ); - simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); - shouldChange( true, "blur after key PAGE_DOWN" ); - element.blur(); + function step3() { + focusWrap(function() { + shouldChange( false, "key PAGE_UP, before blur" ); + simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + shouldChange( true, "blur after key PAGE_UP" ); + }, step4 ); + } - shouldChange( false, "many keys, before blur" ); - simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); - simulateKeyDownUp( element, $.ui.keyCode.UP ); - simulateKeyDownUp( element, $.ui.keyCode.UP ); - simulateKeyDownUp( element, $.ui.keyCode.UP ); - simulateKeyDownUp( element, $.ui.keyCode.DOWN ); - shouldChange( true, "blur after many keys" ); - element.blur(); + function step4() { + focusWrap(function() { + shouldChange( false, "key PAGE_DOWN, before blur" ); + simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + shouldChange( true, "blur after key PAGE_DOWN" ); + }, step5 ); + } - shouldChange( false, "many keys, same final value, before blur" ); - simulateKeyDownUp( element, $.ui.keyCode.UP ); - simulateKeyDownUp( element, $.ui.keyCode.UP ); - simulateKeyDownUp( element, $.ui.keyCode.DOWN ); - simulateKeyDownUp( element, $.ui.keyCode.DOWN ); - shouldChange( false, "blur after many keys, same final value" ); + function step5() { + focusWrap(function() { + shouldChange( false, "many keys, before blur" ); + simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + simulateKeyDownUp( element, $.ui.keyCode.UP ); + simulateKeyDownUp( element, $.ui.keyCode.UP ); + simulateKeyDownUp( element, $.ui.keyCode.UP ); + simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + shouldChange( true, "blur after many keys" ); + }, step6 ); + } - shouldChange( false, "button up, before blur" ); - element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); - shouldChange( true, "blur after button up" ); - setTimeout(function() { - element.blur(); + function step6() { + focusWrap(function() { + shouldChange( false, "many keys, same final value, before blur" ); + simulateKeyDownUp( element, $.ui.keyCode.UP ); + simulateKeyDownUp( element, $.ui.keyCode.UP ); + simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + shouldChange( false, "blur after many keys, same final value" ); - shouldChange( false, "button down, before blur" ); - element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); - shouldChange( true, "blur after button down" ); - setTimeout(function() { - element.blur(); + shouldChange( false, "button up, before blur" ); + element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); + shouldChange( true, "blur after button up" ); + }, step7 ); + } + function step7() { + focusWrap(function() { + shouldChange( false, "button down, before blur" ); + element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); + shouldChange( true, "blur after button down" ); + }, step8 ); + } + + function step8() { + focusWrap(function() { shouldChange( false, "many buttons, same final value, before blur" ); element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); shouldChange( false, "blur after many buttons, same final value" ); - element.blur(); - setTimeout(function() { - shouldChange( true, "stepUp" ); - element.spinner( "stepUp" ); + }, step9 ); + } - shouldChange( true, "stepDown" ); - element.spinner( "stepDown" ); + function step9() { + shouldChange( true, "stepUp" ); + element.spinner( "stepUp" ); - shouldChange( true, "pageUp" ); - element.spinner( "pageUp" ); + shouldChange( true, "stepDown" ); + element.spinner( "stepDown" ); - shouldChange( true, "pageDown" ); - element.spinner( "pageDown" ); + shouldChange( true, "pageUp" ); + element.spinner( "pageUp" ); - shouldChange( true, "value" ); - element.spinner( "value", 999 ); + shouldChange( true, "pageDown" ); + element.spinner( "pageDown" ); - shouldChange( false, "value, same value" ); - element.spinner( "value", 999 ); + shouldChange( true, "value" ); + element.spinner( "value", 999 ); - shouldChange( true, "max, value changed" ); - element.spinner( "option", "max", 900 ); + shouldChange( false, "value, same value" ); + element.spinner( "value", 999 ); - shouldChange( false, "max, value not changed" ); - element.spinner( "option", "max", 1000 ); + shouldChange( true, "max, value changed" ); + element.spinner( "option", "max", 900 ); - shouldChange( true, "min, value changed" ); - element.spinner( "option", "min", 950 ); + shouldChange( false, "max, value not changed" ); + element.spinner( "option", "max", 1000 ); - shouldChange( false, "min, value not changed" ); - element.spinner( "option", "min", 200 ); - shouldChange( true, "cleanup" ); - start(); - }); - }); - }); + shouldChange( true, "min, value changed" ); + element.spinner( "option", "min", 950 ); + + shouldChange( false, "min, value not changed" ); + element.spinner( "option", "min", 200 ); + start(); + } + + step1(); }); })( jQuery ); -- cgit v1.2.3 From 245a82d5aad6e2b721bfb24c9e118f2d92b8696a Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 10 Dec 2012 15:31:56 -0500 Subject: Dialog tests: More async focus handling to deal with IE8. --- tests/unit/dialog/dialog_core.js | 83 ++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index f10087912..817f76ea9 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -39,7 +39,7 @@ test("widget method", function() { dialog.remove(); }); -test( "focus tabbable", function() { +asyncTest( "focus tabbable", function() { expect( 5 ); var el, options = { @@ -49,36 +49,59 @@ test( "focus tabbable", function() { }] }; - el = $( "
    " ).dialog( options ); - equal( document.activeElement, el.find( "input" )[ 1 ], "1. first element inside the dialog matching [autofocus]" ); - el.remove(); + function checkFocus( markup, options, testFn, next ) { + el = $( markup ).dialog( options ); + setTimeout(function() { + testFn(); + el.remove(); + setTimeout( next ); + }); + } - // IE8 fails to focus the input, ends up being the activeElement - // so wait for that stupid browser - stop(); - setTimeout(function() { - el = $( "
    " ).dialog( options ); - equal( document.activeElement, el.find( "input" )[ 0 ], "2. tabbable element inside the content element" ); - el.remove(); + function step1() { + checkFocus( "
    ", options, function() { + equal( document.activeElement, el.find( "input" )[ 1 ], + "1. first element inside the dialog matching [autofocus]" ); + }, step2 ); + } - el = $( "
    text
    " ).dialog( options ); - equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], "3. tabbable element inside the buttonpane" ); - el.remove(); + function step2() { + checkFocus( "
    ", options, function() { + equal( document.activeElement, el.find( "input" )[ 0 ], + "2. tabbable element inside the content element" ); + }, step3 ); + } - el = $( "
    text
    " ).dialog(); - equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], "4. the close button" ); - el.remove(); + function step3() { + checkFocus( "
    text
    ", options, function() { + equal( document.activeElement, + el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], + "3. tabbable element inside the buttonpane" ); + }, step4 ); + } + + function step4() { + checkFocus( "
    text
    ", {}, function() { + equal( document.activeElement, + el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], + "4. the close button" ); + }, step5 ); + } + function step5() { el = $( "
    text
    " ).dialog({ autoOpen: false }); el.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide(); el.dialog( "open" ); - equal( document.activeElement, el.parent()[ 0 ], "5. the dialog itself" ); - el.remove(); + setTimeout(function() { + equal( document.activeElement, el.parent()[ 0 ], "5. the dialog itself" ); + el.remove(); + start(); + }); + } - start(); - }, 13); + step1(); }); test( "#7960: resizable handles below modal overlays", function() { @@ -93,10 +116,10 @@ test( "#7960: resizable handles below modal overlays", function() { dialog.dialog( "destroy" ); }); -asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { +asyncTest( "Prevent tabbing out of dialogs", function() { expect( 3 ); - var el = $( "
    " ).dialog({ modal: true }), + var el = $( "
    " ).dialog(), inputs = el.find( "input" ), widget = el.dialog( "widget" )[ 0 ]; @@ -105,21 +128,23 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { // check shift tab $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); - setTimeout( checkShiftTab, 2 ); + setTimeout( checkShiftTab ); } function checkShiftTab() { ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); el.remove(); - start(); + setTimeout( start ); } - inputs.eq( 1 ).focus(); - equal( document.activeElement, inputs[1], "Focus set on second input" ); - inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); + inputs[1].focus(); + setTimeout(function() { + equal( document.activeElement, inputs[1], "Focus set on second input" ); + inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); - setTimeout( checkTab, 2 ); + setTimeout( checkTab ); + }); }); })(jQuery); -- cgit v1.2.3 From 020abcf8a9494731b3bc58c14e5aac5d8407452a Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 10 Dec 2012 15:54:06 -0500 Subject: Spinner tests: Delay all the things to make IE happy. Maybe... --- tests/unit/spinner/spinner_events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/spinner/spinner_events.js b/tests/unit/spinner/spinner_events.js index 7da16c371..1ee0d17a5 100644 --- a/tests/unit/spinner/spinner_events.js +++ b/tests/unit/spinner/spinner_events.js @@ -253,7 +253,7 @@ asyncTest( "change", function() { start(); } - step1(); + setTimeout( step1 ); }); })( jQuery ); -- cgit v1.2.3 From 694987f2f735476e0ebbea1fe80ec8c504af6846 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 11 Dec 2012 09:44:39 -0500 Subject: Menu tests: Better handling of async focus in IE. --- tests/unit/menu/menu_events.js | 199 ++++++++++++++++++++++------------------- 1 file changed, 108 insertions(+), 91 deletions(-) diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js index a94968138..3c94a5a6c 100644 --- a/tests/unit/menu/menu_events.js +++ b/tests/unit/menu/menu_events.js @@ -87,7 +87,7 @@ asyncTest( "handle blur via click outside", function() { }); }); -test( "handle focus of menu with active item", function() { +asyncTest( "handle focus of menu with active item", function() { expect( 1 ); var element = $( "#menu1" ).menu({ focus: function( event ) { @@ -96,11 +96,19 @@ test( "handle focus of menu with active item", function() { }); log( "focus", true ); - element.focus(); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - element.focus(); - equal( logOutput(), "focus,0,1,2,2", "current active item remains active" ); + element[0].focus(); + setTimeout(function() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element[0].blur(); + setTimeout(function() { + element[0].focus(); + setTimeout(function() { + equal( logOutput(), "focus,0,1,2,2", "current active item remains active" ); + start(); + }); + }); + }); }); asyncTest( "handle submenu auto collapse: mouseleave", function() { @@ -162,7 +170,7 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() { }); -test( "handle keyboard navigation on menu without scroll and without submenus", function() { +asyncTest( "handle keyboard navigation on menu without scroll and without submenus", function() { expect( 12 ); var element = $( "#menu1" ).menu({ select: function( event, ui ) { @@ -174,54 +182,58 @@ test( "handle keyboard navigation on menu without scroll and without submenus", }); log( "keydown", true ); - element.focus(); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" ); + element[0].focus(); + setTimeout(function() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - equal( logOutput(), "keydown,1", "Keydown UP" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal( logOutput(), "keydown,1", "Keydown UP" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); - equal( logOutput(), "keydown", "Keydown LEFT (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equal( logOutput(), "keydown", "Keydown LEFT (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); - equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - equal( logOutput(), "keydown,4", "Keydown PAGE_DOWN" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equal( logOutput(), "keydown,4", "Keydown PAGE_DOWN" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - equal( logOutput(), "keydown,0", "Keydown PAGE_UP" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equal( logOutput(), "keydown,0", "Keydown PAGE_UP" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); - equal( logOutput(), "keydown,4", "Keydown END" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); + equal( logOutput(), "keydown,4", "Keydown END" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); - equal( logOutput(), "keydown,0", "Keydown HOME" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); + equal( logOutput(), "keydown,0", "Keydown HOME" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); - equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" ); + + start(); + }); }); asyncTest( "handle keyboard navigation on menu without scroll and with submenus", function() { @@ -344,7 +356,7 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus" } }); -test( "handle keyboard navigation on menu with scroll and without submenus", function() { +asyncTest( "handle keyboard navigation on menu with scroll and without submenus", function() { expect( 14 ); var element = $( "#menu3" ).menu({ select: function( event, ui ) { @@ -356,63 +368,67 @@ test( "handle keyboard navigation on menu with scroll and without submenus", fun }); log( "keydown", true ); - element.focus(); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" ); + element[0].focus(); + setTimeout(function() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - equal( logOutput(), "keydown,1,0", "Keydown UP" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal( logOutput(), "keydown,1,0", "Keydown UP" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); - equal( logOutput(), "keydown", "Keydown LEFT (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equal( logOutput(), "keydown", "Keydown LEFT (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); - equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - equal( logOutput(), "keydown,10", "Keydown PAGE_UP" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equal( logOutput(), "keydown,10", "Keydown PAGE_UP" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - equal( logOutput(), "keydown,0", "Keydown PAGE_UP" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equal( logOutput(), "keydown,0", "Keydown PAGE_UP" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); - equal( logOutput(), "keydown,37", "Keydown END" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); + equal( logOutput(), "keydown,37", "Keydown END" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); - equal( logOutput(), "keydown,0", "Keydown HOME" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); + equal( logOutput(), "keydown,0", "Keydown HOME" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); - equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" ); - log( "keydown", true ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" ); + log( "keydown", true ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" ); + + start(); + }); }); asyncTest( "handle keyboard navigation on menu with scroll and with submenus", function() { @@ -561,7 +577,7 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite } }); -test( "handle keyboard navigation with spelling of menu items", function() { +asyncTest( "handle keyboard navigation with spelling of menu items", function() { expect( 2 ); var element = $( "#menu2" ).menu({ focus: function( event ) { @@ -577,8 +593,9 @@ test( "handle keyboard navigation with spelling of menu items", function() { equal( logOutput(), "keydown,0,1,3", "Keydown focus Addyston by spelling the first 3 letters" ); element.simulate( "keydown", { keyCode: 68 } ); equal( logOutput(), "keydown,0,1,3,4", "Keydown focus Delphi by repeating the 'd' again" ); + start(); }); - element.focus(); + element[0].focus(); }); })( jQuery ); -- cgit v1.2.3 From 28fcef5e9e57b645af56615fdb1ab7abbe9869ec Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 11 Dec 2012 10:06:13 -0500 Subject: Datepicker tests: Handle async focus in IE. --- tests/unit/datepicker/datepicker_core.js | 251 ++++++++++++++++------------ tests/unit/datepicker/datepicker_options.js | 168 ++++++++++++------- 2 files changed, 245 insertions(+), 174 deletions(-) diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index 67dd29eac..1388f9222 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -30,126 +30,159 @@ test("widget method", function() { deepEqual($("body > #ui-datepicker-div:last-child")[0], actual); }); -test('baseStructure', function() { +asyncTest('baseStructure', function() { expect( 58 ); var header, title, table, thead, week, panel, inl, child, - inp = TestHelpers.datepicker.init('#inp').focus(), + inp = TestHelpers.datepicker.init('#inp'), dp = $('#ui-datepicker-div'); - ok(dp.is(':visible'), 'Structure - datepicker visible'); - ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left'); - ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month'); - equal(dp.children().length, 2, 'Structure - child count'); - header = dp.children(':first'); - ok(header.is('div.ui-datepicker-header'), 'Structure - header division'); - equal(header.children().length, 3, 'Structure - header child count'); - ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() !== '', 'Structure - prev link'); - ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() !== '', 'Structure - next link'); - - title = header.children(':last'); - ok(title.is('div.ui-datepicker-title') && title.html() !== '','Structure - title division'); - equal(title.children().length, 2, 'Structure - title child count'); - ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() !== '', 'Structure - month text'); - ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() !== '', 'Structure - year text'); - - table = dp.children(':eq(1)'); - ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table'); - ok(table.children(':first').is('thead'), 'Structure - month table thead'); - thead = table.children(':first').children(':first'); - ok(thead.is('tr'), 'Structure - month table title row'); - equal(thead.find('th').length, 7, 'Structure - month table title cells'); - ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body'); - ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count'); - week = table.children(':eq(1)').children(':first'); - ok(week.is('tr'), 'Structure - month table week row'); - equal(week.children().length, 7, 'Structure - week child count'); - ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell'); - ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell'); - inp.datepicker('hide').datepicker('destroy'); + function step1() { + inp[0].focus(); + setTimeout(function() { + ok(dp.is(':visible'), 'Structure - datepicker visible'); + ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left'); + ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month'); + equal(dp.children().length, 2, 'Structure - child count'); - // Editable month/year and button panel - inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true}); - inp.focus(); + header = dp.children(':first'); + ok(header.is('div.ui-datepicker-header'), 'Structure - header division'); + equal(header.children().length, 3, 'Structure - header child count'); + ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() !== '', 'Structure - prev link'); + ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() !== '', 'Structure - next link'); - title = dp.find('div.ui-datepicker-title'); - ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector'); - ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector'); + title = header.children(':last'); + ok(title.is('div.ui-datepicker-title') && title.html() !== '','Structure - title division'); + equal(title.children().length, 2, 'Structure - title child count'); + ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() !== '', 'Structure - month text'); + ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() !== '', 'Structure - year text'); - panel = dp.children(':last'); - ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division'); - equal(panel.children().length, 2, 'Structure - button panel child count'); - ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button'); - ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button'); - inp.datepicker('hide').datepicker('destroy'); + table = dp.children(':eq(1)'); + ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table'); + ok(table.children(':first').is('thead'), 'Structure - month table thead'); + thead = table.children(':first').children(':first'); + ok(thead.is('tr'), 'Structure - month table title row'); + equal(thead.find('th').length, 7, 'Structure - month table title cells'); + ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body'); + ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count'); + week = table.children(':eq(1)').children(':first'); + ok(week.is('tr'), 'Structure - month table week row'); + equal(week.children().length, 7, 'Structure - week child count'); + ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell'); + ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell'); + inp.datepicker('hide').datepicker('destroy'); - // Multi-month 2 - inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2}); - inp.focus(); - ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month'); - equal(dp.children().length, 3, 'Structure multi [2] - child count'); - child = dp.children(':first'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division'); - child = dp.children(':eq(1)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division'); - child = dp.children(':eq(2)'); - ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2] - row break'); - ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2'); - inp.datepicker('hide').datepicker('destroy'); + step2(); + }); + } - // Multi-month 3 - inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3}); - inp.focus(); - ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3'); - ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704'); - inp.datepicker('hide').datepicker('destroy'); + function step2() { + // Editable month/year and button panel + inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true}); + inp.focus(); + setTimeout(function() { + title = dp.find('div.ui-datepicker-title'); + ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector'); + ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector'); - // Multi-month [2, 2] - inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: [2, 2]}); - inp.focus(); - ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month'); - equal(dp.children().length, 6, 'Structure multi [2,2] - child count'); - child = dp.children(':first'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division'); - child = dp.children(':eq(1)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - second month division'); - child = dp.children(':eq(2)'); - ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break'); - child = dp.children(':eq(3)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - third month division'); - child = dp.children(':eq(4)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - fourth month division'); - child = dp.children(':eq(5)'); - ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break'); - inp.datepicker('hide').datepicker('destroy'); + panel = dp.children(':last'); + ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division'); + equal(panel.children().length, 2, 'Structure - button panel child count'); + ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button'); + ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button'); + inp.datepicker('hide').datepicker('destroy'); - // Inline - inl = TestHelpers.datepicker.init('#inl'); - dp = inl.children(); - ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div'); - ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left'); - ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month'); - equal(dp.children().length, 2, 'Structure inline - child count'); - header = dp.children(':first'); - ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division'); - equal(header.children().length, 3, 'Structure inline - header child count'); - table = dp.children(':eq(1)'); - ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table'); - ok(table.children(':first').is('thead'), 'Structure inline - month table thead'); - ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body'); - inl.datepicker('destroy'); - - // Inline multi-month - inl = TestHelpers.datepicker.init('#inl', {numberOfMonths: 2}); - dp = inl.children(); - ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div'); - equal(dp.children().length, 3, 'Structure inline multi - child count'); - child = dp.children(':first'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division'); - child = dp.children(':eq(1)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure inline multi - second month division'); - child = dp.children(':eq(2)'); - ok(child.is('div.ui-datepicker-row-break'), 'Structure inline multi - row break'); - inl.datepicker('destroy'); + step3(); + }); + } + + function step3() { + // Multi-month 2 + inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2}); + inp.focus(); + setTimeout(function() { + ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month'); + equal(dp.children().length, 3, 'Structure multi [2] - child count'); + child = dp.children(':first'); + ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division'); + child = dp.children(':eq(1)'); + ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division'); + child = dp.children(':eq(2)'); + ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2] - row break'); + ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2'); + inp.datepicker('hide').datepicker('destroy'); + + step4(); + }); + } + + function step4() { + // Multi-month 3 + inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3}); + inp.focus(); + setTimeout(function() { + ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3'); + ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704'); + inp.datepicker('hide').datepicker('destroy'); + + step5(); + }); + } + + function step5() { + // Multi-month [2, 2] + inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: [2, 2]}); + inp.focus(); + setTimeout(function() { + ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month'); + equal(dp.children().length, 6, 'Structure multi [2,2] - child count'); + child = dp.children(':first'); + ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division'); + child = dp.children(':eq(1)'); + ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - second month division'); + child = dp.children(':eq(2)'); + ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break'); + child = dp.children(':eq(3)'); + ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - third month division'); + child = dp.children(':eq(4)'); + ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - fourth month division'); + child = dp.children(':eq(5)'); + ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break'); + inp.datepicker('hide').datepicker('destroy'); + + // Inline + inl = TestHelpers.datepicker.init('#inl'); + dp = inl.children(); + ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div'); + ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left'); + ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month'); + equal(dp.children().length, 2, 'Structure inline - child count'); + header = dp.children(':first'); + ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division'); + equal(header.children().length, 3, 'Structure inline - header child count'); + table = dp.children(':eq(1)'); + ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table'); + ok(table.children(':first').is('thead'), 'Structure inline - month table thead'); + ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body'); + inl.datepicker('destroy'); + + // Inline multi-month + inl = TestHelpers.datepicker.init('#inl', {numberOfMonths: 2}); + dp = inl.children(); + ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div'); + equal(dp.children().length, 3, 'Structure inline multi - child count'); + child = dp.children(':first'); + ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division'); + child = dp.children(':eq(1)'); + ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure inline multi - second month division'); + child = dp.children(':eq(2)'); + ok(child.is('div.ui-datepicker-row-break'), 'Structure inline multi - row break'); + inl.datepicker('destroy'); + + start(); + }); + } + + step1(); }); test('customStructure', function() { diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 06fde26e6..7b0907d3a 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -87,76 +87,114 @@ test('change', function() { equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn'); }); -test('invocation', function() { +asyncTest('invocation', function() { expect( 29 ); var button, image, inp = TestHelpers.datepicker.init('#inp'), dp = $('#ui-datepicker-div'), body = $('body'); - // On focus - button = inp.siblings('button'); - ok(button.length === 0, 'Focus - button absent'); - image = inp.siblings('img'); - ok(image.length === 0, 'Focus - image absent'); - inp.focus(); - ok(dp.is(':visible'), 'Focus - rendered on focus'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - ok(!dp.is(':visible'), 'Focus - hidden on exit'); - inp.focus(); - ok(dp.is(':visible'), 'Focus - rendered on focus'); - body.simulate('mousedown', {}); - ok(!dp.is(':visible'), 'Focus - hidden on external click'); - inp.datepicker('hide').datepicker('destroy'); - // On button - inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonText: 'Popup'}); - ok(!dp.is(':visible'), 'Button - initially hidden'); - button = inp.siblings('button'); - image = inp.siblings('img'); - ok(button.length === 1, 'Button - button present'); - ok(image.length === 0, 'Button - image absent'); - equal(button.text(), 'Popup', 'Button - button text'); - inp.focus(); - ok(!dp.is(':visible'), 'Button - not rendered on focus'); - button.click(); - ok(dp.is(':visible'), 'Button - rendered on button click'); - button.click(); - ok(!dp.is(':visible'), 'Button - hidden on second button click'); - inp.datepicker('hide').datepicker('destroy'); - // On image button - inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true, - buttonImage: 'img/calendar.gif', buttonText: 'Cal'}); - ok(!dp.is(':visible'), 'Image button - initially hidden'); - button = inp.siblings('button'); - ok(button.length === 0, 'Image button - button absent'); - image = inp.siblings('img'); - ok(image.length === 1, 'Image button - image present'); - equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source'); - equal(image.attr('title'), 'Cal', 'Image button - image text'); - inp.focus(); - ok(!dp.is(':visible'), 'Image button - not rendered on focus'); - image.click(); - ok(dp.is(':visible'), 'Image button - rendered on image click'); - image.click(); - ok(!dp.is(':visible'), 'Image button - hidden on second image click'); - inp.datepicker('hide').datepicker('destroy'); - // On both - inp = TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'}); - ok(!dp.is(':visible'), 'Both - initially hidden'); - button = inp.siblings('button'); - ok(button.length === 1, 'Both - button present'); - image = inp.siblings('img'); - ok(image.length === 0, 'Both - image absent'); - image = button.children('img'); - ok(image.length === 1, 'Both - button image present'); - inp.focus(); - ok(dp.is(':visible'), 'Both - rendered on focus'); - body.simulate('mousedown', {}); - ok(!dp.is(':visible'), 'Both - hidden on external click'); - button.click(); - ok(dp.is(':visible'), 'Both - rendered on button click'); - button.click(); - ok(!dp.is(':visible'), 'Both - hidden on second button click'); - inp.datepicker('hide').datepicker('destroy'); + + function step1() { + // On focus + button = inp.siblings('button'); + ok(button.length === 0, 'Focus - button absent'); + image = inp.siblings('img'); + ok(image.length === 0, 'Focus - image absent'); + inp[0].focus(); + setTimeout(function() { + ok(dp.is(':visible'), 'Focus - rendered on focus'); + inp.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); + ok(!dp.is(':visible'), 'Focus - hidden on exit'); + inp[0].blur(); + setTimeout(function() { + inp[0].focus(); + setTimeout(function() { + ok(dp.is(':visible'), 'Focus - rendered on focus'); + body.simulate('mousedown', {}); + ok(!dp.is(':visible'), 'Focus - hidden on external click'); + inp.datepicker('hide').datepicker('destroy'); + + step2(); + }); + }); + }); + } + + function step2() { + // On button + inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonText: 'Popup'}); + ok(!dp.is(':visible'), 'Button - initially hidden'); + button = inp.siblings('button'); + image = inp.siblings('img'); + ok(button.length === 1, 'Button - button present'); + ok(image.length === 0, 'Button - image absent'); + equal(button.text(), 'Popup', 'Button - button text'); + inp[0].focus(); + setTimeout(function() { + ok(!dp.is(':visible'), 'Button - not rendered on focus'); + button.click(); + ok(dp.is(':visible'), 'Button - rendered on button click'); + button.click(); + ok(!dp.is(':visible'), 'Button - hidden on second button click'); + inp.datepicker('hide').datepicker('destroy'); + + step3(); + }); + } + + function step3() { + // On image button + inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true, + buttonImage: 'img/calendar.gif', buttonText: 'Cal'}); + ok(!dp.is(':visible'), 'Image button - initially hidden'); + button = inp.siblings('button'); + ok(button.length === 0, 'Image button - button absent'); + image = inp.siblings('img'); + ok(image.length === 1, 'Image button - image present'); + equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source'); + equal(image.attr('title'), 'Cal', 'Image button - image text'); + inp[0].focus(); + setTimeout(function() { + ok(!dp.is(':visible'), 'Image button - not rendered on focus'); + image.click(); + ok(dp.is(':visible'), 'Image button - rendered on image click'); + image.click(); + ok(!dp.is(':visible'), 'Image button - hidden on second image click'); + inp.datepicker('hide').datepicker('destroy'); + + step4(); + }); + } + + function step4() { + // On both + inp = TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'}); + ok(!dp.is(':visible'), 'Both - initially hidden'); + button = inp.siblings('button'); + ok(button.length === 1, 'Both - button present'); + image = inp.siblings('img'); + ok(image.length === 0, 'Both - image absent'); + image = button.children('img'); + ok(image.length === 1, 'Both - button image present'); + inp[0].blur(); + setTimeout(function() { + inp[0].focus(); + setTimeout(function() { + ok(dp.is(':visible'), 'Both - rendered on focus'); + body.simulate('mousedown', {}); + ok(!dp.is(':visible'), 'Both - hidden on external click'); + button.click(); + ok(dp.is(':visible'), 'Both - rendered on button click'); + button.click(); + ok(!dp.is(':visible'), 'Both - hidden on second button click'); + inp.datepicker('hide').datepicker('destroy'); + + start(); + }); + }); + } + + step1(); }); test('otherMonths', function() { -- cgit v1.2.3 From b9f206dbcf7f8b9c190e86f0974ad2003911b668 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 11 Dec 2012 16:23:18 -0500 Subject: Dialog: Cleanup. --- tests/unit/dialog/dialog_common.js | 2 +- ui/jquery.ui.dialog.js | 190 ++++++++++++++++++------------------- 2 files changed, 92 insertions(+), 100 deletions(-) diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js index 1a9b4e109..57d7aa0aa 100644 --- a/tests/unit/dialog/dialog_common.js +++ b/tests/unit/dialog/dialog_common.js @@ -2,7 +2,7 @@ TestHelpers.commonWidgetTests( "dialog", { defaults: { appendTo: "body", autoOpen: true, - buttons: {}, + buttons: [], closeOnEscape: true, closeText: 'close', disabled: false, diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 2553109ba..2c7c6b57a 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -19,8 +19,7 @@ */ (function( $, undefined ) { -var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ", - sizeRelatedOptions = { +var sizeRelatedOptions = { buttons: true, height: true, maxHeight: true, @@ -36,12 +35,12 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ui-fr minWidth: true }; -$.widget("ui.dialog", { +$.widget( "ui.dialog", { version: "@VERSION", options: { appendTo: "body", autoOpen: true, - buttons: {}, + buttons: [], closeOnEscape: true, closeText: "close", dialogClass: "", @@ -58,7 +57,7 @@ $.widget("ui.dialog", { at: "center", of: window, collision: "fit", - // ensure that the titlebar is never outside the document + // Ensure the titlebar is always visible using: function( pos ) { var topOffset = $( this ).css( pos ).offset().top; if ( topOffset < 0 ) { @@ -92,12 +91,12 @@ $.widget("ui.dialog", { maxHeight: this.element[0].style.maxHeight, height: this.element[0].style.height }; - this.originalTitle = this.element.attr( "title" ); - this.options.title = this.options.title || this.originalTitle; - this.oldPosition = { + this.originalPosition = { parent: this.element.parent(), index: this.element.parent().children().index( this.element ) }; + this.originalTitle = this.element.attr( "title" ); + this.options.title = this.options.title || this.originalTitle; this._createWrapper(); @@ -136,7 +135,7 @@ $.widget("ui.dialog", { _destroy: function() { var next, - oldPosition = this.oldPosition; + originalPosition = this.originalPosition; this._destroyOverlay(); @@ -144,7 +143,7 @@ $.widget("ui.dialog", { .removeUniqueId() .removeClass( "ui-dialog-content ui-widget-content" ) .css( this.originalCss ) - // without detaching first, the following becomes really slow + // Without detaching first, the following becomes really slow .detach(); this.uiDialog.stop( true, true ).remove(); @@ -153,12 +152,12 @@ $.widget("ui.dialog", { this.element.attr( "title", this.originalTitle ); } - next = oldPosition.parent.children().eq( oldPosition.index ); + next = originalPosition.parent.children().eq( originalPosition.index ); // Don't try to place the dialog next to itself (#8613) if ( next.length && next[ 0 ] !== this.element[ 0 ] ) { next.before( this.element ); } else { - oldPosition.parent.append( this.element ); + originalPosition.parent.append( this.element ); } }, @@ -172,16 +171,11 @@ $.widget("ui.dialog", { close: function( event ) { var that = this; - if ( !this._isOpen ) { - return; - } - - if ( this._trigger( "beforeClose", event ) === false ) { + if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) { return; } this._isOpen = false; - this._destroyOverlay(); if ( !this.opener.filter( ":focusable" ).focus().length ) { @@ -206,7 +200,7 @@ $.widget("ui.dialog", { _moveToTop: function( event, silent ) { var moved = !!this.uiDialog.nextAll( ":visible" ).insertBefore( this.uiDialog ).length; - if ( !silent && moved ) { + if ( moved && !silent ) { this._trigger( "focus", event ); } return moved; @@ -233,29 +227,27 @@ $.widget("ui.dialog", { this._isOpen = true; this._trigger( "open" ); this._trigger( "focus" ); - - return this; }, _focusTabbable: function() { - // set focus to the first match: - // 1. first element inside the dialog matching [autofocus] - // 2. tabbable element inside the content element - // 3. tabbable element inside the buttonpane - // 4. the close button - // 5. the dialog itself + // Set focus to the first match: + // 1. First element inside the dialog matching [autofocus] + // 2. Tabbable element inside the content element + // 3. Tabbable element inside the buttonpane + // 4. The close button + // 5. The dialog itself var hasFocus = this.element.find( "[autofocus]" ); if ( !hasFocus.length ) { hasFocus = this.element.find( ":tabbable" ); - if ( !hasFocus.length ) { - hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); - if ( !hasFocus.length ) { - hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" ); - if ( !hasFocus.length ) { - hasFocus = this.uiDialog; - } - } - } + } + if ( !hasFocus.length ) { + hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); + } + if ( !hasFocus.length ) { + hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" ); + } + if ( !hasFocus.length ) { + hasFocus = this.uiDialog; } hasFocus.eq( 0 ).focus(); }, @@ -279,10 +271,11 @@ $.widget("ui.dialog", { _createWrapper: function() { this.uiDialog = $( "
    " ) - .addClass( uiDialogClasses + this.options.dialogClass ) + .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " + + this.options.dialogClass ) .hide() .attr({ - // setting tabIndex makes the div focusable + // Setting tabIndex makes the div focusable tabIndex: -1, role: "dialog" }) @@ -307,10 +300,10 @@ $.widget("ui.dialog", { if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) && !event.shiftKey ) { first.focus( 1 ); - return false; + event.preventDefault(); } else if ( ( event.target === first[ 0 ] || event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) { last.focus( 1 ); - return false; + event.preventDefault(); } }, mousedown: function( event ) { @@ -334,7 +327,7 @@ $.widget("ui.dialog", { var uiDialogTitle; this.uiDialogTitlebar = $( "
    " ) - .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" ) + .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" ) .prependTo( this.uiDialog ); this._on( this.uiDialogTitlebar, { mousedown: function( event ) { @@ -359,7 +352,7 @@ $.widget("ui.dialog", { .addClass( "ui-dialog-titlebar-close" ) .appendTo( this.uiDialogTitlebar ); this._on( this.uiDialogTitlebarClose, { - "click": function( event ) { + click: function( event ) { event.preventDefault(); this.close( event ); } @@ -384,12 +377,12 @@ $.widget("ui.dialog", { }, _createButtonPane: function() { - var uiDialogButtonPane = ( this.uiDialogButtonPane = $( "
    " ) ) + this.uiDialogButtonPane = $( "
    " ) .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); this.uiButtonSet = $( "
    " ) .addClass( "ui-dialog-buttonset" ) - .appendTo( uiDialogButtonPane ); + .appendTo( this.uiDialogButtonPane ); this._createButtons(); }, @@ -402,34 +395,35 @@ $.widget("ui.dialog", { this.uiDialogButtonPane.remove(); this.uiButtonSet.empty(); - if ( !$.isEmptyObject( buttons ) ) { - $.each( buttons, function( name, props ) { - var click, buttonOptions; - props = $.isFunction( props ) ? - { click: props, text: name } : - props; - // Default to a non-submitting button - props = $.extend( { type: "button" }, props ); - // Change the context for the click callback to be the main element - click = props.click; - props.click = function() { - click.apply( that.element[0], arguments ); - }; - buttonOptions = { - icons: props.icons, - text: props.showText - }; - delete props.icons; - delete props.showText; - $( "", props ) - .button( buttonOptions ) - .appendTo( that.uiButtonSet ); - }); - this.uiDialog.addClass( "ui-dialog-buttons" ); - this.uiDialogButtonPane.appendTo( this.uiDialog ); - } else { + if ( $.isEmptyObject( buttons ) ) { this.uiDialog.removeClass( "ui-dialog-buttons" ); + return; } + + $.each( buttons, function( name, props ) { + var click, buttonOptions; + props = $.isFunction( props ) ? + { click: props, text: name } : + props; + // Default to a non-submitting button + props = $.extend( { type: "button" }, props ); + // Change the context for the click callback to be the main element + click = props.click; + props.click = function() { + click.apply( that.element[0], arguments ); + }; + buttonOptions = { + icons: props.icons, + text: props.showText + }; + delete props.icons; + delete props.showText; + $( "", props ) + .button( buttonOptions ) + .appendTo( that.uiButtonSet ); + }); + this.uiDialog.addClass( "ui-dialog-buttons" ); + this.uiDialogButtonPane.appendTo( this.uiDialog ); }, _makeDraggable: function() { @@ -448,8 +442,7 @@ $.widget("ui.dialog", { handle: ".ui-dialog-titlebar", containment: "document", start: function( event, ui ) { - $( this ) - .addClass( "ui-dialog-dragging" ); + $( this ).addClass( "ui-dialog-dragging" ); that._trigger( "dragStart", event, filteredUi( ui ) ); }, drag: function( event, ui ) { @@ -460,8 +453,7 @@ $.widget("ui.dialog", { ui.position.left - that.document.scrollLeft(), ui.position.top - that.document.scrollTop() ]; - $( this ) - .removeClass( "ui-dialog-dragging" ); + $( this ).removeClass( "ui-dialog-dragging" ); that._trigger( "dragStop", event, filteredUi( ui ) ); } }); @@ -510,23 +502,19 @@ $.widget("ui.dialog", { that._trigger( "resizeStop", event, filteredUi( ui ) ); } }) - .css( "position", position ) - .find( ".ui-resizable-se" ) - .addClass( "ui-icon ui-icon-grip-diagonal-se" ); + .css( "position", position ); }, _minHeight: function() { var options = this.options; - if ( options.height === "auto" ) { - return options.minHeight; - } else { - return Math.min( options.minHeight, options.height ); - } + return options.height === "auto" ? + options.minHeight : + Math.min( options.minHeight, options.height ); }, _position: function() { - // need to show the dialog to get the actual offset in the position plugin + // Need to show the dialog to get the actual offset in the position plugin var isVisible = this.uiDialog.is( ":visible" ); if ( !isVisible ) { this.uiDialog.show(); @@ -539,8 +527,8 @@ $.widget("ui.dialog", { _setOptions: function( options ) { var that = this, - resizableOptions = {}, - resize = false; + resize = false, + resizableOptions = {}; $.each( options, function( key, value ) { that._setOption( key, value ); @@ -589,7 +577,7 @@ $.widget("ui.dialog", { if ( key === "closeText" ) { this.uiDialogTitlebarClose.button({ - // ensure that we always pass a string + // Ensure that we always pass a string label: "" + value }); } @@ -638,7 +626,7 @@ $.widget("ui.dialog", { var nonContentHeight, minContentHeight, maxContentHeight, options = this.options; - // reset content sizing + // Reset content sizing this.element.show().css({ width: "auto", minHeight: 0, @@ -681,18 +669,20 @@ $.widget("ui.dialog", { if ( !this.options.modal ) { return; } - if ( $.ui.dialog.overlayInstances === 0 ) { - // prevent use of anchors and inputs - // we use a setTimeout in case the overlay is created from an - // event that we're going to be cancelling (see #2804) + + if ( !$.ui.dialog.overlayInstances ) { + // Prevent use of anchors and inputs. + // We use a delay in case the overlay is created from an + // event that we're going to be cancelling. (#2804) this._delay(function() { - // handle $(el).dialog().dialog('close') (see #4065) + // Handle .dialog().dialog("close") (#4065) if ( $.ui.dialog.overlayInstances ) { this._on( this.document, { focusin: function( event ) { if ( !$( event.target ).closest( ".ui-dialog").length ) { event.preventDefault(); - $( ".ui-dialog:visible:last .ui-dialog-content" ).data( "ui-dialog" )._focusTabbable(); + $( ".ui-dialog:visible:last .ui-dialog-content" ) + .data( "ui-dialog" )._focusTabbable(); } } }); @@ -700,20 +690,22 @@ $.widget("ui.dialog", { }); } - var $el = this.overlay = $( "
    " ).addClass( "ui-widget-overlay ui-front" ); - $el.appendTo( this.document[ 0 ].body ); - this._on( $el, { + this.overlay = $( "
    " ) + .addClass( "ui-widget-overlay ui-front" ) + .appendTo( this.document[ 0 ].body ); + this._on( this.overlay, { mousedown: "_keepFocus" }); - $.ui.dialog.overlayInstances += 1; + $.ui.dialog.overlayInstances++; }, _destroyOverlay: function() { if ( !this.options.modal ) { return; } - $.ui.dialog.overlayInstances -= 1; - if ( $.ui.dialog.overlayInstances === 0 ) { + + $.ui.dialog.overlayInstances--; + if ( !$.ui.dialog.overlayInstances ) { this._off( this.document, "focusin" ); } this.overlay.remove(); -- cgit v1.2.3 From fec36fd2140a1e88b0a6584f4e9d42a0495d395a Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Wed, 12 Dec 2012 03:16:33 -0500 Subject: Dev: remove todos from datepicker and dialog testsuite --- tests/unit/datepicker/datepicker_options.js | 5 ++--- tests/unit/dialog/dialog_methods.js | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 7b0907d3a..c5e53b85e 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -594,10 +594,9 @@ test('altField', function() { }); test('autoSize', function() { - expect( 14 ); + expect( 15 ); var inp = TestHelpers.datepicker.init('#inp'); - // todo: figure out why this test fails in Opera 11.6 - //equal(inp.prop('size'), 20, 'Auto size - default'); + equal(inp.prop('size'), 20, 'Auto size - default'); inp.datepicker('option', 'autoSize', true); equal(inp.prop('size'), 10, 'Auto size - mm/dd/yy'); inp.datepicker('option', 'dateFormat', 'm/d/yy'); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index fbb649fbf..85d13d157 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -59,6 +59,16 @@ test("destroy", function() { }); }); +test("#4980: Destroy should place element back in original DOM position", function(){ + expect( 2 ); + var container = $('
    '), + modal = container.find('#modal'); + modal.dialog(); + ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); + modal.dialog('destroy'); + ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); +}); + test( "enable/disable disabled", function() { expect( 2 ); var el = $( "
    " ).dialog(); @@ -137,17 +147,6 @@ test("open", function() { ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called'); }); -// TODO merge this with the main destroy test -test("#4980: Destroy should place element back in original DOM position", function(){ - expect( 2 ); - var container = $('
    '), - modal = container.find('#modal'); - modal.dialog(); - ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); - modal.dialog('destroy'); - ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); -}); - test("#6137: dialog('open') causes form elements to reset on IE7", function() { expect(2); -- cgit v1.2.3 From a677ea7dc01b71028af94c3b5b9fa82d401cd98c Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Wed, 12 Dec 2012 03:59:11 -0500 Subject: Dev: update jquery.simulate.js to latest version from http://github.com/jquery/jquery-simulate --- tests/jquery.simulate.js | 89 ++++++++++++++++++++------ tests/unit/resizable/resizable_events.js | 46 +++++++------ tests/unit/resizable/resizable_test_helpers.js | 1 + 3 files changed, 97 insertions(+), 39 deletions(-) diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js index 08cbaafda..0ae88c20f 100644 --- a/tests/jquery.simulate.js +++ b/tests/jquery.simulate.js @@ -1,13 +1,15 @@ -/* - * jquery.simulate - simulate browser mouse and keyboard events - * http://jqueryui.com + /*! + * jQuery Simulate v0.0.1 - simulate browser mouse and keyboard events + * https://github.com/jquery/jquery-simulate * * Copyright 2012 jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license + * + * Date: Sun Dec 9 12:15:33 2012 -0500 */ -;(function( $ ) { +;(function( $, undefined ) { var rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|contextmenu)|click/; @@ -31,7 +33,42 @@ $.simulate = function( elem, type, options ) { } }; +$.extend( $.simulate, { + + keyCode: { + BACKSPACE: 8, + COMMA: 188, + DELETE: 46, + DOWN: 40, + END: 35, + ENTER: 13, + ESCAPE: 27, + HOME: 36, + LEFT: 37, + NUMPAD_ADD: 107, + NUMPAD_DECIMAL: 110, + NUMPAD_DIVIDE: 111, + NUMPAD_ENTER: 108, + NUMPAD_MULTIPLY: 106, + NUMPAD_SUBTRACT: 109, + PAGE_DOWN: 34, + PAGE_UP: 33, + PERIOD: 190, + RIGHT: 39, + SPACE: 32, + TAB: 9, + UP: 38 + }, + + buttonCode: { + LEFT: 0, + MIDDLE: 1, + RIGHT: 2 + } +}); + $.extend( $.simulate.prototype, { + simulateEvent: function( elem, type, options ) { var event = this.createEvent( type, options ); this.dispatchEvent( elem, type, event, options ); @@ -56,7 +93,6 @@ $.extend( $.simulate.prototype, { detail: 0, screenX: 0, screenY: 0, - // TODO: default clientX/Y to a position within the target element clientX: 1, clientY: 1, ctrlKey: false, @@ -101,8 +137,14 @@ $.extend( $.simulate.prototype, { } else if ( document.createEventObject ) { event = document.createEventObject(); $.extend( event, options ); - // TODO: what is this mapping for? - event.button = { 0:1, 1:4, 2:2 }[ event.button ] || event.button; + // standards event.button uses constants defined here: http://msdn.microsoft.com/en-us/library/ie/ff974877(v=vs.85).aspx + // old IE event.button uses constants defined here: http://msdn.microsoft.com/en-us/library/ie/ms533544(v=vs.85).aspx + // so we actually need to map the standard back to oldIE + event.button = { + 0: 1, + 1: 4, + 2: 2 + }[ event.button ] || event.button; } return event; @@ -128,7 +170,10 @@ $.extend( $.simulate.prototype, { event.initKeyEvent( type, options.bubbles, options.cancelable, options.view, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.keyCode, options.charCode ); - // TODO: what is this supporting? + // initKeyEvent throws an exception in WebKit + // see: http://stackoverflow.com/questions/6406784/initkeyevent-keypress-only-works-in-firefox-need-a-cross-browser-solution + // and also https://bugs.webkit.org/show_bug.cgi?id=13368 + // fall back to a generic event until we decide to implement initKeyboardEvent } catch( err ) { event = document.createEvent( "Events" ); event.initEvent( type, options.bubbles, options.cancelable ); @@ -147,9 +192,7 @@ $.extend( $.simulate.prototype, { $.extend( event, options ); } - // TODO: can we hook into core's logic? - if ( $.ui.ie || (({}).toString.call( window.opera ) === "[object Opera]") ) { - // TODO: is charCode ever <0 ? Can we just use charCode || keyCode? + if ( !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ) || (({}).toString.call( window.opera ) === "[object Opera]") ) { event.keyCode = (options.charCode > 0) ? options.charCode : options.keyCode; event.charCode = undefined; } @@ -157,7 +200,6 @@ $.extend( $.simulate.prototype, { return event; }, - // TODO: does this need type? Can't we just check event.type? dispatchEvent: function( elem, type, event ) { if ( elem.dispatchEvent ) { elem.dispatchEvent( event ); @@ -237,20 +279,31 @@ function findCenter( elem ) { $.extend( $.simulate.prototype, { simulateDrag: function() { - var target = this.target, + var i = 0, + target = this.target, options = this.options, center = findCenter( target ), x = Math.floor( center.x ), y = Math.floor( center.y ), dx = options.dx || 0, dy = options.dy || 0, + moves = options.moves || 3, coord = { clientX: x, clientY: y }; + this.simulateEvent( target, "mousedown", coord ); - coord = { clientX: x + 1, clientY: y + 1 }; - this.simulateEvent( document, "mousemove", coord ); - coord = { clientX: x + dx, clientY: y + dy }; - this.simulateEvent( document, "mousemove", coord ); - this.simulateEvent( document, "mousemove", coord ); + + for ( ; i < moves ; i++ ) { + x += dx / moves; + y += dy / moves; + + coord = { + clientX: Math.round( x ), + clientY: Math.round( y ) + }; + + this.simulateEvent( document, "mousemove", coord ); + } + this.simulateEvent( target, "mouseup", coord ); this.simulateEvent( target, "click", coord ); } diff --git a/tests/unit/resizable/resizable_events.js b/tests/unit/resizable/resizable_events.js index 14de76da6..ac222ec10 100644 --- a/tests/unit/resizable/resizable_events.js +++ b/tests/unit/resizable/resizable_events.js @@ -29,19 +29,19 @@ test("start", function() { }); -test("resize", function() { +test( "resize", function() { - expect(9); + expect( 9 ); var count = 0, handle = ".ui-resizable-se"; $("#resizable1").resizable({ handles: "all", - resize: function(event, ui) { - if (count === 0) { - equal( ui.size.width, 101, "compare width" ); - equal( ui.size.height, 101, "compare height" ); + resize: function( event, ui ) { + if ( count === 0 ) { + equal( ui.size.width, 125, "compare width" ); + equal( ui.size.height, 125, "compare height" ); equal( ui.originalSize.width, 100, "compare original width" ); equal( ui.originalSize.height, 100, "compare original height" ); } else { @@ -54,15 +54,15 @@ test("resize", function() { } }); - TestHelpers.resizable.drag(handle, 50, 50); + TestHelpers.resizable.drag( handle, 50, 50 ); - equal(count, 2, "resize callback should happen exactly once per size adjustment"); + equal( count, 2, "resize callback should happen exactly once per size adjustment" ); }); -test("resize (min/max dimensions)", function() { +test( "resize (min/max dimensions)", function() { - expect(5); + expect( 5 ); var count = 0, handle = ".ui-resizable-se"; @@ -73,7 +73,7 @@ test("resize (min/max dimensions)", function() { minHeight: 60, maxWidth: 100, maxHeight: 100, - resize: function(event, ui) { + resize: function( event, ui ) { equal( ui.size.width, 60, "compare width" ); equal( ui.size.height, 60, "compare height" ); equal( ui.originalSize.width, 100, "compare original width" ); @@ -82,15 +82,15 @@ test("resize (min/max dimensions)", function() { } }); - TestHelpers.resizable.drag(handle, -50, -50); + TestHelpers.resizable.drag( handle, -200, -200 ); - equal(count, 1, "resize callback should happen exactly once per size adjustment"); + equal( count, 1, "resize callback should happen exactly once per size adjustment" ); }); -test("resize (containment)", function() { +test( "resize (containment)", function() { - expect(5); + expect( 5 ); var count = 0, handle = ".ui-resizable-se", @@ -102,18 +102,22 @@ test("resize (containment)", function() { $("#resizable1").resizable({ handles: "all", containment: container, - resize: function(event, ui) { - equal( ui.size.width, 50, "compare width" ); - equal( ui.size.height, 50, "compare height" ); + resize: function( event, ui ) { + equal( ui.size.width, 10, "compare width" ); + equal( ui.size.height, 10, "compare height" ); equal( ui.originalSize.width, 100, "compare original width" ); equal( ui.originalSize.height, 100, "compare original height" ); count++; } }); - TestHelpers.resizable.drag(handle, -50, -50); + // Prove you can't resize outside containment by dragging southeast corner southeast + TestHelpers.resizable.drag( handle, 100, 100 ); - equal(count, 1, "resize callback should happen exactly once per size adjustment"); + // Prove you can't resize outside containment by dragging southeast corner northwest + TestHelpers.resizable.drag( handle, -200, -200 ); + + equal( count, 1, "resize callback should happen exactly once per size adjustment" ); }); @@ -148,7 +152,7 @@ test("stop", function() { var count = 0, handle = ".ui-resizable-se"; - + $("#resizable1").resizable({ handles: "all", stop: function(event, ui) { diff --git a/tests/unit/resizable/resizable_test_helpers.js b/tests/unit/resizable/resizable_test_helpers.js index 88f2bc57b..7ab5aa1a5 100644 --- a/tests/unit/resizable/resizable_test_helpers.js +++ b/tests/unit/resizable/resizable_test_helpers.js @@ -3,6 +3,7 @@ TestHelpers.resizable = { // this mouseover is to work around a limitation in resizable // TODO: fix resizable so handle doesn't require mouseover in order to be used $( el ).simulate("mouseover").simulate( "drag", { + moves: 2, dx: dx, dy: dy }); -- cgit v1.2.3 From 0f111a2ac41d5851f14fa4c4bbf2f884ba268074 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 12 Dec 2012 08:47:05 -0500 Subject: Dialog: Spacing. --- ui/jquery.ui.dialog.js | 128 ++++++++++++++++++++++++------------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 2c7c6b57a..26989959e 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -95,15 +95,15 @@ $.widget( "ui.dialog", { parent: this.element.parent(), index: this.element.parent().children().index( this.element ) }; - this.originalTitle = this.element.attr( "title" ); + this.originalTitle = this.element.attr("title"); this.options.title = this.options.title || this.originalTitle; this._createWrapper(); this.element .show() - .removeAttr( "title" ) - .addClass( "ui-dialog-content ui-widget-content" ) + .removeAttr("title") + .addClass("ui-dialog-content ui-widget-content") .appendTo( this.uiDialog ); this._createTitlebar(); @@ -141,7 +141,7 @@ $.widget( "ui.dialog", { this.element .removeUniqueId() - .removeClass( "ui-dialog-content ui-widget-content" ) + .removeClass("ui-dialog-content ui-widget-content") .css( this.originalCss ) // Without detaching first, the following becomes really slow .detach(); @@ -154,7 +154,7 @@ $.widget( "ui.dialog", { next = originalPosition.parent.children().eq( originalPosition.index ); // Don't try to place the dialog next to itself (#8613) - if ( next.length && next[ 0 ] !== this.element[ 0 ] ) { + if ( next.length && next[0] !== this.element[0] ) { next.before( this.element ); } else { originalPosition.parent.append( this.element ); @@ -178,11 +178,11 @@ $.widget( "ui.dialog", { this._isOpen = false; this._destroyOverlay(); - if ( !this.opener.filter( ":focusable" ).focus().length ) { + if ( !this.opener.filter(":focusable").focus().length ) { // Hiding a focused element doesn't trigger blur in WebKit // so in case we have nothing to focus on, explicitly blur the active element // https://bugs.webkit.org/show_bug.cgi?id=47182 - $( this.document[ 0 ].activeElement ).blur(); + $( this.document[0].activeElement ).blur(); } this._hide( this.uiDialog, this.options.hide, function() { @@ -199,7 +199,7 @@ $.widget( "ui.dialog", { }, _moveToTop: function( event, silent ) { - var moved = !!this.uiDialog.nextAll( ":visible" ).insertBefore( this.uiDialog ).length; + var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length; if ( moved && !silent ) { this._trigger( "focus", event ); } @@ -214,7 +214,7 @@ $.widget( "ui.dialog", { return; } - this.opener = $( this.document[ 0 ].activeElement ); + this.opener = $( this.document[0].activeElement ); this._size(); this._position(); @@ -225,8 +225,8 @@ $.widget( "ui.dialog", { this._focusTabbable(); this._isOpen = true; - this._trigger( "open" ); - this._trigger( "focus" ); + this._trigger("open"); + this._trigger("focus"); }, _focusTabbable: function() { @@ -236,15 +236,15 @@ $.widget( "ui.dialog", { // 3. Tabbable element inside the buttonpane // 4. The close button // 5. The dialog itself - var hasFocus = this.element.find( "[autofocus]" ); + var hasFocus = this.element.find("[autofocus]"); if ( !hasFocus.length ) { - hasFocus = this.element.find( ":tabbable" ); + hasFocus = this.element.find(":tabbable"); } if ( !hasFocus.length ) { - hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); + hasFocus = this.uiDialogButtonPane.find(":tabbable"); } if ( !hasFocus.length ) { - hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" ); + hasFocus = this.uiDialogTitlebarClose.filter(":tabbable"); } if ( !hasFocus.length ) { hasFocus = this.uiDialog; @@ -254,9 +254,9 @@ $.widget( "ui.dialog", { _keepFocus: function( event ) { function checkFocus() { - var activeElement = this.document[ 0 ].activeElement, - isActive = this.uiDialog[ 0 ] === activeElement || - $.contains( this.uiDialog[ 0 ], activeElement ); + var activeElement = this.document[0].activeElement, + isActive = this.uiDialog[0] === activeElement || + $.contains( this.uiDialog[0], activeElement ); if ( !isActive ) { this._focusTabbable(); } @@ -270,7 +270,7 @@ $.widget( "ui.dialog", { }, _createWrapper: function() { - this.uiDialog = $( "
    " ) + this.uiDialog = $("
    ") .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " + this.options.dialogClass ) .hide() @@ -294,14 +294,14 @@ $.widget( "ui.dialog", { if ( event.keyCode !== $.ui.keyCode.TAB ) { return; } - var tabbables = this.uiDialog.find( ":tabbable" ), - first = tabbables.filter( ":first" ), - last = tabbables.filter( ":last" ); + var tabbables = this.uiDialog.find(":tabbable"), + first = tabbables.filter(":first"), + last = tabbables.filter(":last"); - if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) && !event.shiftKey ) { + if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) { first.focus( 1 ); event.preventDefault(); - } else if ( ( event.target === first[ 0 ] || event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) { + } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) { last.focus( 1 ); event.preventDefault(); } @@ -316,9 +316,9 @@ $.widget( "ui.dialog", { // We assume that any existing aria-describedby attribute means // that the dialog content is marked up properly // otherwise we brute force the content as the description - if ( !this.element.find( "[aria-describedby]" ).length ) { + if ( !this.element.find("[aria-describedby]").length ) { this.uiDialog.attr({ - "aria-describedby": this.element.uniqueId().attr( "id" ) + "aria-describedby": this.element.uniqueId().attr("id") }); } }, @@ -326,22 +326,22 @@ $.widget( "ui.dialog", { _createTitlebar: function() { var uiDialogTitle; - this.uiDialogTitlebar = $( "
    " ) - .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" ) + this.uiDialogTitlebar = $("
    ") + .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix") .prependTo( this.uiDialog ); this._on( this.uiDialogTitlebar, { mousedown: function( event ) { // Don't prevent click on close button (#8838) // Focusing a dialog that is partially scrolled out of view // causes the browser to scroll it into view, preventing the click event - if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) { + if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) { // Dialog isn't getting focus when dragging (#8063) this.uiDialog.focus(); } } }); - this.uiDialogTitlebarClose = $( "" ) + this.uiDialogTitlebarClose = $("") .button({ label: this.options.closeText, icons: { @@ -349,7 +349,7 @@ $.widget( "ui.dialog", { }, text: false }) - .addClass( "ui-dialog-titlebar-close" ) + .addClass("ui-dialog-titlebar-close") .appendTo( this.uiDialogTitlebar ); this._on( this.uiDialogTitlebarClose, { click: function( event ) { @@ -358,30 +358,30 @@ $.widget( "ui.dialog", { } }); - uiDialogTitle = $( "" ) + uiDialogTitle = $("") .uniqueId() - .addClass( "ui-dialog-title" ) + .addClass("ui-dialog-title") .prependTo( this.uiDialogTitlebar ); this._title( uiDialogTitle ); this.uiDialog.attr({ - "aria-labelledby": uiDialogTitle.attr( "id" ) + "aria-labelledby": uiDialogTitle.attr("id") }); }, _title: function( title ) { if ( !this.options.title ) { - title.html( " " ); + title.html(" "); } title.text( this.options.title ); }, _createButtonPane: function() { - this.uiDialogButtonPane = $( "
    " ) - .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); + this.uiDialogButtonPane = $("
    ") + .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"); - this.uiButtonSet = $( "
    " ) - .addClass( "ui-dialog-buttonset" ) + this.uiButtonSet = $("
    ") + .addClass("ui-dialog-buttonset") .appendTo( this.uiDialogButtonPane ); this._createButtons(); @@ -396,7 +396,7 @@ $.widget( "ui.dialog", { this.uiButtonSet.empty(); if ( $.isEmptyObject( buttons ) ) { - this.uiDialog.removeClass( "ui-dialog-buttons" ); + this.uiDialog.removeClass("ui-dialog-buttons"); return; } @@ -422,7 +422,7 @@ $.widget( "ui.dialog", { .button( buttonOptions ) .appendTo( that.uiButtonSet ); }); - this.uiDialog.addClass( "ui-dialog-buttons" ); + this.uiDialog.addClass("ui-dialog-buttons"); this.uiDialogButtonPane.appendTo( this.uiDialog ); }, @@ -442,7 +442,7 @@ $.widget( "ui.dialog", { handle: ".ui-dialog-titlebar", containment: "document", start: function( event, ui ) { - $( this ).addClass( "ui-dialog-dragging" ); + $( this ).addClass("ui-dialog-dragging"); that._trigger( "dragStart", event, filteredUi( ui ) ); }, drag: function( event, ui ) { @@ -453,7 +453,7 @@ $.widget( "ui.dialog", { ui.position.left - that.document.scrollLeft(), ui.position.top - that.document.scrollTop() ]; - $( this ).removeClass( "ui-dialog-dragging" ); + $( this ).removeClass("ui-dialog-dragging"); that._trigger( "dragStop", event, filteredUi( ui ) ); } }); @@ -465,7 +465,7 @@ $.widget( "ui.dialog", { handles = options.resizable, // .ui-resizable has position: relative defined in the stylesheet // but dialogs have to use absolute or fixed positioning - position = this.uiDialog.css( "position" ), + position = this.uiDialog.css("position"), resizeHandles = typeof handles === 'string' ? handles : "n,e,s,w,se,sw,ne,nw"; @@ -489,16 +489,16 @@ $.widget( "ui.dialog", { minHeight: this._minHeight(), handles: resizeHandles, start: function( event, ui ) { - $( this ).addClass( "ui-dialog-resizing" ); + $( this ).addClass("ui-dialog-resizing"); that._trigger( "resizeStart", event, filteredUi( ui ) ); }, resize: function( event, ui ) { that._trigger( "resize", event, filteredUi( ui ) ); }, stop: function( event, ui ) { - $( this ).removeClass( "ui-dialog-resizing" ); options.height = $( this ).height(); options.width = $( this ).width(); + $( this ).removeClass("ui-dialog-resizing"); that._trigger( "resizeStop", event, filteredUi( ui ) ); } }) @@ -515,7 +515,7 @@ $.widget( "ui.dialog", { _position: function() { // Need to show the dialog to get the actual offset in the position plugin - var isVisible = this.uiDialog.is( ":visible" ); + var isVisible = this.uiDialog.is(":visible"); if ( !isVisible ) { this.uiDialog.show(); } @@ -545,7 +545,7 @@ $.widget( "ui.dialog", { this._size(); this._position(); } - if ( this.uiDialog.is( ":data(ui-resizable)" ) ) { + if ( this.uiDialog.is(":data(ui-resizable)") ) { this.uiDialog.resizable( "option", resizableOptions ); } }, @@ -583,9 +583,9 @@ $.widget( "ui.dialog", { } if ( key === "draggable" ) { - isDraggable = uiDialog.is( ":data(ui-draggable)" ); + isDraggable = uiDialog.is(":data(ui-draggable)"); if ( isDraggable && !value ) { - uiDialog.draggable( "destroy" ); + uiDialog.draggable("destroy"); } if ( !isDraggable && value ) { @@ -599,9 +599,9 @@ $.widget( "ui.dialog", { if ( key === "resizable" ) { // currently resizable, becoming non-resizable - isResizable = uiDialog.is( ":data(ui-resizable)" ); + isResizable = uiDialog.is(":data(ui-resizable)"); if ( isResizable && !value ) { - uiDialog.resizable( "destroy" ); + uiDialog.resizable("destroy"); } // currently resizable, changing handles @@ -616,7 +616,7 @@ $.widget( "ui.dialog", { } if ( key === "title" ) { - this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) ); + this._title( this.uiDialogTitlebar.find(".ui-dialog-title") ); } }, @@ -660,7 +660,7 @@ $.widget( "ui.dialog", { this.element.height( Math.max( 0, options.height - nonContentHeight ) ); } - if (this.uiDialog.is( ":data(ui-resizable)" ) ) { + if (this.uiDialog.is(":data(ui-resizable)") ) { this.uiDialog.resizable( "option", "minHeight", this._minHeight() ); } }, @@ -679,10 +679,10 @@ $.widget( "ui.dialog", { if ( $.ui.dialog.overlayInstances ) { this._on( this.document, { focusin: function( event ) { - if ( !$( event.target ).closest( ".ui-dialog").length ) { + if ( !$( event.target ).closest(".ui-dialog").length ) { event.preventDefault(); - $( ".ui-dialog:visible:last .ui-dialog-content" ) - .data( "ui-dialog" )._focusTabbable(); + $(".ui-dialog:visible:last .ui-dialog-content") + .data("ui-dialog")._focusTabbable(); } } }); @@ -690,9 +690,9 @@ $.widget( "ui.dialog", { }); } - this.overlay = $( "
    " ) - .addClass( "ui-widget-overlay ui-front" ) - .appendTo( this.document[ 0 ].body ); + this.overlay = $("
    ") + .addClass("ui-widget-overlay ui-front") + .appendTo( this.document[0].body ); this._on( this.overlay, { mousedown: "_keepFocus" }); @@ -727,9 +727,9 @@ if ( $.uiBackCompat !== false ) { if ( position ) { if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) { - myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ]; + myAt = position.split ? position.split(" ") : [ position[0], position[1] ]; if ( myAt.length === 1 ) { - myAt[ 1 ] = myAt[ 0 ]; + myAt[1] = myAt[0]; } $.each( [ "left", "top" ], function( i, offsetPosition ) { @@ -742,7 +742,7 @@ if ( $.uiBackCompat !== false ) { position = { my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " + myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]), - at: myAt.join( " " ) + at: myAt.join(" ") }; } @@ -752,7 +752,7 @@ if ( $.uiBackCompat !== false ) { } // need to show the dialog to get the actual offset in the position plugin - isVisible = this.uiDialog.is( ":visible" ); + isVisible = this.uiDialog.is(":visible"); if ( !isVisible ) { this.uiDialog.show(); } -- cgit v1.2.3 From 747d8534520fc3abad81b3c171fa931149398d99 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 12 Dec 2012 08:54:53 -0500 Subject: Core: Removed $.ui.contains. Fixes #8902 - Remove $.ui.contains. --- ui/jquery.ui.core.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 17fad86b4..bd3e30758 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -289,8 +289,6 @@ $.extend( $.ui, { } }, - contains: $.contains, - // only used by resizable hasScroll: function( el, a ) { -- cgit v1.2.3