Show More
@@ -0,0 +1,202 b'' | |||||
|
1 | // Copyright (c) IPython Development Team. | |||
|
2 | // Distributed under the terms of the Modified BSD License. | |||
|
3 | ||||
|
4 | define([ | |||
|
5 | 'base/js/namespace', | |||
|
6 | 'jquery', | |||
|
7 | 'base/js/utils', | |||
|
8 | 'base/js/dialog', | |||
|
9 | 'base/js/keyboard', | |||
|
10 | 'moment', | |||
|
11 | ], function(IPython, $, utils, dialog, keyboard, moment) { | |||
|
12 | "use strict"; | |||
|
13 | ||||
|
14 | var SaveWidget = function (selector, options) { | |||
|
15 | this.editor = undefined; | |||
|
16 | this.selector = selector; | |||
|
17 | this.events = options.events; | |||
|
18 | this.editor = options.editor; | |||
|
19 | this._last_modified = undefined; | |||
|
20 | this.keyboard_manager = options.keyboard_manager; | |||
|
21 | if (this.selector !== undefined) { | |||
|
22 | this.element = $(selector); | |||
|
23 | this.bind_events(); | |||
|
24 | } | |||
|
25 | }; | |||
|
26 | ||||
|
27 | ||||
|
28 | SaveWidget.prototype.bind_events = function () { | |||
|
29 | var that = this; | |||
|
30 | this.element.find('span.filename').click(function () { | |||
|
31 | that.rename({editor: that.editor}); | |||
|
32 | }); | |||
|
33 | this.events.on('file_loaded.Editor', function (evt, model) { | |||
|
34 | that.update_filename(model.name); | |||
|
35 | that.update_document_title(model.name); | |||
|
36 | that.update_last_modified(model.last_modified); | |||
|
37 | }); | |||
|
38 | this.events.on('file_saved.Editor', function (evt, model) { | |||
|
39 | that.update_filename(model.name); | |||
|
40 | that.update_document_title(model.name); | |||
|
41 | that.update_last_modified(model.last_modified); | |||
|
42 | }); | |||
|
43 | this.events.on('file_renamed.Editor', function (evt, model) { | |||
|
44 | that.update_filename(model.name); | |||
|
45 | that.update_document_title(model.name); | |||
|
46 | that.update_address_bar(model.path); | |||
|
47 | }); | |||
|
48 | this.events.on('file_save_failed.Editor', function () { | |||
|
49 | that.set_save_status('Save Failed!'); | |||
|
50 | }); | |||
|
51 | }; | |||
|
52 | ||||
|
53 | ||||
|
54 | SaveWidget.prototype.rename = function (options) { | |||
|
55 | options = options || {}; | |||
|
56 | var that = this; | |||
|
57 | var dialog_body = $('<div/>').append( | |||
|
58 | $("<p/>").addClass("rename-message") | |||
|
59 | .text('Enter a new filename:') | |||
|
60 | ).append( | |||
|
61 | $("<br/>") | |||
|
62 | ).append( | |||
|
63 | $('<input/>').attr('type','text').attr('size','25').addClass('form-control') | |||
|
64 | .val(options.editor.get_filename()) | |||
|
65 | ); | |||
|
66 | var d = dialog.modal({ | |||
|
67 | title: "Rename File", | |||
|
68 | body: dialog_body, | |||
|
69 | buttons : { | |||
|
70 | "OK": { | |||
|
71 | class: "btn-primary", | |||
|
72 | click: function () { | |||
|
73 | var new_name = d.find('input').val(); | |||
|
74 | d.find('.rename-message').text("Renaming..."); | |||
|
75 | d.find('input[type="text"]').prop('disabled', true); | |||
|
76 | that.editor.rename(new_name).then( | |||
|
77 | function () { | |||
|
78 | d.modal('hide'); | |||
|
79 | }, function (error) { | |||
|
80 | d.find('.rename-message').text(error.message || 'Unknown error'); | |||
|
81 | d.find('input[type="text"]').prop('disabled', false).focus().select(); | |||
|
82 | } | |||
|
83 | ); | |||
|
84 | return false; | |||
|
85 | } | |||
|
86 | }, | |||
|
87 | "Cancel": {} | |||
|
88 | }, | |||
|
89 | open : function () { | |||
|
90 | // Upon ENTER, click the OK button. | |||
|
91 | d.find('input[type="text"]').keydown(function (event) { | |||
|
92 | if (event.which === keyboard.keycodes.enter) { | |||
|
93 | d.find('.btn-primary').first().click(); | |||
|
94 | return false; | |||
|
95 | } | |||
|
96 | }); | |||
|
97 | d.find('input[type="text"]').focus().select(); | |||
|
98 | } | |||
|
99 | }); | |||
|
100 | }; | |||
|
101 | ||||
|
102 | ||||
|
103 | SaveWidget.prototype.update_filename = function (filename) { | |||
|
104 | this.element.find('span.filename').text(filename); | |||
|
105 | }; | |||
|
106 | ||||
|
107 | SaveWidget.prototype.update_document_title = function (filename) { | |||
|
108 | document.title = filename; | |||
|
109 | }; | |||
|
110 | ||||
|
111 | SaveWidget.prototype.update_address_bar = function (path) { | |||
|
112 | var state = {path : path}; | |||
|
113 | window.history.replaceState(state, "", utils.url_join_encode( | |||
|
114 | this.editor.base_url, | |||
|
115 | "edit", | |||
|
116 | path) | |||
|
117 | ); | |||
|
118 | }; | |||
|
119 | ||||
|
120 | SaveWidget.prototype.update_last_modified = function (last_modified) { | |||
|
121 | if (last_modified) { | |||
|
122 | this._last_modified = new Date(last_modified); | |||
|
123 | } else { | |||
|
124 | this._last_modified = null; | |||
|
125 | } | |||
|
126 | this._render_last_modified(); | |||
|
127 | }; | |||
|
128 | ||||
|
129 | SaveWidget.prototype._render_last_modified = function () { | |||
|
130 | /** actually set the text in the element, from our _last_modified value | |||
|
131 | ||||
|
132 | called directly, and periodically in timeouts. | |||
|
133 | */ | |||
|
134 | this._schedule_render_last_modified(); | |||
|
135 | var el = this.element.find('span.last_modified'); | |||
|
136 | if (!this._last_modified) { | |||
|
137 | el.text('').attr('title', 'never saved'); | |||
|
138 | return; | |||
|
139 | } | |||
|
140 | var chkd = moment(this._last_modified); | |||
|
141 | var long_date = chkd.format('llll'); | |||
|
142 | var human_date; | |||
|
143 | var tdelta = Math.ceil(new Date() - this._last_modified); | |||
|
144 | if (tdelta < 24 * H){ | |||
|
145 | // less than 24 hours old, use relative date | |||
|
146 | human_date = chkd.fromNow(); | |||
|
147 | } else { | |||
|
148 | // otherwise show calendar | |||
|
149 | // otherwise update every hour and show | |||
|
150 | // <Today | yesterday|...> at hh,mm,ss | |||
|
151 | human_date = chkd.calendar(); | |||
|
152 | } | |||
|
153 | el.text(human_date).attr('title', long_date); | |||
|
154 | }; | |||
|
155 | ||||
|
156 | ||||
|
157 | var S = 1000; | |||
|
158 | var M = 60*S; | |||
|
159 | var H = 60*M; | |||
|
160 | var thresholds = { | |||
|
161 | s: 45 * S, | |||
|
162 | m: 45 * M, | |||
|
163 | h: 22 * H | |||
|
164 | }; | |||
|
165 | var _timeout_from_dt = function (ms) { | |||
|
166 | /** compute a timeout to update the last-modified timeout | |||
|
167 | ||||
|
168 | based on the delta in milliseconds | |||
|
169 | */ | |||
|
170 | if (ms < thresholds.s) { | |||
|
171 | return 5 * S; | |||
|
172 | } else if (ms < thresholds.m) { | |||
|
173 | return M; | |||
|
174 | } else { | |||
|
175 | return 5 * M; | |||
|
176 | } | |||
|
177 | }; | |||
|
178 | ||||
|
179 | SaveWidget.prototype._schedule_render_last_modified = function () { | |||
|
180 | /** schedule the next update to relative date | |||
|
181 | ||||
|
182 | periodically updated, so short values like 'a few seconds ago' don't get stale. | |||
|
183 | */ | |||
|
184 | var that = this; | |||
|
185 | if (!this._last_modified) { | |||
|
186 | return; | |||
|
187 | } | |||
|
188 | if ((this._last_modified_timeout)) { | |||
|
189 | clearTimeout(this._last_modified_timeout); | |||
|
190 | } | |||
|
191 | var dt = Math.ceil(new Date() - this._last_modified); | |||
|
192 | if (dt < 24 * H) { | |||
|
193 | this._last_modified_timeout = setTimeout( | |||
|
194 | $.proxy(this._render_last_modified, this), | |||
|
195 | _timeout_from_dt(dt) | |||
|
196 | ); | |||
|
197 | } | |||
|
198 | }; | |||
|
199 | ||||
|
200 | return {'SaveWidget': SaveWidget}; | |||
|
201 | ||||
|
202 | }); |
@@ -1,141 +1,160 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
4 | define([ |
|
4 | define([ | |
5 | 'jquery', |
|
5 | 'jquery', | |
6 | 'base/js/utils', |
|
6 | 'base/js/utils', | |
7 | 'codemirror/lib/codemirror', |
|
7 | 'codemirror/lib/codemirror', | |
8 | 'codemirror/mode/meta', |
|
8 | 'codemirror/mode/meta', | |
9 | 'codemirror/addon/comment/comment', |
|
9 | 'codemirror/addon/comment/comment', | |
10 | 'codemirror/addon/dialog/dialog', |
|
10 | 'codemirror/addon/dialog/dialog', | |
11 | 'codemirror/addon/edit/closebrackets', |
|
11 | 'codemirror/addon/edit/closebrackets', | |
12 | 'codemirror/addon/edit/matchbrackets', |
|
12 | 'codemirror/addon/edit/matchbrackets', | |
13 | 'codemirror/addon/search/searchcursor', |
|
13 | 'codemirror/addon/search/searchcursor', | |
14 | 'codemirror/addon/search/search', |
|
14 | 'codemirror/addon/search/search', | |
15 | 'codemirror/keymap/emacs', |
|
15 | 'codemirror/keymap/emacs', | |
16 | 'codemirror/keymap/sublime', |
|
16 | 'codemirror/keymap/sublime', | |
17 | 'codemirror/keymap/vim', |
|
17 | 'codemirror/keymap/vim', | |
18 | ], |
|
18 | ], | |
19 | function($, |
|
19 | function($, | |
20 | utils, |
|
20 | utils, | |
21 | CodeMirror |
|
21 | CodeMirror | |
22 | ) { |
|
22 | ) { | |
23 | "use strict"; |
|
23 | "use strict"; | |
24 |
|
24 | |||
25 | var Editor = function(selector, options) { |
|
25 | var Editor = function(selector, options) { | |
26 | var that = this; |
|
26 | var that = this; | |
27 | this.selector = selector; |
|
27 | this.selector = selector; | |
28 | this.contents = options.contents; |
|
28 | this.contents = options.contents; | |
29 | this.events = options.events; |
|
29 | this.events = options.events; | |
30 | this.base_url = options.base_url; |
|
30 | this.base_url = options.base_url; | |
31 | this.file_path = options.file_path; |
|
31 | this.file_path = options.file_path; | |
32 | this.config = options.config; |
|
32 | this.config = options.config; | |
33 | this.codemirror = new CodeMirror($(this.selector)[0]); |
|
33 | this.codemirror = new CodeMirror($(this.selector)[0]); | |
34 | this.generation = -1; |
|
34 | this.generation = -1; | |
35 |
|
35 | |||
36 | // It appears we have to set commands on the CodeMirror class, not the |
|
36 | // It appears we have to set commands on the CodeMirror class, not the | |
37 | // instance. I'd like to be wrong, but since there should only be one CM |
|
37 | // instance. I'd like to be wrong, but since there should only be one CM | |
38 | // instance on the page, this is good enough for now. |
|
38 | // instance on the page, this is good enough for now. | |
39 | CodeMirror.commands.save = $.proxy(this.save, this); |
|
39 | CodeMirror.commands.save = $.proxy(this.save, this); | |
40 |
|
40 | |||
41 | this.save_enabled = false; |
|
41 | this.save_enabled = false; | |
42 |
|
42 | |||
43 | this.config.loaded.then(function () { |
|
43 | this.config.loaded.then(function () { | |
44 | // load codemirror config |
|
44 | // load codemirror config | |
45 | var cfg = that.config.data.Editor || {}; |
|
45 | var cfg = that.config.data.Editor || {}; | |
46 | var cmopts = $.extend(true, {}, // true = recursive copy |
|
46 | var cmopts = $.extend(true, {}, // true = recursive copy | |
47 | Editor.default_codemirror_options, |
|
47 | Editor.default_codemirror_options, | |
48 | cfg.codemirror_options || {} |
|
48 | cfg.codemirror_options || {} | |
49 | ); |
|
49 | ); | |
50 | that._set_codemirror_options(cmopts); |
|
50 | that._set_codemirror_options(cmopts); | |
51 | that.events.trigger('config_changed.Editor', {config: that.config}); |
|
51 | that.events.trigger('config_changed.Editor', {config: that.config}); | |
52 | }); |
|
52 | }); | |
53 | }; |
|
53 | }; | |
54 |
|
54 | |||
55 | // default CodeMirror options |
|
55 | // default CodeMirror options | |
56 | Editor.default_codemirror_options = { |
|
56 | Editor.default_codemirror_options = { | |
57 | extraKeys: { |
|
57 | extraKeys: { | |
58 | "Tab" : "indentMore", |
|
58 | "Tab" : "indentMore", | |
59 | }, |
|
59 | }, | |
60 | indentUnit: 4, |
|
60 | indentUnit: 4, | |
61 | theme: "ipython", |
|
61 | theme: "ipython", | |
62 | lineNumbers: true, |
|
62 | lineNumbers: true, | |
63 | }; |
|
63 | }; | |
64 |
|
64 | |||
65 | Editor.prototype.load = function() { |
|
65 | Editor.prototype.load = function() { | |
66 | /** load the file */ |
|
66 | /** load the file */ | |
67 | var that = this; |
|
67 | var that = this; | |
68 | var cm = this.codemirror; |
|
68 | var cm = this.codemirror; | |
69 | return this.contents.get(this.file_path, {type: 'file', format: 'text'}) |
|
69 | return this.contents.get(this.file_path, {type: 'file', format: 'text'}) | |
70 | .then(function(model) { |
|
70 | .then(function(model) { | |
71 | cm.setValue(model.content); |
|
71 | cm.setValue(model.content); | |
72 |
|
72 | |||
73 | // Setting the file's initial value creates a history entry, |
|
73 | // Setting the file's initial value creates a history entry, | |
74 | // which we don't want. |
|
74 | // which we don't want. | |
75 | cm.clearHistory(); |
|
75 | cm.clearHistory(); | |
76 |
|
76 | |||
77 | // Find and load the highlighting mode |
|
77 | // Find and load the highlighting mode | |
78 | utils.requireCodeMirrorMode(model.mimetype, function(spec) { |
|
78 | utils.requireCodeMirrorMode(model.mimetype, function(spec) { | |
79 | var mode = CodeMirror.getMode({}, spec); |
|
79 | var mode = CodeMirror.getMode({}, spec); | |
80 | cm.setOption('mode', mode); |
|
80 | cm.setOption('mode', mode); | |
81 | }); |
|
81 | }); | |
82 | that.save_enabled = true; |
|
82 | that.save_enabled = true; | |
83 | that.generation = cm.changeGeneration(); |
|
83 | that.generation = cm.changeGeneration(); | |
|
84 | that.events.trigger("file_loaded.Editor", model); | |||
84 | }, |
|
85 | }, | |
85 | function(error) { |
|
86 | function(error) { | |
86 | cm.setValue("Error! " + error.message + |
|
87 | cm.setValue("Error! " + error.message + | |
87 | "\nSaving disabled."); |
|
88 | "\nSaving disabled."); | |
88 | that.save_enabled = false; |
|
89 | that.save_enabled = false; | |
89 | } |
|
90 | } | |
90 | ); |
|
91 | ); | |
91 | }; |
|
92 | }; | |
|
93 | ||||
|
94 | Editor.prototype.get_filename = function () { | |||
|
95 | return utils.url_path_split(this.file_path)[1]; | |||
|
96 | ||||
|
97 | } | |||
92 |
|
98 | |||
93 |
Editor.prototype. |
|
99 | Editor.prototype.rename = function (new_name) { | |
|
100 | /** rename the file */ | |||
|
101 | var that = this; | |||
|
102 | var parent = utils.url_path_split(this.file_path)[0]; | |||
|
103 | var new_path = utils.url_path_join(parent, new_name); | |||
|
104 | return this.contents.rename(this.file_path, new_path).then( | |||
|
105 | function (json) { | |||
|
106 | that.file_path = json.path; | |||
|
107 | that.events.trigger('file_renamed.Editor', json); | |||
|
108 | } | |||
|
109 | ); | |||
|
110 | }; | |||
|
111 | ||||
|
112 | Editor.prototype.save = function () { | |||
94 | /** save the file */ |
|
113 | /** save the file */ | |
95 | if (!this.save_enabled) { |
|
114 | if (!this.save_enabled) { | |
96 | console.log("Not saving, save disabled"); |
|
115 | console.log("Not saving, save disabled"); | |
97 | return; |
|
116 | return; | |
98 | } |
|
117 | } | |
99 | var model = { |
|
118 | var model = { | |
100 | path: this.file_path, |
|
119 | path: this.file_path, | |
101 | type: 'file', |
|
120 | type: 'file', | |
102 | format: 'text', |
|
121 | format: 'text', | |
103 | content: this.codemirror.getValue(), |
|
122 | content: this.codemirror.getValue(), | |
104 | }; |
|
123 | }; | |
105 | var that = this; |
|
124 | var that = this; | |
106 | // record change generation for isClean |
|
125 | // record change generation for isClean | |
107 | this.generation = this.codemirror.changeGeneration(); |
|
126 | this.generation = this.codemirror.changeGeneration(); | |
108 | return this.contents.save(this.file_path, model).then(function() { |
|
127 | return this.contents.save(this.file_path, model).then(function(data) { | |
109 |
that.events.trigger(" |
|
128 | that.events.trigger("file_saved.Editor", data); | |
110 | }); |
|
129 | }); | |
111 | }; |
|
130 | }; | |
112 |
|
131 | |||
113 | Editor.prototype._set_codemirror_options = function (options) { |
|
132 | Editor.prototype._set_codemirror_options = function (options) { | |
114 | // update codemirror options from a dict |
|
133 | // update codemirror options from a dict | |
115 | for (var opt in options) { |
|
134 | for (var opt in options) { | |
116 | if (!options.hasOwnProperty(opt)) { |
|
135 | if (!options.hasOwnProperty(opt)) { | |
117 | continue; |
|
136 | continue; | |
118 | } |
|
137 | } | |
119 | var value = options[opt]; |
|
138 | var value = options[opt]; | |
120 | if (value === null) { |
|
139 | if (value === null) { | |
121 | value = CodeMirror.defaults[opt]; |
|
140 | value = CodeMirror.defaults[opt]; | |
122 | } |
|
141 | } | |
123 | this.codemirror.setOption(opt, value); |
|
142 | this.codemirror.setOption(opt, value); | |
124 | } |
|
143 | } | |
125 | }; |
|
144 | }; | |
126 |
|
145 | |||
127 | Editor.prototype.update_codemirror_options = function (options) { |
|
146 | Editor.prototype.update_codemirror_options = function (options) { | |
128 | /** update codemirror options locally and save changes in config */ |
|
147 | /** update codemirror options locally and save changes in config */ | |
129 | var that = this; |
|
148 | var that = this; | |
130 | this._set_codemirror_options(options); |
|
149 | this._set_codemirror_options(options); | |
131 | return this.config.update({ |
|
150 | return this.config.update({ | |
132 | Editor: { |
|
151 | Editor: { | |
133 | codemirror_options: options |
|
152 | codemirror_options: options | |
134 | } |
|
153 | } | |
135 | }).then( |
|
154 | }).then( | |
136 | that.events.trigger('config_changed.Editor', {config: that.config}) |
|
155 | that.events.trigger('config_changed.Editor', {config: that.config}) | |
137 | ); |
|
156 | ); | |
138 | }; |
|
157 | }; | |
139 |
|
158 | |||
140 | return {Editor: Editor}; |
|
159 | return {Editor: Editor}; | |
141 | }); |
|
160 | }); |
@@ -1,73 +1,80 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
4 | require([ |
|
4 | require([ | |
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'base/js/utils', |
|
6 | 'base/js/utils', | |
7 | 'base/js/page', |
|
7 | 'base/js/page', | |
8 | 'base/js/events', |
|
8 | 'base/js/events', | |
9 | 'contents', |
|
9 | 'contents', | |
10 | 'services/config', |
|
10 | 'services/config', | |
11 | 'edit/js/editor', |
|
11 | 'edit/js/editor', | |
12 | 'edit/js/menubar', |
|
12 | 'edit/js/menubar', | |
|
13 | 'edit/js/savewidget', | |||
13 | 'edit/js/notificationarea', |
|
14 | 'edit/js/notificationarea', | |
14 | 'custom/custom', |
|
15 | 'custom/custom', | |
15 | ], function( |
|
16 | ], function( | |
16 | IPython, |
|
17 | IPython, | |
17 | utils, |
|
18 | utils, | |
18 | page, |
|
19 | page, | |
19 | events, |
|
20 | events, | |
20 | contents, |
|
21 | contents, | |
21 | configmod, |
|
22 | configmod, | |
22 | editmod, |
|
23 | editmod, | |
23 | menubar, |
|
24 | menubar, | |
|
25 | savewidget, | |||
24 | notificationarea |
|
26 | notificationarea | |
25 | ){ |
|
27 | ){ | |
26 | page = new page.Page(); |
|
28 | page = new page.Page(); | |
27 |
|
29 | |||
28 | var base_url = utils.get_body_data('baseUrl'); |
|
30 | var base_url = utils.get_body_data('baseUrl'); | |
29 | var file_path = utils.get_body_data('filePath'); |
|
31 | var file_path = utils.get_body_data('filePath'); | |
30 | contents = new contents.Contents({base_url: base_url}); |
|
32 | contents = new contents.Contents({base_url: base_url}); | |
31 | var config = new configmod.ConfigSection('edit', {base_url: base_url}); |
|
33 | var config = new configmod.ConfigSection('edit', {base_url: base_url}); | |
32 | config.load(); |
|
34 | config.load(); | |
33 |
|
35 | |||
34 | var editor = new editmod.Editor('#texteditor-container', { |
|
36 | var editor = new editmod.Editor('#texteditor-container', { | |
35 | base_url: base_url, |
|
37 | base_url: base_url, | |
36 | events: events, |
|
38 | events: events, | |
37 | contents: contents, |
|
39 | contents: contents, | |
38 | file_path: file_path, |
|
40 | file_path: file_path, | |
39 | config: config, |
|
41 | config: config, | |
40 | }); |
|
42 | }); | |
41 |
|
43 | |||
42 | // Make it available for debugging |
|
44 | // Make it available for debugging | |
43 | IPython.editor = editor; |
|
45 | IPython.editor = editor; | |
44 |
|
46 | |||
45 | var menus = new menubar.MenuBar('#menubar', { |
|
47 | var menus = new menubar.MenuBar('#menubar', { | |
46 | base_url: base_url, |
|
48 | base_url: base_url, | |
47 | editor: editor, |
|
49 | editor: editor, | |
48 | events: events, |
|
50 | events: events, | |
49 | }); |
|
51 | }); | |
50 |
|
52 | |||
|
53 | var save_widget = new savewidget.SaveWidget('span#save_widget', { | |||
|
54 | editor: editor, | |||
|
55 | events: events, | |||
|
56 | }); | |||
|
57 | ||||
51 | var notification_area = new notificationarea.EditorNotificationArea( |
|
58 | var notification_area = new notificationarea.EditorNotificationArea( | |
52 | '#notification_area', { |
|
59 | '#notification_area', { | |
53 | events: events, |
|
60 | events: events, | |
54 | }); |
|
61 | }); | |
55 | notification_area.init_notification_widgets(); |
|
62 | notification_area.init_notification_widgets(); | |
56 |
|
63 | |||
57 | config.loaded.then(function() { |
|
64 | config.loaded.then(function() { | |
58 | if (config.data.load_extensions) { |
|
65 | if (config.data.load_extensions) { | |
59 | var nbextension_paths = Object.getOwnPropertyNames( |
|
66 | var nbextension_paths = Object.getOwnPropertyNames( | |
60 | config.data.load_extensions); |
|
67 | config.data.load_extensions); | |
61 | IPython.load_extensions.apply(this, nbextension_paths); |
|
68 | IPython.load_extensions.apply(this, nbextension_paths); | |
62 | } |
|
69 | } | |
63 | }); |
|
70 | }); | |
64 | editor.load(); |
|
71 | editor.load(); | |
65 | page.show(); |
|
72 | page.show(); | |
66 |
|
73 | |||
67 | window.onbeforeunload = function () { |
|
74 | window.onbeforeunload = function () { | |
68 | if (!editor.codemirror.isClean(editor.generation)) { |
|
75 | if (!editor.codemirror.isClean(editor.generation)) { | |
69 | return "Unsaved changes will be lost. Close anyway?"; |
|
76 | return "Unsaved changes will be lost. Close anyway?"; | |
70 | } |
|
77 | } | |
71 | }; |
|
78 | }; | |
72 |
|
79 | |||
73 | }); |
|
80 | }); |
@@ -1,78 +1,81 b'' | |||||
1 | {% extends "page.html" %} |
|
1 | {% extends "page.html" %} | |
2 |
|
2 | |||
3 | {% block title %}{{page_title}}{% endblock %} |
|
3 | {% block title %}{{page_title}}{% endblock %} | |
4 |
|
4 | |||
5 | {% block stylesheet %} |
|
5 | {% block stylesheet %} | |
6 | <link rel="stylesheet" href="{{ static_url('components/codemirror/lib/codemirror.css') }}"> |
|
6 | <link rel="stylesheet" href="{{ static_url('components/codemirror/lib/codemirror.css') }}"> | |
7 | <link rel="stylesheet" href="{{ static_url('components/codemirror/addon/dialog/dialog.css') }}"> |
|
7 | <link rel="stylesheet" href="{{ static_url('components/codemirror/addon/dialog/dialog.css') }}"> | |
8 | {{super()}} |
|
8 | {{super()}} | |
9 | {% endblock %} |
|
9 | {% endblock %} | |
10 |
|
10 | |||
11 | {% block params %} |
|
11 | {% block params %} | |
12 |
|
12 | |||
13 | data-base-url="{{base_url}}" |
|
13 | data-base-url="{{base_url}}" | |
14 | data-file-path="{{file_path}}" |
|
14 | data-file-path="{{file_path}}" | |
15 |
|
15 | |||
16 | {% endblock %} |
|
16 | {% endblock %} | |
17 |
|
17 | |||
18 | {% block header %} |
|
18 | {% block header %} | |
19 |
|
19 | |||
20 | <span id="filename">{{ basename }}</span> |
|
20 | <span id="save_widget" class="nav pull-left save_widget"> | |
|
21 | <span class="filename"></span> | |||
|
22 | <span class="last_modified"></span> | |||
|
23 | </span> | |||
21 |
|
24 | |||
22 | {% endblock %} |
|
25 | {% endblock %} | |
23 |
|
26 | |||
24 | {% block site %} |
|
27 | {% block site %} | |
25 |
|
28 | |||
26 | <div id="menubar-container" class="container"> |
|
29 | <div id="menubar-container" class="container"> | |
27 | <div id="menubar"> |
|
30 | <div id="menubar"> | |
28 | <div id="menus" class="navbar navbar-default" role="navigation"> |
|
31 | <div id="menus" class="navbar navbar-default" role="navigation"> | |
29 | <div class="container-fluid"> |
|
32 | <div class="container-fluid"> | |
30 | <button type="button" class="btn btn-default navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> |
|
33 | <button type="button" class="btn btn-default navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | |
31 | <i class="fa fa-bars"></i> |
|
34 | <i class="fa fa-bars"></i> | |
32 | <span class="navbar-text">Menu</span> |
|
35 | <span class="navbar-text">Menu</span> | |
33 | </button> |
|
36 | </button> | |
34 | <ul class="nav navbar-nav navbar-right"> |
|
37 | <ul class="nav navbar-nav navbar-right"> | |
35 | <li id="notification_area"></li> |
|
38 | <li id="notification_area"></li> | |
36 | </ul> |
|
39 | </ul> | |
37 | <div class="navbar-collapse collapse"> |
|
40 | <div class="navbar-collapse collapse"> | |
38 | <ul class="nav navbar-nav"> |
|
41 | <ul class="nav navbar-nav"> | |
39 | <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a> |
|
42 | <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a> | |
40 | <ul id="file-menu" class="dropdown-menu"> |
|
43 | <ul id="file-menu" class="dropdown-menu"> | |
41 | <li id="new-file"><a href="#">New</a></li> |
|
44 | <li id="new-file"><a href="#">New</a></li> | |
42 | <li id="save-file"><a href="#">Save</a></li> |
|
45 | <li id="save-file"><a href="#">Save</a></li> | |
43 | </ul> |
|
46 | </ul> | |
44 | </li> |
|
47 | </li> | |
45 | <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a> |
|
48 | <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a> | |
46 | <ul id="edit-menu" class="dropdown-menu"> |
|
49 | <ul id="edit-menu" class="dropdown-menu"> | |
47 | <li id="menu-find"><a href="#">Find</a></li> |
|
50 | <li id="menu-find"><a href="#">Find</a></li> | |
48 | <li id="menu-replace"><a href="#">Find & Replace</a></li> |
|
51 | <li id="menu-replace"><a href="#">Find & Replace</a></li> | |
49 | <li class="divider"></li> |
|
52 | <li class="divider"></li> | |
50 | <li class="dropdown-header">Key Map</li> |
|
53 | <li class="dropdown-header">Key Map</li> | |
51 | <li id="menu-keymap-default"><a href="#">Default<i class="fa"></i></a></li> |
|
54 | <li id="menu-keymap-default"><a href="#">Default<i class="fa"></i></a></li> | |
52 | <li id="menu-keymap-sublime"><a href="#">Sublime Text<i class="fa"></i></a></li> |
|
55 | <li id="menu-keymap-sublime"><a href="#">Sublime Text<i class="fa"></i></a></li> | |
53 | <li id="menu-keymap-vim"><a href="#">Vim<i class="fa"></i></a></li> |
|
56 | <li id="menu-keymap-vim"><a href="#">Vim<i class="fa"></i></a></li> | |
54 | <li id="menu-keymap-emacs"><a href="#">emacs<i class="fa"></i></a></li> |
|
57 | <li id="menu-keymap-emacs"><a href="#">emacs<i class="fa"></i></a></li> | |
55 | </ul> |
|
58 | </ul> | |
56 | </li> |
|
59 | </li> | |
57 | <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a> |
|
60 | <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a> | |
58 | <ul id="view-menu" class="dropdown-menu"> |
|
61 | <ul id="view-menu" class="dropdown-menu"> | |
59 | <li id="menu-line-numbers"><a href="#">Hide Line Numbers</a></li> |
|
62 | <li id="menu-line-numbers"><a href="#">Hide Line Numbers</a></li> | |
60 | </ul> |
|
63 | </ul> | |
61 | </li> |
|
64 | </li> | |
62 | </ul> |
|
65 | </ul> | |
63 | </div> |
|
66 | </div> | |
64 | </div> |
|
67 | </div> | |
65 | </div> |
|
68 | </div> | |
66 | </div> |
|
69 | </div> | |
67 | </div> |
|
70 | </div> | |
68 |
|
71 | |||
69 | <div id="texteditor-container" class="container"></div> |
|
72 | <div id="texteditor-container" class="container"></div> | |
70 |
|
73 | |||
71 | {% endblock %} |
|
74 | {% endblock %} | |
72 |
|
75 | |||
73 | {% block script %} |
|
76 | {% block script %} | |
74 |
|
77 | |||
75 | {{super()}} |
|
78 | {{super()}} | |
76 |
|
79 | |||
77 | <script src="{{ static_url("edit/js/main.js") }}" type="text/javascript" charset="utf-8"></script> |
|
80 | <script src="{{ static_url("edit/js/main.js") }}" type="text/javascript" charset="utf-8"></script> | |
78 | {% endblock %} |
|
81 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now