From c32bebd1bd28d158b017bb1dd7f95fb1d8a8d567 Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Mon, 11 Feb 2013 23:29:48 -0500 Subject: Draggable: Account for z-index set in CSS for the stack option. Fixed #9077 - Draggable: stack option resets the z-index --- ui/jquery.ui.draggable.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 9a31add7c..b8d21bd80 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -917,13 +917,12 @@ $.ui.plugin.add("draggable", "stack", { if (!group.length) { return; } - min = parseInt(group[0].style.zIndex, 10) || 0; + min = parseInt($(group[0]).css("zIndex"), 10) || 0; $(group).each(function(i) { - this.style.zIndex = min + i; + $(this).css("zIndex", min + i); }); - this[0].style.zIndex = min + group.length; - + $(this[0]).css("zIndex", (min + group.length)); } }); -- cgit v1.2.3 From c958b211db2632a02f26e14f57c0862c57870aee Mon Sep 17 00:00:00 2001 From: David Petersen Date: Mon, 11 Feb 2013 20:04:28 -0600 Subject: Position: Handle decimal percentage offsets. Fixes #9076: percentage offset does not support decimal --- tests/unit/position/position_core.js | 26 +++++++++++++++++++++++++- ui/jquery.ui.position.js | 6 +++--- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 7b51223ac..cefd7929c 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -221,7 +221,7 @@ test( "of", function() { }); test( "offsets", function() { - expect( 4 ); + expect( 7 ); $( "#elx" ).position({ my: "left top", @@ -254,6 +254,30 @@ test( "offsets", function() { collision: "none" }); deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "percentage offsets in my" ); + + $( "#elx" ).position({ + my: "left-30.001% top+50.0%", + at: "left bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "decimal percentage offsets in my" ); + + $( "#elx" ).position({ + my: "left+10.4 top-10.6", + at: "left bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 49, left: 50 }, "decimal offsets in my" ); + + $( "#elx" ).position({ + my: "left+right top-left", + at: "left-top bottom-bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 60, left: 40 }, "invalid offsets" ); }); test( "using", function() { diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 0209b442c..81f1e4e8a 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -18,15 +18,15 @@ var cachedScrollbarWidth, round = Math.round, rhorizontal = /left|center|right/, rvertical = /top|center|bottom/, - roffset = /[\+\-]\d+%?/, + roffset = /[\+\-]\d+(\.[\d]+)?%?/, rposition = /^\w+/, rpercent = /%$/, _position = $.fn.position; function getOffsets( offsets, width, height ) { return [ - parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), - parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) + parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), + parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) ]; } -- cgit v1.2.3 From bce9da420646b6cee859475af6616aa9107f0158 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 12 Feb 2013 09:57:29 -0500 Subject: Datepicker i18n: Change Slovak day/month names to lowercase. Fixes #9078 - Datepicker Slovak localisation - name of day/month is always lowercase. --- ui/i18n/jquery.ui.datepicker-sk.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/ui/i18n/jquery.ui.datepicker-sk.js b/ui/i18n/jquery.ui.datepicker-sk.js index 83ae8e811..0cb76c4e8 100644 --- a/ui/i18n/jquery.ui.datepicker-sk.js +++ b/ui/i18n/jquery.ui.datepicker-sk.js @@ -6,11 +6,11 @@ jQuery(function($){ prevText: '<Predchádzajúci', nextText: 'Nasledujúci>', currentText: 'Dnes', - monthNames: ['Január','Február','Marec','Apríl','Máj','Jún', - 'Júl','August','September','Október','November','December'], + monthNames: ['január','február','marec','apríl','máj','jún', + 'júl','august','september','október','november','december'], monthNamesShort: ['Jan','Feb','Mar','Apr','Máj','Jún', 'Júl','Aug','Sep','Okt','Nov','Dec'], - dayNames: ['Nedeľa','Pondelok','Utorok','Streda','Štvrtok','Piatok','Sobota'], + dayNames: ['nedeľa','pondelok','utorok','streda','štvrtok','piatok','sobota'], dayNamesShort: ['Ned','Pon','Uto','Str','Štv','Pia','Sob'], dayNamesMin: ['Ne','Po','Ut','St','Št','Pia','So'], weekHeader: 'Ty', -- cgit v1.2.3 From 3d39d8c32f7b4777c8272fbdd9d24d54ca00dffc Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Tue, 12 Feb 2013 21:27:21 -0500 Subject: Removing unnecessary wrapping of this in draggable's stack option handling. --- ui/jquery.ui.draggable.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index b8d21bd80..8b388d166 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -908,9 +908,8 @@ $.ui.plugin.add("draggable", "snap", { $.ui.plugin.add("draggable", "stack", { start: function() { - var min, - o = $(this).data("ui-draggable").options, + o = this.data("ui-draggable").options, group = $.makeArray($(o.stack)).sort(function(a,b) { return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); }); @@ -921,8 +920,7 @@ $.ui.plugin.add("draggable", "stack", { $(group).each(function(i) { $(this).css("zIndex", min + i); }); - - $(this[0]).css("zIndex", (min + group.length)); + this.css("zIndex", (min + group.length)); } }); -- cgit v1.2.3 From a692bf9b70305de5e9893e717fc71e1e74fb86ac Mon Sep 17 00:00:00 2001 From: Nathanael Silverman Date: Wed, 13 Feb 2013 17:34:52 +0100 Subject: Sortable: Inject a CSS rule to style the cursor. Fixed #7389 - sortable: 'cursor' option didn't override CSS cursor settings. --- ui/jquery.ui.sortable.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 211ff272e..c9b503bd0 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -158,7 +158,7 @@ $.widget("ui.sortable", $.ui.mouse, { _mouseStart: function(event, overrideHandle, noActivation) { - var i, + var i, body, o = this.options; this.currentContainer = this; @@ -228,11 +228,14 @@ $.widget("ui.sortable", $.ui.mouse, { this._setContainment(); } - if(o.cursor) { // cursor option - if ($("body").css("cursor")) { - this._storedCursor = $("body").css("cursor"); - } - $("body").css("cursor", o.cursor); + if( o.cursor && o.cursor !== "auto" ) { // cursor option + body = this.document.find( "body" ); + + // support: IE + this.storedCursor = body.css( "cursor" ); + body.css( "cursor", o.cursor ); + + this.storedStylesheet = $( "" ).appendTo( body ); } if(o.opacity) { // opacity option @@ -1178,8 +1181,9 @@ $.widget("ui.sortable", $.ui.mouse, { } //Do what was originally in plugins - if(this._storedCursor) { - $("body").css("cursor", this._storedCursor); + if ( this.storedCursor ) { + this.document.find( "body" ).css( "cursor", this.storedCursor ); + this.storedStylesheet.remove(); } if(this._storedOpacity) { this.helper.css("opacity", this._storedOpacity); -- cgit v1.2.3 From 5e1b8dc71a72d5753a95c49c844857b91fbdbade Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 18 Feb 2013 16:07:15 -0500 Subject: Dialog: Don't hard-code widget data key. Fixes #9097 - UI dialog inheritance. --- ui/jquery.ui.dialog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 85dbddda2..9d61cf745 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -697,6 +697,7 @@ $.widget( "ui.dialog", { return; } + var widgetFullName = this.widgetFullName; if ( !$.ui.dialog.overlayInstances ) { // Prevent use of anchors and inputs. // We use a delay in case the overlay is created from an @@ -711,7 +712,7 @@ $.widget( "ui.dialog", { !$( event.target ).closest(".ui-datepicker").length ) { event.preventDefault(); $(".ui-dialog:visible:last .ui-dialog-content") - .data("ui-dialog")._focusTabbable(); + .data( widgetFullName )._focusTabbable(); } }); } -- cgit v1.2.3 From 10ca48308fea6a9b30d2457fbf5a1b6e0ed5966c Mon Sep 17 00:00:00 2001 From: Christian Wenz Date: Mon, 18 Feb 2013 18:35:10 -0800 Subject: Datepicker: Updated German locale. Fixes #9098 - Datepicker German localization - make casing of previous/next/today consistent. --- ui/i18n/jquery.ui.datepicker-de.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/ui/i18n/jquery.ui.datepicker-de.js b/ui/i18n/jquery.ui.datepicker-de.js index cfe91759b..abe75c4e4 100644 --- a/ui/i18n/jquery.ui.datepicker-de.js +++ b/ui/i18n/jquery.ui.datepicker-de.js @@ -2,10 +2,10 @@ /* Written by Milian Wolff (mail@milianw.de). */ jQuery(function($){ $.datepicker.regional['de'] = { - closeText: 'schließen', - prevText: '<zurück', + closeText: 'Schließen', + prevText: '<Zurück', nextText: 'Vor>', - currentText: 'heute', + currentText: 'Heute', monthNames: ['Januar','Februar','März','April','Mai','Juni', 'Juli','August','September','Oktober','November','Dezember'], monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun', -- cgit v1.2.3 From 51eb28e76e372fe0af12724edff0b5780b5e5ed0 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 20 Feb 2013 17:35:48 -0500 Subject: Dialog: Extract check for which elements can gain focus into its own method for overriding. Fixes #9087 - Dialog: Allow registering elements outside a dialog for use when a modal dialog is open. --- ui/jquery.ui.dialog.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 9d61cf745..b35c0ffcf 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -692,12 +692,23 @@ $.widget( "ui.dialog", { } }, + _allowInteraction: function( event ) { + if ( $( event.target ).closest(".ui-dialog").length ) { + return true; + } + + // TODO: Remove hack when datepicker implements + // the .ui-front logic (#8989) + return !!$( event.target ).closest(".ui-datepicker").length; + }, + _createOverlay: function() { if ( !this.options.modal ) { return; } - var widgetFullName = this.widgetFullName; + var that = this, + widgetFullName = this.widgetFullName; if ( !$.ui.dialog.overlayInstances ) { // Prevent use of anchors and inputs. // We use a delay in case the overlay is created from an @@ -706,10 +717,7 @@ $.widget( "ui.dialog", { // Handle .dialog().dialog("close") (#4065) if ( $.ui.dialog.overlayInstances ) { this.document.bind( "focusin.dialog", function( event ) { - if ( !$( event.target ).closest(".ui-dialog").length && - // TODO: Remove hack when datepicker implements - // the .ui-front logic (#8989) - !$( event.target ).closest(".ui-datepicker").length ) { + if ( !that._allowInteraction( event ) ) { event.preventDefault(); $(".ui-dialog:visible:last .ui-dialog-content") .data( widgetFullName )._focusTabbable(); -- cgit v1.2.3 From bd47bd4ace3789d9eb302b0dce6f6e042d08a7f1 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 20 Feb 2013 20:16:29 -0500 Subject: Sortable: When sorting table rows, create a td to force dimensions. Fixes #4765 - Sortable: Placeholder not displayed when sorting table rows. --- tests/unit/sortable/sortable.html | 21 ++++++++++++++++++++ tests/unit/sortable/sortable_options.js | 34 +++++++++++++++++++++++++++++++-- ui/jquery.ui.sortable.js | 20 +++++++++++++------ 3 files changed, 67 insertions(+), 8 deletions(-) (limited to 'ui') diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index c23a15854..6e326a865 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -63,6 +63,27 @@
  • Item 5
  • + + + + + + + + + + + + + + + + + + + +
    12
    34
    56
    78
    + diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index cf35aedb1..fe50be002 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -185,11 +185,41 @@ test("{ opacity: 1 }", function() { test("{ placeholder: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); +*/ +test( "{ placeholder: String }", function() { + expect( 1 ); -test("{ placeholder: String }", function() { - ok(false, "missing test - untested code is broken code."); + var element = $( "#sortable" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); + } + }); + + element.find( "li" ).eq( 0 ).simulate( "drag", { + dy: 1 + }); +}); + +test( "{ placholder: String } tr", function() { + expect( 3 ); + + var element = $( "#sortable-table tbody" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); + equal( ui.placeholder.children().length, 1, "placeholder tr contains a td" ); + equal( ui.placeholder.children().html(), $( " " ).html(), + "placeholder td has content for forced dimensions" ); + } + }); + + element.find( "tr" ).eq( 0 ).simulate( "drag", { + dy: 1 + }); }); +/* test("{ revert: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index c9b503bd0..f095ce9c5 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -752,15 +752,23 @@ $.widget("ui.sortable", $.ui.mouse, { o.placeholder = { element: function() { - var el = $(document.createElement(that.currentItem[0].nodeName)) - .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") - .removeClass("ui-sortable-helper")[0]; + var nodeName = that.currentItem[0].nodeName.toLowerCase(), + element = $( that.document[0].createElement( nodeName ) ) + .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") + .removeClass("ui-sortable-helper"); + + if ( nodeName === "tr" ) { + // Use a high colspan to force the td to expand the full + // width of the table (browsers are smart enough to + // handle this properly) + element.append( " " ); + } - if(!className) { - el.style.visibility = "hidden"; + if ( !className ) { + element.css( "visibility", "hidden" ); } - return el; + return element; }, update: function(container, p) { -- cgit v1.2.3 From a924af12b6743408903c642f84a00b0766cd17b7 Mon Sep 17 00:00:00 2001 From: Steve Urmston Date: Tue, 19 Feb 2013 22:58:31 +0000 Subject: Draggable: Revert flag honours Sortable revert speed. Fixed #9103 Draggable: revert option reset after being added to a connectedSortable. --- ui/jquery.ui.draggable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 8b388d166..27b6b4ef0 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -600,7 +600,7 @@ $.ui.plugin.add("draggable", "connectToSortable", { //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid" if(this.shouldRevert) { - this.instance.options.revert = true; + this.instance.options.revert = this.shouldRevert; } //Trigger the stop of the sortable -- cgit v1.2.3 From 2348fb8eb9ec1297a2588a23cf3447c5374bcb21 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 22 Feb 2013 09:15:43 -0500 Subject: Spinner: Call _stop() on blur. Fixes #9112 - Spinner keeps changing after losing focus. --- tests/unit/spinner/spinner_core.js | 27 +++++++++++++++++++++++++++ ui/jquery.ui.spinner.js | 1 + 2 files changed, 28 insertions(+) (limited to 'ui') diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js index a1179bb35..bea5f9122 100644 --- a/tests/unit/spinner/spinner_core.js +++ b/tests/unit/spinner/spinner_core.js @@ -80,6 +80,33 @@ test( "keydown PAGE_DOWN on input, decreases value not less than min", function( equal( element.val(), 20 ); }); +asyncTest( "blur input while spinning with UP", function() { + expect( 3 ); + var value, + element = $( "#spin" ).val( 10 ).spinner(); + + function step1() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal( element.val(), 11 ); + setTimeout( step2, 750 ); + } + + function step2() { + value = element.val(); + ok( value > 11, "repeating while key is down" ); + element[0].blur(); + setTimeout( step3, 250 ); + } + + function step3() { + equal( element.val(), value, "stopped repeating on blur" ); + start(); + } + + element[ 0 ].focus(); + setTimeout( step1 ); +}); + test( "mouse click on up button, increases value not greater than max", function() { expect( 3 ); var element = $( "#spin" ).val( 18 ).spinner({ diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index c14ef9370..644b65239 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -102,6 +102,7 @@ $.widget( "ui.spinner", { return; } + this._stop(); this._refresh(); if ( this.previous !== this.element.val() ) { this._trigger( "change", event ); -- cgit v1.2.3 From d5d3a745b00dd476195cf25b35cc02f3bc31f814 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 25 Feb 2013 15:36:08 -0500 Subject: Autocomplete: Set isNewMenu flag on every suggestion. Fixes #9118 - Autocomplete: Mouse auto-highlights option in Firefox. --- ui/jquery.ui.autocomplete.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 1b0f2138f..b3a05da0b 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -234,7 +234,8 @@ $.widget( "ui.autocomplete", { } }, menufocus: function( event, ui ) { - // #7024 - Prevent accidental activation of menu items in Firefox + // support: Firefox + // Prevent accidental activation of menu items in Firefox (#7024 #9118) if ( this.isNewMenu ) { this.isNewMenu = false; if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) { @@ -490,6 +491,7 @@ $.widget( "ui.autocomplete", { _suggest: function( items ) { var ul = this.menu.element.empty(); this._renderMenu( ul, items ); + this.isNewMenu = true; this.menu.refresh(); // size and position menu -- cgit v1.2.3 From e9c04bfa430eb6b18e7fe1be2f8d162e01181a94 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 26 Feb 2013 08:59:28 -0500 Subject: Position: Fix orientation check for scrollbar widths. Fixes #8763 - Position: getScrollInfo() swapped width and height. --- ui/jquery.ui.position.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 81f1e4e8a..2d3451c06 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -95,8 +95,8 @@ $.position = { hasOverflowY = overflowY === "scroll" || ( overflowY === "auto" && within.height < within.element[0].scrollHeight ); return { - width: hasOverflowX ? $.position.scrollbarWidth() : 0, - height: hasOverflowY ? $.position.scrollbarWidth() : 0 + width: hasOverflowY ? $.position.scrollbarWidth() : 0, + height: hasOverflowX ? $.position.scrollbarWidth() : 0 }; }, getWithinInfo: function( element ) { -- cgit v1.2.3 From 1c80735acb20a468300a53f85ef49b065d40af3e Mon Sep 17 00:00:00 2001 From: Zaven Muradyan Date: Sat, 23 Feb 2013 21:55:29 -0800 Subject: Droppable: Changed drop event to loop over a copied array instead of the droppables directly. Fixed #9116 - Droppable: Drop event can cause droppables to remain active if any droppable is created/destroyed in the event handler. --- tests/unit/droppable/droppable.html | 1 + tests/unit/droppable/droppable_events.js | 33 ++++++++++++++++++++++++++++++++ ui/jquery.ui.droppable.js | 3 ++- 3 files changed, 36 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index 7cd5eb0f5..d084464c2 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -42,6 +42,7 @@
    Draggable
    Droppable
    +
    Droppable
     
    diff --git a/tests/unit/droppable/droppable_events.js b/tests/unit/droppable/droppable_events.js index 8f842e942..707eea1f4 100644 --- a/tests/unit/droppable/droppable_events.js +++ b/tests/unit/droppable/droppable_events.js @@ -5,6 +5,39 @@ module("droppable: events"); +test( "droppable destruction/recreation on drop event", function() { + expect( 1 ); + + var config = { + activeClass: "active", + drop: function() { + var element = $( this ), + newDroppable = $( "
    " ) + .css({ width: 100, height: 100 }) + .text( "Droppable" ); + element.after( newDroppable ); + element.remove(); + newDroppable.droppable( config ); + } + }, + + draggable = $( "#draggable1" ).draggable(), + droppable1 = $( "#droppable1" ).droppable( config ), + droppable2 = $( "#droppable2" ).droppable( config ), + + droppableOffset = droppable1.offset(), + draggableOffset = draggable.offset(), + dx = droppableOffset.left - draggableOffset.left, + dy = droppableOffset.top - draggableOffset.top; + + draggable.simulate( "drag", { + dx: dx, + dy: dy + }); + + ok( !droppable2.hasClass( "active" ), "subsequent droppable no longer active" ); +}); + // this is here to make JSHint pass "unused", and we don't want to // remove the parameter for when we finally implement $.noop(); diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 4fbfcde06..552b24a58 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -278,7 +278,8 @@ $.ui.ddmanager = { drop: function(draggable, event) { var dropped = false; - $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { + // Create a copy of the droppables in case the list changes during the drop (#9116) + $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() { if(!this.options) { return; -- cgit v1.2.3 From 948563b8b55802c6d4c513065f1b78bbdcff104c Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 26 Feb 2013 10:36:03 -0500 Subject: Effects: Delegate to core show/hide when the element is already in the correct final state. This forces the element to go through the olddisplay tracking and forces styles on elements even if they're hidden via an ancestor. Fixes #9120 - Effects: .hide() inconsistent with core with a hidden parent. --- tests/unit/effects/effects.html | 4 +++- tests/unit/effects/effects_core.js | 8 ++++++++ ui/jquery.ui.effect.js | 5 +++-- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index c283eabff..7ddacf7bb 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -96,7 +96,9 @@

      - +

      Child Element Test

      diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js index c9b1e1b4a..928d4c15b 100644 --- a/tests/unit/effects/effects_core.js +++ b/tests/unit/effects/effects_core.js @@ -28,6 +28,14 @@ test( "Immediate Return Conditions", function() { equal( ++count, 3, "Both Functions worked properly" ); }); +test( ".hide() with hidden parent", function() { + expect( 1 ); + var element = $( "div.hidden" ).children(); + element.hide( "blind", function() { + equal( element.css( "display" ), "none", "display: none" ); + }); +}); + asyncTest( "Parse of null for options", function() { var hidden = $( "div.hidden" ), count = 0; diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index 97f006ee0..41aeb4819 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -1150,9 +1150,10 @@ $.fn.extend({ } } - // if the element is hiddden and mode is hide, - // or element is visible and mode is show + // If the element already has the correct final state, delegate to + // the core methods so the internal tracking of "olddisplay" works. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { + elem[ mode ](); done(); } else { effectMethod.call( elem[0], args, done ); -- cgit v1.2.3 From 6f2957743659387f66c9b8953bba9fac5617a440 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 28 Feb 2013 13:34:49 -0500 Subject: Effects: Handle the .hide/show/toggle( options ) signatures from core properly. Fixes #9126 - .show()/.hide() do not support all of core's options. --- tests/unit/effects/effects.html | 2 + tests/unit/effects/effects_core.js | 18 ++++++++ ui/jquery.ui.effect.js | 89 +++++++++++++++++++++++--------------- 3 files changed, 73 insertions(+), 36 deletions(-) (limited to 'ui') diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index 7ddacf7bb..4538ecb03 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -96,6 +96,8 @@

        +
        +
        diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js index 928d4c15b..11e9d0b45 100644 --- a/tests/unit/effects/effects_core.js +++ b/tests/unit/effects/effects_core.js @@ -16,6 +16,24 @@ var minDuration = 15, module( "effects.core" ); +// TODO: test all signatures of .show(), .hide(), .toggle(). +// Look at core's signatures and UI's signatures. +asyncTest( ".hide() with step", function() { + expect( 1 ); + var element = $( "#elem" ), + step = function() { + ok( true, "step callback invoked" ); + step = $.noop; + }; + + element.hide({ + step: function() { + step(); + }, + complete: start + }); +}); + test( "Immediate Return Conditions", function() { var hidden = $( "div.hidden" ), count = 0; diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index 41aeb4819..f3d9929b0 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -1106,14 +1106,29 @@ function _normalizeArguments( effect, options, speed, callback ) { return effect; } -function standardSpeed( speed ) { - // valid standard speeds - if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) { +function standardAnimationOption( option ) { + // Valid standard speeds (nothing, number, named speed) + if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { return true; } - // invalid strings - treat as "normal" speed - return typeof speed === "string" && !$.effects.effect[ speed ]; + // Invalid strings - treat as "normal" speed + if ( typeof option === "string" && !$.effects.effect[ option ] ) { + return true; + } + + // Complete callback + if ( $.isFunction( option ) ) { + return true; + } + + // Options hash (but not naming an effect) + if ( typeof option === "object" && !option.effect ) { + return true; + } + + // Didn't match any standard API + return false; } $.fn.extend({ @@ -1163,39 +1178,41 @@ $.fn.extend({ return queue === false ? this.each( run ) : this.queue( queue || "fx", run ); }, - _show: $.fn.show, - show: function( speed ) { - if ( standardSpeed( speed ) ) { - return this._show.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "show"; - return this.effect.call( this, args ); - } - }, + show: (function( orig ) { + return function( option ) { + if ( standardAnimationOption( option ) ) { + return orig.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "show"; + return this.effect.call( this, args ); + } + }; + })( $.fn.show ), - _hide: $.fn.hide, - hide: function( speed ) { - if ( standardSpeed( speed ) ) { - return this._hide.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "hide"; - return this.effect.call( this, args ); - } - }, + hide: (function( orig ) { + return function( option ) { + if ( standardAnimationOption( option ) ) { + return orig.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "hide"; + return this.effect.call( this, args ); + } + }; + })( $.fn.hide ), - // jQuery core overloads toggle and creates _toggle - __toggle: $.fn.toggle, - toggle: function( speed ) { - if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) { - return this.__toggle.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "toggle"; - return this.effect.call( this, args ); - } - }, + toggle: (function( orig ) { + return function( option ) { + if ( standardAnimationOption( option ) || typeof option === "boolean" ) { + return orig.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "toggle"; + return this.effect.call( this, args ); + } + }; + })( $.fn.toggle ), // helper functions cssUnit: function(key) { -- cgit v1.2.3