Contacts tags support (unstable - step 1).

+ Small fixes
This commit is contained in:
RainLoop Team 2014-05-13 12:29:36 +04:00
parent 74fa12c000
commit 0ca00dec40
34 changed files with 1790 additions and 801 deletions

View file

@ -12,7 +12,7 @@ function RainLoopApp()
this.oRemote = null;
this.oCache = null;
this.oMoveCache = {};
this.quotaDebounce = _.debounce(this.quota, 1000 * 30);
this.moveOrDeleteResponseHelper = _.bind(this.moveOrDeleteResponseHelper, this);
@ -189,11 +189,11 @@ RainLoopApp.prototype.contactsSync = function (fResultFunc)
{
return false;
}
oContacts.syncing(true);
RL.remote().contactsSync(function (sResult, oData) {
oContacts.syncing(false);
if (fResultFunc)
@ -211,14 +211,14 @@ RainLoopApp.prototype.messagesMoveTrigger = function ()
self = this,
sSpamFolder = RL.data().spamFolder()
;
_.each(this.oMoveCache, function (oItem) {
var
bSpam = sSpamFolder === oItem['To'],
bHam = !bSpam && sSpamFolder === oItem['From'] && 'INBOX' === oItem['To']
;
RL.remote().messagesMove(self.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'],
bSpam ? 'SPAM' : (bHam ? 'HAM' : ''));
});
@ -272,7 +272,7 @@ RainLoopApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData)
else
{
RL.cache().setFolderHash(RL.data().currentFolderFullNameRaw(), '');
if (oData && -1 < Utils.inArray(oData.ErrorCode,
[Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage]))
{
@ -345,14 +345,14 @@ RainLoopApp.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFol
{
kn.showScreenPopup(PopupsFolderSystemViewModel, [nSetSystemFoldersNotification]);
}
else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType &&
else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType &&
(sFromFolderFullNameRaw === oData.spamFolder() || sFromFolderFullNameRaw === oData.trashFolder())))
{
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () {
self.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove);
oData.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove);
}]);
}
else if (oMoveFolder)
@ -469,7 +469,7 @@ RainLoopApp.prototype.reloadOpenPgpKeys = function ()
RainLoopApp.prototype.accountsAndIdentities = function ()
{
var oRainLoopData = RL.data();
oRainLoopData.accountsLoading(true);
oRainLoopData.identitiesLoading(true);
@ -477,14 +477,14 @@ RainLoopApp.prototype.accountsAndIdentities = function ()
oRainLoopData.accountsLoading(false);
oRainLoopData.identitiesLoading(false);
if (Enums.StorageResultType.Success === sResult && oData.Result)
{
var
var
sParentEmail = RL.settingsGet('ParentEmail'),
sAccountEmail = oRainLoopData.accountEmail()
;
sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail;
if (Utils.isArray(oData.Result['Accounts']))
@ -493,21 +493,21 @@ RainLoopApp.prototype.accountsAndIdentities = function ()
return new AccountModel(sValue, sValue !== sParentEmail);
}));
}
if (Utils.isArray(oData.Result['Identities']))
{
oRainLoopData.identities(_.map(oData.Result['Identities'], function (oIdentityData) {
var
var
sId = Utils.pString(oIdentityData['Id']),
sEmail = Utils.pString(oIdentityData['Email']),
oIdentity = new IdentityModel(sId, sEmail, sId !== sAccountEmail)
;
oIdentity.name(Utils.pString(oIdentityData['Name']));
oIdentity.replyTo(Utils.pString(oIdentityData['ReplyTo']));
oIdentity.bcc(Utils.pString(oIdentityData['Bcc']));
return oIdentity;
}));
}
@ -518,7 +518,7 @@ RainLoopApp.prototype.accountsAndIdentities = function ()
RainLoopApp.prototype.quota = function ()
{
this.remote().quota(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
Utils.isArray(oData.Result) && 1 < oData.Result.length &&
Utils.isPosNumeric(oData.Result[0], true) && Utils.isPosNumeric(oData.Result[1], true))
{
@ -555,7 +555,7 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList)
if (oFolder)
{
oFolder.interval = iUtc;
if (oData.Result.Hash)
{
RL.cache().setFolderHash(oData.Result.Folder, oData.Result.Hash);
@ -652,7 +652,7 @@ RainLoopApp.prototype.folderInformationMultiply = function (bBoot)
if (oData && oData.Result && oData.Result.List && Utils.isNonEmptyArray(oData.Result.List))
{
_.each(oData.Result.List, function (oItem) {
var
aList = [],
sHash = RL.cache().getFolderHash(oItem.Folder),
@ -936,7 +936,7 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa
}
}
}
if (oItem.subScribed() && 0 < oItem.subFolders().length)
{
aResult = aResult.concat(RL.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [],
@ -970,10 +970,21 @@ RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback)
{
fCallback([]);
}
}, sQuery);
};
/**
* @param {string} sQuery
* @param {Function} fCallback
*/
RainLoopApp.prototype.getContactsTagsAutocomplete = function (sQuery, fCallback)
{
fCallback(_.filter(RL.data().contactTags(), function (oContactTag) {
return oContactTag && oContactTag.filterHelper(sQuery);
}));
};
RainLoopApp.prototype.emailsPicsHashes = function ()
{
RL.remote().emailsPicsHashes(function (sResult, oData) {
@ -1021,7 +1032,7 @@ RainLoopApp.prototype.bootstart = function ()
bFacebook = RL.settingsGet('AllowFacebookSocial'),
bTwitter = RL.settingsGet('AllowTwitterSocial')
;
if (!RL.settingsGet('ChangePasswordIsAllowed'))
{
Utils.removeSettingsViewModel(SettingsChangePasswordScreen);
@ -1036,7 +1047,7 @@ RainLoopApp.prototype.bootstart = function ()
{
Utils.removeSettingsViewModel(SettingsAccounts);
}
if (RL.settingsGet('AllowIdentities'))
{
Utils.removeSettingsViewModel(SettingsIdentity);
@ -1045,7 +1056,7 @@ RainLoopApp.prototype.bootstart = function ()
{
Utils.removeSettingsViewModel(SettingsIdentities);
}
if (!RL.settingsGet('OpenPGP'))
{
Utils.removeSettingsViewModel(SettingsOpenPGP);
@ -1060,12 +1071,12 @@ RainLoopApp.prototype.bootstart = function ()
{
Utils.removeSettingsViewModel(SettingsSocialScreen);
}
if (!RL.settingsGet('AllowThemes'))
{
Utils.removeSettingsViewModel(SettingsThemes);
}
Utils.initOnStartOrLangChange(function () {
$.extend(true, $.magnificPopup.defaults, {
@ -1113,9 +1124,9 @@ RainLoopApp.prototype.bootstart = function ()
{
RL.data().openpgpKeyring = new window.openpgp.Keyring();
RL.data().allowOpenPGP(true);
RL.pub('openpgp.init');
RL.reloadOpenPgpKeys();
}
}
@ -1127,7 +1138,7 @@ RainLoopApp.prototype.bootstart = function ()
}
kn.startScreens([MailBoxScreen, SettingsScreen]);
if (bGoogle || bFacebook || bTwitter)
{
RL.socialUsers(true);
@ -1163,7 +1174,7 @@ RainLoopApp.prototype.bootstart = function ()
window.setInterval(function () {
RL.contactsSync();
}, iContactsSyncInterval * 60000 + 5000);
_.delay(function () {
RL.contactsSync();
}, 5000);
@ -1223,7 +1234,7 @@ RainLoopApp.prototype.bootstart = function ()
Utils.initLayoutResizer('#rl-left', '#rl-right', Enums.ClientSideKeyName.FolderListSize);
});
}
}, this));
}
else

View file

@ -74,7 +74,7 @@ ko.bindingHandlers.tooltip3 = {
'init': function (oElement) {
var $oEl = $(oElement);
$oEl.tooltip({
'container': 'body',
'trigger': 'hover manual',
@ -93,7 +93,7 @@ ko.bindingHandlers.tooltip3 = {
$document.click(function () {
$oEl.tooltip('hide');
});
},
'update': function (oElement, fValueAccessor) {
var sValue = ko.utils.unwrapObservable(fValueAccessor());
@ -124,7 +124,7 @@ ko.bindingHandlers.openDropdownTrigger = {
$el.find('.dropdown-toggle').dropdown('toggle');
Utils.detectDropdownVisibility();
}
fValueAccessor()(false);
}
}
@ -221,7 +221,7 @@ ko.bindingHandlers.clickOnTrue = {
ko.bindingHandlers.modal = {
'init': function (oElement, fValueAccessor) {
$(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({
'keyboard': false,
'show': ko.utils.unwrapObservable(fValueAccessor())
@ -536,11 +536,19 @@ ko.bindingHandlers.emailsTags = {
'init': function(oElement, fValueAccessor) {
var
$oEl = $(oElement),
fValue = fValueAccessor()
fValue = fValueAccessor(),
fFocusCallback = function (bValue) {
if (fValue && fValue.focusTrigger)
{
fValue.focusTrigger(bValue);
}
}
;
$oEl.inputosaurus({
'parseOnBlur': true,
'allowDragAndDrop': true,
'focusCallback': fFocusCallback,
'inputDelimiters': [',', ';'],
'autoCompleteSource': function (oData, fResponse) {
RL.getAutocomplete(oData.term, function (aData) {
@ -551,12 +559,12 @@ ko.bindingHandlers.emailsTags = {
},
'parseHook': function (aInput) {
return _.map(aInput, function (sInputValue) {
var
sValue = Utils.trim(sInputValue),
oEmail = null
;
if ('' !== sValue)
{
oEmail = new EmailModel();
@ -586,8 +594,83 @@ ko.bindingHandlers.emailsTags = {
if (fValue.focusTrigger)
{
fValue.focusTrigger.subscribe(function () {
$oEl.inputosaurus('focus');
fValue.focusTrigger.subscribe(function (bValue) {
if (bValue)
{
$oEl.inputosaurus('focus');
}
});
}
}
};
ko.bindingHandlers.contactTags = {
'init': function(oElement, fValueAccessor) {
var
$oEl = $(oElement),
fValue = fValueAccessor(),
fFocusCallback = function (bValue) {
if (fValue && fValue.focusTrigger)
{
fValue.focusTrigger(bValue);
}
}
;
$oEl.inputosaurus({
'parseOnBlur': true,
'allowDragAndDrop': false,
'focusCallback': fFocusCallback,
'inputDelimiters': [';'],
'outputDelimiter': ';',
'autoCompleteSource': function (oData, fResponse) {
RL.getContactsTagsAutocomplete(oData.term, function (aData) {
fResponse(_.map(aData, function (oTagItem) {
return oTagItem.toLine(false);
}));
});
},
'parseHook': function (aInput) {
return _.map(aInput, function (sInputValue) {
var
sValue = Utils.trim(sInputValue),
oTag = null
;
if ('' !== sValue)
{
oTag = new ContactTagModel();
oTag.name(sValue);
return [oTag.toLine(false), oTag];
}
return [sValue, null];
});
},
'change': _.bind(function (oEvent) {
$oEl.data('ContactsTagsValue', oEvent.target.value);
fValue(oEvent.target.value);
}, this)
});
fValue.subscribe(function (sValue) {
if ($oEl.data('ContactsTagsValue') !== sValue)
{
$oEl.val(sValue);
$oEl.data('ContactsTagsValue', sValue);
$oEl.inputosaurus('refresh');
}
});
if (fValue.focusTrigger)
{
fValue.focusTrigger.subscribe(function (bValue) {
if (bValue)
{
$oEl.inputosaurus('focus');
}
});
}
}
@ -737,7 +820,7 @@ ko.observable.fn.validateFunc = function (fFunc)
this.subscribe(function (sValue) {
this.hasFuncError(!fFunc(sValue));
}, this);
this.valueHasMutated();
}

View file

@ -325,13 +325,13 @@ Utils.i18nToNode = function (oElement)
{
jqThis.html(Utils.i18n(sKey));
}
sKey = jqThis.data('i18n-placeholder');
if (sKey)
{
jqThis.attr('placeholder', Utils.i18n(sKey));
}
sKey = jqThis.data('i18n-title');
if (sKey)
{
@ -469,7 +469,7 @@ Utils.fixLongSubject = function (sSubject)
;
sSubject = Utils.trim(sSubject.replace(/[\s]+/, ' '));
do
{
oMatch = /^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/ig.exec(sSubject);
@ -598,9 +598,9 @@ Utils.initNotificationLanguage = function ()
NotificationI18N[Enums.Notification.CantSaveSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS');
NotificationI18N[Enums.Notification.CantSavePluginSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS');
NotificationI18N[Enums.Notification.DomainAlreadyExists] = Utils.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS');
NotificationI18N[Enums.Notification.CantInstallPackage] = Utils.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE');
NotificationI18N[Enums.Notification.CantDeletePackage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE');
NotificationI18N[Enums.Notification.InvalidPluginPackage] = Utils.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE');
@ -613,7 +613,7 @@ Utils.initNotificationLanguage = function ()
NotificationI18N[Enums.Notification.DemoSendMessageError] = Utils.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR');
NotificationI18N[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS');
NotificationI18N[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR');
NotificationI18N[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
NotificationI18N[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
@ -765,7 +765,7 @@ Utils.initDataConstructorBySettings = function (oData)
oData.contactsAutosave = ko.observable(false);
Globals.sAnimationType = Enums.InterfaceAnimation.Full;
oData.allowThemes = ko.observable(true);
oData.allowCustomLogin = ko.observable(false);
oData.allowLanguagesOnSettings = ko.observable(true);
@ -775,7 +775,7 @@ Utils.initDataConstructorBySettings = function (oData)
oData.useThreads = ko.observable(true);
oData.replySameFolder = ko.observable(true);
oData.useCheckboxesInList = ko.observable(true);
oData.layout = ko.observable(Enums.Layout.SidePreview);
oData.usePreviewPane = ko.computed(function () {
return Enums.Layout.NoPreview !== oData.layout();
@ -1058,7 +1058,7 @@ Utils.setExpandedFolder = function (sFullNameHash, bExpanded)
{
aExpandedList = [];
}
if (bExpanded)
{
aExpandedList.push(sFullNameHash);
@ -1075,7 +1075,7 @@ Utils.setExpandedFolder = function (sFullNameHash, bExpanded)
Utils.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName)
{
var
iDisabledWidth = 65,
iDisabledWidth = 60,
iMinWidth = 155,
oLeft = $(sLeft),
oRight = $(sRight),
@ -1153,7 +1153,7 @@ Utils.initBlockquoteSwitcher = function (oMessageTextBody)
var $oList = $('blockquote:not(.rl-bq-switcher)', oMessageTextBody).filter(function () {
return 0 === $(this).parent().closest('blockquote', oMessageTextBody).length;
});
if ($oList && 0 < $oList.length)
{
$oList.each(function () {
@ -1563,7 +1563,7 @@ Utils.resizeAndCrop = function (sUrl, iValue, fCallback)
oCtx.fillStyle = '#fff';
oCtx.fillRect(0, 0, iValue, iValue);
oCtx.drawImage(this, aDiff[0] / 2, aDiff[1] / 2, this.width - aDiff[0], this.height - aDiff[1], 0, 0, iValue, iValue);
fCallback(oCanvas.toDataURL('image/jpeg'));
};

View file

@ -17,7 +17,7 @@ function KnoinAbstractViewModel(sPosition, sTemplate)
this.viewModelName = '';
this.viewModelVisibility = ko.observable(false);
this.modalVisibility = ko.observable(false).extend({'rateLimit': 0});
this.viewModelDom = null;
}
@ -72,14 +72,21 @@ KnoinAbstractViewModel.prototype.restoreKeyScope = function ()
RL.data().keyScope(this.sCurrentKeyScope);
};
KnoinAbstractViewModel.prototype.registerPopupEscapeKey = function ()
KnoinAbstractViewModel.prototype.registerPopupKeyDown = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility && self.modalVisibility())
if (oEvent && self.modalVisibility && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
return false;
if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode)
{
Utils.delegateRun(self, 'cancelCommand');
return false;
}
else if (Enums.EventKeyCode.Backspace === oEvent.keyCode && !Utils.inFocus())
{
return false;
}
}
return true;

View file

@ -83,7 +83,7 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
ViewModelClass.__builded = true;
ViewModelClass.__vm = oViewModel;
oViewModel.data = RL.data();
oViewModel.viewModelName = ViewModelClass.__name;
if (oViewModelPlace && 1 === oViewModelPlace.length)
@ -126,19 +126,19 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
self.viewModelDom.hide();
}, 300);
}
}, oViewModel);
}
Plugins.runHook('view-model-pre-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
ko.applyBindings(oViewModel, oViewModelDom[0]);
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
if (oViewModel && 'Popups' === sPosition && !oViewModel.bDisabeCloseOnEsc)
if (oViewModel && 'Popups' === sPosition)
{
oViewModel.registerPopupEscapeKey();
oViewModel.registerPopupKeyDown();
}
Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
}
else
@ -240,7 +240,7 @@ Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
}
_.defer(function () {
// hide screen
if (self.oCurrentScreen)
{
@ -336,7 +336,7 @@ Knoin.prototype.startScreens = function (aScreensClasses)
{
oScreen.__started = true;
oScreen.__start();
Plugins.runHook('screen-pre-start', [oScreen.screenName(), oScreen]);
Utils.delegateRun(oScreen, 'onStart');
Plugins.runHook('screen-post-start', [oScreen.screenName(), oScreen]);

View file

@ -8,6 +8,7 @@ function ContactModel()
this.idContact = 0;
this.display = '';
this.properties = [];
this.tags = '';
this.readOnly = false;
this.focused = ko.observable(false);
@ -21,11 +22,11 @@ function ContactModel()
*/
ContactModel.prototype.getNameAndEmailHelper = function ()
{
var
var
sName = '',
sEmail = ''
;
if (Utils.isNonEmptyArray(this.properties))
{
_.each(this.properties, function (aProperty) {
@ -58,6 +59,7 @@ ContactModel.prototype.parse = function (oItem)
this.idContact = Utils.pInt(oItem['IdContact']);
this.display = Utils.pString(oItem['Display']);
this.readOnly = !!oItem['ReadOnly'];
this.tags = '';
if (Utils.isNonEmptyArray(oItem['Properties']))
{
@ -69,6 +71,11 @@ ContactModel.prototype.parse = function (oItem)
}, this);
}
if (Utils.isNonEmptyArray(oItem['Tags']))
{
this.tags = oItem['Tags'].join(';');
}
bResult = true;
}

View file

@ -0,0 +1,45 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function ContactTagModel()
{
this.idContactTag = 0;
this.name = ko.observable('');
this.readOnly = false;
}
ContactTagModel.prototype.parse = function (oItem)
{
var bResult = false;
if (oItem && 'Object/Tag' === oItem['@Object'])
{
this.idContact = Utils.pInt(oItem['IdContactTag']);
this.name(Utils.pString(oItem['Name']));
this.readOnly = !!oItem['ReadOnly'];
bResult = true;
}
return bResult;
};
/**
* @param {string} sSearch
* @return {boolean}
*/
ContactTagModel.prototype.filterHelper = function (sSearch)
{
return this.name().toLowerCase().indexOf(sSearch.toLowerCase()) !== -1;
};
/**
* @param {boolean=} bEncodeHtml = false
* @return {string}
*/
ContactTagModel.prototype.toLine = function (bEncodeHtml)
{
return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ?
Utils.encodeHtml(this.name()) : this.name();
};

View file

@ -7,7 +7,7 @@
function WebMailAjaxRemoteStorage()
{
AbstractAjaxRemoteStorage.call(this);
this.oRequests = {};
}
@ -686,11 +686,12 @@ WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, iOffset, iLim
/**
* @param {?Function} fCallback
*/
WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, aProperties)
WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties)
{
this.defaultRequest(fCallback, 'ContactSave', {
'RequestUid': sRequestUid,
'Uid': Utils.trim(sUid),
'Tags': Utils.trim(sTags),
'Properties': aProperties
});
};

View file

@ -83,13 +83,14 @@ function WebMailDataStorage()
this.identitiesLoading = ko.observable(false).extend({'throttle': 100});
// contacts
this.contactTags = ko.observableArray([]);
this.contacts = ko.observableArray([]);
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200});
this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200});
this.allowContactsSync = ko.observable(false);
this.enableContactsSync = ko.observable(false);
this.contactsSyncUrl = ko.observable('');
@ -229,11 +230,11 @@ function WebMailDataStorage()
this.messageListEndFolder = ko.observable('');
this.messageListEndSearch = ko.observable('');
this.messageListEndPage = ko.observable(1);
this.messageListEndHash = ko.computed(function () {
return this.messageListEndFolder() + '|' + this.messageListEndSearch() + '|' + this.messageListEndPage();
}, this);
this.messageListPageCount = ko.computed(function () {
var iPage = Math.ceil(this.messageListCount() / this.messagesPerPage());
return 0 >= iPage ? 1 : iPage;
@ -266,7 +267,7 @@ function WebMailDataStorage()
this.messageListCompleteLoading.subscribe(function (bValue) {
this.messageListCompleteLoadingThrottle(bValue);
}, this);
this.messageList.subscribe(_.debounce(function (aList) {
_.each(aList, function (oItem) {
if (oItem.newForAnimation())
@ -283,7 +284,7 @@ function WebMailDataStorage()
this.messageLoadingThrottle = ko.observable(false).extend({'throttle': 50});
this.message.focused = ko.observable(false);
this.message.subscribe(function (oMessage) {
if (!oMessage)
{
@ -313,7 +314,7 @@ function WebMailDataStorage()
RL.data().keyScope(Enums.KeyState.MessageList);
}
});
this.folderList.focused.subscribe(function (bValue) {
if (bValue)
{
@ -324,11 +325,11 @@ function WebMailDataStorage()
RL.data().keyScope(Enums.KeyState.MessageList);
}
});
this.messageLoading.subscribe(function (bValue) {
this.messageLoadingThrottle(bValue);
}, this);
this.messageFullScreenMode = ko.observable(false);
this.messageError = ko.observable('');
@ -349,13 +350,13 @@ function WebMailDataStorage()
}, this);
this.currentMessage = ko.observable(null);
this.messageListChecked = ko.computed(function () {
return _.filter(this.messageList(), function (oItem) {
return oItem.checked();
});
}, this).extend({'rateLimit': 0});
this.hasCheckedMessages = ko.computed(function () {
return 0 < this.messageListChecked().length;
}, this).extend({'rateLimit': 0});
@ -442,7 +443,7 @@ WebMailDataStorage.prototype.purgeMessageBodyCache = function()
oMessagesBodiesDom = null,
iEnd = Globals.iMessageBodyCacheCount - Consts.Values.MessageBodyCacheLimit
;
if (0 < iEnd)
{
oMessagesBodiesDom = this.messagesBodiesDom();
@ -475,7 +476,7 @@ WebMailDataStorage.prototype.populateDataOnStart = function()
this.accountIncLogin(RL.settingsGet('IncLogin'));
this.accountOutLogin(RL.settingsGet('OutLogin'));
this.projectHash(RL.settingsGet('ProjectHash'));
this.displayName(RL.settingsGet('DisplayName'));
this.replyTo(RL.settingsGet('ReplyTo'));
this.signature(RL.settingsGet('Signature'));
@ -517,7 +518,7 @@ WebMailDataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUid
{
oNotification.show();
}
window.setTimeout((function (oLocalNotifications) {
return function () {
if (oLocalNotifications.cancel)
@ -720,7 +721,7 @@ WebMailDataStorage.prototype.hideMessageBodies = function ()
WebMailDataStorage.prototype.getNextFolderNames = function (bBoot)
{
bBoot = Utils.isUnd(bBoot) ? false : !!bBoot;
var
aResult = [],
iLimit = 10,
@ -756,10 +757,10 @@ WebMailDataStorage.prototype.getNextFolderNames = function (bBoot)
{
return 1;
}
return 0;
});
_.find(aTimeouts, function (aItem) {
var oFolder = RL.cache().getFolderFromCacheList(aItem[1]);
if (oFolder)
@ -767,7 +768,7 @@ WebMailDataStorage.prototype.getNextFolderNames = function (bBoot)
oFolder.interval = iUtc;
aResult.push(aItem[1]);
}
return iLimit <= aResult.length;
});
@ -785,7 +786,7 @@ WebMailDataStorage.prototype.removeMessagesFromList = function (
{
sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : '';
bCopy = Utils.isUnd(bCopy) ? false : !!bCopy;
aUidForRemove = _.map(aUidForRemove, function (mValue) {
return Utils.pInt(mValue);
});
@ -845,7 +846,7 @@ WebMailDataStorage.prototype.removeMessagesFromList = function (
else
{
oData.messageListIsNotCompleted(true);
_.each(aMessages, function (oMessage) {
if (oCurrentMessage && oCurrentMessage.hash === oMessage.hash)
{
@ -916,7 +917,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
oBody = $('<div id="' + sId + '" />').hide().addClass('rl-cache-class');
oBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html)
{
bIsHtml = true;
@ -926,7 +927,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
{
bIsHtml = false;
sPlain = oData.Result.Plain.toString();
if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) &&
RL.data().allowOpenPGP() &&
Utils.isNormal(oData.Result.PlainRaw))
@ -939,7 +940,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oMessage.plainRaw) &&
/-----BEGIN PGP SIGNATURE-----/.test(oMessage.plainRaw);
}
$proxyDiv.empty();
if (bPgpSigned && oMessage.isPgpSigned())
{
@ -951,7 +952,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
}
else if (bPgpEncrypted && oMessage.isPgpEncrypted())
{
sPlain =
sPlain =
$proxyDiv.append(
$('<pre class="b-plain-openpgp encrypted"></pre>').text(oMessage.plainRaw)
).html()
@ -1028,7 +1029,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
{
RL.setMessageSeen(oMessage);
}
Utils.windowResize();
}
};
@ -1081,7 +1082,7 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
if (oFolder && !bCached)
{
oFolder.interval = iUtc;
RL.cache().setFolderHash(oData.Result.Folder, oData.Result.FolderHash);
if (Utils.isNormal(oData.Result.MessageCount))

View file

@ -175,7 +175,7 @@
float: left;
padding: 0 8px 0 6px;
}
.shareParent {
display: none;
float: right;
@ -224,7 +224,7 @@
}
&.selected {
background-color: #fff;
z-index: 102;
@ -238,7 +238,7 @@
}
}
}
.b-view-content-toolbar {
background-color: #f5f5f5;
padding: 7px;
@ -279,6 +279,27 @@
-webkit-overflow-scrolling: touch;
}
.tags-property-container {
font-size: 18px;
width: 400px;
.inputosaurus-container {
border-width: 1px;
border-color: transparent;
.box-shadow(none);
&:hover {
.box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));
border-color: #ccc;
}
&.inputosaurus-focused {
.box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));
border-color: #999;
}
}
}
.contactValueStatic, .contactValueLargeStatic, .contactValueTextAreaStatic {
height: 20px;
line-height: 20px;
@ -288,7 +309,7 @@
color: #555;
display: none;
}
&.read-only {
.contactValueStatic, .contactValueLargeStatic, .contactValueTextAreaStatic {
display: inline-block;
@ -361,7 +382,7 @@
color: #ddd;
}
}
.contactValueTextArea {
width: 300px;
}

View file

@ -175,9 +175,9 @@ html.ssm-state-tablet {
}
html.rl-left-panel-disabled {
#rl-left {
width: 65px !important;
width: 60px !important;
.show-on-panel-disabled {
display: block;
@ -201,7 +201,7 @@ html.rl-left-panel-disabled {
}
#rl-right {
left: 65px !important;
left: 60px !important;
}
}

View file

@ -1,14 +1,21 @@
.inputosaurus-container {
width: 99%;
line-height: 20px;
padding: 2px;
border: 1px solid #cccccc;
border-radius: 3px;
.box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));
.transition(~"border linear .2s, box-shadow linear .2s");
&.inputosaurus-focused {
background-color: #fff;
border: @rlInputBorderSize solid darken(@inputBorder, 20%);
.box-shadow(none);
}
li {
max-width: 500px;
background-color: #eee;

View file

@ -67,9 +67,9 @@ function MailBoxMessageViewViewModel()
this.forwardCommand = createCommandHelper(Enums.ComposeType.Forward);
this.forwardAsAttachmentCommand = createCommandHelper(Enums.ComposeType.ForwardAsAttachment);
this.editAsNewCommand = createCommandHelper(Enums.ComposeType.EditAsNew);
this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility);
this.messageEditCommand = Utils.createCommand(this, function () {
this.editMessage();
}, this.messageVisibility);
@ -91,7 +91,7 @@ function MailBoxMessageViewViewModel()
[this.message().uid], false);
}
}, this.messageVisibility);
this.archiveCommand = Utils.createCommand(this, function () {
if (this.message())
{
@ -100,7 +100,7 @@ function MailBoxMessageViewViewModel()
[this.message().uid], true);
}
}, this.messageVisibility);
this.spamCommand = Utils.createCommand(this, function () {
if (this.message())
{
@ -120,6 +120,7 @@ function MailBoxMessageViewViewModel()
}, this.messageVisibility);
// viewer
this.viewHash = '';
this.viewSubject = ko.observable('');
this.viewFromShort = ko.observable('');
this.viewToShort = ko.observable('');
@ -134,7 +135,7 @@ function MailBoxMessageViewViewModel()
this.viewDownloadLink = ko.observable('');
this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic);
this.viewUserPicVisible = ko.observable(false);
this.viewPgpPassword = ko.observable('');
this.viewPgpSignedVerifyStatus = ko.computed(function () {
return this.message() ? this.message().pgpSignedVerifyStatus() : Enums.SignedVerifyStatus.None;
@ -143,7 +144,7 @@ function MailBoxMessageViewViewModel()
this.viewPgpSignedVerifyUser = ko.computed(function () {
return this.message() ? this.message().pgpSignedVerifyUser() : '';
}, this);
this.message.subscribe(function (oMessage) {
this.messageActiveDom(null);
@ -152,6 +153,12 @@ function MailBoxMessageViewViewModel()
if (oMessage)
{
if (this.viewHash !== oMessage.hash)
{
this.scrollMessageToTop();
}
this.viewHash = oMessage.hash;
this.viewSubject(oMessage.subject());
this.viewFromShort(oMessage.fromToLine(true, true));
this.viewToShort(oMessage.toToLine(true, true));
@ -179,7 +186,12 @@ function MailBoxMessageViewViewModel()
}
});
}
else
{
this.viewHash = '';
this.scrollMessageToTop();
}
}, this);
this.fullScreenMode.subscribe(function (bValue) {
@ -202,14 +214,10 @@ function MailBoxMessageViewViewModel()
}
});
this.messageActiveDom.subscribe(function () {
this.scrollMessageToTop();
}, this);
this.goUpCommand = Utils.createCommand(this, function () {
RL.pub('mailbox.message-list.selector.go-up');
});
this.goDownCommand = Utils.createCommand(this, function () {
RL.pub('mailbox.message-list.selector.go-down');
});
@ -274,7 +282,7 @@ MailBoxMessageViewViewModel.prototype.scrollToTop = function ()
// $('.messageItem', this.viewModelDom).animate({'scrollTop': 0}, 300);
$('.messageItem', this.viewModelDom).scrollTop(0);
}
Utils.windowResize();
};
@ -308,7 +316,7 @@ MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType)
MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
{
var
var
self = this,
oData = RL.data()
;
@ -319,7 +327,7 @@ MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
self.message.focused(true);
}
}, this);
$('.attachmentsPlace', oDom).magnificPopup({
'delegate': '.magnificPopupImage:visible',
'type': 'image',
@ -513,7 +521,7 @@ MailBoxMessageViewViewModel.prototype.initShortcuts = function ()
{
self.message().printMessage();
}
return false;
});
@ -529,7 +537,7 @@ MailBoxMessageViewViewModel.prototype.initShortcuts = function ()
{
self.deleteCommand();
}
return false;
}
});
@ -673,7 +681,7 @@ MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage)
if (oMessage && '' !== oMessage.readReceipt())
{
RL.remote().sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
oMessage.readReceipt(),
oMessage.readReceipt(),
Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': RL.data().accountEmail()}));

View file

@ -24,7 +24,8 @@ function PopupsContactsViewModel()
this.search = ko.observable('');
this.contactsCount = ko.observable(0);
this.contacts = RL.data().contacts;
this.contactTags = RL.data().contactTags;
this.currentContact = ko.observable(null);
this.importUploaderButton = ko.observable(null);
@ -44,6 +45,21 @@ function PopupsContactsViewModel()
this.viewReadOnly = ko.observable(false);
this.viewProperties = ko.observableArray([]);
this.viewTags = ko.observable('');
this.viewTags.visibility = ko.observable(false);
this.viewTags.focusTrigger = ko.observable(false);
this.viewTags.focusTrigger.subscribe(function (bValue) {
if (!bValue && '' === this.viewTags())
{
this.viewTags.visibility(false);
}
else if (bValue)
{
this.viewTags.visibility(true);
}
}, this);
this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) {
@ -57,7 +73,7 @@ function PopupsContactsViewModel()
Enums.ContactPropertyType.Note
]);
});
this.viewPropertiesOther = ko.computed(function () {
var aList = _.filter(this.viewProperties(), function (oProperty) {
@ -71,7 +87,7 @@ function PopupsContactsViewModel()
});
}, this);
this.viewPropertiesEmails = this.viewProperties.filter(function(oProperty) {
return Enums.ContactPropertyType.Email === oProperty.type();
});
@ -81,7 +97,7 @@ function PopupsContactsViewModel()
});
this.viewHasNonEmptyRequaredProperties = ko.computed(function() {
var
aNames = this.viewPropertiesNames(),
aEmail = this.viewPropertiesEmails(),
@ -89,7 +105,7 @@ function PopupsContactsViewModel()
return '' !== Utils.trim(oProperty.value());
}
;
return !!(_.find(aNames, fHelper) || _.find(aEmail, fHelper));
}, this);
@ -198,7 +214,7 @@ function PopupsContactsViewModel()
this.populateViewContact(null);
this.currentContact(null);
});
this.deleteCommand = Utils.createCommand(this, function () {
this.deleteSelectedContacts();
this.emptySelection(true);
@ -213,7 +229,7 @@ function PopupsContactsViewModel()
aE = _.map(aC, function (oItem) {
if (oItem)
{
var
var
aData = oItem.getNameAndEmailHelper(),
oEmail = aData ? new EmailModel(aData[0], aData[1]) : null
;
@ -235,7 +251,7 @@ function PopupsContactsViewModel()
kn.hideScreenPopup(PopupsContactsViewModel);
kn.showScreenPopup(PopupsComposeViewModel, [Enums.ComposeType.Empty, null, aE]);
}
}, function () {
return 0 < this.contactsCheckedOrSelected().length;
});
@ -245,11 +261,11 @@ function PopupsContactsViewModel()
});
this.saveCommand = Utils.createCommand(this, function () {
this.viewSaving(true);
this.viewSaveTrigger(Enums.SaveSettingsStep.Animate);
var
var
sRequestUid = Utils.fakeMd5(),
aProperties = []
;
@ -265,7 +281,7 @@ function PopupsContactsViewModel()
var bRes = false;
self.viewSaving(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
oData.Result.RequestUid === sRequestUid && 0 < Utils.pInt(oData.Result.ResultID))
{
@ -290,11 +306,11 @@ function PopupsContactsViewModel()
self.viewSaveTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
}
}, sRequestUid, this.viewID(), aProperties);
}, sRequestUid, this.viewID(), this.viewTags(), aProperties);
}, function () {
var
var
bV = this.viewHasNonEmptyRequaredProperties(),
bReadOnly = this.viewReadOnly()
;
@ -313,7 +329,7 @@ function PopupsContactsViewModel()
self.reloadContactList(true);
});
}, function () {
return !this.contacts.syncing() && !this.contacts.importing();
});
@ -322,9 +338,9 @@ function PopupsContactsViewModel()
this.watchDirty = ko.observable(false);
this.watchHash = ko.observable(false);
this.viewHash = ko.computed(function () {
return '' + _.map(self.viewProperties(), function (oItem) {
return '' + self.viewTags() + '|' + _.map(self.viewProperties(), function (oItem) {
return oItem.value();
}).join('');
});
@ -385,6 +401,12 @@ PopupsContactsViewModel.prototype.addNewOrFocusProperty = function (sType, sType
}
};
PopupsContactsViewModel.prototype.addNewTag = function ()
{
this.viewTags.visibility(true);
this.viewTags.focusTrigger(true);
};
PopupsContactsViewModel.prototype.addNewEmail = function ()
{
this.addNewProperty(Enums.ContactPropertyType.Email, 'Home');
@ -454,7 +476,7 @@ PopupsContactsViewModel.prototype.initUploader = function ()
this.contacts.importing(true);
}, this))
.on('onComplete', _.bind(function (sId, bResult, oData) {
this.contacts.importing(false);
this.reloadContactList();
@ -478,7 +500,7 @@ PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = func
iCount = this.contacts().length,
aContacts = this.contactsCheckedOrSelected()
;
if (0 < aContacts.length)
{
_.each(aContacts, function (oContact) {
@ -499,11 +521,11 @@ PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = func
}
_.delay(function () {
_.each(aContacts, function (oContact) {
oKoContacts.remove(oContact);
});
}, 500);
}
};
@ -562,7 +584,8 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
this.emptySelection(false);
this.viewReadOnly(false);
this.viewTags('');
if (oContact)
{
sId = oContact.idContact;
@ -587,15 +610,20 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
});
}
this.viewTags(oContact.tags);
this.viewReadOnly(!!oContact.readOnly);
}
this.viewTags.focusTrigger.valueHasMutated();
this.viewTags.visibility('' !== this.viewTags());
aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.LastName, '', sLastName, false,
this.getPropertyPlceholder(Enums.ContactPropertyType.LastName)));
aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.FirstName, '', sFirstName, !oContact,
this.getPropertyPlceholder(Enums.ContactPropertyType.FirstName)));
this.viewID(sId);
this.viewProperties([]);
this.viewProperties(aList);
@ -613,7 +641,7 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
self = this,
iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage
;
this.bDropPageAfterDelete = false;
if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition)
@ -626,9 +654,10 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
RL.remote().contacts(function (sResult, oData) {
var
iCount = 0,
aList = []
aList = [],
aTagsList = []
;
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List)
{
if (Utils.isNonEmptyArray(oData.Result.List))
@ -643,14 +672,26 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
iCount = Utils.pInt(oData.Result.Count);
iCount = 0 < iCount ? iCount : 0;
}
if (Utils.isNonEmptyArray(oData.Result.Tags))
{
aTagsList = _.map(oData.Result.Tags, function (oItem) {
var oContactTag = new ContactTagModel();
return oContactTag.parse(oItem) ? oContactTag : null;
});
aTagsList = _.compact(aTagsList);
}
}
self.contactsCount(iCount);
self.contacts(aList);
self.viewClearSearch('' !== self.search());
self.contactTags(aTagsList);
self.contacts.loading(false);
self.viewClearSearch('' !== self.search());
}, iOffset, Consts.Defaults.ContactsPerPage, this.search());
};