##// END OF EJS Templates
Add MIME types to nbconvert exporters
Add MIME types to nbconvert exporters

File last commit:

r13829:5778b75f
r13830:8d4507b1
Show More
menubar.js
322 lines | 11.3 KiB | application/javascript | JavascriptLexer
Brian Granger
Implemented menu based UI using Wijmo.
r5857 //----------------------------------------------------------------------------
// Copyright (C) 2008-2011 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
//============================================================================
// MenuBar
//============================================================================
Bussonnier Matthias
add option in menubar to set baseproject url
r9501 /**
* @module IPython
* @namespace IPython
* @submodule MenuBar
*/
Brian Granger
Implemented menu based UI using Wijmo.
r5857 var IPython = (function (IPython) {
Matthias BUSSONNIER
"use strict" in most (if not all) our javascript...
r12103 "use strict";
MinRK
save before download-as...
r13076
var utils = IPython.utils;
Brian Granger
Implemented menu based UI using Wijmo.
r5857
Bussonnier Matthias
add option in menubar to set baseproject url
r9501 /**
Zachary Sailer
fix kill_and_exit button in notebook
r12995 * A MenuBar Class to generate the menubar of IPython notebook
Bussonnier Matthias
add option in menubar to set baseproject url
r9501 * @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) {
MinRK
review pass on multidir js
r13103 options = options || {};
if (options.baseProjectUrl !== undefined) {
Bussonnier Matthias
add option in menubar to set baseproject url
r9501 this._baseProjectUrl = options.baseProjectUrl;
}
Brian Granger
Implemented menu based UI using Wijmo.
r5857 this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
this.bind_events();
}
};
Bussonnier Matthias
make baseProjectUrl a method in Menubar
r9500 MenuBar.prototype.baseProjectUrl = function(){
Bussonnier Matthias
add option in menubar to set baseproject url
r9501 return this._baseProjectUrl || $('body').data('baseProjectUrl');
Bussonnier Matthias
change more baseurl
r9503 };
Bussonnier Matthias
make baseProjectUrl a method in Menubar
r9500
Zachary Sailer
fixing path redirects, cleaning path logic
r12992 MenuBar.prototype.notebookPath = function() {
var path = $('body').data('notebookPath');
Zachary Sailer
fixing broken links from recent changes....
r13033 path = decodeURIComponent(path);
MinRK
review pass on multidir js
r13103 return path;
Zachary Sailer
manual rebase static/notebook/js files
r12986 };
Brian Granger
Implemented menu based UI using Wijmo.
r5857 MenuBar.prototype.style = function () {
Brian Granger
Major refactoring of notebook....
r6193 this.element.addClass('border-box-sizing');
MinRK
bootstrap menubar
r10888 this.element.find("li").click(function (event, ui) {
Brian Granger
Fixing minor typo in menubar.js.
r5908 // The selected cell loses focus when the menu is entered, so we
Brian Granger
Cell splitting and merging is done!
r5898 // re-select it upon selection.
Brian Granger
Refactoring of the notebooks cell management....
r5945 var i = IPython.notebook.get_selected_index();
Brian Granger
Cell splitting and merging is done!
r5898 IPython.notebook.select(i);
}
MinRK
bootstrap menubar
r10888 );
Brian Granger
Implemented menu based UI using Wijmo.
r5857 };
Thomas Kluyver
Add menu entries for getting converted views of a notebook
r13829 MenuBar.prototype._nbconvert = function (format, download) {
download = download || false;
var notebook_name = IPython.notebook.get_notebook_name();
if (IPython.notebook.dirty) {
IPython.notebook.save_notebook({async : false});
}
var url = utils.url_path_join(
this.baseProjectUrl(),
'nbconvert',
format,
this.notebookPath(),
notebook_name + '.ipynb'
) + "?download=" + download.toString();
if (download) {
window.location.assign(url);
} else {
window.open(url);
}
}
Brian Granger
Implemented menu based UI using Wijmo.
r5857
MenuBar.prototype.bind_events = function () {
// File
Matthias BUSSONNIER
fix baseUrl
r9699 var that = this;
Zachary Sailer
fixing path redirects, cleaning path logic
r12992 this.element.find('#new_notebook').click(function () {
Zachary Sailer
removed '/new' URL and added POST notebook request
r13016 IPython.notebook.new_notebook();
Zachary Sailer
fixing path redirects, cleaning path logic
r12992 });
this.element.find('#open_notebook').click(function () {
MinRK
review pass on multidir js
r13103 window.open(utils.url_path_join(
that.baseProjectUrl(),
'tree',
that.notebookPath()
));
Zachary Sailer
fixing path redirects, cleaning path logic
r12992 });
this.element.find('#copy_notebook').click(function () {
Zachary Sailer
Change new/copy URLS to POST requests
r13017 IPython.notebook.copy_notebook();
Zachary Sailer
fixing path redirects, cleaning path logic
r12992 return false;
});
this.element.find('#download_ipynb').click(function () {
var notebook_name = IPython.notebook.get_notebook_name();
MinRK
save before download-as...
r13076 if (IPython.notebook.dirty) {
IPython.notebook.save_notebook({async : false});
}
var url = utils.url_path_join(
that.baseProjectUrl(),
Brian E. Granger
Handle notebook downloads through the /files URL.
r13114 'files',
MinRK
save before download-as...
r13076 that.notebookPath(),
Brian E. Granger
Handle notebook downloads through the /files URL.
r13114 notebook_name + '.ipynb'
MinRK
save before download-as...
r13076 );
Zachary Sailer
fixing path redirects, cleaning path logic
r12992 window.location.assign(url);
});
MinRK
disable download-as-pt...
r13108
Thomas Kluyver
Add menu entries for getting converted views of a notebook
r13829 this.element.find('#print_preview').click(function () {
that._nbconvert('html', false);
});
Zachary Sailer
fixing path redirects, cleaning path logic
r12992 this.element.find('#download_py').click(function () {
Thomas Kluyver
Add menu entries for getting converted views of a notebook
r13829 that._nbconvert('python', true);
});
this.element.find('#download_html').click(function () {
that._nbconvert('html', true);
Zachary Sailer
fixing path redirects, cleaning path logic
r12992 });
MinRK
disable download-as-pt...
r13108
Brian Granger
Improved notebook renaming....
r5859 this.element.find('#rename_notebook').click(function () {
IPython.save_widget.rename_notebook();
});
MinRK
expose notebook checkpoints in html/js...
r10501 this.element.find('#save_checkpoint').click(function () {
IPython.notebook.save_checkpoint();
});
MinRK
add Revert to the menu bar
r10503 this.element.find('#restore_checkpoint').click(function () {
});
Matthias BUSSONNIER
add 'Close and halt' in notebook filemenu
r6850 this.element.find('#kill_and_exit').click(function () {
Paul Ivanov
fix 'close and halt' in notebook File menu
r13146 IPython.notebook.session.delete();
Paul Ivanov
make close-and-halt work on new tabs in Chrome...
r13338 setTimeout(function(){
// allow closing of new tabs in Chromium, impossible in FF
window.open('', '_self', '');
window.close();
}, 500);
Matthias BUSSONNIER
add 'Close and halt' in notebook filemenu
r6850 });
Brian Granger
Implemented menu based UI using Wijmo.
r5857 // Edit
Brian Granger
Added cell level cut/copy/paste.
r5879 this.element.find('#cut_cell').click(function () {
IPython.notebook.cut_cell();
});
this.element.find('#copy_cell').click(function () {
IPython.notebook.copy_cell();
});
Brian Granger
Implemented menu based UI using Wijmo.
r5857 this.element.find('#delete_cell').click(function () {
IPython.notebook.delete_cell();
});
MinRK
add menu item for undo delete cell...
r9551 this.element.find('#undelete_cell').click(function () {
IPython.notebook.undelete();
});
Brian Granger
Basic code cell splitting implemented.
r5896 this.element.find('#split_cell').click(function () {
IPython.notebook.split_cell();
});
this.element.find('#merge_cell_above').click(function () {
IPython.notebook.merge_cell_above();
});
this.element.find('#merge_cell_below').click(function () {
IPython.notebook.merge_cell_below();
});
Brian Granger
Implemented menu based UI using Wijmo.
r5857 this.element.find('#move_cell_up').click(function () {
IPython.notebook.move_cell_up();
});
this.element.find('#move_cell_down').click(function () {
IPython.notebook.move_cell_down();
});
Brian Granger
Cleaning up menu code....
r5858 this.element.find('#select_previous').click(function () {
IPython.notebook.select_prev();
});
this.element.find('#select_next').click(function () {
IPython.notebook.select_next();
});
MinRK
add Edit Notebook Metadata to Edit menu
r12913 this.element.find('#edit_nb_metadata').click(function () {
IPython.notebook.edit_metadata();
});
Brian Granger
Further work on the toolbar UI....
r5994 // View
this.element.find('#toggle_header').click(function () {
$('div#header').toggle();
IPython.layout_manager.do_resize();
});
this.element.find('#toggle_toolbar').click(function () {
MinRK
tweak header styling...
r10906 $('div#maintoolbar').toggle();
IPython.layout_manager.do_resize();
Brian Granger
Further work on the toolbar UI....
r5994 });
Brian Granger
Implemented menu based UI using Wijmo.
r5857 // Insert
this.element.find('#insert_cell_above').click(function () {
Brian Granger
Refactoring of the notebooks cell management....
r5945 IPython.notebook.insert_cell_above('code');
Brian Granger
Implemented menu based UI using Wijmo.
r5857 });
this.element.find('#insert_cell_below').click(function () {
Brian Granger
Refactoring of the notebooks cell management....
r5945 IPython.notebook.insert_cell_below('code');
Brian Granger
Implemented menu based UI using Wijmo.
r5857 });
// Cell
this.element.find('#run_cell').click(function () {
IPython.notebook.execute_selected_cell();
});
this.element.find('#run_cell_in_place').click(function () {
IPython.notebook.execute_selected_cell({terminal:true});
});
this.element.find('#run_all_cells').click(function () {
IPython.notebook.execute_all_cells();
Paul Ivanov
javascript is no place to start adding title tags
r13159 });
Paul Ivanov
fine-grained notebook 'run' controls, closes #2521...
r8606 this.element.find('#run_all_cells_above').click(function () {
IPython.notebook.execute_cells_above();
Paul Ivanov
javascript is no place to start adding title tags
r13159 });
Paul Ivanov
fine-grained notebook 'run' controls, closes #2521...
r8606 this.element.find('#run_all_cells_below').click(function () {
IPython.notebook.execute_cells_below();
Paul Ivanov
javascript is no place to start adding title tags
r13159 });
Brian Granger
Implemented menu based UI using Wijmo.
r5857 this.element.find('#to_code').click(function () {
IPython.notebook.to_code();
});
this.element.find('#to_markdown').click(function () {
IPython.notebook.to_markdown();
});
MinRK
rename plaintext cell -> raw cell
r6248 this.element.find('#to_raw').click(function () {
IPython.notebook.to_raw();
Brian Granger
A first go at RST cell support in the notebook.
r6017 });
Brian Granger
Finishing first draft of RST and heading cells.
r6019 this.element.find('#to_heading1').click(function () {
IPython.notebook.to_heading(undefined, 1);
});
this.element.find('#to_heading2').click(function () {
IPython.notebook.to_heading(undefined, 2);
});
this.element.find('#to_heading3').click(function () {
IPython.notebook.to_heading(undefined, 3);
});
this.element.find('#to_heading4').click(function () {
IPython.notebook.to_heading(undefined, 4);
});
this.element.find('#to_heading5').click(function () {
IPython.notebook.to_heading(undefined, 5);
});
this.element.find('#to_heading6').click(function () {
IPython.notebook.to_heading(undefined, 6);
});
Brian Granger
Implemented menu based UI using Wijmo.
r5857 this.element.find('#toggle_output').click(function () {
IPython.notebook.toggle_output();
});
MinRK
third attempt at scrolled long output...
r7362 this.element.find('#collapse_all_output').click(function () {
IPython.notebook.collapse_all_output();
});
this.element.find('#scroll_all_output').click(function () {
IPython.notebook.scroll_all_output();
});
this.element.find('#expand_all_output').click(function () {
IPython.notebook.expand_all_output();
});
Brian Granger
Implemented menu based UI using Wijmo.
r5857 this.element.find('#clear_all_output').click(function () {
IPython.notebook.clear_all_output();
});
// Kernel
this.element.find('#int_kernel').click(function () {
Zachary Sailer
fix restart/interrupt kernel buttons
r12994 IPython.notebook.session.interrupt_kernel();
Brian Granger
Implemented menu based UI using Wijmo.
r5857 });
this.element.find('#restart_kernel').click(function () {
IPython.notebook.restart_kernel();
});
Brian Granger
Cleaning up menu code....
r5858 // Help
this.element.find('#keyboard_shortcuts').click(function () {
IPython.quick_help.show_keyboard_shortcuts();
});
MinRK
add Revert to the menu bar
r10503
this.update_restore_checkpoint(null);
$([IPython.events]).on('checkpoints_listed.Notebook', function (event, data) {
MinRK
minor checkpoint cleanup...
r12050 that.update_restore_checkpoint(IPython.notebook.checkpoints);
MinRK
add Revert to the menu bar
r10503 });
$([IPython.events]).on('checkpoint_created.Notebook', function (event, data) {
MinRK
minor checkpoint cleanup...
r12050 that.update_restore_checkpoint(IPython.notebook.checkpoints);
MinRK
add Revert to the menu bar
r10503 });
Brian Granger
Implemented menu based UI using Wijmo.
r5857 };
MinRK
restore checkpoints in a sub-list...
r10520 MenuBar.prototype.update_restore_checkpoint = function(checkpoints) {
MinRK
add 'No Checkpoints' to Revert menu...
r11117 var ul = this.element.find("#restore_checkpoint").find("ul");
ul.empty();
MinRK
review pass on multidir js
r13103 if (!checkpoints || checkpoints.length === 0) {
MinRK
add 'No Checkpoints' to Revert menu...
r11117 ul.append(
$("<li/>")
.addClass("disabled")
.append(
$("<a/>")
.text("No checkpoints")
)
);
return;
MinRK
review pass on multidir js
r13103 }
MinRK
remove debug statement...
r11164
MinRK
minor checkpoint cleanup...
r12050 checkpoints.map(function (checkpoint) {
MinRK
restore checkpoints in a sub-list...
r10520 var d = new Date(checkpoint.last_modified);
MinRK
add 'No Checkpoints' to Revert menu...
r11117 ul.append(
$("<li/>").append(
$("<a/>")
.attr("href", "#")
.text(d.format("mmm dd HH:MM:ss"))
.click(function () {
IPython.notebook.restore_checkpoint_dialog(checkpoint);
})
)
);
MinRK
minor checkpoint cleanup...
r12050 });
MinRK
restore checkpoints in a sub-list...
r10520 };
Brian Granger
Implemented menu based UI using Wijmo.
r5857
IPython.MenuBar = MenuBar;
return IPython;
}(IPython));