Show More
@@ -65,59 +65,66 define([ | |||
|
65 | 65 | { shortcut: cmd_ctrl + "Shift-z", help:"redo" }, |
|
66 | 66 | { shortcut: cmd_ctrl + "y", help:"redo" }, |
|
67 | 67 | ].concat( platform_specific ); |
|
68 | ||
|
69 | var mac_humanize_map = { | |
|
70 | // all these are unicode, will probably display badly on anything except macs. | |
|
71 | // these are the standard symbol that are used in MacOS native menus | |
|
72 | 'cmd':'⌘', | |
|
73 | 'shift':'⇧', | |
|
74 | 'alt':'⌥', | |
|
75 | 'up':'↑', | |
|
76 | 'down':'↓', | |
|
77 | 'left':'←', | |
|
78 | 'right':'→', | |
|
79 | 'eject':'⏏', | |
|
80 | 'tab':'⇥', | |
|
81 | 'capslock':'⇧', | |
|
82 | 'esc':'⎋', | |
|
83 | 'ctrl':'⌃', | |
|
84 | 'enter':'↩', | |
|
85 | 'pageup':'⇞', | |
|
86 | 'pagedown':'⇟', | |
|
87 | 'home':'↖', | |
|
88 | 'end':'↘', | |
|
89 | 'altenter':'⌤', | |
|
90 | 'space':'␣', | |
|
91 | 'backspace':'⇤', | |
|
92 | 'apple':'', | |
|
93 | }; | |
|
94 | ||
|
95 | var default_humanize_map = { | |
|
96 | 'shift':'Shift', | |
|
97 | 'alt':'Alt', | |
|
98 | 'up':'Up', | |
|
99 | 'down':'Down', | |
|
100 | 'left':'Left', | |
|
101 | 'right':'Right', | |
|
102 | 'tab':'Tab', | |
|
103 | 'capslock':'Caps Lock', | |
|
104 | 'esc':'Esc', | |
|
105 | 'ctrl':'Ctrl', | |
|
106 | 'enter':'Enter', | |
|
107 | 'pageup':'Page Up', | |
|
108 | 'pagedown':'Page Down', | |
|
109 | 'home':'Home', | |
|
110 | 'end':'End', | |
|
111 | 'space':'Space', | |
|
112 | 'backspace,':'Backaspace', | |
|
113 | }; | |
|
114 | ||
|
115 | var humanize_map; | |
|
116 | ||
|
117 | if (platform === 'MacOS'){ | |
|
118 | humanize_map = mac_humanize_map; | |
|
119 | } else { | |
|
120 | humanize_map = default_humanize_map; | |
|
121 | } | |
|
68 | 122 | |
|
69 | 123 | function humanize_key(key){ |
|
70 | if (platform === 'MacOS'){ | |
|
71 | 124 | if (key.length === 1){ |
|
72 | 125 | key = key.toUpperCase(); |
|
73 | 126 | } |
|
74 | var d= { | |
|
75 | // all these are unicode, will probably display badly on anything except macs. | |
|
76 | // these are the standard symbol that are used in MacOS native menus | |
|
77 | 'cmd':'⌘', | |
|
78 | 'shift':'⇧', | |
|
79 | 'alt':'⌥', | |
|
80 | 'up':'↑', | |
|
81 | 'down':'↓', | |
|
82 | 'left':'←', | |
|
83 | 'right':'→', | |
|
84 | 'eject':'⏏', | |
|
85 | 'tab':'⇥', | |
|
86 | 'capslock':'⇧', | |
|
87 | 'esc':'⎋', | |
|
88 | 'ctrl':'⌃', | |
|
89 | 'enter':'↩', | |
|
90 | 'pageup':'⇞', | |
|
91 | 'pagedown':'⇟', | |
|
92 | 'home':'↖', | |
|
93 | 'end':'↘', | |
|
94 | 'altenter':'⌤', | |
|
95 | 'space':'␣', | |
|
96 | 'backspace':'⇤', | |
|
97 | 'apple':'', | |
|
98 | }; | |
|
99 | } else { | |
|
100 | var d = { | |
|
101 | 'shift':'Shift', | |
|
102 | 'alt':'Alt', | |
|
103 | 'up':'Up', | |
|
104 | 'down':'Down', | |
|
105 | 'left':'Left', | |
|
106 | 'right':'Right', | |
|
107 | 'tab':'Tab', | |
|
108 | 'capslock':'Caps Lock', | |
|
109 | 'esc':'Esc', | |
|
110 | 'ctrl':'Ctrl', | |
|
111 | 'enter':'Enter', | |
|
112 | 'pageup':'Page Up', | |
|
113 | 'pagedown':'Page Down', | |
|
114 | 'home':'Home', | |
|
115 | 'end':'End', | |
|
116 | 'space':'Space', | |
|
117 | 'backspace,':'Backaspace', | |
|
118 | }; | |
|
119 | } | |
|
120 | return d[key.toLowerCase()]||key; | |
|
127 | return humanize_map[key.toLowerCase()]||key; | |
|
121 | 128 | } |
|
122 | 129 | |
|
123 | 130 | function humanize_sequence(sequence){ |
@@ -3,7 +3,7 | |||
|
3 | 3 | |
|
4 | 4 | define([ |
|
5 | 5 | 'base/js/namespace', |
|
6 |
'jquery' |
|
|
6 | 'jquery' | |
|
7 | 7 | ], function(IPython, $) { |
|
8 | 8 | "use strict"; |
|
9 | 9 | |
@@ -92,12 +92,13 define([ | |||
|
92 | 92 | // get rid of legacy code that handle things that are not actions. |
|
93 | 93 | ToolBar.prototype.add_buttons_group = function (list, group_id) { |
|
94 | 94 | // handle custom call of pseudoaction binding. |
|
95 | if(typeof(list) == 'string' && list.slice(0,1) == '<' && list.slice(-1) == '>'){ | |
|
95 | if(typeof(list) === 'string' && list.slice(0,1) === '<' && list.slice(-1) === '>'){ | |
|
96 | var _pseudo_action; | |
|
96 | 97 | try{ |
|
97 |
|
|
|
98 |
|
|
|
98 | _pseudo_action = list.slice(1,-1); | |
|
99 | this[_pseudo_action](); | |
|
99 | 100 | } catch (e) { |
|
100 | console.warn('ouch, calling ', _n, 'does not seem to work...:') | |
|
101 | console.warn('ouch, calling ', _pseudo_action, 'does not seem to work...:'); | |
|
101 | 102 | } |
|
102 | 103 | return ; |
|
103 | 104 | } |
@@ -109,7 +110,7 define([ | |||
|
109 | 110 | var el; |
|
110 | 111 | for(var i=0; i < list.length; i++) { |
|
111 | 112 | |
|
112 |
// IIFE because |
|
|
113 | // IIFE because javascript don't have loop scope so | |
|
113 | 114 | // action_name would otherwise be the same on all iteration |
|
114 | 115 | // of the loop |
|
115 | 116 | // TODO: Indent this thing once reviewed: |
General Comments 0
You need to be logged in to leave comments.
Login now