##// END OF EJS Templates
Fixing HTML cell syntax highlighting.
Fixing HTML cell syntax highlighting.

File last commit:

r4496:7640e547
r4505:3896ff19
Show More
savewidget.js
112 lines | 3.4 KiB | application/javascript | JavascriptLexer
Brian E. Granger
Minors fixes and initial work on save widget....
r4369
//============================================================================
// Cell
//============================================================================
var IPython = (function (IPython) {
var utils = IPython.utils;
var SaveWidget = function (selector) {
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 this.selector = selector;
Brian E. Granger
Massive work on the notebook document format....
r4484 this.notebook_name_re = /[^/\\]+/
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 if (this.selector !== undefined) {
this.element = $(selector);
this.style();
Brian E. Granger
Minors fixes and initial work on save widget....
r4369 this.bind_events();
}
};
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 SaveWidget.prototype.style = function () {
this.element.find('input#notebook_name').addClass('ui-widget ui-widget-content');
this.element.find('button#save_notebook').button();
var left_panel_width = $('div#left_panel').outerWidth();
var left_panel_splitter_width = $('div#left_panel_splitter').outerWidth();
$('span#save_widget').css({marginLeft:left_panel_width+left_panel_splitter_width});
};
Brian E. Granger
Minors fixes and initial work on save widget....
r4369 SaveWidget.prototype.bind_events = function () {
var that = this;
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 this.element.find('button#save_notebook').click(function () {
Brian E. Granger
Massive work on the notebook document format....
r4484 IPython.notebook.save_notebook();
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 });
Brian E. Granger
Using beforeunload to save at exit and kill the kernel.
r4496
$(window).bind('beforeunload', function () {
var kill_kernel = $('#kill_kernel').prop('checked');
IPython.notebook.save_notebook();
if (kill_kernel) {
IPython.notebook.kernel.kill();
return "You are about to exit this notebook and kill the kernel.";
} else {
return "You are about the exit this notebook and leave the kernel running.";
};
});
Brian E. Granger
Minors fixes and initial work on save widget....
r4369 };
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 SaveWidget.prototype.get_notebook_name = function () {
return this.element.find('input#notebook_name').attr('value');
}
Brian E. Granger
Massive work on the notebook document format....
r4484 SaveWidget.prototype.set_notebook_name = function (nbname) {
this.element.find('input#notebook_name').attr('value',nbname);
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 }
Brian E. Granger
Minors fixes and initial work on save widget....
r4369
Brian E. Granger
Massive work on the notebook document format....
r4484 SaveWidget.prototype.get_notebook_id = function () {
return this.element.find('span#notebook_id').text()
};
SaveWidget.prototype.update_url = function () {
var notebook_id = this.get_notebook_id();
if (notebook_id !== '') {
window.history.replaceState({}, '', notebook_id);
};
};
SaveWidget.prototype.test_notebook_name = function () {
var nbname = this.get_notebook_name();
if (this.notebook_name_re.test(nbname)) {
return true;
} else {
var bad_name = $('<div/>');
bad_name.html(
"The notebook name you entered (" +
nbname +
") is not valid. Notebook names can contain any characters except / and \\"
);
bad_name.dialog({title: 'Invalid name', modal: true});
return false;
};
};
SaveWidget.prototype.status_save = function () {
this.element.find('span.ui-button-text').text('Save');
this.element.find('button#save_notebook').button('enable');
};
SaveWidget.prototype.status_saving = function () {
this.element.find('span.ui-button-text').text('Saving');
this.element.find('button#save_notebook').button('disable');
};
SaveWidget.prototype.status_loading = function () {
this.element.find('span.ui-button-text').text('Loading');
this.element.find('button#save_notebook').button('disable');
};
Brian E. Granger
Minors fixes and initial work on save widget....
r4369 IPython.SaveWidget = SaveWidget;
return IPython;
}(IPython));