@atlassian/aui 11.0.0-m009 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aui/aui-prototyping-browserfocus.css +1 -1
- package/dist/aui/aui-prototyping-browserfocus.css.map +1 -1
- package/dist/aui/aui-prototyping-design-tokens-api-full.js +3 -3
- package/dist/aui/aui-prototyping-design-tokens-api-full.js.map +1 -1
- package/dist/aui/aui-prototyping-design-tokens-api.js +1 -1
- package/dist/aui/aui-prototyping-design-tokens-api.js.map +1 -1
- package/dist/aui/aui-prototyping.css +9 -9
- package/dist/aui/aui-prototyping.css.map +1 -1
- package/dist/aui/aui-prototyping.js +15 -15
- package/dist/aui/aui-prototyping.js.map +1 -1
- package/dist/aui/aui-prototyping.nodeps.css +9 -9
- package/dist/aui/aui-prototyping.nodeps.css.map +1 -1
- package/dist/aui/aui-prototyping.nodeps.js +15 -15
- package/dist/aui/aui-prototyping.nodeps.js.map +1 -1
- package/dist/aui/fonts/adgs-icons.eot +0 -0
- package/dist/aui/fonts/adgs-icons.ttf +0 -0
- package/dist/aui/fonts/adgs-icons.woff +0 -0
- package/dist/aui/images/adgs-icons.svg +7 -7
- package/entry/aui.batch.prototyping.js +1 -3
- package/package.json +7 -7
- package/src/js/aui/internal/i18n/aui.js +0 -3
- package/src/less/aui-badge.less +2 -3
- package/src/less/aui-banner.less +2 -0
- package/src/less/aui-icons.less +4 -0
- package/src/less/aui-navigation.less +3 -3
- package/src/less/aui-select2.less +6 -19
- package/src/less/aui-sidebar-badges.less +4 -5
- package/src/less/dropdown2.less +6 -3
- package/src/less/imports/aui-theme/components/icons.less +1 -2
- package/src/less/imports/mixins/focus.less +2 -1
- package/src/less/imports/mixins/trigger-chevron-icon.less +28 -0
- package/src/less/imports/mixins.less +1 -1
- package/src/less/single-select.less +5 -3
- package/entry/behaviours/aui.behaviour.keyboard-shortcuts.js +0 -1
- package/src/js/aui/when-i-type.js +0 -618
- package/src/less/imports/mixins/dropdown2-trigger-chevron-icon.less +0 -17
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
import $ from './jquery';
|
|
2
|
-
import 'jquery.hotkeys/jquery.hotkeys';
|
|
3
|
-
import '../jquery/jquery.moveto';
|
|
4
|
-
import * as logger from './internal/log';
|
|
5
|
-
import { I18n } from './i18n';
|
|
6
|
-
import { popup } from './dialog';
|
|
7
|
-
import globalize from './internal/globalize';
|
|
8
|
-
import keyCode from './key-code';
|
|
9
|
-
import { isEqual } from 'underscore';
|
|
10
|
-
|
|
11
|
-
const EMPTY_SELECTOR = false;
|
|
12
|
-
|
|
13
|
-
var isMac = navigator.platform.indexOf('Mac') !== -1;
|
|
14
|
-
var isSafari = navigator.userAgent.indexOf('Safari') !== -1;
|
|
15
|
-
var multiCharRegex =
|
|
16
|
-
/^(backspace|tab|r(ight|eturn)|s(hift|pace|croll)|c(trl|apslock)|alt|pa(use|ge(up|down))|e(sc|nd)|home|left|up|d(el|own)|insert|f\d\d?|numlock|meta)/i;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Trigger native click event.
|
|
20
|
-
* @param $el
|
|
21
|
-
*/
|
|
22
|
-
const triggerClickEvent = ($el) => {
|
|
23
|
-
const element = $el[0];
|
|
24
|
-
|
|
25
|
-
if (element) {
|
|
26
|
-
// Native event bubbles are compatible with Synthetic Event from React
|
|
27
|
-
const bubbles = true;
|
|
28
|
-
const cancelable = true;
|
|
29
|
-
const event = document.createEvent('MouseEvent');
|
|
30
|
-
event.initMouseEvent(
|
|
31
|
-
'click',
|
|
32
|
-
bubbles,
|
|
33
|
-
cancelable,
|
|
34
|
-
window,
|
|
35
|
-
0,
|
|
36
|
-
0,
|
|
37
|
-
0,
|
|
38
|
-
0,
|
|
39
|
-
0,
|
|
40
|
-
false,
|
|
41
|
-
false,
|
|
42
|
-
false,
|
|
43
|
-
false,
|
|
44
|
-
0,
|
|
45
|
-
null
|
|
46
|
-
);
|
|
47
|
-
element.dispatchEvent(event);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Keyboard commands with syntactic sugar.
|
|
53
|
-
*
|
|
54
|
-
* <strong>Usage:</strong>
|
|
55
|
-
* <pre>
|
|
56
|
-
* whenIType("gh").or("gd").goTo("/secure/Dashboard.jspa");
|
|
57
|
-
* whenIType("c").click("#create_link");
|
|
58
|
-
* </pre>
|
|
59
|
-
*
|
|
60
|
-
* @param keys - Key combinations, modifier keys are "+" deliminated. e.g "ctrl+b"
|
|
61
|
-
*/
|
|
62
|
-
function whenIType(keys) {
|
|
63
|
-
var boundKeyCombos = [];
|
|
64
|
-
var executor = $.Callbacks();
|
|
65
|
-
|
|
66
|
-
function keypressHandler(e) {
|
|
67
|
-
if (!popup.current && executor) {
|
|
68
|
-
executor.fire(e);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function defaultPreventionHandler(e) {
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Bind an arbitrary set of keys by calling bindKeyCombo on each triggering key combo.
|
|
77
|
-
// A string like "abc 123" means (a then b then c) OR (1 then 2 then 3). abc is one key combo, 123 is another.
|
|
78
|
-
function bindKeys(keys) {
|
|
79
|
-
var keyCombos = keys && keys.split ? keys.trim().split(' ') : [keys];
|
|
80
|
-
|
|
81
|
-
keyCombos.forEach(function (keyCombo) {
|
|
82
|
-
bindKeyCombo(keyCombo);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function hasUnprintables(keysArr) {
|
|
87
|
-
// a bit of a heuristic, but works for everything we have. Only the unprintable characters are represented with > 1-character names.
|
|
88
|
-
var i = keysArr.length;
|
|
89
|
-
while (i--) {
|
|
90
|
-
if (keysArr[i].length > 1 && keysArr[i] !== 'space') {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// bind a single key combo to this handler
|
|
98
|
-
// A string like "abc 123" means (a then b then c) OR (1 then 2 then 3). abc is one key combo, 123 is another.
|
|
99
|
-
function bindKeyCombo(keyCombo) {
|
|
100
|
-
var keysArr =
|
|
101
|
-
keyCombo instanceof Array ? keyCombo : keyComboArrayFromString(keyCombo.toString());
|
|
102
|
-
var eventType = hasUnprintables(keysArr) ? 'keydown' : 'keypress';
|
|
103
|
-
|
|
104
|
-
boundKeyCombos.push(keysArr);
|
|
105
|
-
$(document).on(eventType, EMPTY_SELECTOR, keysArr, keypressHandler);
|
|
106
|
-
|
|
107
|
-
// Override browser/plugins
|
|
108
|
-
$(document).on(eventType + ' keyup', EMPTY_SELECTOR, keysArr, defaultPreventionHandler);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// parse out an array of (modifier+key) presses from a single string
|
|
112
|
-
// e.g. "12ctrl+3" becomes [ "1", "2", "ctrl+3" ]
|
|
113
|
-
function keyComboArrayFromString(keyString) {
|
|
114
|
-
var keysArr = [];
|
|
115
|
-
var currModifiers = '';
|
|
116
|
-
|
|
117
|
-
while (keyString.length) {
|
|
118
|
-
var modifierMatch = keyString.match(/^(ctrl|meta|shift|alt)\+/i);
|
|
119
|
-
var multiCharMatch = keyString.match(multiCharRegex);
|
|
120
|
-
|
|
121
|
-
if (modifierMatch) {
|
|
122
|
-
currModifiers += modifierMatch[0];
|
|
123
|
-
keyString = keyString.substring(modifierMatch[0].length);
|
|
124
|
-
} else if (multiCharMatch) {
|
|
125
|
-
keysArr.push(currModifiers + multiCharMatch[0]);
|
|
126
|
-
keyString = keyString.substring(multiCharMatch[0].length);
|
|
127
|
-
currModifiers = '';
|
|
128
|
-
} else {
|
|
129
|
-
keysArr.push(currModifiers + keyString[0]);
|
|
130
|
-
keyString = keyString.substring(1);
|
|
131
|
-
currModifiers = '';
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return keysArr;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function addShortcutsToTitle(selector) {
|
|
139
|
-
var elem = $(selector);
|
|
140
|
-
var title = elem.attr('title') || '';
|
|
141
|
-
var keyCombos = boundKeyCombos.slice();
|
|
142
|
-
var existingCombos = elem.data('boundKeyCombos') || [];
|
|
143
|
-
var kbShortcutAppended = elem.data('kbShortcutAppended') || '';
|
|
144
|
-
var kbShortcutAppendedScreenReader = elem.data('kbShortcutAppendedScreenReader') || '';
|
|
145
|
-
var ariaLabel = elem.attr('aria-label');
|
|
146
|
-
var isFirstShortcut = !kbShortcutAppended;
|
|
147
|
-
var isFirstShortcutScreenReader = !kbShortcutAppendedScreenReader;
|
|
148
|
-
var originalTitle = isFirstShortcut
|
|
149
|
-
? title
|
|
150
|
-
: title.substring(0, title.length - kbShortcutAppended.length);
|
|
151
|
-
var originalAriaLabel = isFirstShortcutScreenReader
|
|
152
|
-
? title
|
|
153
|
-
: ariaLabel.substring(0, ariaLabel.length - kbShortcutAppendedScreenReader.length);
|
|
154
|
-
|
|
155
|
-
while (keyCombos.length) {
|
|
156
|
-
var keyCombo = keyCombos.shift();
|
|
157
|
-
var comboAlreadyExists = existingCombos.some(function (existingCombo) {
|
|
158
|
-
return isEqual(keyCombo, existingCombo);
|
|
159
|
-
});
|
|
160
|
-
if (!comboAlreadyExists) {
|
|
161
|
-
kbShortcutAppended = appendKeyComboInstructions(
|
|
162
|
-
keyCombo.slice(),
|
|
163
|
-
kbShortcutAppended,
|
|
164
|
-
isFirstShortcut
|
|
165
|
-
);
|
|
166
|
-
kbShortcutAppendedScreenReader = appendKeyComboInstructions(
|
|
167
|
-
keyCombo.slice(),
|
|
168
|
-
kbShortcutAppendedScreenReader,
|
|
169
|
-
isFirstShortcutScreenReader,
|
|
170
|
-
{ workaroundJaws: true }
|
|
171
|
-
);
|
|
172
|
-
isFirstShortcut = false;
|
|
173
|
-
isFirstShortcutScreenReader = false;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (isMac) {
|
|
178
|
-
kbShortcutAppended = kbShortcutAppended
|
|
179
|
-
.replace(/Meta/gi, '\u2318') //Apple cmd key
|
|
180
|
-
.replace(/Shift/gi, '\u21E7'); //Apple Shift symbol
|
|
181
|
-
kbShortcutAppendedScreenReader = kbShortcutAppendedScreenReader
|
|
182
|
-
.replace(/Meta/gi, '\u2318') //Apple cmd key
|
|
183
|
-
.replace(/Shift/gi, '\u21E7'); //Apple Shift symbol
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
elem.attr('title', originalTitle + kbShortcutAppended);
|
|
187
|
-
elem.attr('aria-label', originalAriaLabel + kbShortcutAppendedScreenReader);
|
|
188
|
-
elem.data('kbShortcutAppended', kbShortcutAppended);
|
|
189
|
-
elem.data('kbShortcutAppendedScreenReader', kbShortcutAppendedScreenReader);
|
|
190
|
-
elem.data('boundKeyCombos', existingCombos.concat(boundKeyCombos));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function removeShortcutsFromTitle(selector) {
|
|
194
|
-
var elem = $(selector);
|
|
195
|
-
var shortcuts = elem.data('kbShortcutAppended');
|
|
196
|
-
|
|
197
|
-
if (!shortcuts) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
var title = elem.attr('title');
|
|
202
|
-
elem.attr('title', title.replace(shortcuts, ''));
|
|
203
|
-
elem.attr('aria-label', title.replace(shortcuts, ''));
|
|
204
|
-
elem.removeData('kbShortcutAppended');
|
|
205
|
-
elem.removeData('kbShortcutAppendedScreenReader');
|
|
206
|
-
elem.removeData('boundKeyCombos');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function appendKeyComboInstructions(keyCombo, title, isFirst, options) {
|
|
210
|
-
var openParenthesis = '(';
|
|
211
|
-
var closeParenthesis = ')';
|
|
212
|
-
|
|
213
|
-
if (options && options.workaroundJaws) {
|
|
214
|
-
openParenthesis = '';
|
|
215
|
-
closeParenthesis = '';
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (isFirst) {
|
|
219
|
-
title +=
|
|
220
|
-
' ' +
|
|
221
|
-
openParenthesis +
|
|
222
|
-
I18n.getText('aui.keyboard.shortcut.type.x', keyCombo.shift());
|
|
223
|
-
} else {
|
|
224
|
-
title = title.replace(/\)$/, '');
|
|
225
|
-
title += ' ' + I18n.getText('aui.keyboard.shortcut.or.x', keyCombo.shift());
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
keyCombo.forEach(function (key) {
|
|
229
|
-
title += ' ' + I18n.getText('aui.keyboard.shortcut.then.x', key);
|
|
230
|
-
});
|
|
231
|
-
title += closeParenthesis;
|
|
232
|
-
|
|
233
|
-
return title;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
bindKeys(keys);
|
|
237
|
-
|
|
238
|
-
return whenIType.makeShortcut({
|
|
239
|
-
executor: executor,
|
|
240
|
-
bindKeys: bindKeys,
|
|
241
|
-
addShortcutsToTitle: addShortcutsToTitle,
|
|
242
|
-
removeShortcutsFromTitle: removeShortcutsFromTitle,
|
|
243
|
-
keypressHandler: keypressHandler,
|
|
244
|
-
defaultPreventionHandler: defaultPreventionHandler,
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
whenIType.makeShortcut = function (options) {
|
|
249
|
-
var executor = options.executor;
|
|
250
|
-
var bindKeys = options.bindKeys;
|
|
251
|
-
var addShortcutsToTitle = options.addShortcutsToTitle;
|
|
252
|
-
var removeShortcutsFromTitle = options.removeShortcutsFromTitle;
|
|
253
|
-
var keypressHandler = options.keypressHandler;
|
|
254
|
-
var defaultPreventionHandler = options.defaultPreventionHandler;
|
|
255
|
-
|
|
256
|
-
var selectorsWithTitlesModified = [];
|
|
257
|
-
|
|
258
|
-
function makeMoveToFunction(getNewFocus) {
|
|
259
|
-
return function (selector, options) {
|
|
260
|
-
options = options || {};
|
|
261
|
-
var focusedClass = options.focusedClass || 'focused';
|
|
262
|
-
var wrapAround = options.hasOwnProperty('wrapAround') ? options.wrapAround : true;
|
|
263
|
-
var escToCancel = options.hasOwnProperty('escToCancel') ? options.escToCancel : true;
|
|
264
|
-
|
|
265
|
-
executor.add(function () {
|
|
266
|
-
const $items = $(selector);
|
|
267
|
-
let $focusedElem = $items.filter('.' + focusedClass);
|
|
268
|
-
const moveToOptions = $focusedElem.length === 0 ? undefined : { transition: true };
|
|
269
|
-
|
|
270
|
-
if (escToCancel) {
|
|
271
|
-
$(document).one('keydown', function (e) {
|
|
272
|
-
if (e.keyCode === keyCode.ESCAPE && $focusedElem) {
|
|
273
|
-
$focusedElem.removeClass(focusedClass);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if ($focusedElem.length) {
|
|
279
|
-
$focusedElem.removeClass(focusedClass);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
$focusedElem = getNewFocus($focusedElem, $items, wrapAround);
|
|
283
|
-
|
|
284
|
-
if ($focusedElem && $focusedElem.length > 0) {
|
|
285
|
-
$focusedElem.addClass(focusedClass);
|
|
286
|
-
$focusedElem.moveTo(moveToOptions);
|
|
287
|
-
if ($focusedElem.is('a')) {
|
|
288
|
-
$focusedElem.trigger('focus');
|
|
289
|
-
} else {
|
|
290
|
-
$focusedElem.find('a:first').trigger('focus');
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
return this;
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return {
|
|
299
|
-
/**
|
|
300
|
-
* Scrolls to and adds <em>focused</em> class to the next item in the jQuery collection
|
|
301
|
-
*
|
|
302
|
-
* @method moveToNextItem
|
|
303
|
-
* @param selector
|
|
304
|
-
* @param options
|
|
305
|
-
* @return {Object}
|
|
306
|
-
*/
|
|
307
|
-
moveToNextItem: makeMoveToFunction(function ($focusedElem, $items, wrapAround) {
|
|
308
|
-
var index;
|
|
309
|
-
|
|
310
|
-
if (wrapAround && $focusedElem.length === 0) {
|
|
311
|
-
return $items.eq(0);
|
|
312
|
-
} else {
|
|
313
|
-
index = $.inArray($focusedElem.get(0), $items);
|
|
314
|
-
if (index < $items.length - 1) {
|
|
315
|
-
index = index + 1;
|
|
316
|
-
return $items.eq(index);
|
|
317
|
-
} else if (wrapAround) {
|
|
318
|
-
return $items.eq(0);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
return $focusedElem;
|
|
323
|
-
}),
|
|
324
|
-
/**
|
|
325
|
-
* Scrolls to and adds <em>focused</em> class to the previous item in the jQuery collection
|
|
326
|
-
*
|
|
327
|
-
* @method moveToPrevItem
|
|
328
|
-
* @param selector
|
|
329
|
-
* @param focusedClass
|
|
330
|
-
* @return {Object}
|
|
331
|
-
*/
|
|
332
|
-
moveToPrevItem: makeMoveToFunction(function ($focusedElem, $items, wrapAround) {
|
|
333
|
-
var index;
|
|
334
|
-
if (wrapAround && $focusedElem.length === 0) {
|
|
335
|
-
return $items.filter(':last');
|
|
336
|
-
} else {
|
|
337
|
-
index = $.inArray($focusedElem.get(0), $items);
|
|
338
|
-
if (index > 0) {
|
|
339
|
-
index = index - 1;
|
|
340
|
-
return $items.eq(index);
|
|
341
|
-
} else if (wrapAround) {
|
|
342
|
-
return $items.filter(':last');
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return $focusedElem;
|
|
347
|
-
}),
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Clicks the element specified by the <em>selector</em> argument.
|
|
351
|
-
*
|
|
352
|
-
* @method click
|
|
353
|
-
* @param selector - jQuery selector for element
|
|
354
|
-
* @return {Object}
|
|
355
|
-
*/
|
|
356
|
-
click: function (selector) {
|
|
357
|
-
selectorsWithTitlesModified.push(selector);
|
|
358
|
-
addShortcutsToTitle(selector);
|
|
359
|
-
|
|
360
|
-
executor.add(function () {
|
|
361
|
-
const $el = $(selector);
|
|
362
|
-
triggerClickEvent($el);
|
|
363
|
-
});
|
|
364
|
-
return this;
|
|
365
|
-
},
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Navigates to specified <em>location</em>
|
|
369
|
-
*
|
|
370
|
-
* @method goTo
|
|
371
|
-
* @param {String} location - http location
|
|
372
|
-
* @return {Object}
|
|
373
|
-
*/
|
|
374
|
-
goTo: function (location) {
|
|
375
|
-
executor.add(function () {
|
|
376
|
-
window.location.href = location;
|
|
377
|
-
});
|
|
378
|
-
return this;
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* navigates browser window to link href
|
|
383
|
-
*
|
|
384
|
-
* @method followLink
|
|
385
|
-
* @param selector - jQuery selector for element
|
|
386
|
-
* @return {Object}
|
|
387
|
-
*/
|
|
388
|
-
followLink: function (selector) {
|
|
389
|
-
selectorsWithTitlesModified.push(selector);
|
|
390
|
-
addShortcutsToTitle(selector);
|
|
391
|
-
|
|
392
|
-
executor.add(function () {
|
|
393
|
-
var elem = $(selector)[0];
|
|
394
|
-
if (elem && { a: true, link: true }[elem.nodeName.toLowerCase()]) {
|
|
395
|
-
window.location.href = elem.href;
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
return this;
|
|
399
|
-
},
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Executes function
|
|
403
|
-
*
|
|
404
|
-
* @method execute
|
|
405
|
-
* @param {function} func
|
|
406
|
-
* @return {Object}
|
|
407
|
-
*/
|
|
408
|
-
execute: function (func) {
|
|
409
|
-
var self = this;
|
|
410
|
-
executor.add(function () {
|
|
411
|
-
func.apply(self, arguments);
|
|
412
|
-
});
|
|
413
|
-
return this;
|
|
414
|
-
},
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* @deprecated This implementation is uncool. Kept around to satisfy Confluence plugin devs in the short term.
|
|
418
|
-
*
|
|
419
|
-
* Executes the javascript provided by the shortcut plugin point _immediately_.
|
|
420
|
-
*
|
|
421
|
-
* @method evaluate
|
|
422
|
-
* @param {Function} command - the function provided by the shortcut key plugin point
|
|
423
|
-
*/
|
|
424
|
-
evaluate: function (command) {
|
|
425
|
-
command.call(this);
|
|
426
|
-
},
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Scrolls to element if out of view, then clicks it.
|
|
430
|
-
*
|
|
431
|
-
* @method moveToAndClick
|
|
432
|
-
* @param selector - jQuery selector for element
|
|
433
|
-
* @return {Object}
|
|
434
|
-
*/
|
|
435
|
-
moveToAndClick: function (selector) {
|
|
436
|
-
selectorsWithTitlesModified.push(selector);
|
|
437
|
-
addShortcutsToTitle(selector);
|
|
438
|
-
|
|
439
|
-
executor.add(function () {
|
|
440
|
-
const $el = $(selector);
|
|
441
|
-
if ($el.length > 0) {
|
|
442
|
-
triggerClickEvent($el);
|
|
443
|
-
$el.moveTo();
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
return this;
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* Scrolls to element if out of view, then focuses it
|
|
451
|
-
*
|
|
452
|
-
* @method moveToAndFocus
|
|
453
|
-
* @param selector - jQuery selector for element
|
|
454
|
-
* @return {Object}
|
|
455
|
-
*/
|
|
456
|
-
moveToAndFocus: function (selector) {
|
|
457
|
-
selectorsWithTitlesModified.push(selector);
|
|
458
|
-
addShortcutsToTitle(selector);
|
|
459
|
-
|
|
460
|
-
executor.add(function (e) {
|
|
461
|
-
var $elem = $(selector);
|
|
462
|
-
if ($elem.length > 0) {
|
|
463
|
-
$elem.trigger('focus');
|
|
464
|
-
if ($elem.moveTo) {
|
|
465
|
-
$elem.moveTo();
|
|
466
|
-
}
|
|
467
|
-
if ($elem.is(':input')) {
|
|
468
|
-
e.preventDefault();
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
return this;
|
|
473
|
-
},
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Binds additional keyboard controls
|
|
477
|
-
*
|
|
478
|
-
* @method or
|
|
479
|
-
* @param {String} keys - keys to bind
|
|
480
|
-
* @return {Object}
|
|
481
|
-
*/
|
|
482
|
-
or: function (keys) {
|
|
483
|
-
bindKeys(keys);
|
|
484
|
-
return this;
|
|
485
|
-
},
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Unbinds shortcut keys
|
|
489
|
-
*
|
|
490
|
-
* @method unbind
|
|
491
|
-
*/
|
|
492
|
-
unbind: function () {
|
|
493
|
-
$(document)
|
|
494
|
-
.off('keydown keypress', keypressHandler)
|
|
495
|
-
.off('keydown keypress keyup', defaultPreventionHandler);
|
|
496
|
-
|
|
497
|
-
for (var i = 0, len = selectorsWithTitlesModified.length; i < len; i++) {
|
|
498
|
-
removeShortcutsFromTitle(selectorsWithTitlesModified[i]);
|
|
499
|
-
}
|
|
500
|
-
selectorsWithTitlesModified = [];
|
|
501
|
-
},
|
|
502
|
-
};
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* Creates keyboard commands and their actions from json data. Format looks like:
|
|
507
|
-
*
|
|
508
|
-
* <pre>
|
|
509
|
-
* [
|
|
510
|
-
* {
|
|
511
|
-
* "keys":[["g", "d"]],
|
|
512
|
-
* "context":"global",
|
|
513
|
-
* "op":"followLink",
|
|
514
|
-
* "param":"#home_link"
|
|
515
|
-
* },
|
|
516
|
-
* {
|
|
517
|
-
* "keys":[["g", "i"]],
|
|
518
|
-
* "context":"global",
|
|
519
|
-
* "op":"followLink",
|
|
520
|
-
* "param":"#find_link"
|
|
521
|
-
* },
|
|
522
|
-
* {
|
|
523
|
-
* "keys":[["/"]],
|
|
524
|
-
* "context":"global",
|
|
525
|
-
* "op":"moveToAndFocus",
|
|
526
|
-
* "param":"#quickSearchInput"
|
|
527
|
-
* },
|
|
528
|
-
* {
|
|
529
|
-
* "keys":[["c"]],
|
|
530
|
-
* "context":"global",
|
|
531
|
-
* "op":"moveToAndClick",
|
|
532
|
-
* "param":"#create_link"
|
|
533
|
-
* }
|
|
534
|
-
* ]
|
|
535
|
-
* </pre>
|
|
536
|
-
*
|
|
537
|
-
* @method fromJSON
|
|
538
|
-
* @static
|
|
539
|
-
* @param json
|
|
540
|
-
*/
|
|
541
|
-
whenIType.fromJSON = function (json, switchCtrlToMetaOnMac) {
|
|
542
|
-
var shortcuts = [];
|
|
543
|
-
|
|
544
|
-
if (json) {
|
|
545
|
-
$.each(json, function (i, item) {
|
|
546
|
-
const operation = item.op;
|
|
547
|
-
const param = item.param;
|
|
548
|
-
let params;
|
|
549
|
-
|
|
550
|
-
if (operation === 'execute' || operation === 'evaluate') {
|
|
551
|
-
// need to turn function string into function object
|
|
552
|
-
params = [new Function(param)];
|
|
553
|
-
} else if (/^\[[^\]\[]*,[^\]\[]*\]$/.test(param)) {
|
|
554
|
-
// pass in an array to send multiple params
|
|
555
|
-
try {
|
|
556
|
-
params = JSON.parse(param);
|
|
557
|
-
// eslint-disable-next-line no-unused-vars
|
|
558
|
-
} catch (e) {
|
|
559
|
-
logger.error(
|
|
560
|
-
'When using a parameter array, array must be in strict JSON format: ' +
|
|
561
|
-
param
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
if (!Array.isArray(params)) {
|
|
566
|
-
logger.error(
|
|
567
|
-
'Badly formatted shortcut parameter. String or JSON Array of parameters required: ' +
|
|
568
|
-
param
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
} else {
|
|
572
|
-
params = [param];
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
$.each(item.keys, function () {
|
|
576
|
-
var shortcutList = this;
|
|
577
|
-
if (switchCtrlToMetaOnMac && isMac) {
|
|
578
|
-
shortcutList = $.map(shortcutList, function (shortcutString) {
|
|
579
|
-
return shortcutString.replace(/ctrl/i, 'meta');
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
var newShortcut = whenIType(shortcutList);
|
|
584
|
-
newShortcut[operation].apply(newShortcut, params);
|
|
585
|
-
shortcuts.push(newShortcut);
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
return shortcuts;
|
|
591
|
-
};
|
|
592
|
-
|
|
593
|
-
// Trigger this event on an iframe if you want its keypress events to be propagated (Events to work in iframes).
|
|
594
|
-
$(document).on('iframeAppended', function (e, iframe) {
|
|
595
|
-
$(iframe).on('load', function () {
|
|
596
|
-
var $target = $(iframe).contents();
|
|
597
|
-
|
|
598
|
-
$target.on('keyup keydown keypress', function (e) {
|
|
599
|
-
// safari propagates keypress events from iframes
|
|
600
|
-
if (isSafari && e.type === 'keypress') {
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
if (!$(e.target).is(':input')) {
|
|
605
|
-
$.event.trigger(
|
|
606
|
-
e,
|
|
607
|
-
arguments, // Preserve original event data.
|
|
608
|
-
document, // Bubble this event from the iframe's document to its parent document.
|
|
609
|
-
true // Use the capturing phase to preserve original event.target.
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
globalize('whenIType', whenIType);
|
|
617
|
-
|
|
618
|
-
export default whenIType;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
@import (reference) './icon-pseudoelement';
|
|
2
|
-
|
|
3
|
-
#aui {
|
|
4
|
-
.aui-dropdown2-trigger-chevron-icon(@glyphsize: @aui-icon-size-small; @canvassize: @aui-icon-size-small-canvas) {
|
|
5
|
-
#aui.icon-pseudoelement(@aui-icon-font-family);
|
|
6
|
-
content: @aui-glyph-chevron-down;
|
|
7
|
-
font-size: @glyphsize;
|
|
8
|
-
height: @glyphsize;
|
|
9
|
-
line-height: 1;
|
|
10
|
-
margin-top: -(@glyphsize / 2);
|
|
11
|
-
position: absolute;
|
|
12
|
-
right: 3.5px;
|
|
13
|
-
top: 50%;
|
|
14
|
-
text-indent: 0; // Reset indentation set by split button
|
|
15
|
-
width: @glyphsize;
|
|
16
|
-
}
|
|
17
|
-
}
|