mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 20:42:19 +08:00
Momentor (moment optimization)
This commit is contained in:
parent
7750587be1
commit
147dce6e4a
20 changed files with 331 additions and 173 deletions
|
@ -7,7 +7,6 @@
|
|||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
moment = require('moment'),
|
||||
SimplePace = require('SimplePace'),
|
||||
Tinycon = require('Tinycon'),
|
||||
|
||||
|
@ -18,7 +17,9 @@
|
|||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
Events = require('Common/Events'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
Momentor = require('Common/Momentor'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
|
||||
|
@ -651,7 +652,7 @@
|
|||
if (oData && oData.Result && oData.Result.Hash && oData.Result.Folder)
|
||||
{
|
||||
var
|
||||
iUtc = moment().unix(),
|
||||
iUtc = Momentor.momentNowUnix(),
|
||||
sHash = Cache.getFolderHash(oData.Result.Folder),
|
||||
oFolder = Cache.getFolderFromCacheList(oData.Result.Folder),
|
||||
bCheck = false,
|
||||
|
@ -750,7 +751,7 @@
|
|||
|
||||
var
|
||||
self = this,
|
||||
iUtc = moment().unix(),
|
||||
iUtc = Momentor.momentNowUnix(),
|
||||
aFolders = FolderStore.getNextFolderNames(bBoot)
|
||||
;
|
||||
|
||||
|
@ -1624,7 +1625,7 @@
|
|||
}
|
||||
|
||||
Events.sub('interval.1m', function () {
|
||||
Globals.momentTrigger(!Globals.momentTrigger());
|
||||
Momentor.reload();
|
||||
});
|
||||
|
||||
Plugins.runHook('rl-start-screens');
|
||||
|
|
|
@ -27,11 +27,6 @@
|
|||
*/
|
||||
Globals.now = (new window.Date()).getTime();
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.momentTrigger = ko.observable(true);
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
|
|
188
dev/Common/Momentor.js
Normal file
188
dev/Common/Momentor.js
Normal file
|
@ -0,0 +1,188 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
$ = require('$'),
|
||||
_ = require('_'),
|
||||
moment = require('moment'),
|
||||
|
||||
Translator = require('Common/Translator')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Momentor()
|
||||
{
|
||||
this.format = _.bind(this.format, this);
|
||||
|
||||
this.updateMomentNow = _.debounce(_.bind(function () {
|
||||
this._moment = moment();
|
||||
}, this), 500, true);
|
||||
|
||||
this.updateMomentNowUnix = _.debounce(_.bind(function () {
|
||||
this._momentNow = moment().unix();
|
||||
}, this), 500, true);
|
||||
}
|
||||
|
||||
Momentor.prototype._moment = null;
|
||||
Momentor.prototype._momentNow = 0;
|
||||
|
||||
Momentor.prototype.momentNow = function ()
|
||||
{
|
||||
this.updateMomentNow();
|
||||
return this._moment || moment();
|
||||
};
|
||||
|
||||
Momentor.prototype.momentNowUnix = function ()
|
||||
{
|
||||
this.updateMomentNowUnix();
|
||||
return this._momentNow || 0;
|
||||
};
|
||||
|
||||
Momentor.prototype.searchSubtractFormatDateHelper = function (iDate)
|
||||
{
|
||||
var oM = this.momentNow();
|
||||
return oM.clone().subtract('days', iDate).format('YYYY.MM.DD');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oMoment
|
||||
* @return {string}
|
||||
*/
|
||||
Momentor.prototype.formatCustomShortDate = function (oMoment)
|
||||
{
|
||||
var
|
||||
sResult = '',
|
||||
oMomentNow = this.momentNow()
|
||||
;
|
||||
|
||||
if (oMoment && oMomentNow)
|
||||
{
|
||||
if (4 >= oMomentNow.diff(oMoment, 'hours'))
|
||||
{
|
||||
sResult = oMoment.fromNow();
|
||||
}
|
||||
else if (oMomentNow.format('L') === oMoment.format('L'))
|
||||
{
|
||||
sResult = Translator.i18n('MESSAGE_LIST/TODAY_AT', {
|
||||
'TIME': oMoment.format('LT')
|
||||
});
|
||||
}
|
||||
else if (oMomentNow.clone().subtract('days', 1).format('L') === oMoment.format('L'))
|
||||
{
|
||||
sResult = Translator.i18n('MESSAGE_LIST/YESTERDAY_AT', {
|
||||
'TIME': oMoment.format('LT')
|
||||
});
|
||||
}
|
||||
else if (oMomentNow.year() === oMoment.year())
|
||||
{
|
||||
sResult = oMoment.format('D MMM.');
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = oMoment.format('LL');
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} iTimeStampInUTC
|
||||
* @param {string} sFormat
|
||||
* @return {string}
|
||||
*/
|
||||
Momentor.prototype.format = function (iTimeStampInUTC, sFormat)
|
||||
{
|
||||
var
|
||||
oM = null,
|
||||
sResult = '',
|
||||
iNow = this.momentNowUnix()
|
||||
;
|
||||
|
||||
iTimeStampInUTC = 0 < iTimeStampInUTC ? iTimeStampInUTC : (0 === iTimeStampInUTC ? iNow : 0);
|
||||
iTimeStampInUTC = iNow < iTimeStampInUTC ? iNow : iTimeStampInUTC;
|
||||
|
||||
oM = 0 < iTimeStampInUTC ? moment.unix(iTimeStampInUTC) : null;
|
||||
|
||||
if (oM && 1970 === oM.year())
|
||||
{
|
||||
oM = null;
|
||||
}
|
||||
|
||||
if (oM)
|
||||
{
|
||||
switch (sFormat)
|
||||
{
|
||||
case 'FROMNOW':
|
||||
sResult = oM.fromNow();
|
||||
break;
|
||||
case 'SHORT':
|
||||
sResult = this.formatCustomShortDate(oM);
|
||||
break;
|
||||
case 'FULL':
|
||||
sResult = oM.format('LLL');
|
||||
break;
|
||||
default:
|
||||
sResult = oM.format(sFormat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElement
|
||||
*/
|
||||
Momentor.prototype.momentToNode = function (oElement)
|
||||
{
|
||||
var
|
||||
sKey = '',
|
||||
iTime = 0,
|
||||
$oEl = $(oElement)
|
||||
;
|
||||
|
||||
iTime = $oEl.data('moment-time');
|
||||
if (iTime)
|
||||
{
|
||||
sKey = $oEl.data('moment-format');
|
||||
|
||||
if (sKey)
|
||||
{
|
||||
$oEl.text(this.format(iTime, sKey));
|
||||
}
|
||||
|
||||
sKey = $oEl.data('moment-format-title');
|
||||
if (sKey)
|
||||
{
|
||||
$oEl.attr('title', this.format(iTime, sKey));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElements
|
||||
*/
|
||||
Momentor.prototype.momentToNodes = function (oElements)
|
||||
{
|
||||
var self = this;
|
||||
_.defer(function () {
|
||||
$('.moment', oElements).each(function () {
|
||||
self.momentToNode(this);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Momentor.prototype.reload = function ()
|
||||
{
|
||||
this.momentToNodes(window.document);
|
||||
};
|
||||
|
||||
module.exports = new Momentor();
|
||||
|
||||
}());
|
|
@ -58,48 +58,57 @@
|
|||
|
||||
/**
|
||||
* @param {Object} oElement
|
||||
*/
|
||||
Translator.prototype.i18nToNode = function (oElement)
|
||||
{
|
||||
var
|
||||
sKey = '',
|
||||
$oEl = $(oElement)
|
||||
;
|
||||
|
||||
sKey = $oEl.data('i18n-text');
|
||||
if (sKey)
|
||||
{
|
||||
$oEl.text(this.i18n(sKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
sKey = $oEl.data('i18n-html');
|
||||
if (sKey)
|
||||
{
|
||||
$oEl.html(this.i18n(sKey));
|
||||
}
|
||||
|
||||
sKey = $oEl.data('i18n-placeholder');
|
||||
if (sKey)
|
||||
{
|
||||
$oEl.attr('placeholder', this.i18n(sKey));
|
||||
}
|
||||
|
||||
sKey = $oEl.data('i18n-title');
|
||||
if (sKey)
|
||||
{
|
||||
$oEl.attr('title', this.i18n(sKey));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElements
|
||||
* @param {boolean=} bAnimate = false
|
||||
*/
|
||||
Translator.prototype.i18nToNode = function (oElement, bAnimate)
|
||||
Translator.prototype.i18nToNodes = function (oElements, bAnimate)
|
||||
{
|
||||
var self = this;
|
||||
_.defer(function () {
|
||||
$('.i18n', oElement).each(function () {
|
||||
var
|
||||
jqThis = $(this),
|
||||
sKey = ''
|
||||
;
|
||||
|
||||
sKey = jqThis.data('i18n-text');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.text(self.i18n(sKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
sKey = jqThis.data('i18n-html');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.html(self.i18n(sKey));
|
||||
}
|
||||
|
||||
sKey = jqThis.data('i18n-placeholder');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.attr('placeholder', self.i18n(sKey));
|
||||
}
|
||||
|
||||
sKey = jqThis.data('i18n-title');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.attr('title', self.i18n(sKey));
|
||||
}
|
||||
}
|
||||
$('.i18n', oElements).each(function () {
|
||||
self.i18nToNode(this);
|
||||
});
|
||||
|
||||
if (bAnimate && Globals.bAnimationSupported)
|
||||
{
|
||||
$('.i18n-animation.i18n', oElement).letterfx({
|
||||
$('.i18n-animation.i18n', oElements).letterfx({
|
||||
'fx': 'fall fade', 'backwards': false, 'timing': 50, 'fx_duration': '50ms', 'letter_end': 'restore', 'element_end': 'restore'
|
||||
});
|
||||
}
|
||||
|
@ -112,7 +121,9 @@
|
|||
{
|
||||
this.data = window['rainloopI18N'] || {};
|
||||
|
||||
this.i18nToNode($(window.document), true);
|
||||
this.i18nToNodes(window.document, true);
|
||||
|
||||
require('Common/Momentor').reload();
|
||||
this.trigger(!this.trigger());
|
||||
}
|
||||
|
||||
|
|
|
@ -585,71 +585,6 @@
|
|||
return fResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {{moment:Function}} oObject
|
||||
*/
|
||||
Utils.createMomentDate = function (oObject)
|
||||
{
|
||||
if (Utils.isUnd(oObject.moment))
|
||||
{
|
||||
oObject.moment = ko.observable(moment());
|
||||
}
|
||||
|
||||
return ko.computed(function () {
|
||||
Globals.momentTrigger();
|
||||
var oMoment = this.moment();
|
||||
return 1970 === oMoment.year() ? '' : oMoment.fromNow();
|
||||
}, oObject);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {{moment:Function, momentDate:Function}} oObject
|
||||
*/
|
||||
Utils.createMomentShortDate = function (oObject)
|
||||
{
|
||||
return ko.computed(function () {
|
||||
|
||||
var
|
||||
sResult = '',
|
||||
oMomentNow = moment(),
|
||||
oMoment = this.moment(),
|
||||
sMomentDate = this.momentDate()
|
||||
;
|
||||
|
||||
if (1970 === oMoment.year())
|
||||
{
|
||||
sResult = '';
|
||||
}
|
||||
else if (4 >= oMomentNow.diff(oMoment, 'hours'))
|
||||
{
|
||||
sResult = sMomentDate;
|
||||
}
|
||||
else if (oMomentNow.format('L') === oMoment.format('L'))
|
||||
{
|
||||
sResult = require('Common/Translator').i18n('MESSAGE_LIST/TODAY_AT', {
|
||||
'TIME': oMoment.format('LT')
|
||||
});
|
||||
}
|
||||
else if (oMomentNow.clone().subtract('days', 1).format('L') === oMoment.format('L'))
|
||||
{
|
||||
sResult = require('Common/Translator').i18n('MESSAGE_LIST/YESTERDAY_AT', {
|
||||
'TIME': oMoment.format('LT')
|
||||
});
|
||||
}
|
||||
else if (oMomentNow.year() === oMoment.year())
|
||||
{
|
||||
sResult = oMoment.format('D MMM.');
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = oMoment.format('LL');
|
||||
}
|
||||
|
||||
return sResult;
|
||||
|
||||
}, oObject);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sTheme
|
||||
* @return {string}
|
||||
|
@ -764,7 +699,7 @@
|
|||
$('#rl-content', oBody).html(oTemplate.html());
|
||||
$('html', oWin.document).addClass('external ' + $('html').attr('class'));
|
||||
|
||||
require('Common/Translator').i18nToNode(oBody);
|
||||
require('Common/Translator').i18nToNodes(oBody);
|
||||
|
||||
if (oViewModel && $('#rl-content', oBody)[0])
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
{
|
||||
oParams.element = $(oCmponentInfo.element);
|
||||
|
||||
require('Common/Translator').i18nToNode(oParams.element);
|
||||
require('Common/Translator').i18nToNodes(oParams.element);
|
||||
|
||||
if (!Utils.isUnd(oParams.inline) && ko.unwrap(oParams.inline))
|
||||
{
|
||||
|
|
23
dev/External/ko.js
vendored
23
dev/External/ko.js
vendored
|
@ -302,16 +302,35 @@
|
|||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers.moment = {
|
||||
'init': function (oElement, fValueAccessor) {
|
||||
require('Common/Momentor').momentToNode(
|
||||
$(oElement).addClass('moment').data('moment-time', ko.unwrap(fValueAccessor()))
|
||||
);
|
||||
},
|
||||
'update': function (oElement, fValueAccessor) {
|
||||
require('Common/Momentor').momentToNode(
|
||||
$(oElement).data('moment-time', ko.unwrap(fValueAccessor()))
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers.i18nInit = {
|
||||
'init': function (oElement) {
|
||||
require('Common/Translator').i18nToNode(oElement);
|
||||
require('Common/Translator').i18nToNodes(oElement);
|
||||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers.translatorInit = {
|
||||
'init': function (oElement) {
|
||||
require('Common/Translator').i18nToNodes(oElement);
|
||||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers.i18nUpdate = {
|
||||
'update': function (oElement, fValueAccessor) {
|
||||
ko.unwrap(fValueAccessor());
|
||||
require('Common/Translator').i18nToNode(oElement);
|
||||
require('Common/Translator').i18nToNodes(oElement);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@
|
|||
});
|
||||
|
||||
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
||||
'i18nInit': true,
|
||||
'translatorInit': true,
|
||||
'template': function () { return {'name': oViewModel.viewModelTemplate()};}
|
||||
}, oViewModel);
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
moment = require('moment'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
@ -76,8 +75,6 @@
|
|||
this.hasAttachments = ko.observable(false);
|
||||
this.attachmentsMainType = ko.observable('');
|
||||
|
||||
this.moment = ko.observable(moment(moment.unix(0)));
|
||||
|
||||
this.attachmentIconClass = ko.computed(function () {
|
||||
var sClass = '';
|
||||
if (this.hasAttachments())
|
||||
|
@ -102,20 +99,9 @@
|
|||
return sClass;
|
||||
}, this);
|
||||
|
||||
this.fullFormatDateValue = ko.computed(function () {
|
||||
return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
|
||||
}, this);
|
||||
|
||||
this.momentDate = Utils.createMomentDate(this);
|
||||
this.momentShortDate = Utils.createMomentShortDate(this);
|
||||
|
||||
this.regDisposables(this.dateTimeStampInUTC.subscribe(function (iValue) {
|
||||
var iNow = moment().unix();
|
||||
this.moment(moment.unix(iNow < iValue ? iNow : iValue));
|
||||
}, this));
|
||||
|
||||
this.body = null;
|
||||
this.plainRaw = '';
|
||||
|
||||
this.isHtml = ko.observable(false);
|
||||
this.hasImages = ko.observable(false);
|
||||
this.attachments = ko.observableArray([]);
|
||||
|
@ -146,8 +132,7 @@
|
|||
return Enums.MessagePriority.High === this.priority();
|
||||
}, this);
|
||||
|
||||
this.regDisposables([this.attachmentIconClass, this.fullFormatDateValue,
|
||||
this.threadsLen, this.isImportant]);
|
||||
this.regDisposables([this.attachmentIconClass, this.threadsLen, this.isImportant]);
|
||||
}
|
||||
|
||||
_.extend(MessageModel.prototype, AbstractModel.prototype);
|
||||
|
@ -163,16 +148,6 @@
|
|||
return oMessageModel.initByJson(oJsonMessage) ? oMessageModel : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {number} iTimeStampInUTC
|
||||
* @return {string}
|
||||
*/
|
||||
MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC)
|
||||
{
|
||||
return 0 < iTimeStampInUTC ? moment.unix(iTimeStampInUTC).format('LLL') : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {Array} aEmail
|
||||
|
@ -869,7 +844,7 @@
|
|||
'popupReplyTo': this.replyToToLine(false),
|
||||
'popupSubject': this.subject(),
|
||||
'popupIsHtml': this.isHtml(),
|
||||
'popupDate': this.fullFormatDateValue(),
|
||||
'popupDate': require('Common/Momentor').format(this.dateTimeStampInUTC(), 'FULL'),
|
||||
'popupAttachments': this.attachmentsToStringLine(),
|
||||
'popupBody': this.textBodyToString()
|
||||
};
|
||||
|
@ -970,8 +945,6 @@
|
|||
this.hasAttachments(oMessage.hasAttachments());
|
||||
this.attachmentsMainType(oMessage.attachmentsMainType());
|
||||
|
||||
this.moment(oMessage.moment());
|
||||
|
||||
this.body = null;
|
||||
|
||||
this.aDraftInfo = [];
|
||||
|
|
|
@ -314,6 +314,19 @@
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sFolderFullNameRaw
|
||||
* @param {Array} aUids
|
||||
*/
|
||||
RemoteUserStorage.prototype.messageListSimple = function (fCallback, sFolderFullNameRaw, aUids)
|
||||
{
|
||||
return this.defaultRequest(fCallback, 'MessageListSimple', {
|
||||
'Folder': Utils.pString(sFolderFullNameRaw),
|
||||
'Uids': aUids
|
||||
}, Consts.Defaults.DefaultAjaxTimeout, '', ['MessageListSimple']);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sFolderFullNameRaw
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
RoutedSettingsViewModel.__vm = oSettingsScreen;
|
||||
|
||||
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
||||
'i18nInit': true,
|
||||
'translatorInit': true,
|
||||
'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; }
|
||||
}, oSettingsScreen);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
var
|
||||
ko = require('ko'),
|
||||
moment = require('moment'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
LicenseStore = require('Stores/Admin/License')
|
||||
|
@ -71,12 +70,13 @@
|
|||
LicensingAdminSettings.prototype.licenseExpiredMomentValue = function ()
|
||||
{
|
||||
var
|
||||
moment = require('moment'),
|
||||
iTime = this.licenseExpired(),
|
||||
oDate = moment.unix(iTime)
|
||||
oM = moment.unix(iTime)
|
||||
;
|
||||
|
||||
return this.licenseIsUnlim() ? 'Never' :
|
||||
(iTime && (oDate.format('LL') + ' (' + oDate.from(moment()) + ')'));
|
||||
(iTime && (oM.format('LL') + ' (' + oM.from(moment()) + ')'));
|
||||
};
|
||||
|
||||
module.exports = LicensingAdminSettings;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
moment = require('moment'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
|
@ -205,7 +204,7 @@
|
|||
var
|
||||
aResult = [],
|
||||
iLimit = 5,
|
||||
iUtc = moment().unix(),
|
||||
iUtc = require('Common/Momentor').momentNowUnix(),
|
||||
iTimeout = iUtc - 60 * 5,
|
||||
aTimeouts = [],
|
||||
sInboxFolderName = Cache.getFolderInboxName(),
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
window = require('window'),
|
||||
moment = require('moment'),
|
||||
$ = require('$'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
|
@ -766,11 +765,11 @@
|
|||
iCount = 0,
|
||||
iOffset = 0,
|
||||
aList = [],
|
||||
iUtc = moment().unix(),
|
||||
oJsonMessage = null,
|
||||
oMessage = null,
|
||||
oFolder = null,
|
||||
iNewCount = 0,
|
||||
iUtc = require('Common/Momentor').momentNowUnix(),
|
||||
bUnreadCountChange = false
|
||||
;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
moment = require('moment'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
|
@ -66,6 +65,7 @@
|
|||
AdvancedSearchPopupView.prototype.buildSearchString = function ()
|
||||
{
|
||||
var
|
||||
oM = null,
|
||||
aResult = [],
|
||||
sFrom = Utils.trim(this.from()),
|
||||
sTo = Utils.trim(this.to()),
|
||||
|
@ -117,7 +117,7 @@
|
|||
|
||||
if (-1 < this.selectedDateValue())
|
||||
{
|
||||
aResult.push('date:' + moment().subtract('days', this.selectedDateValue()).format('YYYY.MM.DD') + '/');
|
||||
aResult.push('date:' + require('Common/Momentor').searchSubtractFormatDateHelper(this.selectedDateValue()) + '/');
|
||||
}
|
||||
|
||||
if (sText && '' !== sText)
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
moment = require('moment'),
|
||||
JSON = require('JSON'),
|
||||
Jua = require('Jua'),
|
||||
|
||||
|
@ -19,7 +18,9 @@
|
|||
Events = require('Common/Events'),
|
||||
Links = require('Common/Links'),
|
||||
HtmlEditor = require('Common/HtmlEditor'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
Momentor = require('Common/Momentor'),
|
||||
|
||||
Cache = require('Common/Cache'),
|
||||
|
||||
|
@ -716,7 +717,7 @@
|
|||
|
||||
this.savedOrSendingText(
|
||||
0 < this.savedTime() ? Translator.i18n('COMPOSE/SAVED_TIME', {
|
||||
'TIME': moment.unix(this.savedTime() - 1).format('LT')
|
||||
'TIME': Momentor.format(this.savedTime() - 1, 'LT')
|
||||
}) : ''
|
||||
);
|
||||
|
||||
|
@ -806,12 +807,12 @@
|
|||
|
||||
if (-1 < sSignature.indexOf('{{DATE}}'))
|
||||
{
|
||||
sSignature = sSignature.replace(/{{DATE}}/g, moment().format('llll'));
|
||||
sSignature = sSignature.replace(/{{DATE}}/g, Momentor.format(0, 'llll'));
|
||||
}
|
||||
|
||||
if (-1 < sSignature.indexOf('{{TIME}}'))
|
||||
{
|
||||
sSignature = sSignature.replace(/{{TIME}}/g, moment().format('LT'));
|
||||
sSignature = sSignature.replace(/{{TIME}}/g, Momentor.format(0, 'LT'));
|
||||
}
|
||||
if (-1 < sSignature.indexOf('{{MOMENT:'))
|
||||
{
|
||||
|
@ -834,7 +835,8 @@
|
|||
if (aMoments && 0 < aMoments.length)
|
||||
{
|
||||
_.each(aMoments, function (aData) {
|
||||
sSignature = sSignature.replace(aData[0], moment().format(aData[1]));
|
||||
sSignature = sSignature.replace(
|
||||
aData[0], Momentor.format(0, aData[1]));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1033,7 @@
|
|||
|
||||
if ('' !== sComposeType && oMessage)
|
||||
{
|
||||
sDate = oMessage.fullFormatDateValue();
|
||||
sDate = Momentor.format(oMessage.dateTimeStampInUTC(), 'FULL');
|
||||
sSubject = oMessage.subject();
|
||||
aDraftInfo = oMessage.aDraftInfo;
|
||||
|
||||
|
|
|
@ -193,9 +193,8 @@
|
|||
this.viewCc = ko.observable('');
|
||||
this.viewBcc = ko.observable('');
|
||||
this.viewReplyTo = ko.observable('');
|
||||
this.viewDate = ko.observable('');
|
||||
this.viewTimeStamp = ko.observable(0);
|
||||
this.viewSize = ko.observable('');
|
||||
this.viewMoment = ko.observable('');
|
||||
this.viewLineAsCss = ko.observable('');
|
||||
this.viewViewLink = ko.observable('');
|
||||
this.viewDownloadLink = ko.observable('');
|
||||
|
@ -206,6 +205,7 @@
|
|||
|
||||
// THREADS
|
||||
this.viewThreads = ko.observableArray([]);
|
||||
this.viewThreadMessages = ko.observableArray([]);
|
||||
this.viewThreads.trigger = ko.observable(false);
|
||||
|
||||
MessageStore.messageLastThreadUidsData.subscribe(function (oData) {
|
||||
|
@ -252,7 +252,7 @@
|
|||
if (-1 < iIndex)
|
||||
{
|
||||
aResult[0] = true;
|
||||
aResult[1] = (iIndex + 1) + '/' + iLen;
|
||||
aResult[1] = (iIndex + 1) + ' / ' + iLen;
|
||||
aResult[2] = aThreads[iIndex];
|
||||
aResult[3] = 0 < iIndex && aThreads[iIndex - 1] ? aThreads[iIndex - 1] : '';
|
||||
aResult[4] = aThreads[iIndex + 1] ? aThreads[iIndex + 1] : '';
|
||||
|
@ -289,6 +289,17 @@
|
|||
this.openThreadMessage(aStatus[3]);
|
||||
}, this.viewThreadsControlForwardAllow);
|
||||
|
||||
this.threadListCommand = Utils.createCommand(this, function () {
|
||||
var aList = [], aStatus = this.viewThreads.status();
|
||||
if (aStatus && aStatus[0])
|
||||
{
|
||||
this.viewThreadMessages(aList);
|
||||
// window.console.log(aStatus);
|
||||
}
|
||||
}, function () {
|
||||
return !this.messageLoadingThrottle();
|
||||
});
|
||||
|
||||
// PGP
|
||||
this.viewPgpPassword = ko.observable('');
|
||||
this.viewPgpSignedVerifyStatus = ko.computed(function () {
|
||||
|
@ -364,9 +375,8 @@
|
|||
this.viewCc(oMessage.ccToLine(false));
|
||||
this.viewBcc(oMessage.bccToLine(false));
|
||||
this.viewReplyTo(oMessage.replyToToLine(false));
|
||||
this.viewDate(oMessage.fullFormatDateValue());
|
||||
this.viewTimeStamp(oMessage.dateTimeStampInUTC());
|
||||
this.viewSize(oMessage.friendlySize());
|
||||
this.viewMoment(oMessage.momentDate());
|
||||
this.viewLineAsCss(oMessage.lineAsCss());
|
||||
this.viewViewLink(oMessage.viewLink());
|
||||
this.viewDownloadLink(oMessage.downloadLink());
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</span>
|
||||
</div>
|
||||
<div class="dateParent actionHandle dragHandle">
|
||||
<span class="date" data-bind="text: momentShortDate, title: fullFormatDateValue"></span>
|
||||
<span class="date" data-moment-format="SHORT" data-moment-format-title="FULL" data-bind="moment: dateTimeStampInUTC"></span>
|
||||
</div>
|
||||
<div class="checkedParent">
|
||||
<i class="checkboxMessage" data-bind="css: checked() ? 'checkboxMessage icon-checkbox-checked' : 'checkboxMessage icon-checkbox-unchecked'"></i>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div class="delimiter"></div>
|
||||
<div class="wrapper">
|
||||
<div class="dateParent actionHandle dragHandle">
|
||||
<span class="date" data-bind="text: momentShortDate, title: fullFormatDateValue"></span>
|
||||
<span class="date" data-moment-format="SHORT" data-moment-format-title="FULL" data-bind="moment: dateTimeStampInUTC"></span>
|
||||
</div>
|
||||
<div class="checkedParent">
|
||||
<i class="checkboxMessage" data-bind="css: checked() ? 'checkboxMessage icon-checkbox-checked' : 'checkboxMessage icon-checkbox-unchecked'"></i>
|
||||
|
|
|
@ -186,12 +186,25 @@
|
|||
<a class="btn btn-thin" data-tooltip-placement="bottom" data-bind="command: threadForwardCommand">
|
||||
<i class="icon-left-middle"></i>
|
||||
</a>
|
||||
<a class="btn btn-thin" data-tooltip-placement="bottom" style="display: none">
|
||||
<a class="btn btn-thin btn-dark-disabled-border dropdown-toggle" id="thread-list-view-dropdown-id" data-toggle="dropdown"
|
||||
href="#" tabindex="-1" data-tooltip-placement="bottom">
|
||||
<!--href="#" tabindex="-1" data-tooltip-placement="bottom" data-bind="command: threadListCommand">-->
|
||||
<b data-bind="text: viewThreadsControlDesc"></b>
|
||||
</a>
|
||||
<a class="btn btn-thin" data-tooltip-placement="bottom" data-bind="command: threadBackCommand">
|
||||
<i class="icon-right-middle"></i>
|
||||
</a>
|
||||
<!-- <ul class="dropdown-menu g-ui-menu" role="menu" aria-labelledby="thread-list-view-dropdown-id"
|
||||
style="min-width: 400px; max-width: 400px; width: 400px;">
|
||||
<li class="e-item" role="presentation">
|
||||
<a class="e-link menuitem" href="#" tabindex="-1">
|
||||
<span class="thread-from">test@rainloop.de</span>
|
||||
<span class="thread-date">05/20</span>
|
||||
<br />
|
||||
<span class="thread-subject">Re: thread</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>-->
|
||||
</div>
|
||||
</nobr>
|
||||
</div>
|
||||
|
@ -205,9 +218,9 @@
|
|||
<span class="flagParent">
|
||||
<i class="icon-star-empty flagOff" data-bind="css: {'icon-star flagOn': viewIsFlagged, 'icon-star-empty flagOff': !viewIsFlagged()}"></i>
|
||||
</span>
|
||||
<span class="thread-counter" data-bind="visible: viewThreadsControlVisibility"
|
||||
<!-- <span class="thread-counter" data-bind="visible: viewThreadsControlVisibility"
|
||||
style="font-weight: normal; margin-right: 5px">(<span
|
||||
data-bind="text: viewThreadsControlDesc"></span>)</span>
|
||||
data-bind="text: viewThreadsControlDesc"></span>)</span>-->
|
||||
<b style="color: red; margin-right: 5px" data-bind="visible: viewIsImportant">!</b>
|
||||
<span class="subject" data-bind="text: viewSubject, title: viewSubject"></span>
|
||||
<span class="i18n emptySubjectText" data-i18n-text="MESSAGE/EMPTY_SUBJECT_TEXT"></span>
|
||||
|
@ -226,8 +239,8 @@
|
|||
<span class="i18n uiLabel labelTo" data-i18n-text="MESSAGE/LABEL_TO"></span>:
|
||||
<span class="to" data-bind="html: viewToShort, title: viewTo"></span>
|
||||
</span>
|
||||
<span data-bind="visible: '' !== viewDate()">
|
||||
(<span class="date" data-bind="text: viewDate"></span>)
|
||||
<span data-bind="visible: 0 < viewTimeStamp()">
|
||||
(<span class="date" data-moment-format="FULL" data-bind="moment: viewTimeStamp"></span>)
|
||||
</span>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
@ -265,12 +278,12 @@
|
|||
|
||||
<span class="bcc" data-bind="text: viewReplyTo, title: viewReplyTo"></span>
|
||||
</div>
|
||||
<div data-bind="visible: '' !== viewDate()">
|
||||
<div data-bind="visible: 0 < viewTimeStamp()">
|
||||
<span class="i18n uiLabel labelBcc" data-i18n-text="MESSAGE/LABEL_DATE"></span>:
|
||||
|
||||
<span class="date" data-bind="text: viewDate"></span>
|
||||
<span class="date" data-moment-format="FULL" data-bind="moment: viewTimeStamp"></span>
|
||||
|
||||
(<span class="date" data-bind="text: viewMoment"></span>)
|
||||
(<span class="date" data-moment-format="FROMNOW" data-bind="moment: viewTimeStamp"></span>)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue