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

@ -7,7 +7,6 @@
window = require('window'), window = require('window'),
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
moment = require('moment'),
SimplePace = require('SimplePace'), SimplePace = require('SimplePace'),
Tinycon = require('Tinycon'), Tinycon = require('Tinycon'),
@ -18,7 +17,9 @@
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Links = require('Common/Links'), Links = require('Common/Links'),
Events = require('Common/Events'), Events = require('Common/Events'),
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
Momentor = require('Common/Momentor'),
kn = require('Knoin/Knoin'), kn = require('Knoin/Knoin'),
@ -651,7 +652,7 @@
if (oData && oData.Result && oData.Result.Hash && oData.Result.Folder) if (oData && oData.Result && oData.Result.Hash && oData.Result.Folder)
{ {
var var
iUtc = moment().unix(), iUtc = Momentor.momentNowUnix(),
sHash = Cache.getFolderHash(oData.Result.Folder), sHash = Cache.getFolderHash(oData.Result.Folder),
oFolder = Cache.getFolderFromCacheList(oData.Result.Folder), oFolder = Cache.getFolderFromCacheList(oData.Result.Folder),
bCheck = false, bCheck = false,
@ -750,7 +751,7 @@
var var
self = this, self = this,
iUtc = moment().unix(), iUtc = Momentor.momentNowUnix(),
aFolders = FolderStore.getNextFolderNames(bBoot) aFolders = FolderStore.getNextFolderNames(bBoot)
; ;
@ -1624,7 +1625,7 @@
} }
Events.sub('interval.1m', function () { Events.sub('interval.1m', function () {
Globals.momentTrigger(!Globals.momentTrigger()); Momentor.reload();
}); });
Plugins.runHook('rl-start-screens'); Plugins.runHook('rl-start-screens');

View file

@ -27,11 +27,6 @@
*/ */
Globals.now = (new window.Date()).getTime(); Globals.now = (new window.Date()).getTime();
/**
* @type {?}
*/
Globals.momentTrigger = ko.observable(true);
/** /**
* @type {?} * @type {?}
*/ */

188
dev/Common/Momentor.js Normal file
View 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();
}());

View file

