From 7a300d7ff321987ac47f652135efbb8c3ced5f7e Mon Sep 17 00:00:00 2001 From: Bussonnier Matthias Date: Thu, 7 Feb 2013 23:32:48 +0100 Subject: [PATCH] make baseProjectUrl a method in Menubar --- .../frontend/html/notebook/static/js/menubar.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/menubar.js b/IPython/frontend/html/notebook/static/js/menubar.js index 0a584648a..0ec481d29 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); });