##// END OF EJS Templates
Merge pull request #5049 from ivanov/quickhelp-update...
Min RK -
r15891:90ee0375 merge
parent child Browse files
Show More
@@ -44,12 +44,12 b' IPython.keyboard = (function (IPython) {'
44 // These apply to Firefox and Opera
44 // These apply to Firefox and Opera
45 var _mozilla_keycodes = {
45 var _mozilla_keycodes = {
46 '; :': 59, '= +': 61, '- _': 173, 'meta': 224
46 '; :': 59, '= +': 61, '- _': 173, 'meta': 224
47 }
47 };
48
48
49 // This apply to Webkit and IE
49 // This apply to Webkit and IE
50 var _ie_keycodes = {
50 var _ie_keycodes = {
51 '; :': 186, '= +': 187, '- _': 189,
51 '; :': 186, '= +': 187, '- _': 189
52 }
52 };
53
53
54 var browser = IPython.utils.browser[0];
54 var browser = IPython.utils.browser[0];
55 var platform = IPython.utils.platform;
55 var platform = IPython.utils.platform;
@@ -65,45 +65,47 b' IPython.keyboard = (function (IPython) {'
65 for (var name in _keycodes) {
65 for (var name in _keycodes) {
66 var names = name.split(' ');
66 var names = name.split(' ');
67 if (names.length === 1) {
67 if (names.length === 1) {
68 var n = names[0]
68 var n = names[0];
69 keycodes[n] = _keycodes[n]
69 keycodes[n] = _keycodes[n];
70 inv_keycodes[_keycodes[n]] = n
70 inv_keycodes[_keycodes[n]] = n;
71 } else {
71 } else {
72 var primary = names[0];
72 var primary = names[0];
73 var secondary = names[1];
73 var secondary = names[1];
74 keycodes[primary] = _keycodes[name]
74 keycodes[primary] = _keycodes[name];
75 keycodes[secondary] = _keycodes[name]
75 keycodes[secondary] = _keycodes[name];
76 inv_keycodes[_keycodes[name]] = primary
76 inv_keycodes[_keycodes[name]] = primary;
77 }
77 }
78 }
78 }
79
79
80 var normalize_key = function (key) {
80 var normalize_key = function (key) {
81 return inv_keycodes[keycodes[key]];
81 return inv_keycodes[keycodes[key]];
82 }
82 };
83
83
84 var normalize_shortcut = function (shortcut) {
84 var normalize_shortcut = function (shortcut) {
85 // Put a shortcut into normalized form:
85 // Put a shortcut into normalized form:
86 // 1. Make lowercase
86 // 1. Make lowercase
87 // 2. Replace cmd by meta
87 // 2. Replace cmd by meta
88 // 3. Sort '+' separated modifiers into the order alt+ctrl+meta+shift
88 // 3. Sort '-' separated modifiers into the order alt-ctrl-meta-shift
89 // 4. Normalize keys
89 // 4. Normalize keys
90 shortcut = shortcut.toLowerCase().replace('cmd', 'meta');
90 shortcut = shortcut.toLowerCase().replace('cmd', 'meta');
91 var values = shortcut.split("+");
91 shortcut = shortcut.replace(/-$/, '_'); // catch shortcuts using '-' key
92 var values = shortcut.split("-");
92 if (values.length === 1) {
93 if (values.length === 1) {
93 return normalize_key(values[0])
94 return normalize_key(values[0]);
94 } else {
95 } else {
95 var modifiers = values.slice(0,-1);
96 var modifiers = values.slice(0,-1);
96 var key = normalize_key(values[values.length-1]);
97 var key = normalize_key(values[values.length-1]);
97 modifiers.sort();
98 modifiers.sort();
98 return modifiers.join('+') + '+' + key;
99 return modifiers.join('-') + '-' + key;
99 }
100 }
100 }
101 };
101
102
102 var shortcut_to_event = function (shortcut, type) {
103 var shortcut_to_event = function (shortcut, type) {
103 // Convert a shortcut (shift+r) to a jQuery Event object
104 // Convert a shortcut (shift-r) to a jQuery Event object
104 type = type || 'keydown';
105 type = type || 'keydown';
105 shortcut = normalize_shortcut(shortcut);
106 shortcut = normalize_shortcut(shortcut);
106 var values = shortcut.split("+");
107 shortcut = shortcut.replace(/-$/, '_'); // catch shortcuts using '-' key
108 var values = shortcut.split("-");
107 var modifiers = values.slice(0,-1);
109 var modifiers = values.slice(0,-1);
108 var key = values[values.length-1];
110 var key = values[values.length-1];
109 var opts = {which: keycodes[key]};
111 var opts = {which: keycodes[key]};
@@ -112,19 +114,19 b' IPython.keyboard = (function (IPython) {'
112 if (modifiers.indexOf('meta') !== -1) {opts.metaKey = true;}
114 if (modifiers.indexOf('meta') !== -1) {opts.metaKey = true;}
113 if (modifiers.indexOf('shift') !== -1) {opts.shiftKey = true;}
115 if (modifiers.indexOf('shift') !== -1) {opts.shiftKey = true;}
114 return $.Event(type, opts);
116 return $.Event(type, opts);
115 }
117 };
116
118
117 var event_to_shortcut = function (event) {
119 var event_to_shortcut = function (event) {
118 // Convert a jQuery Event object to a shortcut (shift+r)
120 // Convert a jQuery Event object to a shortcut (shift-r)
119 var shortcut = '';
121 var shortcut = '';
120 var key = inv_keycodes[event.which]
122 var key = inv_keycodes[event.which];
121 if (event.altKey && key !== 'alt') {shortcut += 'alt+';}
123 if (event.altKey && key !== 'alt') {shortcut += 'alt-';}
122 if (event.ctrlKey && key !== 'ctrl') {shortcut += 'ctrl+';}
124 if (event.ctrlKey && key !== 'ctrl') {shortcut += 'ctrl-';}
123 if (event.metaKey && key !== 'meta') {shortcut += 'meta+';}
125 if (event.metaKey && key !== 'meta') {shortcut += 'meta-';}
124 if (event.shiftKey && key !== 'shift') {shortcut += 'shift+';}
126 if (event.shiftKey && key !== 'shift') {shortcut += 'shift-';}
125 shortcut += key;
127 shortcut += key;
126 return shortcut
128 return shortcut;
127 }
129 };
128
130
129 var trigger_keydown = function (shortcut, element) {
131 var trigger_keydown = function (shortcut, element) {
130 // Trigger shortcut keydown on an element
132 // Trigger shortcut keydown on an element
@@ -132,17 +134,17 b' IPython.keyboard = (function (IPython) {'
132 element = $(element);
134 element = $(element);
133 var event = shortcut_to_event(shortcut, 'keydown');
135 var event = shortcut_to_event(shortcut, 'keydown');
134 element.trigger(event);
136 element.trigger(event);
135 }
137 };
136
138
137
139
138 // Shortcut manager class
140 // Shortcut manager class
139
141
140 var ShortcutManager = function (delay) {
142 var ShortcutManager = function (delay) {
141 this._shortcuts = {}
143 this._shortcuts = {};
142 this._counts = {}
144 this._counts = {};
143 this._timers = {}
145 this._timers = {};
144 this.delay = delay || 800; // delay in milliseconds
146 this.delay = delay || 800; // delay in milliseconds
145 }
147 };
146
148
147 ShortcutManager.prototype.help = function () {
149 ShortcutManager.prototype.help = function () {
148 var help = [];
150 var help = [];
@@ -168,15 +170,15 b' IPython.keyboard = (function (IPython) {'
168 return 0;
170 return 0;
169 });
171 });
170 return help;
172 return help;
171 }
173 };
172
174
173 ShortcutManager.prototype.clear_shortcuts = function () {
175 ShortcutManager.prototype.clear_shortcuts = function () {
174 this._shortcuts = {};
176 this._shortcuts = {};
175 }
177 };
176
178
177 ShortcutManager.prototype.add_shortcut = function (shortcut, data) {
179 ShortcutManager.prototype.add_shortcut = function (shortcut, data, suppress_help_update) {
178 if (typeof(data) === 'function') {
180 if (typeof(data) === 'function') {
179 data = {help: '', help_index: '', handler: data}
181 data = {help: '', help_index: '', handler: data};
180 }
182 }
181 data.help_index = data.help_index || '';
183 data.help_index = data.help_index || '';
182 data.help = data.help || '';
184 data.help = data.help || '';
@@ -187,19 +189,29 b' IPython.keyboard = (function (IPython) {'
187 shortcut = normalize_shortcut(shortcut);
189 shortcut = normalize_shortcut(shortcut);
188 this._counts[shortcut] = 0;
190 this._counts[shortcut] = 0;
189 this._shortcuts[shortcut] = data;
191 this._shortcuts[shortcut] = data;
190 }
192 if (!suppress_help_update) {
193 // update the keyboard shortcuts notebook help
194 $([IPython.events]).trigger('rebuild.QuickHelp');
195 }
196 };
191
197
192 ShortcutManager.prototype.add_shortcuts = function (data) {
198 ShortcutManager.prototype.add_shortcuts = function (data) {
193 for (var shortcut in data) {
199 for (var shortcut in data) {
194 this.add_shortcut(shortcut, data[shortcut]);
200 this.add_shortcut(shortcut, data[shortcut], true);
195 }
201 }
196 }
202 // update the keyboard shortcuts notebook help
203 $([IPython.events]).trigger('rebuild.QuickHelp');
204 };
197
205
198 ShortcutManager.prototype.remove_shortcut = function (shortcut) {
206 ShortcutManager.prototype.remove_shortcut = function (shortcut, suppress_help_update) {
199 shortcut = normalize_shortcut(shortcut);
207 shortcut = normalize_shortcut(shortcut);
200 delete this._counts[shortcut];
208 delete this._counts[shortcut];
201 delete this._shortcuts[shortcut];
209 delete this._shortcuts[shortcut];
202 }
210 if (!suppress_help_update) {
211 // update the keyboard shortcuts notebook help
212 $([IPython.events]).trigger('rebuild.QuickHelp');
213 }
214 };
203
215
204 ShortcutManager.prototype.count_handler = function (shortcut, event, data) {
216 ShortcutManager.prototype.count_handler = function (shortcut, event, data) {
205 var that = this;
217 var that = this;
@@ -219,7 +231,7 b' IPython.keyboard = (function (IPython) {'
219 t[shortcut] = timer;
231 t[shortcut] = timer;
220 }
232 }
221 return false;
233 return false;
222 }
234 };
223
235
224 ShortcutManager.prototype.call_handler = function (event) {
236 ShortcutManager.prototype.call_handler = function (event) {
225 var shortcut = event_to_shortcut(event);
237 var shortcut = event_to_shortcut(event);
@@ -235,7 +247,7 b' IPython.keyboard = (function (IPython) {'
235 }
247 }
236 }
248 }
237 return true;
249 return true;
238 }
250 };
239
251
240 ShortcutManager.prototype.handles = function (event) {
252 ShortcutManager.prototype.handles = function (event) {
241 var shortcut = event_to_shortcut(event);
253 var shortcut = event_to_shortcut(event);
@@ -252,6 +264,6 b' IPython.keyboard = (function (IPython) {'
252 shortcut_to_event : shortcut_to_event,
264 shortcut_to_event : shortcut_to_event,
253 event_to_shortcut : event_to_shortcut,
265 event_to_shortcut : event_to_shortcut,
254 trigger_keydown : trigger_keydown
266 trigger_keydown : trigger_keydown
255 }
267 };
256
268
257 }(IPython));
269 }(IPython));
@@ -5,5 +5,9 b''
5 @monoFontFamily: monospace; // to allow user to customize their fonts
5 @monoFontFamily: monospace; // to allow user to customize their fonts
6 @navbarHeight: 36px;
6 @navbarHeight: 36px;
7
7
8 code {
9 color: @black; // default code color in bootstrap is #d14 (crimson / amaranth)
10 }
11
8 // Our own global variables for all pages go here
12 // Our own global variables for all pages go here
9
13
@@ -26,7 +26,7 b' var IPython = (function (IPython) {'
26 return true;
26 return true;
27 }
27 }
28 },
28 },
29 'shift+enter' : {
29 'shift-enter' : {
30 help : 'run cell, select below',
30 help : 'run cell, select below',
31 help_index : 'ba',
31 help_index : 'ba',
32 handler : function (event) {
32 handler : function (event) {
@@ -34,7 +34,7 b' var IPython = (function (IPython) {'
34 return false;
34 return false;
35 }
35 }
36 },
36 },
37 'ctrl+enter' : {
37 'ctrl-enter' : {
38 help : 'run cell',
38 help : 'run cell',
39 help_index : 'bb',
39 help_index : 'bb',
40 handler : function (event) {
40 handler : function (event) {
@@ -42,7 +42,7 b' var IPython = (function (IPython) {'
42 return false;
42 return false;
43 }
43 }
44 },
44 },
45 'alt+enter' : {
45 'alt-enter' : {
46 help : 'run cell, insert below',
46 help : 'run cell, insert below',
47 help_index : 'bc',
47 help_index : 'bc',
48 handler : function (event) {
48 handler : function (event) {
@@ -53,7 +53,7 b' var IPython = (function (IPython) {'
53 };
53 };
54
54
55 if (platform === 'MacOS') {
55 if (platform === 'MacOS') {
56 default_common_shortcuts['cmd+s'] =
56 default_common_shortcuts['cmd-s'] =
57 {
57 {
58 help : 'save notebook',
58 help : 'save notebook',
59 help_index : 'fb',
59 help_index : 'fb',
@@ -64,7 +64,7 b' var IPython = (function (IPython) {'
64 }
64 }
65 };
65 };
66 } else {
66 } else {
67 default_common_shortcuts['ctrl+s'] =
67 default_common_shortcuts['ctrl-s'] =
68 {
68 {
69 help : 'save notebook',
69 help : 'save notebook',
70 help_index : 'fb',
70 help_index : 'fb',
@@ -87,7 +87,7 b' var IPython = (function (IPython) {'
87 return false;
87 return false;
88 }
88 }
89 },
89 },
90 'ctrl+m' : {
90 'ctrl-m' : {
91 help : 'command mode',
91 help : 'command mode',
92 help_index : 'ab',
92 help_index : 'ab',
93 handler : function (event) {
93 handler : function (event) {
@@ -141,7 +141,7 b' var IPython = (function (IPython) {'
141 }
141 }
142 }
142 }
143 },
143 },
144 'alt+-' : {
144 'alt--' : {
145 help : 'split cell',
145 help : 'split cell',
146 help_index : 'ea',
146 help_index : 'ea',
147 handler : function (event) {
147 handler : function (event) {
@@ -149,7 +149,7 b' var IPython = (function (IPython) {'
149 return false;
149 return false;
150 }
150 }
151 },
151 },
152 'alt+subtract' : {
152 'alt-subtract' : {
153 help : '',
153 help : '',
154 help_index : 'eb',
154 help_index : 'eb',
155 handler : function (event) {
155 handler : function (event) {
@@ -161,40 +161,40 b' var IPython = (function (IPython) {'
161 help : 'indent or complete',
161 help : 'indent or complete',
162 help_index : 'ec',
162 help_index : 'ec',
163 },
163 },
164 'shift+tab' : {
164 'shift-tab' : {
165 help : 'tooltip',
165 help : 'tooltip',
166 help_index : 'ed',
166 help_index : 'ed',
167 },
167 },
168 };
168 };
169
169
170 if (platform === 'MacOS') {
170 if (platform === 'MacOS') {
171 default_edit_shortcuts['cmd+/'] =
171 default_edit_shortcuts['cmd-/'] =
172 {
172 {
173 help : 'toggle comment',
173 help : 'toggle comment',
174 help_index : 'ee'
174 help_index : 'ee'
175 };
175 };
176 default_edit_shortcuts['cmd+]'] =
176 default_edit_shortcuts['cmd-]'] =
177 {
177 {
178 help : 'indent',
178 help : 'indent',
179 help_index : 'ef'
179 help_index : 'ef'
180 };
180 };
181 default_edit_shortcuts['cmd+['] =
181 default_edit_shortcuts['cmd-['] =
182 {
182 {
183 help : 'dedent',
183 help : 'dedent',
184 help_index : 'eg'
184 help_index : 'eg'
185 };
185 };
186 } else {
186 } else {
187 default_edit_shortcuts['ctrl+/'] =
187 default_edit_shortcuts['ctrl-/'] =
188 {
188 {
189 help : 'toggle comment',
189 help : 'toggle comment',
190 help_index : 'ee'
190 help_index : 'ee'
191 };
191 };
192 default_edit_shortcuts['ctrl+]'] =
192 default_edit_shortcuts['ctrl-]'] =
193 {
193 {
194 help : 'indent',
194 help : 'indent',
195 help_index : 'ef'
195 help_index : 'ef'
196 };
196 };
197 default_edit_shortcuts['ctrl+['] =
197 default_edit_shortcuts['ctrl-['] =
198 {
198 {
199 help : 'dedent',
199 help : 'dedent',
200 help_index : 'eg'
200 help_index : 'eg'
@@ -276,7 +276,7 b' var IPython = (function (IPython) {'
276 return false;
276 return false;
277 }
277 }
278 },
278 },
279 'shift+v' : {
279 'shift-v' : {
280 help : 'paste cell above',
280 help : 'paste cell above',
281 help_index : 'eg',
281 help_index : 'eg',
282 handler : function (event) {
282 handler : function (event) {
@@ -401,7 +401,7 b' var IPython = (function (IPython) {'
401 return false;
401 return false;
402 }
402 }
403 },
403 },
404 'shift+o' : {
404 'shift-o' : {
405 help : 'toggle output scrolling',
405 help : 'toggle output scrolling',
406 help_index : 'gc',
406 help_index : 'gc',
407 handler : function (event) {
407 handler : function (event) {
@@ -417,7 +417,7 b' var IPython = (function (IPython) {'
417 return false;
417 return false;
418 }
418 }
419 },
419 },
420 'ctrl+j' : {
420 'ctrl-j' : {
421 help : 'move cell down',
421 help : 'move cell down',
422 help_index : 'eb',
422 help_index : 'eb',
423 handler : function (event) {
423 handler : function (event) {
@@ -425,7 +425,7 b' var IPython = (function (IPython) {'
425 return false;
425 return false;
426 }
426 }
427 },
427 },
428 'ctrl+k' : {
428 'ctrl-k' : {
429 help : 'move cell up',
429 help : 'move cell up',
430 help_index : 'ea',
430 help_index : 'ea',
431 handler : function (event) {
431 handler : function (event) {
@@ -475,7 +475,7 b' var IPython = (function (IPython) {'
475 return false;
475 return false;
476 }
476 }
477 },
477 },
478 'shift+m' : {
478 'shift-m' : {
479 help : 'merge cell below',
479 help : 'merge cell below',
480 help_index : 'ek',
480 help_index : 'ek',
481 handler : function (event) {
481 handler : function (event) {
@@ -18,6 +18,11 b' var IPython = (function (IPython) {'
18 QuickHelp.prototype.show_keyboard_shortcuts = function () {
18 QuickHelp.prototype.show_keyboard_shortcuts = function () {
19 // toggles display of keyboard shortcut dialog
19 // toggles display of keyboard shortcut dialog
20 var that = this;
20 var that = this;
21 if ( this.force_rebuild ) {
22 this.shortcut_dialog.remove();
23 delete(this.shortcut_dialog);
24 this.force_rebuild = false;
25 }
21 if ( this.shortcut_dialog ){
26 if ( this.shortcut_dialog ){
22 // if dialog is already shown, close it
27 // if dialog is already shown, close it
23 $(this.shortcut_dialog).modal("toggle");
28 $(this.shortcut_dialog).modal("toggle");
@@ -38,7 +43,7 b' var IPython = (function (IPython) {'
38 'allows you to type code/text into a cell and is indicated by a green cell '+
43 'allows you to type code/text into a cell and is indicated by a green cell '+
39 'border. <b>Command mode</b> binds the keyboard to notebook level actions '+
44 'border. <b>Command mode</b> binds the keyboard to notebook level actions '+
40 'and is indicated by a grey cell border.'
45 'and is indicated by a grey cell border.'
41 )
46 );
42 element.append(doc);
47 element.append(doc);
43
48
44 // Command mode
49 // Command mode
@@ -57,73 +62,63 b' var IPython = (function (IPython) {'
57 Close : {}
62 Close : {}
58 }
63 }
59 });
64 });
65
66 $([IPython.events]).on('rebuild.QuickHelp', function() { that.force_rebuild = true;});
60 };
67 };
61
68
62 QuickHelp.prototype.build_command_help = function () {
69 QuickHelp.prototype.build_command_help = function () {
63 var command_shortcuts = IPython.keyboard_manager.command_shortcuts.help();
70 var command_shortcuts = IPython.keyboard_manager.command_shortcuts.help();
64 var help, shortcut;
71 return build_div('<h4>Command Mode (press <code>Esc</code> to enable)</h4>', command_shortcuts);
65 var i, half, n;
72 };
66
73
67 // Command mode
74 var special_case = { pageup: "PageUp", pagedown: "Page Down", 'minus': '-' };
68 var cmd_div = $('<div/>').append($('<h4>Command Mode (press <code>esc</code> to enable)</h4>'));
75 var prettify = function (s) {
69 var cmd_sub_div = $('<div/>').addClass('hbox');
76 s = s.replace(/-$/, 'minus'); // catch shortcuts using '-' key
70 var cmd_col1 = $('<div/>').addClass('box-flex0');
77 var keys = s.split('-');
71 var cmd_col2 = $('<div/>').addClass('box-flex0');
78 var k, i;
72 n = command_shortcuts.length;
79 for (i in keys) {
73 half = ~~(n/2); // Truncate :)
80 k = keys[i];
74 for (i=0; i<half; i++) {
81 if ( k.length == 1 ) {
75 help = command_shortcuts[i]['help'];
82 keys[i] = "<code><strong>" + k + "</strong></code>";
76 shortcut = command_shortcuts[i]['shortcut'];
83 continue; // leave individual keys lower-cased
77 cmd_col1.append($('<div>').addClass('quickhelp').
84 }
78 append($('<span/>').addClass('shortcut_key').text(shortcut)).
85 keys[i] = ( special_case[k] ? special_case[k] : k.charAt(0).toUpperCase() + k.slice(1) );
79 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
86 keys[i] = "<code><strong>" + keys[i] + "</strong></code>";
80 );
87 }
81 };
88 return keys.join('-');
82 for (i=half; i<n; i++) {
89
83 help = command_shortcuts[i]['help'];
90
84 shortcut = command_shortcuts[i]['shortcut'];
91 };
85 cmd_col2.append($('<div>').addClass('quickhelp').
86 append($('<span/>').addClass('shortcut_key').text(shortcut)).
87 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
88 );
89 };
90 cmd_sub_div.append(cmd_col1).append(cmd_col2);
91 cmd_div.append(cmd_sub_div);
92 return cmd_div;
93 }
94
92
95 QuickHelp.prototype.build_edit_help = function () {
93 QuickHelp.prototype.build_edit_help = function () {
96 var edit_shortcuts = IPython.keyboard_manager.edit_shortcuts.help();
94 var edit_shortcuts = IPython.keyboard_manager.edit_shortcuts.help();
97 var help, shortcut;
98 var i, half, n;
99
100 // Edit mode
95 // Edit mode
101 var edit_div = $('<div/>').append($('<h4>Edit Mode (press <code>enter</code> to enable)</h4>'));
96 return build_div('<h4>Edit Mode (press <code>Enter</code> to enable)</h4>', edit_shortcuts);
102 var edit_sub_div = $('<div/>').addClass('hbox');
97 };
103 var edit_col1 = $('<div/>').addClass('box-flex0');
98
104 var edit_col2 = $('<div/>').addClass('box-flex0');
99 var build_one = function (s) {
105 n = edit_shortcuts.length;
100 var help = s.help;
101 var shortcut = prettify(s.shortcut);
102 return $('<div>').addClass('quickhelp').
103 append($('<span/>').addClass('shortcut_key').append($(shortcut))).
104 append($('<span/>').addClass('shortcut_descr').text(' : ' + help));
105
106 };
107
108 var build_div = function (title, shortcuts) {
109 var i, half, n;
110 var div = $('<div/>').append($(title));
111 var sub_div = $('<div/>').addClass('hbox');
112 var col1 = $('<div/>').addClass('box-flex0');
113 var col2 = $('<div/>').addClass('box-flex0');
114 n = shortcuts.length;
106 half = ~~(n/2); // Truncate :)
115 half = ~~(n/2); // Truncate :)
107 for (i=0; i<half; i++) {
116 for (i=0; i<half; i++) { col1.append( build_one(shortcuts[i]) ); }
108 help = edit_shortcuts[i]['help'];
117 for (i=half; i<n; i++) { col2.append( build_one(shortcuts[i]) ); }
109 shortcut = edit_shortcuts[i]['shortcut'];
118 sub_div.append(col1).append(col2);
110 edit_col1.append($('<div>').addClass('quickhelp').
119 div.append(sub_div);
111 append($('<span/>').addClass('shortcut_key').text(shortcut)).
120 return div;
112 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
121 };
113 );
114 };
115 for (i=half; i<n; i++) {
116 help = edit_shortcuts[i]['help'];
117 shortcut = edit_shortcuts[i]['shortcut'];
118 edit_col2.append($('<div>').addClass('quickhelp').
119 append($('<span/>').addClass('shortcut_key').text(shortcut)).
120 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
121 );
122 };
123 edit_sub_div.append(edit_col1).append(edit_col2);
124 edit_div.append(edit_sub_div);
125 return edit_div;
126 }
127
122
128 // Set module variables
123 // Set module variables
129 IPython.QuickHelp = QuickHelp;
124 IPython.QuickHelp = QuickHelp;
@@ -56,7 +56,7 b' var tour_steps = ['
56 title: "Edit Mode",
56 title: "Edit Mode",
57 placement: 'bottom',
57 placement: 'bottom',
58 onShow: function(tour) { edit_mode(); },
58 onShow: function(tour) { edit_mode(); },
59 content: "Pressing <code>enter</code> or clicking in the input text area of the cell switches to Edit Mode."
59 content: "Pressing <code>Enter</code> or clicking in the input text area of the cell switches to Edit Mode."
60 }, {
60 }, {
61 element: '.selected',
61 element: '.selected',
62 title: "Edit Mode",
62 title: "Edit Mode",
@@ -68,7 +68,7 b' var tour_steps = ['
68 title: "Back to Command Mode",
68 title: "Back to Command Mode",
69 placement: 'bottom',
69 placement: 'bottom',
70 onShow: function(tour) { IPython.notebook.command_mode(); },
70 onShow: function(tour) { IPython.notebook.command_mode(); },
71 content: "Pressing <code>esc</code> or clicking outside of the input text area takes you back to Command Mode."
71 content: "Pressing <code>Esc</code> or clicking outside of the input text area takes you back to Command Mode."
72 }, {
72 }, {
73 element: '#keyboard_shortcuts',
73 element: '#keyboard_shortcuts',
74 title: "Keyboard Shortcuts",
74 title: "Keyboard Shortcuts",
@@ -1,6 +1,6 b''
1 .shortcut_key {
1 .shortcut_key {
2 display: inline-block;
2 display: inline-block;
3 width: 15ex;
3 width: 16ex;
4 text-align: right;
4 text-align: right;
5 font-family: @monoFontFamily;
5 font-family: @monoFontFamily;
6 }
6 }
@@ -2,6 +2,7 b''
2 .clearfix:after{clear:both}
2 .clearfix:after{clear:both}
3 .hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}
3 .hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}
4 .input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
4 .input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
5 code{color:#000}
5 .border-box-sizing{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}
6 .border-box-sizing{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}
6 .corner-all{border-radius:4px}
7 .corner-all{border-radius:4px}
7 .hbox{display:-webkit-box;-webkit-box-orient:horizontal;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:horizontal;-moz-box-align:stretch;display:box;box-orient:horizontal;box-align:stretch;display:flex;flex-direction:row;align-items:stretch}
8 .hbox{display:-webkit-box;-webkit-box-orient:horizontal;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:horizontal;-moz-box-align:stretch;display:box;box-orient:horizontal;box-align:stretch;display:flex;flex-direction:row;align-items:stretch}
@@ -1265,6 +1265,7 b' a .icon-rotate-90:before,a .icon-rotate-180:before,a .icon-rotate-270:before,a .'
1265 .icon-vk:before{content:"\f189"}
1265 .icon-vk:before{content:"\f189"}
1266 .icon-weibo:before{content:"\f18a"}
1266 .icon-weibo:before{content:"\f18a"}
1267 .icon-renren:before{content:"\f18b"}
1267 .icon-renren:before{content:"\f18b"}
1268 code{color:#000}
1268 .border-box-sizing{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}
1269 .border-box-sizing{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}
1269 .corner-all{border-radius:4px}
1270 .corner-all{border-radius:4px}
1270 .hbox{display:-webkit-box;-webkit-box-orient:horizontal;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:horizontal;-moz-box-align:stretch;display:box;box-orient:horizontal;box-align:stretch;display:flex;flex-direction:row;align-items:stretch}
1271 .hbox{display:-webkit-box;-webkit-box-orient:horizontal;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:horizontal;-moz-box-align:stretch;display:box;box-orient:horizontal;box-align:stretch;display:flex;flex-direction:row;align-items:stretch}
@@ -1514,7 +1515,7 b' ul#help_menu li a{overflow:hidden;padding-right:2.2em}ul#help_menu li a i{margin'
1514 div#pager_splitter{height:8px}
1515 div#pager_splitter{height:8px}
1515 #pager-container{position:relative;padding:15px 0}
1516 #pager-container{position:relative;padding:15px 0}
1516 div#pager{font-size:14px;line-height:20px;overflow:auto;display:none}div#pager pre{font-size:13px;line-height:1.21429em;color:#000;background-color:#f7f7f7;padding:.4em}
1517 div#pager{font-size:14px;line-height:20px;overflow:auto;display:none}div#pager pre{font-size:13px;line-height:1.21429em;color:#000;background-color:#f7f7f7;padding:.4em}
1517 .shortcut_key{display:inline-block;width:15ex;text-align:right;font-family:monospace}
1518 .shortcut_key{display:inline-block;width:16ex;text-align:right;font-family:monospace}
1518 .shortcut_descr{display:inline-block}
1519 .shortcut_descr{display:inline-block}
1519 span#save_widget{padding:0 5px;margin-top:12px}
1520 span#save_widget{padding:0 5px;margin-top:12px}
1520 span#checkpoint_status,span#autosave_status{font-size:small}
1521 span#checkpoint_status,span#autosave_status{font-size:small}
@@ -1,13 +1,13 b''
1
1
2
2
3 var normalized_shortcuts = [
3 var normalized_shortcuts = [
4 'ctrl+shift+m',
4 'ctrl-shift-m',
5 'alt+meta+p',
5 'alt-meta-p',
6 ];
6 ];
7
7
8 var to_normalize = [
8 var to_normalize = [
9 ['shift+%', 'shift+5'],
9 ['shift-%', 'shift-5'],
10 ['ShiFT+MeTa+CtRl+AlT+m', 'alt+ctrl+meta+shift+m'],
10 ['ShiFT-MeTa-CtRl-AlT-m', 'alt-ctrl-meta-shift-m'],
11 ];
11 ];
12
12
13 var unshifted = "` 1 2 3 4 5 6 7 8 9 0 - = q w e r t y u i o p [ ] \\ a s d f g h j k l ; ' z x c v b n m , . /";
13 var unshifted = "` 1 2 3 4 5 6 7 8 9 0 - = q w e r t y u i o p [ ] \\ a s d f g h j k l ; ' z x c v b n m , . /";
@@ -33,7 +33,7 b' casper.notebook_test(function () {'
33 }, item);
33 }, item);
34 this.test.assertEquals(result, item[1], 'Normalize shortcut: '+item[0]);
34 this.test.assertEquals(result, item[1], 'Normalize shortcut: '+item[0]);
35 });
35 });
36 })
36 });
37
37
38 this.then(function () {
38 this.then(function () {
39 this.each(normalized_shortcuts, function (self, item) {
39 this.each(normalized_shortcuts, function (self, item) {
@@ -46,4 +46,4 b' casper.notebook_test(function () {'
46 });
46 });
47 });
47 });
48
48
49 }); No newline at end of file
49 });
@@ -22,7 +22,7 b' casper.notebook_test(function () {'
22 var cell = IPython.notebook.get_cell(0);
22 var cell = IPython.notebook.get_cell(0);
23 cell.set_text('a=11; print(a)');
23 cell.set_text('a=11; print(a)');
24 cell.clear_output();
24 cell.clear_output();
25 IPython.keyboard.trigger_keydown('shift+enter');
25 IPython.keyboard.trigger_keydown('shift-enter');
26 });
26 });
27
27
28 this.wait_for_output(0);
28 this.wait_for_output(0);
@@ -41,7 +41,7 b' casper.notebook_test(function () {'
41 var cell = IPython.notebook.get_cell(0);
41 var cell = IPython.notebook.get_cell(0);
42 cell.set_text('a=12; print(a)');
42 cell.set_text('a=12; print(a)');
43 cell.clear_output();
43 cell.clear_output();
44 IPython.keyboard.trigger_keydown('ctrl+enter');
44 IPython.keyboard.trigger_keydown('ctrl-enter');
45 });
45 });
46
46
47 this.wait_for_output(0);
47 this.wait_for_output(0);
General Comments 0
You need to be logged in to leave comments. Login now