File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ define(['bidi/numericshaping'], function(numericshaping) {
1313 var _loadLocale = function ( ) {
1414 if ( _isMirroringEnabled ( ) ) {
1515 document . body . dir = 'rtl' ;
16+ } else {
17+ document . body . dir = 'ltr' ;
1618 }
1719
1820 requirejs ( [ 'moment' ] , function ( moment ) {
@@ -23,7 +25,9 @@ define(['bidi/numericshaping'], function(numericshaping) {
2325 } ;
2426
2527 var _isMirroringEnabled = function ( ) {
26- return new RegExp ( '^(ar|he)' ) . test ( _uiLang ( ) ) ;
28+ if ( ! IPython . notebook || ! IPython . notebook . metadata . direction )
29+ return new RegExp ( '^(ar|he)' ) . test ( _uiLang ( ) ) ;
30+ return ( IPython . notebook . metadata . direction == 'rtl' ) ;
2731 } ;
2832
2933 /**
Original file line number Diff line number Diff line change @@ -68,8 +68,11 @@ define([
6868 'toggle-rtl-layout' : {
6969 cmd : i18n . msg . _ ( 'toggle rtl layout' ) ,
7070 help : i18n . msg . _ ( 'Toggle the screen directionality between left-to-right and right-to-left' ) ,
71- handler : function ( ) {
72- ( document . body . getAttribute ( 'dir' ) == 'rtl' ) ? document . body . setAttribute ( 'dir' , 'ltr' ) : document . body . setAttribute ( 'dir' , 'rtl' ) ;
71+ handler : function ( env ) {
72+ var new_direction = document . body . getAttribute ( 'dir' ) == 'rtl' ? 'ltr' : 'rtl' ;
73+ document . body . setAttribute ( 'dir' , new_direction ) ;
74+ env . notebook . metadata . direction = new_direction ;
75+ env . notebook . set_dirty ( true ) ;
7376 }
7477 } ,
7578 'edit-command-mode-keyboard-shortcuts' : {
Original file line number Diff line number Diff line change @@ -77,14 +77,6 @@ requirejs([
7777
7878 // Pull typeahead from the global jquery object
7979 var typeahead = $ . typeahead ;
80-
81- try {
82- requirejs ( [ 'custom/custom' ] , function ( ) { } ) ;
83- bidi . loadLocale ( ) ;
84- } catch ( err ) {
85- console . log ( "Error processing custom.js. Logging and continuing" ) ;
86- console . warn ( err ) ;
87- }
8880
8981 // compat with old IPython, remove for IPython > 3.0
9082 window . CodeMirror = CodeMirror ;
@@ -238,4 +230,14 @@ requirejs([
238230
239231 notebook . load_notebook ( common_options . notebook_path ) ;
240232
233+ notebook . events . on ( 'notebook_loaded.Notebook' , function ( ) {
234+ try {
235+ requirejs ( [ 'custom/custom' ] , function ( ) { } ) ;
236+ bidi . loadLocale ( ) ;
237+ } catch ( err ) {
238+ console . log ( "Error processing custom.js. Logging and continuing" ) ;
239+ console . warn ( err ) ;
240+ }
241+ } ) ;
242+
241243} ) ;
You can’t perform that action at this time.
0 commit comments