diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-03-01 15:19:57 +0100 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-03-01 15:19:57 +0100 |
commit | f65d6b92cc14ee3e829d6e941fcd07a5fb37b278 (patch) | |
tree | 1947006f1b9dbe073daabcfb732b09c52dd0c778 /ui | |
parent | 63215a68757c4fa78079a48488d9a91f0ec8cf50 (diff) | |
parent | 2321ae06cbe44b86d14c82ebd452d06e3922dca9 (diff) | |
download | jquery-ui-f65d6b92cc14ee3e829d6e941fcd07a5fb37b278.tar.gz jquery-ui-f65d6b92cc14ee3e829d6e941fcd07a5fb37b278.zip |
Merge branch 'data-naming'
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.effects.core.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.accordion.js | 6 | ||||
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 17 | ||||
-rw-r--r-- | ui/jquery.ui.slider.js | 34 | ||||
-rw-r--r-- | ui/jquery.ui.tabs.js | 12 | ||||
-rw-r--r-- | ui/jquery.ui.tooltip.js | 14 | ||||
-rw-r--r-- | ui/jquery.ui.widget.js | 23 |
7 files changed, 63 insertions, 47 deletions
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index b28e4c4ee..bc69c9477 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -159,7 +159,7 @@ var classAnimationActions = [ "add", "remove", "toggle" ], padding: 1 }, // prefix used for storing data on .data() - dataSpace = "ec.storage."; + dataSpace = "ui-effects-"; $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { $.fx.step[ prop ] = function( fx ) { @@ -689,7 +689,7 @@ $.extend( baseEasings, { Bounce: function ( p ) { var pow2, bounce = 4; - + while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); } diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 48e964a94..6c4432828 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -405,7 +405,7 @@ $.widget( "ui.accordion", { animate = this.options.animate || {}, options = down && animate.down || animate, complete = function() { - toShow.removeData( "accordionHeight" ); + toShow.removeData( "ui-accordion-height" ); that._completed( data ); }; @@ -430,7 +430,7 @@ $.widget( "ui.accordion", { toHide.animate( hideProps, duration, easing ); toShow .hide() - .data( "accordionHeight", { + .data( "ui-accordion-height", { total: total, toHide: toHide }) @@ -455,7 +455,7 @@ $.widget( "ui.accordion", { $.fx.step.accordionHeight = function( fx ) { var elem = $( fx.elem ), - data = elem.data( "accordionHeight" ); + data = elem.data( "ui-accordion-height" ); elem.height( data.total - elem.outerHeight() - data.toHide.outerHeight() + elem.height() ); }; var hideProps = {}, diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index e261b9147..05a2a28f2 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -225,7 +225,9 @@ $.widget( "ui.autocomplete", { // custom key handling for now input: $(), focus: function( event, ui ) { - var item = ui.item.data( "item.autocomplete" ); + // back compat for _renderItem using item.autocomplete, via #7810 + // TODO remove the fallback, see #8156 + var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ); if ( false !== self._trigger( "focus", event, { item: item } ) ) { // use value to match what will end up in the input, if it was a key event if ( /^key/.test(event.originalEvent.type) ) { @@ -234,7 +236,9 @@ $.widget( "ui.autocomplete", { } }, select: function( event, ui ) { - var item = ui.item.data( "item.autocomplete" ), + // back compat for _renderItem using item.autocomplete, via #7810 + // TODO remove the fallback, see #8156 + var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ); previous = self.previous; // only trigger when focus was lost (click on menu) @@ -470,13 +474,16 @@ $.widget( "ui.autocomplete", { _renderMenu: function( ul, items ) { var self = this; $.each( items, function( index, item ) { - self._renderItem( ul, item ); + self._renderItemData( ul, item ); }); }, - _renderItem: function( ul, item) { + _renderItemData: function( ul, item ) { + return this._renderItem( ul, item ).data( "ui-autocomplete-item", item ); + }, + + _renderItem: function( ul, item ) { return $( "<li></li>" ) - .data( "item.autocomplete", item ) .append( $( "<a></a>" ).text( item.label ) ) .appendTo( ul ); }, diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index aff9093ba..36075507e 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -74,7 +74,7 @@ $.widget( "ui.slider", $.ui.mouse, { .addClass( "ui-slider-range" + // note: this isn't the most fittingly semantic framework class for this element, // but worked best visually with a variety of themes - " ui-widget-header" + + " ui-widget-header" + ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) ); } @@ -110,21 +110,21 @@ $.widget( "ui.slider", $.ui.mouse, { }); this.handles.each(function( i ) { - $( this ).data( "index.ui-slider-handle", i ); + $( this ).data( "ui-slider-handle-index", i ); }); this.handles .keydown(function( event ) { - var index = $( this ).data( "index.ui-slider-handle" ), + var index = $( this ).data( "ui-slider-handle-index" ), allowed, curVal, newVal, step; - + if ( self.options.disabled ) { return; } - + switch ( event.keyCode ) { case $.ui.keyCode.HOME: case $.ui.keyCode.END: @@ -145,14 +145,14 @@ $.widget( "ui.slider", $.ui.mouse, { } break; } - + step = self.options.step; if ( self.options.values && self.options.values.length ) { curVal = newVal = self.values( index ); } else { curVal = newVal = self.value(); } - + switch ( event.keyCode ) { case $.ui.keyCode.HOME: newVal = self._valueMin(); @@ -181,19 +181,19 @@ $.widget( "ui.slider", $.ui.mouse, { newVal = self._trimAlignValue( curVal - step ); break; } - + self._slide( event, index, newVal ); }) .keyup(function( event ) { - var index = $( this ).data( "index.ui-slider-handle" ); - + var index = $( this ).data( "ui-slider-handle-index" ); + if ( self._keySliding ) { self._keySliding = false; self._stop( event, index ); self._change( event, index ); $( this ).removeClass( "ui-state-active" ); } - + }); this._refreshValue(); @@ -275,7 +275,7 @@ $.widget( "ui.slider", $.ui.mouse, { closestHandle .addClass( "ui-state-active" ) .focus(); - + offset = closestHandle.offset(); mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" ); this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { @@ -301,7 +301,7 @@ $.widget( "ui.slider", $.ui.mouse, { _mouseDrag: function( event ) { var position = { x: event.pageX, y: event.pageY }, normValue = this._normValueFromMouse( position ); - + this._slide( event, this._handleIndex, normValue ); return false; @@ -320,7 +320,7 @@ $.widget( "ui.slider", $.ui.mouse, { return false; }, - + _detectOrientation: function() { this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal"; }, @@ -377,7 +377,7 @@ $.widget( "ui.slider", $.ui.mouse, { if ( this.options.values && this.options.values.length ) { otherVal = this.values( index ? 0 : 1 ); - if ( ( this.options.values.length === 2 && this.options.range === true ) && + if ( ( this.options.values.length === 2 && this.options.range === true ) && ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) ) ) { newVal = otherVal; @@ -562,7 +562,7 @@ $.widget( "ui.slider", $.ui.mouse, { return vals; } }, - + // returns the step-aligned value that val is closest to, between (inclusive) min and max _trimAlignValue: function( val ) { if ( val <= this._valueMin() ) { @@ -591,7 +591,7 @@ $.widget( "ui.slider", $.ui.mouse, { _valueMax: function() { return this.options.max; }, - + _refreshValue: function() { var oRange = this.options.range, o = this.options, diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 90f021a69..eca1a5c1b 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -15,7 +15,7 @@ var tabId = 0, rhash = /#.*$/; - + function getNextTabId() { return ++tabId; } @@ -24,7 +24,7 @@ var isLocal = function( anchor ) { // clone the node to work around IE 6 not normalizing the href property // if it's manually set, i.e., a.href = "#foo" kills the normalization anchor = anchor.cloneNode( false ); - return anchor.hash.length > 1 && + return anchor.hash.length > 1 && anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); }; @@ -257,7 +257,7 @@ $.widget( "ui.tabs", { return $( "<div></div>" ) .attr( "id", id ) .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ) - .data( "destroy.tabs", true ); + .data( "ui-tabs-destroy", true ); }, _setupDisabled: function( disabled ) { @@ -457,7 +457,7 @@ $.widget( "ui.tabs", { .removeData( "load.tabs" ); this.lis.unbind( ".tabs" ).add( this.panels ).each(function() { - if ( $.data( this, "destroy.tabs" ) ) { + if ( $.data( this, "ui-tabs-destroy" ) ) { $( this ).remove(); } else { $( this ).removeClass([ @@ -755,7 +755,7 @@ if ( $.uiBackCompat !== false ) { url.replace( "#", "" ) : this._tabId( li.find( "a" )[ 0 ] ); - li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true ); + li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true ); li.find( "a" ).attr( "aria-controls", id ); var doInsertAfter = index >= this.lis.length; @@ -855,7 +855,7 @@ if ( $.uiBackCompat !== false ) { return $( this.options.panelTemplate ) .attr( "id", id ) .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ) - .data( "destroy.tabs", true ); + .data( "ui-tabs-destroy", true ); } }); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 6a41f8c4a..08ad19636 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -72,7 +72,7 @@ $.widget( "ui.tooltip", { var element = $( this ); if ( element.is( "[title]" ) ) { element - .data( "tooltip-title", element.attr( "title" ) ) + .data( "ui-tooltip-title", element.attr( "title" ) ) .attr( "title", "" ); } }); @@ -82,8 +82,8 @@ $.widget( "ui.tooltip", { // restore title attributes this.element.find( this.options.items ).andSelf().each(function() { var element = $( this ); - if ( element.data( "tooltip-title" ) ) { - element.attr( "title", element.data( "tooltip-title" ) ); + if ( element.data( "ui-tooltip-title" ) ) { + element.attr( "title", element.data( "ui-tooltip-title" ) ); } }); }, @@ -99,8 +99,8 @@ $.widget( "ui.tooltip", { return; } - if ( !target.data( "tooltip-title" ) ) { - target.data( "tooltip-title", target.attr( "title" ) ); + if ( !target.data( "ui-tooltip-title" ) ) { + target.data( "ui-tooltip-title", target.attr( "title" ) ); } target.data( "tooltip-open", true ); @@ -180,8 +180,8 @@ $.widget( "ui.tooltip", { } // only set title if we had one before (see comment in _open()) - if ( target.data( "tooltip-title" ) ) { - target.attr( "title", target.data( "tooltip-title" ) ); + if ( target.data( "ui-tooltip-title" ) ) { + target.attr( "title", target.data( "ui-tooltip-title" ) ); } target.removeAttr( "aria-describedby" ); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 2d48ae26d..40abd67de 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -36,7 +36,7 @@ $.widget = function( name, base, prototype ) { // create selector for plugin $.expr[ ":" ][ fullName ] = function( elem ) { - return !!$.data( elem, name ); + return !!$.data( elem, fullName ); }; $[ namespace ] = $[ namespace ] || {}; @@ -105,7 +105,9 @@ $.widget = function( name, base, prototype ) { constructor: constructor, namespace: namespace, widgetName: name, - widgetBaseClass: fullName + // TODO remove widgetBaseClass, see #8155 + widgetBaseClass: fullName, + widgetFullName: fullName }); // If this widget is being redefined then we need to find all widgets that @@ -148,6 +150,7 @@ $.widget.extend = function( target ) { }; $.widget.bridge = function( name, object ) { + var fullName = object.prototype.widgetFullName; $.fn[ name ] = function( options ) { var isMethodCall = typeof options === "string", args = slice.call( arguments, 1 ), @@ -160,7 +163,7 @@ $.widget.bridge = function( name, object ) { if ( isMethodCall ) { this.each(function() { - var instance = $.data( this, name ); + var instance = $.data( this, fullName ); if ( !instance ) { return $.error( "cannot call methods on " + name + " prior to initialization; " + "attempted to call method '" + options + "'" ); @@ -178,7 +181,7 @@ $.widget.bridge = function( name, object ) { }); } else { this.each(function() { - var instance = $.data( this, name ); + var instance = $.data( this, fullName ); if ( instance ) { instance.option( options || {} )._init(); } else { @@ -217,7 +220,10 @@ $.Widget.prototype = { this.focusable = $(); if ( element !== this ) { + // 1.9 BC for #7810 + // TODO remove dual storage $.data( element, this.widgetName, this ); + $.data( element, this.widgetFullName, this ); this._bind({ remove: "destroy" }); this.document = $( element.style ? // element within the document @@ -242,12 +248,15 @@ $.Widget.prototype = { // all event bindings should go through this._bind() this.element .unbind( "." + this.widgetName ) - .removeData( this.widgetName ); + // 1.9 BC for #7810 + // TODO remove dual storage + .removeData( this.widgetName ) + .removeData( this.widgetFullName ); this.widget() .unbind( "." + this.widgetName ) .removeAttr( "aria-disabled" ) .removeClass( - this.widgetBaseClass + "-disabled " + + this.widgetFullName + "-disabled " + "ui-state-disabled" ); // clean up events and states @@ -314,7 +323,7 @@ $.Widget.prototype = { if ( key === "disabled" ) { this.widget() - .toggleClass( this.widgetBaseClass + "-disabled ui-state-disabled", !!value ) + .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value ) .attr( "aria-disabled", value ); this.hoverable.removeClass( "ui-state-hover" ); this.focusable.removeClass( "ui-state-focus" ); |