diff --git a/IPython/frontend/html/notebook/static/js/menubar.js b/IPython/frontend/html/notebook/static/js/menubar.js index 0a58464..0ec481d 100644 --- a/IPython/frontend/html/notebook/static/js/menubar.js +++ b/IPython/frontend/html/notebook/static/js/menubar.js @@ -20,6 +20,10 @@ var IPython = (function (IPython) { } }; + MenuBar.prototype.baseProjectUrl = function(){ + return $('body').data('baseProjectUrl'); + } + MenuBar.prototype.style = function () { this.element.addClass('border-box-sizing'); @@ -37,17 +41,17 @@ var IPython = (function (IPython) { MenuBar.prototype.bind_events = function () { // File this.element.find('#new_notebook').click(function () { - window.open($('body').data('baseProjectUrl')+'new'); + window.open(this.baseProjectUrl()+'new'); }); this.element.find('#open_notebook').click(function () { - window.open($('body').data('baseProjectUrl')); + window.open(this.baseProjectUrl()); }); this.element.find('#rename_notebook').click(function () { IPython.save_widget.rename_notebook(); }); this.element.find('#copy_notebook').click(function () { var notebook_id = IPython.notebook.get_notebook_id(); - var url = $('body').data('baseProjectUrl') + notebook_id + '/copy'; + var url = this.baseProjectUrl() + notebook_id + '/copy'; window.open(url,'_blank'); return false; }); @@ -56,13 +60,13 @@ var IPython = (function (IPython) { }); this.element.find('#download_ipynb').click(function () { var notebook_id = IPython.notebook.get_notebook_id(); - var url = $('body').data('baseProjectUrl') + 'notebooks/' + + var url = this.baseProjectUrl() + 'notebooks/' + notebook_id + '?format=json'; window.location.assign(url); }); this.element.find('#download_py').click(function () { var notebook_id = IPython.notebook.get_notebook_id(); - var url = $('body').data('baseProjectUrl') + 'notebooks/' + + var url = this.baseProjectUrl() + 'notebooks/' + notebook_id + '?format=py'; window.location.assign(url); });