mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
CommonJS (research/3)
This commit is contained in:
parent
586abbb802
commit
06bb124379
99 changed files with 51037 additions and 42961 deletions
208
dev/Screens/MailBoxScreen.js
Normal file
208
dev/Screens/MailBoxScreen.js
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('../External/underscore.js'),
|
||||
$html = require('../External/$html.js'),
|
||||
|
||||
Enums = require('../Common/Enums.js'),
|
||||
Globals = require('../Common/Globals.js'),
|
||||
Utils = require('../Common/Utils.js'),
|
||||
Events = require('../Common/Events.js'),
|
||||
|
||||
KnoinAbstractScreen = require('../Knoin/KnoinAbstractScreen.js'),
|
||||
|
||||
AppSettings = require('../Storages/AppSettings.js'),
|
||||
Data = require('../Storages/WebMailDataStorage.js'),
|
||||
Cache = require('../Storages/WebMailCacheStorage.js'),
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractScreen
|
||||
*/
|
||||
function MailBoxScreen()
|
||||
{
|
||||
var
|
||||
MailBoxSystemDropDownViewModel = require('../ViewModels/MailBoxSystemDropDownViewModel.js'),
|
||||
MailBoxFolderListViewModel = require('../ViewModels/MailBoxFolderListViewModel.js'),
|
||||
MailBoxMessageListViewModel = require('../ViewModels/MailBoxMessageListViewModel.js'),
|
||||
MailBoxMessageViewViewModel = require('../ViewModels/MailBoxMessageViewViewModel.js')
|
||||
;
|
||||
|
||||
KnoinAbstractScreen.call(this, 'mailbox', [
|
||||
MailBoxSystemDropDownViewModel,
|
||||
MailBoxFolderListViewModel,
|
||||
MailBoxMessageListViewModel,
|
||||
MailBoxMessageViewViewModel
|
||||
]);
|
||||
|
||||
this.oLastRoute = {};
|
||||
}
|
||||
|
||||
_.extend(MailBoxScreen.prototype, KnoinAbstractScreen.prototype);
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
MailBoxScreen.prototype.oLastRoute = {};
|
||||
|
||||
MailBoxScreen.prototype.setNewTitle = function ()
|
||||
{
|
||||
var
|
||||
RL = require('../Boots/RainLoopApp.js'),
|
||||
sEmail = Data.accountEmail(),
|
||||
nFoldersInboxUnreadCount = Data.foldersInboxUnreadCount()
|
||||
;
|
||||
|
||||
RL.setTitle(('' === sEmail ? '' :
|
||||
(0 < nFoldersInboxUnreadCount ? '(' + nFoldersInboxUnreadCount + ') ' : ' ') + sEmail + ' - ') + Utils.i18n('TITLES/MAILBOX'));
|
||||
};
|
||||
|
||||
MailBoxScreen.prototype.onShow = function ()
|
||||
{
|
||||
this.setNewTitle();
|
||||
Globals.keyScope(Enums.KeyState.MessageList);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFolderHash
|
||||
* @param {number} iPage
|
||||
* @param {string} sSearch
|
||||
* @param {boolean=} bPreview = false
|
||||
*/
|
||||
MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPreview)
|
||||
{
|
||||
var RL = require('../Boots/RainLoopApp.js');
|
||||
if (Utils.isUnd(bPreview) ? false : !!bPreview)
|
||||
{
|
||||
if (Enums.Layout.NoPreview === Data.layout() && !Data.message())
|
||||
{
|
||||
RL.historyBack();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var
|
||||
sFolderFullNameRaw = Cache.getFolderFullNameRaw(sFolderHash),
|
||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw)
|
||||
;
|
||||
|
||||
if (oFolder)
|
||||
{
|
||||
Data
|
||||
.currentFolder(oFolder)
|
||||
.messageListPage(iPage)
|
||||
.messageListSearch(sSearch)
|
||||
;
|
||||
|
||||
if (Enums.Layout.NoPreview === Data.layout() && Data.message())
|
||||
{
|
||||
Data.message(null);
|
||||
}
|
||||
|
||||
RL.reloadMessageList();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxScreen.prototype.onStart = function ()
|
||||
{
|
||||
var
|
||||
RL = require('../Boots/RainLoopApp.js'),
|
||||
fResizeFunction = function () {
|
||||
Utils.windowResize();
|
||||
}
|
||||
;
|
||||
|
||||
if (AppSettings.capa(Enums.Capa.AdditionalAccounts) || AppSettings.capa(Enums.Capa.AdditionalIdentities))
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
if ('INBOX' !== Data.currentFolderFullNameRaw())
|
||||
{
|
||||
RL.folderInformation('INBOX');
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
_.delay(function () {
|
||||
RL.quota();
|
||||
}, 5000);
|
||||
|
||||
_.delay(function () {
|
||||
Remote.appDelayStart(Utils.emptyFunction);
|
||||
}, 35000);
|
||||
|
||||
$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === Data.layout());
|
||||
|
||||
Data.folderList.subscribe(fResizeFunction);
|
||||
Data.messageList.subscribe(fResizeFunction);
|
||||
Data.message.subscribe(fResizeFunction);
|
||||
|
||||
Data.layout.subscribe(function (nValue) {
|
||||
$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue);
|
||||
});
|
||||
|
||||
Events.sub('mailbox.inbox-unread-count', function (nCount) {
|
||||
Data.foldersInboxUnreadCount(nCount)
|
||||
});
|
||||
|
||||
Data.foldersInboxUnreadCount.subscribe(function () {
|
||||
this.setNewTitle();
|
||||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Array}
|
||||
*/
|
||||
MailBoxScreen.prototype.routes = function ()
|
||||
{
|
||||
var
|
||||
fNormP = function () {
|
||||
return ['Inbox', 1, '', true];
|
||||
},
|
||||
fNormS = function (oRequest, oVals) {
|
||||
oVals[0] = Utils.pString(oVals[0]);
|
||||
oVals[1] = Utils.pInt(oVals[1]);
|
||||
oVals[1] = 0 >= oVals[1] ? 1 : oVals[1];
|
||||
oVals[2] = Utils.pString(oVals[2]);
|
||||
|
||||
if ('' === oRequest)
|
||||
{
|
||||
oVals[0] = 'Inbox';
|
||||
oVals[1] = 1;
|
||||
}
|
||||
|
||||
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2]), false];
|
||||
},
|
||||
fNormD = function (oRequest, oVals) {
|
||||
oVals[0] = Utils.pString(oVals[0]);
|
||||
oVals[1] = Utils.pString(oVals[1]);
|
||||
|
||||
if ('' === oRequest)
|
||||
{
|
||||
oVals[0] = 'Inbox';
|
||||
}
|
||||
|
||||
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1]), false];
|
||||
}
|
||||
;
|
||||
|
||||
return [
|
||||
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}],
|
||||
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}],
|
||||
[/^([a-zA-Z0-9]+)\/(.+)\/?$/, {'normalize_': fNormD}],
|
||||
[/^message-preview$/, {'normalize_': fNormP}],
|
||||
[/^([^\/]*)$/, {'normalize_': fNormS}]
|
||||
];
|
||||
};
|
||||
|
||||
module.exports = MailBoxScreen;
|
||||
|
||||
}(module));
|
||||
Loading…
Add table
Add a link
Reference in a new issue