##// END OF EJS Templates
use `async : false` to avoid pop-up blocker on New / Copy notebook
MinRK -
Show More
@@ -134,7 +134,7 b' class NotebookManager(LoggingConfigurable):'
134 """Copy an existing notebook and return its new model."""
134 """Copy an existing notebook and return its new model."""
135 model = self.get_notebook_model(name, path)
135 model = self.get_notebook_model(name, path)
136 name = os.path.splitext(name)[0] + '-Copy'
136 name = os.path.splitext(name)[0] + '-Copy'
137 name = self.increment_filename(name, path) + self.filename_ext
137 name = self.increment_filename(name, path)
138 model['name'] = name
138 model['name'] = name
139 model = self.save_notebook_model(model, name, path)
139 model = self.save_notebook_model(model, name, path)
140 return model
140 return model
@@ -1743,47 +1743,56 b' var IPython = (function (IPython) {'
1743
1743
1744 Notebook.prototype.new_notebook = function(){
1744 Notebook.prototype.new_notebook = function(){
1745 var path = this.notebookPath();
1745 var path = this.notebookPath();
1746 var base_project_url = this.baseProjectUrl();
1746 var settings = {
1747 var settings = {
1747 processData : false,
1748 processData : false,
1748 cache : false,
1749 cache : false,
1749 type : "POST",
1750 type : "POST",
1750 dataType : "json",
1751 dataType : "json",
1751 success:$.proxy(function (data, status, xhr){
1752 async : false,
1753 success : function (data, status, xhr){
1752 var notebook_name = data.name;
1754 var notebook_name = data.name;
1753 window.open(
1755 window.open(
1754 utils.url_path_join(
1756 utils.url_path_join(
1755 this.baseProjectUrl(),
1757 base_project_url,
1756 'notebooks',
1758 'notebooks',
1757 this.notebookPath(),
1759 path,
1758 notebook_name
1760 notebook_name
1759 ),
1761 ),
1760 '_blank'
1762 '_blank'
1761 );
1763 );
1762 }, this)
1764 }
1763 };
1765 };
1764 var url = this.baseProjectUrl() + 'api/notebooks' + path;
1766 var url = utils.url_path_join(
1767 base_project_url,
1768 'api/notebooks',
1769 path
1770 );
1765 $.ajax(url,settings);
1771 $.ajax(url,settings);
1766 };
1772 };
1767
1773
1768
1774
1769 Notebook.prototype.copy_notebook = function(){
1775 Notebook.prototype.copy_notebook = function(){
1770 var path = this.notebookPath();
1776 var path = this.notebookPath();
1777 var base_project_url = this.baseProjectUrl();
1771 var settings = {
1778 var settings = {
1772 processData : false,
1779 processData : false,
1773 cache : false,
1780 cache : false,
1774 type : "POST",
1781 type : "POST",
1775 success:$.proxy(function (data, status, xhr){
1782 dataType : "json",
1783 async : false,
1784 success : function (data, status, xhr) {
1776 var notebook_name = data.name;
1785 var notebook_name = data.name;
1777 window.open(utils.url_path_join(
1786 window.open(utils.url_path_join(
1778 this._baseProjectUrl,
1787 base_project_url,
1779 'notebooks',
1788 'notebooks',
1780 this.notebookPath(),
1789 path,
1781 notebook_name
1790 notebook_name
1782 ));
1791 ), '_blank');
1783 }, this)
1792 }
1784 };
1793 };
1785 var url = utils.url_path_join(
1794 var url = utils.url_path_join(
1786 this._baseProjectUrl,
1795 base_project_url,
1787 'api/notebooks',
1796 'api/notebooks',
1788 path,
1797 path,
1789 this.notebook_name,
1798 this.notebook_name,
@@ -364,25 +364,27 b' var IPython = (function (IPython) {'
364
364
365 NotebookList.prototype.new_notebook = function(){
365 NotebookList.prototype.new_notebook = function(){
366 var path = this.notebookPath();
366 var path = this.notebookPath();
367 var base_project_url = this.baseProjectUrl();
367 var settings = {
368 var settings = {
368 processData : false,
369 processData : false,
369 cache : false,
370 cache : false,
370 type : "POST",
371 type : "POST",
371 dataType : "json",
372 dataType : "json",
372 success:$.proxy(function (data, status, xhr){
373 async : false,
374 success : function (data, status, xhr) {
373 var notebook_name = data.name;
375 var notebook_name = data.name;
374 window.open(
376 window.open(
375 utils.url_path_join(
377 utils.url_path_join(
376 this.baseProjectUrl(),
378 base_project_url,
377 'notebooks',
379 'notebooks',
378 path,
380 path,
379 notebook_name),
381 notebook_name),
380 '_blank'
382 '_blank'
381 );
383 );
382 }, this)
384 }
383 };
385 };
384 var url = utils.url_path_join(
386 var url = utils.url_path_join(
385 this.baseProjectUrl(),
387 base_project_url,
386 'api/notebooks',
388 'api/notebooks',
387 path
389 path
388 );
390 );
General Comments 0
You need to be logged in to leave comments. Login now