mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 15:45:55 +08:00
cleanup some code
This commit is contained in:
parent
e566494a87
commit
cb2048f163
|
@ -83,23 +83,6 @@ export const Focused = {
|
|||
FolderList: 'folder-list'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const State = {
|
||||
Empty: 10,
|
||||
Login: 20,
|
||||
Auth: 30
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const StateType = {
|
||||
Webmail: 0,
|
||||
Admin: 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
|
@ -108,7 +91,6 @@ export const Capa = {
|
|||
TwoFactorForce: 'TWO_FACTOR_FORCE',
|
||||
OpenPGP: 'OPEN_PGP',
|
||||
Prefetch: 'PREFETCH',
|
||||
Gravatar: 'GRAVATAR',
|
||||
Folders: 'FOLDERS',
|
||||
Composer: 'COMPOSER',
|
||||
Contacts: 'CONTACTS',
|
||||
|
@ -252,7 +234,7 @@ export const ClientSideKeyName = {
|
|||
LastSignMe: 7,
|
||||
ComposeLastIdentityID: 8,
|
||||
MessageHeaderFullInfo: 9,
|
||||
MessageAttachmnetControls: 10
|
||||
MessageAttachmentControls: 10
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -432,17 +414,6 @@ export const ContactPropertyType = {
|
|||
Custom: 250
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const Ports = {
|
||||
Imap: 143,
|
||||
ImapSsl: 993,
|
||||
Smtp: 25,
|
||||
SmtpSsl: 465,
|
||||
SmtpStartTls: 587
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
|
|
|
@ -7,11 +7,7 @@ const
|
|||
SERVER_PREFIX = './?',
|
||||
SUB_QUERY_PREFIX = '&q[]=',
|
||||
VERSION = Settings.app('version'),
|
||||
WEB_PREFIX = Settings.app('webPath') || '',
|
||||
VERSION_PREFIX = Settings.app('webVersionPath') || 'rainloop/v/' + VERSION + '/',
|
||||
STATIC_PREFIX = VERSION_PREFIX + 'static/',
|
||||
ADMIN_HOST_USE = !!Settings.app('adminHostUse'),
|
||||
ADMIN_PATH = Settings.app('adminPath') || 'admin',
|
||||
|
||||
getHash = () => Settings.get('AuthAccountHash') || '0';
|
||||
|
||||
|
@ -34,7 +30,7 @@ export function root(startupUrl = '') {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function rootAdmin() {
|
||||
return ADMIN_HOST_USE ? ROOT : SERVER_PREFIX + ADMIN_PATH;
|
||||
return Settings.app('adminHostUse') ? ROOT : SERVER_PREFIX + (Settings.app('adminPath') || 'admin');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,7 +234,7 @@ export function exportContactsCsv() {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function staticPrefix(path) {
|
||||
return STATIC_PREFIX + path;
|
||||
return VERSION_PREFIX + 'static/' + path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -292,7 +288,7 @@ export function themePreviewLink(theme) {
|
|||
let prefix = VERSION_PREFIX;
|
||||
if ('@custom' === theme.substr(-7)) {
|
||||
theme = theme.substr(0, theme.length - 7).trim();
|
||||
prefix = WEB_PREFIX;
|
||||
prefix = Settings.app('webPath') || '';
|
||||
}
|
||||
|
||||
return prefix + 'themes/' + encodeURI(theme) + '/images/preview.png';
|
||||
|
|
|
@ -18,9 +18,7 @@ export class AbstractModel {
|
|||
|
||||
regDisposables(value) {
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((item) => {
|
||||
this.disposables.push(item);
|
||||
});
|
||||
value.forEach(item => this.disposables.push(item));
|
||||
} else if (value) {
|
||||
this.disposables.push(value);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ export class AbstractScreen {
|
|||
/**
|
||||
* @returns {?Object}
|
||||
*/
|
||||
__cross() {
|
||||
get __cross() {
|
||||
return this.oCross;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ export class AbstractViewNext {
|
|||
sDefaultKeyScope = KeyState.None;
|
||||
sCurrentKeyScope = KeyState.None;
|
||||
|
||||
viewModelVisibility = ko.observable(false);
|
||||
viewModelVisible = false;
|
||||
modalVisibility = ko.observable(false).extend({ rateLimit: 0 });
|
||||
|
||||
viewModelName = '';
|
||||
|
|
|
@ -249,8 +249,7 @@ export function isPopupVisible(ViewModelClassToShow) {
|
|||
*/
|
||||
function screenOnRoute(screenName, subPart) {
|
||||
let vmScreen = null,
|
||||
isSameScreen = false,
|
||||
cross = null;
|
||||
isSameScreen = false;
|
||||
|
||||
if (null == screenName || '' == screenName) {
|
||||
screenName = defaultScreenName;
|
||||
|
@ -295,7 +294,7 @@ function screenOnRoute(screenName, subPart) {
|
|||
ViewType.Popup !== ViewModelClass.__vm.viewModelPosition
|
||||
) {
|
||||
ViewModelClass.__dom.hidden = true;
|
||||
ViewModelClass.__vm.viewModelVisibility(false);
|
||||
ViewModelClass.__vm.viewModelVisible = false;
|
||||
|
||||
ViewModelClass.__vm.onHide && ViewModelClass.__vm.onHide();
|
||||
ViewModelClass.__vm.onHideWithDelay && setTimeout(()=>ViewModelClass.__vm.onHideWithDelay(), 500);
|
||||
|
@ -321,7 +320,7 @@ function screenOnRoute(screenName, subPart) {
|
|||
ViewModelClass.__vm.onBeforeShow && ViewModelClass.__vm.onBeforeShow();
|
||||
|
||||
ViewModelClass.__dom.hidden = false;
|
||||
ViewModelClass.__vm.viewModelVisibility(true);
|
||||
ViewModelClass.__vm.viewModelVisible = true;
|
||||
|
||||
ViewModelClass.__vm.onShow && ViewModelClass.__vm.onShow();
|
||||
|
||||
|
@ -334,10 +333,7 @@ function screenOnRoute(screenName, subPart) {
|
|||
}
|
||||
// --
|
||||
|
||||
cross = vmScreen && vmScreen.__cross ? vmScreen.__cross() : null;
|
||||
if (cross) {
|
||||
cross.parse(subPart);
|
||||
}
|
||||
vmScreen && vmScreen.__cross && vmScreen.__cross.parse(subPart);
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType, ServerSecure, Ports, Notification } from 'Common/Enums';
|
||||
import { StorageResultType, ServerSecure, Notification } from 'Common/Enums';
|
||||
import { pInt, pString } from 'Common/Utils';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
|
@ -125,19 +125,19 @@ class DomainPopupView extends AbstractViewNext {
|
|||
value && this.imapServer() && !this.smtpServer() && this.smtpServer(this.imapServer().replace(/imap/gi, 'smtp'))
|
||||
);
|
||||
|
||||
this.imapSecure.subscribe((value) => {
|
||||
this.imapSecure.subscribe(value => {
|
||||
if (this.enableSmartPorts()) {
|
||||
const port = pInt(this.imapPort());
|
||||
switch (pString(value)) {
|
||||
case '0':
|
||||
case '2':
|
||||
if (Ports.ImapSsl === port) {
|
||||
this.imapPort(pString(Ports.Imap));
|
||||
if (993 === port) {
|
||||
this.imapPort('143');
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (Ports.Imap === port) {
|
||||
this.imapPort(pString(Ports.ImapSsl));
|
||||
if (143 === port) {
|
||||
this.imapPort('993');
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
|
@ -145,23 +145,23 @@ class DomainPopupView extends AbstractViewNext {
|
|||
}
|
||||
});
|
||||
|
||||
this.smtpSecure.subscribe((value) => {
|
||||
this.smtpSecure.subscribe(value => {
|
||||
if (this.enableSmartPorts()) {
|
||||
const port = pInt(this.smtpPort());
|
||||
switch (pString(value)) {
|
||||
case '0':
|
||||
if (Ports.SmtpSsl === port || Ports.SmtpStartTls === port) {
|
||||
this.smtpPort(pString(Ports.Smtp));
|
||||
if (465 === port || 587 === port) {
|
||||
this.smtpPort('25');
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (Ports.Smtp === port || Ports.SmtpStartTls === port) {
|
||||
this.smtpPort(pString(Ports.SmtpSsl));
|
||||
if (25 === port || 587 === port) {
|
||||
this.smtpPort('465');
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
if (Ports.Smtp === port || Ports.SmtpSsl === port) {
|
||||
this.smtpPort(pString(Ports.SmtpStartTls));
|
||||
if (25 === port || 465 === port) {
|
||||
this.smtpPort('587');
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
|
|
|
@ -82,7 +82,7 @@ class AbstractSystemDropDownUserView extends AbstractViewNext {
|
|||
|
||||
onBuild() {
|
||||
shortcuts.add('`', '', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => {
|
||||
if (this.viewModelVisibility()) {
|
||||
if (this.viewModelVisible) {
|
||||
MessageStore.messageFullScreenMode(false);
|
||||
this.accountMenuDropdownTrigger(true);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class AbstractSystemDropDownUserView extends AbstractViewNext {
|
|||
|
||||
// shortcuts help
|
||||
shortcuts.add('/', 'shift', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => {
|
||||
if (this.viewModelVisibility()) {
|
||||
if (this.viewModelVisible) {
|
||||
showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -872,7 +872,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
|||
}
|
||||
|
||||
prefetchNextTick() {
|
||||
if (ifvisible && !this.bPrefetch && !ifvisible.now() && this.viewModelVisibility()) {
|
||||
if (ifvisible && !this.bPrefetch && !ifvisible.now() && this.viewModelVisible) {
|
||||
const message = this.messageList().find(
|
||||
item => item && !hasRequestedMessage(item.folderFullNameRaw, item.uid)
|
||||
);
|
||||
|
|
|
@ -109,7 +109,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
|
||||
this.showAttachmnetControls = ko.observable(false);
|
||||
|
||||
this.showAttachmnetControlsState = v => Local.set(ClientSideKeyName.MessageAttachmnetControls, !!v);
|
||||
this.showAttachmnetControlsState = v => Local.set(ClientSideKeyName.MessageAttachmentControls, !!v);
|
||||
|
||||
this.allowAttachmnetControls = ko.computed(
|
||||
() => this.attachmentsActions().length && Settings.capa(Capa.AttachmentsActions)
|
||||
|
@ -220,7 +220,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
|
||||
if (message) {
|
||||
this.showAttachmnetControls(false);
|
||||
if (Local.get(ClientSideKeyName.MessageAttachmnetControls)) {
|
||||
if (Local.get(ClientSideKeyName.MessageAttachmentControls)) {
|
||||
setTimeout(() => {
|
||||
this.showAttachmnetControls(true);
|
||||
}, 50);
|
||||
|
@ -509,7 +509,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
escShortcuts() {
|
||||
if (this.viewModelVisibility() && this.message()) {
|
||||
if (this.viewModelVisible && this.message()) {
|
||||
const preview = Layout.NoPreview !== this.layout();
|
||||
if (this.fullScreenMode()) {
|
||||
this.fullScreenMode(false);
|
||||
|
|
2
vendors/jua/jua.js
vendored
2
vendors/jua/jua.js
vendored
|
@ -494,7 +494,7 @@
|
|||
while (iLen--)
|
||||
fakeMd5 += '0123456789abcdefghijklmnopqrstuvwxyz'.substr(Math.round(Math.random() * 36), 1);
|
||||
|
||||
this.addFile('jua-uid-' + fakeMd5 + '-' + (new Date()).getTime().toString(), oFileInfo);
|
||||
this.addFile('jua-uid-' + fakeMd5 + '-' + (Date.now().toString()), oFileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
2
vendors/jua/jua.min.js
vendored
2
vendors/jua/jua.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -2341,7 +2341,6 @@ ko.exportSymbol('jsonExpressionRewriting.insertPropertyAccessorsIntoJson', ko.ex
|
|||
|
||||
var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
|
||||
var endCommentRegex = /^\s*\/ko\s*$/;
|
||||
var htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true };
|
||||
|
||||
function isStartComment(node) {
|
||||
return (node.nodeType == 8) && startCommentRegex.test(node.nodeValue);
|
||||
|
@ -2389,28 +2388,6 @@ ko.exportSymbol('jsonExpressionRewriting.insertPropertyAccessorsIntoJson', ko.ex
|
|||
return null; // Must have no matching end comment, and allowUnbalanced is true
|
||||
}
|
||||
|
||||
function getUnbalancedChildTags(node) {
|
||||
// e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>
|
||||
// from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->
|
||||
var childNode = node.firstChild, captureRemaining = null;
|
||||
if (childNode) {
|
||||
do {
|
||||
if (captureRemaining) // We already hit an unbalanced node and are now just scooping up all subsequent nodes
|
||||
captureRemaining.push(childNode);
|
||||
else if (isStartComment(childNode)) {
|
||||
var matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true);
|
||||
if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set
|
||||
childNode = matchingEndComment;
|
||||
else
|
||||
captureRemaining = [childNode]; // It's unbalanced, so start capturing from this point
|
||||
} else if (isEndComment(childNode)) {
|
||||
captureRemaining = [childNode]; // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing
|
||||
}
|
||||
} while (childNode = childNode.nextSibling);
|
||||
}
|
||||
return captureRemaining;
|
||||
}
|
||||
|
||||
ko.virtualElements = {
|
||||
allowedBindings: {},
|
||||
|
||||
|
|
23
vendors/knockout/src/virtualElements.js
vendored
23
vendors/knockout/src/virtualElements.js
vendored
|
@ -9,7 +9,6 @@
|
|||
|
||||
var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
|
||||
var endCommentRegex = /^\s*\/ko\s*$/;
|
||||
var htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true };
|
||||
|
||||
function isStartComment(node) {
|
||||
return (node.nodeType == 8) && startCommentRegex.test(node.nodeValue);
|
||||
|
@ -57,28 +56,6 @@
|
|||
return null; // Must have no matching end comment, and allowUnbalanced is true
|
||||
}
|
||||
|
||||
function getUnbalancedChildTags(node) {
|
||||
// e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>
|
||||
// from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->
|
||||
var childNode = node.firstChild, captureRemaining = null;
|
||||
if (childNode) {
|
||||
do {
|
||||
if (captureRemaining) // We already hit an unbalanced node and are now just scooping up all subsequent nodes
|
||||
captureRemaining.push(childNode);
|
||||
else if (isStartComment(childNode)) {
|
||||
var matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true);
|
||||
if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set
|
||||
childNode = matchingEndComment;
|
||||
else
|
||||
captureRemaining = [childNode]; // It's unbalanced, so start capturing from this point
|
||||
} else if (isEndComment(childNode)) {
|
||||
captureRemaining = [childNode]; // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing
|
||||
}
|
||||
} while (childNode = childNode.nextSibling);
|
||||
}
|
||||
return captureRemaining;
|
||||
}
|
||||
|
||||
ko.virtualElements = {
|
||||
allowedBindings: {},
|
||||
|
||||
|
|
Loading…
Reference in a new issue