@ -58,48 +58,57 @@
/** /**
* @param {Object} oElement * @param {Object} oElement
* @param {boolean=} bAnimate = false
*/ */
Translator.prototype.i18nToNode = function (oElement, bAnimate) Translator.prototype.i18nToNode = function (oElement)
{ {
var self = this;
_.defer(function () {
$('.i18n', oElement).each(function () {
var var
jqThis = $(this), sKey = '',
sKey = '' $oEl = $(oElement)
; ;
sKey = jqThis.data('i18n-text'); sKey = $oEl.data('i18n-text');
if (sKey) if (sKey)
{ {
jqThis.text(self.i18n(sKey)); $oEl.text(this.i18n(sKey));
} }
else else
{ {
sKey = jqThis.data('i18n-html'); sKey = $oEl.data('i18n-html');
if (sKey) if (sKey)
{ {
jqThis.html(self.i18n(sKey)); $oEl.html(this.i18n(sKey));
} }
sKey = jqThis.data('i18n-placeholder'); sKey = $oEl.data('i18n-placeholder');
if (sKey) if (sKey)
{ {
jqThis.attr('placeholder', self.i18n(sKey)); $oEl.attr('placeholder', this.i18n(sKey));
} }
sKey = jqThis.data('i18n-title'); sKey = $oEl.data('i18n-title');
if (sKey) if (sKey)
{ {
jqThis.attr('title', self.i18n(sKey)); $oEl.attr('title', this.i18n(sKey));
} }
} }
};
/**
* @param {Object} oElements
* @param {boolean=} bAnimate = false
*/
Translator.prototype.i18nToNodes = function (oElements, bAnimate)
{
var self = this;
_.defer(function () {
$('.i18n', oElements).each(function () {
self.i18nToNode(this);
}); });
if (bAnimate && Globals.bAnimationSupported) 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' '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.data = window['rainloopI18N'] || {};
this.i18nToNode($(window.document), true); this.i18nToNodes(window.document, true);
require('Common/Momentor').reload();
this.trigger(!this.trigger()); this.trigger(!this.trigger());
} }

View file

@ -585,71 +585,6 @@
return fResult; 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 * @param {string} sTheme
* @return {string} * @return {string}
@ -764,7 +699,7 @@
$('#rl-content', oBody).html(oTemplate.html()); $('#rl-content', oBody).html(oTemplate.html());
$('html', oWin.document).addClass('external ' + $('html').attr('class')); $('html', oWin.document).addClass('external ' + $('html').attr('class'));
require('Common/Translator').i18nToNode(oBody); require('Common/Translator').i18nToNodes(oBody);
if (oViewModel && $('#rl-content', oBody)[0]) if (oViewModel && $('#rl-content', oBody)[0])
{ {

View file

@ -50,7 +50,7 @@
{ {
oParams.element = $(oCmponentInfo.element); 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)) if (!Utils.isUnd(oParams.inline) && ko.unwrap(oParams.inline))
{ {

23
dev/External/ko.js vendored
View file

@ -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 = { ko.bindingHandlers.i18nInit = {
'init': function (oElement) { '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 = { ko.bindingHandlers.i18nUpdate = {
'update': function (oElement, fValueAccessor) { 'update': function (oElement, fValueAccessor) {
ko.unwrap(fValueAccessor()); ko.unwrap(fValueAccessor());
require('Common/Translator').i18nToNode(oElement); require('Common/Translator').i18nToNodes(oElement);
} }
}; };

View file

@ -213,7 +213,7 @@
}); });
ko.applyBindingAccessorsToNode(oViewModelDom[0], { ko.applyBindingAccessorsToNode(oViewModelDom[0], {
'i18nInit': true, 'translatorInit': true,
'template': function () { return {'name': oViewModel.viewModelTemplate()};} 'template': function () { return {'name': oViewModel.viewModelTemplate()};}
}, oViewModel); }, oViewModel);

View file

@ -8,7 +8,6 @@
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
ko = require('ko'), ko = require('ko'),
moment = require('moment'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
@ -76,8 +75,6 @@
this.hasAttachments = ko.observable(false); this.hasAttachments = ko.observable(false);
this.attachmentsMainType = ko.observable(''); this.attachmentsMainType = ko.observable('');
this.moment = ko.observable(moment(moment.unix(0)));
this.attachmentIconClass = ko.computed(function () { this.attachmentIconClass = ko.computed(function () {
var sClass = ''; var sClass = '';
if (this.hasAttachments()) if (this.hasAttachments())
@ -102,20 +99,9 @@
return sClass; return sClass;
}, this); }, 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.body = null;
this.plainRaw = ''; this.plainRaw = '';
this.isHtml = ko.observable(false); this.isHtml = ko.observable(false);
this.hasImages = ko.observable(false); this.hasImages = ko.observable(false);
this.attachments = ko.observableArray([]); this.attachments = ko.observableArray([]);
@ -146,8 +132,7 @@
return Enums.MessagePriority.High === this.priority(); return Enums.MessagePriority.High === this.priority();
}, this); }, this);
this.regDisposables([this.attachmentIconClass, this.fullFormatDateValue, this.regDisposables([this.attachmentIconClass, this.threadsLen, this.isImportant]);
this.threadsLen, this.isImportant]);
} }
_.extend(MessageModel.prototype, AbstractModel.prototype); _.extend(MessageModel.prototype, AbstractModel.prototype);
@ -163,16 +148,6 @@
return oMessageModel.initByJson(oJsonMessage) ? oMessageModel : null; 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 * @static
* @param {Array} aEmail * @param {Array} aEmail
@ -869,7 +844,7 @@
'popupReplyTo': this.replyToToLine(false), 'popupReplyTo': this.replyToToLine(false),
'popupSubject': this.subject(), 'popupSubject': this.subject(),
'popupIsHtml': this.isHtml(), 'popupIsHtml': this.isHtml(),
'popupDate': this.fullFormatDateValue(), 'popupDate': require('Common/Momentor').format(this.dateTimeStampInUTC(), 'FULL'),
'popupAttachments': this.attachmentsToStringLine(), 'popupAttachments': this.attachmentsToStringLine(),
'popupBody': this.textBodyToString() 'popupBody': this.textBodyToString()
}; };
@ -970,8 +945,6 @@
this.hasAttachments(oMessage.hasAttachments()); this.hasAttachments(oMessage.hasAttachments());
this.attachmentsMainType(oMessage.attachmentsMainType()); this.attachmentsMainType(oMessage.attachmentsMainType());
this.moment(oMessage.moment());
this.body = null; this.body = null;
this.aDraftInfo = []; this.aDraftInfo = [];

