savewidget.js
52 lines
| 1.5 KiB
| application/javascript
|
JavascriptLexer
Brian E. Granger
|
r4369 | |||
//============================================================================ | ||||
// Cell | ||||
//============================================================================ | ||||
var IPython = (function (IPython) { | ||||
var utils = IPython.utils; | ||||
var SaveWidget = function (selector) { | ||||
Brian E. Granger
|
r4372 | this.selector = selector; | ||
if (this.selector !== undefined) { | ||||
this.element = $(selector); | ||||
this.style(); | ||||
Brian E. Granger
|
r4369 | this.bind_events(); | ||
} | ||||
}; | ||||
Brian E. Granger
|
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
|
r4369 | SaveWidget.prototype.bind_events = function () { | ||
var that = this; | ||||
Brian E. Granger
|
r4372 | this.element.find('button#save_notebook').click(function () { | ||
IPython.notebook.save_notebook(that.get_notebook_name()); | ||||
}); | ||||
Brian E. Granger
|
r4369 | }; | ||
Brian E. Granger
|
r4372 | SaveWidget.prototype.get_notebook_name = function () { | ||
return this.element.find('input#notebook_name').attr('value'); | ||||
} | ||||
SaveWidget.prototype.set_notebook_name = function (name) { | ||||
this.element.find('input#notebook_name').attr('value',name); | ||||
} | ||||
Brian E. Granger
|
r4369 | |||
IPython.SaveWidget = SaveWidget; | ||||
return IPython; | ||||
}(IPython)); | ||||