From 228b1b191b4f668a74e7005fc9c8c9250c090aa9 Mon Sep 17 00:00:00 2001 From: "Richard D. Worth" Date: Tue, 27 Sep 2011 07:57:06 -0400 Subject: Sortable: replaced hard-coded sortable with this.widgetName, and removed lines from destroy that are handled by super. Fixes #7741 - ui.sortable is not working when it is extended --- ui/jquery.ui.sortable.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 99798a915..62d227a3d 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -63,13 +63,11 @@ $.widget("ui.sortable", $.ui.mouse, { destroy: function() { this.element - .removeClass("ui-sortable ui-sortable-disabled") - .removeData("sortable") - .unbind(".sortable"); + .removeClass("ui-sortable ui-sortable-disabled"); this._mouseDestroy(); for ( var i = this.items.length - 1; i >= 0; i-- ) - this.items[i].item.removeData("sortable-item"); + this.items[i].item.removeData(this.widgetName + "-item"); return this; }, @@ -86,6 +84,7 @@ $.widget("ui.sortable", $.ui.mouse, { }, _mouseCapture: function(event, overrideHandle) { + var that = this; if (this.reverting) { return false; @@ -98,12 +97,12 @@ $.widget("ui.sortable", $.ui.mouse, { //Find out if the clicked node (or one of its parents) is a actual item in this.items var currentItem = null, self = this, nodes = $(event.target).parents().each(function() { - if($.data(this, 'sortable-item') == self) { + if($.data(this, that.widgetName + '-item') == self) { currentItem = $(this); return false; } }); - if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target); + if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target); if(!currentItem) return false; if(this.options.handle && !overrideHandle) { @@ -528,7 +527,7 @@ $.widget("ui.sortable", $.ui.mouse, { for (var i = connectWith.length - 1; i >= 0; i--){ var cur = $(connectWith[i]); for (var j = cur.length - 1; j >= 0; j--){ - var inst = $.data(cur[j], 'sortable'); + var inst = $.data(cur[j], this.widgetName); if(inst && inst != this && !inst.options.disabled) { queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]); } @@ -550,7 +549,7 @@ $.widget("ui.sortable", $.ui.mouse, { _removeCurrentsFromItems: function() { - var list = this.currentItem.find(":data(sortable-item)"); + var list = this.currentItem.find(":data(" + this.widgetName + "-item)"); for (var i=0; i < this.items.length; i++) { @@ -576,7 +575,7 @@ $.widget("ui.sortable", $.ui.mouse, { for (var i = connectWith.length - 1; i >= 0; i--){ var cur = $(connectWith[i]); for (var j = cur.length - 1; j >= 0; j--){ - var inst = $.data(cur[j], 'sortable'); + var inst = $.data(cur[j], this.widgetName); if(inst && inst != this && !inst.options.disabled) { queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); this.containers.push(inst); @@ -592,7 +591,7 @@ $.widget("ui.sortable", $.ui.mouse, { for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) { var item = $(_queries[j]); - item.data('sortable-item', targetData); // Data for target checking (mouse manager) + item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager) items.push({ item: item, -- cgit v1.2.3 From c2f036277c6190bc8677bc0eac53c22ed5e8a08d Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 28 Sep 2011 18:30:58 -0400 Subject: Spinner: Added culture option. --- tests/unit/spinner/spinner.html | 1 + tests/unit/spinner/spinner_defaults.js | 1 + tests/unit/spinner/spinner_options.js | 25 +++++++++++++++++++++++++ ui/jquery.ui.spinner.js | 6 ++++-- 4 files changed, 31 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html index ddfb03d91..321c16b4c 100644 --- a/tests/unit/spinner/spinner.html +++ b/tests/unit/spinner/spinner.html @@ -9,6 +9,7 @@ + diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_defaults.js index 3321f8733..0a4e7c236 100644 --- a/tests/unit/spinner/spinner_defaults.js +++ b/tests/unit/spinner/spinner_defaults.js @@ -1,5 +1,6 @@ commonWidgetTests( "spinner", { defaults: { + culture: null, disabled: false, incremental: true, max: null, diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js index 2b557cb69..8be57c785 100644 --- a/tests/unit/spinner/spinner_options.js +++ b/tests/unit/spinner/spinner_options.js @@ -2,6 +2,8 @@ module( "spinner: options" ); +// culture is tested after numberFormat, since it depends on numberFormat + test( "incremental, false", function() { expect( 100 ); @@ -91,6 +93,29 @@ test( "numberFormat, currency", function() { equal( element.val(), "$1.00", "formatted after step" ); }); +test( "culture, null", function() { + expect( 2 ); + Globalize.culture( "ja-JP" ); + var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "C" }); + equal( element.val(), "¥0", "formatted on init" ); + element.spinner( "stepUp" ); + equal( element.val(), "¥1", "formatted after step" ); + + // reset culture + Globalize.culture( "default" ); +}); + +test( "currency, ja-JP", function() { + expect( 2 ); + var element = $( "#spin" ).val( 0 ).spinner({ + numberFormat: "C", + culture: "ja-JP" + }); + equal( element.val(), "¥0", "formatted on init" ); + element.spinner( "stepUp" ); + equal( element.val(), "¥1", "formatted after step" ); +}); + test( "max", function() { expect( 3 ); var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 }); diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 09df97be7..31de2c9da 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -30,6 +30,7 @@ $.widget( "ui.spinner", { defaultElement: "", widgetEventPrefix: "spin", options: { + culture: null, incremental: true, max: null, min: null, @@ -320,7 +321,8 @@ $.widget( "ui.spinner", { _parse: function( val ) { if ( typeof val === "string" && val !== "" ) { - val = window.Globalize && this.options.numberFormat ? Globalize.parseFloat( val ) : +val; + val = window.Globalize && this.options.numberFormat ? + Globalize.parseFloat( val, 10, this.options.culture ) : +val; } return val === "" || isNaN( val ) ? null : val; }, @@ -330,7 +332,7 @@ $.widget( "ui.spinner", { return ""; } return window.Globalize && this.options.numberFormat ? - Globalize.format( value, this.options.numberFormat ) : + Globalize.format( value, this.options.numberFormat, this.options.culture ) : value; }, -- cgit v1.2.3 From ac8a19b62d89a5b70b8ef89029ff81cdf889cf41 Mon Sep 17 00:00:00 2001 From: kborchers Date: Thu, 29 Sep 2011 14:08:42 -0500 Subject: Menubar: Fixed an issue with autoExpand binding that caused the menu to close on fast mouseenter by changing to _bind on the parent menubar item --- ui/jquery.ui.menubar.js | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.menubar.js b/ui/jquery.ui.menubar.js index 9af3aa080..b86ba298d 100644 --- a/ui/jquery.ui.menubar.js +++ b/ui/jquery.ui.menubar.js @@ -123,22 +123,6 @@ $.widget( "ui.menubar", { .attr( "aria-haspopup", "true" ) .wrapInner( "" ); - if ( that.options.autoExpand ) { - input.bind( "mouseleave.menubar", function( event ) { - that.timer = setTimeout( function() { - that._close(); - }, 150 ); - }); - menu.bind( "mouseleave.menubar", function( event ) { - that.timer = setTimeout( function() { - that._close(); - }, 150 ); - }) - .bind( "mouseenter.menubar", function( event ) { - clearTimeout( that.timer ); - }); - } - // TODO review if these options are a good choice, maybe they can be merged if ( that.options.menuIcon ) { input.addClass( "ui-state-default" ).append( "" ); @@ -169,6 +153,15 @@ $.widget( "ui.menubar", { }, 100); } }); + if ( that.options.autoExpand ) { + that._bind( { + "mouseleave .ui-menubar-item": function( event ) { + that.timer = setTimeout( function() { + that._close(); + }, 150 ); + } + }); + } }, _destroy : function() { -- cgit v1.2.3 From dda67fc171d82523fa63bc63c011ebd4351911c9 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Thu, 29 Sep 2011 18:55:58 -0400 Subject: Effect core: Making animate class cross-frame safe, style guidence --- ui/jquery.effects.core.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 15d81b4b0..699b41d81 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -161,7 +161,7 @@ var classAnimationActions = [ "add", "remove", "toggle" ], // prefix used for storing data on .data() dataSpace = "ec.storage."; -$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function(_, prop) { +$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { $.fx.step[ prop ] = function( fx ) { if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { jQuery.style( fx.elem, prop, fx.end ); @@ -171,8 +171,8 @@ $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopS }); function getElementStyles() { - var style = document.defaultView - ? document.defaultView.getComputedStyle(this, null) + var style = this.ownerDocument.defaultView + ? this.ownerDocument.defaultView.getComputedStyle( this, null ) : this.currentStyle, newStyle = {}, key, -- cgit v1.2.3 From e8ba367a58995b191706e5682eacba534cd25697 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Thu, 29 Sep 2011 20:45:23 -0400 Subject: Effects: fixing an animateClass issue when the class was empty --- ui/jquery.effects.core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 699b41d81..3dc0a4e67 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -223,7 +223,7 @@ $.effects.animateClass = function( value, duration, easing, callback ) { return this.queue( function() { var animated = $( this ), - baseClass = animated.attr( "class" ), + baseClass = animated.attr( "class" ) || "", finalClass, allAnimations = o.children ? animated.find( "*" ).andSelf() : animated; -- cgit v1.2.3 From 1e395ecf08c8c9d24b1b676692124f9e2c2602c1 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 30 Sep 2011 17:06:06 -0400 Subject: Accordion: Fixed nested accordions. --- ui/jquery.ui.accordion.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index c976e3e69..580009d33 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -13,8 +13,6 @@ */ (function( $, undefined ) { -var lastToggle = {}; - // TODO: use ui-accordion-header-active class and fix styling $.widget( "ui.accordion", { version: "@VERSION", @@ -39,6 +37,7 @@ $.widget( "ui.accordion", { var self = this, options = self.options; + self.lastToggle = {}; self.element.addClass( "ui-accordion ui-widget ui-helper-reset" ); self.headers = self.element.find( options.header ) @@ -378,10 +377,11 @@ $.widget( "ui.accordion", { } animations[ animation ]({ + widget: self, toShow: toShow, toHide: toHide, - prevShow: lastToggle.toShow, - prevHide: lastToggle.toHide, + prevShow: self.lastToggle.toShow, + prevHide: self.lastToggle.toHide, complete: complete, down: toShow.length && ( !toHide.length || ( toShow.index() < toHide.index() ) ) }, additional ); @@ -450,7 +450,7 @@ $.extend( $.ui.accordion, { duration: 300 }, options, additions ); - lastToggle = options; + options.widget.lastToggle = options; if ( !options.toHide.size() ) { originalWidth = options.toShow[0].style.width; -- cgit v1.2.3 From 663719863f947352c03f0a8b43dceff293c4f554 Mon Sep 17 00:00:00 2001 From: David Leal Date: Sat, 1 Oct 2011 12:06:40 +0100 Subject: Autocomplete: Fix stray reference to element.val(). --- ui/jquery.ui.autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index a4bc82d28..6b06cfe2c 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -328,7 +328,7 @@ $.widget( "ui.autocomplete", { clearTimeout( self.searching ); self.searching = setTimeout(function() { // only search if the value has changed - if ( self.term != self.element.val() ) { + if ( self.term != self._value() ) { self.selectedItem = null; self.search( null, event ); } -- cgit v1.2.3 From 8d09f750a45823f7499672076eed5b19a823e309 Mon Sep 17 00:00:00 2001 From: Marian Rudzynski Date: Sat, 1 Oct 2011 10:56:49 -0400 Subject: Menubar: moved mouseleave _bind call into existing _bind block, added the mouseenter binding back in to help with accidental quick mouseouts causing the menu to close and use same close time for all --- ui/jquery.ui.menubar.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.menubar.js b/ui/jquery.ui.menubar.js index b86ba298d..673493366 100644 --- a/ui/jquery.ui.menubar.js +++ b/ui/jquery.ui.menubar.js @@ -94,7 +94,7 @@ $.widget( "ui.menubar", { } if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" || that.options.autoExpand ) { if( that.options.autoExpand ) { - clearTimeout( that.timer ); + clearTimeout( that.closeTimer ); } that._open( event, menu ); @@ -150,18 +150,19 @@ $.widget( "ui.menubar", { focusout: function( event ) { that.closeTimer = setTimeout( function() { that._close( event ); - }, 100); + }, 150); + }, + "mouseleave .ui-menubar-item": function( event ) { + if ( that.options.autoExpand ) { + that.closeTimer = setTimeout( function() { + that._close( event ); + }, 150); + } + }, + "mouseenter .ui-menubar-item": function( event ) { + clearTimeout( that.closeTimer ); } }); - if ( that.options.autoExpand ) { - that._bind( { - "mouseleave .ui-menubar-item": function( event ) { - that.timer = setTimeout( function() { - that._close(); - }, 150 ); - } - }); - } }, _destroy : function() { -- cgit v1.2.3