##// END OF EJS Templates
Finishing work on "Make a Copy" functionality.
Brian Granger -
Show More
@@ -236,16 +236,21 b' class NotebookManager(LoggingConfigurable):'
236 236 os.unlink(path)
237 237 self.delete_notebook_id(notebook_id)
238 238
239 def new_notebook(self):
240 """Create a new notebook and returns its notebook_id."""
239 def increment_filename(self, basename):
240 """Return a non-used filename of the form basename0."""
241 241 i = 0
242 242 while True:
243 name = u'Untitled%i' % i
243 name = u'%s%i' % (basename,i)
244 244 path = self.get_path_by_name(name)
245 245 if not os.path.isfile(path):
246 246 break
247 247 else:
248 248 i = i+1
249 return path, name
250
251 def new_notebook(self):
252 """Create a new notebook and return its notebook_id."""
253 path, name = self.increment_filename('Untitled')
249 254 notebook_id = self.new_notebook_id(name)
250 255 metadata = current.new_metadata(name=name)
251 256 nb = current.new_notebook(metadata=metadata)
@@ -254,9 +259,10 b' class NotebookManager(LoggingConfigurable):'
254 259 return notebook_id
255 260
256 261 def copy_notebook(self, notebook_id):
257 """Create a new notebook and returns its notebook_id."""
262 """Copy an existing notebook and return its notebook_id."""
258 263 last_mod, nb = self.get_notebook_object(notebook_id)
259 264 name = nb.metadata.name + '-Copy'
265 path, name = self.increment_filename(name)
260 266 nb.metadata.name = name
261 267 notebook_id = self.new_notebook_id(name)
262 268 self.save_notebook_object(notebook_id, nb)
@@ -311,9 +311,6 b' var IPython = (function (IPython) {'
311 311 {
312 312 if(this.npressed >fallback_on_tooltip_after && this.prevmatch==matched_text)
313 313 {
314 console.log('Ok, you really want to complete after pressing tab '+this.npressed+' times !');
315 console.log('You should understand that there is no (more) completion for that !');
316 console.log("I'll show you the tooltip, will you stop bothering me ?");
317 314 this.request_tooltip_after_time(matched_text+'(',0);
318 315 return;
319 316 }
@@ -487,8 +484,6 b' var IPython = (function (IPython) {'
487 484 // dismiss the completer and go back to before invoking it
488 485 insert(matched_text,event);
489 486 } else if( press ){ // abort only on .keypress or esc
490 // abort with what the user have pressed until now
491 console.log('aborting with keycode : '+code+' is down :'+down);
492 487 }
493 488 }
494 489 select.keydown(function (event) {
@@ -790,7 +785,6 b' var IPython = (function (IPython) {'
790 785
791 786
792 787 CodeCell.prototype.fromJSON = function (data) {
793 console.log('Import from JSON:', data);
794 788 if (data.cell_type === 'code') {
795 789 if (data.input !== undefined) {
796 790 this.set_code(data.input);
@@ -828,7 +822,6 b' var IPython = (function (IPython) {'
828 822 data.outputs = outputs;
829 823 data.language = 'python';
830 824 data.collapsed = this.collapsed;
831 // console.log('Export to JSON:',data);
832 825 return data;
833 826 };
834 827
@@ -31,7 +31,6 b' var IPython = (function (IPython) {'
31 31 // in the DOM.
32 32 $(".wijmo-wijmenu-text").parent().bind("click", function () {
33 33 $('ul#menus').wijmenu("hideAllMenus");
34 console.log('I am closing you!');
35 34 });
36 35 // Make sure we hover over menu items correctly. This is needed when
37 36 // menu shortcuts are used as they have a slightly different structure
@@ -587,17 +587,14 b' var IPython = (function (IPython) {'
587 587
588 588
589 589 Notebook.prototype.set_timebeforetooltip = function (time) {
590 console.log("change time before tooltip to : "+time);
591 590 this.time_before_tooltip = time;
592 591 };
593 592
594 593 Notebook.prototype.set_tooltipontab = function (state) {
595 console.log("change tooltip on tab to : "+state);
596 594 this.tooltip_on_tab = state;
597 595 };
598 596
599 597 Notebook.prototype.set_smartcompleter = function (state) {
600 console.log("Smart completion (kwargs first) changed to to : "+state);
601 598 this.smart_completer = state;
602 599 };
603 600
@@ -120,7 +120,8 b' var IPython = (function (IPython) {'
120 120 SaveWidget.prototype.update_url = function () {
121 121 var notebook_id = this.get_notebook_id();
122 122 if (notebook_id !== '') {
123 window.history.replaceState({}, '', notebook_id);
123 var new_url = '/'+notebook_id;
124 window.history.replaceState({}, '', new_url);
124 125 };
125 126 };
126 127
@@ -68,8 +68,8 b''
68 68 <li id="new_notebook"><span class="wijmo-wijmenu-text">New</span></li>
69 69 <li id="open_notebook"><span class="wijmo-wijmenu-text">Open...</span></li>
70 70 <li></li>
71 <li id="rename_notebook"><span class="wijmo-wijmenu-text">Rename...</span></li>
72 71 <li id="copy_notebook"><span class="wijmo-wijmenu-text">Make a Copy...</span></li>
72 <li id="rename_notebook"><span class="wijmo-wijmenu-text">Rename...</span></li>
73 73 <li id="save_notebook">
74 74 <div>
75 75 <span class="wijmo-wijmenu-text">Save</span>
General Comments 0
You need to be logged in to leave comments. Login now