From 4013cd8b17fdda27abe922c06e265f6979d5e12b Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 5 Mar 2017 10:25:50 +0200 Subject: [PATCH 01/19] enable the localization mode --- notebook/static/edit/js/main.js | 7 ++++++- notebook/static/notebook/js/main.js | 9 +++++++-- notebook/static/tree/js/main.js | 13 +++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/notebook/static/edit/js/main.js b/notebook/static/edit/js/main.js index 958d2b711f..37d5e1b89d 100644 --- a/notebook/static/edit/js/main.js +++ b/notebook/static/edit/js/main.js @@ -13,6 +13,7 @@ require([ 'edit/js/menubar', 'edit/js/savewidget', 'edit/js/notificationarea', + 'bidi/bidi', ], function( $, contents_service, @@ -24,12 +25,16 @@ require([ editmod, menubar, savewidget, - notificationarea + notificationarea, + bidi ){ "use strict"; try { requirejs(['custom/custom'], function() {}); + bidi.loadLocale(bidi.uiLang()); + bidi.setNumericShaping("national"); + bidi.isMirroringEnabled(); } catch(err) { console.log("Error loading custom.js from edition service. Continuing and logging"); console.warn(err); diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index 6f2e82e01a..34b8230ef2 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -42,7 +42,8 @@ require([ 'codemirror/lib/codemirror', 'notebook/js/about', 'notebook/js/searchandreplace', - 'notebook/js/clipboard' + 'notebook/js/clipboard', + 'bidi/bidi' ], function( $, contents_service, @@ -65,7 +66,8 @@ require([ CodeMirror, about, searchandreplace, - clipboard + clipboard, + bidi ) { "use strict"; @@ -74,6 +76,9 @@ require([ try{ requirejs(['custom/custom'], function() {}); + bidi.loadLocale(bidi.uiLang()); + bidi.setNumericShaping("national"); + bidi.isMirroringEnabled(); } catch(err) { console.log("Error processing custom.js. Logging and continuing"); console.warn(err); diff --git a/notebook/static/tree/js/main.js b/notebook/static/tree/js/main.js index e087a82928..655e7d1533 100644 --- a/notebook/static/tree/js/main.js +++ b/notebook/static/tree/js/main.js @@ -35,6 +35,7 @@ require([ 'tree/js/terminallist', 'tree/js/newnotebook', 'auth/js/loginwidget', + 'bidi/bidi', ], function( $, contents_service, @@ -49,18 +50,22 @@ require([ kernellist, terminallist, newnotebook, - loginwidget){ + loginwidget, + bidi){ "use strict"; try{ requirejs(['custom/custom'], function() {}); + bidi.loadLocale(bidi.uiLang()); + bidi.setNumericShaping("national"); + bidi.setCalendarType("hijri"); + bidi.isMirroringEnabled(); } catch(err) { console.log("Error loading custom.js from tree service. Continuing and logging"); console.warn(err); } - console.log('Welcome to Project Jupyter! Explore the various tools available and their corresponding documentation. If you are interested in contributing to the platform, please visit the community resources section at http://jupyter.org/community.html.'); - - + + // Setup all of the config related things var common_options = { From c66338913914bdb8d7414208c5d5a85fd3ea0d66 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 5 Mar 2017 10:26:58 +0200 Subject: [PATCH 02/19] configure the moment-hijri plugin --- tools/build-main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build-main.js b/tools/build-main.js index 44b5b70133..c568102524 100644 --- a/tools/build-main.js +++ b/tools/build-main.js @@ -20,6 +20,7 @@ var rjs_config = { bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min', "jquery-ui": 'components/jquery-ui/ui/minified/jquery-ui.min', moment: 'components/moment/moment', + "moment-hijri": 'components/moment-hijri/moment-hijri', codemirror: 'components/codemirror', xterm: 'components/xterm.js/dist/xterm', typeahead: 'components/jquery-typeahead/dist/jquery.typeahead', From ea72fe3ff5c73eeedc9fe9e50426823a0cc28570 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 5 Mar 2017 10:43:29 +0200 Subject: [PATCH 03/19] Creating bidi interface --- notebook/static/bidi/bidi.js | 114 ++++++++++++++++++++++ notebook/static/edit/js/savewidget.js | 6 +- notebook/static/notebook/js/savewidget.js | 4 +- notebook/static/tree/js/notebooklist.js | 14 ++- 4 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 notebook/static/bidi/bidi.js diff --git a/notebook/static/bidi/bidi.js b/notebook/static/bidi/bidi.js new file mode 100644 index 0000000000..bee1e03424 --- /dev/null +++ b/notebook/static/bidi/bidi.js @@ -0,0 +1,114 @@ +// Copyright (c) Jupyter Development Team. +// Distributed under the terms of the Modified BSD License. + +define([ + 'bidi/numericshaping', + 'moment-hijri', +], function (numericshaping, moment){ + "use strict"; + var calendarType=""; + var textDir=""; + var shaperType=""; + + var _setCalendarType = function (val){ + calendarType=val; + }; + + var _getcalendarType = function (){ + return calendarType; + }; + + var _setTextDir = function (dir){ + textDir=dir; + }; + + var _setNumericShaping = function (val){ + shaperType=val; + }; + + var _flags= { + NS: 1, + CALENDAR : 2 + }; + + /* + * Test the UI Language + */ + var _uiLang= function (){ + return navigator.language.toLowerCase(); + }; + /* + * TODO: this function cannot be invoked once ,as moment has different formats for the date . + * It needs improvements. + */ + var _getGlobalizedDate = function (date) { + var lang = _uiLang(); + if (calendarType === "hijri" || lang ==='ar-sa') { + + } else if (calendarType === "hebrew") { + } + return; + }; + + /* + * check if the locale exists provided by moment + */ + var _hasLocale = function (lang) { + if (lang == 'af'||'ar-ma'||'ar-sa'||'ar'||'az'||'be'||'bg' ||'bn'||'bo'||'br'||'bs'||'ca'||'cs'||'cv'||'cy'||'da'||'de-at'||'de'||'el'||'en-au'||'en-ca'||'en-gb'||'eo'||'es'||'et'||'eu'||'fa'||'fi'||'fo'||'fr-ca'||'fr'||'gl'||'he'||'hi'||'hr'||'hu'||'hy-am'||'id'||'is'||'it'||'ja'||'ka'||'km'||'ko'||'lb'||'lt'||'lv'||'mk'||'ml'||'mr'||'ms-my'||'my'||'nb'||'ne'||'nl'||'nn'||'pl'||'pt-br'||'pt'||'ro'||'ru'||'sk'||'sl'||'sq'||'sr-cyrl'||'sr'||'sv'||'ta'||'th'||'tl-ph'||'tr'||'tzm-latn'||'tzm'||'uk'||'uz'||'vi'||'zh-cn'||'zh-tw' ) { + return true; + } + else{ + return false; + } + }; + + /* + * to load the required locale + */ + var _loadLocale = function (lang) { + if ( _hasLocale(lang)){ + return requirejs(['components/moment/locale/'+lang], function (){}); + } + else{ + return requirejs(['components/moment'], function (){}); + } + }; + + /* + * TODO: to add the other RTL languages + */ + var _isMirroringEnabled= function() { + if(new RegExp("^(ar|he)").test(_uiLang())){ + $("body").attr("dir","rtl"); + } + return; + }; + + var _applyBidi = function (value , flag) { + if(flag & _flags.NS == _flags.NS) { + value = numericshaping.shapeNumerals(value, shaperType, textDir); + return value; + } + if(flag & _flags.CALENDAR == _flags.CALENDAR) { + value = _getGlobalizedDate(value); + console.log("Calendar "); + return value; + } + return value; + }; + + var bidi = { + isMirroringEnabled : _isMirroringEnabled, + setNumericShaping : _setNumericShaping, + setCalendarType: _setCalendarType, + getcalendarType : _getcalendarType, + setTextDir : _setTextDir, + getGlobalizedDate: _getGlobalizedDate, + flags : _flags, + applyBidi : _applyBidi, + uiLang : _uiLang, + loadLocale : _loadLocale, + }; + + return bidi; +}); diff --git a/notebook/static/edit/js/savewidget.js b/notebook/static/edit/js/savewidget.js index 31d7cc65d1..7d0cd3a315 100644 --- a/notebook/static/edit/js/savewidget.js +++ b/notebook/static/edit/js/savewidget.js @@ -7,9 +7,10 @@ define([ 'base/js/dialog', 'base/js/keyboard', 'moment', -], function($, utils, dialog, keyboard, moment) { + 'bidi/bidi', +], function($, utils, dialog, keyboard, moment ,bidi) { "use strict"; - + bidi.loadLocale(bidi.uiLang()); var SaveWidget = function (selector, options) { this.editor = undefined; this.selector = selector; @@ -108,6 +109,7 @@ define([ SaveWidget.prototype.update_filename = function (filename) { + filename = bidi.applyBidi(filename , bidi.flags.NS); this.element.find('span.filename').text(filename); }; diff --git a/notebook/static/notebook/js/savewidget.js b/notebook/static/notebook/js/savewidget.js index c78067f980..a17d0b67a0 100644 --- a/notebook/static/notebook/js/savewidget.js +++ b/notebook/static/notebook/js/savewidget.js @@ -7,7 +7,8 @@ define([ 'base/js/dialog', 'base/js/keyboard', 'moment', -], function($, utils, dialog, keyboard, moment) { + 'bidi/bidi', +], function($, utils, dialog, keyboard, moment ,bidi) { "use strict"; var SaveWidget = function (selector, options) { @@ -130,6 +131,7 @@ define([ SaveWidget.prototype.update_notebook_name = function () { var nbname = this.notebook.get_notebook_name(); + nbname = bidi.applyBidi(nbname , bidi.flags.NS); this.element.find('span.filename').text(nbname); }; diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index f9724c0a7c..ff1e6b6094 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -8,8 +8,9 @@ define([ 'base/js/dialog', 'base/js/events', 'base/js/keyboard', - 'moment' -], function($, IPython, utils, dialog, events, keyboard, moment) { + 'moment', + 'bidi/bidi', +], function($, IPython, utils, dialog, events, keyboard, moment , bidi) { "use strict"; var NotebookList = function (selector, options) { @@ -643,6 +644,7 @@ define([ select_all.data('indeterminate', true); } // Update total counter + checked = bidi.applyBidi(checked , bidi.flags.NS); $('#counter-select-all').html(checked===0 ? ' ' : checked); // If at aleast on item is selected, hide the selection instructions. @@ -658,7 +660,8 @@ define([ name = model.name, modified = model.last_modified; var running = (model.type === 'notebook' && this.sessions[path] !== undefined); - + + name = bidi.applyBidi(name , bidi.flags.NS); item.data('name', name); item.data('path', path); item.data('modified', modified); @@ -697,6 +700,11 @@ define([ // Add in the date that the file was last modified item.find(".item_modified").text(utils.format_datetime(modified)); + if (bidi.getcalendarType()==="hijri"){ + require(['moment-hijri'],function (moment_hijri){ + item.find(".item_modified").attr("title", moment_hijri(modified).format("iYYYY-iMM-iDD HH:mm")); + }); + } item.find(".item_modified").attr("title", moment(modified).format("YYYY-MM-DD HH:mm")); }; From ad63cfda823ea1e276d34e55c37653a2dd7d7678 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 5 Mar 2017 10:44:48 +0200 Subject: [PATCH 04/19] Creating digit shaping core --- notebook/static/bidi/numericshaping.js | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 notebook/static/bidi/numericshaping.js diff --git a/notebook/static/bidi/numericshaping.js b/notebook/static/bidi/numericshaping.js new file mode 100644 index 0000000000..5ac272b3d7 --- /dev/null +++ b/notebook/static/bidi/numericshaping.js @@ -0,0 +1,59 @@ +// Copyright (c) Jupyter Development Team. +// Distributed under the terms of the Modified BSD License. + +define([], + function(bidi) { + "use strict"; + + 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) { + text = text.toString(); + if (!text) { + return text; + } + switch (shaperType) { + case "defaultNumeral": + return _shapeEuropean(text); + case "national": + return _shapeArabic(text); + case "contextual": + return _shapeContextual(text, textDir === "rtl" ? 2 : 1); + default: + return text; + } + }; + + var _shapeEuropean = function(text) { + return text.replace(/[\u0660-\u0669]/g, function(c) { + return c.charCodeAt(0) - 1632; + }); + }; + + var _shapeArabic = function(text) { + return text.replace(/[0-9]/g, function(c) { + 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 + }; + + return numericshaping; +}); From 243a3f8d7766e37961abbf084c624520a3816649 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Mon, 20 Mar 2017 10:05:13 +0200 Subject: [PATCH 05/19] Bidi Support --- notebook/static/auth/js/main.js | 5 +- notebook/static/auth/less/login.less | 27 ++++- notebook/static/base/less/page.less | 11 ++ notebook/static/bidi/bidi.js | 104 +++++------------- notebook/static/bidi/nationalcalendar.js | 42 +++++++ notebook/static/custom/custom.css | 16 ++- notebook/static/edit/js/main.js | 5 +- notebook/static/edit/js/savewidget.js | 52 ++++++--- notebook/static/notebook/js/main.js | 5 +- notebook/static/notebook/js/savewidget.js | 30 ++++- .../static/notebook/less/commandpalette.less | 25 +++++ .../static/notebook/less/kernelselector.less | 4 + notebook/static/notebook/less/menubar.less | 58 ++++++++++ .../notebook/less/notificationarea.less | 18 +++ .../static/notebook/less/renderedhtml.less | 7 ++ notebook/static/notebook/less/savewidget.less | 11 ++ notebook/static/notebook/less/toolbar.less | 3 + notebook/static/tree/js/main.js | 11 +- notebook/static/tree/js/notebooklist.js | 10 +- notebook/static/tree/js/sessionlist.js | 8 +- notebook/static/tree/less/tree.less | 51 +++++++++ 21 files changed, 388 insertions(+), 115 deletions(-) create mode 100644 notebook/static/bidi/nationalcalendar.js diff --git a/notebook/static/auth/js/main.js b/notebook/static/auth/js/main.js index 7be82388ed..68d7871c58 100644 --- a/notebook/static/auth/js/main.js +++ b/notebook/static/auth/js/main.js @@ -1,7 +1,10 @@ // Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. -define(['./loginmain', './logoutmain'], function (login_main, logout_main) { +define(['./loginmain', './logoutmain', 'bidi/bidi'], function (login_main, logout_main, bidi) { + if(bidi.isMirroringEnabled()){ + $("body").attr("dir","rtl"); + } return { login_main: login_main, logout_main: logout_main diff --git a/notebook/static/auth/less/login.less b/notebook/static/auth/less/login.less index d21a3a1c74..0091d8c8b9 100644 --- a/notebook/static/auth/less/login.less +++ b/notebook/static/auth/less/login.less @@ -3,4 +3,29 @@ display: inline-block; // pull the lower margin back margin-bottom: -4px; -} \ No newline at end of file +} + +/*[dir="rtl"] .center-nav { + form.pull-left { + .pull-right(); + } + .navbar-text { + float: right; + } +} +*/ +[dir="rtl"] .navbar-inner { + text-align: right; +} + +[dir="rtl"] p .navbar-text { + float: right; +} + +[dir="rtl"] div.text-left { + .text-right(); +} + +/*[dir ="rtl"] #ipython-main-app { + text-align: right; +}*/ diff --git a/notebook/static/base/less/page.less b/notebook/static/base/less/page.less index 7a51af6a87..6a565433a5 100644 --- a/notebook/static/base/less/page.less +++ b/notebook/static/base/less/page.less @@ -62,7 +62,14 @@ body > #header { } } +[dir="rtl"] #ipython_notebook { + margin-right: 10px; + margin-left: 0; +} +[dir="rtl"] #ipython_notebook.pull-left { + .pull-right(); +} #noscript { width: auto; @@ -103,6 +110,10 @@ span#login_widget { float: right; } +[dir="rtl"] span#login_widget { + float: left; +} + span#login_widget > .button, #logout { diff --git a/notebook/static/bidi/bidi.js b/notebook/static/bidi/bidi.js index bee1e03424..1760158ac5 100644 --- a/notebook/static/bidi/bidi.js +++ b/notebook/static/bidi/bidi.js @@ -3,110 +3,64 @@ define([ 'bidi/numericshaping', - 'moment-hijri', -], function (numericshaping, moment){ + 'bidi/nationalcalendar', +], function (numericshaping ,nationalcalendar){ "use strict"; - var calendarType=""; - var textDir=""; var shaperType=""; + var textDir=""; - var _setCalendarType = function (val){ - calendarType=val; - }; - - var _getcalendarType = function (){ + /* var _getCalendarType = function (){ return calendarType; - }; + };*/ - var _setTextDir = function (dir){ - textDir=dir; - }; - - var _setNumericShaping = function (val){ - shaperType=val; + var _setUserPreferences = function (calendartype, shapertype) { + nationalcalendar.setType(calendartype); + shaperType = shapertype; + textDir = "rtl"; }; var _flags= { - NS: 1, - CALENDAR : 2 + NS: 1, + CALENDAR : 2 }; - /* - * Test the UI Language - */ var _uiLang= function (){ return navigator.language.toLowerCase(); }; - /* - * TODO: this function cannot be invoked once ,as moment has different formats for the date . - * It needs improvements. - */ - var _getGlobalizedDate = function (date) { - var lang = _uiLang(); - if (calendarType === "hijri" || lang ==='ar-sa') { - - } else if (calendarType === "hebrew") { - } - return; - }; - /* - * check if the locale exists provided by moment - */ - var _hasLocale = function (lang) { - if (lang == 'af'||'ar-ma'||'ar-sa'||'ar'||'az'||'be'||'bg' ||'bn'||'bo'||'br'||'bs'||'ca'||'cs'||'cv'||'cy'||'da'||'de-at'||'de'||'el'||'en-au'||'en-ca'||'en-gb'||'eo'||'es'||'et'||'eu'||'fa'||'fi'||'fo'||'fr-ca'||'fr'||'gl'||'he'||'hi'||'hr'||'hu'||'hy-am'||'id'||'is'||'it'||'ja'||'ka'||'km'||'ko'||'lb'||'lt'||'lv'||'mk'||'ml'||'mr'||'ms-my'||'my'||'nb'||'ne'||'nl'||'nn'||'pl'||'pt-br'||'pt'||'ro'||'ru'||'sk'||'sl'||'sq'||'sr-cyrl'||'sr'||'sv'||'ta'||'th'||'tl-ph'||'tr'||'tzm-latn'||'tzm'||'uk'||'uz'||'vi'||'zh-cn'||'zh-tw' ) { - return true; - } - else{ - return false; + var _loadLocale = function () { + try{ + if(_isMirroringEnabled()){ + $("body").attr("dir","rtl"); + } + requirejs(['components/moment/locale/'+_uiLang()], function (){}); + }catch (err) { + console.log("Error loading the required locale"); + console.warn(err); } }; - /* - * to load the required locale - */ - var _loadLocale = function (lang) { - if ( _hasLocale(lang)){ - return requirejs(['components/moment/locale/'+lang], function (){}); - } - else{ - return requirejs(['components/moment'], function (){}); - } - }; - - /* - * TODO: to add the other RTL languages - */ var _isMirroringEnabled= function() { - if(new RegExp("^(ar|he)").test(_uiLang())){ - $("body").attr("dir","rtl"); - } - return; + return (new RegExp("^(ar|he)").test(_uiLang())); }; var _applyBidi = function (value , flag) { if(flag & _flags.NS == _flags.NS) { value = numericshaping.shapeNumerals(value, shaperType, textDir); - return value; + //return value; + } + else if(flag & _flags.CALENDAR == _flags.CALENDAR) { + value = nationalcalendar.formatDate(value); + console.log(value.long_date + " "+ value.human_date); } - if(flag & _flags.CALENDAR == _flags.CALENDAR) { - value = _getGlobalizedDate(value); - console.log("Calendar "); - return value; - } return value; }; - var bidi = { - isMirroringEnabled : _isMirroringEnabled, - setNumericShaping : _setNumericShaping, - setCalendarType: _setCalendarType, - getcalendarType : _getcalendarType, - setTextDir : _setTextDir, - getGlobalizedDate: _getGlobalizedDate, + var bidi = { + setUserPreferences : _setUserPreferences, flags : _flags, applyBidi : _applyBidi, - uiLang : _uiLang, + isMirroringEnabled : _isMirroringEnabled, loadLocale : _loadLocale, }; diff --git a/notebook/static/bidi/nationalcalendar.js b/notebook/static/bidi/nationalcalendar.js new file mode 100644 index 0000000000..6001c79de1 --- /dev/null +++ b/notebook/static/bidi/nationalcalendar.js @@ -0,0 +1,42 @@ +// Copyright (c) Jupyter Development Team. +// Distributed under the terms of the Modified BSD License. + +define(['base/js/utils', + 'moment', + 'moment-hijri', + ], + function(utils, moment, moment_hijri ,bidi) { + "use strict"; + + var calendarType = ""; + + var setType = function (val) { + calendarType = val; + }; + + var formatDate = function (date){ + var chkd = moment(date); + var long_date = chkd.format('llll'); + var human_date; + var tdelta = Math.ceil(new Date() - date); + if (tdelta < utils.time.milliseconds.d){ + // less than 24 hours old, use relative date + human_date = chkd.fromNow(); + } else { + // otherwise show calendar + // at hh,mm,ss + human_date = chkd.calendar(); + } + return { + long_date : long_date, + human_date : human_date + }; + + } + + return{ + formatDate : formatDate, + setType : setType + }; + +}); diff --git a/notebook/static/custom/custom.css b/notebook/static/custom/custom.css index 9f4abdaa49..6f3283861f 100644 --- a/notebook/static/custom/custom.css +++ b/notebook/static/custom/custom.css @@ -4,4 +4,18 @@ Placeholder for custom user CSS mainly to be overridden in profile/static/custom/custom.css This will always be an empty file in IPython -*/ \ No newline at end of file +*/ + +/*for the error , connecting & renaming window*/ + +[dir="rtl"] .modal-footer { + text-align : left !important; +} + +[dir="rtl"] .close { + float : left; +} + +[dir="rtl"] .fa-step-forward::before { + content: "\f048"; +} \ No newline at end of file diff --git a/notebook/static/edit/js/main.js b/notebook/static/edit/js/main.js index 37d5e1b89d..4c2e2aa52c 100644 --- a/notebook/static/edit/js/main.js +++ b/notebook/static/edit/js/main.js @@ -32,9 +32,8 @@ require([ try { requirejs(['custom/custom'], function() {}); - bidi.loadLocale(bidi.uiLang()); - bidi.setNumericShaping("national"); - bidi.isMirroringEnabled(); + bidi.loadLocale(); + bidi.setUserPreferences("hijri", "contextual"); } catch(err) { console.log("Error loading custom.js from edition service. Continuing and logging"); console.warn(err); diff --git a/notebook/static/edit/js/savewidget.js b/notebook/static/edit/js/savewidget.js index 7d0cd3a315..a9f93e5579 100644 --- a/notebook/static/edit/js/savewidget.js +++ b/notebook/static/edit/js/savewidget.js @@ -8,9 +8,9 @@ define([ 'base/js/keyboard', 'moment', 'bidi/bidi', -], function($, utils, dialog, keyboard, moment ,bidi) { +], function($, utils, dialog, keyboard, moment, bidi) { "use strict"; - bidi.loadLocale(bidi.uiLang()); + //bidi.loadLocale(); var SaveWidget = function (selector, options) { this.editor = undefined; this.selector = selector; @@ -149,19 +149,41 @@ define([ el.text('').attr('title', 'never saved'); return; } - var chkd = moment(this._last_modified); - var long_date = chkd.format('llll'); - var human_date; - var tdelta = Math.ceil(new Date() - this._last_modified); - if (tdelta < utils.time.milliseconds.d){ - // less than 24 hours old, use relative date - human_date = chkd.fromNow(); - } else { - // otherwise show calendar - // at hh,mm,ss - human_date = chkd.calendar(); - } - el.text(human_date).attr('title', long_date); + var date = this._last_modified; + /* if(bidi.getCalendarType() ==="hijri"){ + require(['moment-hijri'],function (moment_hijri){ + var chkd = moment_hijri(date); + var long_date = chkd.format('iYYYY-iMM-iDD HH:mm'); + var human_date; + var tdelta = Math.ceil(new Date() - date); + if (tdelta < utils.time.milliseconds.d){ + // less than 24 hours old, use relative date + human_date = chkd.fromNow(); + } else { + // otherwise show calendar + // at hh,mm,ss + human_date = chkd.calendar(); + } + el.text(human_date).attr('title', long_date); + + }); + } else {*/ + var chkd = moment(this._last_modified); + var long_date = chkd.format('llll'); + + var human_date; + var tdelta = Math.ceil(new Date() - this._last_modified); + if (tdelta < utils.time.milliseconds.d){ + // less than 24 hours old, use relative date + human_date = chkd.fromNow(); + } else { + // otherwise show calendar + // at hh,mm,ss + human_date = chkd.calendar(); + } + el.text(human_date).attr('title', long_date); + // } + }; SaveWidget.prototype._schedule_render_last_modified = function () { diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index 34b8230ef2..5b883c57fc 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -76,9 +76,8 @@ require([ try{ requirejs(['custom/custom'], function() {}); - bidi.loadLocale(bidi.uiLang()); - bidi.setNumericShaping("national"); - bidi.isMirroringEnabled(); + bidi.loadLocale(); + bidi.setUserPreferences("hijri", "national"); } catch(err) { console.log("Error processing custom.js. Logging and continuing"); console.warn(err); diff --git a/notebook/static/notebook/js/savewidget.js b/notebook/static/notebook/js/savewidget.js index a17d0b67a0..8f4f215050 100644 --- a/notebook/static/notebook/js/savewidget.js +++ b/notebook/static/notebook/js/savewidget.js @@ -177,7 +177,33 @@ define([ el.text('').attr('title', 'no checkpoint'); return; } - var chkd = moment(this._checkpoint_date); + var date = this._checkpoint_date; + /* if(bidi.getCalendarType() ==="hijri"){ + require(['moment-hijri'] ,function (moment){ + var chkd = moment(date); + var long_date = chkd.format('iYYYY-iMM-iDD HH:mm'); + var human_date; + var tdelta = Math.ceil(new Date() - date); + if (tdelta < utils.time.milliseconds.d){ + // less than 24 hours old, use relative date + human_date = chkd.fromNow(); + } else { + // otherwise show calendar + // at hh,mm,ss + human_date = chkd.calendar(); + } + el.text('Last Checkpoint: ' + human_date).attr('title', long_date); + }); + } + else{*/ + var d = bidi.applyBidi(this._checkpoint_date , bidi.flags.CALENDAR); + + var long_date = d.long_date; + var human_date =d.human_date; + el.text('Last Checkpoint: ' + human_date).attr('title', long_date); + +// } + /*var chkd = moment(this._checkpoint_date); var long_date = chkd.format('llll'); var human_date; var tdelta = Math.ceil(new Date() - this._checkpoint_date); @@ -189,7 +215,7 @@ define([ // at hh,mm,ss human_date = chkd.calendar(); } - el.text('Last Checkpoint: ' + human_date).attr('title', long_date); + el.text('Last Checkpoint: ' + human_date).attr('title', long_date);*/ }; diff --git a/notebook/static/notebook/less/commandpalette.less b/notebook/static/notebook/less/commandpalette.less index 28e738660f..32632336a2 100644 --- a/notebook/static/notebook/less/commandpalette.less +++ b/notebook/static/notebook/less/commandpalette.less @@ -3,6 +3,11 @@ ul.typeahead-list i{ width: 18px; } +[dir="rtl"] ul.typeahead-list i { + margin-left: 0; + margin-right: -10px; +} + ul.typeahead-list { max-height: 80vh; overflow:auto; @@ -14,6 +19,14 @@ ul.typeahead-list { } } +ul.typeahead-list & > li > a.pull-right { + .pull-left(); +} + +[dir="rtl"] .typeahead-list { + text-align : right; +} + .cmd-palette { & .modal-body{ padding: 7px; @@ -33,6 +46,14 @@ ul.typeahead-list { color: transparent; } +[dir="rtl"] .no-shortcut.pull-right{ + .pull-left(); +} + +[dir="rtl"] .command-shortcut.pull-right{ + .pull-left(); +} + .command-shortcut:before{ content:"(command mode)"; padding-right:3px; @@ -44,3 +65,7 @@ ul.typeahead-list { padding-right:3px; color:@gray-light; } + +[dir="rtl"] .edit-shortcut.pull-right { + float: left !important; +} diff --git a/notebook/static/notebook/less/kernelselector.less b/notebook/static/notebook/less/kernelselector.less index 33c68a34c2..ca94118c0f 100644 --- a/notebook/static/notebook/less/kernelselector.less +++ b/notebook/static/notebook/less/kernelselector.less @@ -8,3 +8,7 @@ height: 32px; } } + +[dir="rtl"] #kernel_logo_widget { + .pull-left(); +} \ No newline at end of file diff --git a/notebook/static/notebook/less/menubar.less b/notebook/static/notebook/less/menubar.less index 7f776c0355..8e74af3eaf 100644 --- a/notebook/static/notebook/less/menubar.less +++ b/notebook/static/notebook/less/menubar.less @@ -20,6 +20,36 @@ } +[dir="rtl"] #menubar { + .navbar-toggle { + float: right; + } +} + +[dir="rtl"] #menubar { + .navbar-collapse { + clear: right; + } + .navbar-nav { + float : right; + } + .nav { + padding-right : 0px; + } + .navbar-nav > li { + float: right; + } +} + +[dir="rtl"] ul.dropdown-menu { + text-align: right; + left : auto; +} + +[dir="rtl"] ul#new-menu.dropdown-menu { + right : auto; + left: 0; +} .nav-wrapper { border-bottom: 1px solid @navbar-default-border; } @@ -29,6 +59,10 @@ i.menu-icon { padding-top: 4px; } +[dir="rtl"] i.menu-icon.pull-right { + .pull-left(); +} + ul#help_menu li a{ overflow: hidden; padding-right: 2.2em; @@ -37,6 +71,18 @@ ul#help_menu li a{ } } +[dir="rtl"] ul#help_menu li a{ + padding-left : 2.2em; + i { + margin-right: 0; + margin-left : -1.2em; + } + + i.pull-right { + .pull-left(); + } +} + // Make sub menus work in BS3. // Credit: http://www.bootply.com/86684 .dropdown-submenu { @@ -50,6 +96,11 @@ ul#help_menu li a{ margin-left: -1px; } +[dir="rtl"] .dropdown-submenu>.dropdown-menu { + right:100%; + margin-right: -1px; +} + // arrow that indicate presence of submenu .dropdown-submenu:hover>.dropdown-menu { display: block; @@ -65,6 +116,13 @@ ul#help_menu li a{ margin-right: -10px; } +[dir="rtl"] .dropdown-submenu>a:after { + float: left; + content: @fa-var-caret-left; + margin-right : 0; + margin-left : -10px; +} + .dropdown-submenu:hover>a:after { color: @dropdown-link-hover-color; } diff --git a/notebook/static/notebook/less/notificationarea.less b/notebook/static/notebook/less/notificationarea.less index bfbf5b73f6..8f8b7566c9 100644 --- a/notebook/static/notebook/less/notificationarea.less +++ b/notebook/static/notebook/less/notificationarea.less @@ -3,6 +3,10 @@ z-index: 10; } +[dir="rtl"] #notification_area { + .pull-left(); +} + .indicator_area { .pull-right(); color: @navbar-default-link-color; @@ -14,6 +18,10 @@ width: auto; } +[dir="rtl"] .indicator_area { + .pull-left(); +} + #kernel_indicator { .indicator_area(); @@ -25,11 +33,21 @@ } } +[dir="rtl"] #kernel_indicator { + .pull-left(); + border-left: 0; + border-right : 1px solid; +} + #modal_indicator { .pull-right(); .indicator_area(); } +[dir="rtl"] #modal_indicator { + .pull-left(); +} + #readonly-indicator { .pull-right(); .indicator_area(); diff --git a/notebook/static/notebook/less/renderedhtml.less b/notebook/static/notebook/less/renderedhtml.less index bdc8cb07a8..4d5c8d4087 100644 --- a/notebook/static/notebook/less/renderedhtml.less +++ b/notebook/static/notebook/less/renderedhtml.less @@ -114,3 +114,10 @@ .alert {margin-bottom: initial;} * + .alert {margin-top: 1em;} } + +[dir="rtl"] .rendered_html { + p { + text-align : right; + } +} + diff --git a/notebook/static/notebook/less/savewidget.less b/notebook/static/notebook/less/savewidget.less index 889e7db37f..512e32ea9f 100644 --- a/notebook/static/notebook/less/savewidget.less +++ b/notebook/static/notebook/less/savewidget.less @@ -17,6 +17,17 @@ span.save_widget { } } +[dir="rtl"] span.save_widget.pull-left { + .pull-right(); +} + +[dir="rtl"] span.save_widget { + span.filename { + margin-left : 0; + margin-right : @padding-large-horizontal; + } +} + span.checkpoint_status, span.autosave_status { font-size: small; } diff --git a/notebook/static/notebook/less/toolbar.less b/notebook/static/notebook/less/toolbar.less index 743027436f..1224b76727 100644 --- a/notebook/static/notebook/less/toolbar.less +++ b/notebook/static/notebook/less/toolbar.less @@ -51,6 +51,9 @@ height: @btn_small_height; } +[dir="rtl"] .btn-group > .btn, .btn-group-vertical > .btn { + float: right; +} // highlight the new menu where celltoolbar is .pulse, .dropdown-menu > li > a.pulse, li.pulse > a.dropdown-toggle, li.pulse.open > a.dropdown-toggle { diff --git a/notebook/static/tree/js/main.js b/notebook/static/tree/js/main.js index 655e7d1533..03bbfcfbbd 100644 --- a/notebook/static/tree/js/main.js +++ b/notebook/static/tree/js/main.js @@ -55,17 +55,16 @@ require([ "use strict"; try{ requirejs(['custom/custom'], function() {}); - bidi.loadLocale(bidi.uiLang()); - bidi.setNumericShaping("national"); - bidi.setCalendarType("hijri"); - bidi.isMirroringEnabled(); + bidi.loadLocale(); + bidi.setUserPreferences("hijri", "national" ); } catch(err) { console.log("Error loading custom.js from tree service. Continuing and logging"); console.warn(err); } - console.log('Welcome to Project Jupyter! Explore the various tools available and their corresponding documentation. If you are interested in contributing to the platform, please visit the community resources section at http://jupyter.org/community.html.'); - + console.log('Welcome to Project Jupyter! Explore the various tools available and their corresponding documentation. If you are interested in contributing to the platform, please visit the community resources section at http://jupyter.org/community.html.'); + + // Setup all of the config related things var common_options = { diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index ff1e6b6094..9f175a3f50 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -10,7 +10,7 @@ define([ 'base/js/keyboard', 'moment', 'bidi/bidi', -], function($, IPython, utils, dialog, events, keyboard, moment , bidi) { +], function($, IPython, utils, dialog, events, keyboard, moment, bidi) { "use strict"; var NotebookList = function (selector, options) { @@ -700,12 +700,12 @@ define([ // Add in the date that the file was last modified item.find(".item_modified").text(utils.format_datetime(modified)); - if (bidi.getcalendarType()==="hijri"){ - require(['moment-hijri'],function (moment_hijri){ + if (true/*bidi.getCalendarType()==="hijri"*/){ require(['moment-hijri'],function (moment_hijri){ item.find(".item_modified").attr("title", moment_hijri(modified).format("iYYYY-iMM-iDD HH:mm")); }); - } - item.find(".item_modified").attr("title", moment(modified).format("YYYY-MM-DD HH:mm")); + }else{ + item.find(".item_modified").attr("title", moment(modified).format("YYYY-MM-DD HH:mm")); + } }; diff --git a/notebook/static/tree/js/sessionlist.js b/notebook/static/tree/js/sessionlist.js index 41b22aa590..65b6c94472 100644 --- a/notebook/static/tree/js/sessionlist.js +++ b/notebook/static/tree/js/sessionlist.js @@ -4,9 +4,11 @@ define([ 'jquery', 'base/js/utils', -], function($, utils) { + 'bidi/bidi', +], function($, utils, bidi) { "use strict"; + var isRTL = bidi.isMirroringEnabled(); var SesssionList = function (options) { /** * Constructor @@ -36,7 +38,7 @@ define([ // to do the animation (borderSpacing). $icon.animate({ borderSpacing: 90 }, { step: function(now,fx) { - $icon.css('transform','rotate(-' + now + 'deg)'); + isRTL ? $icon.css('transform','rotate(' + now + 'deg)') : $icon.css('transform','rotate(-' + now + 'deg)'); } }, 250); } else { @@ -44,7 +46,7 @@ define([ // See comment above. $icon.animate({ borderSpacing: 0 }, { step: function(now,fx) { - $icon.css('transform','rotate(-' + now + 'deg)'); + isRTL ? $icon.css('transform','rotate(' + now + 'deg)') : $icon.css('transform','rotate(-' + now + 'deg)'); } }, 250); } diff --git a/notebook/static/tree/less/tree.less b/notebook/static/tree/less/tree.less index faebeaf623..518dc72a67 100644 --- a/notebook/static/tree/less/tree.less +++ b/notebook/static/tree/less/tree.less @@ -25,6 +25,14 @@ ul#tabs a { padding-bottom: @dashboard_tb_pad; } +[dir="rtl"] ul#tabs.nav-tabs > li { + float : right; +} + +[dir="rtl"] ul#tabs.nav.nav-tabs { + padding-right: 0; +} + ul.breadcrumb { a:focus, a:hover { text-decoration: none; @@ -48,6 +56,15 @@ ul.breadcrumb { } } +[dir="rtl"] .list_toolbar { + .tree-buttons .pull-right { + .pull-left(); + } + .col-sm-4 , .col-sm-8 { + float : right; + } +} + .dynamic-buttons { padding-top: @dashboard_tb_pad - 1px; display: inline-block; @@ -121,6 +138,13 @@ ul.breadcrumb { } } +[dir="rtl"] .list_item>div { + + input { + margin-right : 0; + } +} + .new-file input[type=checkbox] { visibility: hidden; } @@ -144,6 +168,10 @@ ul.breadcrumb { margin-left: @dashboard_lr_pad; } +[dir="rtl"] .item_modified.pull-right{ + .pull-left(); +} + .item_buttons { line-height: 1em; .btn-toolbar(); @@ -162,6 +190,17 @@ ul.breadcrumb { } } +[dir="rtl"] .item_buttons.pull-right { + .pull-left(); +} + +[dir="rtl"] .item_buttons { + .kernel-name { + margin-left : @dashboard_lr_pad; + float : right; + } +} + .toolbar_info { height: @btn_small_height; line-height: @btn_small_height; @@ -198,6 +237,10 @@ ul.breadcrumb { padding-left: @dashboard_lr_pad; } +[dir="rtl"] .sort_button.pull-right { + .pull-left(); +} + #tree-selector { padding-right: 0px; } @@ -206,11 +249,19 @@ ul.breadcrumb { min-width: 50px; } +[dir="rtl"] #button-select-all.btn { + float : right ; +} + #select-all { margin-left: @dashboard_lr_pad; margin-right: 2px; } +[dir="rtl"] #select-all.pull-left { + .pull-right(); +} + .menu_icon { margin-right: 2px; } From 6f126382d7292868f2bf579ad3398924f057db4c Mon Sep 17 00:00:00 2001 From: samarsultan Date: Thu, 30 Mar 2017 12:45:58 +0200 Subject: [PATCH 06/19] tuning bidi support --- notebook/static/bidi/bidi.js | 28 ++++--------- notebook/static/bidi/nationalcalendar.js | 42 ------------------- notebook/static/edit/js/main.js | 2 +- notebook/static/edit/js/savewidget.js | 50 +++++++---------------- notebook/static/notebook/js/main.js | 3 +- notebook/static/notebook/js/savewidget.js | 35 +++------------- notebook/static/tree/js/main.js | 2 +- notebook/static/tree/js/notebooklist.js | 11 ++--- 8 files changed, 33 insertions(+), 140 deletions(-) delete mode 100644 notebook/static/bidi/nationalcalendar.js diff --git a/notebook/static/bidi/bidi.js b/notebook/static/bidi/bidi.js index 1760158ac5..21d7d7dcf6 100644 --- a/notebook/static/bidi/bidi.js +++ b/notebook/static/bidi/bidi.js @@ -3,8 +3,7 @@ define([ 'bidi/numericshaping', - 'bidi/nationalcalendar', -], function (numericshaping ,nationalcalendar){ +], function (numericshaping){ "use strict"; var shaperType=""; var textDir=""; @@ -13,17 +12,11 @@ define([ return calendarType; };*/ - var _setUserPreferences = function (calendartype, shapertype) { - nationalcalendar.setType(calendartype); + var _setUserPreferences = function (shapertype) { shaperType = shapertype; textDir = "rtl"; }; - - var _flags= { - NS: 1, - CALENDAR : 2 - }; - + var _uiLang= function (){ return navigator.language.toLowerCase(); }; @@ -35,6 +28,7 @@ define([ } requirejs(['components/moment/locale/'+_uiLang()], function (){}); }catch (err) { + return moment.locale(); console.log("Error loading the required locale"); console.warn(err); } @@ -44,22 +38,14 @@ define([ return (new RegExp("^(ar|he)").test(_uiLang())); }; - var _applyBidi = function (value , flag) { - if(flag & _flags.NS == _flags.NS) { - value = numericshaping.shapeNumerals(value, shaperType, textDir); - //return value; - } - else if(flag & _flags.CALENDAR == _flags.CALENDAR) { - value = nationalcalendar.formatDate(value); - console.log(value.long_date + " "+ value.human_date); - } + var _applyNumericShaping = function (value) { + value = numericshaping.shapeNumerals(value, shaperType, textDir); return value; }; var bidi = { setUserPreferences : _setUserPreferences, - flags : _flags, - applyBidi : _applyBidi, + applyNumericShaping : _applyNumericShaping, isMirroringEnabled : _isMirroringEnabled, loadLocale : _loadLocale, }; diff --git a/notebook/static/bidi/nationalcalendar.js b/notebook/static/bidi/nationalcalendar.js deleted file mode 100644 index 6001c79de1..0000000000 --- a/notebook/static/bidi/nationalcalendar.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Jupyter Development Team. -// Distributed under the terms of the Modified BSD License. - -define(['base/js/utils', - 'moment', - 'moment-hijri', - ], - function(utils, moment, moment_hijri ,bidi) { - "use strict"; - - var calendarType = ""; - - var setType = function (val) { - calendarType = val; - }; - - var formatDate = function (date){ - var chkd = moment(date); - var long_date = chkd.format('llll'); - var human_date; - var tdelta = Math.ceil(new Date() - date); - if (tdelta < utils.time.milliseconds.d){ - // less than 24 hours old, use relative date - human_date = chkd.fromNow(); - } else { - // otherwise show calendar - // at hh,mm,ss - human_date = chkd.calendar(); - } - return { - long_date : long_date, - human_date : human_date - }; - - } - - return{ - formatDate : formatDate, - setType : setType - }; - -}); diff --git a/notebook/static/edit/js/main.js b/notebook/static/edit/js/main.js index 4c2e2aa52c..e1aa99fe45 100644 --- a/notebook/static/edit/js/main.js +++ b/notebook/static/edit/js/main.js @@ -33,7 +33,7 @@ require([ try { requirejs(['custom/custom'], function() {}); bidi.loadLocale(); - bidi.setUserPreferences("hijri", "contextual"); + bidi.setUserPreferences("contextual"); } catch(err) { console.log("Error loading custom.js from edition service. Continuing and logging"); console.warn(err); diff --git a/notebook/static/edit/js/savewidget.js b/notebook/static/edit/js/savewidget.js index a9f93e5579..2f1f073229 100644 --- a/notebook/static/edit/js/savewidget.js +++ b/notebook/static/edit/js/savewidget.js @@ -109,7 +109,7 @@ define([ SaveWidget.prototype.update_filename = function (filename) { - filename = bidi.applyBidi(filename , bidi.flags.NS); + filename = bidi.applyNumericShaping(filename); this.element.find('span.filename').text(filename); }; @@ -148,42 +148,20 @@ define([ if (!this._last_modified) { el.text('').attr('title', 'never saved'); return; + } + var chkd = moment(this._last_modified); + var long_date = chkd.format('llll'); + var human_date; + var tdelta = Math.ceil(new Date() - this._last_modified); + if (tdelta < utils.time.milliseconds.d){ + // less than 24 hours old, use relative date + human_date = chkd.fromNow(); + } else { + // otherwise show calendar + // at hh,mm,ss + human_date = chkd.calendar(); } - var date = this._last_modified; - /* if(bidi.getCalendarType() ==="hijri"){ - require(['moment-hijri'],function (moment_hijri){ - var chkd = moment_hijri(date); - var long_date = chkd.format('iYYYY-iMM-iDD HH:mm'); - var human_date; - var tdelta = Math.ceil(new Date() - date); - if (tdelta < utils.time.milliseconds.d){ - // less than 24 hours old, use relative date - human_date = chkd.fromNow(); - } else { - // otherwise show calendar - // at hh,mm,ss - human_date = chkd.calendar(); - } - el.text(human_date).attr('title', long_date); - - }); - } else {*/ - var chkd = moment(this._last_modified); - var long_date = chkd.format('llll'); - - var human_date; - var tdelta = Math.ceil(new Date() - this._last_modified); - if (tdelta < utils.time.milliseconds.d){ - // less than 24 hours old, use relative date - human_date = chkd.fromNow(); - } else { - // otherwise show calendar - // at hh,mm,ss - human_date = chkd.calendar(); - } - el.text(human_date).attr('title', long_date); - // } - + el.text(human_date).attr('title', long_date); }; SaveWidget.prototype._schedule_render_last_modified = function () { diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index 5b883c57fc..9e323a2af7 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -77,7 +77,8 @@ require([ try{ requirejs(['custom/custom'], function() {}); bidi.loadLocale(); - bidi.setUserPreferences("hijri", "national"); + //bidi.setUserPreferences("hijri", "national"); + bidi.setUserPreferences("contextual"); } catch(err) { console.log("Error processing custom.js. Logging and continuing"); console.warn(err); diff --git a/notebook/static/notebook/js/savewidget.js b/notebook/static/notebook/js/savewidget.js index 8f4f215050..e0234d05e5 100644 --- a/notebook/static/notebook/js/savewidget.js +++ b/notebook/static/notebook/js/savewidget.js @@ -131,7 +131,7 @@ define([ SaveWidget.prototype.update_notebook_name = function () { var nbname = this.notebook.get_notebook_name(); - nbname = bidi.applyBidi(nbname , bidi.flags.NS); + nbname = bidi.applyNumericShaping(nbname); this.element.find('span.filename').text(nbname); }; @@ -177,33 +177,7 @@ define([ el.text('').attr('title', 'no checkpoint'); return; } - var date = this._checkpoint_date; - /* if(bidi.getCalendarType() ==="hijri"){ - require(['moment-hijri'] ,function (moment){ - var chkd = moment(date); - var long_date = chkd.format('iYYYY-iMM-iDD HH:mm'); - var human_date; - var tdelta = Math.ceil(new Date() - date); - if (tdelta < utils.time.milliseconds.d){ - // less than 24 hours old, use relative date - human_date = chkd.fromNow(); - } else { - // otherwise show calendar - // at hh,mm,ss - human_date = chkd.calendar(); - } - el.text('Last Checkpoint: ' + human_date).attr('title', long_date); - }); - } - else{*/ - var d = bidi.applyBidi(this._checkpoint_date , bidi.flags.CALENDAR); - - var long_date = d.long_date; - var human_date =d.human_date; - el.text('Last Checkpoint: ' + human_date).attr('title', long_date); - -// } - /*var chkd = moment(this._checkpoint_date); + var chkd = moment(this._checkpoint_date); var long_date = chkd.format('llll'); var human_date; var tdelta = Math.ceil(new Date() - this._checkpoint_date); @@ -211,11 +185,12 @@ define([ // less than 24 hours old, use relative date human_date = chkd.fromNow(); } else { - // otherwise show calendar + // otherwise show calendar // at hh,mm,ss human_date = chkd.calendar(); } - el.text('Last Checkpoint: ' + human_date).attr('title', long_date);*/ + el.text('Last Checkpoint: ' + human_date).attr('title', long_date); + }; diff --git a/notebook/static/tree/js/main.js b/notebook/static/tree/js/main.js index 03bbfcfbbd..2110aad2c7 100644 --- a/notebook/static/tree/js/main.js +++ b/notebook/static/tree/js/main.js @@ -56,7 +56,7 @@ require([ try{ requirejs(['custom/custom'], function() {}); bidi.loadLocale(); - bidi.setUserPreferences("hijri", "national" ); + bidi.setUserPreferences("contextual" ); } catch(err) { console.log("Error loading custom.js from tree service. Continuing and logging"); console.warn(err); diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index 9f175a3f50..99ab0e89af 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -644,7 +644,7 @@ define([ select_all.data('indeterminate', true); } // Update total counter - checked = bidi.applyBidi(checked , bidi.flags.NS); + checked = bidi.applyNumericShaping(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.applyBidi(name , bidi.flags.NS); + name = bidi.applyNumericShaping(name); item.data('name', name); item.data('path', path); item.data('modified', modified); @@ -700,12 +700,7 @@ define([ // Add in the date that the file was last modified item.find(".item_modified").text(utils.format_datetime(modified)); - if (true/*bidi.getCalendarType()==="hijri"*/){ require(['moment-hijri'],function (moment_hijri){ - item.find(".item_modified").attr("title", moment_hijri(modified).format("iYYYY-iMM-iDD HH:mm")); - }); - }else{ - item.find(".item_modified").attr("title", moment(modified).format("YYYY-MM-DD HH:mm")); - } + item.find(".item_modified").attr("title", moment(modified).format("YYYY-MM-DD HH:mm")); }; From a87528ca22b643a81c29bc5e5cedca6e7e927198 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Thu, 30 Mar 2017 12:47:39 +0200 Subject: [PATCH 07/19] tuning rtl mode --- notebook/static/notebook/less/menubar.less | 3 +++ 1 file changed, 3 insertions(+) diff --git a/notebook/static/notebook/less/menubar.less b/notebook/static/notebook/less/menubar.less index 8e74af3eaf..414557aee4 100644 --- a/notebook/static/notebook/less/menubar.less +++ b/notebook/static/notebook/less/menubar.less @@ -39,6 +39,9 @@ .navbar-nav > li { float: right; } + .navbar-right { + float : left !important; + } } [dir="rtl"] ul.dropdown-menu { From 2d0be3560f4e403c720a4923f7c61bb37346a6b1 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 2 Apr 2017 12:50:06 +0200 Subject: [PATCH 08/19] Tuning bidi support --- notebook/static/bidi/bidi.js | 50 ++++++++++++++--------- notebook/static/edit/js/main.js | 2 +- notebook/static/edit/js/savewidget.js | 4 +- notebook/static/notebook/js/main.js | 3 +- notebook/static/notebook/js/savewidget.js | 4 +- notebook/static/tree/js/main.js | 2 +- notebook/static/tree/js/notebooklist.js | 4 +- 7 files changed, 39 insertions(+), 30 deletions(-) diff --git a/notebook/static/bidi/bidi.js b/notebook/static/bidi/bidi.js index 21d7d7dcf6..d82fd1c1dd 100644 --- a/notebook/static/bidi/bidi.js +++ b/notebook/static/bidi/bidi.js @@ -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, }; diff --git a/notebook/static/edit/js/main.js b/notebook/static/edit/js/main.js index e1aa99fe45..7a8a8a4f5f 100644 --- a/notebook/static/edit/js/main.js +++ b/notebook/static/edit/js/main.js @@ -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); diff --git a/notebook/static/edit/js/savewidget.js b/notebook/static/edit/js/savewidget.js index 2f1f073229..60c1d581f1 100644 --- a/notebook/static/edit/js/savewidget.js +++ b/notebook/static/edit/js/savewidget.js @@ -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); }; diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index 9e323a2af7..67999bed4e 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -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); diff --git a/notebook/static/notebook/js/savewidget.js b/notebook/static/notebook/js/savewidget.js index e0234d05e5..e62bb2b672 100644 --- a/notebook/static/notebook/js/savewidget.js +++ b/notebook/static/notebook/js/savewidget.js @@ -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); }; diff --git a/notebook/static/tree/js/main.js b/notebook/static/tree/js/main.js index 2110aad2c7..87adf57a01 100644 --- a/notebook/static/tree/js/main.js +++ b/notebook/static/tree/js/main.js @@ -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); diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index 99ab0e89af..62421f101a 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -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); From f21969d72447f9a5e44fd45e4a5613656fd169f4 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 2 Apr 2017 13:06:49 +0200 Subject: [PATCH 09/19] tuning rtl mode style for login page --- notebook/static/auth/less/login.less | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/notebook/static/auth/less/login.less b/notebook/static/auth/less/login.less index 0091d8c8b9..8a4ce3ffcb 100644 --- a/notebook/static/auth/less/login.less +++ b/notebook/static/auth/less/login.less @@ -5,7 +5,7 @@ margin-bottom: -4px; } -/*[dir="rtl"] .center-nav { +[dir="rtl"] .center-nav { form.pull-left { .pull-right(); } @@ -13,19 +13,11 @@ float: right; } } -*/ + [dir="rtl"] .navbar-inner { text-align: right; } -[dir="rtl"] p .navbar-text { - float: right; -} - [dir="rtl"] div.text-left { .text-right(); } - -/*[dir ="rtl"] #ipython-main-app { - text-align: right; -}*/ From e112142810693433da56bc6a16936d7b00e93ece Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 2 Apr 2017 13:22:00 +0200 Subject: [PATCH 10/19] tuning rtl mode style for commanpalette window --- notebook/static/notebook/less/commandpalette.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/static/notebook/less/commandpalette.less b/notebook/static/notebook/less/commandpalette.less index 32632336a2..7c4069ed11 100644 --- a/notebook/static/notebook/less/commandpalette.less +++ b/notebook/static/notebook/less/commandpalette.less @@ -67,5 +67,5 @@ ul.typeahead-list & > li > a.pull-right { } [dir="rtl"] .edit-shortcut.pull-right { - float: left !important; + .pull-left(); } From 29ce7dea3b5c70e0d94a688ebb013cb8598a73b5 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 2 Apr 2017 13:34:14 +0200 Subject: [PATCH 11/19] tuning code style --- notebook/static/custom/custom.css | 2 +- notebook/static/notebook/less/kernelselector.less | 2 +- notebook/static/tree/js/main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/notebook/static/custom/custom.css b/notebook/static/custom/custom.css index 6f3283861f..b8367c9135 100644 --- a/notebook/static/custom/custom.css +++ b/notebook/static/custom/custom.css @@ -18,4 +18,4 @@ This will always be an empty file in IPython [dir="rtl"] .fa-step-forward::before { content: "\f048"; -} \ No newline at end of file +} diff --git a/notebook/static/notebook/less/kernelselector.less b/notebook/static/notebook/less/kernelselector.less index ca94118c0f..9cd552dd4d 100644 --- a/notebook/static/notebook/less/kernelselector.less +++ b/notebook/static/notebook/less/kernelselector.less @@ -11,4 +11,4 @@ [dir="rtl"] #kernel_logo_widget { .pull-left(); -} \ No newline at end of file +} diff --git a/notebook/static/tree/js/main.js b/notebook/static/tree/js/main.js index 87adf57a01..ec906d144f 100644 --- a/notebook/static/tree/js/main.js +++ b/notebook/static/tree/js/main.js @@ -61,7 +61,7 @@ require([ console.log("Error loading custom.js from tree service. Continuing and logging"); console.warn(err); } - + console.log('Welcome to Project Jupyter! Explore the various tools available and their corresponding documentation. If you are interested in contributing to the platform, please visit the community resources section at http://jupyter.org/community.html.'); From b5258c32f9498cbc437db37f78628d507bdd6aa2 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Sun, 2 Apr 2017 13:46:22 +0200 Subject: [PATCH 12/19] removing moment-hijri path --- tools/build-main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/build-main.js b/tools/build-main.js index c568102524..44b5b70133 100644 --- a/tools/build-main.js +++ b/tools/build-main.js @@ -20,7 +20,6 @@ var rjs_config = { bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min', "jquery-ui": 'components/jquery-ui/ui/minified/jquery-ui.min', moment: 'components/moment/moment', - "moment-hijri": 'components/moment-hijri/moment-hijri', codemirror: 'components/codemirror', xterm: 'components/xterm.js/dist/xterm', typeahead: 'components/jquery-typeahead/dist/jquery.typeahead', From 7fee8447fa2d94f9a81ce8c73e22151bbc8ac8ad Mon Sep 17 00:00:00 2001 From: Samar Sultan Date: Sun, 2 Apr 2017 14:47:41 +0200 Subject: [PATCH 13/19] Update notebooklist.js --- notebook/static/tree/js/notebooklist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index 62421f101a..be940522fb 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -700,7 +700,7 @@ define([ // Add in the date that the file was last modified item.find(".item_modified").text(utils.format_datetime(modified)); - item.find(".item_modified").attr("title", moment(modified).format("YYYY-MM-DD HH:mm")); + item.find(".item_modified").attr("title", moment(modified).format("YYYY-MM-DD HH:mm")); }; From ca244e79869fd09ba5e81ffe67a17c0ef142944f Mon Sep 17 00:00:00 2001 From: Samar Sultan Date: Sun, 2 Apr 2017 14:49:48 +0200 Subject: [PATCH 14/19] Update savewidget.js --- notebook/static/edit/js/savewidget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/static/edit/js/savewidget.js b/notebook/static/edit/js/savewidget.js index 60c1d581f1..38f7fa8511 100644 --- a/notebook/static/edit/js/savewidget.js +++ b/notebook/static/edit/js/savewidget.js @@ -148,7 +148,7 @@ define([ if (!this._last_modified) { el.text('').attr('title', 'never saved'); return; - } + } var chkd = moment(this._last_modified); var long_date = chkd.format('llll'); var human_date; From 3e0c87d12a412600de6d330e74ae8ea19a700caf Mon Sep 17 00:00:00 2001 From: samarsultan Date: Tue, 1 Aug 2017 16:33:53 +0200 Subject: [PATCH 15/19] tuning code style --- notebook/nbconvert/handlers.py | 4 ++-- notebook/notebookapp.py | 24 +++++++++++++------ notebook/static/notebook/js/outputarea.js | 29 +++++++++++++++++++---- notebook/static/notebook/js/savewidget.js | 1 + 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/notebook/nbconvert/handlers.py b/notebook/nbconvert/handlers.py index 4dd5352cc6..648c9827f8 100644 --- a/notebook/nbconvert/handlers.py +++ b/notebook/nbconvert/handlers.py @@ -58,12 +58,12 @@ def get_exporter(format, **kwargs): """get an exporter, raising appropriate errors""" # if this fails, will raise 500 try: - from nbconvert.exporters.export import exporter_map + from nbconvert.exporters.base import get_exporter except ImportError as e: raise web.HTTPError(500, "Could not import nbconvert: %s" % e) try: - Exporter = exporter_map[format] + Exporter = get_exporter(format) except KeyError: # should this be 400? raise web.HTTPError(404, u"No exporter for format: %s" % format) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 132aa4ddf2..97599f276f 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -389,21 +389,31 @@ class NbserverListApp(JupyterApp): description=_("List currently running notebook servers.") flags = dict( + jsonlist=({'NbserverListApp': {'jsonlist': True}}, + _("Produce machine-readable JSON list output.")), json=({'NbserverListApp': {'json': True}}, - _("Produce machine-readable JSON output.")), + _("Produce machine-readable JSON object on each line of output.")), ) + jsonlist = Bool(False, config=True, + help=_("If True, the output will be a JSON list of objects, one per " + "active notebook server, each with the details from the " + "relevant server info file.")) json = Bool(False, config=True, help=_("If True, each line of output will be a JSON object with the " - "details from the server info file.")) + "details from the server info file. For a JSON list output, " + "see the NbserverListApp.jsonlist configuration value")) def start(self): - if not self.json: - print(_("Currently running servers:")) - for serverinfo in list_running_servers(self.runtime_dir): - if self.json: + serverinfo_list = list(list_running_servers(self.runtime_dir)) + if self.jsonlist: + print(json.dumps(serverinfo_list, indent=2)) + elif self.json: + for serverinfo in serverinfo_list: print(json.dumps(serverinfo)) - else: + else: + print("Currently running servers:") + for serverinfo in serverinfo_list: url = serverinfo['url'] if serverinfo.get('token'): url = url + '?token=%s' % serverinfo['token'] diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index ef83fea5b6..872c1987f4 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -77,7 +77,6 @@ define([ OutputArea.prototype.style = function () { this.collapse_button.hide(); - this.prompt_overlay.hide(); this.wrapper.addClass('output_wrapper'); this.element.addClass('output'); @@ -263,6 +262,7 @@ define([ var MIME_SVG = 'image/svg+xml'; var MIME_PNG = 'image/png'; var MIME_JPEG = 'image/jpeg'; + var MIME_GIF = 'image/gif'; var MIME_PDF = 'application/pdf'; var MIME_TEXT = 'text/plain'; @@ -275,6 +275,7 @@ define([ MIME_SVG, MIME_PNG, MIME_JPEG, + MIME_GIF, MIME_PDF, MIME_TEXT, ]; @@ -660,6 +661,7 @@ define([ OutputArea.safe_outputs[MIME_LATEX] = true; OutputArea.safe_outputs[MIME_PNG] = true; OutputArea.safe_outputs[MIME_JPEG] = true; + OutputArea.safe_outputs[MIME_GIF] = true; OutputArea.prototype.append_mime_type = function (json, element, handle_inserted) { for (var i=0; i < OutputArea.display_order.length; i++) { @@ -683,7 +685,7 @@ define([ // callback, if the mime type is something other we must call the // inserted callback only when the element is actually inserted // into the DOM. Use a timeout of 0 to do this. - if ([MIME_PNG, MIME_JPEG].indexOf(type) < 0 && handle_inserted !== undefined) { + if ([MIME_PNG, MIME_JPEG, MIME_GIF].indexOf(type) < 0 && handle_inserted !== undefined) { setTimeout(handle_inserted, 0); } this.events.trigger('output_appended.OutputArea', [type, value, md, toinsert]); @@ -822,7 +824,7 @@ define([ }); } img[0].src = 'data:image/png;base64,'+ png; - set_width_height(img, md, MIME_PNG); + set_width_height(img, md, type); dblclick_to_reset_size(img); toinsert.append(img); element.append(toinsert); @@ -840,7 +842,24 @@ define([ }); } img[0].src = 'data:image/jpeg;base64,'+ jpeg; - set_width_height(img, md, MIME_JPEG); + set_width_height(img, md, type); + dblclick_to_reset_size(img); + toinsert.append(img); + element.append(toinsert); + return toinsert; + }; + + var append_gif = function (gif, md, element, handle_inserted) { + var type = MIME_GIF; + var toinsert = this.create_output_subarea(md, "output_gif", type); + var img = $(""); + if (handle_inserted !== undefined) { + img.on('load', function(){ + handle_inserted(img); + }); + } + img[0].src = 'data:image/gif;base64,'+ gif; + set_width_height(img, md, type); dblclick_to_reset_size(img); toinsert.append(img); element.append(toinsert); @@ -1073,6 +1092,7 @@ define([ MIME_SVG, MIME_PNG, MIME_JPEG, + MIME_GIF, MIME_PDF, MIME_TEXT ]; @@ -1084,6 +1104,7 @@ define([ OutputArea.append_map[MIME_SVG] = append_svg; OutputArea.append_map[MIME_PNG] = append_png; OutputArea.append_map[MIME_JPEG] = append_jpeg; + OutputArea.append_map[MIME_GIF] = append_gif; OutputArea.append_map[MIME_LATEX] = append_latex; OutputArea.append_map[MIME_JAVASCRIPT] = append_javascript; OutputArea.append_map[MIME_PDF] = append_pdf; diff --git a/notebook/static/notebook/js/savewidget.js b/notebook/static/notebook/js/savewidget.js index 2ab6019db1..39c64a188a 100644 --- a/notebook/static/notebook/js/savewidget.js +++ b/notebook/static/notebook/js/savewidget.js @@ -192,6 +192,7 @@ define([ // at hh,mm,ss human_date = chkd.calendar(); } + el.text(i18n.msg.sprintf(i18n.msg._('Last Checkpoint: %s'),human_date)).attr('title', long_date); }; From 142b74b019f1802425f7b6569de5b4986893b85c Mon Sep 17 00:00:00 2001 From: samarsultan Date: Tue, 1 Aug 2017 16:37:30 +0200 Subject: [PATCH 16/19] 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 d82fd1c1dd..bd7118d147 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 5ac272b3d7..d78ec0d0df 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 }; From c4385ebcb3e9b1cde66e353bd64138d7afd566af Mon Sep 17 00:00:00 2001 From: samarsultan Date: Tue, 1 Aug 2017 16:41:47 +0200 Subject: [PATCH 17/19] removing setUserPreference function --- notebook/static/edit/js/main.js | 1 - notebook/static/notebook/js/main.js | 1 - notebook/static/tree/js/main.js | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/notebook/static/edit/js/main.js b/notebook/static/edit/js/main.js index 6f523d8771..9b2a2cb682 100644 --- a/notebook/static/edit/js/main.js +++ b/notebook/static/edit/js/main.js @@ -33,7 +33,6 @@ require([ try { requirejs(['custom/custom'], function() {}); bidi.loadLocale(); - 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); diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index a8705a1c4e..2e64d3cdc8 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -77,7 +77,6 @@ require([ try{ requirejs(['custom/custom'], function() {}); bidi.loadLocale(); - bidi.setUserPreferences(/*"contextual"*/); //waiting for user input here } catch(err) { console.log("Error processing custom.js. Logging and continuing"); console.warn(err); diff --git a/notebook/static/tree/js/main.js b/notebook/static/tree/js/main.js index 09a65e8188..44cb7e2008 100644 --- a/notebook/static/tree/js/main.js +++ b/notebook/static/tree/js/main.js @@ -53,10 +53,10 @@ require([ loginwidget, bidi){ "use strict"; + try{ requirejs(['custom/custom'], function() {}); bidi.loadLocale(); - 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); From 048befc311f1351c1ae928c101e36d05d63ba374 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Tue, 1 Aug 2017 17:03:00 +0200 Subject: [PATCH 18/19] update savewidget.js --- notebook/static/edit/js/savewidget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/static/edit/js/savewidget.js b/notebook/static/edit/js/savewidget.js index f7dd92b2a6..6154100998 100644 --- a/notebook/static/edit/js/savewidget.js +++ b/notebook/static/edit/js/savewidget.js @@ -10,7 +10,7 @@ define([ 'bidi/bidi', ], function($, utils, dialog, keyboard, moment, bidi) { "use strict"; - bidi.loadLocale(); + var SaveWidget = function (selector, options) { this.editor = undefined; this.selector = selector; From 28fcc7bffd4cef97cc6346a8629301142951e785 Mon Sep 17 00:00:00 2001 From: samarsultan Date: Tue, 1 Aug 2017 17:03:42 +0200 Subject: [PATCH 19/19] update notebooklist.js --- notebook/static/tree/js/notebooklist.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index ba28ac762f..49e73b7206 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -10,8 +10,7 @@ define([ 'base/js/events', 'base/js/keyboard', 'moment', - 'bidi/bidi', - 'moment' + 'bidi/bidi' ], function($, IPython, utils, i18n, dialog, events, keyboard, moment, bidi) { "use strict"; @@ -717,11 +716,11 @@ define([ NotebookList.prototype.add_link = function (model, item) { var running = (model.type === 'notebook' && this.sessions[model.path] !== undefined); - item.data('name', bidi.applyBidi(model.name)); + item.data('name',model.name); item.data('path', model.path); item.data('modified', model.last_modified); item.data('type', model.type); - item.find(".item_name").text(model.name); + item.find(".item_name").text(bidi.applyBidi(model.name)); var icon = NotebookList.icons[model.type]; if (running) { icon = 'running_' + icon;