From fb2e492ce8ed0b3042d58b5f6ee87aaf77ca9129 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Tue, 5 Jul 2016 22:52:52 +0300 Subject: [PATCH] More scrict rules --- .eslintrc.js | 6 +++- dev/Common/Enums.jsx | 40 ++++++++++++++++++++++++ dev/Component/TextArea.jsx | 4 ++- dev/Knoin/Knoin.js | 1 - dev/Model/Message.js | 1 - dev/Remote/User/Ajax.js | 1 - dev/Settings/User/General.js | 12 +++---- dev/Stores/User/Message.js | 10 +++--- dev/Stores/User/Notification.js | 2 +- dev/Stores/User/Settings.js | 2 +- dev/View/Admin/Login.js | 2 +- dev/View/Admin/Settings/Menu.js | 3 +- dev/View/Popup/Compose.js | 12 +++---- dev/View/Popup/ComposeOpenPgp.js | 2 +- dev/View/Popup/Contacts.js | 14 ++++----- dev/View/Popup/Domain.js | 27 +++++++--------- dev/View/Popup/Filter.js | 1 - dev/View/Popup/FolderSystem.js | 2 +- dev/View/Popup/KeyboardShortcutsHelp.js | 2 +- dev/View/Popup/MessageOpenPgp.js | 2 +- dev/View/Popup/NewOpenPgpKey.js | 7 +++-- dev/View/Popup/Plugin.js | 2 +- dev/View/Popup/TwoFactorConfiguration.js | 8 ++--- dev/View/User/AbstractSystemDropDown.js | 2 +- dev/View/User/Login.js | 6 ++-- dev/View/User/MailBox/FolderList.js | 8 ++--- dev/View/User/MailBox/MessageList.js | 8 ++--- dev/View/User/MailBox/MessageView.js | 20 ++++++------ dev/boot.jsx | 6 ++-- package.json | 2 +- 30 files changed, 126 insertions(+), 89 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 66f76a94f..35d74d3f2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -210,7 +210,11 @@ module.exports = { // 'no-lonely-if': 2, // 'no-mixed-operators': 2, 'no-mixed-spaces-and-tabs': 2, - 'no-multiple-empty-lines': 2, + 'no-multiple-empty-lines': [2, { + "max": 1, + "maxEOF": 1, + "maxBOF": 1 + }], // 'no-negated-condition': 2, // 'no-nested-ternary': 2, 'no-new-object': 2, diff --git a/dev/Common/Enums.jsx b/dev/Common/Enums.jsx index 2cc74877f..b63b51913 100644 --- a/dev/Common/Enums.jsx +++ b/dev/Common/Enums.jsx @@ -414,6 +414,46 @@ export const ContactPropertyType = { 'Custom': 250 }; +/** + * @enum {number} + */ +export const Magics = { + 'EventWhichMouseMiddle': 3, + 'ifvisibleIdle10s': 10, + + 'BitLength2048': 2048, + 'BitLength1024': 1024, + + 'Size50px': 50, + 'Size20px': 20, + 'Size1px': 1, + + 'Time1m': 60000, + 'Time30s': 30000, + 'Time7s': 7000, + 'Time5s': 5000, + 'Time3s': 3000, + 'Time1s': 1000, + 'Time500ms': 500, + 'Time350ms': 350, + 'Time250ms': 250, + 'Time200ms': 200, + 'Time100ms': 100, + 'Time50ms': 50, + 'Time20ms': 20 +}; + +/** + * @enum {number} + */ +export const Ports = { + 'Imap': 143, + 'ImapSsl': 993, + 'Smtp': 25, + 'SmtpSsl': 465, + 'SmtpStartTls': 587 +}; + /** * @enum {number} */ diff --git a/dev/Component/TextArea.jsx b/dev/Component/TextArea.jsx index d0ea2b8f2..99ed82498 100644 --- a/dev/Component/TextArea.jsx +++ b/dev/Component/TextArea.jsx @@ -3,6 +3,8 @@ import {isUnd} from 'Common/Utils'; import {componentExportHelper} from 'Component/Abstract'; import {AbstractInput} from 'Component/AbstractInput'; +const DEFAULT_ROWS = 5; + class TextAreaComponent extends AbstractInput { /** @@ -13,7 +15,7 @@ class TextAreaComponent extends AbstractInput super(params); - this.rows = params.rows || 5; + this.rows = params.rows || DEFAULT_ROWS; this.spellcheck = isUnd(params.spellcheck) ? false : !!params.spellcheck; } } diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index a8b639bc3..3d5b17fd0 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -439,7 +439,6 @@ Knoin.prototype.startScreens = function(aScreensClasses) }, this); - _.each(this.oScreens, function(oScreen) { if (oScreen && !oScreen.__started && oScreen.__start) { diff --git a/dev/Model/Message.js b/dev/Model/Message.js index f0acdcf9f..53571aa80 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -592,7 +592,6 @@ MessageModel.prototype.findAttachmentByContentLocation = function(sContentLocati return oResult || null; }; - /** * @returns {string} */ diff --git a/dev/Remote/User/Ajax.js b/dev/Remote/User/Ajax.js index 708621557..61322c146 100644 --- a/dev/Remote/User/Ajax.js +++ b/dev/Remote/User/Ajax.js @@ -585,7 +585,6 @@ RemoteUserAjax.prototype.saveMessage = function(fCallback, sIdentityID, sMessage }, Consts.SAVE_MESSAGE_AJAX_TIMEOUT); }; - /** * @param {?Function} fCallback * @param {string} sMessageFolder diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index 4e4b12ae7..4a958875a 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -50,7 +50,7 @@ function GeneralUserSettings() return Utils.convertLangName(this.language()); }, this); - this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100}); + this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': Enums.Magics.Time100ms}); this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.editorDefaultTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); @@ -121,7 +121,7 @@ GeneralUserSettings.prototype.onBuild = function() self.languageTrigger(iSaveSettingsStep); _.delay(function() { self.languageTrigger(Enums.SaveSettingsStep.Idle); - }, 1000); + }, Enums.Magics.Time1s); }; }; @@ -163,7 +163,7 @@ GeneralUserSettings.prototype.onBuild = function() Remote.saveSettings(null, { 'DesktopNotifications': bValue ? '1' : '0' }); - }, 3000); + }, Enums.Magics.Time3s); }); self.enableSoundNotification.subscribe(function(bValue) { @@ -171,7 +171,7 @@ GeneralUserSettings.prototype.onBuild = function() Remote.saveSettings(null, { 'SoundNotification': bValue ? '1' : '0' }); - }, 3000); + }, Enums.Magics.Time3s); }); self.replySameFolder.subscribe(function(bValue) { @@ -179,7 +179,7 @@ GeneralUserSettings.prototype.onBuild = function() Remote.saveSettings(null, { 'ReplySameFolder': bValue ? '1' : '0' }); - }, 3000); + }, Enums.Magics.Time3s); }); self.useThreads.subscribe(function(bValue) { @@ -206,7 +206,7 @@ GeneralUserSettings.prototype.onBuild = function() }); }); - }, 50); + }, Enums.Magics.Time50ms); }; GeneralUserSettings.prototype.onShow = function() diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 501b5d4b7..e95e4851f 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -70,7 +70,7 @@ function MessageUserStore() return this.messageCurrentLoading(); }, this); - this.messageLoadingThrottle = ko.observable(false).extend({'throttle': 50}); + this.messageLoadingThrottle = ko.observable(false).extend({'throttle': Enums.Magics.Time50ms}); this.messageFullScreenMode = ko.observable(false); @@ -82,7 +82,7 @@ function MessageUserStore() this.onMessageResponse = _.bind(this.onMessageResponse, this); - this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, 1000 * 30); + this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, Enums.Magics.Time30s); } MessageUserStore.prototype.computers = function() @@ -174,7 +174,7 @@ MessageUserStore.prototype.subscribers = function() oItem.newForAnimation(false); } }); - }, 500)); + }, Enums.Magics.Time500ms)); this.message.subscribe(function(oMessage) { @@ -240,7 +240,7 @@ MessageUserStore.prototype.purgeMessageBodyCache = function() { _.delay(function() { oMessagesDom.find('.rl-cache-purge').remove(); - }, 300); + }, Enums.Magics.Time350ms); } } } @@ -393,7 +393,7 @@ MessageUserStore.prototype.removeMessagesFromList = function( _.each(aMessages, function(item) { self.messageList.remove(item); }); - }, 400); + }, Enums.Magics.Time350ms); } } diff --git a/dev/Stores/User/Notification.js b/dev/Stores/User/Notification.js index 88db3459f..360dc3ce9 100644 --- a/dev/Stores/User/Notification.js +++ b/dev/Stores/User/Notification.js @@ -198,7 +198,7 @@ NotificationUserStore.prototype.displayDesktopNotification = function(sImageSrc, oLocalNotifications.close(); } }; - }(oNotification)), 7000); + }(oNotification)), Enums.Magics.Time7s); } } }; diff --git a/dev/Stores/User/Settings.js b/dev/Stores/User/Settings.js index 6b87cb8aa..96f285c00 100644 --- a/dev/Stores/User/Settings.js +++ b/dev/Stores/User/Settings.js @@ -83,7 +83,7 @@ SettingsUserStore.prototype.populate = function() { self.iAutoLogoutTimer = window.setTimeout(function() { Events.pub('rl.auto-logout'); - }, self.autoLogout() * 1000 * 60); + }, self.autoLogout() * Enums.Magics.Time1m); } }); diff --git a/dev/View/Admin/Login.js b/dev/View/Admin/Login.js index 6d21ca152..3def3fb56 100644 --- a/dev/View/Admin/Login.js +++ b/dev/View/Admin/Login.js @@ -119,7 +119,7 @@ LoginAdminView.prototype.onShow = function() _.delay(_.bind(function() { this.loginFocus(true); - }, this), 100); + }, this), Enums.Magics.Time100ms); }; diff --git a/dev/View/Admin/Settings/Menu.js b/dev/View/Admin/Settings/Menu.js index 19e9b0d8e..f78eb5995 100644 --- a/dev/View/Admin/Settings/Menu.js +++ b/dev/View/Admin/Settings/Menu.js @@ -3,6 +3,7 @@ var _ = require('_'), Globals = require('Common/Globals'), + Enums = require('Common/Enums'), kn = require('Knoin/Knoin'), AbstractView = require('Knoin/AbstractView'); @@ -61,7 +62,7 @@ MenuSettingsAdminView.prototype.onBuild = function(oDom) } } - }, 200)); + }, Enums.Magics.Time200ms)); }; module.exports = MenuSettingsAdminView; diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 93e6968a3..bb15b17f5 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -519,7 +519,7 @@ function ComposePopupView() _.delay(function() { kn.showScreenPopup(require('View/Popup/Contacts'), [true, self.sLastFocusedField]); - }, 200); + }, Enums.Magics.Time200ms); } }, function() { @@ -586,7 +586,7 @@ function ComposePopupView() this.bDisabeCloseOnEsc = true; this.sDefaultKeyScope = Enums.KeyState.Compose; - this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200); + this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), Enums.Magics.Time200ms); this.emailsSource = _.bind(this.emailsSource, this); this.autosaveFunction = _.bind(this.autosaveFunction, this); @@ -613,7 +613,7 @@ ComposePopupView.prototype.autosaveFunction = function() ComposePopupView.prototype.autosaveStart = function() { window.clearTimeout(this.iTimer); - this.iTimer = window.setTimeout(this.autosaveFunction, 1000 * 60 * 1); + this.iTimer = window.setTimeout(this.autosaveFunction, Enums.Magics.Time1m); }; ComposePopupView.prototype.autosaveStop = function() @@ -1361,7 +1361,7 @@ ComposePopupView.prototype.setFocusInPopup = function() } } - }, 100); + }, Enums.Magics.Time100ms); } }; @@ -1451,7 +1451,7 @@ ComposePopupView.prototype.onBuild = function() }); Events.sub('window.resize.real', this.resizerTrigger); - Events.sub('window.resize.real', _.debounce(this.resizerTrigger, 50)); + Events.sub('window.resize.real', _.debounce(this.resizerTrigger, Enums.Magics.Time50ms)); if (this.dropboxEnabled() && this.dropboxApiKey() && !window.Dropbox) { @@ -1478,7 +1478,7 @@ ComposePopupView.prototype.onBuild = function() { self.oEditor.resize(); } - }, 5000); + }, Enums.Magics.Time5s); }; ComposePopupView.prototype.driveCallback = function(sAccessToken, oData) diff --git a/dev/View/Popup/ComposeOpenPgp.js b/dev/View/Popup/ComposeOpenPgp.js index da17ee8c4..4a3fcd7bd 100644 --- a/dev/View/Popup/ComposeOpenPgp.js +++ b/dev/View/Popup/ComposeOpenPgp.js @@ -231,7 +231,7 @@ function ComposeOpenPgpPopupView() self.submitRequest(false); - }, 10); + }, Enums.Magics.Time20ms); } else { diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index d68a95d98..e4f733e6a 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -290,7 +290,7 @@ function ContactsPopupView() _.delay(function() { kn.showScreenPopup(require('View/Popup/Compose'), [Enums.ComposeType.Empty, null, aToEmails, aCcEmails, aBccEmails]); - }, 200); + }, Enums.Magics.Time200ms); } return true; @@ -338,7 +338,7 @@ function ContactsPopupView() _.delay(function() { self.viewSaveTrigger(bRes ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult); - }, 300); + }, Enums.Magics.Time350ms); if (bRes) { @@ -346,7 +346,7 @@ function ContactsPopupView() _.delay(function() { self.viewSaveTrigger(Enums.SaveSettingsStep.Idle); - }, 1000); + }, Enums.Magics.Time1s); } }, sRequestUid, this.viewID(), aProperties); @@ -549,13 +549,11 @@ ContactsPopupView.prototype.removeCheckedOrSelectedContactsFromList = function() } _.delay(function() { - _.each(aContacts, function(oContact) { oKoContacts.remove(oContact); Utils.delegateRunOnDestroy(oContact); }); - - }, 500); + }, Enums.Magics.Time500ms); } }; @@ -578,7 +576,7 @@ ContactsPopupView.prototype.deleteSelectedContacts = function() */ ContactsPopupView.prototype.deleteResponse = function(sResult, oData) { - if (500 < (Enums.StorageResultType.Success === sResult && oData && oData.Time ? Utils.pInt(oData.Time) : 0)) + if (Enums.Magics.Time500ms < (Enums.StorageResultType.Success === sResult && oData && oData.Time ? Utils.pInt(oData.Time) : 0)) { this.reloadContactList(this.bDropPageAfterDelete); } @@ -587,7 +585,7 @@ ContactsPopupView.prototype.deleteResponse = function(sResult, oData) var self = this; _.delay(function() { self.reloadContactList(self.bDropPageAfterDelete); - }, 500); + }, Enums.Magics.Time500ms); } }; diff --git a/dev/View/Popup/Domain.js b/dev/View/Popup/Domain.js index 69302d5a5..4d016da3d 100644 --- a/dev/View/Popup/Domain.js +++ b/dev/View/Popup/Domain.js @@ -248,19 +248,18 @@ function DomainPopupView() if (this.enableSmartPorts()) { var iPort = Utils.pInt(this.imapPort()); - sValue = Utils.pString(sValue); - switch (sValue) + switch (Utils.pString(sValue)) { case '0': - if (993 === iPort) + if (Enums.Ports.ImapSsl === iPort) { - this.imapPort('143'); + this.imapPort(Utils.pString(Enums.Ports.Imap)); } break; case '1': - if (143 === iPort) + if (Enums.Ports.Imap === iPort) { - this.imapPort('993'); + this.imapPort(Utils.pString(Enums.Ports.ImapSsl)); } break; // no default @@ -272,25 +271,24 @@ function DomainPopupView() if (this.enableSmartPorts()) { var iPort = Utils.pInt(this.smtpPort()); - sValue = Utils.pString(sValue); - switch (sValue) + switch (Utils.pString(sValue)) { case '0': - if (465 === iPort || 587 === iPort) + if (Enums.Ports.SmtpSsl === iPort || Enums.Ports.SmtpStartTls === iPort) { - this.smtpPort('25'); + this.smtpPort(Utils.pString(Enums.Ports.Smtp)); } break; case '1': - if (25 === iPort || 587 === iPort) + if (Enums.Ports.Smtp === iPort || Enums.Ports.SmtpStartTls === iPort) { - this.smtpPort('465'); + this.smtpPort(Utils.pString(Enums.Ports.SmtpSsl)); } break; case '2': - if (25 === iPort || 465 === iPort) + if (Enums.Ports.Smtp === iPort || Enums.Ports.SmtpSsl === iPort) { - this.smtpPort('587'); + this.smtpPort(Utils.pString(Enums.Ports.SmtpStartTls)); } break; // no default @@ -398,7 +396,6 @@ DomainPopupView.prototype.onHide = function() this.sieveSettings(false); }; - DomainPopupView.prototype.onShow = function(oDomain) { this.saving(false); diff --git a/dev/View/Popup/Filter.js b/dev/View/Popup/Filter.js index 58e85639d..772ed8fc6 100644 --- a/dev/View/Popup/Filter.js +++ b/dev/View/Popup/Filter.js @@ -155,7 +155,6 @@ FilterPopupView.prototype.populateOptions = function() ]); }; - FilterPopupView.prototype.removeCondition = function(oConditionToDelete) { if (this.filter()) diff --git a/dev/View/Popup/FolderSystem.js b/dev/View/Popup/FolderSystem.js index 3b0e62b1b..35a07dd6f 100644 --- a/dev/View/Popup/FolderSystem.js +++ b/dev/View/Popup/FolderSystem.js @@ -65,7 +65,7 @@ function FolderSystemPopupView() 'NullFolder': 'NullFolder' }); - }, 1000); + }, Enums.Magics.Time1s); fCallback = function() { diff --git a/dev/View/Popup/KeyboardShortcutsHelp.js b/dev/View/Popup/KeyboardShortcutsHelp.js index e78c79ba6..d20650f32 100644 --- a/dev/View/Popup/KeyboardShortcutsHelp.js +++ b/dev/View/Popup/KeyboardShortcutsHelp.js @@ -54,7 +54,7 @@ KeyboardShortcutsHelpPopupView.prototype.onBuild = function(oDom) return true; - }, 100)); + }, Enums.Magics.Time100ms)); }; module.exports = KeyboardShortcutsHelpPopupView; diff --git a/dev/View/Popup/MessageOpenPgp.js b/dev/View/Popup/MessageOpenPgp.js index 2742d8438..d091c4f18 100644 --- a/dev/View/Popup/MessageOpenPgp.js +++ b/dev/View/Popup/MessageOpenPgp.js @@ -83,7 +83,7 @@ function MessageOpenPgpPopupView() this.cancelCommand(); this.resultCallback(oPrivateKey); - }, this), 100); + }, this), Enums.Magics.Time100ms); }, function() { return !this.submitRequest(); diff --git a/dev/View/Popup/NewOpenPgpKey.js b/dev/View/Popup/NewOpenPgpKey.js index 8d0542fef..bb8bc9257 100644 --- a/dev/View/Popup/NewOpenPgpKey.js +++ b/dev/View/Popup/NewOpenPgpKey.js @@ -3,6 +3,7 @@ var _ = require('_'), ko = require('ko'), + Enums = require('Common/Enums'), Utils = require('Common/Utils'), PgpStore = require('Stores/User/Pgp'), @@ -24,7 +25,7 @@ function NewOpenPgpKeyPopupView() this.name = ko.observable(''); this.password = ko.observable(''); - this.keyBitLength = ko.observable(2048); + this.keyBitLength = ko.observable(Enums.Magics.BitLength2048); this.submitRequest = ko.observable(false); @@ -90,7 +91,7 @@ function NewOpenPgpKeyPopupView() self.submitRequest(false); } - }, 100); + }, Enums.Magics.Time100ms); return true; }); @@ -108,7 +109,7 @@ NewOpenPgpKeyPopupView.prototype.clearPopup = function() this.email(''); this.email.error(false); - this.keyBitLength(2048); + this.keyBitLength(Enums.Magics.BitLength2048); }; NewOpenPgpKeyPopupView.prototype.onShow = function() diff --git a/dev/View/Popup/Plugin.js b/dev/View/Popup/Plugin.js index 4af74f749..d031c0f64 100644 --- a/dev/View/Popup/Plugin.js +++ b/dev/View/Popup/Plugin.js @@ -79,7 +79,7 @@ function PluginPopupView() this.bDisabeCloseOnEsc = true; this.sDefaultKeyScope = Enums.KeyState.All; - this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200); + this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), Enums.Magics.Time200ms); kn.constructorEnd(this); } diff --git a/dev/View/Popup/TwoFactorConfiguration.js b/dev/View/Popup/TwoFactorConfiguration.js index 39fa87342..033de90ed 100644 --- a/dev/View/Popup/TwoFactorConfiguration.js +++ b/dev/View/Popup/TwoFactorConfiguration.js @@ -91,10 +91,9 @@ function TwoFactorConfigurationPopupView() this.viewTwoFactorStatus = ko.computed(function() { Translator.trigger(); - return Translator.i18n( - this.twoFactorStatus() ? - 'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_CONFIGURED_DESC' : - 'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC' + return Translator.i18n(this.twoFactorStatus() ? + 'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_CONFIGURED_DESC' : + 'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC' ); }, this); @@ -111,7 +110,6 @@ function TwoFactorConfigurationPopupView() kn.extendAsViewModel(['View/Popup/TwoFactorConfiguration', 'TwoFactorConfigurationPopupView'], TwoFactorConfigurationPopupView); _.extend(TwoFactorConfigurationPopupView.prototype, AbstractView.prototype); - TwoFactorConfigurationPopupView.prototype.showSecret = function() { this.secreting(true); diff --git a/dev/View/User/AbstractSystemDropDown.js b/dev/View/User/AbstractSystemDropDown.js index d6f3087a5..f23e56776 100644 --- a/dev/View/User/AbstractSystemDropDown.js +++ b/dev/View/User/AbstractSystemDropDown.js @@ -72,7 +72,7 @@ AbstractSystemDropDownUserView.prototype.accountClick = function(oAccount, oEven _.delay(function() { AccountStore.accounts.loading(false); - }, 1000); + }, Enums.Magics.Time1s); } return true; diff --git a/dev/View/User/Login.js b/dev/View/User/Login.js index 8abc6b60e..af60e8e42 100644 --- a/dev/View/User/Login.js +++ b/dev/View/User/Login.js @@ -212,7 +212,7 @@ function LoginUserView() _.delay(function() { self.additionalCode.focused(true); - }, 100); + }, Enums.Magics.Time100ms); } else if (oData.Admin) { @@ -476,7 +476,7 @@ LoginUserView.prototype.onBuild = function() }); - }, 50); + }, Enums.Magics.Time50ms); Utils.triggerAutocompleteInputChange(true); }; @@ -500,7 +500,7 @@ LoginUserView.prototype.selectLanguageOnTab = function(bShift) var self = this; _.delay(function() { self.emailFocus(true); - }, 5); + }, Enums.Magics.Time50ms); return false; } diff --git a/dev/View/User/MailBox/FolderList.js b/dev/View/User/MailBox/FolderList.js index 8533b8baf..851c355d3 100644 --- a/dev/View/User/MailBox/FolderList.js +++ b/dev/View/User/MailBox/FolderList.js @@ -143,7 +143,7 @@ FolderListMailBoxUserView.prototype.onBuild = function(oDom) var iIndex = -1, - iKeyCode = handler && 'up' === handler.shortcut ? 38 : 40, + iKeyCode = handler && 'up' === handler.shortcut ? Enums.EventKeyCode.Up : Enums.EventKeyCode.Down, $items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom); if (event && $items.length) @@ -154,11 +154,11 @@ FolderListMailBoxUserView.prototype.onBuild = function(oDom) $items.eq(iIndex).removeClass('focused'); } - if (38 === iKeyCode && 0 < iIndex) + if (Enums.EventKeyCode.Up === iKeyCode && 0 < iIndex) { iIndex -= 1; } - else if (40 === iKeyCode && iIndex < $items.length - 1) + else if (Enums.EventKeyCode.Down === iKeyCode && iIndex < $items.length - 1) { iIndex += 1; } @@ -220,7 +220,7 @@ FolderListMailBoxUserView.prototype.messagesDropOver = function(oFolder) oFolder.collapsed(false); require('App/User').default.setExpandedFolder(oFolder.fullNameHash, true); Utils.windowResize(); - }, 500); + }, Enums.Magics.Time500ms); } }; diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 0a60d680c..3cd2c80a6 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -429,7 +429,7 @@ MessageListMailBoxUserView.prototype.goToUpUpOrDownDown = function(bUp) self.gotoPage(bUp ? oPrev : oNext); } - }, 350); + }, Enums.Magics.Time350ms); return true; }; @@ -461,7 +461,7 @@ MessageListMailBoxUserView.prototype.searchEnterAction = function() MessageListMailBoxUserView.prototype.printableMessageCountForDeletion = function() { var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length; - return 1 < iCnt ? ' (' + (100 > iCnt ? iCnt : '99+') + ')' : ''; + return 1 < iCnt ? ' (' + (100 > iCnt ? iCnt : '99+') + ')' : ''; // eslint-disable-line no-magic-numbers }; MessageListMailBoxUserView.prototype.cancelSearch = function() @@ -772,7 +772,7 @@ MessageListMailBoxUserView.prototype.onBuild = function(oDom) if (!Globals.bMobileDevice && ifvisible && Settings.capa(Enums.Capa.Prefetch)) { - ifvisible.setIdleDuration(10); + ifvisible.setIdleDuration(Enums.Magics.ifvisibleIdle10s); ifvisible.idle(function() { self.prefetchNextTick(); @@ -980,7 +980,7 @@ MessageListMailBoxUserView.prototype.prefetchNextTick = function() { self.prefetchNextTick(); } - }, 1000); + }, Enums.Magics.Time1s); }, oMessage.folderFullNameRaw, oMessage.uid); } diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 8146040af..83a205507 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -547,7 +547,7 @@ MessageViewMailBoxUserView.prototype.checkHeaderHeight = function() if (this.oHeaderDom) { this.viewBodyTopValue(this.message() ? this.oHeaderDom.height() + - 20 /* padding-(top/bottom): 20px */ + 1 /* borded-bottom: 1px */ : 0); + Enums.Magics.Size20px /* padding-(top/bottom): 20px */ + Enums.Magics.Size1px /* borded-bottom: 1px */ : 0); } }; @@ -661,13 +661,13 @@ MessageViewMailBoxUserView.prototype.onBuild = function(oDom) Events.sub('window.resize', _.throttle(function() { _.delay(fCheckHeaderHeight, 1); - _.delay(fCheckHeaderHeight, 200); - _.delay(fCheckHeaderHeight, 500); - }, 50)); + _.delay(fCheckHeaderHeight, Enums.Magics.Time200ms); + _.delay(fCheckHeaderHeight, Enums.Magics.Time500ms); + }, Enums.Magics.Time50ms)); this.showFullInfo.subscribe(function(value) { Utils.windowResize(); - Utils.windowResize(250); + Utils.windowResize(Enums.Magics.Time200ms); Local.set(Enums.ClientSideKeyName.MessageHeaderFullInfo, value ? '1' : '0'); }); @@ -695,7 +695,7 @@ MessageViewMailBoxUserView.prototype.onBuild = function(oDom) oDom .on('click', 'a', function(oEvent) { // setup maito protocol - return !(!!oEvent && 3 !== oEvent.which && Utils.mailToHelper( + return !(!!oEvent && Enums.Magics.EventWhichMouseMiddle !== oEvent.which && Utils.mailToHelper( $(this).attr('href'), Settings.capa(Enums.Capa.Composer) ? require('View/Popup/Compose') : null )); }) @@ -1033,11 +1033,11 @@ MessageViewMailBoxUserView.prototype.scrollMessageToTop = function() { if (this.oMessageScrollerDom) { - if (50 < this.oMessageScrollerDom.scrollTop()) + if (Enums.Size50px < this.oMessageScrollerDom.scrollTop()) { this.oMessageScrollerDom - .scrollTop(50) - .animate({'scrollTop': 0}, 200); + .scrollTop(Enums.Size50px) + .animate({'scrollTop': 0}, Enums.Time200ms); } else { @@ -1192,7 +1192,7 @@ MessageViewMailBoxUserView.prototype.showImages = function(oMessage) MessageViewMailBoxUserView.prototype.printableCheckedMessageCount = function() { var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length; - return 0 < iCnt ? (100 > iCnt ? iCnt : '99+') : ''; + return 0 < iCnt ? (100 > iCnt ? iCnt : '99+') : ''; // eslint-disable-line no-magic-numbers }; /** diff --git a/dev/boot.jsx b/dev/boot.jsx index d12ed58b8..5880021ec 100644 --- a/dev/boot.jsx +++ b/dev/boot.jsx @@ -2,12 +2,12 @@ import window from 'window'; import {Promise} from 'es6-promise-polyfill/promise.js'; -import {jassl} from 'jassl'; import {progressJs} from '../vendors/progress.js/src/progress.js'; +import {jassl} from 'jassl'; +window.jassl = jassl; window.Promise = window.Promise || Promise; window.progressJs = window.progressJs || progressJs(); -window.jassl = jassl; window.progressJs.onbeforeend(() => { const _$ = window.$; @@ -16,7 +16,7 @@ window.progressJs.onbeforeend(() => { _$('.progressjs-container').hide(); window.setTimeout(() => { _$('.progressjs-container').remove(); - }, 200); + }, 200); // eslint-disable-line no-magic-numbers } }); diff --git a/package.json b/package.json index 077a37e02..c2bcc7965 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,6 @@ "pikaday": "^1.4.0", "raw-loader": "^0.5.1", "rimraf": "*", - "webpack": "2.1.0-beta.13" + "webpack": "^2.1.0-beta.15" } }