Browse Source

Update for latest docmanager

Steven Silvester 9 years ago
parent
commit
2bc2076d51
2 changed files with 24 additions and 1 deletions
  1. 1 1
      package.json
  2. 23 0
      src/notebook/plugin.ts

+ 1 - 1
package.json

@@ -8,7 +8,7 @@
     "codemirror": "^5.10.0",
     "jquery": "^2.2.0",
     "jquery-ui": "^1.10.5",
-    "jupyter-js-docmanager": "^0.4.0",
+    "jupyter-js-docmanager": "^0.4.1",
     "jupyter-js-filebrowser": "^0.10.0",
     "jupyter-js-notebook": "^0.7.1",
     "jupyter-js-services": "^0.5.0",

+ 23 - 0
src/notebook/plugin.ts

@@ -214,6 +214,28 @@ class NotebookFileHandler extends AbstractFileHandler<NotebookContainer> {
     if (w) w.model.selectPreviousCell();
   }
 
+  /**
+   * Set the dirty state of a widget (defaults to current active widget).
+   */
+  setDirty(widget?: NotebookContainer): void {
+    super.setDirty(widget);
+    widget = this.resolveWidget(widget);
+    if (widget) {
+      widget.model.dirty = true;
+    }
+  }
+
+  /**
+   * Clear the dirty state of a widget (defaults to current active widget).
+   */
+  clearDirty(widget?: NotebookContainer): void {
+    super.clearDirty(widget);
+    widget = this.resolveWidget(widget);
+    if (widget) {
+      widget.model.dirty = false;
+    }
+  }
+
   /**
    * Get options use to fetch the model contents from disk.
    */
@@ -234,6 +256,7 @@ class NotebookFileHandler extends AbstractFileHandler<NotebookContainer> {
    */
   protected createWidget(contents: IContentsModel): NotebookContainer {
     let panel = new NotebookContainer();
+    panel.model.stateChanged.connect(this._onModelChanged, this);
     panel.title.text = contents.name;
     panel.addClass(notebookContainerClass);