##// END OF EJS Templates
Merge pull request #2127 from Carreau/jsToolbar...
Brian E. Granger -
r8513:d9a42fe4 merge
parent child Browse files
Show More
@@ -0,0 +1,179 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2011 The IPython Development Team
3 //
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
7
8 //============================================================================
9 // ToolBar
10 //============================================================================
11
12 var IPython = (function (IPython) {
13
14 var MainToolBar = function (selector) {
15 this.selector = selector;
16 IPython.ToolBar.apply(this, arguments);
17 this.construct();
18 this.add_drop_down_list();
19 this.bind_events();
20 };
21
22 MainToolBar.prototype = new IPython.ToolBar();
23
24 MainToolBar.prototype.construct = function () {
25 this.add_buttons_group([
26 {
27 id : 'save_b',
28 label : 'Save',
29 icon : 'ui-icon-disk',
30 callback : function () {
31 IPython.notebook.save_notebook();
32 }
33 }
34 ]);
35 this.add_buttons_group([
36 {
37 id : 'cut_b',
38 label : 'Cut Cell',
39 icon : 'ui-icon-scissors',
40 callback : function () {
41 IPython.notebook.cut_cell();
42 }
43 },
44 {
45 id : 'copy_b',
46 label : 'Copy Cell',
47 icon : 'ui-icon-copy',
48 callback : function () {
49 IPython.notebook.copy_cell();
50 }
51 },
52 {
53 id : 'paste_b',
54 label : 'Paste Cell',
55 icon : 'ui-icon-clipboard',
56 callback : function () {
57 IPython.notebook.paste_cell();
58 }
59 }
60 ],'cut_copy_paste');
61
62 this.add_buttons_group([
63 {
64 id : 'move_up_b',
65 label : 'Move Cell Up',
66 icon : 'ui-icon-arrowthick-1-n',
67 callback : function () {
68 IPython.notebook.move_cell_up();
69 }
70 },
71 {
72 id : 'move_down_b',
73 label : 'Move Cell Down',
74 icon : 'ui-icon-arrowthick-1-s',
75 callback : function () {
76 IPython.notebook.move_cell_down();
77 }
78 }
79 ],'move_up_down');
80
81 this.add_buttons_group([
82 {
83 id : 'insert_above_b',
84 label : 'Insert Cell Above',
85 icon : 'ui-icon-arrowthickstop-1-n',
86 callback : function () {
87 IPython.notebook.insert_cell_above('code');
88 }
89 },
90 {
91 id : 'insert_below_b',
92 label : 'Insert Cell Below',
93 icon : 'ui-icon-arrowthickstop-1-s',
94 callback : function () {
95 IPython.notebook.insert_cell_below('code');
96 }
97 }
98 ],'insert_above_below');
99
100 this.add_buttons_group([
101 {
102 id : 'run_b',
103 label : 'Run Cell',
104 icon : 'ui-icon-play',
105 callback : function () {
106 IPython.notebook.execute_selected_cell();
107 }
108 },
109 {
110 id : 'interrupt_b',
111 label : 'Interrupt',
112 icon : 'ui-icon-stop',
113 callback : function () {
114 IPython.notebook.kernel.interrupt();
115 }
116 }
117 ],'run_int');
118
119
120 };
121
122 MainToolBar.prototype.add_drop_down_list = function () {
123 var select = $(this.selector)
124 .append($('<select/>')
125 .attr('id','cell_type')
126 .addClass('ui-widget ui-widget-content')
127 .append($('<option/>').attr('value','code').text('Code'))
128 .append($('<option/>').attr('value','markdown').text('Markdown'))
129 .append($('<option/>').attr('value','raw').text('Raw Text'))
130 .append($('<option/>').attr('value','heading1').text('Heading 1'))
131 .append($('<option/>').attr('value','heading2').text('Heading 2'))
132 .append($('<option/>').attr('value','heading3').text('Heading 3'))
133 .append($('<option/>').attr('value','heading4').text('Heading 4'))
134 .append($('<option/>').attr('value','heading5').text('Heading 5'))
135 .append($('<option/>').attr('value','heading6').text('Heading 6'))
136 .append($('<option/>').attr('value','heading7').text('Heading 7'))
137 .append($('<option/>').attr('value','heading8').text('Heading 8'))
138 );
139 };
140
141 MainToolBar.prototype.bind_events = function () {
142 var that = this;
143
144 this.element.find('#cell_type').change(function () {
145 var cell_type = $(this).val();
146 if (cell_type === 'code') {
147 IPython.notebook.to_code();
148 } else if (cell_type === 'markdown') {
149 IPython.notebook.to_markdown();
150 } else if (cell_type === 'raw') {
151 IPython.notebook.to_raw();
152 } else if (cell_type === 'heading1') {
153 IPython.notebook.to_heading(undefined, 1);
154 } else if (cell_type === 'heading2') {
155 IPython.notebook.to_heading(undefined, 2);
156 } else if (cell_type === 'heading3') {
157 IPython.notebook.to_heading(undefined, 3);
158 } else if (cell_type === 'heading4') {
159 IPython.notebook.to_heading(undefined, 4);
160 } else if (cell_type === 'heading5') {
161 IPython.notebook.to_heading(undefined, 5);
162 } else if (cell_type === 'heading6') {
163 IPython.notebook.to_heading(undefined, 6);
164 }
165 });
166 $([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
167 if (data.cell_type === 'heading') {
168 that.element.find('#cell_type').val(data.cell_type+data.level);
169 } else {
170 that.element.find('#cell_type').val(data.cell_type);
171 }
172 });
173 };
174
175 IPython.MainToolBar = MainToolBar;
176
177 return IPython;
178
179 }(IPython));
@@ -1,408 +1,408 b''
1 1 /**
2 2 * Primary styles
3 3 *
4 4 * Author: IPython Development Team
5 5 */
6 6
7 7
8 8 body {
9 9 overflow: hidden;
10 10 }
11 11
12 12 span#save_widget {
13 13 padding: 5px;
14 14 margin: 0px 0px 0px 300px;
15 15 display:inline-block;
16 16 }
17 17
18 18 span#notebook_name {
19 19 height: 1em;
20 20 line-height: 1em;
21 21 padding: 3px;
22 22 border: none;
23 23 font-size: 146.5%;
24 24 }
25 25
26 26 .ui-menubar-item .ui-button .ui-button-text {
27 27 padding: 0.4em 1.0em;
28 28 font-size: 100%;
29 29 }
30 30
31 31 .ui-menu {
32 32 -moz-box-shadow: 0px 6px 10px -1px #adadad;
33 33 -webkit-box-shadow: 0px 6px 10px -1px #adadad;
34 34 box-shadow: 0px 6px 10px -1px #adadad;
35 35 }
36 36
37 37 .ui-menu .ui-menu-item a {
38 38 border: 1px solid transparent;
39 39 padding: 2px 1.6em;
40 40 }
41 41
42 42 .ui-menu .ui-menu-item a.ui-state-focus {
43 43 margin: 0;
44 44 }
45 45
46 46 .ui-menu hr {
47 47 margin: 0.3em 0;
48 48 }
49 49
50 50 #menubar_container {
51 51 position: relative;
52 52 }
53 53
54 54 #notification_area {
55 55 position: absolute;
56 56 right: 0px;
57 57 top: 0px;
58 58 height: 25px;
59 59 padding: 3px 0px;
60 60 padding-right: 3px;
61 61 z-index: 10;
62 62 }
63 63
64 64 .notification_widget{
65 65 float : right;
66 66 right: 0px;
67 67 top: 1px;
68 68 height: 25px;
69 69 padding: 3px 6px;
70 70 z-index: 10;
71 71 }
72 72
73 #toolbar {
73 .toolbar {
74 74 padding: 3px 15px;
75 75 }
76 76
77 77 #cell_type {
78 78 font-size: 85%;
79 79 }
80 80
81 81
82 82 div#main_app {
83 83 width: 100%;
84 84 position: relative;
85 85 }
86 86
87 87 span#quick_help_area {
88 88 position: static;
89 89 padding: 5px 0px;
90 90 margin: 0px 0px 0px 0px;
91 91 }
92 92
93 93 .help_string {
94 94 float: right;
95 95 width: 170px;
96 96 padding: 0px 5px;
97 97 text-align: left;
98 98 font-size: 85%;
99 99 }
100 100
101 101 .help_string_label {
102 102 float: right;
103 103 font-size: 85%;
104 104 }
105 105
106 106 div#notebook_panel {
107 107 margin: 0px 0px 0px 0px;
108 108 padding: 0px;
109 109 }
110 110
111 111 div#notebook {
112 112 overflow-y: scroll;
113 113 overflow-x: auto;
114 114 width: 100%;
115 115 /* This spaces the cell away from the edge of the notebook area */
116 116 padding: 5px 5px 15px 5px;
117 117 margin: 0px;
118 118 background-color: white;
119 119 }
120 120
121 121 div#pager_splitter {
122 122 height: 8px;
123 123 }
124 124
125 125 #pager_container {
126 126 position : relative;
127 127 }
128 128
129 129 div#pager {
130 130 padding: 15px;
131 131 overflow: auto;
132 132 display: none;
133 133 }
134 134
135 135 div.ui-widget-content {
136 136 border: 1px solid #aaa;
137 137 outline: none;
138 138 }
139 139
140 140 .cell {
141 141 border: 1px solid transparent;
142 142 }
143 143
144 144 div.cell {
145 145 width: 100%;
146 146 padding: 5px 5px 5px 0px;
147 147 /* This acts as a spacer between cells, that is outside the border */
148 148 margin: 2px 0px 2px 0px;
149 149 }
150 150
151 151 div.code_cell {
152 152 background-color: white;
153 153 }
154 154
155 155 /* any special styling for code cells that are currently running goes here */
156 156 div.code_cell.running {
157 157 }
158 158
159 159 div.prompt {
160 160 /* This needs to be wide enough for 3 digit prompt numbers: In[100]: */
161 161 width: 11ex;
162 162 /* This 0.4em is tuned to match the padding on the CodeMirror editor. */
163 163 padding: 0.4em;
164 164 margin: 0px;
165 165 font-family: monospace;
166 166 text-align:right;
167 167 }
168 168
169 169 div.input {
170 170 page-break-inside: avoid;
171 171 }
172 172
173 173 /* input_area and input_prompt must match in top border and margin for alignment */
174 174 div.input_area {
175 175 color: black;
176 176 border: 1px solid #ddd;
177 177 border-radius: 3px;
178 178 background: #f7f7f7;
179 179 }
180 180
181 181 div.input_prompt {
182 182 color: navy;
183 183 border-top: 1px solid transparent;
184 184 }
185 185
186 186 div.output_wrapper {
187 187 /* This is a spacer between the input and output of each cell */
188 188 margin-top: 5px;
189 189 margin-left: 5px;
190 190 /* FF needs explicit width to stretch */
191 191 width: 100%;
192 192 /* this position must be relative to enable descendents to be absolute within it */
193 193 position: relative;
194 194 }
195 195
196 196 /* class for the output area when it should be height-limited */
197 197 div.output_scroll {
198 198 /* ideally, this would be max-height, but FF barfs all over that */
199 199 height: 24em;
200 200 /* FF needs this *and the wrapper* to specify full width, or it will shrinkwrap */
201 201 width: 100%;
202 202
203 203 overflow: auto;
204 204 border-radius: 3px;
205 205 box-shadow: inset 0 2px 8px rgba(0, 0, 0, .8);
206 206 }
207 207
208 208 /* output div while it is collapsed */
209 209 div.output_collapsed {
210 210 margin-right: 5px;
211 211 }
212 212
213 213 div.out_prompt_overlay {
214 214 height: 100%;
215 215 padding: 0px;
216 216 position: absolute;
217 217 border-radius: 3px;
218 218 }
219 219
220 220 div.out_prompt_overlay:hover {
221 221 /* use inner shadow to get border that is computed the same on WebKit/FF */
222 222 box-shadow: inset 0 0 1px #000;
223 223 background: rgba(240, 240, 240, 0.5);
224 224 }
225 225
226 226 div.output_prompt {
227 227 color: darkred;
228 228 /* 5px right shift to account for margin in parent container */
229 229 margin: 0 5px 0 -5px;
230 230 }
231 231
232 232 /* This class is the outer container of all output sections. */
233 233 div.output_area {
234 234 padding: 0px;
235 235 page-break-inside: avoid;
236 236 }
237 237
238 238 /* This class is for the output subarea inside the output_area and after
239 239 the prompt div. */
240 240 div.output_subarea {
241 241 padding: 0.4em 0.4em 0.4em 0.4em;
242 242 }
243 243
244 244 /* The rest of the output_* classes are for special styling of the different
245 245 output types */
246 246
247 247 /* all text output has this class: */
248 248 div.output_text {
249 249 text-align: left;
250 250 color: black;
251 251 font-family: monospace;
252 252 }
253 253
254 254 /* stdout/stderr are 'text' as well as 'stream', but pyout/pyerr are *not* streams */
255 255 div.output_stream {
256 256 padding-top: 0.0em;
257 257 padding-bottom: 0.0em;
258 258 }
259 259 div.output_stdout {
260 260 }
261 261 div.output_stderr {
262 262 background: #fdd; /* very light red background for stderr */
263 263 }
264 264
265 265 div.output_latex {
266 266 text-align: left;
267 267 color: black;
268 268 }
269 269
270 270 div.output_html {
271 271 }
272 272
273 273 div.output_png {
274 274 }
275 275
276 276 div.output_jpeg {
277 277 }
278 278
279 279 div.text_cell {
280 280 background-color: white;
281 281 padding: 5px 5px 5px 5px;
282 282 }
283 283
284 284 div.text_cell_input {
285 285 color: black;
286 286 border: 1px solid #ddd;
287 287 border-radius: 3px;
288 288 background: #f7f7f7;
289 289 }
290 290
291 291 div.text_cell_render {
292 292 font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
293 293 outline: none;
294 294 resize: none;
295 295 width: inherit;
296 296 border-style: none;
297 297 padding: 5px;
298 298 color: black;
299 299 }
300 300
301 301 /* The following gets added to the <head> if it is detected that the user has a
302 302 * monospace font with inconsistent normal/bold/italic height. See
303 303 * notebookmain.js. Such fonts will have keywords vertically offset with
304 304 * respect to the rest of the text. The user should select a better font.
305 305 * See: https://github.com/ipython/ipython/issues/1503
306 306 *
307 307 * .CodeMirror span {
308 308 * vertical-align: bottom;
309 309 * }
310 310 */
311 311
312 312 .CodeMirror {
313 313 line-height: 1.231; /* Changed from 1em to our global default */
314 314 }
315 315
316 316 .CodeMirror-scroll {
317 317 height: auto; /* Changed to auto to autogrow */
318 318 /* The CodeMirror docs are a bit fuzzy on if overflow-y should be hidden or visible.*/
319 319 /* We have found that if it is visible, vertical scrollbars appear with font size changes.*/
320 320 overflow-y: hidden;
321 321 overflow-x: auto; /* Changed from auto to remove scrollbar */
322 322 }
323 323
324 324 /* CSS font colors for translated ANSI colors. */
325 325
326 326
327 327 .ansiblack {color: black;}
328 328 .ansired {color: darkred;}
329 329 .ansigreen {color: darkgreen;}
330 330 .ansiyellow {color: brown;}
331 331 .ansiblue {color: darkblue;}
332 332 .ansipurple {color: darkviolet;}
333 333 .ansicyan {color: steelblue;}
334 334 .ansigrey {color: grey;}
335 335 .ansibold {font-weight: bold;}
336 336
337 337 .completions {
338 338 position: absolute;
339 339 z-index: 10;
340 340 overflow: hidden;
341 341 border: 1px solid grey;
342 342 }
343 343
344 344 .completions select {
345 345 background: white;
346 346 outline: none;
347 347 border: none;
348 348 padding: 0px;
349 349 margin: 0px;
350 350 overflow: auto;
351 351 font-family: monospace;
352 352 }
353 353
354 354 option.context {
355 355 background-color: #DEF7FF;
356 356 }
357 357 option.introspection {
358 358 background-color: #EBF4EB;
359 359 }
360 360
361 361 /*fixed part of the completion*/
362 362 .completions p b {
363 363 font-weight:bold;
364 364 }
365 365
366 366 .completions p {
367 367 background: #DDF;
368 368 /*outline: none;
369 369 padding: 0px;*/
370 370 border-bottom: black solid 1px;
371 371 padding: 1px;
372 372 font-family: monospace;
373 373 }
374 374
375 375 pre.dialog {
376 376 background-color: #f7f7f7;
377 377 border: 1px solid #ddd;
378 378 border-radius: 3px;
379 379 padding: 0.4em;
380 380 padding-left: 2em;
381 381 }
382 382
383 383 p.dialog {
384 384 padding : 0.2em;
385 385 }
386 386
387 387 .shortcut_key {
388 388 display: inline-block;
389 389 width: 15ex;
390 390 text-align: right;
391 391 font-family: monospace;
392 392 }
393 393
394 394 .shortcut_descr {
395 395 }
396 396
397 397 /* Word-wrap output correctly. This is the CSS3 spelling, though Firefox seems
398 398 to not honor it correctly. Webkit browsers (Chrome, rekonq, Safari) do.
399 399 */
400 400 pre, code, kbd, samp { white-space: pre-wrap; }
401 401
402 402 #fonttest {
403 403 font-family: monospace;
404 404 }
405 405
406 406 .js-error {
407 407 color: darkred;
408 408 }
@@ -1,62 +1,62 b''
1 1 //----------------------------------------------------------------------------
2 2 // Copyright (C) 2008-2011 The IPython Development Team
3 3 //
4 4 // Distributed under the terms of the BSD License. The full license is in
5 5 // the file COPYING, distributed as part of this software.
6 6 //----------------------------------------------------------------------------
7 7
8 8 //============================================================================
9 9 // Layout
10 10 //============================================================================
11 11
12 12 var IPython = (function (IPython) {
13 13
14 14 var LayoutManager = function () {
15 15 this.bind_events();
16 16 };
17 17
18 18
19 19 LayoutManager.prototype.bind_events = function () {
20 20 $(window).resize($.proxy(this.do_resize,this));
21 21 };
22 22
23 23 LayoutManager.prototype.app_height = function() {
24 24 var win = $(window);
25 25 var w = win.width();
26 26 var h = win.height();
27 27 var header_height;
28 28 if ($('div#header').css('display') === 'none') {
29 29 header_height = 0;
30 30 } else {
31 31 header_height = $('div#header').outerHeight(true);
32 32 }
33 33 var menubar_height = $('div#menubar').outerHeight(true);
34 34 var toolbar_height;
35 if ($('div#toolbar').css('display') === 'none') {
35 if ($('div#maintoolbar').css('display') === 'none') {
36 36 toolbar_height = 0;
37 37 } else {
38 toolbar_height = $('div#toolbar').outerHeight(true);
38 toolbar_height = $('div#maintoolbar').outerHeight(true);
39 39 }
40 40 return h-header_height-menubar_height-toolbar_height; // content height
41 41 }
42 42
43 43 LayoutManager.prototype.do_resize = function () {
44 44 var app_height = this.app_height() // content height
45 45
46 46 $('div#main_app').height(app_height); // content+padding+border height
47 47
48 48 var pager_height = IPython.pager.percentage_height*app_height;
49 49 var pager_splitter_height = $('div#pager_splitter').outerHeight(true);
50 50 $('div#pager').height(pager_height);
51 51 if (IPython.pager.expanded) {
52 52 $('div#notebook').height(app_height-pager_height-pager_splitter_height);
53 53 } else {
54 54 $('div#notebook').height(app_height-pager_splitter_height);
55 55 }
56 56 };
57 57
58 58 IPython.LayoutManager = LayoutManager;
59 59
60 60 return IPython;
61 61
62 62 }(IPython));
@@ -1,87 +1,87 b''
1 1 //----------------------------------------------------------------------------
2 2 // Copyright (C) 2011 The IPython Development Team
3 3 //
4 4 // Distributed under the terms of the BSD License. The full license is in
5 5 // the file COPYING, distributed as part of this software.
6 6 //----------------------------------------------------------------------------
7 7
8 8 //============================================================================
9 9 // On document ready
10 10 //============================================================================
11 11
12 12
13 13 $(document).ready(function () {
14 14
15 15 // monkey patch CM to be able to syntax highlight cell magics
16 16 // bug reported upstream,
17 17 // see https://github.com/marijnh/CodeMirror2/issues/670
18 18 if(CodeMirror.getMode(1,'text/plain').indent == undefined ){
19 19 console.log('patching CM for undefined indent');
20 20 CodeMirror.modes.null = function() { return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}}}
21 21 }
22 22
23 23 CodeMirror.patchedGetMode = function(config, mode){
24 24 var cmmode = CodeMirror.getMode(config, mode);
25 25 if(cmmode.indent == null)
26 26 {
27 27 console.log('patch mode "' , mode, '" on the fly');
28 28 cmmode.indent = function(){return 0};
29 29 }
30 30 return cmmode;
31 31 }
32 32 // end monkey patching CodeMirror
33 33
34 34 IPython.init_mathjax();
35 35
36 36 IPython.read_only = $('body').data('readOnly') === 'True';
37 37 $('div#main_app').addClass('border-box-sizing ui-widget');
38 38 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
39 39 // The header's bottom border is provided by the menu bar so we remove it.
40 40 $('div#header').css('border-bottom-style','none');
41 41
42 42 IPython.page = new IPython.Page();
43 43 IPython.markdown_converter = new Markdown.Converter();
44 44 IPython.layout_manager = new IPython.LayoutManager();
45 45 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
46 46 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
47 47 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
48 48 IPython.notebook = new IPython.Notebook('div#notebook');
49 49 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
50 50 IPython.menubar = new IPython.MenuBar('#menubar')
51 IPython.toolbar = new IPython.ToolBar('#toolbar')
51 IPython.toolbar = new IPython.MainToolBar('#maintoolbar')
52 52 IPython.tooltip = new IPython.Tooltip()
53 53 IPython.notification_area = new IPython.NotificationArea('#notification_area')
54 54 IPython.notification_area.init_notification_widgets();
55 55
56 56 IPython.layout_manager.do_resize();
57 57
58 58 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
59 59 '<span id="test2" style="font-weight: bold;">x</span>'+
60 60 '<span id="test3" style="font-style: italic;">x</span></pre></div>')
61 61 var nh = $('#test1').innerHeight();
62 62 var bh = $('#test2').innerHeight();
63 63 var ih = $('#test3').innerHeight();
64 64 if(nh != bh || nh != ih) {
65 65 $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
66 66 }
67 67 $('#fonttest').remove();
68 68
69 69 if(IPython.read_only){
70 70 // hide various elements from read-only view
71 71 $('div#pager').remove();
72 72 $('div#pager_splitter').remove();
73 73
74 74 // set the notebook name field as not modifiable
75 75 $('#notebook_name').attr('disabled','disabled')
76 76 }
77 77
78 78 IPython.page.show();
79 79
80 80 IPython.layout_manager.do_resize();
81 81 $([IPython.events]).on('notebook_loaded.Notebook', function () {
82 82 IPython.layout_manager.do_resize();
83 83 })
84 84 IPython.notebook.load_notebook($('body').data('notebookId'));
85 85
86 86 });
87 87
@@ -1,152 +1,96 b''
1 1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008 The IPython Development Team
3 3 //
4 4 // Distributed under the terms of the BSD License. The full license is in
5 5 // the file COPYING, distributed as part of this software.
6 6 //----------------------------------------------------------------------------
7 7
8 8 //============================================================================
9 9 // ToolBar
10 10 //============================================================================
11 11
12 12 var IPython = (function (IPython) {
13 13
14 14 var ToolBar = function (selector) {
15 15 this.selector = selector;
16 16 if (this.selector !== undefined) {
17 17 this.element = $(selector);
18 18 this.style();
19 this.bind_events();
20 19 }
21 20 };
22 21
22 // add a group of button into the current toolbar.
23 //
24 // First argument : Mandatory
25 // list of dict as argument, each dict should contain
26 // 3 mandatory keys and values :
27 // label : string -- the text to show on hover
28 // icon : string -- the jQuery-ui icon to add on this button
29 // callback : function -- the callback to execute on a click
30 //
31 // and optionally an 'id' key that is assigned to the button element
32 //
33 // Second Argument, optional,
34 // string reprensenting the id to give to the button group.
35 //
36 // Example
37 //
38 // IPython.toolbar.add_button_group([
39 // {label:'my button',
40 // icon:'ui-icon-disk',
41 // callback:function(){alert('hoho'),
42 // id : 'my_button_id', // this is optional
43 // }
44 // },
45 // {label:'my second button',
46 // icon:'ui-icon-scissors',
47 // callback:function(){alert('be carefull I cut')}
48 // }
49 // ],
50 // "my_button_group_id"
51 // )
52 //
53 ToolBar.prototype.add_buttons_group = function (list, group_id) {
54 var span_group = $('<span/>');
55 if( group_id != undefined ) {
56 span_group.attr('id',group_id);
57 }
58 for(var el in list) {
59 var button = $('<button/>').button({
60 icons : {primary : list[el].icon},
61 text : false,
62 label : list[el].label
63 });
64 var id = list[el].id;
65 if( id != undefined )
66 button.attr('id',id);
67 var fun = list[el].callback;
68 button.click(fun);
69 span_group.append(button);
70 }
71 span_group.buttonset();
72 $(this.selector).append(span_group);
73 };
23 74
24 75 ToolBar.prototype.style = function () {
25 76 this.element.addClass('border-box-sizing').
26 addClass('ui-widget ui-widget-content').
77 addClass('ui-widget ui-widget-content toolbar').
27 78 css('border-top-style','none').
28 79 css('border-left-style','none').
29 80 css('border-right-style','none');
30 this.element.find('#cell_type').addClass('ui-widget ui-widget-content');
31 this.element.find('#save_b').button({
32 icons : {primary: 'ui-icon-disk'},
33 text : false
34 });
35 this.element.find('#cut_b').button({
36 icons: {primary: 'ui-icon-scissors'},
37 text : false
38 });
39 this.element.find('#copy_b').button({
40 icons: {primary: 'ui-icon-copy'},
41 text : false
42 });
43 this.element.find('#paste_b').button({
44 icons: {primary: 'ui-icon-clipboard'},
45 text : false
46 });
47 this.element.find('#cut_copy_paste').buttonset();
48 this.element.find('#move_up_b').button({
49 icons: {primary: 'ui-icon-arrowthick-1-n'},
50 text : false
51 });
52 this.element.find('#move_down_b').button({
53 icons: {primary: 'ui-icon-arrowthick-1-s'},
54 text : false
55 });
56 this.element.find('#move_up_down').buttonset();
57 this.element.find('#insert_above_b').button({
58 icons: {primary: 'ui-icon-arrowthickstop-1-n'},
59 text : false
60 });
61 this.element.find('#insert_below_b').button({
62 icons: {primary: 'ui-icon-arrowthickstop-1-s'},
63 text : false
64 });
65 this.element.find('#insert_above_below').buttonset();
66 this.element.find('#run_b').button({
67 icons: {primary: 'ui-icon-play'},
68 text : false
69 });
70 this.element.find('#interrupt_b').button({
71 icons: {primary: 'ui-icon-stop'},
72 text : false
73 });
74 this.element.find('#run_int').buttonset();
75 };
76
77
78 ToolBar.prototype.bind_events = function () {
79 var that = this;
80 this.element.find('#save_b').click(function () {
81 IPython.notebook.save_notebook();
82 });
83 this.element.find('#cut_b').click(function () {
84 IPython.notebook.cut_cell();
85 });
86 this.element.find('#copy_b').click(function () {
87 IPython.notebook.copy_cell();
88 });
89 this.element.find('#paste_b').click(function () {
90 IPython.notebook.paste_cell();
91 });
92 this.element.find('#move_up_b').click(function () {
93 IPython.notebook.move_cell_up();
94 });
95 this.element.find('#move_down_b').click(function () {
96 IPython.notebook.move_cell_down();
97 });
98 this.element.find('#insert_above_b').click(function () {
99 IPython.notebook.insert_cell_above('code');
100 });
101 this.element.find('#insert_below_b').click(function () {
102 IPython.notebook.insert_cell_below('code');
103 });
104 this.element.find('#run_b').click(function () {
105 IPython.notebook.execute_selected_cell();
106 });
107 this.element.find('#interrupt_b').click(function () {
108 IPython.notebook.kernel.interrupt();
109 });
110 this.element.find('#cell_type').change(function () {
111 var cell_type = $(this).val();
112 if (cell_type === 'code') {
113 IPython.notebook.to_code();
114 } else if (cell_type === 'markdown') {
115 IPython.notebook.to_markdown();
116 } else if (cell_type === 'raw') {
117 IPython.notebook.to_raw();
118 } else if (cell_type === 'heading1') {
119 IPython.notebook.to_heading(undefined, 1);
120 } else if (cell_type === 'heading2') {
121 IPython.notebook.to_heading(undefined, 2);
122 } else if (cell_type === 'heading3') {
123 IPython.notebook.to_heading(undefined, 3);
124 } else if (cell_type === 'heading4') {
125 IPython.notebook.to_heading(undefined, 4);
126 } else if (cell_type === 'heading5') {
127 IPython.notebook.to_heading(undefined, 5);
128 } else if (cell_type === 'heading6') {
129 IPython.notebook.to_heading(undefined, 6);
130 };
131 });
132 $([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
133 if (data.cell_type === 'heading') {
134 that.element.find('#cell_type').val(data.cell_type+data.level);
135 } else {
136 that.element.find('#cell_type').val(data.cell_type);
137 }
138 });
139 81 };
140 82
141 83
142 84 ToolBar.prototype.toggle = function () {
143 85 this.element.toggle();
86 if (IPython.layout_manager != undefined) {
144 87 IPython.layout_manager.do_resize();
88 }
145 89 };
146 90
147 91
148 92 IPython.ToolBar = ToolBar;
149 93
150 94 return IPython;
151 95
152 96 }(IPython));
@@ -1,259 +1,224 b''
1 1 {% extends page.html %}
2 2 {% block stylesheet %}
3 3
4 4 {% if mathjax_url %}
5 5 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
6 6 {% end %}
7 7 <script type="text/javascript">
8 8 // MathJax disabled, set as null to distingish from *missing* MathJax,
9 9 // where it will be undefined, and should prompt a dialog later.
10 10 window.mathjax_url = "{{mathjax_url}}";
11 11 </script>
12 12
13 13 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
14 14 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
15 15
16 16 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
17 17
18 18 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
19 19 <link rel="stylesheet" href="{{ static_url("css/tooltip.css") }}" type="text/css" />
20 20 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
21 21
22 22 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" media="print"/>
23 23
24 24 {% end %}
25 25
26 26
27 27 {% block params %}
28 28
29 29 data-project={{project}}
30 30 data-base-project-url={{base_project_url}}
31 31 data-base-kernel-url={{base_kernel_url}}
32 32 data-read-only={{read_only and not logged_in}}
33 33 data-notebook-id={{notebook_id}}
34 34
35 35 {% end %}
36 36
37 37
38 38 {% block header %}
39 39
40 40 <span id="save_widget">
41 41 <span id="notebook_name"></span>
42 42 <span id="save_status"></span>
43 43 </span>
44 44
45 45 {% end %}
46 46
47 47
48 48 {% block site %}
49 49
50 50 <div id="menubar_container">
51 51 <div id="menubar">
52 52 <ul id="menus">
53 53 <li><a href="#">File</a>
54 54 <ul>
55 55 <li id="new_notebook"><a href="#">New</a></li>
56 56 <li id="open_notebook"><a href="#">Open...</a></li>
57 57 <hr/>
58 58 <li id="copy_notebook"><a href="#">Make a Copy...</a></li>
59 59 <li id="rename_notebook"><a href="#">Rename...</a></li>
60 60 <li id="save_notebook"><a href="#">Save</a></li>
61 61 <hr/>
62 62 <li><a href="#">Download as</a>
63 63 <ul>
64 64 <li id="download_ipynb"><a href="#">IPython (.ipynb)</a></li>
65 65 <li id="download_py"><a href="#">Python (.py)</a></li>
66 66 </ul>
67 67 </li>
68 68 <hr/>
69 69 <li id="print_notebook"><a href="/{{notebook_id}}/print" target="_blank">Print View</a></li>
70 70 <hr/>
71 71 <li id="kill_and_exit"><a href="#" >Close and halt</a></li>
72 72 </ul>
73 73 </li>
74 74 <li><a href="#">Edit</a>
75 75 <ul>
76 76 <li id="cut_cell"><a href="#">Cut Cell</a></li>
77 77 <li id="copy_cell"><a href="#">Copy Cell</a></li>
78 78 <li id="paste_cell" class="ui-state-disabled"><a href="#">Paste Cell</a></li>
79 79 <li id="paste_cell_above" class="ui-state-disabled"><a href="#">Paste Cell Above</a></li>
80 80 <li id="paste_cell_below" class="ui-state-disabled"><a href="#">Paste Cell Below</a></li>
81 81 <li id="delete_cell"><a href="#">Delete</a></li>
82 82 <hr/>
83 83 <li id="split_cell"><a href="#">Split Cell</a></li>
84 84 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
85 85 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
86 86 <hr/>
87 87 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
88 88 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
89 89 <hr/>
90 90 <li id="select_previous"><a href="#">Select Previous Cell</a></li>
91 91 <li id="select_next"><a href="#">Select Next Cell</a></li>
92 92 </ul>
93 93 </li>
94 94 <li><a href="#">View</a>
95 95 <ul>
96 96 <li id="toggle_header"><a href="#">Toggle Header</a></li>
97 97 <li id="toggle_toolbar"><a href="#">Toggle Toolbar</a></li>
98 98 </ul>
99 99 </li>
100 100 <li><a href="#">Insert</a>
101 101 <ul>
102 102 <li id="insert_cell_above"><a href="#">Insert Cell Above</a></li>
103 103 <li id="insert_cell_below"><a href="#">Insert Cell Below</a></li>
104 104 </ul>
105 105 </li>
106 106 <li><a href="#">Cell</a>
107 107 <ul>
108 108 <li id="run_cell"><a href="#">Run</a></li>
109 109 <li id="run_cell_in_place"><a href="#">Run in Place</a></li>
110 110 <li id="run_all_cells"><a href="#">Run All</a></li>
111 111 <hr/>
112 112 <li id="to_code"><a href="#">Code</a></li>
113 113 <li id="to_markdown"><a href="#">Markdown </a></li>
114 114 <li id="to_raw"><a href="#">Raw Text</a></li>
115 115 <li id="to_heading1"><a href="#">Heading 1</a></li>
116 116 <li id="to_heading2"><a href="#">Heading 2</a></li>
117 117 <li id="to_heading3"><a href="#">Heading 3</a></li>
118 118 <li id="to_heading4"><a href="#">Heading 4</a></li>
119 119 <li id="to_heading5"><a href="#">Heading 5</a></li>
120 120 <li id="to_heading6"><a href="#">Heading 6</a></li>
121 121 <hr/>
122 122 <li id="toggle_output"><a href="#">Toggle Current Output</a></li>
123 123 <li id="all_outputs"><a href="#">All Output</a>
124 124 <ul>
125 125 <li id="expand_all_output"><a href="#">Expand</a></li>
126 126 <li id="scroll_all_output"><a href="#">Scroll Long</a></li>
127 127 <li id="collapse_all_output"><a href="#">Collapse</a></li>
128 128 <li id="clear_all_output"><a href="#">Clear</a></li>
129 129 </ul>
130 130 </li>
131 131 </ul>
132 132 </li>
133 133 <li><a href="#">Kernel</a>
134 134 <ul>
135 135 <li id="int_kernel"><a href="#">Interrupt</a></li>
136 136 <li id="restart_kernel"><a href="#">Restart</a></li>
137 137 </ul>
138 138 </li>
139 139 <li><a href="#">Help</a>
140 140 <ul>
141 141 <li><a href="http://ipython.org/documentation.html" target="_blank">IPython Help</a></li>
142 142 <li><a href="http://ipython.org/ipython-doc/stable/interactive/htmlnotebook.html" target="_blank">Notebook Help</a></li>
143 143 <li id="keyboard_shortcuts"><a href="#">Keyboard Shortcuts</a></li>
144 144 <hr/>
145 145 <li><a href="http://docs.python.org" target="_blank">Python</a></li>
146 146 <li><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></li>
147 147 <li><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></li>
148 148 <li><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></li>
149 149 <li><a href="http://matplotlib.sourceforge.net/" target="_blank">Matplotlib</a></li>
150 150 </ul>
151 151 </li>
152 152 </ul>
153 153
154 154 </div>
155 155 <div id="notification_area">
156 156 </div>
157 157 </div>
158 158
159 159
160 <div id="toolbar">
161
162 <span>
163 <button id="save_b">Save</button>
164 </span>
165 <span id="cut_copy_paste">
166 <button id="cut_b" title="Cut Cell">Cut Cell</button>
167 <button id="copy_b" title="Copy Cell">Copy Cell</button>
168 <button id="paste_b" title="Paste Cell">Paste Cell</button>
169 </span>
170 <span id="move_up_down">
171 <button id="move_up_b" title="Move Cell Up">Move Cell Up</button>
172 <button id="move_down_b" title="Move Cell Down">Move Down</button>
173 </span>
174 <span id="insert_above_below">
175 <button id="insert_above_b" title="Insert Cell Above">Insert Cell Above</button>
176 <button id="insert_below_b" title="Insert Cell Below">Insert Cell Below</button>
177 </span>
178 <span id="run_int">
179 <button id="run_b" title="Run Cell">Run Cell</button>
180 <button id="interrupt_b" title="Interrupt">Interrupt</button>
181 </span>
182 <span>
183 <select id="cell_type">
184 <option value="code">Code</option>
185 <option value="markdown">Markdown</option>
186 <option value="raw">Raw Text</option>
187 <option value="heading1">Heading 1</option>
188 <option value="heading2">Heading 2</option>
189 <option value="heading3">Heading 3</option>
190 <option value="heading4">Heading 4</option>
191 <option value="heading5">Heading 5</option>
192 <option value="heading6">Heading 6</option>
193 </select>
194 </span>
195
196 </div>
160 <div id="maintoolbar"></div>
197 161
198 162 <div id="main_app">
199 163
200 164 <div id="notebook_panel">
201 165 <div id="notebook"></div>
202 166 <div id="pager_splitter"></div>
203 167 <div id="pager_container">
204 168 <div id='pager_button_area'>
205 169 </div>
206 170 <div id="pager"></div>
207 171 </div>
208 172 </div>
209 173
210 174 </div>
211 175 <div id='tooltip' class='tooltip ui-corner-all' style='display:none'></div>
212 176
213 177
214 178 {% end %}
215 179
216 180
217 181 {% block script %}
218 182
219 183 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
220 184 <script src="{{ static_url("codemirror/lib/util/loadmode.js") }}" charset="utf-8"></script>
221 185 <script src="{{ static_url("codemirror/lib/util/multiplex.js") }}" charset="utf-8"></script>
222 186 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
223 187 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
224 188 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
225 189 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
226 190 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
227 191 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
228 192 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
229 193
230 194 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
231 195
232 196 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
233 197 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
234 198
235 199 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
236 200 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
237 201 <script src="{{ static_url("js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
238 202 <script src="{{ static_url("js/initmathjax.js") }}" type="text/javascript" charset="utf-8"></script>
239 203 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
240 204 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
241 205 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
242 206 <script src="{{ static_url("js/completer.js") }}" type="text/javascript" charset="utf-8"></script>
243 207 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
244 208 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
245 209 <script src="{{ static_url("js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
246 210 <script src="{{ static_url("js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
247 211 <script src="{{ static_url("js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
248 212 <script src="{{ static_url("js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
249 213 <script src="{{ static_url("js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
214 <script src="{{ static_url("js/maintoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
250 215 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
251 216 <script src="{{ static_url("js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script>
252 217 <script src="{{ static_url("js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script>
253 218 <script src="{{ static_url("js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script>
254 219 <script src="{{ static_url("js/config.js") }}" type="text/javascript" charset="utf-8"></script>
255 220 <script src="{{ static_url("js/notebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
256 221
257 222 <script src="{{ static_url("js/contexthint.js") }}" charset="utf-8"></script>
258 223
259 224 {% end %}
General Comments 0
You need to be logged in to leave comments. Login now