-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathconstants.js
More file actions
60 lines (59 loc) · 2.06 KB
/
constants.js
File metadata and controls
60 lines (59 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Reusable constants.
*/
(function(define) {
'use strict';
define([], function() {
/**
* Reusable constants.
*
* ### keys - A mapping of key names to their corresponding identifiers.
* ### keyCodes - A mapping of key names to their corresponding keyCodes (DEPRECATED).
*
* - `constants.keys.tab` - the tab key
* - `constants.keys.enter` - the enter key
* - `constants.keys.esc` - the escape key
* - `constants.keys.space` - the space key
* - `constants.keys.left` - the left arrow key
* - `constants.keys.up` - the up arrow key
* - `constants.keys.right` - the right arrow key
* - `constants.keys.down` - the down arrow key
*
* @class constants
*/
return {
keys: {
tab: 'Tab',
enter: 'Enter',
esc: 'Escape',
space: 'Space',
left: 'ArrowLeft',
up: 'ArrowUp',
right: 'ArrowRight',
down: 'ArrowDown'
},
// NOTE: keyCode is deprecated. Use the `key` or `code` event property if possible.
// See: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
keyCodes: {
tab: 9,
enter: 13,
esc: 27,
space: 32,
left: 37,
up: 38,
right: 39,
down: 40
}
};
});
}).call(
this,
// Pick a define function as follows:
// 1. Use the default 'define' function if it is available
// 2. If not, use 'RequireJS.define' if that is available
// 3. else use the GlobalLoader to install the class into the edx namespace
// eslint-disable-next-line no-nested-ternary
typeof define === 'function' && define.amd ? define :
(typeof RequireJS !== 'undefined' ? RequireJS.define :
edx.GlobalLoader.defineAs('constants', 'edx-ui-toolkit/js/utils/constants'))
);