menubar.js
50 lines
| 1.4 KiB
| application/javascript
|
JavascriptLexer
Thomas Kluyver
|
r19012 | // Copyright (c) IPython Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||||
define([ | ||||
'base/js/namespace', | ||||
'jquery', | ||||
'base/js/utils', | ||||
'bootstrap', | ||||
], function(IPython, $, utils, bootstrap) { | ||||
"use strict"; | ||||
var MenuBar = function (selector, options) { | ||||
Jonathan Frederic
|
r19176 | /** | ||
* Constructor | ||||
* | ||||
* A MenuBar Class to generate the menubar of IPython notebook | ||||
* | ||||
* Parameters: | ||||
* selector: string | ||||
* options: dictionary | ||||
* Dictionary of keyword arguments. | ||||
* codemirror: CodeMirror instance | ||||
* contents: ContentManager instance | ||||
* events: $(Events) instance | ||||
* base_url : string | ||||
* file_path : string | ||||
*/ | ||||
Thomas Kluyver
|
r19012 | options = options || {}; | ||
this.base_url = options.base_url || utils.get_body_data("baseUrl"); | ||||
this.selector = selector; | ||||
Thomas Kluyver
|
r19013 | this.editor = options.editor; | ||
Thomas Kluyver
|
r19012 | |||
if (this.selector !== undefined) { | ||||
this.element = $(selector); | ||||
this.bind_events(); | ||||
} | ||||
}; | ||||
MenuBar.prototype.bind_events = function () { | ||||
Jonathan Frederic
|
r19176 | /** | ||
* File | ||||
*/ | ||||
Thomas Kluyver
|
r19012 | var that = this; | ||
this.element.find('#save_file').click(function () { | ||||
Thomas Kluyver
|
r19013 | that.editor.save(); | ||
Thomas Kluyver
|
r19012 | }); | ||
}; | ||||
return {'MenuBar': MenuBar}; | ||||
}); | ||||