mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-27 11:09:20 +03:00
Uploading and preparing the repository to the dev version.
Original unminified source code (dev folder - js, css, less) (fixes #6) Grunt build system Multiple identities correction (fixes #9) Compose html editor (fixes #12) New general settings - Loading Description New warning about default admin password Split general and login screen settings
This commit is contained in:
parent
afad45137e
commit
4cc2207513
846 changed files with 99453 additions and 2123 deletions
23
dev/Models/AccountModel.js
Normal file
23
dev/Models/AccountModel.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @param {boolean=} bCanBeDelete = true
|
||||
* @constructor
|
||||
*/
|
||||
function AccountModel(sEmail, bCanBeDelete)
|
||||
{
|
||||
this.email = sEmail;
|
||||
this.deleteAccess = ko.observable(false);
|
||||
this.canBeDalete = ko.observable(bCanBeDelete);
|
||||
}
|
||||
|
||||
AccountModel.prototype.email = '';
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AccountModel.prototype.changeAccountLink = function ()
|
||||
{
|
||||
return RL.link().change(this.email);
|
||||
};
|
||||
228
dev/Models/AttachmentModel.js
Normal file
228
dev/Models/AttachmentModel.js
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AttachmentModel()
|
||||
{
|
||||
this.mimeType = '';
|
||||
this.fileName = '';
|
||||
this.estimatedSize = 0;
|
||||
this.friendlySize = '';
|
||||
this.isInline = false;
|
||||
this.isLinked = false;
|
||||
this.cid = '';
|
||||
this.cidWithOutTags = '';
|
||||
this.contentLocation = '';
|
||||
this.download = '';
|
||||
this.folder = '';
|
||||
this.uid = '';
|
||||
this.mimeIndex = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {AjaxJsonAttachment} oJsonAttachment
|
||||
* @return {?AttachmentModel}
|
||||
*/
|
||||
AttachmentModel.newInstanceFromJson = function (oJsonAttachment)
|
||||
{
|
||||
var oAttachmentModel = new AttachmentModel();
|
||||
return oAttachmentModel.initByJson(oJsonAttachment) ? oAttachmentModel : null;
|
||||
};
|
||||
|
||||
AttachmentModel.prototype.mimeType = '';
|
||||
AttachmentModel.prototype.fileName = '';
|
||||
AttachmentModel.prototype.estimatedSize = 0;
|
||||
AttachmentModel.prototype.friendlySize = '';
|
||||
AttachmentModel.prototype.isInline = false;
|
||||
AttachmentModel.prototype.isLinked = false;
|
||||
AttachmentModel.prototype.cid = '';
|
||||
AttachmentModel.prototype.cidWithOutTags = '';
|
||||
AttachmentModel.prototype.contentLocation = '';
|
||||
AttachmentModel.prototype.download = '';
|
||||
AttachmentModel.prototype.folder = '';
|
||||
AttachmentModel.prototype.uid = '';
|
||||
AttachmentModel.prototype.mimeIndex = '';
|
||||
|
||||
/**
|
||||
* @param {AjaxJsonAttachment} oJsonAttachment
|
||||
*/
|
||||
AttachmentModel.prototype.initByJson = function (oJsonAttachment)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
|
||||
{
|
||||
this.mimeType = oJsonAttachment.MimeType;
|
||||
this.fileName = oJsonAttachment.FileName;
|
||||
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
|
||||
this.isInline = !!oJsonAttachment.IsInline;
|
||||
this.isLinked = !!oJsonAttachment.IsLinked;
|
||||
this.cid = oJsonAttachment.CID;
|
||||
this.contentLocation = oJsonAttachment.ContentLocation;
|
||||
this.download = oJsonAttachment.Download;
|
||||
|
||||
this.folder = oJsonAttachment.Folder;
|
||||
this.uid = oJsonAttachment.Uid;
|
||||
this.mimeIndex = oJsonAttachment.MimeIndex;
|
||||
|
||||
this.friendlySize = Utils.friendlySize(this.estimatedSize);
|
||||
this.cidWithOutTags = this.cid.replace(/^<+/, '').replace(/>+$/, '');
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
AttachmentModel.prototype.isImage = function ()
|
||||
{
|
||||
return -1 < Utils.inArray(this.mimeType.toLowerCase(),
|
||||
['image/png', 'image/jpg', 'image/jpeg', 'image/gif']
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
AttachmentModel.prototype.isText = function ()
|
||||
{
|
||||
return 'text/' === this.mimeType.substr(0, 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AttachmentModel.prototype.linkDownload = function ()
|
||||
{
|
||||
return RL.link().attachmentDownload(this.download);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AttachmentModel.prototype.linkPreview = function ()
|
||||
{
|
||||
return RL.link().attachmentPreview(this.download);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AttachmentModel.prototype.linkPreviewAsPlain = function ()
|
||||
{
|
||||
return RL.link().attachmentPreviewAsPlain(this.download);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AttachmentModel.prototype.generateTransferDownloadUrl = function ()
|
||||
{
|
||||
var sLink = this.linkDownload();
|
||||
if ('http' !== sLink.substr(0, 4))
|
||||
{
|
||||
sLink = window.location.protocol + '//' + window.location.host + window.location.pathname + sLink;
|
||||
}
|
||||
|
||||
return this.mimeType + ':' + this.fileName + ':' + sLink;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {AttachmentModel} oAttachment
|
||||
* @param {*} oEvent
|
||||
* @return {boolean}
|
||||
*/
|
||||
AttachmentModel.prototype.eventDragStart = function (oAttachment, oEvent)
|
||||
{
|
||||
var oLocalEvent = oEvent.originalEvent || oEvent;
|
||||
if (oAttachment && oLocalEvent && oLocalEvent.dataTransfer && oLocalEvent.dataTransfer.setData)
|
||||
{
|
||||
oLocalEvent.dataTransfer.setData('DownloadURL', this.generateTransferDownloadUrl());
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
AttachmentModel.prototype.iconClass = function ()
|
||||
{
|
||||
var
|
||||
aParts = this.mimeType.toLocaleString().split('/'),
|
||||
sClass = 'icon-file'
|
||||
;
|
||||
|
||||
if (aParts && aParts[1])
|
||||
{
|
||||
if ('image' === aParts[0])
|
||||
{
|
||||
sClass = 'icon-image';
|
||||
}
|
||||
else if ('text' === aParts[0])
|
||||
{
|
||||
sClass = 'icon-file-xml';
|
||||
}
|
||||
else if ('audio' === aParts[0])
|
||||
{
|
||||
sClass = 'icon-music';
|
||||
}
|
||||
else if ('video' === aParts[0])
|
||||
{
|
||||
sClass = 'icon-film';
|
||||
}
|
||||
else if (-1 < Utils.inArray(aParts[1],
|
||||
['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2', 'x-zip', 'x-7z', 'x-rar', 'x-tar', 'x-gzip', 'x-bzip', 'x-bzip2', 'x-zip-compressed', 'x-7z-compressed', 'x-rar-compressed']))
|
||||
{
|
||||
sClass = 'icon-file-zip';
|
||||
}
|
||||
else if (-1 < Utils.inArray(aParts[1],
|
||||
['pdf', 'x-pdf']))
|
||||
{
|
||||
sClass = 'icon-file-pdf';
|
||||
}
|
||||
else if (-1 < Utils.inArray(aParts[1], [
|
||||
'exe', 'x-exe', 'x-winexe', 'bat'
|
||||
]))
|
||||
{
|
||||
sClass = 'icon-console';
|
||||
}
|
||||
else if (-1 < Utils.inArray(aParts[1], [
|
||||
'rtf', 'msword', 'vnd.msword', 'vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'vnd.ms-word.document.macroEnabled.12',
|
||||
'vnd.ms-word.template.macroEnabled.12'
|
||||
]))
|
||||
{
|
||||
sClass = 'icon-file-word';
|
||||
}
|
||||
else if (-1 < Utils.inArray(aParts[1], [
|
||||
'excel', 'ms-excel', 'vnd.ms-excel',
|
||||
'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'vnd.ms-excel.template.macroEnabled.12',
|
||||
'vnd.ms-excel.addin.macroEnabled.12',
|
||||
'vnd.ms-excel.sheet.binary.macroEnabled.12'
|
||||
]))
|
||||
{
|
||||
sClass = 'icon-file-excel';
|
||||
}
|
||||
else if (-1 < Utils.inArray(aParts[1], [
|
||||
'powerpoint', 'ms-powerpoint', 'vnd.ms-powerpoint',
|
||||
'vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||
'vnd.ms-powerpoint.addin.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.template.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.slideshow.macroEnabled.12'
|
||||
]))
|
||||
{
|
||||
sClass = 'icon-file-powerpoint';
|
||||
}
|
||||
}
|
||||
|
||||
return sClass;
|
||||
};
|
||||
63
dev/Models/ComposeAttachmentModel.js
Normal file
63
dev/Models/ComposeAttachmentModel.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string} sId
|
||||
* @param {string} sFileName
|
||||
* @param {?number=} nSize
|
||||
* @param {boolean=} bInline
|
||||
* @param {boolean=} bLinked
|
||||
* @param {string=} sCID
|
||||
* @param {string=} sContentLocation
|
||||
*/
|
||||
function ComposeAttachmentModel(sId, sFileName, nSize, bInline, bLinked, sCID, sContentLocation)
|
||||
{
|
||||
this.id = sId;
|
||||
this.isInline = Utils.isUnd(bInline) ? false : !!bInline;
|
||||
this.isLinked = Utils.isUnd(bLinked) ? false : !!bLinked;
|
||||
this.CID = Utils.isUnd(sCID) ? '' : sCID;
|
||||
this.contentLocation = Utils.isUnd(sContentLocation) ? '' : sContentLocation;
|
||||
this.fromMessage = false;
|
||||
|
||||
this.fileName = ko.observable(sFileName);
|
||||
this.size = ko.observable(Utils.isUnd(nSize) ? null : nSize);
|
||||
this.tempName = ko.observable('');
|
||||
|
||||
this.progress = ko.observable('');
|
||||
this.error = ko.observable('');
|
||||
this.waiting = ko.observable(true);
|
||||
this.uploading = ko.observable(false);
|
||||
this.enabled = ko.observable(true);
|
||||
|
||||
this.friendlySize = ko.computed(function () {
|
||||
var mSize = this.size();
|
||||
return null === mSize ? '' : Utils.friendlySize(this.size());
|
||||
}, this);
|
||||
}
|
||||
|
||||
ComposeAttachmentModel.prototype.id = '';
|
||||
ComposeAttachmentModel.prototype.isInline = false;
|
||||
ComposeAttachmentModel.prototype.isLinked = false;
|
||||
ComposeAttachmentModel.prototype.CID = '';
|
||||
ComposeAttachmentModel.prototype.contentLocation = '';
|
||||
ComposeAttachmentModel.prototype.fromMessage = false;
|
||||
ComposeAttachmentModel.prototype.cancel = Utils.emptyFunction;
|
||||
|
||||
/**
|
||||
* @param {AjaxJsonComposeAttachment} oJsonAttachment
|
||||
*/
|
||||
ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oJsonAttachment)
|
||||
{
|
||||
this.fileName(oJsonAttachment.Name);
|
||||
this.size(Utils.isUnd(oJsonAttachment.Size) ? 0 : Utils.pInt(oJsonAttachment.Size));
|
||||
this.tempName(Utils.isUnd(oJsonAttachment.TempName) ? '' : oJsonAttachment.TempName);
|
||||
this.isInline = false;
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
73
dev/Models/ContactModel.js
Normal file
73
dev/Models/ContactModel.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ContactModel()
|
||||
{
|
||||
this.idContact = 0;
|
||||
this.imageHash = '';
|
||||
this.listName = '';
|
||||
this.name = '';
|
||||
this.emails = [];
|
||||
|
||||
this.checked = ko.observable(false);
|
||||
this.selected = ko.observable(false);
|
||||
this.deleted = ko.observable(false);
|
||||
}
|
||||
|
||||
ContactModel.prototype.parse = function (oItem)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oItem && 'Object/Contact' === oItem['@Object'])
|
||||
{
|
||||
this.idContact = Utils.pInt(oItem['IdContact']);
|
||||
this.listName = Utils.pString(oItem['ListName']);
|
||||
this.name = Utils.pString(oItem['Name']);
|
||||
this.emails = Utils.isNonEmptyArray(oItem['Emails']) ? oItem['Emails'] : [];
|
||||
this.imageHash = Utils.pString(oItem['ImageHash']);
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
ContactModel.prototype.srcAttr = function ()
|
||||
{
|
||||
return '' === this.imageHash ? RL.link().emptyContactPic() :
|
||||
RL.link().getUserPicUrlFromHash(this.imageHash);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
ContactModel.prototype.generateUid = function ()
|
||||
{
|
||||
return '' + this.idContact;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
ContactModel.prototype.lineAsCcc = function ()
|
||||
{
|
||||
var aResult = [];
|
||||
if (this.deleted())
|
||||
{
|
||||
aResult.push('deleted');
|
||||
}
|
||||
if (this.selected())
|
||||
{
|
||||
aResult.push('selected');
|
||||
}
|
||||
if (this.checked())
|
||||
{
|
||||
aResult.push('checked');
|
||||
}
|
||||
|
||||
return aResult.join(' ');
|
||||
};
|
||||
240
dev/Models/EmailModel.js
Normal file
240
dev/Models/EmailModel.js
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @param {string=} sEmail
|
||||
* @param {string=} sName
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function EmailModel(sEmail, sName)
|
||||
{
|
||||
this.email = sEmail || '';
|
||||
this.name = sName || '';
|
||||
this.privateType = null;
|
||||
|
||||
this.clearDuplicateName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {AjaxJsonEmail} oJsonEmail
|
||||
* @return {?EmailModel}
|
||||
*/
|
||||
EmailModel.newInstanceFromJson = function (oJsonEmail)
|
||||
{
|
||||
var oEmailModel = new EmailModel();
|
||||
return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
EmailModel.prototype.name = '';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
EmailModel.prototype.email = '';
|
||||
|
||||
/**
|
||||
* @type {(number|null)}
|
||||
*/
|
||||
EmailModel.prototype.privateType = null;
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
EmailModel.prototype.validate = function ()
|
||||
{
|
||||
return '' !== this.name || '' !== this.email;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} bWithoutName = false
|
||||
* @return {string}
|
||||
*/
|
||||
EmailModel.prototype.hash = function (bWithoutName)
|
||||
{
|
||||
return '#' + (bWithoutName ? '' : this.name) + '#' + this.email + '#';
|
||||
};
|
||||
|
||||
EmailModel.prototype.clearDuplicateName = function ()
|
||||
{
|
||||
if (this.name === this.email)
|
||||
{
|
||||
this.name = '';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
EmailModel.prototype.type = function ()
|
||||
{
|
||||
if (null === this.privateType)
|
||||
{
|
||||
if (this.email && '@facebook.com' === this.email.substr(-13))
|
||||
{
|
||||
this.privateType = Enums.EmailType.Facebook;
|
||||
}
|
||||
|
||||
if (null === this.privateType)
|
||||
{
|
||||
this.privateType = Enums.EmailType.Default;
|
||||
}
|
||||
}
|
||||
|
||||
return this.privateType;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sQuery
|
||||
* @return {boolean}
|
||||
*/
|
||||
EmailModel.prototype.search = function (sQuery)
|
||||
{
|
||||
return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(sQuery.toLowerCase());
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sString
|
||||
*/
|
||||
EmailModel.prototype.parse = function (sString)
|
||||
{
|
||||
sString = Utils.trim(sString);
|
||||
|
||||
var
|
||||
mRegex = /(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g,
|
||||
mMatch = mRegex.exec(sString)
|
||||
;
|
||||
|
||||
if (mMatch)
|
||||
{
|
||||
this.name = mMatch[1] || '';
|
||||
this.email = mMatch[2] || '';
|
||||
|
||||
this.clearDuplicateName();
|
||||
}
|
||||
else if ((/^[^@]+@[^@]+$/).test(sString))
|
||||
{
|
||||
this.name = '';
|
||||
this.email = sString;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {AjaxJsonEmail} oJsonEmail
|
||||
* @return {boolean}
|
||||
*/
|
||||
EmailModel.prototype.initByJson = function (oJsonEmail)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oJsonEmail && 'Object/Email' === oJsonEmail['@Object'])
|
||||
{
|
||||
this.name = Utils.trim(oJsonEmail.Name);
|
||||
this.email = Utils.trim(oJsonEmail.Email);
|
||||
|
||||
bResult = '' !== this.email;
|
||||
this.clearDuplicateName();
|
||||
}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} bFriendlyView
|
||||
* @param {boolean=} bWrapWithLink = false
|
||||
* @return {string}
|
||||
*/
|
||||
EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink)
|
||||
{
|
||||
var sResult = '';
|
||||
if ('' !== this.email)
|
||||
{
|
||||
bWrapWithLink = Utils.isUnd(bWrapWithLink) ? false : !!bWrapWithLink;
|
||||
if (bFriendlyView && '' !== this.name)
|
||||
{
|
||||
sResult = bWrapWithLink ? '<a href="mailto:' + Utils.encodeHtml('"' + this.name + '" <' + this.email + '>') +
|
||||
'" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.name) + '</a>' : this.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = this.email;
|
||||
if ('' !== this.name)
|
||||
{
|
||||
if (bWrapWithLink)
|
||||
{
|
||||
sResult = Utils.encodeHtml('"' + this.name + '" <') +
|
||||
'<a href="mailto:' + Utils.encodeHtml('"' + this.name + '" <' + this.email + '>') + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(sResult) + '</a>' + Utils.encodeHtml('>');
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = '"' + this.name + '" <' + sResult + '>';
|
||||
}
|
||||
}
|
||||
else if (bWrapWithLink)
|
||||
{
|
||||
sResult = '<a href="mailto:' + Utils.encodeHtml(this.email) + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.email) + '</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
EmailModel.prototype.select2Result = function ()
|
||||
{
|
||||
var
|
||||
sResult = '',
|
||||
sImg = RL.cache().getUserPic(this.email)
|
||||
;
|
||||
|
||||
if ('' !== sImg)
|
||||
{
|
||||
sResult += '<img class="select2-user-pic pull-left" src="' + Utils.encodeHtml(sImg) + '" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += '<img class="select2-user-pic pull-left" src="' + RL.link().emptyContactPic() + '" />';
|
||||
}
|
||||
|
||||
if (Enums.EmailType.Facebook === this.type())
|
||||
{
|
||||
sResult += '' + (0 < this.name.length ? this.name : this.email);
|
||||
sResult += '<i class="icon-facebook pull-right select2-icon-result" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += '' + (0 < this.name.length ? this.email + ' <span class="select2-subname">(' + this.name + ')</span>' : this.email);
|
||||
}
|
||||
|
||||
return sResult + '';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oContainer
|
||||
* @return {string|null}
|
||||
*/
|
||||
EmailModel.prototype.select2Selection = function (oContainer)
|
||||
{
|
||||
var sResult = '';
|
||||
if (Enums.EmailType.Facebook === this.type())
|
||||
{
|
||||
sResult = 0 < this.name.length ? this.name : this.email;
|
||||
if ('' !== sResult)
|
||||
{
|
||||
$('<pan>').text(sResult).appendTo(oContainer);
|
||||
oContainer.append('<i class="icon-facebook select2-icon"></i>');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
305
dev/Models/FolderModel.js
Normal file
305
dev/Models/FolderModel.js
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FolderModel()
|
||||
{
|
||||
this.name = ko.observable('');
|
||||
this.fullName = '';
|
||||
this.fullNameRaw = '';
|
||||
this.fullNameHash = '';
|
||||
this.delimiter = '';
|
||||
this.namespace = '';
|
||||
this.deep = 0;
|
||||
|
||||
this.selectable = false;
|
||||
this.existen = true;
|
||||
|
||||
this.isNamespaceFolder = false;
|
||||
this.isGmailFolder = false;
|
||||
this.isUnpaddigFolder = false;
|
||||
|
||||
this.type = ko.observable(Enums.FolderType.User);
|
||||
|
||||
this.selected = ko.observable(false);
|
||||
this.edited = ko.observable(false);
|
||||
this.collapsed = ko.observable(true);
|
||||
this.subScribed = ko.observable(true);
|
||||
this.subFolders = ko.observableArray([]);
|
||||
this.deleteAccess = ko.observable(false);
|
||||
this.actionBlink = ko.observable(false).extend({'falseTimeout': 1000});
|
||||
|
||||
this.nameForEdit = ko.observable('');
|
||||
|
||||
this.name.subscribe(function (sValue) {
|
||||
this.nameForEdit(sValue);
|
||||
}, this);
|
||||
|
||||
this.edited.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
this.nameForEdit(this.name());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.canBeEdited = ko.computed(function () {
|
||||
return Enums.FolderType.User === this.type();
|
||||
}, this);
|
||||
|
||||
this.privateMessageCountAll = ko.observable(0);
|
||||
this.privateMessageCountUnread = ko.observable(0);
|
||||
|
||||
this.collapsedPrivate = ko.observable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {AjaxJsonFolder} oJsonFolder
|
||||
* @return {?FolderModel}
|
||||
*/
|
||||
FolderModel.newInstanceFromJson = function (oJsonFolder)
|
||||
{
|
||||
var oFolderModel = new FolderModel();
|
||||
return oFolderModel.initByJson(oJsonFolder) ? oFolderModel.initComputed() : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {FolderModel}
|
||||
*/
|
||||
FolderModel.prototype.initComputed = function ()
|
||||
{
|
||||
this.hasSubScribedSubfolders = ko.computed(function () {
|
||||
return !!_.find(this.subFolders(), function (oFolder) {
|
||||
return oFolder.subScribed();
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.visible = ko.computed(function () {
|
||||
var
|
||||
bSubScribed = this.subScribed(),
|
||||
bSubFolders = this.hasSubScribedSubfolders()
|
||||
;
|
||||
|
||||
return (bSubScribed || (bSubFolders && (!this.existen || !this.selectable)));
|
||||
}, this);
|
||||
|
||||
this.isSystemFolder = ko.computed(function () {
|
||||
return Enums.FolderType.User !== this.type();
|
||||
}, this);
|
||||
|
||||
this.hidden = ko.computed(function () {
|
||||
var
|
||||
bSystem = this.isSystemFolder(),
|
||||
bSubFolders = this.hasSubScribedSubfolders()
|
||||
;
|
||||
|
||||
return this.isGmailFolder || (bSystem && this.isNamespaceFolder) || (bSystem && !bSubFolders);
|
||||
}, this);
|
||||
|
||||
this.selectableForFolderList = ko.computed(function () {
|
||||
return !this.isSystemFolder() && this.selectable;
|
||||
}, this);
|
||||
|
||||
this.messageCountAll = ko.computed({
|
||||
'read': this.privateMessageCountAll,
|
||||
'write': function (iValue) {
|
||||
if (Utils.isPosNumeric(iValue, true))
|
||||
{
|
||||
this.privateMessageCountAll(iValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.privateMessageCountAll.valueHasMutated();
|
||||
}
|
||||
},
|
||||
'owner': this
|
||||
});
|
||||
|
||||
this.messageCountUnread = ko.computed({
|
||||
'read': this.privateMessageCountUnread,
|
||||
'write': function (iValue) {
|
||||
if (Utils.isPosNumeric(iValue, true))
|
||||
{
|
||||
this.privateMessageCountUnread(iValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.privateMessageCountUnread.valueHasMutated();
|
||||
}
|
||||
},
|
||||
'owner': this
|
||||
});
|
||||
|
||||
this.printableUnreadCount = ko.computed(function () {
|
||||
var
|
||||
iCount = this.messageCountAll(),
|
||||
iUnread = this.messageCountUnread(),
|
||||
iType = this.type()
|
||||
;
|
||||
// return 0 < iUnread ? '' + iUnread : '';
|
||||
// return 0 < iUnread && 'INBOX' === this.fullNameRaw ? '' + iUnread : '';
|
||||
return 0 < iUnread && (Enums.FolderType.Inbox === iType || Enums.FolderType.Spam === iType) ? '' + iUnread :
|
||||
(0 < iCount && Enums.FolderType.Draft === iType ? '' + iCount : '');
|
||||
}, this);
|
||||
|
||||
this.canBeDeleted = ko.computed(function () {
|
||||
var
|
||||
bSystem = this.isSystemFolder()
|
||||
;
|
||||
return !bSystem && 0 === this.subFolders().length && 'INBOX' !== this.fullNameRaw;
|
||||
}, this);
|
||||
|
||||
this.canBeSubScribed = ko.computed(function () {
|
||||
return !this.isSystemFolder() && this.selectable && 'INBOX' !== this.fullNameRaw;
|
||||
}, this);
|
||||
|
||||
this.visible.subscribe(function () {
|
||||
Utils.timeOutAction('folder-list-folder-visibility-change', function () {
|
||||
$window.trigger('folder-list-folder-visibility-change');
|
||||
}, 100);
|
||||
});
|
||||
|
||||
this.localName = ko.computed(function () {
|
||||
|
||||
Globals.langChangeTick();
|
||||
|
||||
var
|
||||
iType = this.type(),
|
||||
sName = this.name()
|
||||
;
|
||||
|
||||
if (this.isSystemFolder())
|
||||
{
|
||||
switch (iType)
|
||||
{
|
||||
case Enums.FolderType.Inbox:
|
||||
sName = Utils.i18n('FOLDER_LIST/INBOX_NAME');
|
||||
break;
|
||||
case Enums.FolderType.SentItems:
|
||||
sName = Utils.i18n('FOLDER_LIST/SENT_NAME');
|
||||
break;
|
||||
case Enums.FolderType.Draft:
|
||||
sName = Utils.i18n('FOLDER_LIST/DRAFTS_NAME');
|
||||
break;
|
||||
case Enums.FolderType.Spam:
|
||||
sName = Utils.i18n('FOLDER_LIST/SPAM_NAME');
|
||||
break;
|
||||
case Enums.FolderType.Trash:
|
||||
sName = Utils.i18n('FOLDER_LIST/TRASH_NAME');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sName;
|
||||
|
||||
}, this);
|
||||
|
||||
this.manageFolderSystemName = ko.computed(function () {
|
||||
|
||||
Globals.langChangeTick();
|
||||
|
||||
var
|
||||
sSuffix = '',
|
||||
iType = this.type(),
|
||||
sName = this.name()
|
||||
;
|
||||
|
||||
if (this.isSystemFolder())
|
||||
{
|
||||
switch (iType)
|
||||
{
|
||||
case Enums.FolderType.Inbox:
|
||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/INBOX_NAME') + ')';
|
||||
break;
|
||||
case Enums.FolderType.SentItems:
|
||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/SENT_NAME') + ')';
|
||||
break;
|
||||
case Enums.FolderType.Draft:
|
||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/DRAFTS_NAME') + ')';
|
||||
break;
|
||||
case Enums.FolderType.Spam:
|
||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/SPAM_NAME') + ')';
|
||||
break;
|
||||
case Enums.FolderType.Trash:
|
||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/TRASH_NAME') + ')';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ('' !== sSuffix && '(' + sName + ')' === sSuffix || '(inbox)' === sSuffix.toLowerCase())
|
||||
{
|
||||
sSuffix = '';
|
||||
}
|
||||
|
||||
return sSuffix;
|
||||
|
||||
}, this);
|
||||
|
||||
this.collapsed = ko.computed({
|
||||
'read': function () {
|
||||
return !this.hidden() && this.collapsedPrivate();
|
||||
},
|
||||
'write': function (mValue) {
|
||||
this.collapsedPrivate(mValue);
|
||||
},
|
||||
'owner': this
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
FolderModel.prototype.fullName = '';
|
||||
FolderModel.prototype.fullNameRaw = '';
|
||||
FolderModel.prototype.fullNameHash = '';
|
||||
FolderModel.prototype.delimiter = '';
|
||||
FolderModel.prototype.namespace = '';
|
||||
FolderModel.prototype.deep = 0;
|
||||
|
||||
FolderModel.prototype.isNamespaceFolder = false;
|
||||
FolderModel.prototype.isGmailFolder = false;
|
||||
FolderModel.prototype.isUnpaddigFolder = false;
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
FolderModel.prototype.collapsedCss = function ()
|
||||
{
|
||||
return this.hasSubScribedSubfolders() ?
|
||||
(this.collapsed() ? 'icon-arrow-right-3 e-collapsed-sign' : 'icon-arrow-down-3 e-collapsed-sign') : 'icon-none e-collapsed-sign';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {AjaxJsonFolder} oJsonFolder
|
||||
* @return {boolean}
|
||||
*/
|
||||
FolderModel.prototype.initByJson = function (oJsonFolder)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oJsonFolder && 'Object/Folder' === oJsonFolder['@Object'])
|
||||
{
|
||||
this.name(oJsonFolder.Name);
|
||||
this.delimiter = oJsonFolder.Delimiter;
|
||||
this.fullName = oJsonFolder.FullName;
|
||||
this.fullNameRaw = oJsonFolder.FullNameRaw;
|
||||
this.fullNameHash = oJsonFolder.FullNameHash;
|
||||
this.deep = oJsonFolder.FullNameRaw.split(this.delimiter).length - 1;
|
||||
this.selectable = !!oJsonFolder.IsSelectable;
|
||||
this.existen = !!oJsonFolder.IsExisten;
|
||||
|
||||
this.subScribed(!!oJsonFolder.IsSubscribed);
|
||||
this.type('INBOX' === this.fullNameRaw ? Enums.FolderType.Inbox : Enums.FolderType.User);
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
FolderModel.prototype.printableFullName = function ()
|
||||
{
|
||||
return this.fullName.split(this.delimiter).join(' / ');
|
||||
};
|
||||
37
dev/Models/IdentityModel.js
Normal file
37
dev/Models/IdentityModel.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @param {string} sId
|
||||
* @param {string} sEmail
|
||||
* @param {boolean=} bCanBeDelete = true
|
||||
* @constructor
|
||||
*/
|
||||
function IdentityModel(sId, sEmail, bCanBeDelete)
|
||||
{
|
||||
this.id = sId;
|
||||
this.email = ko.observable(sEmail);
|
||||
this.name = ko.observable('');
|
||||
this.replyTo = ko.observable('');
|
||||
this.bcc = ko.observable('');
|
||||
|
||||
this.deleteAccess = ko.observable(false);
|
||||
this.canBeDalete = ko.observable(bCanBeDelete);
|
||||
}
|
||||
|
||||
IdentityModel.prototype.formattedName = function ()
|
||||
{
|
||||
var sName = this.name();
|
||||
return '' === sName ? this.email() : sName + ' <' + this.email() + '>';
|
||||
};
|
||||
|
||||
IdentityModel.prototype.formattedNameForCompose = function ()
|
||||
{
|
||||
var sName = this.name();
|
||||
return '' === sName ? this.email() : sName + ' (' + this.email() + ')';
|
||||
};
|
||||
|
||||
IdentityModel.prototype.formattedNameForEmail = function ()
|
||||
{
|
||||
var sName = this.name();
|
||||
return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>';
|
||||
};
|
||||
897
dev/Models/MessageModel.js
Normal file
897
dev/Models/MessageModel.js
Normal file
|
|
@ -0,0 +1,897 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function MessageModel()
|
||||
{
|
||||
this.folderFullNameRaw = '';
|
||||
this.uid = '';
|
||||
this.requestHash = '';
|
||||
this.subject = ko.observable('');
|
||||
this.size = ko.observable(0);
|
||||
this.dateTimeStampInUTC = ko.observable(0);
|
||||
this.priority = ko.observable(Enums.MessagePriority.Normal);
|
||||
|
||||
this.fromEmailString = ko.observable('');
|
||||
this.toEmailsString = ko.observable('');
|
||||
this.senderEmailsString = ko.observable('');
|
||||
|
||||
this.prefetched = false;
|
||||
|
||||
this.emails = [];
|
||||
|
||||
this.from = [];
|
||||
this.to = [];
|
||||
this.cc = [];
|
||||
this.bcc = [];
|
||||
this.replyTo = [];
|
||||
|
||||
this.newForAnimation = ko.observable(false);
|
||||
|
||||
this.deleted = ko.observable(false);
|
||||
this.unseen = ko.observable(false);
|
||||
this.flagged = ko.observable(false);
|
||||
this.answered = ko.observable(false);
|
||||
this.forwarded = ko.observable(false);
|
||||
|
||||
this.selected = ko.observable(false);
|
||||
this.checked = ko.observable(false);
|
||||
this.hasAttachments = ko.observable(false);
|
||||
this.attachmentsMainType = ko.observable('');
|
||||
|
||||
this.moment = ko.observable(moment());
|
||||
|
||||
this.attachmentIconClass = ko.computed(function () {
|
||||
var sClass = '';
|
||||
if (this.hasAttachments())
|
||||
{
|
||||
sClass = 'icon-attachment';
|
||||
switch (this.attachmentsMainType())
|
||||
{
|
||||
case 'image':
|
||||
sClass = 'icon-image';
|
||||
break;
|
||||
case 'archive':
|
||||
sClass = 'icon-file-zip';
|
||||
break;
|
||||
case 'doc':
|
||||
sClass = 'icon-file';
|
||||
break;
|
||||
case 'pdf':
|
||||
sClass = 'icon-file-pdf';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sClass;
|
||||
}, this);
|
||||
|
||||
this.fullFormatDateValue = ko.computed(function () {
|
||||
return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
|
||||
}, this);
|
||||
|
||||
this.fullFormatDateValue = ko.computed(function () {
|
||||
return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
|
||||
}, this);
|
||||
|
||||
this.momentDate = Utils.createMomentDate(this);
|
||||
this.momentShortDate = Utils.createMomentShortDate(this);
|
||||
|
||||
this.dateTimeStampInUTC.subscribe(function (iValue) {
|
||||
var iNow = moment().unix();
|
||||
this.moment(moment.unix(iNow < iValue ? iNow : iValue));
|
||||
}, this);
|
||||
|
||||
this.body = null;
|
||||
this.isRtl = ko.observable(false);
|
||||
this.isHtml = ko.observable(false);
|
||||
this.hasImages = ko.observable(false);
|
||||
this.attachments = ko.observableArray([]);
|
||||
|
||||
this.priority = ko.observable(Enums.MessagePriority.Normal);
|
||||
this.aDraftInfo = [];
|
||||
this.sMessageId = '';
|
||||
this.sInReplyTo = '';
|
||||
this.sReferences = '';
|
||||
|
||||
this.parentUid = ko.observable(0);
|
||||
this.threads = ko.observableArray([]);
|
||||
this.threadsLen = ko.observable(0);
|
||||
this.hasUnseenSubMessage = ko.observable(false);
|
||||
this.hasFlaggedSubMessage = ko.observable(false);
|
||||
|
||||
this.lastInCollapsedThread = ko.observable(false);
|
||||
this.lastInCollapsedThreadLoading = ko.observable(false);
|
||||
|
||||
this.threadsLenResult = ko.computed(function () {
|
||||
var iCount = this.threadsLen();
|
||||
return 0 === this.parentUid() && 0 < iCount ? iCount + 1 : '';
|
||||
}, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {AjaxJsonMessage} oJsonMessage
|
||||
* @return {?MessageModel}
|
||||
*/
|
||||
MessageModel.newInstanceFromJson = function (oJsonMessage)
|
||||
{
|
||||
var oMessageModel = new MessageModel();
|
||||
return oMessageModel.initByJson(oJsonMessage) ? oMessageModel : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {number} iTimeStampInUTC
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC)
|
||||
{
|
||||
return moment.unix(iTimeStampInUTC).format('LLL');
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {Array} aEmail
|
||||
* @param {boolean=} bFriendlyView
|
||||
* @param {boolean=} bWrapWithLink = false
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.emailsToLine = function (aEmail, bFriendlyView, bWrapWithLink)
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
iIndex = 0,
|
||||
iLen = 0
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(aEmail))
|
||||
{
|
||||
for (iIndex = 0, iLen = aEmail.length; iIndex < iLen; iIndex++)
|
||||
{
|
||||
aResult.push(aEmail[iIndex].toLine(bFriendlyView, bWrapWithLink));
|
||||
}
|
||||
}
|
||||
|
||||
return aResult.join(', ');
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {?Array} aJsonEmails
|
||||
* @return {Array}
|
||||
*/
|
||||
MessageModel.initEmailsFromJson = function (aJsonEmails)
|
||||
{
|
||||
var
|
||||
iIndex = 0,
|
||||
iLen = 0,
|
||||
oEmailModel = null,
|
||||
aResult = []
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(aJsonEmails))
|
||||
{
|
||||
for (iIndex = 0, iLen = aJsonEmails.length; iIndex < iLen; iIndex++)
|
||||
{
|
||||
oEmailModel = EmailModel.newInstanceFromJson(aJsonEmails[iIndex]);
|
||||
if (oEmailModel)
|
||||
{
|
||||
aResult.push(oEmailModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {Array.<EmailModel>} aMessageEmails
|
||||
* @param {Object} oLocalUnic
|
||||
* @param {Array} aLocalEmails
|
||||
*/
|
||||
MessageModel.replyHelper = function (aMessageEmails, oLocalUnic, aLocalEmails)
|
||||
{
|
||||
if (aMessageEmails && 0 < aMessageEmails.length)
|
||||
{
|
||||
var
|
||||
iIndex = 0,
|
||||
iLen = aMessageEmails.length
|
||||
;
|
||||
|
||||
for (; iIndex < iLen; iIndex++)
|
||||
{
|
||||
if (Utils.isUnd(oLocalUnic[aMessageEmails[iIndex].email]))
|
||||
{
|
||||
oLocalUnic[aMessageEmails[iIndex].email] = true;
|
||||
aLocalEmails.push(aMessageEmails[iIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {AjaxJsonMessage} oJsonMessage
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageModel.prototype.initByJson = function (oJsonMessage)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
|
||||
{
|
||||
this.folderFullNameRaw = oJsonMessage.Folder;
|
||||
this.uid = oJsonMessage.Uid;
|
||||
this.requestHash = oJsonMessage.RequestHash;
|
||||
|
||||
this.prefetched = false;
|
||||
|
||||
this.size(Utils.pInt(oJsonMessage.Size));
|
||||
|
||||
this.from = MessageModel.initEmailsFromJson(oJsonMessage.From);
|
||||
this.to = MessageModel.initEmailsFromJson(oJsonMessage.To);
|
||||
this.cc = MessageModel.initEmailsFromJson(oJsonMessage.Cc);
|
||||
this.bcc = MessageModel.initEmailsFromJson(oJsonMessage.Bcc);
|
||||
this.replyTo = MessageModel.initEmailsFromJson(oJsonMessage.ReplyTo);
|
||||
|
||||
this.subject(oJsonMessage.Subject);
|
||||
this.dateTimeStampInUTC(Utils.pInt(oJsonMessage.DateTimeStampInUTC));
|
||||
this.hasAttachments(!!oJsonMessage.HasAttachments);
|
||||
this.attachmentsMainType(oJsonMessage.AttachmentsMainType);
|
||||
|
||||
this.fromEmailString(MessageModel.emailsToLine(this.from, true));
|
||||
this.toEmailsString(MessageModel.emailsToLine(this.to, true));
|
||||
|
||||
this.parentUid(Utils.pInt(oJsonMessage.ParentThread));
|
||||
this.threads(Utils.isArray(oJsonMessage.Threads) ? oJsonMessage.Threads : []);
|
||||
this.threadsLen(Utils.pInt(oJsonMessage.ThreadsLen));
|
||||
|
||||
this.initFlagsByJson(oJsonMessage);
|
||||
this.computeSenderEmail();
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
MessageModel.prototype.computeSenderEmail = function ()
|
||||
{
|
||||
var
|
||||
sSent = RL.data().sentFolder(),
|
||||
sDraft = RL.data().draftFolder()
|
||||
;
|
||||
|
||||
this.senderEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ?
|
||||
this.toEmailsString() : this.fromEmailString());
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {AjaxJsonMessage} oJsonMessage
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage)
|
||||
{
|
||||
var
|
||||
bResult = false,
|
||||
iPriority = Enums.MessagePriority.Normal
|
||||
;
|
||||
|
||||
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
|
||||
{
|
||||
iPriority = Utils.pInt(oJsonMessage.Priority);
|
||||
this.priority(-1 < Utils.inArray(iPriority, [Enums.MessagePriority.High, Enums.MessagePriority.Low]) ?
|
||||
iPriority : Enums.MessagePriority.Normal);
|
||||
|
||||
this.aDraftInfo = oJsonMessage.DraftInfo;
|
||||
|
||||
this.sMessageId = oJsonMessage.MessageId;
|
||||
this.sInReplyTo = oJsonMessage.InReplyTo;
|
||||
this.sReferences = oJsonMessage.References;
|
||||
|
||||
this.hasAttachments(!!oJsonMessage.HasAttachments);
|
||||
this.attachmentsMainType(oJsonMessage.AttachmentsMainType);
|
||||
|
||||
this.foundedCIDs = Utils.isArray(oJsonMessage.FoundedCIDs) ? oJsonMessage.FoundedCIDs : [];
|
||||
this.attachments(this.initAttachmentsFromJson(oJsonMessage.Attachments));
|
||||
|
||||
this.computeSenderEmail();
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {(AjaxJsonAttachment|null)} oJsonAttachments
|
||||
* @return {Array}
|
||||
*/
|
||||
MessageModel.prototype.initAttachmentsFromJson = function (oJsonAttachments)
|
||||
{
|
||||
var
|
||||
iIndex = 0,
|
||||
iLen = 0,
|
||||
oAttachmentModel = null,
|
||||
aResult = []
|
||||
;
|
||||
|
||||
if (oJsonAttachments && 'Collection/AttachmentCollection' === oJsonAttachments['@Object'] &&
|
||||
Utils.isNonEmptyArray(oJsonAttachments['@Collection']))
|
||||
{
|
||||
for (iIndex = 0, iLen = oJsonAttachments['@Collection'].length; iIndex < iLen; iIndex++)
|
||||
{
|
||||
oAttachmentModel = AttachmentModel.newInstanceFromJson(oJsonAttachments['@Collection'][iIndex]);
|
||||
if (oAttachmentModel)
|
||||
{
|
||||
if ('' !== oAttachmentModel.cidWithOutTags && 0 < this.foundedCIDs.length &&
|
||||
0 <= Utils.inArray(oAttachmentModel.cidWithOutTags, this.foundedCIDs))
|
||||
{
|
||||
oAttachmentModel.isLinked = true;
|
||||
}
|
||||
|
||||
aResult.push(oAttachmentModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {AjaxJsonMessage} oJsonMessage
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageModel.prototype.initFlagsByJson = function (oJsonMessage)
|
||||
{
|
||||
var bResult = false;
|
||||
|
||||
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
|
||||
{
|
||||
this.unseen(!oJsonMessage.IsSeen);
|
||||
this.flagged(!!oJsonMessage.IsFlagged);
|
||||
this.answered(!!oJsonMessage.IsAnswered);
|
||||
this.forwarded(!!oJsonMessage.IsForwarded);
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} bFriendlyView
|
||||
* @param {boolean=} bWrapWithLink = false
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.fromToLine = function (bFriendlyView, bWrapWithLink)
|
||||
{
|
||||
return MessageModel.emailsToLine(this.from, bFriendlyView, bWrapWithLink);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} bFriendlyView
|
||||
* @param {boolean=} bWrapWithLink = false
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.toToLine = function (bFriendlyView, bWrapWithLink)
|
||||
{
|
||||
return MessageModel.emailsToLine(this.to, bFriendlyView, bWrapWithLink);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} bFriendlyView
|
||||
* @param {boolean=} bWrapWithLink = false
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.ccToLine = function (bFriendlyView, bWrapWithLink)
|
||||
{
|
||||
return MessageModel.emailsToLine(this.cc, bFriendlyView, bWrapWithLink);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} bFriendlyView
|
||||
* @param {boolean=} bWrapWithLink = false
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.bccToLine = function (bFriendlyView, bWrapWithLink)
|
||||
{
|
||||
return MessageModel.emailsToLine(this.bcc, bFriendlyView, bWrapWithLink);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
MessageModel.prototype.lineAsCcc = function ()
|
||||
{
|
||||
var aResult = [];
|
||||
if (this.deleted())
|
||||
{
|
||||
aResult.push('deleted');
|
||||
}
|
||||
if (this.selected())
|
||||
{
|
||||
aResult.push('selected');
|
||||
}
|
||||
if (this.checked())
|
||||
{
|
||||
aResult.push('checked');
|
||||
}
|
||||
if (this.flagged())
|
||||
{
|
||||
aResult.push('flagged');
|
||||
}
|
||||
if (this.unseen())
|
||||
{
|
||||
aResult.push('unseen');
|
||||
}
|
||||
if (this.answered())
|
||||
{
|
||||
aResult.push('answered');
|
||||
}
|
||||
if (this.forwarded())
|
||||
{
|
||||
aResult.push('forwarded');
|
||||
}
|
||||
if (this.hasAttachments())
|
||||
{
|
||||
aResult.push('withAttachments');
|
||||
switch (this.attachmentsMainType())
|
||||
{
|
||||
case 'image':
|
||||
aResult.push('imageOnlyAttachments');
|
||||
break;
|
||||
case 'archive':
|
||||
aResult.push('archiveOnlyAttachments');
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.newForAnimation())
|
||||
{
|
||||
aResult.push('new');
|
||||
}
|
||||
if ('' === this.subject())
|
||||
{
|
||||
aResult.push('emptySubject');
|
||||
}
|
||||
if (0 < this.parentUid())
|
||||
{
|
||||
aResult.push('hasParentMessage');
|
||||
}
|
||||
if (0 < this.threadsLen() && 0 === this.parentUid())
|
||||
{
|
||||
aResult.push('hasChildrenMessage');
|
||||
}
|
||||
if (this.hasUnseenSubMessage())
|
||||
{
|
||||
aResult.push('hasUnseenSubMessage');
|
||||
}
|
||||
if (this.hasFlaggedSubMessage())
|
||||
{
|
||||
aResult.push('hasFlaggedSubMessage');
|
||||
}
|
||||
|
||||
return aResult.join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageModel.prototype.hasVisibleAttachments = function ()
|
||||
{
|
||||
return !!_.find(this.attachments(), function (oAttachment) {
|
||||
return !oAttachment.isLinked;
|
||||
});
|
||||
// return 0 < this.attachments().length;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sCid
|
||||
* @return {*}
|
||||
*/
|
||||
MessageModel.prototype.findAttachmentByCid = function (sCid)
|
||||
{
|
||||
var
|
||||
oResult = null,
|
||||
aAttachments = this.attachments()
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(aAttachments))
|
||||
{
|
||||
sCid = sCid.replace(/^<+/, '').replace(/>+$/, '');
|
||||
oResult = _.find(aAttachments, function (oAttachment) {
|
||||
return sCid === oAttachment.cidWithOutTags;
|
||||
});
|
||||
}
|
||||
|
||||
return oResult || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sContentLocation
|
||||
* @return {*}
|
||||
*/
|
||||
MessageModel.prototype.findAttachmentByContentLocation = function (sContentLocation)
|
||||
{
|
||||
var
|
||||
oResult = null,
|
||||
aAttachments = this.attachments()
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(aAttachments))
|
||||
{
|
||||
oResult = _.find(aAttachments, function (oAttachment) {
|
||||
return sContentLocation === oAttachment.contentLocation;
|
||||
});
|
||||
}
|
||||
|
||||
return oResult || null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.messageId = function ()
|
||||
{
|
||||
return this.sMessageId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.inReplyTo = function ()
|
||||
{
|
||||
return this.sInReplyTo;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.references = function ()
|
||||
{
|
||||
return this.sReferences;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.fromAsSingleEmail = function ()
|
||||
{
|
||||
return Utils.isArray(this.from) && this.from[0] ? this.from[0].email : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.viewLink = function ()
|
||||
{
|
||||
return RL.link().messageViewLink(this.requestHash);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.downloadLink = function ()
|
||||
{
|
||||
return RL.link().messageDownloadLink(this.requestHash);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oExcludeEmails
|
||||
* @return {Array}
|
||||
*/
|
||||
MessageModel.prototype.replyEmails = function (oExcludeEmails)
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails
|
||||
;
|
||||
|
||||
MessageModel.replyHelper(this.replyTo, oUnic, aResult);
|
||||
if (0 === aResult.length)
|
||||
{
|
||||
MessageModel.replyHelper(this.from, oUnic, aResult);
|
||||
}
|
||||
|
||||
return aResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oExcludeEmails
|
||||
* @return {Array.<Array>}
|
||||
*/
|
||||
MessageModel.prototype.replyAllEmails = function (oExcludeEmails)
|
||||
{
|
||||
var
|
||||
aToResult = [],
|
||||
aCcResult = [],
|
||||
oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails
|
||||
;
|
||||
|
||||
MessageModel.replyHelper(this.replyTo, oUnic, aToResult);
|
||||
if (0 === aToResult.length)
|
||||
{
|
||||
MessageModel.replyHelper(this.from, oUnic, aToResult);
|
||||
}
|
||||
|
||||
MessageModel.replyHelper(this.to, oUnic, aToResult);
|
||||
MessageModel.replyHelper(this.cc, oUnic, aCcResult);
|
||||
|
||||
return [aToResult, aCcResult];
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.textBodyToString = function ()
|
||||
{
|
||||
return this.body ? this.body.html() : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.prototype.attachmentsToStringLine = function ()
|
||||
{
|
||||
var aAttachLines = _.map(this.attachments(), function (oItem) {
|
||||
return oItem.fileName + ' (' + oItem.friendlySize + ')';
|
||||
});
|
||||
|
||||
return aAttachLines && 0 < aAttachLines.length ? aAttachLines.join(', ') : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Object}
|
||||
*/
|
||||
MessageModel.prototype.getDataForWindowPopup = function ()
|
||||
{
|
||||
return {
|
||||
'popupFrom': this.fromToLine(false),
|
||||
'popupTo': this.toToLine(false),
|
||||
'popupCc': this.ccToLine(false),
|
||||
'popupBcc': this.bccToLine(false),
|
||||
'popupSubject': this.subject(),
|
||||
'popupDate': this.fullFormatDateValue(),
|
||||
'popupAttachments': this.attachmentsToStringLine(),
|
||||
'popupBody': this.textBodyToString()
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean=} bPrint = false
|
||||
*/
|
||||
MessageModel.prototype.viewPopupMessage = function (bPrint)
|
||||
{
|
||||
Utils.windowPopupKnockout(this.getDataForWindowPopup(), 'PopupsWindowSimpleMessage', this.subject(), function (oPopupWin) {
|
||||
if (oPopupWin && oPopupWin.document && oPopupWin.document.body)
|
||||
{
|
||||
$('img.lazy', oPopupWin.document.body).each(function (iIndex, oImg) {
|
||||
|
||||
var
|
||||
$oImg = $(oImg),
|
||||
sOrig = $oImg.data('original'),
|
||||
sSrc = $oImg.attr('src')
|
||||
;
|
||||
|
||||
if (0 <= iIndex && sOrig && !sSrc)
|
||||
{
|
||||
$oImg.attr('src', sOrig);
|
||||
}
|
||||
});
|
||||
|
||||
if (bPrint)
|
||||
{
|
||||
window.setTimeout(function () {
|
||||
oPopupWin.print();
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
MessageModel.prototype.printMessage = function ()
|
||||
{
|
||||
this.viewPopupMessage(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
MessageModel.prototype.generateUid = function ()
|
||||
{
|
||||
return this.folderFullNameRaw + '/' + this.uid;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
* @return {MessageModel}
|
||||
*/
|
||||
MessageModel.prototype.populateByMessageListItem = function (oMessage)
|
||||
{
|
||||
this.folderFullNameRaw = oMessage.folderFullNameRaw;
|
||||
this.uid = oMessage.uid;
|
||||
this.requestHash = oMessage.requestHash;
|
||||
this.subject(oMessage.subject());
|
||||
this.size(oMessage.size());
|
||||
this.dateTimeStampInUTC(oMessage.dateTimeStampInUTC());
|
||||
this.priority(oMessage.priority());
|
||||
|
||||
this.fromEmailString(oMessage.fromEmailString());
|
||||
this.toEmailsString(oMessage.toEmailsString());
|
||||
|
||||
this.emails = oMessage.emails;
|
||||
|
||||
this.from = oMessage.from;
|
||||
this.to = oMessage.to;
|
||||
this.cc = oMessage.cc;
|
||||
this.bcc = oMessage.bcc;
|
||||
this.replyTo = oMessage.replyTo;
|
||||
|
||||
this.unseen(oMessage.unseen());
|
||||
this.flagged(oMessage.flagged());
|
||||
this.answered(oMessage.answered());
|
||||
this.forwarded(oMessage.forwarded());
|
||||
|
||||
this.selected(oMessage.selected());
|
||||
this.checked(oMessage.checked());
|
||||
this.hasAttachments(oMessage.hasAttachments());
|
||||
this.attachmentsMainType(oMessage.attachmentsMainType());
|
||||
|
||||
this.moment(oMessage.moment());
|
||||
|
||||
this.body = null;
|
||||
// this.isRtl(oMessage.isRtl());
|
||||
// this.isHtml(false);
|
||||
// this.hasImages(false);
|
||||
// this.attachments([]);
|
||||
|
||||
this.priority(Enums.MessagePriority.Normal);
|
||||
this.aDraftInfo = [];
|
||||
this.sMessageId = '';
|
||||
this.sInReplyTo = '';
|
||||
this.sReferences = '';
|
||||
|
||||
this.parentUid(oMessage.parentUid());
|
||||
this.threads(oMessage.threads());
|
||||
this.threadsLen(oMessage.threadsLen());
|
||||
|
||||
this.computeSenderEmail();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
MessageModel.prototype.showExternalImages = function (bLazy)
|
||||
{
|
||||
if (this.body && this.body.data('rl-has-images'))
|
||||
{
|
||||
bLazy = Utils.isUnd(bLazy) ? false : bLazy;
|
||||
|
||||
this.hasImages(false);
|
||||
this.body.data('rl-has-images', false);
|
||||
|
||||
$('[data-x-src]', this.body).each(function () {
|
||||
if (bLazy && $(this).is('img'))
|
||||
{
|
||||
$(this)
|
||||
.addClass('lazy')
|
||||
.attr('data-original', $(this).attr('data-x-src'))
|
||||
.removeAttr('data-x-src')
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', $(this).attr('data-x-src')).removeAttr('data-x-src');
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-x-style-url]', this.body).each(function () {
|
||||
var sStyle = Utils.trim($(this).attr('style'));
|
||||
sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
|
||||
$(this).attr('style', sStyle + $(this).attr('data-x-style-url')).removeAttr('data-x-style-url');
|
||||
});
|
||||
|
||||
if (bLazy)
|
||||
{
|
||||
$('img.lazy', this.body).addClass('lazy-inited').lazyload({
|
||||
'threshold' : 400,
|
||||
'effect' : 'fadeIn',
|
||||
'skip_invisible' : false,
|
||||
'container': $('.RL-MailMessageView .messageView .messageItem .content')[0]
|
||||
});
|
||||
|
||||
$window.resize();
|
||||
}
|
||||
|
||||
Utils.windowResize(500);
|
||||
}
|
||||
};
|
||||
|
||||
MessageModel.prototype.showInternalImages = function (bLazy)
|
||||
{
|
||||
if (this.body && !this.body.data('rl-init-internal-images'))
|
||||
{
|
||||
bLazy = Utils.isUnd(bLazy) ? false : bLazy;
|
||||
|
||||
var self = this;
|
||||
|
||||
this.body.data('rl-init-internal-images', true);
|
||||
|
||||
$('[data-x-src-cid]', this.body).each(function () {
|
||||
|
||||
var oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-cid'));
|
||||
if (oAttachment && oAttachment.download)
|
||||
{
|
||||
if (bLazy && $(this).is('img'))
|
||||
{
|
||||
$(this)
|
||||
.addClass('lazy')
|
||||
.attr('data-original', oAttachment.linkPreview());
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', oAttachment.linkPreview());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-x-src-location]', this.body).each(function () {
|
||||
|
||||
var oAttachment = self.findAttachmentByContentLocation($(this).attr('data-x-src-location'));
|
||||
if (!oAttachment)
|
||||
{
|
||||
oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-location'));
|
||||
}
|
||||
|
||||
if (oAttachment && oAttachment.download)
|
||||
{
|
||||
if (bLazy && $(this).is('img'))
|
||||
{
|
||||
$(this)
|
||||
.addClass('lazy')
|
||||
.attr('data-original', oAttachment.linkPreview());
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', oAttachment.linkPreview());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-x-style-cid]', this.body).each(function () {
|
||||
|
||||
var
|
||||
sStyle = '',
|
||||
sName = '',
|
||||
oAttachment = self.findAttachmentByCid($(this).attr('data-x-style-cid'))
|
||||
;
|
||||
|
||||
if (oAttachment && oAttachment.linkPreview)
|
||||
{
|
||||
sName = $(this).attr('data-x-style-cid-name');
|
||||
if ('' !== sName)
|
||||
{
|
||||
sStyle = Utils.trim($(this).attr('style'));
|
||||
sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
|
||||
$(this).attr('style', sStyle + sName + ': url(\'' + oAttachment.linkPreview() + '\')');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (bLazy)
|
||||
{
|
||||
(function ($oImg, oContainer) {
|
||||
_.delay(function () {
|
||||
$oImg.addClass('lazy-inited').lazyload({
|
||||
'threshold' : 400,
|
||||
'effect' : 'fadeIn',
|
||||
'skip_invisible' : false,
|
||||
'container': oContainer
|
||||
});
|
||||
}, 300);
|
||||
}($('img.lazy', self.body), $('.RL-MailMessageView .messageView .messageItem .content')[0]));
|
||||
}
|
||||
|
||||
Utils.windowResize(500);
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue