mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
pad_editbar: Convert bodyKeyEvent()
into a method
This commit is contained in:
parent
b2fe6e3e7e
commit
11faf6104a
1 changed files with 57 additions and 57 deletions
|
@ -126,6 +126,8 @@ const padeditbar = (() => {
|
||||||
const syncAnimation = syncAnimationFn();
|
const syncAnimation = syncAnimationFn();
|
||||||
|
|
||||||
const self = {
|
const self = {
|
||||||
|
_editbarPosition: 0,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.dropdowns = [];
|
this.dropdowns = [];
|
||||||
|
|
||||||
|
@ -139,7 +141,7 @@ const padeditbar = (() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body:not(#editorcontainerbox)').on('keydown', (evt) => {
|
$('body:not(#editorcontainerbox)').on('keydown', (evt) => {
|
||||||
bodyKeyEvent(evt);
|
this._bodyKeyEvent(evt);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.show-more-icon-btn').click(() => {
|
$('.show-more-icon-btn').click(() => {
|
||||||
|
@ -294,18 +296,15 @@ const padeditbar = (() => {
|
||||||
$('.toolbar').addClass('cropped');
|
$('.toolbar').addClass('cropped');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
|
||||||
|
|
||||||
let editbarPosition = 0;
|
_bodyKeyEvent(evt) {
|
||||||
|
|
||||||
const bodyKeyEvent = (evt) => {
|
|
||||||
// If the event is Alt F9 or Escape & we're already in the editbar menu
|
// If the event is Alt F9 or Escape & we're already in the editbar menu
|
||||||
// Send the users focus back to the pad
|
// Send the users focus back to the pad
|
||||||
if ((evt.keyCode === 120 && evt.altKey) || evt.keyCode === 27) {
|
if ((evt.keyCode === 120 && evt.altKey) || evt.keyCode === 27) {
|
||||||
if ($(':focus').parents('.toolbar').length === 1) {
|
if ($(':focus').parents('.toolbar').length === 1) {
|
||||||
// If we're in the editbar already..
|
// If we're in the editbar already..
|
||||||
// Close any dropdowns we have open..
|
// Close any dropdowns we have open..
|
||||||
padeditbar.toggleDropDown('none');
|
this.toggleDropDown('none');
|
||||||
// Check we're on a pad and not on the timeslider
|
// Check we're on a pad and not on the timeslider
|
||||||
// Or some other window I haven't thought about!
|
// Or some other window I haven't thought about!
|
||||||
if (typeof pad === 'undefined') {
|
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 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;
|
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
|
// Allow focus to shift back to end of row and start of row
|
||||||
if (editbarPosition === -1) editbarPosition = focusItems.length - 1;
|
if (this._editbarPosition === -1) this._editbarPosition = focusItems.length - 1;
|
||||||
$(focusItems[editbarPosition]).focus();
|
$(focusItems[this._editbarPosition]).focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// On right arrow move to next button in editbar
|
// 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 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;
|
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
|
// Allow focus to shift back to end of row and start of row
|
||||||
if (editbarPosition >= focusItems.length) editbarPosition = 0;
|
if (this._editbarPosition >= focusItems.length) this._editbarPosition = 0;
|
||||||
$(focusItems[editbarPosition]).focus();
|
$(focusItems[this._editbarPosition]).focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const aceAttributeCommand = (cmd, ace) => {
|
const aceAttributeCommand = (cmd, ace) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue