##// END OF EJS Templates
cleanup dangling kernel in test_kernelsession
cleanup dangling kernel in test_kernelsession

File last commit:

r5479:0168dc21
r5629:ba0b0dbd
Show More
savewidget.js
157 lines | 4.8 KiB | application/javascript | JavascriptLexer
Brian E. Granger
More review changes....
r4609 //----------------------------------------------------------------------------
// 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.
//----------------------------------------------------------------------------
Brian E. Granger
Minors fixes and initial work on save widget....
r4369
//============================================================================
Brian E. Granger
More review changes....
r4609 // SaveWidget
Brian E. Granger
Minors fixes and initial work on save widget....
r4369 //============================================================================
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;
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 this.notebook_name_blacklist_re = /[\/\\]/;
Brian E. Granger
Fixing logic for rename behavior.
r4632 this.last_saved_name = '';
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');
Brian E. Granger
Save button becomes Rename when the notebook name changes.
r4630 this.element.find('input#notebook_name').attr('tabindex','1');
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 this.element.find('button#save_notebook').button();
MinRK
Add tooltips to the notebook via 'title' attr....
r5097 this.element.find('button#save_notebook').attr('title', 'Save the Notebook');
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 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
Save button becomes Rename when the notebook name changes.
r4630
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 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
Adding keyboard shortcuts.
r4645 that.save_notebook();
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 });
Brian E. Granger
Fixing logic for rename behavior.
r4632 this.element.find('input#notebook_name').keyup(function () {
that.is_renaming();
Brian E. Granger
Save button becomes Rename when the notebook name changes.
r4630 });
Brian E. Granger
Minors fixes and initial work on save widget....
r4369 };
Brian E. Granger
Adding keyboard shortcuts.
r4645 SaveWidget.prototype.save_notebook = function () {
IPython.notebook.save_notebook();
Felix Werner
Update document title and last_saved_name only after a successful save.
r5006 };
SaveWidget.prototype.notebook_saved = function () {
Brian E. Granger
Adding keyboard shortcuts.
r4645 this.set_document_title();
this.last_saved_name = this.get_notebook_name();
};
Brian E. Granger
Fixing logic for rename behavior.
r4632 SaveWidget.prototype.is_renaming = function () {
if (this.get_notebook_name() !== this.last_saved_name) {
this.status_rename();
} else {
this.status_save();
};
};
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');
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 };
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372
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
Browser window title follows the name of the notebook.
r4549 this.set_document_title();
Brian E. Granger
Fixing logic for rename behavior.
r4632 this.last_saved_name = nbname;
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 };
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
Browser window title follows the name of the notebook.
r4549 SaveWidget.prototype.set_document_title = function () {
nbname = this.get_notebook_name();
Brian E. Granger
Misc changes to the notebook....
r5104 document.title = nbname;
Brian E. Granger
Browser window title follows the name of the notebook.
r4549 };
Brian E. Granger
Massive work on the notebook document format....
r4484 SaveWidget.prototype.get_notebook_id = function () {
Brian E. Granger
Adding base_project_url and base_kernel_url as HTML data attribs....
r5100 return $('body').data('notebookId');
Brian E. Granger
Massive work on the notebook document format....
r4484 };
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();
Felix Werner
Fixed testing of new notebook name before saving.
r5008 if (this.notebook_name_blacklist_re.test(nbname) == false) {
Brian E. Granger
Massive work on the notebook document format....
r4484 return true;
} else {
var bad_name = $('<div/>');
bad_name.html(
"The notebook name you entered (" +
nbname +
Felix Werner
Fixed testing of new notebook name before saving.
r5008 ") is not valid. Notebook names can contain any characters except / and \\."
Brian E. Granger
Massive work on the notebook document format....
r4484 );
bad_name.dialog({title: 'Invalid name', modal: true});
return false;
};
};
Felix Werner
Notify the user of errors when saving a notebook.
r5007 SaveWidget.prototype.reset_status = function () {
this.is_renaming();
};
Brian E. Granger
Massive work on the notebook document format....
r4484 SaveWidget.prototype.status_save = function () {
MinRK
underline keyboard shortcut letter on buttons
r4660 this.element.find('button#save_notebook').button('option', 'label', '<u>S</u>ave');
Brian E. Granger
Massive work on the notebook document format....
r4484 this.element.find('button#save_notebook').button('enable');
Stefan van der Walt
Refactor static printing.
r4615 IPython.print_widget.enable();
Stefan van der Walt
Implement static publishing of HTML notebook.
r4592 };
Brian E. Granger
Massive work on the notebook document format....
r4484
SaveWidget.prototype.status_saving = function () {
Stefan van der Walt
Refactor static printing.
r4615 this.element.find('button#save_notebook').button('option', 'label', 'Saving');
Brian E. Granger
Massive work on the notebook document format....
r4484 this.element.find('button#save_notebook').button('disable');
Stefan van der Walt
Refactor static printing.
r4615 IPython.print_widget.disable();
Stefan van der Walt
Implement static publishing of HTML notebook.
r4592 };
Brian E. Granger
Massive work on the notebook document format....
r4484
SaveWidget.prototype.status_loading = function () {
Stefan van der Walt
Refactor static printing.
r4615 this.element.find('button#save_notebook').button('option', 'label', 'Loading');
Brian E. Granger
Massive work on the notebook document format....
r4484 this.element.find('button#save_notebook').button('disable');
Stefan van der Walt
Refactor static printing.
r4615 IPython.print_widget.disable();
Brian E. Granger
Massive work on the notebook document format....
r4484 };
Brian E. Granger
Save button becomes Rename when the notebook name changes.
r4630 SaveWidget.prototype.status_rename = function () {
this.element.find('button#save_notebook').button('option', 'label', 'Rename');
this.element.find('button#save_notebook').button('enable');
IPython.print_widget.enable();
};
Brian E. Granger
Minors fixes and initial work on save widget....
r4369 IPython.SaveWidget = SaveWidget;
return IPython;
}(IPython));