Skip to content

Commit 79ace1e

Browse files
author
RockQ
committed
Update the fix using "dir=rtl" in markup to config the widget direction. The new testcase is http://jsfiddle.net/nhvwL5my/
Signed-off-by: RockQ <rqruanqi@cn.ibm.com>
1 parent 42c20bf commit 79ace1e

File tree

3 files changed

+24
-61
lines changed

3 files changed

+24
-61
lines changed

themes/base/spinner.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
right: auto;
7474
left: 0;
7575
}
76-
.ui-rtl .ui-spinner a.ui-spinner-button {
76+
.ui-rtl.ui-spinner a.ui-spinner-button {
7777
border-left-width: 0;
7878
border-right-width: 1px;
7979
}

ui/core.js

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
* Released under the MIT license.
77
* http://jquery.org/license
88
*
9-
* http://api.jqueryui.com/category/ui-core/
109
*/
10+
11+
//>>label: Core
12+
//>>group: UI Core
13+
//>>description: The core of jQuery UI, required for all interactions and widgets.
14+
//>>docs: http://api.jqueryui.com/category/ui-core/
15+
//>>demos: http://jqueryui.com/
16+
1117
(function( factory ) {
1218
if ( typeof define === "function" && define.amd ) {
1319

@@ -136,14 +142,6 @@ $.extend( $.expr[ ":" ], {
136142
}
137143
});
138144

139-
// support: document in RTL mode
140-
$(function () {
141-
$.ui.isRtl = ( $( "body" ).attr( "dir" ) || $( "html" ).attr( "dir" ) || "" ).toLowerCase() === "rtl";
142-
if ( $.ui.isRtl ) {
143-
$( "body" ).addClass( "ui-rtl" );
144-
}
145-
});
146-
147145
// support: jQuery <1.8
148146
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
149147
$.each( [ "Width", "Height" ], function( i, name ) {
@@ -217,22 +215,6 @@ if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
217215
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
218216

219217
$.fn.extend({
220-
focus: (function( orig ) {
221-
return function( delay, fn ) {
222-
return typeof delay === "number" ?
223-
this.each(function() {
224-
var elem = this;
225-
setTimeout(function() {
226-
$( elem ).focus();
227-
if ( fn ) {
228-
fn.call( elem );
229-
}
230-
}, delay );
231-
}) :
232-
orig.apply( this, arguments );
233-
};
234-
})( $.fn.focus ),
235-
236218
disableSelection: (function() {
237219
var eventType = "onselectstart" in document.createElement( "div" ) ?
238220
"selectstart" :
@@ -247,35 +229,6 @@ $.fn.extend({
247229

248230
enableSelection: function() {
249231
return this.unbind( ".ui-disableSelection" );
250-
},
251-
252-
zIndex: function( zIndex ) {
253-
if ( zIndex !== undefined ) {
254-
return this.css( "zIndex", zIndex );
255-
}
256-
257-
if ( this.length ) {
258-
var elem = $( this[ 0 ] ), position, value;
259-
while ( elem.length && elem[ 0 ] !== document ) {
260-
// Ignore z-index if position is set to a value where z-index is ignored by the browser
261-
// This makes behavior of this function consistent across browsers
262-
// WebKit always returns auto if the element is positioned
263-
position = elem.css( "position" );
264-
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
265-
// IE returns 0 when zIndex is not specified
266-
// other browsers return a string
267-
// we ignore the case of nested elements with an explicit value of 0
268-
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
269-
value = parseInt( elem.css( "zIndex" ), 10 );
270-
if ( !isNaN( value ) && value !== 0 ) {
271-
return value;
272-
}
273-
}
274-
elem = elem.parent();
275-
}
276-
}
277-
278-
return 0;
279232
}
280233
});
281234

ui/spinner.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
* Copyright 2014 jQuery Foundation and other contributors
66
* Released under the MIT license.
77
* http://jquery.org/license
8-
*
9-
* http://api.jqueryui.com/spinner/
108
*/
9+
10+
//>>label: Spinner
11+
//>>group: Widgets
12+
//>>description: Displays buttons to easily input numbers via the keyboard or mouse.
13+
//>>docs: http://api.jqueryui.com/spinner/
14+
//>>demos: http://jqueryui.com/spinner/
15+
1116
(function( factory ) {
1217
if ( typeof define === "function" && define.amd ) {
1318

@@ -60,6 +65,7 @@ return $.widget( "ui.spinner", {
6065
},
6166

6267
_create: function() {
68+
var rtl = this.element.attr( "dir" ) === "rtl";
6369
// handle string values that need to be parsed
6470
this._setOption( "max", this.options.max );
6571
this._setOption( "min", this.options.min );
@@ -202,13 +208,16 @@ return $.widget( "ui.spinner", {
202208
},
203209

204210
_draw: function() {
205-
var uiSpinner = this.uiSpinner = this.element
211+
var rtl = this.element.attr( "dir" ) === "rtl",
212+
uiSpinner = this.uiSpinner = this.element
206213
.addClass( "ui-spinner-input" )
207214
.attr( "autocomplete", "off" )
208215
.wrap( this._uiSpinnerHtml() )
209216
.parent()
210217
// add buttons
211-
.append( this._buttonHtml() );
218+
.append( this._buttonHtml() )
219+
// add ui-rtl class
220+
.toggleClass( "ui-rtl", rtl );
212221

213222
this.element.attr( "role", "spinbutton" );
214223

@@ -258,11 +267,12 @@ return $.widget( "ui.spinner", {
258267
},
259268

260269
_buttonHtml: function() {
270+
var rtl = this.element.attr( "dir" ) === "rtl";
261271
return "" +
262-
"<a class='ui-spinner-button ui-spinner-up " + ($.ui.isRtl ? "ui-corner-tl" : "ui-corner-tr") + "'>" +
272+
"<a class='ui-spinner-button ui-spinner-up " + ( rtl ? "ui-corner-tl'>" : "ui-corner-tr'>" ) +
263273
"<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
264274
"</a>" +
265-
"<a class='ui-spinner-button ui-spinner-down " + ($.ui.isRtl ? "ui-corner-bl" : "ui-corner-br") + "'>" +
275+
"<a class='ui-spinner-button ui-spinner-down " + ( rtl ? "ui-corner-bl'>" : "ui-corner-br'>" ) +
266276
"<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
267277
"</a>";
268278
},

0 commit comments

Comments
 (0)