|
|
|
|
@ -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);
|
|
|
|
|
});
|
|
|
|
|
|