diff --git a/IPython/frontend/html/notebook/static/js/clusterlist.js b/IPython/frontend/html/notebook/static/js/clusterlist.js
index 2808bbfb9..8ef1de082 100644
--- a/IPython/frontend/html/notebook/static/js/clusterlist.js
+++ b/IPython/frontend/html/notebook/static/js/clusterlist.js
@@ -20,6 +20,10 @@ var IPython = (function (IPython) {
}
};
+ ClusterList.prototype.baseProjectUrl = function(){
+ return this._baseProjectUrl || $('body').data('baseProjectUrl');
+ };
+
ClusterList.prototype.style = function () {
$('#cluster_toolbar').addClass('list_toolbar');
$('#cluster_list_info').addClass('toolbar_info');
@@ -52,7 +56,7 @@ var IPython = (function (IPython) {
dataType : "json",
success : $.proxy(this.load_list_success, this)
};
- var url = $('body').data('baseProjectUrl') + 'clusters';
+ var url = this.baseProjectUrl() + 'clusters';
$.ajax(url, settings);
};
@@ -134,7 +138,7 @@ var IPython = (function (IPython) {
}
};
status_col.html('starting');
- var url = $('body').data('baseProjectUrl') + 'clusters/' + that.data.profile + '/start';
+ var url = this.baseProjectUrl() + 'clusters/' + that.data.profile + '/start';
$.ajax(url, settings);
};
});
@@ -168,7 +172,7 @@ var IPython = (function (IPython) {
}
};
status_col.html('stopping')
- var url = $('body').data('baseProjectUrl') + 'clusters/' + that.data.profile + '/stop';
+ var url = this.baseProjectUrl() + 'clusters/' + that.data.profile + '/stop';
$.ajax(url, settings);
});
};
diff --git a/IPython/frontend/html/notebook/static/js/loginwidget.js b/IPython/frontend/html/notebook/static/js/loginwidget.js
index d0d739e3b..96fc030e6 100644
--- a/IPython/frontend/html/notebook/static/js/loginwidget.js
+++ b/IPython/frontend/html/notebook/static/js/loginwidget.js
@@ -10,9 +10,10 @@
//============================================================================
var IPython = (function (IPython) {
- var base_url = $('body').data('baseProjectUrl');
- var LoginWidget = function (selector) {
+ var LoginWidget = function (selector, options) {
+ var options = options || {};
+ this.base_url = options.baseProjectUrl || $('body').data('baseProjectUrl') ;
this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
@@ -30,10 +31,10 @@ var IPython = (function (IPython) {
LoginWidget.prototype.bind_events = function () {
var that = this;
this.element.find("button#logout").click(function () {
- window.location = base_url+"logout";
+ window.location = that.base_url+"logout";
});
this.element.find("button#login").click(function () {
- window.location = base_url+"login";
+ window.location = that.base_url+"login";
});
};
diff --git a/IPython/frontend/html/notebook/static/js/menubar.js b/IPython/frontend/html/notebook/static/js/menubar.js
index 470f92bf0..fc586cf26 100644
--- a/IPython/frontend/html/notebook/static/js/menubar.js
+++ b/IPython/frontend/html/notebook/static/js/menubar.js
@@ -9,9 +9,34 @@
// MenuBar
//============================================================================
+/**
+ * @module IPython
+ * @namespace IPython
+ * @submodule MenuBar
+ */
+
+
var IPython = (function (IPython) {
- var MenuBar = function (selector) {
+ /**
+ * A MenuBar Class to generate the menubar of IPython noteboko
+ * @Class MenuBar
+ *
+ * @constructor
+ *
+ *
+ * @param selector {string} selector for the menubar element in DOM
+ * @param {object} [options]
+ * @param [options.baseProjectUrl] {String} String to use for the
+ * Base Project url, default would be to inspect
+ * $('body').data('baseProjectUrl');
+ * does not support change for now is set through this option
+ */
+ var MenuBar = function (selector, options) {
+ var options = options || {};
+ if(options.baseProjectUrl!= undefined){
+ this._baseProjectUrl = options.baseProjectUrl;
+ }
this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
@@ -20,6 +45,10 @@ var IPython = (function (IPython) {
}
};
+ MenuBar.prototype.baseProjectUrl = function(){
+ return this._baseProjectUrl || $('body').data('baseProjectUrl');
+ };
+
MenuBar.prototype.style = function () {
this.element.addClass('border-box-sizing');
@@ -37,17 +66,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 +85,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);
});
diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js
index 7c7ecdac2..2caa3ee95 100644
--- a/IPython/frontend/html/notebook/static/js/notebook.js
+++ b/IPython/frontend/html/notebook/static/js/notebook.js
@@ -14,8 +14,11 @@ var IPython = (function (IPython) {
var utils = IPython.utils;
var key = IPython.utils.keycodes;
- var Notebook = function (selector) {
- this.read_only = IPython.read_only;
+ var Notebook = function (selector, options) {
+ var options = options || {};
+ this._baseProjectUrl = options.baseProjectUrl;
+ this.read_only = options.read_only || IPython.read_only;
+
this.element = $(selector);
this.element.scroll();
this.element.data("notebook", this);
@@ -46,6 +49,10 @@ var IPython = (function (IPython) {
$('div#notebook').addClass('border-box-sizing');
};
+ Notebook.prototype.baseProjectUrl = function(){
+ return this._baseProjectUrl || $('body').data('baseProjectUrl');
+ };
+
Notebook.prototype.create_elements = function () {
// We add this end_space div to the end of the notebook div to:
@@ -1239,7 +1246,7 @@ var IPython = (function (IPython) {
error : $.proxy(this.save_notebook_error,this)
};
$([IPython.events]).trigger('notebook_saving.Notebook');
- var url = $('body').data('baseProjectUrl') + 'notebooks/' + this.notebook_id;
+ var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id;
$.ajax(url, settings);
};
@@ -1268,7 +1275,7 @@ var IPython = (function (IPython) {
error : $.proxy(this.load_notebook_error,this),
};
$([IPython.events]).trigger('notebook_loading.Notebook');
- var url = $('body').data('baseProjectUrl') + 'notebooks/' + this.notebook_id;
+ var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id;
$.ajax(url, settings);
};
diff --git a/IPython/frontend/html/notebook/static/js/notebooklist.js b/IPython/frontend/html/notebook/static/js/notebooklist.js
index 6402eccda..58b681e19 100644
--- a/IPython/frontend/html/notebook/static/js/notebooklist.js
+++ b/IPython/frontend/html/notebook/static/js/notebooklist.js
@@ -20,6 +20,10 @@ var IPython = (function (IPython) {
}
};
+ NotebookList.prototype.baseProjectUrl = function () {
+ return $('body').data('baseProjectUrl')
+ };
+
NotebookList.prototype.style = function () {
$('#notebook_toolbar').addClass('list_toolbar');
$('#drag_info').addClass('toolbar_info');
@@ -100,7 +104,7 @@ var IPython = (function (IPython) {
},this)
};
- var url = $('body').data('baseProjectUrl') + 'notebooks';
+ var url = this.baseProjectUrl() + 'notebooks';
$.ajax(url, settings);
};
@@ -162,7 +166,7 @@ var IPython = (function (IPython) {
var new_item_name = $('').addClass('item_name');
new_item_name.append(
$('').
- attr('href', $('body').data('baseProjectUrl')+notebook_id).
+ attr('href', this.baseProjectUrl()+notebook_id).
attr('target','_blank').
text(nbname)
);
@@ -212,7 +216,7 @@ var IPython = (function (IPython) {
that.load_list();
}
};
- var url = $('body').data('baseProjectUrl') + 'kernels/'+kernel;
+ var url = this.baseProjectUrl() + 'kernels/'+kernel;
$.ajax(url, settings);
});
new_buttons.append(shutdown_button);
@@ -253,7 +257,7 @@ var IPython = (function (IPython) {
parent_item.remove();
}
};
- var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id;
+ var url = this.baseProjectUrl() + 'notebooks/' + notebook_id;
$.ajax(url, settings);
$(this).dialog('close');
},
@@ -302,7 +306,7 @@ var IPython = (function (IPython) {
};
var qs = $.param({name:nbname, format:nbformat});
- var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs;
+ var url = this.baseProjectUrl() + 'notebooks?' + qs;
$.ajax(url, settings);
});
var cancel_button = $('').button().
diff --git a/IPython/frontend/html/notebook/static/js/notebookmain.js b/IPython/frontend/html/notebook/static/js/notebookmain.js
index c19150d78..297822dba 100644
--- a/IPython/frontend/html/notebook/static/js/notebookmain.js
+++ b/IPython/frontend/html/notebook/static/js/notebookmain.js
@@ -39,15 +39,17 @@ $(document).ready(function () {
// The header's bottom border is provided by the menu bar so we remove it.
$('div#header').css('border-bottom-style','none');
+ var baseProjectUrl = $('body').data('baseProjectUrl')
+
IPython.page = new IPython.Page();
IPython.markdown_converter = new Markdown.Converter();
IPython.layout_manager = new IPython.LayoutManager();
IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
- IPython.login_widget = new IPython.LoginWidget('span#login_widget');
- IPython.notebook = new IPython.Notebook('div#notebook');
+ IPython.login_widget = new IPython.LoginWidget('span#login_widget',{baseProjectUrl:baseProjectUrl});
+ IPython.notebook = new IPython.Notebook('div#notebook',{baseProjectUrl:baseProjectUrl, read_only:IPython.read_only});
IPython.save_widget = new IPython.SaveWidget('span#save_widget');
- IPython.menubar = new IPython.MenuBar('#menubar')
+ IPython.menubar = new IPython.MenuBar('#menubar',{baseProjectUrl:baseProjectUrl})
IPython.toolbar = new IPython.MainToolBar('#maintoolbar')
IPython.tooltip = new IPython.Tooltip()
IPython.notification_area = new IPython.NotificationArea('#notification_area')