Show More
@@ -16,7 +16,7 b' var Notebook = function (selector) {' | |||
|
16 | 16 | |
|
17 | 17 | Notebook.prototype.bind_events = function () { |
|
18 | 18 | var that = this; |
|
19 |
|
|
|
19 | $(document).keydown(function (event) { | |
|
20 | 20 | console.log(event); |
|
21 | 21 | if (event.which == 38 && event.shiftKey) { |
|
22 | 22 | that.select_prev(); |
@@ -24,6 +24,7 b' Notebook.prototype.bind_events = function () {' | |||
|
24 | 24 | that.select_next(); |
|
25 | 25 | } else if (event.which == 13 && event.shiftKey) { |
|
26 | 26 | // The focus is not quite working here. |
|
27 | event.preventDefault(); | |
|
27 | 28 | that.insert_code_cell_after(); |
|
28 | 29 | } |
|
29 | 30 | }); |
@@ -155,7 +156,7 b' Notebook.prototype.insert_cell_before = function (cell, index) {' | |||
|
155 | 156 | this.append_cell(cell); |
|
156 | 157 | return this; |
|
157 | 158 | }; |
|
158 | if (index > 0 && index < ncells) { | |
|
159 | if (index >= 0 && index < ncells) { | |
|
159 | 160 | this.cell_elements().eq(index).before(cell.element); |
|
160 | 161 | }; |
|
161 | 162 | return this; |
@@ -170,6 +171,7 b' Notebook.prototype.move_cell_up = function (index) {' | |||
|
170 | 171 | if (pivot !== null && tomove !== null) { |
|
171 | 172 | tomove.detach(); |
|
172 | 173 | pivot.before(tomove); |
|
174 | this.select(i-1); | |
|
173 | 175 | }; |
|
174 | 176 | }; |
|
175 | 177 | return this; |
@@ -184,6 +186,7 b' Notebook.prototype.move_cell_down = function (index) {' | |||
|
184 | 186 | if (pivot !== null && tomove !== null) { |
|
185 | 187 | tomove.detach(); |
|
186 | 188 | pivot.after(tomove); |
|
189 | this.select(i+1); | |
|
187 | 190 | }; |
|
188 | 191 | }; |
|
189 | 192 | return this; |
@@ -321,7 +324,10 b' var Cell = function (notebook) {' | |||
|
321 | 324 | Cell.prototype.select = function () { |
|
322 | 325 | this.element.addClass('ui-widget-content ui-corner-all'); |
|
323 | 326 | this.selected = true; |
|
327 | // TODO: we need t test across browsers to see if both of these are needed. | |
|
328 | // In the meantime, there should not be any harm in having them both. | |
|
324 | 329 | this.element.find('textarea').trigger('focusin'); |
|
330 | this.element.find('textarea').trigger('focus'); | |
|
325 | 331 | }; |
|
326 | 332 | |
|
327 | 333 | |
@@ -445,27 +451,52 b' TextCell.prototype.create_element = function () {' | |||
|
445 | 451 | }; |
|
446 | 452 | |
|
447 | 453 | |
|
448 |
TextCell.prototype.c |
|
|
454 | TextCell.prototype.select = function () { | |
|
455 | this.edit(); | |
|
456 | Cell.prototype.select.apply(this); | |
|
457 | }; | |
|
458 | ||
|
459 | ||
|
460 | TextCell.prototype.edit = function () { | |
|
449 | 461 | var text_cell = this.element; |
|
450 | 462 | var input = text_cell.find("textarea.text_cell_input"); |
|
451 | var output = text_cell.find("div.text_cell_render"); | |
|
463 | var output = text_cell.find("div.text_cell_render"); | |
|
464 | output.hide(); | |
|
465 | input.show().trigger('focus'); | |
|
466 | }; | |
|
467 | ||
|
452 | 468 | |
|
469 | TextCell.prototype.render = function () { | |
|
470 | var text_cell = this.element; | |
|
471 | var input = text_cell.find("textarea.text_cell_input"); | |
|
472 | var output = text_cell.find("div.text_cell_render"); | |
|
473 | var text = input.val(); | |
|
474 | output.html(text) | |
|
475 | input.html(text); | |
|
476 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); | |
|
477 | input.hide(); | |
|
478 | output.show(); | |
|
479 | }; | |
|
480 | ||
|
481 | ||
|
482 | TextCell.prototype.config_mathjax = function () { | |
|
483 | var text_cell = this.element; | |
|
484 | var that = this; | |
|
453 | 485 | text_cell.click(function () { |
|
454 |
|
|
|
455 | input.show().trigger('focus'); | |
|
486 | that.edit(); | |
|
456 | 487 | }).focusout(function () { |
|
457 | var text = input.val(); | |
|
458 | output.html(text) | |
|
459 | input.html(text); | |
|
460 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); | |
|
461 | input.hide(); | |
|
462 | output.show(); | |
|
488 | that.render(); | |
|
463 | 489 | }); |
|
464 | 490 | |
|
465 | 491 | text_cell.trigger("focusout"); |
|
466 | 492 | }; |
|
467 | 493 | |
|
468 | 494 | |
|
495 | //============================================================================ | |
|
496 | // On document ready | |
|
497 | //============================================================================ | |
|
498 | ||
|
499 | ||
|
469 | 500 | $(document).ready(function () { |
|
470 | 501 | |
|
471 | 502 | MathJax.Hub.Config({ |
General Comments 0
You need to be logged in to leave comments.
Login now