##// END OF EJS Templates
Merge pull request #884 from fperez/nb-usability...
Fernando Perez -
r5075:4cc4dc87 merge
parent child Browse files
Show More
@@ -0,0 +1,39 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-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 // QuickHelp button
10 //============================================================================
11
12 var IPython = (function (IPython) {
13
14 var QuickHelp = function (selector) {
15 this.selector = selector;
16 if (this.selector !== undefined) {
17 this.element = $(selector);
18 this.style();
19 this.bind_events();
20 }
21 };
22
23 QuickHelp.prototype.style = function () {
24 this.element.find('button#quick_help').button();
25 };
26
27 QuickHelp.prototype.bind_events = function () {
28 var that = this;
29 this.element.find("button#quick_help").click(function () {
30 IPython.notebook.toggle_keyboard_shortcuts();
31 });
32 };
33
34 // Set module variables
35 IPython.QuickHelp = QuickHelp;
36
37 return IPython;
38
39 }(IPython));
@@ -1,7 +1,7 b''
1
1
2
2
3 .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
3 .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
4 .cm-s-ipython span.cm-number {color: #666666;}
4 .cm-s-ipython span.cm-number {color: #0A32C8;}
5 .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
5 .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
6 .cm-s-ipython span.cm-meta {color: #AA22FF;}
6 .cm-s-ipython span.cm-meta {color: #AA22FF;}
7 .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
7 .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
@@ -22,7 +22,7 b' div#header {'
22 /* Initially hidden to prevent FLOUC */
22 /* Initially hidden to prevent FLOUC */
23 display: none;
23 display: none;
24 position: relative;
24 position: relative;
25 height: 45px;
25 height: 40px;
26 padding: 5px;
26 padding: 5px;
27 margin: 0px;
27 margin: 0px;
28 width: 100%;
28 width: 100%;
@@ -35,7 +35,7 b' span#ipython_notebook {'
35
35
36 span#ipython_notebook h1 {
36 span#ipython_notebook h1 {
37 font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
37 font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 font-size: 197%;
38 font-size: 150%;
39 display: inline;
39 display: inline;
40 color: black;
40 color: black;
41 }
41 }
@@ -1,4 +1,3 b''
1
2 /**
1 /**
3 * Primary styles
2 * Primary styles
4 *
3 *
@@ -19,12 +18,18 b' body {'
19 }
18 }
20
19
21 span#save_widget {
20 span#save_widget {
22 position: absolute;
21 position: static;
23 left: 0px;
22 left: 0px;
24 padding: 5px 0px;
23 padding: 5px 0px;
25 margin: 0px 0px 0px 0px;
24 margin: 0px 0px 0px 0px;
26 }
25 }
27
26
27 span#quick_help_area {
28 position: static;
29 padding: 5px 0px;
30 margin: 0px 0px 0px 0px;
31 }
32
28 input#notebook_name {
33 input#notebook_name {
29 height: 1em;
34 height: 1em;
30 line-height: 1em;
35 line-height: 1em;
@@ -35,9 +40,10 b' span#kernel_status {'
35 position: absolute;
40 position: absolute;
36 padding: 8px 5px 5px 5px;
41 padding: 8px 5px 5px 5px;
37 right: 10px;
42 right: 10px;
38 font-weight: bold;
43 font-weight: bold;
39 }
44 }
40
45
46
41 .status_idle {
47 .status_idle {
42 color: gray;
48 color: gray;
43 }
49 }
@@ -156,7 +162,7 b' div#notebook {'
156 overflow-x: auto;
162 overflow-x: auto;
157 width: 100%;
163 width: 100%;
158 /* This spaces the cell away from the edge of the notebook area */
164 /* This spaces the cell away from the edge of the notebook area */
159 padding: 15px 15px 15px 15px;
165 padding: 5px 5px 15px 5px;
160 margin: 0px
166 margin: 0px
161 background-color: white;
167 background-color: white;
162 }
168 }
@@ -172,9 +178,9 b' div#pager {'
172
178
173 div.cell {
179 div.cell {
174 width: 100%;
180 width: 100%;
175 padding: 5px;
181 padding: 5px 5px 5px 0px;
176 /* This acts as a spacer between cells, that is outside the border */
182 /* This acts as a spacer between cells, that is outside the border */
177 margin: 5px 0px 5px 0px;
183 margin: 2px 0px 2px 0px;
178 }
184 }
179
185
180 div.code_cell {
186 div.code_cell {
@@ -200,7 +206,7 b' div.input_area {'
200 color: black;
206 color: black;
201 border: 1px solid #ddd;
207 border: 1px solid #ddd;
202 border-radius: 3px;
208 border-radius: 3px;
203 background: #fafafa;
209 background: #f7f7f7;
204 }
210 }
205
211
206 div.input_prompt {
212 div.input_prompt {
@@ -330,9 +336,10 b' div.text_cell_render {'
330
336
331 .shortcut_key {
337 .shortcut_key {
332 display: inline-block;
338 display: inline-block;
333 width: 10ex;
339 width: 13ex;
334 text-align: right;
340 text-align: right;
341 font-family: monospace;
335 }
342 }
336
343
337 .shortcut_descr {
344 .shortcut_descr {
338 } No newline at end of file
345 }
@@ -48,9 +48,10 b' var IPython = (function (IPython) {'
48
48
49
49
50 CodeCell.prototype.handle_codemirror_keyevent = function (editor, event) {
50 CodeCell.prototype.handle_codemirror_keyevent = function (editor, event) {
51 // This method gets called in CodeMirror's onKeyDown/onKeyPress handlers and
51 // This method gets called in CodeMirror's onKeyDown/onKeyPress
52 // is used to provide custom key handling. Its return value is used to determine
52 // handlers and is used to provide custom key handling. Its return
53 // if CodeMirror should ignore the event: true = ignore, false = don't ignore.
53 // value is used to determine if CodeMirror should ignore the event:
54 // true = ignore, false = don't ignore.
54 if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
55 if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
55 // Always ignore shift-enter in CodeMirror as we handle it.
56 // Always ignore shift-enter in CodeMirror as we handle it.
56 return true;
57 return true;
@@ -59,8 +60,8 b' var IPython = (function (IPython) {'
59 var cur = editor.getCursor();
60 var cur = editor.getCursor();
60 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim();
61 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim();
61 if (pre_cursor === "") {
62 if (pre_cursor === "") {
62 // Don't autocomplete if the part of the line before the cursor is empty.
63 // Don't autocomplete if the part of the line before the cursor
63 // In this case, let CodeMirror handle indentation.
64 // is empty. In this case, let CodeMirror handle indentation.
64 return false;
65 return false;
65 } else {
66 } else {
66 // Autocomplete the current line.
67 // Autocomplete the current line.
@@ -86,9 +87,14 b' var IPython = (function (IPython) {'
86 } else {
87 } else {
87 return false;
88 return false;
88 };
89 };
89 } else {
90 } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey
90 // keypress/keyup also trigger on TAB press, and we don't want to use those
91 && event.type == 'keydown') {
91 // to disable tab completion.
92 // toggle line numbers with Ctrl-Shift-L
93 this.toggle_line_numbers();
94 }
95 else {
96 // keypress/keyup also trigger on TAB press, and we don't want to
97 // use those to disable tab completion.
92 if (this.is_completing && event.keyCode !== 9) {
98 if (this.is_completing && event.keyCode !== 9) {
93 var ed_cur = editor.getCursor();
99 var ed_cur = editor.getCursor();
94 var cc_cur = this.completion_cursor;
100 var cc_cur = this.completion_cursor;
@@ -177,6 +183,14 b' var IPython = (function (IPython) {'
177 select.focus();
183 select.focus();
178 };
184 };
179
185
186 CodeCell.prototype.toggle_line_numbers = function () {
187 if (this.code_mirror.getOption('lineNumbers') == false) {
188 this.code_mirror.setOption('lineNumbers', true);
189 } else {
190 this.code_mirror.setOption('lineNumbers', false);
191 }
192 this.code_mirror.refresh()
193 };
180
194
181 CodeCell.prototype.select = function () {
195 CodeCell.prototype.select = function () {
182 IPython.Cell.prototype.select.apply(this);
196 IPython.Cell.prototype.select.apply(this);
@@ -470,4 +484,3 b' var IPython = (function (IPython) {'
470
484
471 return IPython;
485 return IPython;
472 }(IPython));
486 }(IPython));
473
@@ -130,9 +130,24 b' var IPython = (function (IPython) {'
130 that.select_next();
130 that.select_next();
131 that.control_key_active = false;
131 that.control_key_active = false;
132 return false;
132 return false;
133 } else if (event.which === 76 && that.control_key_active) {
134 // Toggle line numbers = l
135 that.cell_toggle_line_numbers();
136 that.control_key_active = false;
137 return false;
138 } else if (event.which === 73 && that.control_key_active) {
139 // Interrupt kernel = i
140 IPython.notebook.kernel.interrupt();
141 that.control_key_active = false;
142 return false;
143 } else if (event.which === 190 && that.control_key_active) {
144 // Restart kernel = . # matches qt console
145 IPython.notebook.restart_kernel();
146 that.control_key_active = false;
147 return false;
133 } else if (event.which === 72 && that.control_key_active) {
148 } else if (event.which === 72 && that.control_key_active) {
134 // Show keyboard shortcuts = h
149 // Show keyboard shortcuts = h
135 that.show_keyboard_shortcuts();
150 that.toggle_keyboard_shortcuts();
136 that.control_key_active = false;
151 that.control_key_active = false;
137 return false;
152 return false;
138 } else if (that.control_key_active) {
153 } else if (that.control_key_active) {
@@ -181,15 +196,25 b' var IPython = (function (IPython) {'
181 };
196 };
182
197
183
198
184 Notebook.prototype.show_keyboard_shortcuts = function () {
199 Notebook.prototype.toggle_keyboard_shortcuts = function () {
200 // toggles display of keyboard shortcut dialog
201 var that = this;
202 if ( this.shortcut_dialog ){
203 // if dialog is already shown, close it
204 this.shortcut_dialog.dialog("close");
205 this.shortcut_dialog = null;
206 return;
207 }
185 var dialog = $('<div/>');
208 var dialog = $('<div/>');
209 this.shortcut_dialog = dialog;
186 var shortcuts = [
210 var shortcuts = [
187 {key: 'Shift-Enter', help: 'run cell'},
211 {key: 'Shift-Enter', help: 'run cell'},
188 {key: 'Ctrl-Enter', help: 'run cell in terminal mode'},
212 {key: 'Ctrl-Enter', help: 'run cell in-place'},
189 {key: 'Ctrl-m d', help: 'delete cell'},
213 {key: 'Ctrl-m d', help: 'delete cell'},
190 {key: 'Ctrl-m a', help: 'insert cell above'},
214 {key: 'Ctrl-m a', help: 'insert cell above'},
191 {key: 'Ctrl-m b', help: 'insert cell below'},
215 {key: 'Ctrl-m b', help: 'insert cell below'},
192 {key: 'Ctrl-m t', help: 'toggle output'},
216 {key: 'Ctrl-m t', help: 'toggle output'},
217 {key: 'Ctrl-m l', help: 'toggle line numbers'},
193 {key: 'Ctrl-m s', help: 'save notebook'},
218 {key: 'Ctrl-m s', help: 'save notebook'},
194 {key: 'Ctrl-m j', help: 'move cell down'},
219 {key: 'Ctrl-m j', help: 'move cell down'},
195 {key: 'Ctrl-m k', help: 'move cell up'},
220 {key: 'Ctrl-m k', help: 'move cell up'},
@@ -197,7 +222,9 b' var IPython = (function (IPython) {'
197 {key: 'Ctrl-m m', help: 'markdown cell'},
222 {key: 'Ctrl-m m', help: 'markdown cell'},
198 {key: 'Ctrl-m p', help: 'select previous'},
223 {key: 'Ctrl-m p', help: 'select previous'},
199 {key: 'Ctrl-m n', help: 'select next'},
224 {key: 'Ctrl-m n', help: 'select next'},
200 {key: 'Ctrl-m h', help: 'display keyboard shortcuts'}
225 {key: 'Ctrl-m i', help: 'interrupt kernel'},
226 {key: 'Ctrl-m .', help: 'restart kernel'},
227 {key: 'Ctrl-m h', help: 'show keyboard shortcuts'}
201 ];
228 ];
202 for (var i=0; i<shortcuts.length; i++) {
229 for (var i=0; i<shortcuts.length; i++) {
203 dialog.append($('<div>').
230 dialog.append($('<div>').
@@ -205,6 +232,10 b' var IPython = (function (IPython) {'
205 append($('<span/>').addClass('shortcut_descr').html(' : ' + shortcuts[i].help))
232 append($('<span/>').addClass('shortcut_descr').html(' : ' + shortcuts[i].help))
206 );
233 );
207 };
234 };
235 dialog.bind('dialogclose', function(event) {
236 // dialog has been closed, allow it to be drawn again.
237 that.shortcut_dialog = null;
238 });
208 dialog.dialog({title: 'Keyboard shortcuts'});
239 dialog.dialog({title: 'Keyboard shortcuts'});
209 };
240 };
210
241
@@ -602,6 +633,11 b' var IPython = (function (IPython) {'
602 this.dirty = true;
633 this.dirty = true;
603 };
634 };
604
635
636 // Other cell functions: line numbers, ...
637
638 Notebook.prototype.cell_toggle_line_numbers = function() {
639 this.selected_cell().toggle_line_numbers()
640 };
605
641
606 // Kernel related things
642 // Kernel related things
607
643
@@ -613,8 +649,26 b' var IPython = (function (IPython) {'
613
649
614
650
615 Notebook.prototype.restart_kernel = function () {
651 Notebook.prototype.restart_kernel = function () {
652 var that = this;
616 var notebook_id = IPython.save_widget.get_notebook_id();
653 var notebook_id = IPython.save_widget.get_notebook_id();
617 this.kernel.restart($.proxy(this.kernel_started, this));
654
655 var dialog = $('<div/>');
656 dialog.html('Do you want to restart the current kernel? You will lose all variables defined in it.');
657 $(document).append(dialog);
658 dialog.dialog({
659 resizable: false,
660 modal: true,
661 title: "Restart kernel or continue running?",
662 buttons : {
663 "Restart": function () {
664 that.kernel.restart($.proxy(that.kernel_started, that));
665 $(this).dialog('close');
666 },
667 "Continue running": function () {
668 $(this).dialog('close');
669 }
670 }
671 });
618 };
672 };
619
673
620
674
@@ -694,11 +748,11 b' var IPython = (function (IPython) {'
694 modal: true,
748 modal: true,
695 title: "Dead kernel",
749 title: "Dead kernel",
696 buttons : {
750 buttons : {
697 "Yes": function () {
751 "Restart": function () {
698 that.start_kernel();
752 that.start_kernel();
699 $(this).dialog('close');
753 $(this).dialog('close');
700 },
754 },
701 "No": function () {
755 "Continue running": function () {
702 $(this).dialog('close');
756 $(this).dialog('close');
703 }
757 }
704 }
758 }
@@ -32,6 +32,7 b' $(document).ready(function () {'
32 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
32 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
33 IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter');
33 IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter');
34 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
34 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
35 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
35 IPython.print_widget = new IPython.PrintWidget('span#print_widget');
36 IPython.print_widget = new IPython.PrintWidget('span#print_widget');
36 IPython.notebook = new IPython.Notebook('div#notebook');
37 IPython.notebook = new IPython.Notebook('div#notebook');
37 IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status');
38 IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status');
@@ -56,13 +56,16 b''
56 <span id="notebook_id" style="display:none">{{notebook_id}}</span>
56 <span id="notebook_id" style="display:none">{{notebook_id}}</span>
57 <button id="save_notebook"><u>S</u>ave</button>
57 <button id="save_notebook"><u>S</u>ave</button>
58 </span>
58 </span>
59 <span id="quick_help_area">
60 <button id="quick_help">Quick<u>H</u>elp</button>
61 </span>
59 <span id="kernel_status">Idle</span>
62 <span id="kernel_status">Idle</span>
60 </div>
63 </div>
61
64
62 <div id="MathJaxFetchingWarning"
65 <div id="MathJaxFetchingWarning"
63 style="width:80%; margin:auto;padding-top:20%;text-align: justify; display:none">
66 style="width:80%; margin:auto;padding-top:20%;text-align: justify; display:none">
64 <p style="font-size:26px;">There was an issue trying to fetch MathJax.js
67 <p style="font-size:26px;">There was an issue trying to fetch MathJax.js
65 from the internet.</p>
68 from the internet.</p>
66
69
67 <p style="padding:0.2em"> With a working internet connection, you can run
70 <p style="padding:0.2em"> With a working internet connection, you can run
68 the following at a Python or IPython prompt, which will install a local
71 the following at a Python or IPython prompt, which will install a local
@@ -176,7 +179,7 b''
176 <div class="section_content">
179 <div class="section_content">
177 <div class="section_row">
180 <div class="section_row">
178 <span id="int_restart" class="section_row_buttons">
181 <span id="int_restart" class="section_row_buttons">
179 <button id="int_kernel">Interrupt</button>
182 <button id="int_kernel"><u>I</u>nterrupt</button>
180 <button id="restart_kernel">Restart</button>
183 <button id="restart_kernel">Restart</button>
181 </span>
184 </span>
182 <span class="section_row_header">Actions</span>
185 <span class="section_row_header">Actions</span>
@@ -217,7 +220,7 b''
217 <span class="help_string_label">Shift-Enter :</span>
220 <span class="help_string_label">Shift-Enter :</span>
218 </div>
221 </div>
219 <div class="section_row">
222 <div class="section_row">
220 <span class="help_string">run in terminal mode</span>
223 <span class="help_string">run selected cell in-place</span>
221 <span class="help_string_label">Ctrl-Enter :</span>
224 <span class="help_string_label">Ctrl-Enter :</span>
222 </div>
225 </div>
223 <div class="section_row">
226 <div class="section_row">
@@ -263,6 +266,7 b''
263 <script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script>
266 <script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script>
264 <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script>
267 <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script>
265 <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script>
268 <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script>
269 <script src="static/js/quickhelp.js" type="text/javascript" charset="utf-8"></script>
266 <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script>
270 <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script>
267 <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script>
271 <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script>
268 <script src="static/js/printwidget.js" type="text/javascript" charset="utf-8"></script>
272 <script src="static/js/printwidget.js" type="text/javascript" charset="utf-8"></script>
@@ -274,5 +278,3 b''
274 </body>
278 </body>
275
279
276 </html>
280 </html>
277
278
General Comments 0
You need to be logged in to leave comments. Login now