Show More
@@ -21,6 +21,7 var IPython = (function (IPython) { | |||||
21 | this.next_prompt_number = 1; |
|
21 | this.next_prompt_number = 1; | |
22 | this.kernel = null; |
|
22 | this.kernel = null; | |
23 | this.clipboard = null; |
|
23 | this.clipboard = null; | |
|
24 | this.paste_enabled = false; | |||
24 | this.dirty = false; |
|
25 | this.dirty = false; | |
25 | this.msg_cell_map = {}; |
|
26 | this.msg_cell_map = {}; | |
26 | this.metadata = {}; |
|
27 | this.metadata = {}; | |
@@ -583,23 +584,30 var IPython = (function (IPython) { | |||||
583 |
|
584 | |||
584 | Notebook.prototype.enable_paste = function () { |
|
585 | Notebook.prototype.enable_paste = function () { | |
585 | var that = this; |
|
586 | var that = this; | |
586 | $('#paste_cell').removeClass('ui-state-disabled') |
|
587 | if (!this.paste_enabled) { | |
587 | .on('click', function () {that.paste_cell();}); |
|
588 | $('#paste_cell').removeClass('ui-state-disabled') | |
588 | $('#paste_cell_above').removeClass('ui-state-disabled') |
|
589 | .on('click', function () {that.paste_cell();}); | |
589 | .on('click', function () {that.paste_cell_above();}); |
|
590 | $('#paste_cell_above').removeClass('ui-state-disabled') | |
590 | $('#paste_cell_below').removeClass('ui-state-disabled') |
|
591 | .on('click', function () {that.paste_cell_above();}); | |
591 | .on('click', function () {that.paste_cell_below();}); |
|
592 | $('#paste_cell_below').removeClass('ui-state-disabled') | |
|
593 | .on('click', function () {that.paste_cell_below();}); | |||
|
594 | this.paste_enabled = true; | |||
|
595 | }; | |||
592 | }; |
|
596 | }; | |
593 |
|
597 | |||
594 |
|
598 | |||
595 | Notebook.prototype.disable_paste = function () { |
|
599 | Notebook.prototype.disable_paste = function () { | |
596 | $('#paste_cell').addClass('ui-state-disabled').off('click'); |
|
600 | if (this.paste_enabled) { | |
597 |
$('#paste_cell |
|
601 | $('#paste_cell').addClass('ui-state-disabled').off('click'); | |
598 |
$('#paste_cell_ |
|
602 | $('#paste_cell_above').addClass('ui-state-disabled').off('click'); | |
|
603 | $('#paste_cell_below').addClass('ui-state-disabled').off('click'); | |||
|
604 | this.paste_enabled = false; | |||
|
605 | }; | |||
599 | }; |
|
606 | }; | |
600 |
|
607 | |||
601 |
|
608 | |||
602 | Notebook.prototype.cut_cell = function () { |
|
609 | Notebook.prototype.cut_cell = function () { | |
|
610 | console.log('cut_cell'); | |||
603 | this.copy_cell(); |
|
611 | this.copy_cell(); | |
604 | this.delete_cell(); |
|
612 | this.delete_cell(); | |
605 | } |
|
613 | } | |
@@ -612,7 +620,8 var IPython = (function (IPython) { | |||||
612 |
|
620 | |||
613 |
|
621 | |||
614 | Notebook.prototype.paste_cell = function () { |
|
622 | Notebook.prototype.paste_cell = function () { | |
615 | if (this.clipboard !== null) { |
|
623 | console.log('paste_cell'); | |
|
624 | if (this.clipboard !== null && this.paste_enabled) { | |||
616 | var cell_data = this.clipboard; |
|
625 | var cell_data = this.clipboard; | |
617 | if (cell_data.cell_type == 'code') { |
|
626 | if (cell_data.cell_type == 'code') { | |
618 | new_cell = this.insert_code_cell_above(); |
|
627 | new_cell = this.insert_code_cell_above(); | |
@@ -624,14 +633,14 var IPython = (function (IPython) { | |||||
624 | new_cell = this.insert_markdown_cell_above(); |
|
633 | new_cell = this.insert_markdown_cell_above(); | |
625 | new_cell.fromJSON(cell_data); |
|
634 | new_cell.fromJSON(cell_data); | |
626 | }; |
|
635 | }; | |
|
636 | this.select_next(); | |||
|
637 | this.delete_cell(); | |||
627 | }; |
|
638 | }; | |
628 | this.select_next(); |
|
|||
629 | this.delete_cell(); |
|
|||
630 | }; |
|
639 | }; | |
631 |
|
640 | |||
632 |
|
641 | |||
633 | Notebook.prototype.paste_cell_above = function () { |
|
642 | Notebook.prototype.paste_cell_above = function () { | |
634 | if (this.clipboard !== null) { |
|
643 | if (this.clipboard !== null && this.paste_enabled) { | |
635 | var cell_data = this.clipboard; |
|
644 | var cell_data = this.clipboard; | |
636 | if (cell_data.cell_type == 'code') { |
|
645 | if (cell_data.cell_type == 'code') { | |
637 | new_cell = this.insert_code_cell_above(); |
|
646 | new_cell = this.insert_code_cell_above(); | |
@@ -648,16 +657,16 var IPython = (function (IPython) { | |||||
648 |
|
657 | |||
649 |
|
658 | |||
650 | Notebook.prototype.paste_cell_below = function () { |
|
659 | Notebook.prototype.paste_cell_below = function () { | |
651 | if (this.clipboard !== null) { |
|
660 | if (this.clipboard !== null && this.paste_enabled) { | |
652 | var cell_data = this.clipboard; |
|
661 | var cell_data = this.clipboard; | |
653 | if (cell_data.cell_type == 'code') { |
|
662 | if (cell_data.cell_type == 'code') { | |
654 |
new_cell = this.insert_code_cell_ |
|
663 | new_cell = this.insert_code_cell_below(); | |
655 | new_cell.fromJSON(cell_data); |
|
664 | new_cell.fromJSON(cell_data); | |
656 | } else if (cell_data.cell_type === 'html') { |
|
665 | } else if (cell_data.cell_type === 'html') { | |
657 |
new_cell = this.insert_html_cell_ |
|
666 | new_cell = this.insert_html_cell_below(); | |
658 | new_cell.fromJSON(cell_data); |
|
667 | new_cell.fromJSON(cell_data); | |
659 | } else if (cell_data.cell_type === 'markdown') { |
|
668 | } else if (cell_data.cell_type === 'markdown') { | |
660 |
new_cell = this.insert_markdown_cell_ |
|
669 | new_cell = this.insert_markdown_cell_below(); | |
661 | new_cell.fromJSON(cell_data); |
|
670 | new_cell.fromJSON(cell_data); | |
662 | }; |
|
671 | }; | |
663 | }; |
|
672 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now