Skip to content

Commit

Permalink
Spinner: Deprecate _uiSpinnerHtml and _buttonHtml extension points
Browse files Browse the repository at this point in the history
Fixes #11097
  • Loading branch information
arschmitz committed May 22, 2015
1 parent 40ec737 commit f6d02bd
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 9 deletions.
35 changes: 35 additions & 0 deletions tests/unit/spinner/common-deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
define( [
"lib/common",
"ui/spinner"
], function( common ) {

common.testWidget( "spinner", {
defaults: {
classes: {
"ui-spinner": "ui-corner-all",
"ui-spinner-up": "ui-corner-tr",
"ui-spinner-down": "ui-corner-br"
},
culture: null,
disabled: false,
icons: {
down: "ui-icon-triangle-1-s",
up: "ui-icon-triangle-1-n"
},
incremental: true,
max: null,
min: null,
numberFormat: null,
page: 10,
step: 1,

// callbacks
change: null,
create: null,
spin: null,
start: null,
stop: null
}
});

} );
21 changes: 21 additions & 0 deletions tests/unit/spinner/deprecated.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Spinner Test Suite</title>

<script src="../../../external/requirejs/require.js"></script>
<script src="../../lib/css.js" data-modules="core button spinner"></script>
<script src="../../lib/bootstrap.js" data-widget="spinner" data-deprecated="true"></script>
</head>
<body>

<div id="qunit"></div>
<div id="qunit-fixture">

<input id="spin" class="foo">
<input id="spin2" value="2">

</div>
</body>
</html>
41 changes: 41 additions & 0 deletions tests/unit/spinner/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
define( [
"jquery",
"ui/spinner"
], function( $, testHelper ) {

var originalSpinner = $.ui.spinner.prototype;
module( "spinner: deprecated", {
setup: function() {
$.widget( "ui.spinner", $.ui.spinner, {
_uiSpinnerHtml: function() {
return "<span class='spin-wrap'>";
},

_buttonHtml: function() {
return "" +
"<a class='spin-up'>" +
"<span>&#9650;</span>" +
"</a>" +
"<a>" +
"<span>&#9660;</span>" +
"</a>";
}
} );
},

teardown: function() {
$.ui.spinner.prototype = originalSpinner;
}
} );

test( "markup structure - custom", function( assert ) {
expect( 2 );
var element = $( "#spin" ).spinner(),
spinner = element.spinner( "widget" ),
up = spinner.find( ".ui-spinner-up" );

assert.hasClasses( spinner, "ui-spinner ui-widget ui-widget-content spin-wrap", "_uiSpinnerHtml overides default markup" );
assert.hasClasses( up, "ui-spinner-button ui-spinner-up ui-widget spin-up", "_uiButtonHtml overides default markup" );
} );

} );
16 changes: 7 additions & 9 deletions ui/spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ $.widget( "ui.spinner", {
.wrap( "<span>" )
.parent()

// add buttons
.append( "" +
// Add buttons
.append(
"<a>" +
"<span>&#9650;</span>" +
"</a>" +
"<a>" +
"<span>&#9660;</span>" +
"</a>"; );
"</a>" );
},

_draw: function() {
Expand Down Expand Up @@ -256,9 +256,9 @@ $.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
Expand Down Expand Up @@ -538,15 +538,13 @@ if ( $.uiBackCompat !== false ) {
// Backcompat for dialogClass option
$.widget( "ui.spinner", $.ui.spinner, {
_enhance: function(){
var uiSpinner = this.uiSpinner = this.element
this.uiSpinner = this.element
.attr( "autocomplete", "off" )
.wrap( this._uiSpinnerHtml() )
.parent()

// Add buttons
.append( this._buttonHtml() );

this.element.attr( "role", "spinbutton" );
},
_uiSpinnerHtml: function() {
return "<span>";
Expand Down

0 comments on commit f6d02bd

Please sign in to comment.