mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Momentor (moment optimization)
This commit is contained in:
parent
7750587be1
commit
147dce6e4a
20 changed files with 331 additions and 173 deletions
|
|
@ -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])
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue