mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Code refactoring
This commit is contained in:
parent
345e7c58af
commit
8cf8b94d39
103 changed files with 664 additions and 659 deletions
|
|
@ -1,79 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function (App) {
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Plugins = require('Common/Plugins'),
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
|
||||
EmailModel = require('Model/Email')
|
||||
;
|
||||
|
||||
Globals.__APP__ = App;
|
||||
|
||||
Globals.$win
|
||||
.keydown(Utils.killCtrlAandS)
|
||||
.keyup(Utils.killCtrlAandS)
|
||||
.unload(function () {
|
||||
Globals.bUnload = true;
|
||||
})
|
||||
;
|
||||
|
||||
Globals.$html
|
||||
.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile')
|
||||
.on('click.dropdown.data-api', function () {
|
||||
Utils.detectDropdownVisibility();
|
||||
})
|
||||
;
|
||||
|
||||
// export
|
||||
window['rl'] = window['rl'] || {};
|
||||
window['rl']['addHook'] = _.bind(Plugins.addHook, Plugins);
|
||||
window['rl']['settingsGet'] = _.bind(Plugins.mainSettingsGet, Plugins);
|
||||
window['rl']['remoteRequest'] = _.bind(Plugins.remoteRequest, Plugins);
|
||||
window['rl']['pluginSettingsGet'] = _.bind(Plugins.settingsGet, Plugins);
|
||||
window['rl']['createCommand'] = Utils.createCommand;
|
||||
|
||||
window['rl']['EmailModel'] = EmailModel;
|
||||
window['rl']['Enums'] = Enums;
|
||||
|
||||
window['__APP_BOOT'] = function (fCall) {
|
||||
|
||||
$(function () {
|
||||
|
||||
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
|
||||
{
|
||||
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
App.bootstart();
|
||||
|
||||
Globals.$html
|
||||
.removeClass('no-js rl-booted-trigger')
|
||||
.addClass('rl-booted')
|
||||
;
|
||||
|
||||
}, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
fCall(false);
|
||||
}
|
||||
|
||||
window['__APP_BOOT'] = null;
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}());
|
||||
|
|
@ -22,9 +22,9 @@
|
|||
|
||||
Local = require('Storage/Local'),
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/App/Data'),
|
||||
Cache = require('Storage/App/Cache'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
Data = require('Storage/User/Data'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
Remote = require('Storage/User/Remote'),
|
||||
|
||||
EmailModel = require('Model/Email'),
|
||||
FolderModel = require('Model/Folder'),
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
* @constructor
|
||||
* @extends AbstractApp
|
||||
*/
|
||||
function AppApp()
|
||||
function AppUser()
|
||||
{
|
||||
AbstractApp.call(this, Remote);
|
||||
|
||||
|
|
@ -103,19 +103,19 @@
|
|||
this.socialUsers = _.bind(this.socialUsers, this);
|
||||
}
|
||||
|
||||
_.extend(AppApp.prototype, AbstractApp.prototype);
|
||||
_.extend(AppUser.prototype, AbstractApp.prototype);
|
||||
|
||||
AppApp.prototype.remote = function ()
|
||||
AppUser.prototype.remote = function ()
|
||||
{
|
||||
return Remote;
|
||||
};
|
||||
|
||||
AppApp.prototype.data = function ()
|
||||
AppUser.prototype.data = function ()
|
||||
{
|
||||
return Data;
|
||||
};
|
||||
|
||||
AppApp.prototype.reloadFlagsCurrentMessageListAndMessageFromCache = function ()
|
||||
AppUser.prototype.reloadFlagsCurrentMessageListAndMessageFromCache = function ()
|
||||
{
|
||||
_.each(Data.messageList(), function (oMessage) {
|
||||
Cache.initMessageFlagsFromCache(oMessage);
|
||||
|
|
@ -128,7 +128,7 @@
|
|||
* @param {boolean=} bDropPagePosition = false
|
||||
* @param {boolean=} bDropCurrenFolderCache = false
|
||||
*/
|
||||
AppApp.prototype.reloadMessageList = function (bDropPagePosition, bDropCurrenFolderCache)
|
||||
AppUser.prototype.reloadMessageList = function (bDropPagePosition, bDropCurrenFolderCache)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
|
|
@ -172,12 +172,12 @@
|
|||
}, Data.currentFolderFullNameRaw(), iOffset, Data.messagesPerPage(), Data.messageListSearch());
|
||||
};
|
||||
|
||||
AppApp.prototype.recacheInboxMessageList = function ()
|
||||
AppUser.prototype.recacheInboxMessageList = function ()
|
||||
{
|
||||
Remote.messageList(Utils.emptyFunction, Cache.getFolderInboxName(), 0, Data.messagesPerPage(), '', true);
|
||||
};
|
||||
|
||||
AppApp.prototype.reloadMessageListHelper = function (bEmptyList)
|
||||
AppUser.prototype.reloadMessageListHelper = function (bEmptyList)
|
||||
{
|
||||
this.reloadMessageList(bEmptyList);
|
||||
};
|
||||
|
|
@ -186,7 +186,7 @@
|
|||
* @param {Function} fResultFunc
|
||||
* @returns {boolean}
|
||||
*/
|
||||
AppApp.prototype.contactsSync = function (fResultFunc)
|
||||
AppUser.prototype.contactsSync = function (fResultFunc)
|
||||
{
|
||||
var oContacts = Data.contacts;
|
||||
if (oContacts.importing() || oContacts.syncing() || !Data.enableContactsSync() || !Data.allowContactsSync())
|
||||
|
|
@ -209,7 +209,7 @@
|
|||
return true;
|
||||
};
|
||||
|
||||
AppApp.prototype.messagesMoveTrigger = function ()
|
||||
AppUser.prototype.messagesMoveTrigger = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
|
|
@ -230,7 +230,7 @@
|
|||
this.oMoveCache = {};
|
||||
};
|
||||
|
||||
AppApp.prototype.messagesMoveHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForMove)
|
||||
AppUser.prototype.messagesMoveHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForMove)
|
||||
{
|
||||
var sH = '$$' + sFromFolderFullNameRaw + '$$' + sToFolderFullNameRaw + '$$';
|
||||
if (!this.oMoveCache[sH])
|
||||
|
|
@ -246,7 +246,7 @@
|
|||
this.messagesMoveTrigger();
|
||||
};
|
||||
|
||||
AppApp.prototype.messagesCopyHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForCopy)
|
||||
AppUser.prototype.messagesCopyHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForCopy)
|
||||
{
|
||||
Remote.messagesCopy(
|
||||
this.moveOrDeleteResponseHelper,
|
||||
|
|
@ -256,7 +256,7 @@
|
|||
);
|
||||
};
|
||||
|
||||
AppApp.prototype.messagesDeleteHelper = function (sFromFolderFullNameRaw, aUidForRemove)
|
||||
AppUser.prototype.messagesDeleteHelper = function (sFromFolderFullNameRaw, aUidForRemove)
|
||||
{
|
||||
Remote.messagesDelete(
|
||||
this.moveOrDeleteResponseHelper,
|
||||
|
|
@ -265,7 +265,7 @@
|
|||
);
|
||||
};
|
||||
|
||||
AppApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData)
|
||||
AppUser.prototype.moveOrDeleteResponseHelper = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && Data.currentFolder())
|
||||
{
|
||||
|
|
@ -293,7 +293,7 @@
|
|||
* @param {string} sFromFolderFullNameRaw
|
||||
* @param {Array} aUidForRemove
|
||||
*/
|
||||
AppApp.prototype.deleteMessagesFromFolderWithoutCheck = function (sFromFolderFullNameRaw, aUidForRemove)
|
||||
AppUser.prototype.deleteMessagesFromFolderWithoutCheck = function (sFromFolderFullNameRaw, aUidForRemove)
|
||||
{
|
||||
this.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove);
|
||||
Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove);
|
||||
|
|
@ -305,7 +305,7 @@
|
|||
* @param {Array} aUidForRemove
|
||||
* @param {boolean=} bUseFolder = true
|
||||
*/
|
||||
AppApp.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFolderFullNameRaw, aUidForRemove, bUseFolder)
|
||||
AppUser.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFolderFullNameRaw, aUidForRemove, bUseFolder)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
|
|
@ -370,7 +370,7 @@
|
|||
* @param {string} sToFolderFullNameRaw
|
||||
* @param {boolean=} bCopy = false
|
||||
*/
|
||||
AppApp.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForMove, sToFolderFullNameRaw, bCopy)
|
||||
AppUser.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForMove, sToFolderFullNameRaw, bCopy)
|
||||
{
|
||||
if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForMove) && 0 < aUidForMove.length)
|
||||
{
|
||||
|
|
@ -401,7 +401,7 @@
|
|||
/**
|
||||
* @param {Function=} fCallback
|
||||
*/
|
||||
AppApp.prototype.folders = function (fCallback)
|
||||
AppUser.prototype.folders = function (fCallback)
|
||||
{
|
||||
Data.foldersLoading(true);
|
||||
|
||||
|
|
@ -424,7 +424,7 @@
|
|||
}, this));
|
||||
};
|
||||
|
||||
AppApp.prototype.reloadOpenPgpKeys = function ()
|
||||
AppUser.prototype.reloadOpenPgpKeys = function ()
|
||||
{
|
||||
if (Data.capaOpenPGP())
|
||||
{
|
||||
|
|
@ -468,7 +468,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
AppApp.prototype.accountsAndIdentities = function ()
|
||||
AppUser.prototype.accountsAndIdentities = function ()
|
||||
{
|
||||
Data.accountsLoading(true);
|
||||
Data.identitiesLoading(true);
|
||||
|
|
@ -517,7 +517,7 @@
|
|||
});
|
||||
};
|
||||
|
||||
AppApp.prototype.quota = function ()
|
||||
AppUser.prototype.quota = function ()
|
||||
{
|
||||
Remote.quota(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
|
|
@ -534,7 +534,7 @@
|
|||
* @param {string} sFolder
|
||||
* @param {Array=} aList = []
|
||||
*/
|
||||
AppApp.prototype.folderInformation = function (sFolder, aList)
|
||||
AppUser.prototype.folderInformation = function (sFolder, aList)
|
||||
{
|
||||
if ('' !== Utils.trim(sFolder))
|
||||
{
|
||||
|
|
@ -638,7 +638,7 @@
|
|||
/**
|
||||
* @param {boolean=} bBoot = false
|
||||
*/
|
||||
AppApp.prototype.folderInformationMultiply = function (bBoot)
|
||||
AppUser.prototype.folderInformationMultiply = function (bBoot)
|
||||
{
|
||||
bBoot = Utils.isUnd(bBoot) ? false : !!bBoot;
|
||||
|
||||
|
|
@ -724,7 +724,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
AppApp.prototype.setMessageSeen = function (oMessage)
|
||||
AppUser.prototype.setMessageSeen = function (oMessage)
|
||||
{
|
||||
if (oMessage.unseen())
|
||||
{
|
||||
|
|
@ -744,17 +744,17 @@
|
|||
Remote.messageSetSeen(Utils.emptyFunction, oMessage.folderFullNameRaw, [oMessage.uid], true);
|
||||
};
|
||||
|
||||
AppApp.prototype.googleConnect = function ()
|
||||
AppUser.prototype.googleConnect = function ()
|
||||
{
|
||||
window.open(Links.socialGoogle(), 'Google', 'left=200,top=100,width=650,height=600,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
};
|
||||
|
||||
AppApp.prototype.twitterConnect = function ()
|
||||
AppUser.prototype.twitterConnect = function ()
|
||||
{
|
||||
window.open(Links.socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=350,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
};
|
||||
|
||||
AppApp.prototype.facebookConnect = function ()
|
||||
AppUser.prototype.facebookConnect = function ()
|
||||
{
|
||||
window.open(Links.socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
};
|
||||
|
|
@ -762,7 +762,7 @@
|
|||
/**
|
||||
* @param {boolean=} bFireAllActions
|
||||
*/
|
||||
AppApp.prototype.socialUsers = function (bFireAllActions)
|
||||
AppUser.prototype.socialUsers = function (bFireAllActions)
|
||||
{
|
||||
if (bFireAllActions)
|
||||
{
|
||||
|
|
@ -796,19 +796,19 @@
|
|||
});
|
||||
};
|
||||
|
||||
AppApp.prototype.googleDisconnect = function ()
|
||||
AppUser.prototype.googleDisconnect = function ()
|
||||
{
|
||||
Data.googleActions(true);
|
||||
Remote.googleDisconnect(this.socialUsers);
|
||||
};
|
||||
|
||||
AppApp.prototype.facebookDisconnect = function ()
|
||||
AppUser.prototype.facebookDisconnect = function ()
|
||||
{
|
||||
Data.facebookActions(true);
|
||||
Remote.facebookDisconnect(this.socialUsers);
|
||||
};
|
||||
|
||||
AppApp.prototype.twitterDisconnect = function ()
|
||||
AppUser.prototype.twitterDisconnect = function ()
|
||||
{
|
||||
Data.twitterActions(true);
|
||||
Remote.twitterDisconnect(this.socialUsers);
|
||||
|
|
@ -818,7 +818,7 @@
|
|||
* @param {string} sQuery
|
||||
* @param {Function} fCallback
|
||||
*/
|
||||
AppApp.prototype.getAutocomplete = function (sQuery, fCallback)
|
||||
AppUser.prototype.getAutocomplete = function (sQuery, fCallback)
|
||||
{
|
||||
var
|
||||
aData = []
|
||||
|
|
@ -841,7 +841,7 @@
|
|||
}, sQuery);
|
||||
};
|
||||
|
||||
AppApp.prototype.setMessageList = function (oData, bCached)
|
||||
AppUser.prototype.setMessageList = function (oData, bCached)
|
||||
{
|
||||
if (oData && oData.Result && 'Collection/MessageCollection' === oData.Result['@Object'] &&
|
||||
oData.Result['@Collection'] && Utils.isArray(oData.Result['@Collection']))
|
||||
|
|
@ -976,7 +976,7 @@
|
|||
* @param {Array} aFolders
|
||||
* @return {Array}
|
||||
*/
|
||||
AppApp.prototype.folderResponseParseRec = function (sNamespace, aFolders)
|
||||
AppUser.prototype.folderResponseParseRec = function (sNamespace, aFolders)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
|
|
@ -1048,7 +1048,7 @@
|
|||
/**
|
||||
* @param {*} oData
|
||||
*/
|
||||
AppApp.prototype.setFolders = function (oData)
|
||||
AppUser.prototype.setFolders = function (oData)
|
||||
{
|
||||
var
|
||||
aList = [],
|
||||
|
|
@ -1113,7 +1113,7 @@
|
|||
* @param {string} sFullNameHash
|
||||
* @return {boolean}
|
||||
*/
|
||||
AppApp.prototype.isFolderExpanded = function (sFullNameHash)
|
||||
AppUser.prototype.isFolderExpanded = function (sFullNameHash)
|
||||
{
|
||||
var aExpandedList = Local.get(Enums.ClientSideKeyName.ExpandedFolders);
|
||||
return Utils.isArray(aExpandedList) && -1 !== _.indexOf(aExpandedList, sFullNameHash);
|
||||
|
|
@ -1123,7 +1123,7 @@
|
|||
* @param {string} sFullNameHash
|
||||
* @param {boolean} bExpanded
|
||||
*/
|
||||
AppApp.prototype.setExpandedFolder = function (sFullNameHash, bExpanded)
|
||||
AppUser.prototype.setExpandedFolder = function (sFullNameHash, bExpanded)
|
||||
{
|
||||
var aExpandedList = Local.get(Enums.ClientSideKeyName.ExpandedFolders);
|
||||
if (!Utils.isArray(aExpandedList))
|
||||
|
|
@ -1144,7 +1144,7 @@
|
|||
Local.set(Enums.ClientSideKeyName.ExpandedFolders, aExpandedList);
|
||||
};
|
||||
|
||||
AppApp.prototype.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName)
|
||||
AppUser.prototype.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName)
|
||||
{
|
||||
var
|
||||
iDisabledWidth = 60,
|
||||
|
|
@ -1215,7 +1215,7 @@
|
|||
});
|
||||
};
|
||||
|
||||
AppApp.prototype.bootstartLoginScreen = function ()
|
||||
AppUser.prototype.bootstartLoginScreen = function ()
|
||||
{
|
||||
var sCustomLoginLink = Utils.pString(Settings.settingsGet('CustomLoginLink'));
|
||||
if (!sCustomLoginLink)
|
||||
|
|
@ -1223,7 +1223,7 @@
|
|||
kn.hideLoading();
|
||||
|
||||
kn.startScreens([
|
||||
require('Screen/App/Login')
|
||||
require('Screen/User/Login')
|
||||
]);
|
||||
|
||||
Plugins.runHook('rl-start-login-screens');
|
||||
|
|
@ -1241,7 +1241,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
AppApp.prototype.bootstart = function ()
|
||||
AppUser.prototype.bootstart = function ()
|
||||
{
|
||||
AbstractApp.prototype.bootstart.call(this);
|
||||
|
||||
|
|
@ -1318,9 +1318,9 @@
|
|||
}
|
||||
|
||||
kn.startScreens([
|
||||
require('Screen/App/MailBox'),
|
||||
require('Screen/App/Settings'),
|
||||
require('Screen/App/About')
|
||||
require('Screen/User/MailBox'),
|
||||
require('Screen/User/Settings'),
|
||||
require('Screen/User/About')
|
||||
]);
|
||||
|
||||
if (bGoogle || bFacebook || bTwitter)
|
||||
|
|
@ -1447,6 +1447,6 @@
|
|||
Events.pub('rl.bootstart-end');
|
||||
};
|
||||
|
||||
module.exports = new AppApp();
|
||||
module.exports = new AppUser();
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue