pad_editbar: Convert `bodyKeyEvent()` into a method
parent
b2fe6e3e7e
commit
11faf6104a
|
@ -126,6 +126,8 @@ const padeditbar = (() => {
|
|||
const syncAnimation = syncAnimationFn();
|
||||
|
||||
const self = {
|
||||
_editbarPosition: 0,
|
||||
|
||||
init() {
|
||||
this.dropdowns = [];
|
||||
|
||||
|
@ -139,7 +141,7 @@ const padeditbar = (() => {
|
|||
});
|
||||
|
||||
$('body:not(#editorcontainerbox)').on('keydown', (evt) => {
|
||||
bodyKeyEvent(evt);
|
||||
this._bodyKeyEvent(evt);
|
||||
});
|
||||
|
||||
$('.show-more-icon-btn').click(() => {
|
||||
|
@ -294,18 +296,15 @@ const padeditbar = (() => {
|
|||
$('.toolbar').addClass('cropped');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let editbarPosition = 0;
|
||||
|
||||
const bodyKeyEvent = (evt) => {
|
||||
_bodyKeyEvent(evt) {
|
||||
// If the event is Alt F9 or Escape & we're already in the editbar menu
|
||||
// Send the users focus back to the pad
|
||||
if ((evt.keyCode === 120 && evt.altKey) || evt.keyCode === 27) {
|
||||
if ($(':focus').parents('.toolbar').length === 1) {
|
||||
// If we're in the editbar already..
|
||||
// Close any dropdowns we have open..
|
||||
padeditbar.toggleDropDown('none');
|
||||
this.toggleDropDown('none');
|
||||
// Check we're on a pad and not on the timeslider
|
||||
// Or some other window I haven't thought about!
|
||||
if (typeof pad === 'undefined') {
|
||||
|
@ -342,10 +341,10 @@ const padeditbar = (() => {
|
|||
// If a dropdown is visible or we're in an input don't move to the next button
|
||||
if ($('.popup').is(':visible') || evt.target.localName === 'input') return;
|
||||
|
||||
editbarPosition--;
|
||||
this._editbarPosition--;
|
||||
// Allow focus to shift back to end of row and start of row
|
||||
if (editbarPosition === -1) editbarPosition = focusItems.length - 1;
|
||||
$(focusItems[editbarPosition]).focus();
|
||||
if (this._editbarPosition === -1) this._editbarPosition = focusItems.length - 1;
|
||||
$(focusItems[this._editbarPosition]).focus();
|
||||
}
|
||||
|
||||
// On right arrow move to next button in editbar
|
||||
|
@ -353,12 +352,13 @@ const padeditbar = (() => {
|
|||
// If a dropdown is visible or we're in an input don't move to the next button
|
||||
if ($('.popup').is(':visible') || evt.target.localName === 'input') return;
|
||||
|
||||
editbarPosition++;
|
||||
this._editbarPosition++;
|
||||
// Allow focus to shift back to end of row and start of row
|
||||
if (editbarPosition >= focusItems.length) editbarPosition = 0;
|
||||
$(focusItems[editbarPosition]).focus();
|
||||
if (this._editbarPosition >= focusItems.length) this._editbarPosition = 0;
|
||||
$(focusItems[this._editbarPosition]).focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const aceAttributeCommand = (cmd, ace) => {
|
||||
|
|
Loading…
Reference in New Issue