##// END OF EJS Templates
Function to refactor print statements in doctests to print() function calls for Python 3.
Function to refactor print statements in doctests to print() function calls for Python 3.

File last commit:

r4660:de11bafe
r4890:055cc6cb
Show More
savewidget.js
147 lines | 4.6 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;
Brian E. Granger
Massive work on the notebook document format....
r4484 this.notebook_name_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();
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();
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');
}
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;
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();
document.title = 'IPy: ' + nbname;
};
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 () {
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));