View file

@ -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 {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw

View file

@ -103,7 +103,7 @@
RoutedSettingsViewModel.__vm = oSettingsScreen; RoutedSettingsViewModel.__vm = oSettingsScreen;
ko.applyBindingAccessorsToNode(oViewModelDom[0], { ko.applyBindingAccessorsToNode(oViewModelDom[0], {
'i18nInit': true, 'translatorInit': true,
'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; } 'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; }
}, oSettingsScreen); }, oSettingsScreen);

View file

@ -5,7 +5,6 @@
var var
ko = require('ko'), ko = require('ko'),
moment = require('moment'),
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
LicenseStore = require('Stores/Admin/License') LicenseStore = require('Stores/Admin/License')
@ -71,12 +70,13 @@
LicensingAdminSettings.prototype.licenseExpiredMomentValue = function () LicensingAdminSettings.prototype.licenseExpiredMomentValue = function ()
{ {
var var
moment = require('moment'),
iTime = this.licenseExpired(), iTime = this.licenseExpired(),
oDate = moment.unix(iTime) oM = moment.unix(iTime)
; ;
return this.licenseIsUnlim() ? 'Never' : return this.licenseIsUnlim() ? 'Never' :
(iTime && (oDate.format('LL') + ' (' + oDate.from(moment()) + ')')); (iTime && (oM.format('LL') + ' (' + oM.from(moment()) + ')'));
}; };
module.exports = LicensingAdminSettings; module.exports = LicensingAdminSettings;

View file

