mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 00:14:50 +03:00
es5 -> es2015 (last stage)
Signature plugin fixes Add view decorator A large number of fixes
This commit is contained in:
parent
e88c193334
commit
17669b7be0
153 changed files with 21193 additions and 21115 deletions
|
|
@ -218,10 +218,10 @@ class EmailModel
|
|||
return false;
|
||||
}
|
||||
|
||||
var
|
||||
substr = function(str, start, len) {
|
||||
const
|
||||
substr = (str, start, len) => {
|
||||
str = pString(str);
|
||||
var end = str.length;
|
||||
let end = str.length;
|
||||
|
||||
if (0 > start)
|
||||
{
|
||||
|
|
@ -233,7 +233,7 @@ class EmailModel
|
|||
return start >= str.length || 0 > start || start > end ? false : str.slice(start, end);
|
||||
},
|
||||
|
||||
substrReplace = function(str, replace, start, length) {
|
||||
substrReplace = (str, replace, start, length) => {
|
||||
str = pString(str);
|
||||
if (0 > start)
|
||||
{
|
||||
|
|
@ -246,8 +246,9 @@ class EmailModel
|
|||
length = length + str.length - start;
|
||||
}
|
||||
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);
|
||||
},
|
||||
};
|
||||
|
||||
let
|
||||
$sName = '',
|
||||
$sEmail = '',
|
||||
$sComment = '',
|
||||
|
|
|
|||
|
|
@ -190,9 +190,7 @@ class FilterModel extends AbstractModel
|
|||
Enabled: this.enabled() ? '1' : '0',
|
||||
Name: this.name(),
|
||||
ConditionsType: this.conditionsType(),
|
||||
Conditions: _.map(this.conditions(), function(oItem) {
|
||||
return oItem.toJson();
|
||||
}),
|
||||
Conditions: _.map(this.conditions(), (item) => item.toJson()),
|
||||
|
||||
ActionValue: this.actionValue(),
|
||||
ActionValueSecond: this.actionValueSecond(),
|
||||
|
|
@ -257,7 +255,8 @@ class FilterModel extends AbstractModel
|
|||
}
|
||||
|
||||
cloneSelf() {
|
||||
var filter = new FilterModel();
|
||||
|
||||
const filter = new FilterModel();
|
||||
|
||||
filter.id = this.id;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,30 +19,30 @@ class FilterConditionModel extends AbstractModel
|
|||
this.valueSecond = ko.observable('');
|
||||
this.valueSecond.error = ko.observable(false);
|
||||
|
||||
this.template = ko.computed(function() {
|
||||
this.template = ko.computed(() => {
|
||||
|
||||
var sTemplate = '';
|
||||
let template = '';
|
||||
switch (this.field())
|
||||
{
|
||||
case FilterConditionField.Size:
|
||||
sTemplate = 'SettingsFiltersConditionSize';
|
||||
template = 'SettingsFiltersConditionSize';
|
||||
break;
|
||||
case FilterConditionField.Header:
|
||||
sTemplate = 'SettingsFiltersConditionMore';
|
||||
template = 'SettingsFiltersConditionMore';
|
||||
break;
|
||||
default:
|
||||
sTemplate = 'SettingsFiltersConditionDefault';
|
||||
template = 'SettingsFiltersConditionDefault';
|
||||
break;
|
||||
}
|
||||
|
||||
return sTemplate;
|
||||
return template;
|
||||
|
||||
}, this);
|
||||
|
||||
this.field.subscribe(function() {
|
||||
this.field.subscribe(() => {
|
||||
this.value('');
|
||||
this.valueSecond('');
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.regDisposables([this.template]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ class FolderModel extends AbstractModel
|
|||
|
||||
this.isInbox = ko.computed(() => FolderType.Inbox === this.type());
|
||||
|
||||
this.hasSubScribedSubfolders = ko.computed(function() {
|
||||
return !!_.find(this.subFolders(), (oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder());
|
||||
}, this);
|
||||
this.hasSubScribedSubfolders = ko.computed(
|
||||
() => !!_.find(this.subFolders(), (oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder())
|
||||
);
|
||||
|
||||
this.canBeEdited = ko.computed(() => FolderType.User === this.type() && this.existen && this.selectable);
|
||||
|
||||
|
|
@ -236,9 +236,9 @@ class FolderModel extends AbstractModel
|
|||
|
||||
this.hasUnreadMessages = ko.computed(() => 0 < this.messageCountUnread() && '' !== this.printableUnreadCount());
|
||||
|
||||
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function() {
|
||||
return !!_.find(this.subFolders(), (folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders());
|
||||
}, this);
|
||||
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(
|
||||
() => !!_.find(this.subFolders(), (folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders())
|
||||
);
|
||||
|
||||
// subscribe
|
||||
this.name.subscribe((value) => {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,11 @@
|
|||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
import moment from 'moment';
|
||||
import classnames from 'classnames';
|
||||
|
||||
import {MessagePriority, SignedVerifyStatus} from 'Common/Enums';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
import {
|
||||
pInt, inArray, isArray, isUnd, trim,
|
||||
|
|
@ -455,73 +458,24 @@ class MessageModel extends AbstractModel
|
|||
* @return string
|
||||
*/
|
||||
lineAsCss() {
|
||||
const result = [];
|
||||
if (this.deleted())
|
||||
{
|
||||
result.push('deleted');
|
||||
}
|
||||
if (this.deletedMark())
|
||||
{
|
||||
result.push('deleted-mark');
|
||||
}
|
||||
if (this.selected())
|
||||
{
|
||||
result.push('selected');
|
||||
}
|
||||
if (this.checked())
|
||||
{
|
||||
result.push('checked');
|
||||
}
|
||||
if (this.flagged())
|
||||
{
|
||||
result.push('flagged');
|
||||
}
|
||||
if (this.unseen())
|
||||
{
|
||||
result.push('unseen');
|
||||
}
|
||||
if (this.answered())
|
||||
{
|
||||
result.push('answered');
|
||||
}
|
||||
if (this.forwarded())
|
||||
{
|
||||
result.push('forwarded');
|
||||
}
|
||||
if (this.focused())
|
||||
{
|
||||
result.push('focused');
|
||||
}
|
||||
if (this.isImportant())
|
||||
{
|
||||
result.push('important');
|
||||
}
|
||||
if (this.hasAttachments())
|
||||
{
|
||||
result.push('withAttachments');
|
||||
}
|
||||
if (this.newForAnimation())
|
||||
{
|
||||
result.push('new');
|
||||
}
|
||||
if ('' === this.subject())
|
||||
{
|
||||
result.push('emptySubject');
|
||||
}
|
||||
// if (1 < this.threadsLen())
|
||||
// {
|
||||
// result.push('hasChildrenMessage');
|
||||
// }
|
||||
if (this.hasUnseenSubMessage())
|
||||
{
|
||||
result.push('hasUnseenSubMessage');
|
||||
}
|
||||
if (this.hasFlaggedSubMessage())
|
||||
{
|
||||
result.push('hasFlaggedSubMessage');
|
||||
}
|
||||
|
||||
return result.join(' ');
|
||||
return classnames({
|
||||
'deleted': this.deleted(),
|
||||
'deleted-mark': this.deletedMark(),
|
||||
'selected': this.selected(),
|
||||
'checked': this.checked(),
|
||||
'flagged': this.flagged(),
|
||||
'unseen': this.unseen(),
|
||||
'answered': this.answered(),
|
||||
'forwarded': this.forwarded(),
|
||||
'focused': this.focused(),
|
||||
'important': this.isImportant(),
|
||||
'withAttachments': this.hasAttachments(),
|
||||
'new': this.newForAnimation(),
|
||||
'emptySubject': '' === this.subject(),
|
||||
// 'hasChildrenMessage': 1 < this.threadsLen(),
|
||||
'hasUnseenSubMessage': this.hasUnseenSubMessage(),
|
||||
'hasFlaggedSubMessage': this.hasFlaggedSubMessage()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -680,7 +634,19 @@ class MessageModel extends AbstractModel
|
|||
*/
|
||||
viewPopupMessage(print = false) {
|
||||
this.showLazyExternalImagesInBody();
|
||||
previewMessage(this.subject(), this.body, this.isHtml(), print);
|
||||
|
||||
const
|
||||
timeStampInUTC = this.dateTimeStampInUTC() || 0,
|
||||
m = 0 < timeStampInUTC ? moment.unix(timeStampInUTC) : null;
|
||||
|
||||
previewMessage({
|
||||
title: this.subject(),
|
||||
subject: this.subject(),
|
||||
date: m ? m.format('LLL') : '',
|
||||
fromCreds: this.fromToLine(false),
|
||||
toLabel: i18n('MESSAGE/LABEL_TO'),
|
||||
toCreds: this.toToLine(false)
|
||||
}, this.body, this.isHtml(), print);
|
||||
}
|
||||
|
||||
printMessage() {
|
||||
|
|
@ -770,7 +736,7 @@ class MessageModel extends AbstractModel
|
|||
if (this.body)
|
||||
{
|
||||
$('.lazy.lazy-inited[data-original]', this.body).each(function() {
|
||||
$(this).attr('src', $(this).attr('data-original')).removeAttr('data-original');
|
||||
$(this).attr('src', $(this).attr('data-original')).removeAttr('data-original'); // eslint-disable-line no-invalid-this
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -781,26 +747,28 @@ class MessageModel extends AbstractModel
|
|||
this.hasImages(false);
|
||||
this.body.data('rl-has-images', false);
|
||||
|
||||
var sAttr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
|
||||
$('[' + sAttr + ']', this.body).each(function() {
|
||||
if (lazy && $(this).is('img'))
|
||||
let attr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
|
||||
$('[' + attr + ']', this.body).each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
$(this)
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', $(this).attr(sAttr))
|
||||
.removeAttr(sAttr);
|
||||
.attr('data-original', $this.attr(attr))
|
||||
.removeAttr(attr);
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', $(this).attr(sAttr)).removeAttr(sAttr);
|
||||
$this.attr('src', $this.attr(attr)).removeAttr(attr);
|
||||
}
|
||||
});
|
||||
|
||||
sAttr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url';
|
||||
$('[' + sAttr + ']', this.body).each(function() {
|
||||
var sStyle = trim($(this).attr('style'));
|
||||
sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
|
||||
$(this).attr('style', sStyle + $(this).attr(sAttr)).removeAttr(sAttr);
|
||||
attr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url';
|
||||
$('[' + attr + ']', this.body).each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
let style = trim($this.attr('style'));
|
||||
style = '' === style ? '' : (';' === style.substr(-1) ? style + ' ' : style + '; ');
|
||||
$this.attr('style', style + $this.attr(attr)).removeAttr(attr);
|
||||
});
|
||||
|
||||
if (lazy)
|
||||
|
|
@ -824,43 +792,47 @@ class MessageModel extends AbstractModel
|
|||
{
|
||||
this.body.data('rl-init-internal-images', true);
|
||||
|
||||
var self = this;
|
||||
const self = this;
|
||||
|
||||
$('[data-x-src-cid]', this.body).each(function() {
|
||||
const attachment = self.findAttachmentByCid($(this).attr('data-x-src-cid'));
|
||||
const
|
||||
$this = $(this), // eslint-disable-line no-invalid-this
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-src-cid'));
|
||||
|
||||
if (attachment && attachment.download)
|
||||
{
|
||||
if (lazy && $(this).is('img'))
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
$(this)
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', attachment.linkPreview());
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', attachment.linkPreview());
|
||||
$this.attr('src', attachment.linkPreview());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-x-src-location]', this.body).each(function() {
|
||||
let attachment = self.findAttachmentByContentLocation($(this).attr('data-x-src-location'));
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
let attachment = self.findAttachmentByContentLocation($this.attr('data-x-src-location'));
|
||||
if (!attachment)
|
||||
{
|
||||
attachment = self.findAttachmentByCid($(this).attr('data-x-src-location'));
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-src-location'));
|
||||
}
|
||||
|
||||
if (attachment && attachment.download)
|
||||
{
|
||||
if (lazy && $(this).is('img'))
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
$(this)
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', attachment.linkPreview());
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', attachment.linkPreview());
|
||||
$this.attr('src', attachment.linkPreview());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -869,16 +841,19 @@ class MessageModel extends AbstractModel
|
|||
let
|
||||
style = '',
|
||||
name = '';
|
||||
const attachment = self.findAttachmentByCid($(this).attr('data-x-style-cid'));
|
||||
|
||||
const
|
||||
$this = $(this), // eslint-disable-line no-invalid-this
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-style-cid'));
|
||||
|
||||
if (attachment && attachment.linkPreview)
|
||||
{
|
||||
name = $(this).attr('data-x-style-cid-name');
|
||||
name = $this.attr('data-x-style-cid-name');
|
||||
if ('' !== name)
|
||||
{
|
||||
style = trim($(this).attr('style'));
|
||||
style = trim($this.attr('style'));
|
||||
style = '' === style ? '' : (';' === style.substr(-1) ? style + ' ' : style + '; ');
|
||||
$(this).attr('style', style + name + ': url(\'' + attachment.linkPreview() + '\')');
|
||||
$this.attr('style', style + name + ': url(\'' + attachment.linkPreview() + '\')');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue