##// END OF EJS Templates
remove useless classes
Matthias BUSSONNIER -
Show More
@@ -1,447 +1,448 b''
1 /**
1 /**
2 * Primary styles
2 * Primary styles
3 *
3 *
4 * Author: IPython Development Team
4 * Author: IPython Development Team
5 */
5 */
6
6
7 @import "variables.less";
7 @import "variables.less";
8
8
9 body {
9 body {
10 overflow: hidden;
10 overflow: hidden;
11 background-color:@notebook_background;
11 }
12 }
12
13
13 blockquote {
14 blockquote {
14 border-left: 4px solid #DDD;
15 border-left: 4px solid #DDD;
15 padding: 0 15px;
16 padding: 0 15px;
16 color: #777;
17 color: #777;
17 }
18 }
18
19
19 span#save_widget {
20 span#save_widget {
20 padding: 5px;
21 padding: 5px;
21 margin: 0px 0px 0px 300px;
22 margin: 0px 0px 0px 300px;
22 display:inline-block;
23 display:inline-block;
23 }
24 }
24
25
25 span#notebook_name {
26 span#notebook_name {
26 height: 1em;
27 height: 1em;
27 line-height: 1em;
28 line-height: 1em;
28 padding: 3px;
29 padding: 3px;
29 border: none;
30 border: none;
30 font-size: 146.5%;
31 font-size: 146.5%;
31 }
32 }
32
33
33
34
34 .ui-menubar-item .ui-button .ui-button-text {
35 .ui-menubar-item .ui-button .ui-button-text {
35 padding: 0.4em 1.0em;
36 padding: 0.4em 1.0em;
36 font-size: 100%;
37 font-size: 100%;
37 }
38 }
38
39
39 .ui-menu {
40 .ui-menu {
40 -moz-box-shadow: 0px 6px 10px -1px #adadad;
41 -moz-box-shadow: 0px 6px 10px -1px #adadad;
41 -webkit-box-shadow: 0px 6px 10px -1px #adadad;
42 -webkit-box-shadow: 0px 6px 10px -1px #adadad;
42 box-shadow: 0px 6px 10px -1px #adadad;
43 box-shadow: 0px 6px 10px -1px #adadad;
43 }
44 }
44
45
45 .ui-menu .ui-menu-item a {
46 .ui-menu .ui-menu-item a {
46 border: 1px solid transparent;
47 border: 1px solid transparent;
47 padding: 2px 1.6em;
48 padding: 2px 1.6em;
48 }
49 }
49
50
50 .ui-menu .ui-menu-item a.ui-state-focus {
51 .ui-menu .ui-menu-item a.ui-state-focus {
51 margin: 0;
52 margin: 0;
52 }
53 }
53
54
54 .ui-menu hr {
55 .ui-menu hr {
55 margin: 0.3em 0;
56 margin: 0.3em 0;
56 }
57 }
57
58
58 #menubar_container {
59 #menubar_container {
59 position: relative;
60 position: relative;
60 }
61 }
61
62
62 #notification_area {
63 #notification_area {
63 position: absolute;
64 position: absolute;
64 right: 0px;
65 right: 0px;
65 top: 0px;
66 top: 0px;
66 height: 25px;
67 height: 25px;
67 padding: 3px 0px;
68 padding: 3px 0px;
68 padding-right: 3px;
69 padding-right: 3px;
69 z-index: 10;
70 z-index: 10;
70 }
71 }
71
72
72 .notification_widget{
73 .notification_widget{
73 float : right;
74 float : right;
74 right: 0px;
75 right: 0px;
75 top: 1px;
76 top: 1px;
76 height: 25px;
77 height: 25px;
77 padding: 3px 6px;
78 padding: 3px 6px;
78 z-index: 10;
79 z-index: 10;
79 }
80 }
80
81
81 .toolbar {
82 .toolbar {
82 padding: 3px 15px;
83 padding: 3px 15px;
84 border-bottom: @borderwidth @border_color solid;
83 }
85 }
84
86
85 #maintoolbar > select, #maintoolbar label {
87 #maintoolbar > select, #maintoolbar label {
86 font-size: 85%;
88 font-size: 85%;
87 margin-left:0.3em;
89 margin-left:0.3em;
88 margin-right:0.3em;
90 margin-right:0.3em;
89
91
90 }
92 }
91
93
92
94
93 div#main_app {
95 div#main_app {
94 width: 100%;
96 width: 100%;
95 position: relative;
97 position: relative;
96 }
98 }
97
99
98 span#quick_help_area {
100 span#quick_help_area {
99 position: static;
101 position: static;
100 padding: 5px 0px;
102 padding: 5px 0px;
101 margin: 0px 0px 0px 0px;
103 margin: 0px 0px 0px 0px;
102 }
104 }
103
105
104 .help_string {
106 .help_string {
105 float: right;
107 float: right;
106 width: 170px;
108 width: 170px;
107 padding: 0px 5px;
109 padding: 0px 5px;
108 text-align: left;
110 text-align: left;
109 font-size: 85%;
111 font-size: 85%;
110 }
112 }
111
113
112 .help_string_label {
114 .help_string_label {
113 float: right;
115 float: right;
114 font-size: 85%;
116 font-size: 85%;
115 }
117 }
116
118
117 div#notebook_panel {
119 div#notebook_panel {
118 margin: 0px 0px 0px 0px;
120 margin: 0px 0px 0px 0px;
119 padding: 0px;
121 padding: 0px;
120 }
122 }
121
123
122 div#notebook {
124 div#notebook {
123 overflow-y: scroll;
125 overflow-y: scroll;
124 overflow-x: auto;
126 overflow-x: auto;
125 width: 100%;
127 width: 100%;
126 /* This spaces the cell away from the edge of the notebook area */
128 /* This spaces the cell away from the edge of the notebook area */
127 padding: 5px 5px 15px 5px;
129 padding: 5px 5px 15px 5px;
128 margin: 0px;
130 margin: 0px;
129 background-color: @notebook_background;
130 }
131 }
131
132
132 div#pager_splitter {
133 div#pager_splitter {
133 height: 8px;
134 height: 8px;
134 }
135 }
135
136
136 #pager_container {
137 #pager_container {
137 position : relative;
138 position : relative;
138 }
139 }
139
140
140 div#pager {
141 div#pager {
141 padding: 15px;
142 padding: 15px;
142 overflow: auto;
143 overflow: auto;
143 display: none;
144 display: none;
144 }
145 }
145
146
146 div.ui-widget-content {
147 div.ui-widget-content {
147 border: 1px solid @border_color;
148 border: 1px solid @border_color;
148 outline: none;
149 outline: none;
149 }
150 }
150
151
151 .cell {
152 .cell {
152 border: 1px solid transparent;
153 border: 1px solid transparent;
153
154
154 &.selected {
155 &.selected {
155 .corner-all;
156 .corner-all;
156 background-color:@cell_selected_background;
157 background-color:@cell_selected_background;
157 border : thin @border_color solid;
158 border : thin @border_color solid;
158 }
159 }
159 }
160 }
160
161
161 div.cell {
162 div.cell {
162 width: 100%;
163 width: 100%;
163 padding: 5px 5px 5px 0px;
164 padding: 5px 5px 5px 0px;
164 /* This acts as a spacer between cells, that is outside the border */
165 /* This acts as a spacer between cells, that is outside the border */
165 margin: 2px 0px 2px 0px;
166 margin: 2px 0px 2px 0px;
166 outline: none;
167 outline: none;
167 }
168 }
168
169
169 div.code_cell {
170 div.code_cell {
170 }
171 }
171
172
172 /* any special styling for code cells that are currently running goes here */
173 /* any special styling for code cells that are currently running goes here */
173 div.code_cell.running {
174 div.code_cell.running {
174 }
175 }
175
176
176 div.prompt {
177 div.prompt {
177 /* This needs to be wide enough for 3 digit prompt numbers: In[100]: */
178 /* This needs to be wide enough for 3 digit prompt numbers: In[100]: */
178 width: 11ex;
179 width: 11ex;
179 /* This 0.4em is tuned to match the padding on the CodeMirror editor. */
180 /* This 0.4em is tuned to match the padding on the CodeMirror editor. */
180 padding: 0.4em;
181 padding: 0.4em;
181 margin: 0px;
182 margin: 0px;
182 font-family: monospace;
183 font-family: monospace;
183 text-align: right;
184 text-align: right;
184 /* This has to match that of the the CodeMirror class line-height below */
185 /* This has to match that of the the CodeMirror class line-height below */
185 line-height: 1.231;
186 line-height: 1.231;
186 }
187 }
187
188
188 div.input {
189 div.input {
189 page-break-inside: avoid;
190 page-break-inside: avoid;
190 }
191 }
191
192
192 /* input_area and input_prompt must match in top border and margin for alignment */
193 /* input_area and input_prompt must match in top border and margin for alignment */
193 div.input_area {
194 div.input_area {
194 color: black;
195 color: black;
195 border: 1px solid @border_color;
196 border: 1px solid @border_color;
196 .corner-all;
197 .corner-all;
197 background: @cell_background;
198 background: @cell_background;
198 }
199 }
199
200
200 div.input_prompt {
201 div.input_prompt {
201 color: navy;
202 color: navy;
202 border-top: 1px solid transparent;
203 border-top: 1px solid transparent;
203 }
204 }
204
205
205 div.output_wrapper {
206 div.output_wrapper {
206 /* This is a spacer between the input and output of each cell */
207 /* This is a spacer between the input and output of each cell */
207 margin-top: 5px;
208 margin-top: 5px;
208 margin-left: 5px;
209 margin-left: 5px;
209 /* FF needs explicit width to stretch */
210 /* FF needs explicit width to stretch */
210 width: 100%;
211 width: 100%;
211 /* this position must be relative to enable descendents to be absolute within it */
212 /* this position must be relative to enable descendents to be absolute within it */
212 position: relative;
213 position: relative;
213 }
214 }
214
215
215 /* class for the output area when it should be height-limited */
216 /* class for the output area when it should be height-limited */
216 div.output_scroll {
217 div.output_scroll {
217 /* ideally, this would be max-height, but FF barfs all over that */
218 /* ideally, this would be max-height, but FF barfs all over that */
218 height: 24em;
219 height: 24em;
219 /* FF needs this *and the wrapper* to specify full width, or it will shrinkwrap */
220 /* FF needs this *and the wrapper* to specify full width, or it will shrinkwrap */
220 width: 100%;
221 width: 100%;
221
222
222 overflow: auto;
223 overflow: auto;
223 .corner-all;
224 .corner-all;
224 box-shadow: inset 0 2px 8px rgba(0, 0, 0, .8);
225 box-shadow: inset 0 2px 8px rgba(0, 0, 0, .8);
225 }
226 }
226
227
227 /* output div while it is collapsed */
228 /* output div while it is collapsed */
228 div.output_collapsed {
229 div.output_collapsed {
229 margin-right: 5px;
230 margin-right: 5px;
230 }
231 }
231
232
232 div.out_prompt_overlay {
233 div.out_prompt_overlay {
233 height: 100%;
234 height: 100%;
234 padding: 0px;
235 padding: 0px;
235 position: absolute;
236 position: absolute;
236 .corner-all;
237 .corner-all;
237 }
238 }
238
239
239 div.out_prompt_overlay:hover {
240 div.out_prompt_overlay:hover {
240 /* use inner shadow to get border that is computed the same on WebKit/FF */
241 /* use inner shadow to get border that is computed the same on WebKit/FF */
241 box-shadow: inset 0 0 1px #000;
242 box-shadow: inset 0 0 1px #000;
242 background: rgba(240, 240, 240, 0.5);
243 background: rgba(240, 240, 240, 0.5);
243 }
244 }
244
245
245 div.output_prompt {
246 div.output_prompt {
246 color: darkred;
247 color: darkred;
247 /* 5px right shift to account for margin in parent container */
248 /* 5px right shift to account for margin in parent container */
248 margin: 0 5px 0 -5px;
249 margin: 0 5px 0 -5px;
249 }
250 }
250
251
251 /* This class is the outer container of all output sections. */
252 /* This class is the outer container of all output sections. */
252 div.output_area {
253 div.output_area {
253 padding: 0px;
254 padding: 0px;
254 page-break-inside: avoid;
255 page-break-inside: avoid;
255 }
256 }
256
257
257
258
258 /* This is needed to protect the pre formating from global settings such
259 /* This is needed to protect the pre formating from global settings such
259 as that of bootstrap */
260 as that of bootstrap */
260 div.output_area pre {
261 div.output_area pre {
261 font-family: monospace;
262 font-family: monospace;
262 margin: 0;
263 margin: 0;
263 padding: 0;
264 padding: 0;
264 border: 0;
265 border: 0;
265 font-size: 100%;
266 font-size: 100%;
266 font: inherit;
267 font: inherit;
267 vertical-align: baseline;
268 vertical-align: baseline;
268 color: black;
269 color: black;
269 background-color: white;
270 background-color: white;
270 }
271 }
271
272
272 /* This class is for the output subarea inside the output_area and after
273 /* This class is for the output subarea inside the output_area and after
273 the prompt div. */
274 the prompt div. */
274 div.output_subarea {
275 div.output_subarea {
275 padding: 0.44em 0.4em 0.4em 1px;
276 padding: 0.44em 0.4em 0.4em 1px;
276 }
277 }
277
278
278 /* The rest of the output_* classes are for special styling of the different
279 /* The rest of the output_* classes are for special styling of the different
279 output types */
280 output types */
280
281
281 /* all text output has this class: */
282 /* all text output has this class: */
282 div.output_text {
283 div.output_text {
283 text-align: left;
284 text-align: left;
284 color: black;
285 color: black;
285 font-family: monospace;
286 font-family: monospace;
286 /* This has to match that of the the CodeMirror class line-height below */
287 /* This has to match that of the the CodeMirror class line-height below */
287 line-height: 1.231;
288 line-height: 1.231;
288 }
289 }
289
290
290 /* stdout/stderr are 'text' as well as 'stream', but pyout/pyerr are *not* streams */
291 /* stdout/stderr are 'text' as well as 'stream', but pyout/pyerr are *not* streams */
291 div.output_stream {
292 div.output_stream {
292 padding-top: 0.0em;
293 padding-top: 0.0em;
293 padding-bottom: 0.0em;
294 padding-bottom: 0.0em;
294 }
295 }
295 div.output_stdout {
296 div.output_stdout {
296 }
297 }
297 div.output_stderr {
298 div.output_stderr {
298 background: #fdd; /* very light red background for stderr */
299 background: #fdd; /* very light red background for stderr */
299 }
300 }
300
301
301 div.output_latex {
302 div.output_latex {
302 text-align: left;
303 text-align: left;
303 color: black;
304 color: black;
304 }
305 }
305
306
306 div.output_html {
307 div.output_html {
307 }
308 }
308
309
309 div.output_png {
310 div.output_png {
310 }
311 }
311
312
312 div.output_jpeg {
313 div.output_jpeg {
313 }
314 }
314
315
315 div.text_cell {
316 div.text_cell {
316 padding: 5px 5px 5px 5px;
317 padding: 5px 5px 5px 5px;
317 }
318 }
318
319
319 div.text_cell_input {
320 div.text_cell_input {
320 color: black;
321 color: black;
321 border: 1px solid @border_color;
322 border: 1px solid @border_color;
322 .corner-all;
323 .corner-all;
323 background: @cell_background;
324 background: @cell_background;
324 }
325 }
325
326
326 div.text_cell_render {
327 div.text_cell_render {
327 font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
328 font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
328 outline: none;
329 outline: none;
329 resize: none;
330 resize: none;
330 width: inherit;
331 width: inherit;
331 border-style: none;
332 border-style: none;
332 padding: 5px;
333 padding: 5px;
333 color: black;
334 color: black;
334 }
335 }
335
336
336 /* The following gets added to the <head> if it is detected that the user has a
337 /* The following gets added to the <head> if it is detected that the user has a
337 * monospace font with inconsistent normal/bold/italic height. See
338 * monospace font with inconsistent normal/bold/italic height. See
338 * notebookmain.js. Such fonts will have keywords vertically offset with
339 * notebookmain.js. Such fonts will have keywords vertically offset with
339 * respect to the rest of the text. The user should select a better font.
340 * respect to the rest of the text. The user should select a better font.
340 * See: https://github.com/ipython/ipython/issues/1503
341 * See: https://github.com/ipython/ipython/issues/1503
341 *
342 *
342 * .CodeMirror span {
343 * .CodeMirror span {
343 * vertical-align: bottom;
344 * vertical-align: bottom;
344 * }
345 * }
345 */
346 */
346
347
347 .CodeMirror {
348 .CodeMirror {
348 line-height: 1.231; /* Changed from 1em to our global default */
349 line-height: 1.231; /* Changed from 1em to our global default */
349 }
350 }
350
351
351 .CodeMirror-scroll {
352 .CodeMirror-scroll {
352 height: auto; /* Changed to auto to autogrow */
353 height: auto; /* Changed to auto to autogrow */
353 /* The CodeMirror docs are a bit fuzzy on if overflow-y should be hidden or visible.*/
354 /* The CodeMirror docs are a bit fuzzy on if overflow-y should be hidden or visible.*/
354 /* We have found that if it is visible, vertical scrollbars appear with font size changes.*/
355 /* We have found that if it is visible, vertical scrollbars appear with font size changes.*/
355 overflow-y: hidden;
356 overflow-y: hidden;
356 overflow-x: auto; /* Changed from auto to remove scrollbar */
357 overflow-x: auto; /* Changed from auto to remove scrollbar */
357 }
358 }
358
359
359 /* CSS font colors for translated ANSI colors. */
360 /* CSS font colors for translated ANSI colors. */
360
361
361
362
362 .ansiblack {color: black;}
363 .ansiblack {color: black;}
363 .ansired {color: darkred;}
364 .ansired {color: darkred;}
364 .ansigreen {color: darkgreen;}
365 .ansigreen {color: darkgreen;}
365 .ansiyellow {color: brown;}
366 .ansiyellow {color: brown;}
366 .ansiblue {color: darkblue;}
367 .ansiblue {color: darkblue;}
367 .ansipurple {color: darkviolet;}
368 .ansipurple {color: darkviolet;}
368 .ansicyan {color: steelblue;}
369 .ansicyan {color: steelblue;}
369 .ansigrey {color: grey;}
370 .ansigrey {color: grey;}
370 .ansibold {font-weight: bold;}
371 .ansibold {font-weight: bold;}
371
372
372 .completions {
373 .completions {
373 position: absolute;
374 position: absolute;
374 z-index: 10;
375 z-index: 10;
375 overflow: hidden;
376 overflow: hidden;
376 border: 1px solid @border_color;
377 border: 1px solid @border_color;
377 }
378 }
378
379
379 .completions select {
380 .completions select {
380 background: white;
381 background: white;
381 outline: none;
382 outline: none;
382 border: none;
383 border: none;
383 padding: 0px;
384 padding: 0px;
384 margin: 0px;
385 margin: 0px;
385 overflow: auto;
386 overflow: auto;
386 font-family: monospace;
387 font-family: monospace;
387 }
388 }
388
389
389 option.context {
390 option.context {
390 background-color: #DEF7FF;
391 background-color: #DEF7FF;
391 }
392 }
392 option.introspection {
393 option.introspection {
393 background-color: #EBF4EB;
394 background-color: #EBF4EB;
394 }
395 }
395
396
396 /*fixed part of the completion*/
397 /*fixed part of the completion*/
397 .completions p b {
398 .completions p b {
398 font-weight:bold;
399 font-weight:bold;
399 }
400 }
400
401
401 .completions p {
402 .completions p {
402 background: #DDF;
403 background: #DDF;
403 /*outline: none;
404 /*outline: none;
404 padding: 0px;*/
405 padding: 0px;*/
405 border-bottom: black solid 1px;
406 border-bottom: black solid 1px;
406 padding: 1px;
407 padding: 1px;
407 font-family: monospace;
408 font-family: monospace;
408 }
409 }
409
410
410 pre.dialog {
411 pre.dialog {
411 background-color: @cell_background;
412 background-color: @cell_background;
412 border: 1px solid #ddd;
413 border: 1px solid #ddd;
413 .corner-all;
414 .corner-all;
414 padding: 0.4em;
415 padding: 0.4em;
415 padding-left: 2em;
416 padding-left: 2em;
416 }
417 }
417
418
418 p.dialog {
419 p.dialog {
419 padding : 0.2em;
420 padding : 0.2em;
420 }
421 }
421
422
422 .shortcut_key {
423 .shortcut_key {
423 display: inline-block;
424 display: inline-block;
424 width: 15ex;
425 width: 15ex;
425 text-align: right;
426 text-align: right;
426 font-family: monospace;
427 font-family: monospace;
427 }
428 }
428
429
429 .shortcut_descr {
430 .shortcut_descr {
430 }
431 }
431
432
432 /* Word-wrap output correctly. This is the CSS3 spelling, though Firefox seems
433 /* Word-wrap output correctly. This is the CSS3 spelling, though Firefox seems
433 to not honor it correctly. Webkit browsers (Chrome, rekonq, Safari) do.
434 to not honor it correctly. Webkit browsers (Chrome, rekonq, Safari) do.
434 */
435 */
435 pre, code, kbd, samp { white-space: pre-wrap; }
436 pre, code, kbd, samp { white-space: pre-wrap; }
436
437
437 #fonttest {
438 #fonttest {
438 font-family: monospace;
439 font-family: monospace;
439 }
440 }
440
441
441 .js-error {
442 .js-error {
442 color: darkred;
443 color: darkred;
443 }
444 }
444
445
445
446
446
447
447
448
@@ -1,59 +1,59 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // Global header/site setup.
9 // Global header/site setup.
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 var Page = function () {
14 var Page = function () {
15 this.style();
15 this.style();
16 this.bind_events();
16 this.bind_events();
17 };
17 };
18
18
19 Page.prototype.style = function () {
19 Page.prototype.style = function () {
20 $('div#header').addClass('border-box-sizing').
20 $('div#header').addClass('border-box-sizing').
21 addClass('ui-widget ui-widget-content').
21 addClass('ui-widget').
22 css('border-top-style','none').
22 css('border-top-style','none').
23 css('border-left-style','none').
23 css('border-left-style','none').
24 css('border-right-style','none');
24 css('border-right-style','none');
25 $('div#site').addClass('border-box-sizing')
25 $('div#site').addClass('border-box-sizing')
26 };
26 };
27
27
28
28
29 Page.prototype.bind_events = function () {
29 Page.prototype.bind_events = function () {
30 };
30 };
31
31
32
32
33 Page.prototype.show = function () {
33 Page.prototype.show = function () {
34 // The header and site divs start out hidden to prevent FLOUC.
34 // The header and site divs start out hidden to prevent FLOUC.
35 // Main scripts should call this method after styling everything.
35 // Main scripts should call this method after styling everything.
36 this.show_header();
36 this.show_header();
37 this.show_site();
37 this.show_site();
38 };
38 };
39
39
40
40
41 Page.prototype.show_header = function () {
41 Page.prototype.show_header = function () {
42 // The header and site divs start out hidden to prevent FLOUC.
42 // The header and site divs start out hidden to prevent FLOUC.
43 // Main scripts should call this method after styling everything.
43 // Main scripts should call this method after styling everything.
44 $('div#header').css('display','block');
44 $('div#header').css('display','block');
45 };
45 };
46
46
47
47
48 Page.prototype.show_site = function () {
48 Page.prototype.show_site = function () {
49 // The header and site divs start out hidden to prevent FLOUC.
49 // The header and site divs start out hidden to prevent FLOUC.
50 // Main scripts should call this method after styling everything.
50 // Main scripts should call this method after styling everything.
51 $('div#site').css('display','block');
51 $('div#site').css('display','block');
52 };
52 };
53
53
54
54
55 IPython.Page = Page;
55 IPython.Page = Page;
56
56
57 return IPython;
57 return IPython;
58
58
59 }(IPython));
59 }(IPython));
@@ -1,139 +1,139 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // SaveWidget
9 // SaveWidget
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 var utils = IPython.utils;
14 var utils = IPython.utils;
15
15
16 var SaveWidget = function (selector) {
16 var SaveWidget = function (selector) {
17 this.selector = selector;
17 this.selector = selector;
18 if (this.selector !== undefined) {
18 if (this.selector !== undefined) {
19 this.element = $(selector);
19 this.element = $(selector);
20 this.style();
20 this.style();
21 this.bind_events();
21 this.bind_events();
22 }
22 }
23 };
23 };
24
24
25
25
26 SaveWidget.prototype.style = function () {
26 SaveWidget.prototype.style = function () {
27 this.element.find('span#save_widget').addClass('ui-widget');
27 this.element.find('span#save_widget').addClass('ui-widget');
28 this.element.find('span#notebook_name').addClass('ui-widget ui-widget-content');
28 this.element.find('span#notebook_name').addClass('ui-widget');
29 this.element.find('span#save_status').addClass('ui-widget ui-widget-content')
29 this.element.find('span#save_status').addClass('ui-widget')
30 .css({border: 'none', 'margin-left': '20px'});
30 .css({border: 'none', 'margin-left': '20px'});
31 };
31 };
32
32
33
33
34 SaveWidget.prototype.bind_events = function () {
34 SaveWidget.prototype.bind_events = function () {
35 var that = this;
35 var that = this;
36 this.element.find('span#notebook_name').click(function () {
36 this.element.find('span#notebook_name').click(function () {
37 that.rename_notebook();
37 that.rename_notebook();
38 });
38 });
39 this.element.find('span#notebook_name').hover(function () {
39 this.element.find('span#notebook_name').hover(function () {
40 $(this).addClass("ui-state-hover");
40 $(this).addClass("ui-state-hover");
41 }, function () {
41 }, function () {
42 $(this).removeClass("ui-state-hover");
42 $(this).removeClass("ui-state-hover");
43 });
43 });
44 $([IPython.events]).on('notebook_loaded.Notebook', function () {
44 $([IPython.events]).on('notebook_loaded.Notebook', function () {
45 that.set_last_saved();
45 that.set_last_saved();
46 that.update_notebook_name();
46 that.update_notebook_name();
47 that.update_document_title();
47 that.update_document_title();
48 });
48 });
49 $([IPython.events]).on('notebook_saved.Notebook', function () {
49 $([IPython.events]).on('notebook_saved.Notebook', function () {
50 that.set_last_saved();
50 that.set_last_saved();
51 that.update_notebook_name();
51 that.update_notebook_name();
52 that.update_document_title();
52 that.update_document_title();
53 });
53 });
54 $([IPython.events]).on('notebook_save_failed.Notebook', function () {
54 $([IPython.events]).on('notebook_save_failed.Notebook', function () {
55 that.set_save_status('Last Save Failed!');
55 that.set_save_status('Last Save Failed!');
56 });
56 });
57 };
57 };
58
58
59
59
60 SaveWidget.prototype.rename_notebook = function () {
60 SaveWidget.prototype.rename_notebook = function () {
61 var that = this;
61 var that = this;
62 var dialog = $('<div/>');
62 var dialog = $('<div/>');
63 dialog.append(
63 dialog.append(
64 $('<h3/>').html('Enter a new notebook name:')
64 $('<h3/>').html('Enter a new notebook name:')
65 .css({'margin-bottom': '10px'})
65 .css({'margin-bottom': '10px'})
66 );
66 );
67 dialog.append(
67 dialog.append(
68 $('<input/>').attr('type','text').attr('size','25')
68 $('<input/>').attr('type','text').attr('size','25')
69 .addClass('ui-widget ui-widget-content')
69 .addClass('ui-widget ui-widget-content')
70 .attr('value',IPython.notebook.get_notebook_name())
70 .attr('value',IPython.notebook.get_notebook_name())
71 );
71 );
72 // $(document).append(dialog);
72 // $(document).append(dialog);
73 dialog.dialog({
73 dialog.dialog({
74 resizable: false,
74 resizable: false,
75 modal: true,
75 modal: true,
76 title: "Rename Notebook",
76 title: "Rename Notebook",
77 closeText: "",
77 closeText: "",
78 close: function(event, ui) {$(this).dialog('destroy').remove();},
78 close: function(event, ui) {$(this).dialog('destroy').remove();},
79 buttons : {
79 buttons : {
80 "OK": function () {
80 "OK": function () {
81 var new_name = $(this).find('input').attr('value');
81 var new_name = $(this).find('input').attr('value');
82 if (!IPython.notebook.test_notebook_name(new_name)) {
82 if (!IPython.notebook.test_notebook_name(new_name)) {
83 $(this).find('h3').html(
83 $(this).find('h3').html(
84 "Invalid notebook name. Notebook names must "+
84 "Invalid notebook name. Notebook names must "+
85 "have 1 or more characters and can contain any characters " +
85 "have 1 or more characters and can contain any characters " +
86 "except :/\\. Please enter a new notebook name:"
86 "except :/\\. Please enter a new notebook name:"
87 );
87 );
88 } else {
88 } else {
89 IPython.notebook.set_notebook_name(new_name);
89 IPython.notebook.set_notebook_name(new_name);
90 IPython.notebook.save_notebook();
90 IPython.notebook.save_notebook();
91 $(this).dialog('close');
91 $(this).dialog('close');
92 }
92 }
93 },
93 },
94 "Cancel": function () {
94 "Cancel": function () {
95 $(this).dialog('close');
95 $(this).dialog('close');
96 }
96 }
97 },
97 },
98 open : function (event, ui) {
98 open : function (event, ui) {
99 var that = $(this);
99 var that = $(this);
100 // Upon ENTER, click the OK button.
100 // Upon ENTER, click the OK button.
101 that.find('input[type="text"]').keydown(function (event, ui) {
101 that.find('input[type="text"]').keydown(function (event, ui) {
102 if (event.which === utils.keycodes.ENTER) {
102 if (event.which === utils.keycodes.ENTER) {
103 that.parent().find('button').first().click();
103 that.parent().find('button').first().click();
104 }
104 }
105 });
105 });
106 }
106 }
107 });
107 });
108 }
108 }
109
109
110
110
111 SaveWidget.prototype.update_notebook_name = function () {
111 SaveWidget.prototype.update_notebook_name = function () {
112 var nbname = IPython.notebook.get_notebook_name();
112 var nbname = IPython.notebook.get_notebook_name();
113 this.element.find('span#notebook_name').html(nbname);
113 this.element.find('span#notebook_name').html(nbname);
114 };
114 };
115
115
116
116
117 SaveWidget.prototype.update_document_title = function () {
117 SaveWidget.prototype.update_document_title = function () {
118 var nbname = IPython.notebook.get_notebook_name();
118 var nbname = IPython.notebook.get_notebook_name();
119 document.title = nbname;
119 document.title = nbname;
120 };
120 };
121
121
122
122
123 SaveWidget.prototype.set_save_status = function (msg) {
123 SaveWidget.prototype.set_save_status = function (msg) {
124 this.element.find('span#save_status').html(msg);
124 this.element.find('span#save_status').html(msg);
125 }
125 }
126
126
127
127
128 SaveWidget.prototype.set_last_saved = function () {
128 SaveWidget.prototype.set_last_saved = function () {
129 var d = new Date();
129 var d = new Date();
130 this.set_save_status('Last saved: '+d.format('mmm dd h:MM TT'));
130 this.set_save_status('Last saved: '+d.format('mmm dd h:MM TT'));
131 };
131 };
132
132
133
133
134 IPython.SaveWidget = SaveWidget;
134 IPython.SaveWidget = SaveWidget;
135
135
136 return IPython;
136 return IPython;
137
137
138 }(IPython));
138 }(IPython));
139
139
@@ -1,111 +1,111 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008 The IPython Development Team
2 // Copyright (C) 2008 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // ToolBar
9 // ToolBar
10 //============================================================================
10 //============================================================================
11 /**
11 /**
12 * @module IPython
12 * @module IPython
13 * @namespace IPython
13 * @namespace IPython
14 * @submodule ToolBar
14 * @submodule ToolBar
15 */
15 */
16
16
17 var IPython = (function (IPython) {
17 var IPython = (function (IPython) {
18
18
19 /**
19 /**
20 * A generic toolbar on which one can add button
20 * A generic toolbar on which one can add button
21 * @class ToolBar
21 * @class ToolBar
22 * @constructor
22 * @constructor
23 * @param {Dom object} selector
23 * @param {Dom object} selector
24 */
24 */
25 var ToolBar = function (selector) {
25 var ToolBar = function (selector) {
26 this.selector = selector;
26 this.selector = selector;
27 if (this.selector !== undefined) {
27 if (this.selector !== undefined) {
28 this.element = $(selector);
28 this.element = $(selector);
29 this.style();
29 this.style();
30 }
30 }
31 };
31 };
32
32
33 /**
33 /**
34 * add a group of button into the current toolbar.
34 * add a group of button into the current toolbar.
35 *
35 *
36 *
36 *
37 * @example
37 * @example
38 *
38 *
39 * IPython.toolbar.add_buttons_group([
39 * IPython.toolbar.add_buttons_group([
40 * {
40 * {
41 * label:'my button',
41 * label:'my button',
42 * icon:'ui-icon-disk',
42 * icon:'ui-icon-disk',
43 * callback:function(){alert('hoho'),
43 * callback:function(){alert('hoho'),
44 * id : 'my_button_id', // this is optional
44 * id : 'my_button_id', // this is optional
45 * },
45 * },
46 * {
46 * {
47 * label:'my second button',
47 * label:'my second button',
48 * icon:'ui-icon-scissors',
48 * icon:'ui-icon-scissors',
49 * callback:function(){alert('be carefull I cut')}
49 * callback:function(){alert('be carefull I cut')}
50 * }
50 * }
51 * ],
51 * ],
52 * "my_button_group_id"
52 * "my_button_group_id"
53 * )
53 * )
54 *
54 *
55 * @method add_buttons_group
55 * @method add_buttons_group
56 * @param list {List}
56 * @param list {List}
57 * List of button of the group, with the following paramter for each :
57 * List of button of the group, with the following paramter for each :
58 * @param list.label {string} text to show on button hover
58 * @param list.label {string} text to show on button hover
59 * @param list.icon {string} icon to choose from [jQuery ThemeRoller](http://jqueryui.com/themeroller/)
59 * @param list.icon {string} icon to choose from [jQuery ThemeRoller](http://jqueryui.com/themeroller/)
60 * @param list.callback {function} function to be called on button click
60 * @param list.callback {function} function to be called on button click
61 * @param [list.id] {String} id to give to the button
61 * @param [list.id] {String} id to give to the button
62 * @param [group_id] {String} optionnal id to give to the group
62 * @param [group_id] {String} optionnal id to give to the group
63 *
63 *
64 */
64 */
65 ToolBar.prototype.add_buttons_group = function (list, group_id) {
65 ToolBar.prototype.add_buttons_group = function (list, group_id) {
66 var span_group = $('<span/>');
66 var span_group = $('<span/>');
67 if( group_id != undefined ) {
67 if( group_id != undefined ) {
68 span_group.attr('id',group_id);
68 span_group.attr('id',group_id);
69 }
69 }
70 for(var el in list) {
70 for(var el in list) {
71 var button = $('<button/>').button({
71 var button = $('<button/>').button({
72 icons : {primary : list[el].icon},
72 icons : {primary : list[el].icon},
73 text : false,
73 text : false,
74 label : list[el].label
74 label : list[el].label
75 });
75 });
76 var id = list[el].id;
76 var id = list[el].id;
77 if( id != undefined )
77 if( id != undefined )
78 button.attr('id',id);
78 button.attr('id',id);
79 var fun = list[el].callback;
79 var fun = list[el].callback;
80 button.click(fun);
80 button.click(fun);
81 span_group.append(button);
81 span_group.append(button);
82 }
82 }
83 span_group.buttonset();
83 span_group.buttonset();
84 $(this.selector).append(span_group);
84 $(this.selector).append(span_group);
85 };
85 };
86
86
87 ToolBar.prototype.style = function () {
87 ToolBar.prototype.style = function () {
88 this.element.addClass('border-box-sizing').
88 this.element.addClass('border-box-sizing').
89 addClass('ui-widget ui-widget-content toolbar').
89 addClass('toolbar').
90 css('border-top-style','none').
90 css('border-top-style','none').
91 css('border-left-style','none').
91 css('border-left-style','none').
92 css('border-right-style','none');
92 css('border-right-style','none');
93 };
93 };
94
94
95 /**
95 /**
96 * Show and hide toolbar
96 * Show and hide toolbar
97 * @method toggle
97 * @method toggle
98 */
98 */
99 ToolBar.prototype.toggle = function () {
99 ToolBar.prototype.toggle = function () {
100 this.element.toggle();
100 this.element.toggle();
101 if (IPython.layout_manager != undefined) {
101 if (IPython.layout_manager != undefined) {
102 IPython.layout_manager.do_resize();
102 IPython.layout_manager.do_resize();
103 }
103 }
104 };
104 };
105
105
106
106
107 IPython.ToolBar = ToolBar;
107 IPython.ToolBar = ToolBar;
108
108
109 return IPython;
109 return IPython;
110
110
111 }(IPython));
111 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now