##// END OF EJS Templates
setting the notebook dirty flag is now an event...
MinRK -
Show More
@@ -258,7 +258,7 b' var IPython = (function (IPython) {'
258 CodeCell.prototype._handle_execute_reply = function (content) {
258 CodeCell.prototype._handle_execute_reply = function (content) {
259 this.set_input_prompt(content.execution_count);
259 this.set_input_prompt(content.execution_count);
260 this.element.removeClass("running");
260 this.element.removeClass("running");
261 $([IPython.events]).trigger('set_dirty.Notebook', {'value': true});
261 $([IPython.events]).trigger('set_dirty.Notebook', {value: true});
262 }
262 }
263
263
264 /**
264 /**
@@ -37,7 +37,7 b' var IPython = (function (IPython) {'
37 this.undelete_index = null;
37 this.undelete_index = null;
38 this.undelete_below = false;
38 this.undelete_below = false;
39 this.paste_enabled = false;
39 this.paste_enabled = false;
40 this.dirty = false;
40 this.set_dirty(false);
41 this.metadata = {};
41 this.metadata = {};
42 this._checkpoint_after_save = false;
42 this._checkpoint_after_save = false;
43 this.last_checkpoint = null;
43 this.last_checkpoint = null;
@@ -308,10 +308,13 b' var IPython = (function (IPython) {'
308 } else if (that.control_key_active) {
308 } else if (that.control_key_active) {
309 that.control_key_active = false;
309 that.control_key_active = false;
310 return true;
310 return true;
311 };
311 } else if ( utils.is_typing(event) ) {
312 that.set_dirty(true);
313 return true;
314 }
312 return true;
315 return true;
313 });
316 });
314
317
315 var collapse_time = function(time){
318 var collapse_time = function(time){
316 var app_height = $('#ipython-main-app').height(); // content height
319 var app_height = $('#ipython-main-app').height(); // content height
317 var splitter_height = $('div#pager_splitter').outerHeight(true);
320 var splitter_height = $('div#pager_splitter').outerHeight(true);
@@ -354,6 +357,21 b' var IPython = (function (IPython) {'
354 };
357 };
355
358
356 /**
359 /**
360 * Set the dirty flag, and trigger the set_dirty.Notebook event
361 *
362 * @method set_dirty
363 */
364 Notebook.prototype.set_dirty = function (value) {
365 if (value === undefined) {
366 value = true;
367 }
368 if (this.dirty == value) {
369 return;
370 }
371 $([IPython.events]).trigger('set_dirty.Notebook', {value: value});
372 };
373
374 /**
357 * Scroll the top of the page to a given cell.
375 * Scroll the top of the page to a given cell.
358 *
376 *
359 * @method scroll_to_cell
377 * @method scroll_to_cell
@@ -645,7 +663,7 b' var IPython = (function (IPython) {'
645 pivot.before(tomove);
663 pivot.before(tomove);
646 this.select(i-1);
664 this.select(i-1);
647 };
665 };
648 this.dirty = true;
666 this.set_dirty(true);
649 };
667 };
650 return this;
668 return this;
651 };
669 };
@@ -669,7 +687,7 b' var IPython = (function (IPython) {'
669 this.select(i+1);
687 this.select(i+1);
670 };
688 };
671 };
689 };
672 this.dirty = true;
690 this.set_dirty();
673 return this;
691 return this;
674 };
692 };
675
693
@@ -700,7 +718,7 b' var IPython = (function (IPython) {'
700 this.undelete_index = i;
718 this.undelete_index = i;
701 this.undelete_below = false;
719 this.undelete_below = false;
702 };
720 };
703 this.dirty = true;
721 this.set_dirty(true);
704 };
722 };
705 return this;
723 return this;
706 };
724 };
@@ -740,7 +758,7 b' var IPython = (function (IPython) {'
740 if(this._insert_element_at_index(cell.element,index)){
758 if(this._insert_element_at_index(cell.element,index)){
741 cell.render();
759 cell.render();
742 this.select(this.find_cell_index(cell));
760 this.select(this.find_cell_index(cell));
743 this.dirty = true;
761 this.set_dirty(true);
744 }
762 }
745 }
763 }
746 return cell;
764 return cell;
@@ -779,7 +797,7 b' var IPython = (function (IPython) {'
779
797
780 if (this.undelete_index !== null && index <= this.undelete_index) {
798 if (this.undelete_index !== null && index <= this.undelete_index) {
781 this.undelete_index = this.undelete_index + 1;
799 this.undelete_index = this.undelete_index + 1;
782 this.dirty = true;
800 this.set_dirty(true);
783 }
801 }
784 return true;
802 return true;
785 };
803 };
@@ -855,7 +873,7 b' var IPython = (function (IPython) {'
855 // to this state, instead of a blank cell
873 // to this state, instead of a blank cell
856 target_cell.code_mirror.clearHistory();
874 target_cell.code_mirror.clearHistory();
857 source_element.remove();
875 source_element.remove();
858 this.dirty = true;
876 this.set_dirty(true);
859 };
877 };
860 };
878 };
861 };
879 };
@@ -884,7 +902,7 b' var IPython = (function (IPython) {'
884 // to this state, instead of a blank cell
902 // to this state, instead of a blank cell
885 target_cell.code_mirror.clearHistory();
903 target_cell.code_mirror.clearHistory();
886 source_element.remove();
904 source_element.remove();
887 this.dirty = true;
905 this.set_dirty(true);
888 };
906 };
889 };
907 };
890 };
908 };
@@ -914,7 +932,7 b' var IPython = (function (IPython) {'
914 // to this state, instead of a blank cell
932 // to this state, instead of a blank cell
915 target_cell.code_mirror.clearHistory();
933 target_cell.code_mirror.clearHistory();
916 source_element.remove();
934 source_element.remove();
917 this.dirty = true;
935 this.set_dirty(true);
918 };
936 };
919 };
937 };
920 };
938 };
@@ -949,7 +967,7 b' var IPython = (function (IPython) {'
949 // to this state, instead of a blank cell
967 // to this state, instead of a blank cell
950 target_cell.code_mirror.clearHistory();
968 target_cell.code_mirror.clearHistory();
951 source_element.remove();
969 source_element.remove();
952 this.dirty = true;
970 this.set_dirty(true);
953 };
971 };
954 $([IPython.events]).trigger('selected_cell_type_changed.Notebook',
972 $([IPython.events]).trigger('selected_cell_type_changed.Notebook',
955 {'cell_type':'heading',level:level}
973 {'cell_type':'heading',level:level}
@@ -1177,7 +1195,7 b' var IPython = (function (IPython) {'
1177 Notebook.prototype.collapse = function (index) {
1195 Notebook.prototype.collapse = function (index) {
1178 var i = this.index_or_selected(index);
1196 var i = this.index_or_selected(index);
1179 this.get_cell(i).collapse();
1197 this.get_cell(i).collapse();
1180 this.dirty = true;
1198 this.set_dirty(true);
1181 };
1199 };
1182
1200
1183 /**
1201 /**
@@ -1189,7 +1207,7 b' var IPython = (function (IPython) {'
1189 Notebook.prototype.expand = function (index) {
1207 Notebook.prototype.expand = function (index) {
1190 var i = this.index_or_selected(index);
1208 var i = this.index_or_selected(index);
1191 this.get_cell(i).expand();
1209 this.get_cell(i).expand();
1192 this.dirty = true;
1210 this.set_dirty(true);
1193 };
1211 };
1194
1212
1195 /** Toggle whether a cell's output is collapsed or expanded.
1213 /** Toggle whether a cell's output is collapsed or expanded.
@@ -1200,7 +1218,7 b' var IPython = (function (IPython) {'
1200 Notebook.prototype.toggle_output = function (index) {
1218 Notebook.prototype.toggle_output = function (index) {
1201 var i = this.index_or_selected(index);
1219 var i = this.index_or_selected(index);
1202 this.get_cell(i).toggle_output();
1220 this.get_cell(i).toggle_output();
1203 this.dirty = true;
1221 this.set_dirty(true);
1204 };
1222 };
1205
1223
1206 /**
1224 /**
@@ -1228,7 +1246,7 b' var IPython = (function (IPython) {'
1228 }
1246 }
1229 };
1247 };
1230 // this should not be set if the `collapse` key is removed from nbformat
1248 // this should not be set if the `collapse` key is removed from nbformat
1231 this.dirty = true;
1249 this.set_dirty(true);
1232 };
1250 };
1233
1251
1234 /**
1252 /**
@@ -1246,7 +1264,7 b' var IPython = (function (IPython) {'
1246 }
1264 }
1247 };
1265 };
1248 // this should not be set if the `collapse` key is removed from nbformat
1266 // this should not be set if the `collapse` key is removed from nbformat
1249 this.dirty = true;
1267 this.set_dirty(true);
1250 };
1268 };
1251
1269
1252 /**
1270 /**
@@ -1264,7 +1282,7 b' var IPython = (function (IPython) {'
1264 }
1282 }
1265 };
1283 };
1266 // this should not be set if the `collapse` key is removed from nbformat
1284 // this should not be set if the `collapse` key is removed from nbformat
1267 this.dirty = true;
1285 this.set_dirty(true);
1268 };
1286 };
1269
1287
1270 /**
1288 /**
@@ -1283,7 +1301,7 b' var IPython = (function (IPython) {'
1283 cells[i].set_input_prompt();
1301 cells[i].set_input_prompt();
1284 }
1302 }
1285 };
1303 };
1286 this.dirty = true;
1304 this.set_dirty(true);
1287 };
1305 };
1288
1306
1289
1307
@@ -1376,7 +1394,7 b' var IPython = (function (IPython) {'
1376 that.select(cell_index+1);
1394 that.select(cell_index+1);
1377 };
1395 };
1378 };
1396 };
1379 this.dirty = true;
1397 this.set_dirty(true);
1380 };
1398 };
1381
1399
1382 /**
1400 /**
@@ -1624,7 +1642,7 b' var IPython = (function (IPython) {'
1624 * @param {jqXHR} xhr jQuery Ajax object
1642 * @param {jqXHR} xhr jQuery Ajax object
1625 */
1643 */
1626 Notebook.prototype.save_notebook_success = function (start, data, status, xhr) {
1644 Notebook.prototype.save_notebook_success = function (start, data, status, xhr) {
1627 this.dirty = false;
1645 this.set_dirty(false);
1628 $([IPython.events]).trigger('notebook_saved.Notebook');
1646 $([IPython.events]).trigger('notebook_saved.Notebook');
1629 this._update_autosave_interval(start);
1647 this._update_autosave_interval(start);
1630 if (this._checkpoint_after_save) {
1648 if (this._checkpoint_after_save) {
@@ -1703,7 +1721,7 b' var IPython = (function (IPython) {'
1703 if (this.ncells() === 0) {
1721 if (this.ncells() === 0) {
1704 this.insert_cell_below('code');
1722 this.insert_cell_below('code');
1705 };
1723 };
1706 this.dirty = false;
1724 this.set_dirty(false);
1707 this.select(0);
1725 this.select(0);
1708 this.scroll_to_top();
1726 this.scroll_to_top();
1709 if (data.orig_nbformat !== undefined && data.nbformat !== data.orig_nbformat) {
1727 if (data.orig_nbformat !== undefined && data.nbformat !== data.orig_nbformat) {
General Comments 0
You need to be logged in to leave comments. Login now