Show More
@@ -198,9 +198,22 b' define([' | |||||
198 | Cell.prototype.handle_codemirror_keyevent = function (editor, event) { |
|
198 | Cell.prototype.handle_codemirror_keyevent = function (editor, event) { | |
199 | var shortcuts = this.keyboard_manager.edit_shortcuts; |
|
199 | var shortcuts = this.keyboard_manager.edit_shortcuts; | |
200 |
|
200 | |||
|
201 | var cur = editor.getCursor(); | |||
|
202 | if((cur.line !== 0 || cur.ch !==0) && event.keyCode === 38){ | |||
|
203 | event._ipkmIgnore = true; | |||
|
204 | } | |||
|
205 | var nLastLine = editor.lastLine() | |||
|
206 | if( ( event.keyCode === 40) | |||
|
207 | && (( cur.line !== nLastLine) | |||
|
208 | || ( cur.ch !== editor.getLineHandle(nLastLine).text.length)) | |||
|
209 | ){ | |||
|
210 | event._ipkmIgnore = true; | |||
|
211 | } | |||
201 | // if this is an edit_shortcuts shortcut, the global keyboard/shortcut |
|
212 | // if this is an edit_shortcuts shortcut, the global keyboard/shortcut | |
202 | // manager will handle it |
|
213 | // manager will handle it | |
203 |
if (shortcuts.handles(event)) { |
|
214 | if (shortcuts.handles(event)) { | |
|
215 | return true; | |||
|
216 | } | |||
204 |
|
217 | |||
205 | return false; |
|
218 | return false; | |
206 | }; |
|
219 | }; | |
@@ -291,7 +304,6 b' define([' | |||||
291 | * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise |
|
304 | * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise | |
292 | */ |
|
305 | */ | |
293 | Cell.prototype.handle_keyevent = function (editor, event) { |
|
306 | Cell.prototype.handle_keyevent = function (editor, event) { | |
294 |
|
||||
295 | if (this.mode === 'command') { |
|
307 | if (this.mode === 'command') { | |
296 | return true; |
|
308 | return true; | |
297 | } else if (this.mode === 'edit') { |
|
309 | } else if (this.mode === 'edit') { |
@@ -114,7 +114,7 b' define([' | |||||
114 | * @param name {String} name to use to refer to the callback. It is advised to use a prefix with the name |
|
114 | * @param name {String} name to use to refer to the callback. It is advised to use a prefix with the name | |
115 | * for easier sorting and avoid collision |
|
115 | * for easier sorting and avoid collision | |
116 | * @param callback {function(div, cell)} callback that will be called to generate the ui element |
|
116 | * @param callback {function(div, cell)} callback that will be called to generate the ui element | |
117 |
* @param [cell_types] {List |
|
117 | * @param [cell_types] {List_of_String|undefined} optional list of cell types. If present the UI element | |
118 | * will be added only to cells of types in the list. |
|
118 | * will be added only to cells of types in the list. | |
119 | * |
|
119 | * | |
120 | * |
|
120 | * | |
@@ -163,7 +163,7 b' define([' | |||||
163 | * @method register_preset |
|
163 | * @method register_preset | |
164 | * @param name {String} name to use to refer to the preset. It is advised to use a prefix with the name |
|
164 | * @param name {String} name to use to refer to the preset. It is advised to use a prefix with the name | |
165 | * for easier sorting and avoid collision |
|
165 | * for easier sorting and avoid collision | |
166 |
* @param preset_list {List |
|
166 | * @param preset_list {List_of_String} reverse order of the button in the toolbar. Each String of the list | |
167 | * should correspond to a name of a registerd callback. |
|
167 | * should correspond to a name of a registerd callback. | |
168 | * |
|
168 | * | |
169 | * @private |
|
169 | * @private | |
@@ -288,8 +288,6 b' define([' | |||||
288 | }; |
|
288 | }; | |
289 |
|
289 | |||
290 |
|
290 | |||
291 | /** |
|
|||
292 | */ |
|
|||
293 | CellToolbar.utils = {}; |
|
291 | CellToolbar.utils = {}; | |
294 |
|
292 | |||
295 |
|
293 | |||
@@ -385,7 +383,7 b' define([' | |||||
385 | * @method utils.select_ui_generator |
|
383 | * @method utils.select_ui_generator | |
386 | * @static |
|
384 | * @static | |
387 | * |
|
385 | * | |
388 |
* @param list_list {list |
|
386 | * @param list_list {list_of_sublist} List of sublist of metadata value and name in the dropdown list. | |
389 | * subslit shoud contain 2 element each, first a string that woul be displayed in the dropdown list, |
|
387 | * subslit shoud contain 2 element each, first a string that woul be displayed in the dropdown list, | |
390 | * and second the corresponding value to be passed to setter/return by getter. the corresponding value |
|
388 | * and second the corresponding value to be passed to setter/return by getter. the corresponding value | |
391 | * should not be "undefined" or behavior can be unexpected. |
|
389 | * should not be "undefined" or behavior can be unexpected. |
@@ -83,11 +83,7 b' define([' | |||||
83 | this.completer = null; |
|
83 | this.completer = null; | |
84 |
|
84 | |||
85 |
|
85 | |||
86 | var cm_overwrite_options = { |
|
86 | var config = utils.mergeopt(CodeCell, this.config); | |
87 | onKeyEvent: $.proxy(this.handle_keyevent,this) |
|
|||
88 | }; |
|
|||
89 |
|
||||
90 | var config = utils.mergeopt(CodeCell, this.config, {cm_config: cm_overwrite_options}); |
|
|||
91 | Cell.apply(this,[{ |
|
87 | Cell.apply(this,[{ | |
92 | config: config, |
|
88 | config: config, | |
93 | keyboard_manager: options.keyboard_manager, |
|
89 | keyboard_manager: options.keyboard_manager, | |
@@ -144,7 +140,7 b' define([' | |||||
144 | inner_cell.append(this.celltoolbar.element); |
|
140 | inner_cell.append(this.celltoolbar.element); | |
145 | var input_area = $('<div/>').addClass('input_area'); |
|
141 | var input_area = $('<div/>').addClass('input_area'); | |
146 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); |
|
142 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); | |
147 |
this.code_mirror.on('keydown', $.proxy(this.handle_ |
|
143 | this.code_mirror.on('keydown', $.proxy(this.handle_keyevent,this)) | |
148 | $(this.code_mirror.getInputField()).attr("spellcheck", "false"); |
|
144 | $(this.code_mirror.getInputField()).attr("spellcheck", "false"); | |
149 | inner_cell.append(input_area); |
|
145 | inner_cell.append(input_area); | |
150 | input.append(prompt).append(inner_cell); |
|
146 | input.append(prompt).append(inner_cell); |
@@ -318,11 +318,13 b' define([' | |||||
318 | // Enter |
|
318 | // Enter | |
319 | if (code == keycodes.enter) { |
|
319 | if (code == keycodes.enter) { | |
320 | event.codemirrorIgnore = true; |
|
320 | event.codemirrorIgnore = true; | |
|
321 | event._ipkmIgnore = true; | |||
321 | event.preventDefault(); |
|
322 | event.preventDefault(); | |
322 | this.pick(); |
|
323 | this.pick(); | |
323 | // Escape or backspace |
|
324 | // Escape or backspace | |
324 | } else if (code == keycodes.esc || code == keycodes.backspace) { |
|
325 | } else if (code == keycodes.esc || code == keycodes.backspace) { | |
325 | event.codemirrorIgnore = true; |
|
326 | event.codemirrorIgnore = true; | |
|
327 | event._ipkmIgnore = true; | |||
326 | event.preventDefault(); |
|
328 | event.preventDefault(); | |
327 | this.close(); |
|
329 | this.close(); | |
328 | } else if (code == keycodes.tab) { |
|
330 | } else if (code == keycodes.tab) { | |
@@ -343,6 +345,7 b' define([' | |||||
343 | // need to do that to be able to move the arrow |
|
345 | // need to do that to be able to move the arrow | |
344 | // when on the first or last line ofo a code cell |
|
346 | // when on the first or last line ofo a code cell | |
345 | event.codemirrorIgnore = true; |
|
347 | event.codemirrorIgnore = true; | |
|
348 | event._ipkmIgnore = true; | |||
346 | event.preventDefault(); |
|
349 | event.preventDefault(); | |
347 |
|
350 | |||
348 | var options = this.sel.find('option'); |
|
351 | var options = this.sel.find('option'); | |
@@ -356,7 +359,7 b' define([' | |||||
356 | index = Math.min(Math.max(index, 0), options.length-1); |
|
359 | index = Math.min(Math.max(index, 0), options.length-1); | |
357 | this.sel[0].selectedIndex = index; |
|
360 | this.sel[0].selectedIndex = index; | |
358 | } else if (code == keycodes.pageup || code == keycodes.pagedown) { |
|
361 | } else if (code == keycodes.pageup || code == keycodes.pagedown) { | |
359 | CodeMirror.e_stop(event); |
|
362 | event._ipkmIgnore = true; | |
360 |
|
363 | |||
361 | var options = this.sel.find('option'); |
|
364 | var options = this.sel.find('option'); | |
362 | var index = this.sel[0].selectedIndex; |
|
365 | var index = this.sel[0].selectedIndex; |
@@ -227,6 +227,9 b' define([' | |||||
227 | help : 'select previous cell', |
|
227 | help : 'select previous cell', | |
228 | help_index : 'da', |
|
228 | help_index : 'da', | |
229 | handler : function (event) { |
|
229 | handler : function (event) { | |
|
230 | if(event.codemirrorIgnore===true){ | |||
|
231 | return false; | |||
|
232 | } | |||
230 | var index = that.notebook.get_selected_index(); |
|
233 | var index = that.notebook.get_selected_index(); | |
231 | if (index !== 0 && index !== null) { |
|
234 | if (index !== 0 && index !== null) { | |
232 | that.notebook.select_prev(); |
|
235 | that.notebook.select_prev(); | |
@@ -239,6 +242,9 b' define([' | |||||
239 | help : 'select next cell', |
|
242 | help : 'select next cell', | |
240 | help_index : 'db', |
|
243 | help_index : 'db', | |
241 | handler : function (event) { |
|
244 | handler : function (event) { | |
|
245 | if(event.codemirrorIgnore===true){ | |||
|
246 | return false; | |||
|
247 | } | |||
242 | var index = that.notebook.get_selected_index(); |
|
248 | var index = that.notebook.get_selected_index(); | |
243 | if (index !== (that.notebook.ncells()-1) && index !== null) { |
|
249 | if (index !== (that.notebook.ncells()-1) && index !== null) { | |
244 | that.notebook.select_next(); |
|
250 | that.notebook.select_next(); | |
@@ -508,6 +514,9 b' define([' | |||||
508 | KeyboardManager.prototype.bind_events = function () { |
|
514 | KeyboardManager.prototype.bind_events = function () { | |
509 | var that = this; |
|
515 | var that = this; | |
510 | $(document).keydown(function (event) { |
|
516 | $(document).keydown(function (event) { | |
|
517 | if(event._ipkmIgnore==true||event.originalEvent._ipkmIgnore==true){ | |||
|
518 | return false; | |||
|
519 | } | |||
511 | return that.handle_keydown(event); |
|
520 | return that.handle_keydown(event); | |
512 | }); |
|
521 | }); | |
513 | }; |
|
522 | }; |
@@ -893,7 +893,7 b' define([' | |||||
893 | * Insert an element at given cell index. |
|
893 | * Insert an element at given cell index. | |
894 | * |
|
894 | * | |
895 | * @method _insert_element_at_index |
|
895 | * @method _insert_element_at_index | |
896 |
* @param element {dom |
|
896 | * @param element {dom_element} a cell element | |
897 | * @param [index] {int} a valid index where to inser cell |
|
897 | * @param [index] {int} a valid index where to inser cell | |
898 | * @private |
|
898 | * @private | |
899 | * |
|
899 | * |
@@ -11,7 +11,7 b' define([' | |||||
11 | * A generic toolbar on which one can add button |
|
11 | * A generic toolbar on which one can add button | |
12 | * @class ToolBar |
|
12 | * @class ToolBar | |
13 | * @constructor |
|
13 | * @constructor | |
14 |
* @param {Dom |
|
14 | * @param {Dom_object} selector | |
15 | */ |
|
15 | */ | |
16 | var ToolBar = function (selector, layout_manager) { |
|
16 | var ToolBar = function (selector, layout_manager) { | |
17 | this.selector = selector; |
|
17 | this.selector = selector; |
General Comments 0
You need to be logged in to leave comments.
Login now