##// END OF EJS Templates
DEBUG...
Jonathan Frederic -
Show More
@@ -147,23 +147,31 b' var IPython = (function (IPython) {'
147 }
147 }
148 if (this.code_mirror) {
148 if (this.code_mirror) {
149 this.code_mirror.on('focus', function(cm, change) {
149 this.code_mirror.on('focus', function(cm, change) {
150 $([IPython.events]).trigger('edit_mode.Cell', {cell: that});
150 console.log('cell focused');
151 if (that._continue_blur) {
152 that._continue_blur = false;
153 } else {
154 if (that.mode === 'command') {
155 $([IPython.events]).trigger('edit_mode.Cell', {cell: that});
156 }
157 }
151 });
158 });
152 }
159 }
153 if (this.code_mirror) {
160 if (this.code_mirror) {
154 this.code_mirror.on('blur', function(cm, change) {
161 this.code_mirror.on('blur', function(cm, change) {
155 if (that.mode === 'edit') {
162 console.log('cell blur');
156 setTimeout(function () {
163 that._continue_blur = true;
164 setTimeout($.proxy(function () {
165 if (that._continue_blur) {
166 console.log('cell blur> edit true> callback');
157 var isf = IPython.utils.is_focused;
167 var isf = IPython.utils.is_focused;
158 var trigger = true;
168 if (! (isf('div#tooltip') || isf('div.completions'))) {
159 if (isf('div#tooltip') || isf('div.completions')) {
169 if (that.mode === 'edit') {
160 trigger = false;
170 $([IPython.events]).trigger('command_mode.Cell', {cell: that});
161 }
171 }
162 if (trigger) {
163 $([IPython.events]).trigger('command_mode.Cell', {cell: that});
164 }
172 }
165 }, 1);
173 }
166 }
174 }, that), 1);
167 });
175 });
168 }
176 }
169 };
177 };
@@ -725,29 +725,35 b' var IPython = (function (IPython) {'
725 };
725 };
726
726
727 KeyboardManager.prototype.edit_mode = function () {
727 KeyboardManager.prototype.edit_mode = function () {
728 console.log('kb edit');
728 this.last_mode = this.mode;
729 this.last_mode = this.mode;
729 this.mode = 'edit';
730 this.mode = 'edit';
730 };
731 };
731
732
732 KeyboardManager.prototype.command_mode = function () {
733 KeyboardManager.prototype.command_mode = function () {
734 console.log('kb command');
733 this.last_mode = this.mode;
735 this.last_mode = this.mode;
734 this.mode = 'command';
736 this.mode = 'command';
735 };
737 };
736
738
737 KeyboardManager.prototype.enable = function () {
739 KeyboardManager.prototype.enable = function () {
740 console.log('kb enable');
738 this.enabled = true;
741 this.enabled = true;
739 };
742 };
740
743
741 KeyboardManager.prototype.disable = function () {
744 KeyboardManager.prototype.disable = function () {
745 console.log('kb disable');
742 this.enabled = false;
746 this.enabled = false;
743 };
747 };
744
748
745 KeyboardManager.prototype.register_events = function (e) {
749 KeyboardManager.prototype.register_events = function (e) {
746 var that = this;
750 var that = this;
747 e.on('focusin', function () {
751 e.on('focusin', function () {
752 console.log('kb focus in');
748 that.disable();
753 that.disable();
749 });
754 });
750 e.on('focusout', function () {
755 e.on('focusout', function () {
756 console.log('kb focus out');
751 that.enable();
757 that.enable();
752 });
758 });
753 // There are times (raw_input) where we remove the element from the DOM before
759 // There are times (raw_input) where we remove the element from the DOM before
@@ -755,6 +761,7 b' var IPython = (function (IPython) {'
755 // which gets triggered upon removal, iff it is focused at the time.
761 // which gets triggered upon removal, iff it is focused at the time.
756 e.on('remove', function () {
762 e.on('remove', function () {
757 if (document.activeElement === e[0]) {
763 if (document.activeElement === e[0]) {
764 console.log('kb remove');
758 that.enable();
765 that.enable();
759 }
766 }
760 });
767 });
@@ -116,12 +116,18 b' var IPython = (function (IPython) {'
116 });
116 });
117
117
118 $([IPython.events]).on('edit_mode.Cell', function (event, data) {
118 $([IPython.events]).on('edit_mode.Cell', function (event, data) {
119 console.log('edit mode cell');
119 var index = that.find_cell_index(data.cell);
120 var index = that.find_cell_index(data.cell);
120 that.select(index);
121 that.select(index);
121 that.edit_mode();
122 that.edit_mode();
122 });
123 });
123
124
124 $([IPython.events]).on('command_mode.Cell', function (event, data) {
125 $([IPython.events]).on('command_mode.Cell', function (event, data) {
126 console.log('command mode cell');
127 // In Firefox the focus event is called before the blur event. In
128 // other words, two cells elements may be focused at any given time.
129 // Here we verify that no cells are currently in edit mode before
130 // putting the entire notebook in command mode.
125 that.command_mode();
131 that.command_mode();
126 });
132 });
127
133
@@ -459,7 +465,6 b' var IPython = (function (IPython) {'
459 if (this.is_valid_cell_index(index)) {
465 if (this.is_valid_cell_index(index)) {
460 var sindex = this.get_selected_index();
466 var sindex = this.get_selected_index();
461 if (sindex !== null && index !== sindex) {
467 if (sindex !== null && index !== sindex) {
462 this.command_mode();
463 this.get_cell(sindex).unselect();
468 this.get_cell(sindex).unselect();
464 }
469 }
465 var cell = this.get_cell(index);
470 var cell = this.get_cell(index);
@@ -515,6 +520,7 b' var IPython = (function (IPython) {'
515 };
520 };
516
521
517 Notebook.prototype.command_mode = function () {
522 Notebook.prototype.command_mode = function () {
523 console.log('cell.command_mode');
518 if (this.mode !== 'command') {
524 if (this.mode !== 'command') {
519 $([IPython.events]).trigger('command_mode.Notebook');
525 $([IPython.events]).trigger('command_mode.Notebook');
520 var index = this.get_edit_index();
526 var index = this.get_edit_index();
@@ -528,6 +534,7 b' var IPython = (function (IPython) {'
528 };
534 };
529
535
530 Notebook.prototype.edit_mode = function () {
536 Notebook.prototype.edit_mode = function () {
537 console.log('cell.edit_mode');
531 if (this.mode !== 'edit') {
538 if (this.mode !== 'edit') {
532 $([IPython.events]).trigger('edit_mode.Notebook');
539 $([IPython.events]).trigger('edit_mode.Notebook');
533 var cell = this.get_selected_cell();
540 var cell = this.get_selected_cell();
@@ -1402,6 +1409,7 b' var IPython = (function (IPython) {'
1402 var cell = this.get_selected_cell();
1409 var cell = this.get_selected_cell();
1403 var cell_index = this.find_cell_index(cell);
1410 var cell_index = this.find_cell_index(cell);
1404
1411
1412 console.log('execute cell command_mode');
1405 cell.execute();
1413 cell.execute();
1406 this.command_mode();
1414 this.command_mode();
1407 cell.focus_cell();
1415 cell.focus_cell();
@@ -1923,6 +1931,7 b' var IPython = (function (IPython) {'
1923 */
1931 */
1924 Notebook.prototype.load_notebook_success = function (data, status, xhr) {
1932 Notebook.prototype.load_notebook_success = function (data, status, xhr) {
1925 this.fromJSON(data);
1933 this.fromJSON(data);
1934 console.log('load notebook success');
1926 if (this.ncells() === 0) {
1935 if (this.ncells() === 0) {
1927 this.insert_cell_below('code');
1936 this.insert_cell_below('code');
1928 this.select(0);
1937 this.select(0);
General Comments 0
You need to be logged in to leave comments. Login now