Skip to content
This repository

notebook download implies save #895

Closed
wants to merge 1 commit into from

3 participants

Min RK Fernando Perez Brian E. Granger
Min RK
Owner

closes #852

Note that this should get some review, as I'm not certain it's the right way to go. This change makes download trigger a save, and the save-success callback triggers the actual download. However, at least on Chrome, the fact that opening the download url is no longer triggered directly by the click action means it can get caught by pop-up blockers.

Fernando Perez
Owner

Yup, in fact ffox also blocks it. So I think we need to find out something else, I don't like to require people to disable their popup blockers... But I have to say, I don't know what a better solution would be.

Min RK
Owner

In that case, I don't think we can force a save on download. We have to just add a note to the tooltip, that Download/print get the most recently saved version.

If we can detect that the document has been edited since last save, then we can do this with a dialog 'Would you like to save changes before downloading?' But I don't think we have a global flag that gets set on any edit.

Fernando Perez
Owner

Do you just want to change the tooltip and close this one? I would like to set a dirty flag on cell edit, but that's a separate job. It would be nice if the UI could reflect that dirty state also (emacs marks the status area with '**', other editors do similar things). But that's a separate request... I'm OK with closing this one and just editing the tooltip.

Brian E. Granger
Owner

We do have a dirty flag that detect when a cell is run, moved, deleted. We could look at this flag. But you are right that this flag doesn't currently detect if a cell has been edited but not run. But I agree with Fernando that we can't require pop-up blockers to be disabled. I have run into this issue in numerous places in the notebook already.

Min RK
Owner

I'll close this, and just add a note to the tooltip. Probably not consider that closing the original Issue, though.

Min RK minrk closed this pull request from a commit October 20, 2011
Min RK Add tooltip to Download/Print indicating need to save first
A real fix would be to trigger a save on each of thes actions, which would address #852

closes gh-895
bbc4d01
Min RK minrk closed this in bbc4d01 October 20, 2011
Brian E. Granger ellisonbg referenced this pull request from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 18, 2011
Min RK notebook download implies save
closes #852
2aacd8b
This page is out of date. Refresh to see the latest.
16  IPython/frontend/html/notebook/static/js/panelsection.js
@@ -106,9 +106,19 @@ var IPython = (function (IPython) {
106 106
         });
107 107
         this.content.find('#download_notebook').click(function () {
108 108
             var format = that.content.find('#download_format').val();
109  
-            var notebook_id = IPython.save_widget.get_notebook_id();
110  
-            var url = '/notebooks/' + notebook_id + '?format=' + format;
111  
-            window.open(url,'_newtab');
  109
+            // save on download
  110
+            IPython.save_widget.save_notebook();
  111
+            // hook into notebook_saved method to download on success:
  112
+            var old_notebook_saved = IPython.save_widget.notebook_saved;
  113
+            IPython.save_widget.notebook_saved = function() {
  114
+                // restore and call original function:
  115
+                IPython.save_widget.notebook_saved = old_notebook_saved;
  116
+                IPython.save_widget.notebook_saved();
  117
+                // now trigger download
  118
+                var notebook_id = IPython.save_widget.get_notebook_id();
  119
+                var url = '/notebooks/' + notebook_id + '?format=' + format;
  120
+                window.open(url,'_newtab');
  121
+            }
112 122
         });
113 123
     };
114 124
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.