|
1 | 1 | // Copyright (c) Jupyter Development Team.
|
2 | 2 | // Distributed under the terms of the Modified BSD License.
|
3 | 3 |
|
4 |
| -define([ |
5 |
| - 'bidi/numericshaping', |
6 |
| -], function (numericshaping){ |
7 |
| - "use strict"; |
8 |
| - |
9 |
| - var shaperType=""; |
10 |
| - var textDir=""; |
11 |
| - |
12 |
| - var _uiLang= function (){ |
13 |
| - return navigator.language.toLowerCase(); |
14 |
| - }; |
15 |
| - |
16 |
| - var _loadLocale = function () { |
17 |
| - if(_isMirroringEnabled()){ |
18 |
| - $("body").attr("dir","rtl"); |
19 |
| - } |
20 |
| - requirejs(['components/moment/locale/'+_uiLang()], function (err){ |
21 |
| - console.warn("Error loading the required locale"); |
22 |
| - console.warn(err); |
23 |
| - }); |
24 |
| - shaperType= _uiLang()=='ar'? "national" : "defaultNumeral"; |
25 |
| - }; |
26 |
| - |
27 |
| - var _isMirroringEnabled= function() { |
28 |
| - return (new RegExp("^(ar|he)").test(_uiLang())); |
29 |
| - }; |
30 |
| - |
31 |
| - /** |
| 4 | +define(['bidi/numericshaping'], function(numericshaping) { |
| 5 | + 'use strict'; |
| 6 | + |
| 7 | + var shaperType = ''; |
| 8 | + var textDir = ''; |
| 9 | + |
| 10 | + var _uiLang = function() { |
| 11 | + return navigator.language.toLowerCase(); |
| 12 | + }; |
| 13 | + |
| 14 | + var _loadLocale = function() { |
| 15 | + if (_isMirroringEnabled()) { |
| 16 | + $('body').attr('dir', 'rtl'); |
| 17 | + } |
| 18 | + var uiLang = _uiLang(); |
| 19 | + |
| 20 | + if (uiLang !== 'en' && uiLang !== 'en-us') { |
| 21 | + // moment does not ship with a separate file for locale/en or locale/en-us |
| 22 | + // so we must skip dynamically requiring it |
| 23 | + requirejs(['components/moment/locale/' + _uiLang()], function(err) { |
| 24 | + console.warn('Error loading the required locale'); |
| 25 | + console.warn(err); |
| 26 | + }); |
| 27 | + } |
| 28 | + |
| 29 | + shaperType = _uiLang() == 'ar' ? 'national' : 'defaultNumeral'; |
| 30 | + }; |
| 31 | + |
| 32 | + var _isMirroringEnabled = function() { |
| 33 | + return new RegExp('^(ar|he)').test(_uiLang()); |
| 34 | + }; |
| 35 | + |
| 36 | + /** |
32 | 37 | * NS : for digit Shaping.
|
33 | 38 | * BTD : for future work in case of Base Text Direction Addition.
|
34 |
| - */ |
35 |
| - /*var _flags= { |
36 |
| - NS: 1, |
37 |
| - BTD : 2 |
38 |
| - };*/ |
39 |
| - |
40 |
| - /** |
| 39 | + */ |
| 40 | + |
| 41 | + /** |
41 | 42 | * @param value : the string to apply the bidi-support on it.
|
42 | 43 | * @param flag :indicates the type of bidi-support (Numeric-shaping ,Base-text-dir ).
|
43 | 44 | */
|
44 |
| - var _applyBidi = function (value /*, flag*/) { |
45 |
| - value = numericshaping.shapeNumerals(value, shaperType); |
46 |
| - return value; |
47 |
| - }; |
48 |
| - |
49 |
| - var bidi = { |
50 |
| - applyBidi : _applyBidi, |
51 |
| - isMirroringEnabled : _isMirroringEnabled, |
52 |
| - loadLocale : _loadLocale, |
53 |
| - }; |
54 |
| - |
55 |
| - return bidi; |
| 45 | + var _applyBidi = function(value /*, flag*/) { |
| 46 | + value = numericshaping.shapeNumerals(value, shaperType); |
| 47 | + return value; |
| 48 | + }; |
| 49 | + |
| 50 | + var bidi = { |
| 51 | + applyBidi: _applyBidi, |
| 52 | + isMirroringEnabled: _isMirroringEnabled, |
| 53 | + loadLocale: _loadLocale, |
| 54 | + }; |
| 55 | + |
| 56 | + return bidi; |
56 | 57 | });
|
0 commit comments