mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +03:00
Added: addEventsListener() and addEventsListeners()
This commit is contained in:
parent
c270f0ad9a
commit
5990addfef
14 changed files with 484 additions and 464 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { Scope } from 'Common/Enums';
|
||||
import { i18n } from 'Common/Translator';
|
||||
import { isFunction } from 'Common/Utils';
|
||||
|
||||
|
|
@ -58,8 +57,8 @@ class AskPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
onBuild() {
|
||||
// shortcuts.add('tab', 'shift', Scope.Ask, () => {
|
||||
shortcuts.add('tab,arrowright,arrowleft', '', Scope.Ask, () => {
|
||||
// shortcuts.add('tab', 'shift', 'Ask', () => {
|
||||
shortcuts.add('tab,arrowright,arrowleft', '', 'Ask', () => {
|
||||
let btn = this.querySelector('.buttonYes');
|
||||
if (btn.matches(':focus')) {
|
||||
btn = this.querySelector('.buttonNo');
|
||||
|
|
@ -68,7 +67,7 @@ class AskPopupView extends AbstractViewPopup {
|
|||
return false;
|
||||
});
|
||||
|
||||
shortcuts.add('escape', '', Scope.Ask, () => {
|
||||
shortcuts.add('escape', '', 'Ask', () => {
|
||||
this.noClick();
|
||||
return false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import {
|
||||
Scope,
|
||||
Notification,
|
||||
UploadErrorCode
|
||||
} from 'Common/Enums';
|
||||
|
|
@ -50,6 +49,8 @@ import { ContactsPopupView } from 'View/Popup/Contacts';
|
|||
import { ThemeStore } from 'Stores/Theme';
|
||||
|
||||
const
|
||||
ScopeCompose = 'Compose',
|
||||
|
||||
base64_encode = text => btoa(text).match(/.{1,76}/g).join('\r\n'),
|
||||
|
||||
email = new EmailModel(),
|
||||
|
|
@ -1323,42 +1324,42 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
|
||||
this.addAttachmentEnabled(true);
|
||||
|
||||
shortcuts.add('q', 'meta', Scope.Compose, ()=>false);
|
||||
shortcuts.add('w', 'meta', Scope.Compose, ()=>false);
|
||||
shortcuts.add('q', 'meta', ScopeCompose, ()=>false);
|
||||
shortcuts.add('w', 'meta', ScopeCompose, ()=>false);
|
||||
|
||||
shortcuts.add('contextmenu', '', Scope.Compose, e => this.popupMenu(e));
|
||||
shortcuts.add('m', 'meta', Scope.Compose, e => this.popupMenu(e));
|
||||
shortcuts.add('contextmenu', '', ScopeCompose, e => this.popupMenu(e));
|
||||
shortcuts.add('m', 'meta', ScopeCompose, e => this.popupMenu(e));
|
||||
|
||||
shortcuts.add('escape,close', '', Scope.Compose, () => {
|
||||
shortcuts.add('escape,close', '', ScopeCompose, () => {
|
||||
this.skipCommand();
|
||||
return false;
|
||||
});
|
||||
shortcuts.add('arrowdown', 'meta', Scope.Compose, () => {
|
||||
shortcuts.add('arrowdown', 'meta', ScopeCompose, () => {
|
||||
this.skipCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
shortcuts.add('s', 'meta', Scope.Compose, () => {
|
||||
shortcuts.add('s', 'meta', ScopeCompose, () => {
|
||||
this.saveCommand();
|
||||
return false;
|
||||
});
|
||||
shortcuts.add('save', '', Scope.Compose, () => {
|
||||
shortcuts.add('save', '', ScopeCompose, () => {
|
||||
this.saveCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
if (Settings.app('allowCtrlEnterOnCompose')) {
|
||||
shortcuts.add('enter', 'meta', Scope.Compose, () => {
|
||||
shortcuts.add('enter', 'meta', ScopeCompose, () => {
|
||||
this.sendCommand();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
shortcuts.add('mailsend', '', Scope.Compose, () => {
|
||||
shortcuts.add('mailsend', '', ScopeCompose, () => {
|
||||
this.sendCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
shortcuts.add('escape,close', 'shift', Scope.Compose, () => {
|
||||
shortcuts.add('escape,close', 'shift', ScopeCompose, () => {
|
||||
this.modalVisibility() && this.tryToClosePopup();
|
||||
return false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
import { koArrayWithDestroy } from 'External/ko';
|
||||
|
||||
import {
|
||||
SaveSettingsStep,
|
||||
Scope
|
||||
} from 'Common/Enums';
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
|
||||
import { ComposeType } from 'Common/EnumsUser';
|
||||
|
||||
|
|
@ -26,7 +23,9 @@ import { ContactPropertyModel, ContactPropertyType } from 'Model/ContactProperty
|
|||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
const CONTACTS_PER_PAGE = 50,
|
||||
const
|
||||
CONTACTS_PER_PAGE = 50,
|
||||
ScopeContacts = 'Contacts',
|
||||
propertyIsMail = prop => prop.isType(ContactPropertyType.Email),
|
||||
propertyIsName = prop => prop.isType(ContactPropertyType.FirstName) || prop.isType(ContactPropertyType.LastName);
|
||||
|
||||
|
|
@ -446,14 +445,14 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
onBuild(dom) {
|
||||
this.selector.init(dom.querySelector('.b-list-content'), Scope.Contacts);
|
||||
this.selector.init(dom.querySelector('.b-list-content'), ScopeContacts);
|
||||
|
||||
shortcuts.add('delete', '', Scope.Contacts, () => {
|
||||
shortcuts.add('delete', '', ScopeContacts, () => {
|
||||
this.deleteCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
shortcuts.add('c,w', '', Scope.Contacts, () => {
|
||||
shortcuts.add('c,w', '', ScopeContacts, () => {
|
||||
this.newMessageCommand();
|
||||
return false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import { Scope } from 'Common/Enums';
|
||||
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
export class KeyboardShortcutsHelpPopupView extends AbstractViewPopup {
|
||||
|
|
@ -14,7 +12,7 @@ export class KeyboardShortcutsHelpPopupView extends AbstractViewPopup {
|
|||
|
||||
// shortcuts.add('tab', 'shift',
|
||||
shortcuts.add('tab,arrowleft,arrowright', '',
|
||||
Scope.KeyboardShortcutsHelp,
|
||||
'KeyboardShortcutsHelp',
|
||||
event => {
|
||||
let next = 0;
|
||||
tabs.forEach((node, index) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { Scope } from 'Common/Enums';
|
||||
import { doc } from 'Common/Globals';
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
|
|
@ -119,7 +118,7 @@ class OpenPgpKeyPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
onBuild() {
|
||||
shortcuts.add('a', 'meta', Scope.OpenPgpKey, () => {
|
||||
shortcuts.add('a', 'meta', 'OpenPgpKey', () => {
|
||||
this.selectKey();
|
||||
return false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {
|
|||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
|
||||
import { doc, leftPanelDisabled, moveAction, Settings, SettingsCapa, SettingsGet, fireEvent } from 'Common/Globals';
|
||||
import { doc, leftPanelDisabled, moveAction, Settings, SettingsCapa, SettingsGet, fireEvent, addEventsListeners } from 'Common/Globals';
|
||||
|
||||
import { computedPaginatorHelper, showMessageComposer, populateMessageBody } from 'Common/UtilsUser';
|
||||
import { FileInfo } from 'Common/File';
|
||||
|
|
@ -642,28 +642,29 @@ export class MailMessageList extends AbstractViewRight {
|
|||
|
||||
this.selector.init(dom.querySelector('.b-content'), Scope.MessageList);
|
||||
|
||||
dom.addEventListener('click', event => {
|
||||
ThemeStore.isMobile() && !eqs(event, '.toggleLeft') && leftPanelDisabled(true);
|
||||
addEventsListeners(dom, {
|
||||
click: event => {
|
||||
ThemeStore.isMobile() && !eqs(event, '.toggleLeft') && leftPanelDisabled(true);
|
||||
|
||||
if (eqs(event, '.messageList') && Scope.MessageView === AppUserStore.focusedState()) {
|
||||
AppUserStore.focusedState(Scope.MessageList);
|
||||
if (eqs(event, '.messageList') && Scope.MessageView === AppUserStore.focusedState()) {
|
||||
AppUserStore.focusedState(Scope.MessageList);
|
||||
}
|
||||
|
||||
let el = eqs(event, '.e-paginator a');
|
||||
el && this.gotoPage(ko.dataFor(el));
|
||||
|
||||
eqs(event, '.checkboxCheckAll') && this.checkAll(!this.checkAll());
|
||||
|
||||
el = eqs(event, '.flagParent');
|
||||
el && this.flagMessages(ko.dataFor(el));
|
||||
|
||||
el = eqs(event, '.threads-len');
|
||||
el && this.gotoThread(ko.dataFor(el));
|
||||
},
|
||||
dblclick: event => {
|
||||
let el = eqs(event, '.actionHandle');
|
||||
el && this.gotoThread(ko.dataFor(el));
|
||||
}
|
||||
|
||||
let el = eqs(event, '.e-paginator a');
|
||||
el && this.gotoPage(ko.dataFor(el));
|
||||
|
||||
eqs(event, '.checkboxCheckAll') && this.checkAll(!this.checkAll());
|
||||
|
||||
el = eqs(event, '.flagParent');
|
||||
el && this.flagMessages(ko.dataFor(el));
|
||||
|
||||
el = eqs(event, '.threads-len');
|
||||
el && this.gotoThread(ko.dataFor(el));
|
||||
});
|
||||
|
||||
dom.addEventListener('dblclick', event => {
|
||||
let el = eqs(event, '.actionHandle');
|
||||
el && this.gotoThread(ko.dataFor(el));
|
||||
});
|
||||
|
||||
// initUploaderForAppend
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue