From 59b32241bf4aea88e7017e1ae25f131ec4bb2139 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Tue, 9 Aug 2016 22:52:30 +0300 Subject: [PATCH] More fixes for scrutinizer-ci --- dev/External/ko.js | 44 ++++++++--------------- dev/Promises/AbstractAjax.js | 15 ++++---- dev/Promises/User/Populator.js | 33 ++++++----------- dev/Remote/AbstractAjax.js | 3 +- dev/View/Admin/Settings/Menu.js | 13 ++++--- dev/View/Popup/AddOpenPgpKey.js | 18 +++++----- dev/View/Popup/Compose.js | 11 +++--- dev/View/Popup/ComposeOpenPgp.js | 14 +++----- dev/View/Popup/FolderSystem.js | 54 +++++++++++++--------------- dev/View/Popup/MessageOpenPgp.js | 6 ++-- dev/View/Popup/NewOpenPgpKey.js | 8 ++--- dev/View/User/MailBox/FolderList.js | 20 ++++------- dev/View/User/MailBox/MessageList.js | 37 +++++++------------ dev/View/User/MailBox/MessageView.js | 24 ++++--------- dev/View/User/Settings/Menu.js | 6 ++-- webpack.config.js | 1 - 16 files changed, 116 insertions(+), 191 deletions(-) diff --git a/dev/External/ko.js b/dev/External/ko.js index 424f24180..b2b8b7584 100644 --- a/dev/External/ko.js +++ b/dev/External/ko.js @@ -4,7 +4,6 @@ var ko = window.ko, _ = require('_'), $ = require('$'), - JSON = require('JSON'), Opentip = require('Opentip'), Pikaday = require('pikaday'), @@ -83,10 +82,10 @@ ko.bindingHandlers.editor = { ko.bindingHandlers.json = { init: function(oElement, fValueAccessor) { - $(oElement).text(JSON.stringify(ko.unwrap(fValueAccessor()))); + $(oElement).text(window.JSON.stringify(ko.unwrap(fValueAccessor()))); }, update: function(oElement, fValueAccessor) { - $(oElement).text(JSON.stringify(ko.unwrap(fValueAccessor()))); + $(oElement).text(window.JSON.stringify(ko.unwrap(fValueAccessor()))); } }; @@ -198,8 +197,6 @@ ko.bindingHandlers.tooltip = { update: function(oElement, fValueAccessor) { var - bi18n = true, - sValue = '', $oEl = $(oElement), fValue = fValueAccessor(), bMobile = 'on' === ($oEl.data('tooltip-mobile') || 'off'), @@ -207,13 +204,11 @@ ko.bindingHandlers.tooltip = { if ((!Globals.bMobileDevice || bMobile) && oElement.__opentip) { - bi18n = 'on' === ($oEl.data('tooltip-i18n') || 'on'); - sValue = !ko.isObservable(fValue) && _.isFunction(fValue) ? fValue() : ko.unwrap(fValue); - + var sValue = !ko.isObservable(fValue) && _.isFunction(fValue) ? fValue() : ko.unwrap(fValue); if (sValue) { - oElement.__opentip.setContent( - bi18n ? require('Common/Translator').i18n(sValue) : sValue); + var i18n = 'on' === ($oEl.data('tooltip-i18n') || 'on'); + oElement.__opentip.setContent(i18n ? require('Common/Translator').i18n(sValue) : sValue); oElement.__opentip.activate(); } else @@ -636,8 +631,6 @@ ko.bindingHandlers.draggable = { $(sDroppableSelector).each(function() { var - moveUp = null, - moveDown = null, $this = $(this), oOffset = $this.offset(), bottomPos = oOffset.top + $this.height(); @@ -649,7 +642,7 @@ ko.bindingHandlers.draggable = { { if (oEvent.pageY >= bottomPos - iTriggerZone && oEvent.pageY <= bottomPos) { - moveUp = function() { + var moveUp = function() { $this.scrollTop($this.scrollTop() + iScrollSpeed); Utils.windowResize(); }; @@ -660,7 +653,7 @@ ko.bindingHandlers.draggable = { if (oEvent.pageY >= oOffset.top && oEvent.pageY <= oOffset.top + iTriggerZone) { - moveDown = function() { + var moveDown = function() { $this.scrollTop($this.scrollTop() - iScrollSpeed); Utils.windowResize(); }; @@ -869,19 +862,14 @@ ko.bindingHandlers.emailsTags = { 'parseHook': function(aInput) { return _.map(aInput, function(sInputValue) { - - var - sValue = Utils.trim(sInputValue), - oEmail = null; - - if ('' !== sValue) + var value = Utils.trim(sInputValue); + if ('' !== value) { - oEmail = new EmailModel(); - oEmail.mailsoParse(sValue); - return [oEmail.toLine(false), oEmail]; + var email = new EmailModel(); + email.mailsoParse(value); + return [email.toLine(false), email]; } - - return [sValue, null]; + return [value, null]; }); @@ -976,15 +964,13 @@ ko.bindingHandlers.command = { ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click'] .init.apply(oViewModel, Array.prototype.slice.call(arguments)); // eslint-disable-line prefer-rest-params }, - update: function(oElement, fValueAccessor) { var - bResult = true, jqElement = $(oElement), - oCommand = fValueAccessor(); + oCommand = fValueAccessor(), + bResult = oCommand.enabled(); - bResult = oCommand.enabled(); jqElement.toggleClass('command-not-enabled', !bResult); if (bResult) diff --git a/dev/Promises/AbstractAjax.js b/dev/Promises/AbstractAjax.js index d435285b8..5408be03c 100644 --- a/dev/Promises/AbstractAjax.js +++ b/dev/Promises/AbstractAjax.js @@ -56,9 +56,7 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut, var self = this; return new Promise(function(resolve, reject) { - var - oH = null, - iStart = Utils.microtime(); + var iStart = Utils.microtime(); iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : Consts.DEFAULT_AJAX_TIMEOUT; sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString); @@ -72,7 +70,7 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut, self.setTrigger(fTrigger, true); - oH = $.ajax({ + var oH = $.ajax({ type: bPost ? 'POST' : 'GET', url: Links.ajax(sAdditionalGetString), async: true, @@ -81,10 +79,10 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut, timeout: iTimeOut, global: true }).always(function(oData, sTextStatus) { + var bCached = false, - oErrorData = null, - sType = Enums.StorageResultType.Error; + oErrorData = null; if (oData && oData.Time) { @@ -92,6 +90,7 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut, } // backward capability + var sType = Enums.StorageResultType.Error; switch (true) { case 'success' === sTextStatus && oData && oData.Result && sAction === oData.Action: @@ -100,7 +99,9 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut, case 'abort' === sTextStatus && (!oData || !oData.__aborted__): sType = Enums.StorageResultType.Abort; break; - // no default + default: + sType = Enums.StorageResultType.Error; + break; } Plugins.runHook('ajax-default-response', [sAction, diff --git a/dev/Promises/User/Populator.js b/dev/Promises/User/Populator.js index 5fbef1aa4..92970f6dc 100644 --- a/dev/Promises/User/Populator.js +++ b/dev/Promises/User/Populator.js @@ -57,30 +57,20 @@ PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aF { var self = this, - iIndex = 0, - iLen = 0, - oFolder = null, - oCacheFolder = null, bDisplaySpecSetting = FolderStore.displaySpecSetting(), - sFolderFullNameRaw = '', - aSubFolders = [], aList = []; - for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++) - { - oFolder = aFolders[iIndex]; + _.each(aFolders, function(oFolder) { if (oFolder) { - sFolderFullNameRaw = oFolder.FullNameRaw; - - oCacheFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); + var oCacheFolder = Cache.getFolderFromCacheList(oFolder.FullNameRaw); if (!oCacheFolder) { oCacheFolder = FolderModel.newInstanceFromJson(oFolder); if (oCacheFolder) { - Cache.setFolderToCacheList(sFolderFullNameRaw, oCacheFolder); - Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw, oCacheFolder); + Cache.setFolderToCacheList(oFolder.FullNameRaw, oCacheFolder); + Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, oFolder.FullNameRaw, oCacheFolder); } } @@ -115,18 +105,17 @@ PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aF } } - aSubFolders = oFolder.SubFolders; - if (aSubFolders && 'Collection/FolderCollection' === aSubFolders['@Object'] && - aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection'])) + if (oFolder.SubFolders && 'Collection/FolderCollection' === oFolder.SubFolders['@Object'] && + oFolder.SubFolders['@Collection'] && Utils.isArray(oFolder.SubFolders['@Collection'])) { oCacheFolder.subFolders( - this.folderResponseParseRec(sNamespace, aSubFolders['@Collection'], expandedFolders)); + self.folderResponseParseRec(sNamespace, oFolder.SubFolders['@Collection'], expandedFolders)); } aList.push(oCacheFolder); } } - } + }); return aList; }; @@ -137,7 +126,6 @@ PromisesUserPopulator.prototype.foldersList = function(oData) oData['@Collection'] && Utils.isArray(oData['@Collection'])) { var - folderList = [], expandedFolders = Local.get(Enums.ClientSideKeyName.ExpandedFolders), iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')), iC = Utils.pInt(oData.CountRec); @@ -145,8 +133,9 @@ PromisesUserPopulator.prototype.foldersList = function(oData) iLimit = 100 < iLimit ? 100 : (10 > iLimit ? 10 : iLimit); FolderStore.displaySpecSetting(0 >= iC || iLimit < iC); - folderList = this.folderResponseParseRec(Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders); - FolderStore.folderList(folderList); // @todo optimization required + + FolderStore.folderList(this.folderResponseParseRec( + Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders)); // @todo optimization required } }; diff --git a/dev/Remote/AbstractAjax.js b/dev/Remote/AbstractAjax.js index 7e434e18d..9888a2dd5 100644 --- a/dev/Remote/AbstractAjax.js +++ b/dev/Remote/AbstractAjax.js @@ -135,7 +135,6 @@ AbstractAjaxRemote.prototype.ajaxRequest = function(fResultCallback, oParameters bPost = '' === sGetAdd, oHeaders = {}, iStart = (new window.Date()).getTime(), - oDefAjax = null, sAction = ''; oParameters = oParameters || {}; @@ -165,7 +164,7 @@ AbstractAjaxRemote.prototype.ajaxRequest = function(fResultCallback, oParameters oParameters.XToken = Settings.appSettingsGet('token'); } - oDefAjax = $.ajax({ + var oDefAjax = $.ajax({ type: bPost ? 'POST' : 'GET', url: Links.ajax(sGetAdd), async: true, diff --git a/dev/View/Admin/Settings/Menu.js b/dev/View/Admin/Settings/Menu.js index 1b3d3a160..caa07fd1d 100644 --- a/dev/View/Admin/Settings/Menu.js +++ b/dev/View/Admin/Settings/Menu.js @@ -41,23 +41,22 @@ MenuSettingsAdminView.prototype.onBuild = function(oDom) var sH = '', - iIndex = -1, bUp = handler && 'up' === handler.shortcut, $items = $('.b-admin-menu .e-item', oDom); if (event && $items.length) { - iIndex = $items.index($items.filter('.selected')); - if (bUp && 0 < iIndex) + var index = $items.index($items.filter('.selected')); + if (bUp && 0 < index) { - iIndex -= 1; + index -= 1; } - else if (!bUp && iIndex < $items.length - 1) + else if (!bUp && index < $items.length - 1) { - iIndex += 1; + index += 1; } - sH = $items.eq(iIndex).attr('href'); + sH = $items.eq(index).attr('href'); if (sH) { kn.setHash(sH, false, true); diff --git a/dev/View/Popup/AddOpenPgpKey.js b/dev/View/Popup/AddOpenPgpKey.js index 1f82ed6af..9a78dc337 100644 --- a/dev/View/Popup/AddOpenPgpKey.js +++ b/dev/View/Popup/AddOpenPgpKey.js @@ -30,27 +30,29 @@ function AddOpenPgpKeyPopupView() var count = 30, - match = null, - key = Utils.trim(this.key()), + keyTrimmed = Utils.trim(this.key()), reg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi, - openpgpKeyring = PgpStore.openpgpKeyring, - done = false; + openpgpKeyring = PgpStore.openpgpKeyring; - if (/[\n]/.test(key)) + if (/[\n]/.test(keyTrimmed)) { - key = key.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n'); + keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n'); } - this.key.error('' === key); + this.key.error('' === keyTrimmed); if (!openpgpKeyring || this.key.error()) { return false; } + var + done = false, + match = null; + do { - match = reg.exec(key); + match = reg.exec(keyTrimmed); if (match && 0 < count) { if (match[0] && match[1] && match[2] && match[1] === match[2]) diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 15936e6a6..110ee5594 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -5,7 +5,6 @@ var $ = require('$'), ko = require('ko'), key = require('key'), - JSON = require('JSON'), Jua = require('Jua'), Enums = require('Common/Enums'), @@ -1481,7 +1480,7 @@ ComposePopupView.prototype.driveCallback = function(sAccessToken, oData) if (oRequest && oRequest.responseText) { var - oResponse = JSON.parse(oRequest.responseText), + oResponse = window.JSON.parse(oRequest.responseText), fExport = function(oItem, sMimeType, sExt) { if (oItem && oItem.exportLinks) { @@ -1849,12 +1848,10 @@ ComposePopupView.prototype.addMessageAsAttachment = function(oMessage) { if (oMessage) { - var - oAttachment = null, - sTemp = oMessage.subject(); - + var sTemp = oMessage.subject(); sTemp = '.eml' === sTemp.substr(-4).toLowerCase() ? sTemp : sTemp + '.eml'; - oAttachment = new ComposeAttachmentModel( + + var oAttachment = new ComposeAttachmentModel( oMessage.requestHash, sTemp, oMessage.size() ); diff --git a/dev/View/Popup/ComposeOpenPgp.js b/dev/View/Popup/ComposeOpenPgp.js index cb090f600..d2e3603a6 100644 --- a/dev/View/Popup/ComposeOpenPgp.js +++ b/dev/View/Popup/ComposeOpenPgp.js @@ -87,7 +87,6 @@ function ComposeOpenPgpPopupView() var bResult = true, oPrivateKey = null, - aPrivateKeys = [], aPublicKeys = []; this.submitRequest(true); @@ -110,7 +109,7 @@ function ComposeOpenPgpPopupView() if (bResult) { - aPrivateKeys = this.signKey().key.getNativeKeys(); + var aPrivateKeys = this.signKey().key.getNativeKeys(); oPrivateKey = aPrivateKeys[0] || null; try @@ -248,22 +247,19 @@ function ComposeOpenPgpPopupView() var sKeyId = this.selectedPrivateKey(), - oKey = null, oOption = sKeyId ? _.find(this.privateKeysOptions(), function(oItem) { return oItem && sKeyId === oItem.id; }) : null; if (oOption) { - oKey = { + this.signKey({ 'empty': !oOption.key, 'selected': ko.observable(!!oOption.key), 'users': oOption.key.users, 'hash': oOption.key.id.substr(-8).toUpperCase(), 'key': oOption.key - }; - - this.signKey(oKey); + }); } }); @@ -402,7 +398,6 @@ ComposeOpenPgpPopupView.prototype.onShow = function(fCallback, sText, oIdentity, self = this, aRec = [], sEmail = '', - aKeys = [], oEmail = new EmailModel(); this.resultCallback = fCallback; @@ -433,7 +428,8 @@ ComposeOpenPgpPopupView.prototype.onShow = function(fCallback, sText, oIdentity, { sEmail = oIdentity.email(); aRec.unshift(sEmail); - aKeys = PgpStore.findAllPrivateKeysByEmailNotNative(sEmail); + + var aKeys = PgpStore.findAllPrivateKeysByEmailNotNative(sEmail); if (aKeys && aKeys[0]) { this.signKey({ diff --git a/dev/View/Popup/FolderSystem.js b/dev/View/Popup/FolderSystem.js index 0fba7ed56..231a1921e 100644 --- a/dev/View/Popup/FolderSystem.js +++ b/dev/View/Popup/FolderSystem.js @@ -38,45 +38,41 @@ function FolderSystemPopupView() ], null, null, null, null, null, true); }, this); - var - fSaveSystemFolders = null, - fCallback = null; - this.sentFolder = FolderStore.sentFolder; this.draftFolder = FolderStore.draftFolder; this.spamFolder = FolderStore.spamFolder; this.trashFolder = FolderStore.trashFolder; this.archiveFolder = FolderStore.archiveFolder; - fSaveSystemFolders = _.debounce(function() { + var + fSaveSystemFolders = _.debounce(function() { + Settings.settingsSet('SentFolder', FolderStore.sentFolder()); + Settings.settingsSet('DraftFolder', FolderStore.draftFolder()); + Settings.settingsSet('SpamFolder', FolderStore.spamFolder()); + Settings.settingsSet('TrashFolder', FolderStore.trashFolder()); + Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder()); - Settings.settingsSet('SentFolder', FolderStore.sentFolder()); - Settings.settingsSet('DraftFolder', FolderStore.draftFolder()); - Settings.settingsSet('SpamFolder', FolderStore.spamFolder()); - Settings.settingsSet('TrashFolder', FolderStore.trashFolder()); - Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder()); + Remote.saveSystemFolders(Utils.noop, { + 'SentFolder': FolderStore.sentFolder(), + 'DraftFolder': FolderStore.draftFolder(), + 'SpamFolder': FolderStore.spamFolder(), + 'TrashFolder': FolderStore.trashFolder(), + 'ArchiveFolder': FolderStore.archiveFolder(), + 'NullFolder': 'NullFolder' + }); - Remote.saveSystemFolders(Utils.noop, { - 'SentFolder': FolderStore.sentFolder(), - 'DraftFolder': FolderStore.draftFolder(), - 'SpamFolder': FolderStore.spamFolder(), - 'TrashFolder': FolderStore.trashFolder(), - 'ArchiveFolder': FolderStore.archiveFolder(), - 'NullFolder': 'NullFolder' - }); + }, Enums.Magics.Time1s); - }, Enums.Magics.Time1s); + var + fCallback = function() { + Settings.settingsSet('SentFolder', FolderStore.sentFolder()); + Settings.settingsSet('DraftFolder', FolderStore.draftFolder()); + Settings.settingsSet('SpamFolder', FolderStore.spamFolder()); + Settings.settingsSet('TrashFolder', FolderStore.trashFolder()); + Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder()); - fCallback = function() { - - Settings.settingsSet('SentFolder', FolderStore.sentFolder()); - Settings.settingsSet('DraftFolder', FolderStore.draftFolder()); - Settings.settingsSet('SpamFolder', FolderStore.spamFolder()); - Settings.settingsSet('TrashFolder', FolderStore.trashFolder()); - Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder()); - - fSaveSystemFolders(); - }; + fSaveSystemFolders(); + }; FolderStore.sentFolder.subscribe(fCallback); FolderStore.draftFolder.subscribe(fCallback); diff --git a/dev/View/Popup/MessageOpenPgp.js b/dev/View/Popup/MessageOpenPgp.js index d091c4f18..36c984068 100644 --- a/dev/View/Popup/MessageOpenPgp.js +++ b/dev/View/Popup/MessageOpenPgp.js @@ -39,15 +39,13 @@ function MessageOpenPgpPopupView() _.delay(_.bind(function() { - var - oPrivateKeys = [], - oPrivateKey = null; + var oPrivateKey = null; try { if (this.resultCallback && this.selectedKey()) { - oPrivateKeys = this.selectedKey().getNativeKeys(); + var oPrivateKeys = this.selectedKey().getNativeKeys(); oPrivateKey = oPrivateKeys && oPrivateKeys[0] ? oPrivateKeys[0] : null; if (oPrivateKey) diff --git a/dev/View/Popup/NewOpenPgpKey.js b/dev/View/Popup/NewOpenPgpKey.js index 46ab1c875..24c5b340a 100644 --- a/dev/View/Popup/NewOpenPgpKey.js +++ b/dev/View/Popup/NewOpenPgpKey.js @@ -58,17 +58,13 @@ function NewOpenPgpKeyPopupView() _.delay(function() { - var mPromise = false; - try { - mPromise = PgpStore.openpgp.generateKey({ + PgpStore.openpgp.generateKey({ userIds: [oUserId], numBits: Utils.pInt(self.keyBitLength()), passphrase: Utils.trim(self.password()) - }); - - mPromise.then(function(mKeyPair) { + }).then(function(mKeyPair) { self.submitRequest(false); diff --git a/dev/View/User/MailBox/FolderList.js b/dev/View/User/MailBox/FolderList.js index 26668db2b..0d4fe32e8 100644 --- a/dev/View/User/MailBox/FolderList.js +++ b/dev/View/User/MailBox/FolderList.js @@ -118,13 +118,10 @@ FolderListMailBoxUserView.prototype.onBuild = function(oDom) oDom .on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function(oEvent) { - var - oFolder = ko.dataFor(this), - bCollapsed = false; - + var oFolder = ko.dataFor(this); if (oFolder && oEvent) { - bCollapsed = oFolder.collapsed(); + var bCollapsed = oFolder.collapsed(); require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed); oFolder.collapsed(!bCollapsed); @@ -142,13 +139,12 @@ FolderListMailBoxUserView.prototype.onBuild = function(oDom) key('up, down', Enums.KeyState.FolderList, function(event, handler) { var - iIndex = -1, 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) { - iIndex = $items.index($items.filter('.focused')); + var iIndex = $items.index($items.filter('.focused')); if (-1 < iIndex) { $items.eq(iIndex).removeClass('focused'); @@ -182,17 +178,13 @@ FolderListMailBoxUserView.prototype.onBuild = function(oDom) }); key('space', Enums.KeyState.FolderList, function() { - var - bCollapsed = true, - oFolder = null, - $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom); - + var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom); if ($items.length && $items[0]) { - oFolder = ko.dataFor($items[0]); + var oFolder = ko.dataFor($items[0]); if (oFolder) { - bCollapsed = oFolder.collapsed(); + var bCollapsed = oFolder.collapsed(); require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed); oFolder.collapsed(!bCollapsed); } diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index eeb5c2475..fd524cbac 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -538,14 +538,9 @@ MessageListMailBoxUserView.prototype.setAction = function(sFolderFullNameRaw, mU */ MessageListMailBoxUserView.prototype.setActionForAll = function(sFolderFullNameRaw, iSetAction) { - var - oFolder = null, - aMessages = MessageStore.messageList(); - if ('' !== sFolderFullNameRaw) { - oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); - + var oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); if (oFolder) { switch (iSetAction) @@ -554,7 +549,7 @@ MessageListMailBoxUserView.prototype.setActionForAll = function(sFolderFullNameR oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); if (oFolder) { - _.each(aMessages, function(oMessage) { + _.each(MessageStore.messageList(), function(oMessage) { oMessage.unseen(false); }); @@ -568,7 +563,7 @@ MessageListMailBoxUserView.prototype.setActionForAll = function(sFolderFullNameR oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); if (oFolder) { - _.each(aMessages, function(oMessage) { + _.each(MessageStore.messageList(), function(oMessage) { oMessage.unseen(true); }); @@ -644,18 +639,15 @@ MessageListMailBoxUserView.prototype.flagMessages = function(oCurrentMessage) MessageListMailBoxUserView.prototype.flagMessagesFast = function(bFlag) { - var - aChecked = this.messageListCheckedOrSelected(), - aFlagged = []; - + var aChecked = this.messageListCheckedOrSelected(); if (0 < aChecked.length) { - aFlagged = _.filter(aChecked, function(oMessage) { - return oMessage.flagged(); - }); - if (Utils.isUnd(bFlag)) { + var aFlagged = _.filter(aChecked, function(oMessage) { + return oMessage.flagged(); + }); + this.setAction(aChecked[0].folderFullNameRaw, true, aChecked.length === aFlagged.length ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked); } @@ -669,18 +661,15 @@ MessageListMailBoxUserView.prototype.flagMessagesFast = function(bFlag) MessageListMailBoxUserView.prototype.seenMessagesFast = function(bSeen) { - var - aChecked = this.messageListCheckedOrSelected(), - aUnseen = []; - + var aChecked = this.messageListCheckedOrSelected(); if (0 < aChecked.length) { - aUnseen = _.filter(aChecked, function(oMessage) { - return oMessage.unseen(); - }); - if (Utils.isUnd(bSeen)) { + var aUnseen = _.filter(aChecked, function(oMessage) { + return oMessage.unseen(); + }); + this.setAction(aChecked[0].folderFullNameRaw, true, 0 < aUnseen.length ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked); } diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 6bcd86cba..1935c25d7 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -302,25 +302,15 @@ function MessageViewMailBoxUserView() }, this); this.viewFromDkimStatusIconClass = ko.computed(function() { - - var sResult = 'icon-none iconcolor-display-none'; -// var sResult = 'icon-warning-alt iconcolor-grey'; switch (this.viewFromDkimData()[0]) { case 'none': - break; + return 'icon-none iconcolor-display-none'; case 'pass': - sResult = 'icon-ok iconcolor-green'; -// sResult = 'icon-warning-alt iconcolor-green'; - break; + return 'icon-ok iconcolor-green'; default: - sResult = 'icon-warning-alt iconcolor-red'; - break; - // no default + return 'icon-warning-alt iconcolor-red'; } - - return sResult; - }, this); this.viewFromDkimStatusTitle = ko.computed(function() { @@ -465,7 +455,6 @@ MessageViewMailBoxUserView.prototype.detectDomBackgroundColor = function(oDom) var iLimit = 5, sResult = '', - aC = null, fFindDom = function(oInputDom) { var children = oInputDom ? oInputDom.children() : null; return (children && 1 === children.length && children.is('table,div,center')) ? children : null; @@ -486,7 +475,7 @@ MessageViewMailBoxUserView.prototype.detectDomBackgroundColor = function(oDom) if (oDom && 1 === oDom.length) { - aC = oDom; + var aC = oDom; while ('' === sResult) { iLimit -= 1; @@ -643,8 +632,7 @@ MessageViewMailBoxUserView.prototype.onBuild = function(oDom) { var self = this, - oScript = null, -// sErrorMessage = Translator.i18n('PREVIEW_POPUP/IMAGE_ERROR'), +// sErrorMessage = Translator.i18n('PREVIEW_POPUP/IMAGE_ERROR'), fCheckHeaderHeight = _.bind(this.checkHeaderHeight, this); this.oDom = oDom; @@ -675,7 +663,7 @@ MessageViewMailBoxUserView.prototype.onBuild = function(oDom) if (this.dropboxEnabled() && this.dropboxApiKey() && !window.Dropbox) { - oScript = window.document.createElement('script'); + var oScript = window.document.createElement('script'); oScript.type = 'text/javascript'; oScript.src = 'https://www.dropbox.com/static/api/2/dropins.js'; $(oScript).attr('id', 'dropboxjs').attr('data-app-key', self.dropboxApiKey()); diff --git a/dev/View/User/Settings/Menu.js b/dev/View/User/Settings/Menu.js index 39f20f9ae..a475991ca 100644 --- a/dev/View/User/Settings/Menu.js +++ b/dev/View/User/Settings/Menu.js @@ -47,14 +47,12 @@ MenuSettingsUserView.prototype.onBuild = function(oDom) key('up, down', Enums.KeyState.Settings, _.throttle(function(event, handler) { var - sH = '', - iIndex = -1, bUp = handler && 'up' === handler.shortcut, $items = $('.b-settings-menu .e-item', oDom); if (event && $items.length) { - iIndex = $items.index($items.filter('.selected')); + var iIndex = $items.index($items.filter('.selected')); if (bUp && 0 < iIndex) { iIndex -= 1; @@ -64,7 +62,7 @@ MenuSettingsUserView.prototype.onBuild = function(oDom) iIndex += 1; } - sH = $items.eq(iIndex).attr('href'); + var sH = $items.eq(iIndex).attr('href'); if (sH) { kn.setHash(sH, false, true); diff --git a/webpack.config.js b/webpack.config.js index a2b72d19b..c578bdee6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -55,7 +55,6 @@ module.exports = { }, externals: { 'window': 'window', - 'JSON': 'window.JSON', 'progressJs': 'window.progressJs', 'moment': 'window.moment', 'ifvisible': 'window.ifvisible',