@ -6,7 +6,6 @@
var var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
moment = require('moment'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Consts = require('Common/Consts'), Consts = require('Common/Consts'),
@ -205,7 +204,7 @@
var var
aResult = [], aResult = [],
iLimit = 5, iLimit = 5,
iUtc = moment().unix(), iUtc = require('Common/Momentor').momentNowUnix(),
iTimeout = iUtc - 60 * 5, iTimeout = iUtc - 60 * 5,
aTimeouts = [], aTimeouts = [],
sInboxFolderName = Cache.getFolderInboxName(), sInboxFolderName = Cache.getFolderInboxName(),

View file

@ -7,7 +7,6 @@
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
window = require('window'), window = require('window'),
moment = require('moment'),
$ = require('$'), $ = require('$'),
kn = require('Knoin/Knoin'), kn = require('Knoin/Knoin'),
@ -766,11 +765,11 @@
iCount = 0, iCount = 0,
iOffset = 0, iOffset = 0,
aList = [], aList = [],
iUtc = moment().unix(),
oJsonMessage = null, oJsonMessage = null,
oMessage = null, oMessage = null,
oFolder = null, oFolder = null,
iNewCount = 0, iNewCount = 0,
iUtc = require('Common/Momentor').momentNowUnix(),
bUnreadCountChange = false bUnreadCountChange = false
; ;

View file

@ -6,7 +6,6 @@
var var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
moment = require('moment'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
@ -66,6 +65,7 @@
AdvancedSearchPopupView.prototype.buildSearchString = function () AdvancedSearchPopupView.prototype.buildSearchString = function ()
{ {
var var
oM = null,
aResult = [], aResult = [],
sFrom = Utils.trim(this.from()), sFrom = Utils.trim(this.from()),
sTo = Utils.trim(this.to()), sTo = Utils.trim(this.to()),
@ -117,7 +117,7 @@
if (-1 < this.selectedDateValue()) 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) if (sText && '' !== sText)

View file

@ -8,7 +8,6 @@
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
ko = require('ko'), ko = require('ko'),
moment = require('moment'),
JSON = require('JSON'), JSON = require('JSON'),
Jua = require('Jua'), Jua = require('Jua'),
@ -19,7 +18,9 @@
Events = require('Common/Events'), Events = require('Common/Events'),
Links = require('Common/Links'), Links = require('Common/Links'),
HtmlEditor = require('Common/HtmlEditor'), HtmlEditor = require('Common/HtmlEditor'),
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
Momentor = require('Common/Momentor'),
Cache = require('Common/Cache'), Cache = require('Common/Cache'),
@ -716,7 +717,7 @@
this.savedOrSendingText( this.savedOrSendingText(
0 < this.savedTime() ? Translator.i18n('COMPOSE/SAVED_TIME', { 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}}')) 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}}')) 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:')) if (-1 < sSignature.indexOf('{{MOMENT:'))
{ {
@ -834,7 +835,8 @@
if (aMoments && 0 < aMoments.length) if (aMoments && 0 < aMoments.length)
{ {
_.each(aMoments, function (aData) { _.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) if ('' !== sComposeType && oMessage)
{ {
sDate = oMessage.fullFormatDateValue(); sDate = Momentor.format(oMessage.dateTimeStampInUTC(), 'FULL');
sSubject = oMessage.subject(); sSubject = oMessage.subject();
aDraftInfo = oMessage.aDraftInfo; aDraftInfo = oMessage.aDraftInfo;

View file

@ -193,9 +193,8 @@
this.viewCc = ko.observable(''); this.viewCc = ko.observable('');
this.viewBcc = ko.observable(''); this.viewBcc = ko.observable('');
this.viewReplyTo = ko.observable(''); this.viewReplyTo = ko.observable('');
this.viewDate = ko.observable(''); this.viewTimeStamp = ko.observable(0);
this.viewSize = ko.observable(''); this.viewSize = ko.observable('');
this.viewMoment = ko.observable('');
this.viewLineAsCss = ko.observable(''); this.viewLineAsCss = ko.observable('');
this.viewViewLink = ko.observable(''); this.viewViewLink = ko.observable('');
this.viewDownloadLink = ko.observable(''); this.viewDownloadLink = ko.observable('');
@ -206,6 +205,7 @@
// THREADS // THREADS
this.viewThreads = ko.observableArray([]); this.viewThreads = ko.observableArray([]);
this.viewThreadMessages = ko.observableArray([]);
this.viewThreads.trigger = ko.observable(false); this.viewThreads.trigger = ko.observable(false);
MessageStore.messageLastThreadUidsData.subscribe(function (oData) { MessageStore.messageLastThreadUidsData.subscribe(function (oData) {
@ -289,6 +289,17 @@
this.openThreadMessage(aStatus[3]); this.openThreadMessage(aStatus[3]);
}, this.viewThreadsControlForwardAllow); }, 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 // PGP
this.viewPgpPassword = ko.observable(''); this.viewPgpPassword = ko.observable('');
this.viewPgpSignedVerifyStatus = ko.computed(function () { this.viewPgpSignedVerifyStatus = ko.computed(function () {
@ -364,9 +375,8 @@
this.viewCc(oMessage.ccToLine(false)); this.viewCc(oMessage.ccToLine(false));
this.viewBcc(oMessage.bccToLine(false)); this.viewBcc(oMessage.bccToLine(false));
this.viewReplyTo(oMessage.replyToToLine(false)); this.viewReplyTo(oMessage.replyToToLine(false));
this.viewDate(oMessage.fullFormatDateValue()); this.viewTimeStamp(oMessage.dateTimeStampInUTC());
this.viewSize(oMessage.friendlySize()); this.viewSize(oMessage.friendlySize());
this.viewMoment(oMessage.momentDate());
this.viewLineAsCss(oMessage.lineAsCss()); this.viewLineAsCss(oMessage.lineAsCss());
this.viewViewLink(oMessage.viewLink()); this.viewViewLink(oMessage.viewLink());
this.viewDownloadLink(oMessage.downloadLink()); this.viewDownloadLink(oMessage.downloadLink());

View file

@ -16,7 +16,7 @@
</span> </span>
</div> </div>
<div class="dateParent actionHandle dragHandle"> <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>
<div class="checkedParent"> <div class="checkedParent">
<i class="checkboxMessage" data-bind="css: checked() ? 'checkboxMessage icon-checkbox-checked' : 'checkboxMessage icon-checkbox-unchecked'"></i> <i class="checkboxMessage" data-bind="css: checked() ? 'checkboxMessage icon-checkbox-checked' : 'checkboxMessage icon-checkbox-unchecked'"></i>

View file

@ -5,7 +5,7 @@
<div class="delimiter"></div> <div class="delimiter"></div>
<div class="wrapper"> <div class="wrapper">
<div class="dateParent actionHandle dragHandle"> <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>
<div class="checkedParent"> <div class="checkedParent">
<i class="checkboxMessage" data-bind="css: checked() ? 'checkboxMessage icon-checkbox-checked' : 'checkboxMessage icon-checkbox-unchecked'"></i> <i class="checkboxMessage" data-bind="css: checked() ? 'checkboxMessage icon-checkbox-checked' : 'checkboxMessage icon-checkbox-unchecked'"></i>

View file

@ -186,12 +186,25 @@
<a class="btn btn-thin" data-tooltip-placement="bottom" data-bind="command: threadForwardCommand"> <a class="btn btn-thin" data-tooltip-placement="bottom" data-bind="command: threadForwardCommand">
<i class="icon-left-middle"></i> <i class="icon-left-middle"></i>
</a> </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> <b data-bind="text: viewThreadsControlDesc"></b>
</a> </a>
<a class="btn btn-thin" data-tooltip-placement="bottom" data-bind="command: threadBackCommand"> <a class="btn btn-thin" data-tooltip-placement="bottom" data-bind="command: threadBackCommand">
<i class="icon-right-middle"></i> <i class="icon-right-middle"></i>
</a> </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> </div>
</nobr> </nobr>
</div> </div>
@ -205,9 +218,9 @@
<span class="flagParent"> <span class="flagParent">
<i class="icon-star-empty flagOff" data-bind="css: {'icon-star flagOn': viewIsFlagged, 'icon-star-empty flagOff': !viewIsFlagged()}"></i> <i class="icon-star-empty flagOff" data-bind="css: {'icon-star flagOn': viewIsFlagged, 'icon-star-empty flagOff': !viewIsFlagged()}"></i>
</span> </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 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> <b style="color: red; margin-right: 5px" data-bind="visible: viewIsImportant">!</b>
<span class="subject" data-bind="text: viewSubject, title: viewSubject"></span> <span class="subject" data-bind="text: viewSubject, title: viewSubject"></span>
<span class="i18n emptySubjectText" data-i18n-text="MESSAGE/EMPTY_SUBJECT_TEXT"></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="i18n uiLabel labelTo" data-i18n-text="MESSAGE/LABEL_TO"></span>:
<span class="to" data-bind="html: viewToShort, title: viewTo"></span> <span class="to" data-bind="html: viewToShort, title: viewTo"></span>
</span> </span>
<span data-bind="visible: '' !== viewDate()"> <span data-bind="visible: 0 < viewTimeStamp()">
(<span class="date" data-bind="text: viewDate"></span>) (<span class="date" data-moment-format="FULL" data-bind="moment: viewTimeStamp"></span>)
</span> </span>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
@ -265,12 +278,12 @@
&nbsp; &nbsp;
<span class="bcc" data-bind="text: viewReplyTo, title: viewReplyTo"></span> <span class="bcc" data-bind="text: viewReplyTo, title: viewReplyTo"></span>
</div> </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="i18n uiLabel labelBcc" data-i18n-text="MESSAGE/LABEL_DATE"></span>:
&nbsp; &nbsp;
<span class="date" data-bind="text: viewDate"></span> <span class="date" data-moment-format="FULL" data-bind="moment: viewTimeStamp"></span>
&nbsp; &nbsp;
(<span class="date" data-bind="text: viewMoment"></span>) (<span class="date" data-moment-format="FROMNOW" data-bind="moment: viewTimeStamp"></span>)
</div> </div>
</div> </div>
</div> </div>