Momentor (moment optimization)

This commit is contained in:
RainLoop Team 2015-03-07 04:32:06 +04:00
parent 7750587be1
commit 147dce6e4a
20 changed files with 331 additions and 173 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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());