##// 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 258 CodeCell.prototype._handle_execute_reply = function (content) {
259 259 this.set_input_prompt(content.execution_count);
260 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 37 this.undelete_index = null;
38 38 this.undelete_below = false;
39 39 this.paste_enabled = false;
40 this.dirty = false;
40 this.set_dirty(false);
41 41 this.metadata = {};
42 42 this._checkpoint_after_save = false;
43 43 this.last_checkpoint = null;
@@ -308,10 +308,13 b' var IPython = (function (IPython) {'
308 308 } else if (that.control_key_active) {
309 309 that.control_key_active = false;
310 310 return true;
311 };
311 } else if ( utils.is_typing(event) ) {
312 that.set_dirty(true);
313 return true;
314 }
312 315 return true;
313 316 });
314
317
315 318 var collapse_time = function(time){
316 319 var app_height = $('#ipython-main-app').height(); // content height
317 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 375 * Scroll the top of the page to a given cell.
358 376 *
359 377 * @method scroll_to_cell
@@ -645,7 +663,7 b' var IPython = (function (IPython) {'
645 663 pivot.before(tomove);
646 664 this.select(i-1);
647 665 };
648 this.dirty = true;
666 this.set_dirty(true);
649 667 };
650 668 return this;
651 669 };
@@ -669,7 +687,7 b' var IPython = (function (IPython) {'
669 687 this.select(i+1);
670 688 };
671 689 };
672 this.dirty = true;
690 this.set_dirty();
673 691 return this;
674 692 };
675 693
@@ -700,7 +718,7 b' var IPython = (function (IPython) {'
700 718 this.undelete_index = i;
701 719 this.undelete_below = false;
702 720 };
703 this.dirty = true;
721 this.set_dirty(true);
704 722 };
705 723 return this;
706 724 };
@@ -740,7 +758,7 b' var IPython = (function (IPython) {'
740 758 if(this._insert_element_at_index(cell.element,index)){
741 759 cell.render();
742 760 this.select(this.find_cell_index(cell));
743 this.dirty = true;
761 this.set_dirty(true);
744 762 }
745 763 }
746 764 return cell;
@@ -779,7 +797,7 b' var IPython = (function (IPython) {'
779 797
780 798 if (this.undelete_index !== null && index <= this.undelete_index) {
781 799 this.undelete_index = this.undelete_index + 1;
782 this.dirty = true;
800 this.set_dirty(true);
783 801 }
784 802 return true;
785 803 };
@@ -855,7 +873,7 b' var IPython = (function (IPython) {'
855 873 // to this state, instead of a blank cell
856 874 target_cell.code_mirror.clearHistory();
857 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 902 // to this state, instead of a blank cell
885 903 target_cell.code_mirror.clearHistory();
886 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 932 // to this state, instead of a blank cell
915 933 target_cell.code_mirror.clearHistory();
916 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 967 // to this state, instead of a blank cell
950 968 target_cell.code_mirror.clearHistory();
951 969 source_element.remove();
952 this.dirty = true;
970 this.set_dirty(true);
953 971 };
954 972 $([IPython.events]).trigger('selected_cell_type_changed.Notebook',
955 973 {'cell_type':'heading',level:level}
@@ -1177,7 +1195,7 b' var IPython = (function (IPython) {'
1177 1195 Notebook.prototype.collapse = function (index) {
1178 1196 var i = this.index_or_selected(index);
1179 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 1207 Notebook.prototype.expand = function (index) {
1190 1208 var i = this.index_or_selected(index);
1191 1209 this.get_cell(i).expand();
1192 this.dirty = true;
1210 this.set_dirty(true);
1193 1211 };
1194 1212
1195 1213 /** Toggle whether a cell's output is collapsed or expanded.
@@ -1200,7 +1218,7 b' var IPython = (function (IPython) {'
1200 1218 Notebook.prototype.toggle_output = function (index) {
1201 1219 var i = this.index_or_selected(index);
1202 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 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 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 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 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 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 1642 * @param {jqXHR} xhr jQuery Ajax object
1625 1643 */
1626 1644 Notebook.prototype.save_notebook_success = function (start, data, status, xhr) {
1627 this.dirty = false;
1645 this.set_dirty(false);
1628 1646 $([IPython.events]).trigger('notebook_saved.Notebook');
1629 1647 this._update_autosave_interval(start);
1630 1648 if (this._checkpoint_after_save) {
@@ -1703,7 +1721,7 b' var IPython = (function (IPython) {'
1703 1721 if (this.ncells() === 0) {
1704 1722 this.insert_cell_below('code');
1705 1723 };
1706 this.dirty = false;
1724 this.set_dirty(false);
1707 1725 this.select(0);
1708 1726 this.scroll_to_top();
1709 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