From 42c20bfa9885278e20edc79d54b2a0307e11a55e Mon Sep 17 00:00:00 2001 From: Rock_Q Date: Sat, 11 Oct 2014 11:13:26 +0800 Subject: [PATCH 1/3] Spinner Rtl enablement --- themes/base/spinner.css | 16 +++++++++++++++- ui/core.js | 8 ++++++++ ui/spinner.js | 4 ++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/themes/base/spinner.css b/themes/base/spinner.css index 4f6e59d9b4d..72182bcb653 100644 --- a/themes/base/spinner.css +++ b/themes/base/spinner.css @@ -42,7 +42,7 @@ .ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; - border-right: none; + border-right-width: 0; } /* vertically center icon */ .ui-spinner .ui-icon { @@ -63,3 +63,17 @@ /* need to fix icons sprite */ background-position: -65px -16px; } + +/* rtl mode overrides */ +.ui-rtl .ui-spinner-input{ + margin-right: .4em; + margin-left: 22px; +} +.ui-rtl .ui-spinner-button { + right: auto; + left: 0; +} +.ui-rtl .ui-spinner a.ui-spinner-button { + border-left-width: 0; + border-right-width: 1px; +} diff --git a/ui/core.js b/ui/core.js index 0bcb46aa7df..3b5a33cea58 100644 --- a/ui/core.js +++ b/ui/core.js @@ -136,6 +136,14 @@ $.extend( $.expr[ ":" ], { } }); +// support: document in RTL mode +$(function () { + $.ui.isRtl = ( $( "body" ).attr( "dir" ) || $( "html" ).attr( "dir" ) || "" ).toLowerCase() === "rtl"; + if ( $.ui.isRtl ) { + $( "body" ).addClass( "ui-rtl" ); + } +}); + // support: jQuery <1.8 if ( !$( "" ).outerWidth( 1 ).jquery ) { $.each( [ "Width", "Height" ], function( i, name ) { diff --git a/ui/spinner.js b/ui/spinner.js index 263b29d3fbb..f421aa71f16 100644 --- a/ui/spinner.js +++ b/ui/spinner.js @@ -259,10 +259,10 @@ return $.widget( "ui.spinner", { _buttonHtml: function() { return "" + - "" + + "" + "" + "" + - "" + + "" + "" + ""; }, From 79ace1e9e4bf906a28b74bf2d45ca809a435faf4 Mon Sep 17 00:00:00 2001 From: RockQ Date: Sun, 4 Jan 2015 17:51:54 +0800 Subject: [PATCH 2/3] 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 --- themes/base/spinner.css | 2 +- ui/core.js | 61 +++++------------------------------------ ui/spinner.js | 22 +++++++++++---- 3 files changed, 24 insertions(+), 61 deletions(-) diff --git a/themes/base/spinner.css b/themes/base/spinner.css index 72182bcb653..e706d201232 100644 --- a/themes/base/spinner.css +++ b/themes/base/spinner.css @@ -73,7 +73,7 @@ right: auto; left: 0; } -.ui-rtl .ui-spinner a.ui-spinner-button { +.ui-rtl.ui-spinner a.ui-spinner-button { border-left-width: 0; border-right-width: 1px; } diff --git a/ui/core.js b/ui/core.js index 3b5a33cea58..a6f7d65489d 100644 --- a/ui/core.js +++ b/ui/core.js @@ -6,8 +6,14 @@ * Released under the MIT license. * http://jquery.org/license * - * http://api.jqueryui.com/category/ui-core/ */ + +//>>label: Core +//>>group: UI Core +//>>description: The core of jQuery UI, required for all interactions and widgets. +//>>docs: http://api.jqueryui.com/category/ui-core/ +//>>demos: http://jqueryui.com/ + (function( factory ) { if ( typeof define === "function" && define.amd ) { @@ -136,14 +142,6 @@ $.extend( $.expr[ ":" ], { } }); -// support: document in RTL mode -$(function () { - $.ui.isRtl = ( $( "body" ).attr( "dir" ) || $( "html" ).attr( "dir" ) || "" ).toLowerCase() === "rtl"; - if ( $.ui.isRtl ) { - $( "body" ).addClass( "ui-rtl" ); - } -}); - // support: jQuery <1.8 if ( !$( "" ).outerWidth( 1 ).jquery ) { $.each( [ "Width", "Height" ], function( i, name ) { @@ -217,22 +215,6 @@ if ( $( "" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); $.fn.extend({ - focus: (function( orig ) { - return function( delay, fn ) { - return typeof delay === "number" ? - this.each(function() { - var elem = this; - setTimeout(function() { - $( elem ).focus(); - if ( fn ) { - fn.call( elem ); - } - }, delay ); - }) : - orig.apply( this, arguments ); - }; - })( $.fn.focus ), - disableSelection: (function() { var eventType = "onselectstart" in document.createElement( "div" ) ? "selectstart" : @@ -247,35 +229,6 @@ $.fn.extend({ enableSelection: function() { return this.unbind( ".ui-disableSelection" ); - }, - - zIndex: function( zIndex ) { - if ( zIndex !== undefined ) { - return this.css( "zIndex", zIndex ); - } - - if ( this.length ) { - var elem = $( this[ 0 ] ), position, value; - while ( elem.length && elem[ 0 ] !== document ) { - // Ignore z-index if position is set to a value where z-index is ignored by the browser - // This makes behavior of this function consistent across browsers - // WebKit always returns auto if the element is positioned - position = elem.css( "position" ); - if ( position === "absolute" || position === "relative" || position === "fixed" ) { - // IE returns 0 when zIndex is not specified - // other browsers return a string - // we ignore the case of nested elements with an explicit value of 0 - //
- value = parseInt( elem.css( "zIndex" ), 10 ); - if ( !isNaN( value ) && value !== 0 ) { - return value; - } - } - elem = elem.parent(); - } - } - - return 0; } }); diff --git a/ui/spinner.js b/ui/spinner.js index f421aa71f16..aa19f5a4c65 100644 --- a/ui/spinner.js +++ b/ui/spinner.js @@ -5,9 +5,14 @@ * Copyright 2014 jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license - * - * http://api.jqueryui.com/spinner/ */ + +//>>label: Spinner +//>>group: Widgets +//>>description: Displays buttons to easily input numbers via the keyboard or mouse. +//>>docs: http://api.jqueryui.com/spinner/ +//>>demos: http://jqueryui.com/spinner/ + (function( factory ) { if ( typeof define === "function" && define.amd ) { @@ -60,6 +65,7 @@ return $.widget( "ui.spinner", { }, _create: function() { + var rtl = this.element.attr( "dir" ) === "rtl"; // handle string values that need to be parsed this._setOption( "max", this.options.max ); this._setOption( "min", this.options.min ); @@ -202,13 +208,16 @@ return $.widget( "ui.spinner", { }, _draw: function() { - var uiSpinner = this.uiSpinner = this.element + var rtl = this.element.attr( "dir" ) === "rtl", + uiSpinner = this.uiSpinner = this.element .addClass( "ui-spinner-input" ) .attr( "autocomplete", "off" ) .wrap( this._uiSpinnerHtml() ) .parent() // add buttons - .append( this._buttonHtml() ); + .append( this._buttonHtml() ) + // add ui-rtl class + .toggleClass( "ui-rtl", rtl ); this.element.attr( "role", "spinbutton" ); @@ -258,11 +267,12 @@ return $.widget( "ui.spinner", { }, _buttonHtml: function() { + var rtl = this.element.attr( "dir" ) === "rtl"; return "" + - "
" + + "" : "ui-corner-tr'>" ) + "" + "" + - "" + + "" : "ui-corner-br'>" ) + "" + ""; }, From cb2ec061a05cb38f099e6f74d5798e4d1e8a34d6 Mon Sep 17 00:00:00 2001 From: RockQ Date: Sun, 4 Jan 2015 23:06:17 +0800 Subject: [PATCH 3/3] Remove unnecessary rtl variable declaration in spinner.js _create function Signed-off-by: RockQ --- ui/spinner.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/spinner.js b/ui/spinner.js index 7f8cce770b1..571131b49ae 100644 --- a/ui/spinner.js +++ b/ui/spinner.js @@ -65,7 +65,6 @@ return $.widget( "ui.spinner", { }, _create: function() { - var rtl = this.element.attr( "dir" ) === "rtl"; // handle string values that need to be parsed this._setOption( "max", this.options.max ); this._setOption( "min", this.options.min );