From 142b74b019f1802425f7b6569de5b4986893b85c Mon Sep 17 00:00:00 2001 From: samarsultan Date: Tue, 1 Aug 2017 16:37:30 +0200 Subject: [PATCH] updating bidi and numericshaping files --- notebook/static/bidi/bidi.js | 14 +++----------- notebook/static/bidi/numericshaping.js | 21 ++------------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/notebook/static/bidi/bidi.js b/notebook/static/bidi/bidi.js index d82fd1c1d..bd7118d14 100644 --- a/notebook/static/bidi/bidi.js +++ b/notebook/static/bidi/bidi.js @@ -5,18 +5,10 @@ define([ 'bidi/numericshaping', ], function (numericshaping){ "use strict"; + var shaperType=""; var textDir=""; - var _setUserPreferences = function (shapertype /*, textdir*/) { //for future work in case of BTD Support we need to set the textDir also. - shaperType = shapertype; - if (_uiLang() == 'ar'||'he'){ - textDir = "rtl"; - }else { - textDir = "ltr"; - } - }; - var _uiLang= function (){ return navigator.language.toLowerCase(); }; @@ -29,6 +21,7 @@ define([ console.warn("Error loading the required locale"); console.warn(err); }); + shaperType= _uiLang()=='ar'? "national" : "defaultNumeral"; }; var _isMirroringEnabled= function() { @@ -49,12 +42,11 @@ define([ * @param flag :indicates the type of bidi-support (Numeric-shaping ,Base-text-dir ). */ var _applyBidi = function (value /*, flag*/) { - value = numericshaping.shapeNumerals(value, shaperType, textDir); + value = numericshaping.shapeNumerals(value, shaperType); return value; }; var bidi = { - setUserPreferences : _setUserPreferences, applyBidi : _applyBidi, isMirroringEnabled : _isMirroringEnabled, loadLocale : _loadLocale, diff --git a/notebook/static/bidi/numericshaping.js b/notebook/static/bidi/numericshaping.js index 5ac272b3d..d78ec0d0d 100644 --- a/notebook/static/bidi/numericshaping.js +++ b/notebook/static/bidi/numericshaping.js @@ -7,7 +7,7 @@ define([], var regex = /([0-9])|([\u0660-\u0669])|([\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FF\u0750-\u077F\u08A0-\u08E3\u200F\u202B\u202E\u2067\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFC\uFDFE-\uFDFF\uFE70-\uFEFE]+)|([^0-9\u0660-\u0669\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FF\u0750-\u077F\u08A0-\u08E3\u200F\u202B\u202E\u2067\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFC\uFDFE-\uFDFF\uFE70-\uFEFE\u0600-\u0607\u0609-\u060A\u060C\u060E-\u061A\u064B-\u066C\u0670\u06D6-\u06E4\u06E7-\u06ED\u06F0-\u06F9\u08E4-\u08FF\uFD3E-\uFD3F\uFDD0-\uFDEF\uFDFD\uFEFF\u0000-\u0040\u005B-\u0060\u007B-\u007F\u0080-\u00A9\u00AB-\u00B4\u00B6-\u00B9\u00BB-\u00BF\u00D7\u00F7\u02B9-\u02BA\u02C2-\u02CF\u02D2-\u02DF\u02E5-\u02ED\u02EF-\u02FF\u2070\u2074-\u207E\u2080-\u208E\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A-\u213B\u2140-\u2144\u214A-\u214D\u2150-\u215F\u2189\uA720-\uA721\uA788\uFF01-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE]+)/g; - var shape = function(text, shaperType, textDir) { + var shape = function(text, shaperType) { text = text.toString(); if (!text) { return text; @@ -17,8 +17,6 @@ define([], return _shapeEuropean(text); case "national": return _shapeArabic(text); - case "contextual": - return _shapeContextual(text, textDir === "rtl" ? 2 : 1); default: return text; } @@ -35,22 +33,7 @@ define([], return String.fromCharCode(parseInt(c) + 1632); }); }; - - var _shapeContextual = function (text, context) { - return text.replace(regex, function(match, latinDigit, arabicDigit, strongArabic, strongLatin){ - if (latinDigit) { - return (context === 2) ? String.fromCharCode(parseInt(latinDigit) + 1632) : latinDigit; - } else if (arabicDigit) { - return (context === 1) ? arabicDigit.charCodeAt(0) - 1632 : arabicDigit; - } else if (strongArabic) { - context = 2; - } else if (strongLatin) { - context = 1; - } - return match; - }); - }; - + var numericshaping = { shapeNumerals : shape };