Tuning bidi support

pull/2357/head
samarsultan 9 years ago
parent a87528ca22
commit 2d0be3560f

@ -8,44 +8,54 @@ define([
var shaperType="";
var textDir="";
/* var _getCalendarType = function (){
return calendarType;
};*/
var _setUserPreferences = function (shapertype) {
var _setUserPreferences = function (shapertype /*, textdir*/) { //for future work in case of BTD Support we need to set the textDir also.
shaperType = shapertype;
textDir = "rtl";
if (_uiLang() == 'ar'||'he'){
textDir = "rtl";
}else {
textDir = "ltr";
}
};
var _uiLang= function (){
return navigator.language.toLowerCase();
};
var _loadLocale = function () {
try{
if(_isMirroringEnabled()){
$("body").attr("dir","rtl");
}
requirejs(['components/moment/locale/'+_uiLang()], function (){});
}catch (err) {
return moment.locale();
console.log("Error loading the required locale");
console.warn(err);
}
var _loadLocale = function () {
if(_isMirroringEnabled()){
$("body").attr("dir","rtl");
}
requirejs(['components/moment/locale/'+_uiLang()], function (err){
console.warn("Error loading the required locale");
console.warn(err);
});
};
var _isMirroringEnabled= function() {
return (new RegExp("^(ar|he)").test(_uiLang()));
};
/**
* NS : for digit Shaping.
* BTD : for future work in case of Base Text Direction Addition.
*/
/*var _flags= {
NS: 1,
BTD : 2
};*/
var _applyNumericShaping = function (value) {
/**
* @param value : the string to apply the bidi-support on it.
* @param flag :indicates the type of bidi-support (Numeric-shaping ,Base-text-dir ).
*/
var _applyBidi = function (value /*, flag*/) {
value = numericshaping.shapeNumerals(value, shaperType, textDir);
return value;
};
var bidi = {
setUserPreferences : _setUserPreferences,
applyNumericShaping : _applyNumericShaping,
applyBidi : _applyBidi,
isMirroringEnabled : _isMirroringEnabled,
loadLocale : _loadLocale,
};

@ -33,7 +33,7 @@ require([
try {
requirejs(['custom/custom'], function() {});
bidi.loadLocale();
bidi.setUserPreferences("contextual");
bidi.setUserPreferences(/*"contextual"*/); //waiting for user input here
} catch(err) {
console.log("Error loading custom.js from edition service. Continuing and logging");
console.warn(err);

@ -10,7 +10,7 @@ define([
'bidi/bidi',
], function($, utils, dialog, keyboard, moment, bidi) {
"use strict";
//bidi.loadLocale();
bidi.loadLocale();
var SaveWidget = function (selector, options) {
this.editor = undefined;
this.selector = selector;
@ -109,7 +109,7 @@ define([
SaveWidget.prototype.update_filename = function (filename) {
filename = bidi.applyNumericShaping(filename);
filename = bidi.applyBidi(filename);
this.element.find('span.filename').text(filename);
};

@ -77,8 +77,7 @@ require([
try{
requirejs(['custom/custom'], function() {});
bidi.loadLocale();
//bidi.setUserPreferences("hijri", "national");
bidi.setUserPreferences("contextual");
bidi.setUserPreferences(/*"contextual"*/); //waiting for user input here
} catch(err) {
console.log("Error processing custom.js. Logging and continuing");
console.warn(err);

@ -8,7 +8,7 @@ define([
'base/js/keyboard',
'moment',
'bidi/bidi',
], function($, utils, dialog, keyboard, moment ,bidi) {
], function($, utils, dialog, keyboard, moment, bidi) {
"use strict";
var SaveWidget = function (selector, options) {
@ -131,7 +131,7 @@ define([
SaveWidget.prototype.update_notebook_name = function () {
var nbname = this.notebook.get_notebook_name();
nbname = bidi.applyNumericShaping(nbname);
nbname = bidi.applyBidi(nbname);
this.element.find('span.filename').text(nbname);
};

@ -56,7 +56,7 @@ require([
try{
requirejs(['custom/custom'], function() {});
bidi.loadLocale();
bidi.setUserPreferences("contextual" );
bidi.setUserPreferences(/*"contextual"*/); //waiting for user input here
} catch(err) {
console.log("Error loading custom.js from tree service. Continuing and logging");
console.warn(err);

@ -644,7 +644,7 @@ define([
select_all.data('indeterminate', true);
}
// Update total counter
checked = bidi.applyNumericShaping(checked);
checked = bidi.applyBidi(checked);
$('#counter-select-all').html(checked===0 ? ' ' : checked);
// If at aleast on item is selected, hide the selection instructions.
@ -661,7 +661,7 @@ define([
modified = model.last_modified;
var running = (model.type === 'notebook' && this.sessions[path] !== undefined);
name = bidi.applyNumericShaping(name);
name = bidi.applyBidi(name);
item.data('name', name);
item.data('path', path);
item.data('modified', modified);

Loading…
Cancel
Save