//---------------------------------------------------------------------------- // 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. //---------------------------------------------------------------------------- //============================================================================ // SaveWidget //============================================================================ var IPython = (function (IPython) { var utils = IPython.utils; var SaveWidget = function (selector) { this.selector = selector; if (this.selector !== undefined) { this.element = $(selector); this.style(); this.bind_events(); } }; SaveWidget.prototype.style = function () { }; SaveWidget.prototype.bind_events = function () { var that = this; this.element.find('span#notebook_name').click(function () { that.rename_notebook(); }); this.element.find('span#notebook_name').hover(function () { $(this).addClass("ui-state-hover"); }, function () { $(this).removeClass("ui-state-hover"); }); $([IPython.events]).on('notebook_loaded.Notebook', function () { that.update_notebook_name(); that.update_document_title(); }); $([IPython.events]).on('notebook_saved.Notebook', function () { that.update_notebook_name(); that.update_document_title(); }); $([IPython.events]).on('notebook_save_failed.Notebook', function () { that.set_save_status('Autosave Failed!'); }); $([IPython.events]).on('checkpoints_listed.Notebook', function (event, data) { that.set_last_checkpoint(data[0]); }); $([IPython.events]).on('checkpoint_created.Notebook', function (event, data) { that.set_last_checkpoint(data); }); $([IPython.events]).on('set_dirty.Notebook', function (event, data) { that.set_autosaved(data.value); }); }; SaveWidget.prototype.rename_notebook = function () { var that = this; var dialog = $('
').append( $("").addClass("rename-message") .html('Enter a new notebook name:') ).append( $("