diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-05-14 08:37:53 -0400 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-06-03 08:37:45 -0400 |
commit | d4719bf6160a0c99273abddc42e39a734e9943a2 (patch) | |
tree | e9dc48912370ecf7f781e1df554c23ed33cf52f8 /ui/spinner.js | |
parent | c2224bf5dc418c84c185844611786b9ccfb869a7 (diff) | |
download | jquery-ui-d4719bf6160a0c99273abddc42e39a734e9943a2.tar.gz jquery-ui-d4719bf6160a0c99273abddc42e39a734e9943a2.zip |
Spinner: Deprecate _uiSpinnerHtml and _buttonHtml extension points
Fixes #11097
Closes gh-1560
Diffstat (limited to 'ui/spinner.js')
-rw-r--r-- | ui/spinner.js | 80 |
1 files changed, 56 insertions, 24 deletions
diff --git a/ui/spinner.js b/ui/spinner.js index 236a66afa..c56d2c918 100644 --- a/ui/spinner.js +++ b/ui/spinner.js @@ -44,7 +44,7 @@ function spinner_modifier( fn ) { }; } -return $.widget( "ui.spinner", { +$.widget( "ui.spinner", { version: "@VERSION", defaultElement: "<input>", widgetEventPrefix: "spin", @@ -214,13 +214,26 @@ return $.widget( "ui.spinner", { "mouseleave .ui-spinner-button": "_stop" }, - _draw: function() { - var uiSpinner = this.uiSpinner = this.element + // Support mobile enhanced option and make backcompat more sane + _enhance: function() { + this.uiSpinner = this.element .attr( "autocomplete", "off" ) - .wrap( this._uiSpinnerHtml() ) + .wrap( "<span>" ) .parent() - // add buttons - .append( this._buttonHtml() ); + + // Add buttons + .append( + "<a>" + + "<span>▲</span>" + + "</a>" + + "<a>" + + "<span>▼</span>" + + "</a>" + ); + }, + + _draw: function() { + this._enhance(); this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" ); this._addClass( "ui-spinner-input" ); @@ -228,7 +241,7 @@ return $.widget( "ui.spinner", { this.element.attr( "role", "spinbutton" ); // button bindings - this.buttons = uiSpinner.children( "a" ) + this.buttons = this.uiSpinner.children( "a" ) .attr( "tabIndex", -1 ) .button(); @@ -244,9 +257,9 @@ return $.widget( "ui.spinner", { // IE 6 doesn't understand height: 50% for the buttons // unless the wrapper has an explicit height - if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) && - uiSpinner.height() > 0 ) { - uiSpinner.height( uiSpinner.height() ); + if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) && + this.uiSpinner.height() > 0 ) { + this.uiSpinner.height( this.uiSpinner.height() ); } // disable spinner if element was already disabled @@ -277,20 +290,6 @@ return $.widget( "ui.spinner", { return false; }, - _uiSpinnerHtml: function() { - return "<span>"; - }, - - _buttonHtml: function() { - return "" + - "<a>" + - "<span>▲</span>" + - "</a>" + - "<a>" + - "<span>▼</span>" + - "</a>"; - }, - _start: function( event ) { if ( !this.spinning && this._trigger( "start", event ) === false ) { return false; @@ -533,4 +532,37 @@ return $.widget( "ui.spinner", { } } ); +// DEPRECATED +// TODO: switch return back to widget declaration at top of file when this is removed +if ( $.uiBackCompat !== false ) { + + // Backcompat for spinner html extension points + $.widget( "ui.spinner", $.ui.spinner, { + _enhance: function() { + this.uiSpinner = this.element + .attr( "autocomplete", "off" ) + .wrap( this._uiSpinnerHtml() ) + .parent() + + // Add buttons + .append( this._buttonHtml() ); + }, + _uiSpinnerHtml: function() { + return "<span>"; + }, + + _buttonHtml: function() { + return "" + + "<a>" + + "<span>▲</span>" + + "</a>" + + "<a>" + + "<span>▼</span>" + + "</a>"; + } + } ); +} + +return $.ui.spinner; + } ) ); |