mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-10 15:08:28 +03:00
Uploading and preparing the repository to the dev version.
Original unminified source code (dev folder - js, css, less) (fixes #6) Grunt build system Multiple identities correction (fixes #9) Compose html editor (fixes #12) New general settings - Loading Description New warning about default admin password Split general and login screen settings
This commit is contained in:
parent
afad45137e
commit
4cc2207513
846 changed files with 99453 additions and 2123 deletions
69
dev/ViewModels/AbstractSystemDropDownViewModel.js
Normal file
69
dev/ViewModels/AbstractSystemDropDownViewModel.js
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function AbstractSystemDropDownViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'SystemDropDown');
|
||||
|
||||
var oData = RL.data();
|
||||
|
||||
this.accounts = oData.accounts;
|
||||
this.accountEmail = oData.accountEmail;
|
||||
this.accountsLoading = oData.accountsLoading;
|
||||
this.allowAddAccount = RL.settingsGet('AllowAdditionalAccounts');
|
||||
|
||||
this.loading = ko.computed(function () {
|
||||
return this.accountsLoading();
|
||||
}, this);
|
||||
|
||||
this.accountClick = _.bind(this.accountClick, this);
|
||||
}
|
||||
|
||||
_.extend(AbstractSystemDropDownViewModel.prototype, KnoinAbstractViewModel.prototype);
|
||||
|
||||
AbstractSystemDropDownViewModel.prototype.accountClick = function (oAccount, oEvent)
|
||||
{
|
||||
if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
|
||||
{
|
||||
var self = this;
|
||||
this.accountsLoading(true);
|
||||
_.delay(function () {
|
||||
self.accountsLoading(false);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
AbstractSystemDropDownViewModel.prototype.emailTitle = function ()
|
||||
{
|
||||
return RL.data().accountEmail();
|
||||
};
|
||||
|
||||
AbstractSystemDropDownViewModel.prototype.settingsClick = function ()
|
||||
{
|
||||
kn.setHash(RL.link().settings());
|
||||
};
|
||||
|
||||
AbstractSystemDropDownViewModel.prototype.addAccountClick = function ()
|
||||
{
|
||||
if (this.allowAddAccount)
|
||||
{
|
||||
kn.showScreenPopup(PopupsAddAccountViewModel);
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSystemDropDownViewModel.prototype.logoutClick = function ()
|
||||
{
|
||||
RL.remote().logout(function () {
|
||||
if (window.__rlah_clear)
|
||||
{
|
||||
window.__rlah_clear();
|
||||
}
|
||||
|
||||
RL.loginAndLogoutReload(true, RL.settingsGet('ParentEmail') && 0 < RL.settingsGet('ParentEmail').length);
|
||||
});
|
||||
};
|
||||
86
dev/ViewModels/AdminLoginViewModel.js
Normal file
86
dev/ViewModels/AdminLoginViewModel.js
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function AdminLoginViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'AdminLogin');
|
||||
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.loginFocus = ko.observable(false);
|
||||
|
||||
this.login.subscribe(function () {
|
||||
this.loginError(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.submitCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.loginError('' === Utils.trim(this.login()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.loginError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
RL.remote().adminLogin(_.bind(function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData&& 'AdminLogin' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.loginAndLogoutReload();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.login(), this.password());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('AdminLoginViewModel', AdminLoginViewModel);
|
||||
|
||||
AdminLoginViewModel.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(_.bind(function () {
|
||||
this.loginFocus(true);
|
||||
}, this), 100);
|
||||
|
||||
};
|
||||
|
||||
AdminLoginViewModel.prototype.onHide = function ()
|
||||
{
|
||||
this.loginFocus(false);
|
||||
};
|
||||
21
dev/ViewModels/AdminMenuViewModel.js
Normal file
21
dev/ViewModels/AdminMenuViewModel.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function AdminMenuViewModel(oScreen)
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu');
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('AdminMenuViewModel', AdminMenuViewModel);
|
||||
|
||||
AdminMenuViewModel.prototype.link = function (sRoute)
|
||||
{
|
||||
return '#/' + sRoute;
|
||||
};
|
||||
22
dev/ViewModels/AdminPaneViewModel.js
Normal file
22
dev/ViewModels/AdminPaneViewModel.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function AdminPaneViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'AdminPane');
|
||||
|
||||
this.adminDomain = ko.observable(RL.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(RL.settingsGet('Version'));
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('AdminPaneViewModel', AdminPaneViewModel);
|
||||
|
||||
AdminPaneViewModel.prototype.logoutClick = function ()
|
||||
{
|
||||
RL.remote().adminLogout(function () {
|
||||
RL.loginAndLogoutReload();
|
||||
});
|
||||
};
|
||||
269
dev/ViewModels/LoginViewModel.js
Normal file
269
dev/ViewModels/LoginViewModel.js
Normal file
|
|
@ -0,0 +1,269 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function LoginViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'Login');
|
||||
|
||||
var oData = RL.data();
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.signMe = ko.observable(false);
|
||||
|
||||
this.logoMain = ko.observable('RainLoop');
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
this.loginFocus = ko.observable(false);
|
||||
this.submitFocus = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
}, this);
|
||||
|
||||
this.login.subscribe(function () {
|
||||
this.loginError(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.allowCustomLogin = oData.allowCustomLogin;
|
||||
this.allowLanguagesOnLogin = oData.allowLanguagesOnLogin;
|
||||
|
||||
this.langRequest = ko.observable(false);
|
||||
this.mainLanguage = oData.mainLanguage;
|
||||
this.bSendLanguage = false;
|
||||
|
||||
this.mainLanguageFullName = ko.computed(function () {
|
||||
return Utils.convertLangName(this.mainLanguage());
|
||||
}, this);
|
||||
|
||||
this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
|
||||
|
||||
this.signMeType.subscribe(function (iValue) {
|
||||
this.signMe(Enums.LoginSignMeType.DefaultOn === iValue);
|
||||
}, this);
|
||||
|
||||
this.signMeVisibility = ko.computed(function () {
|
||||
return Enums.LoginSignMeType.Unused !== this.signMeType();
|
||||
}, this);
|
||||
|
||||
this.submitCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
RL.remote().login(_.bind(function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.loginAndLogoutReload();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.email(), this.login(), this.password(), !!this.signMe(),
|
||||
this.bSendLanguage ? this.mainLanguage() : '');
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.facebookLoginEnabled = ko.observable(false);
|
||||
|
||||
this.facebookCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(RL.link().socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.facebookLoginEnabled();
|
||||
});
|
||||
|
||||
this.googleLoginEnabled = ko.observable(false);
|
||||
|
||||
this.googleCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(RL.link().socialGoogle(), 'Google', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.googleLoginEnabled();
|
||||
});
|
||||
|
||||
this.twitterLoginEnabled = ko.observable(false);
|
||||
|
||||
this.twitterCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(RL.link().socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.twitterLoginEnabled();
|
||||
});
|
||||
|
||||
this.loginFocus.subscribe(function (bValue) {
|
||||
if (bValue && '' === this.login() && '' !== this.email())
|
||||
{
|
||||
this.login(this.email());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.socialLoginEnabled = ko.computed(function () {
|
||||
|
||||
var
|
||||
bF = this.facebookLoginEnabled(),
|
||||
bG = this.googleLoginEnabled(),
|
||||
bT = this.twitterLoginEnabled()
|
||||
;
|
||||
|
||||
return bF || bG || bT;
|
||||
}, this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('LoginViewModel', LoginViewModel);
|
||||
|
||||
LoginViewModel.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(_.bind(function () {
|
||||
if ('' !== this.email() && '' !== this.password())
|
||||
{
|
||||
this.submitFocus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.emailFocus(true);
|
||||
}
|
||||
|
||||
if (RL.settingsGet('UserLanguage'))
|
||||
{
|
||||
$.cookie('rllang', RL.data().language(), {'expires': 30});
|
||||
}
|
||||
|
||||
}, this), 100);
|
||||
};
|
||||
|
||||
LoginViewModel.prototype.onHide = function ()
|
||||
{
|
||||
this.submitFocus(false);
|
||||
this.emailFocus(false);
|
||||
};
|
||||
|
||||
LoginViewModel.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
sJsHash = RL.settingsGet('JsHash'),
|
||||
fSocial = function (iErrorCode) {
|
||||
iErrorCode = Utils.pInt(iErrorCode);
|
||||
if (0 === iErrorCode)
|
||||
{
|
||||
self.submitRequest(true);
|
||||
RL.loginAndLogoutReload();
|
||||
}
|
||||
else
|
||||
{
|
||||
self.submitError(Utils.getNotification(iErrorCode));
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
this.facebookLoginEnabled(!!RL.settingsGet('AllowFacebookSocial'));
|
||||
this.twitterLoginEnabled(!!RL.settingsGet('AllowTwitterSocial'));
|
||||
this.googleLoginEnabled(!!RL.settingsGet('AllowGoogleSocial'));
|
||||
|
||||
switch ((RL.settingsGet('SignMe') || 'unused').toLowerCase())
|
||||
{
|
||||
case Enums.LoginSignMeTypeAsString.DefaultOff:
|
||||
this.signMeType(Enums.LoginSignMeType.DefaultOff);
|
||||
break;
|
||||
case Enums.LoginSignMeTypeAsString.DefaultOn:
|
||||
this.signMeType(Enums.LoginSignMeType.DefaultOn);
|
||||
break;
|
||||
default:
|
||||
case Enums.LoginSignMeTypeAsString.Unused:
|
||||
this.signMeType(Enums.LoginSignMeType.Unused);
|
||||
break;
|
||||
}
|
||||
|
||||
this.email(RL.data().devEmail);
|
||||
this.login(RL.data().devLogin);
|
||||
this.password(RL.data().devPassword);
|
||||
|
||||
if (this.googleLoginEnabled())
|
||||
{
|
||||
window['rl_' + sJsHash + '_google_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
if (this.facebookLoginEnabled())
|
||||
{
|
||||
window['rl_' + sJsHash + '_facebook_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
if (this.twitterLoginEnabled())
|
||||
{
|
||||
window['rl_' + sJsHash + '_twitter_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
RL.data().language.subscribe(function (sValue) {
|
||||
self.langRequest(true);
|
||||
$.ajax({
|
||||
'url': RL.link().langLink(sValue),
|
||||
'dataType': 'script',
|
||||
'cache': true
|
||||
}).done(function() {
|
||||
self.bSendLanguage = true;
|
||||
Utils.i18nToDoc();
|
||||
$.cookie('rllang', RL.data().language(), {'expires': 30});
|
||||
}).always(function() {
|
||||
self.langRequest(false);
|
||||
});
|
||||
});
|
||||
}, 50);
|
||||
};
|
||||
|
||||
LoginViewModel.prototype.selectLanguage = function ()
|
||||
{
|
||||
kn.showScreenPopup(PopupsLanguagesViewModel);
|
||||
};
|
||||
|
||||
113
dev/ViewModels/MailBoxFolderListViewModel.js
Normal file
113
dev/ViewModels/MailBoxFolderListViewModel.js
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function MailBoxFolderListViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Left', 'MailFolderList');
|
||||
|
||||
this.folderList = RL.data().folderList;
|
||||
this.folderListSystem = RL.data().folderListSystem;
|
||||
|
||||
this.iDropOverTimer = 0;
|
||||
|
||||
this.allowContacts = !!RL.settingsGet('ContactsIsSupported') && !!RL.settingsGet('ContactsIsAllowed');
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('MailBoxFolderListViewModel', MailBoxFolderListViewModel);
|
||||
|
||||
MailBoxFolderListViewModel.prototype.onBuild = function (oDom)
|
||||
{
|
||||
oDom
|
||||
.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function (oEvent) {
|
||||
var
|
||||
oFolder = ko.dataFor(this),
|
||||
bCollapsed = false
|
||||
;
|
||||
if (oFolder && oEvent)
|
||||
{
|
||||
bCollapsed = oFolder.collapsed();
|
||||
Utils.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||
|
||||
oFolder.collapsed(!bCollapsed);
|
||||
oEvent.preventDefault();
|
||||
oEvent.stopPropagation();
|
||||
}
|
||||
})
|
||||
.on('click', '.b-folders .e-item .e-link.selectable', function (oEvent) {
|
||||
|
||||
oEvent.preventDefault();
|
||||
|
||||
var oFolder = ko.dataFor(this);
|
||||
if (oFolder)
|
||||
{
|
||||
if (!RL.data().usePreviewPane())
|
||||
{
|
||||
RL.data().message(null);
|
||||
}
|
||||
|
||||
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw())
|
||||
{
|
||||
RL.cache().setFolderHash(oFolder.fullNameRaw, '');
|
||||
}
|
||||
|
||||
kn.setHash(RL.link().mailBox(oFolder.fullNameHash));
|
||||
}
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
MailBoxFolderListViewModel.prototype.messagesDropOver = function (oFolder)
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
if (oFolder && oFolder.collapsed())
|
||||
{
|
||||
this.iDropOverTimer = window.setTimeout(function () {
|
||||
oFolder.collapsed(false);
|
||||
Utils.setExpandedFolder(oFolder.fullNameHash, true);
|
||||
Utils.windowResize();
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxFolderListViewModel.prototype.messagesDropOut = function ()
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {FolderModel} oToFolder
|
||||
* @param {{helper:jQuery}} oUi
|
||||
*/
|
||||
MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi)
|
||||
{
|
||||
if (oToFolder && oUi && oUi.helper)
|
||||
{
|
||||
var
|
||||
sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
|
||||
aUids = oUi.helper.data('rl-uids')
|
||||
;
|
||||
|
||||
if (MailBoxMessageListViewModel && MailBoxMessageListViewModel.__vm && Utils.isNormal(sFromFolderFullNameRaw) && Utils.isArray(aUids))
|
||||
{
|
||||
MailBoxMessageListViewModel.__vm.moveMessagesToFolder(
|
||||
sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxFolderListViewModel.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(PopupsComposeViewModel);
|
||||
};
|
||||
|
||||
MailBoxFolderListViewModel.prototype.contactsClick = function ()
|
||||
{
|
||||
if (this.allowContacts)
|
||||
{
|
||||
kn.showScreenPopup(PopupsContactsViewModel);
|
||||
}
|
||||
};
|
||||
935
dev/ViewModels/MailBoxMessageListViewModel.js
Normal file
935
dev/ViewModels/MailBoxMessageListViewModel.js
Normal file
|
|
@ -0,0 +1,935 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function MailBoxMessageListViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'MailMessageList');
|
||||
|
||||
this.sLastUid = null;
|
||||
this.emptySubjectValue = '';
|
||||
|
||||
var oData = RL.data();
|
||||
|
||||
this.popupVisibility = RL.popupVisibility;
|
||||
|
||||
this.messageList = oData.messageList;
|
||||
this.currentMessage = oData.currentMessage;
|
||||
this.isMessageSelected = oData.isMessageSelected;
|
||||
this.messageListSearch = oData.messageListSearch;
|
||||
this.messageListError = oData.messageListError;
|
||||
this.folderMenuForMove = oData.folderMenuForMove;
|
||||
|
||||
this.useCheckboxesInList = oData.useCheckboxesInList;
|
||||
|
||||
this.mainMessageListSearch = oData.mainMessageListSearch;
|
||||
this.messageListEndFolder = oData.messageListEndFolder;
|
||||
|
||||
this.messageListChecked = oData.messageListChecked;
|
||||
this.messageListCheckedOrSelected = oData.messageListCheckedOrSelected;
|
||||
this.messageListCheckedOrSelectedUidsWithSubMails = oData.messageListCheckedOrSelectedUidsWithSubMails;
|
||||
this.messageListCompleteLoadingThrottle = oData.messageListCompleteLoadingThrottle;
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.emptySubjectValue = Utils.i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT');
|
||||
}, this);
|
||||
|
||||
this.userQuota = oData.userQuota;
|
||||
this.userUsageSize = oData.userUsageSize;
|
||||
this.userUsageProc = oData.userUsageProc;
|
||||
|
||||
// append drag and drop
|
||||
this.dragOver = ko.observable(false).extend({'throttle': 1});
|
||||
this.dragOverEnter = ko.observable(false).extend({'throttle': 1});
|
||||
this.dragOverArea = ko.observable(null);
|
||||
this.dragOverBodyArea = ko.observable(null);
|
||||
|
||||
this.messageListItemTemplate = ko.computed(function () {
|
||||
return oData.usePreviewPane() ?
|
||||
'MailMessageListItem' : 'MailMessageListItemNoPreviewPane';
|
||||
});
|
||||
|
||||
this.messageListSearchDesc = ko.computed(function () {
|
||||
var sValue = oData.messageListEndSearch();
|
||||
return '' === sValue ? '' : Utils.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue});
|
||||
});
|
||||
|
||||
this.messageListPagenator = ko.computed(function () {
|
||||
|
||||
var
|
||||
iPrev = 0,
|
||||
iNext = 0,
|
||||
iLimit = 2,
|
||||
aResult = [],
|
||||
iCurrentPage = oData.messageListPage(),
|
||||
iPageCount = oData.messageListPageCount(),
|
||||
|
||||
/**
|
||||
* @param {number} iIndex
|
||||
* @param {boolean=} bPush
|
||||
* @param {string=} sCustomName
|
||||
*/
|
||||
fAdd = function (iIndex, bPush, sCustomName) {
|
||||
|
||||
var oData = {
|
||||
'current': iIndex === iCurrentPage,
|
||||
'name': Utils.isUnd(sCustomName) ? iIndex.toString() : sCustomName.toString(),
|
||||
'custom': Utils.isUnd(sCustomName) ? false : true,
|
||||
'title': Utils.isUnd(sCustomName) ? '' : iIndex.toString(),
|
||||
'value': iIndex.toString()
|
||||
};
|
||||
|
||||
if (Utils.isUnd(bPush) ? true : !!bPush)
|
||||
{
|
||||
aResult.push(oData);
|
||||
}
|
||||
else
|
||||
{
|
||||
aResult.unshift(oData);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
if (1 < iPageCount || (0 < iPageCount && iPageCount < iCurrentPage))
|
||||
// if (0 < iPageCount && 0 < iCurrentPage)
|
||||
{
|
||||
if (iPageCount < iCurrentPage)
|
||||
{
|
||||
fAdd(iPageCount);
|
||||
iPrev = iPageCount;
|
||||
iNext = iPageCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (3 >= iCurrentPage || iPageCount - 2 <= iCurrentPage)
|
||||
{
|
||||
iLimit += 2;
|
||||
}
|
||||
|
||||
fAdd(iCurrentPage);
|
||||
iPrev = iCurrentPage;
|
||||
iNext = iCurrentPage;
|
||||
}
|
||||
|
||||
while (0 < iLimit) {
|
||||
|
||||
iPrev -= 1;
|
||||
iNext += 1;
|
||||
|
||||
if (0 < iPrev)
|
||||
{
|
||||
fAdd(iPrev, false);
|
||||
iLimit--;
|
||||
}
|
||||
|
||||
if (iPageCount >= iNext)
|
||||
{
|
||||
fAdd(iNext, true);
|
||||
iLimit--;
|
||||
}
|
||||
else if (0 >= iPrev)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (3 === iPrev)
|
||||
{
|
||||
fAdd(2, false);
|
||||
}
|
||||
else if (3 < iPrev)
|
||||
{
|
||||
fAdd(Math.round((iPrev - 1) / 2), false, '...');
|
||||
}
|
||||
|
||||
if (iPageCount - 2 === iNext)
|
||||
{
|
||||
fAdd(iPageCount - 1, true);
|
||||
}
|
||||
else if (iPageCount - 2 > iNext)
|
||||
{
|
||||
fAdd(Math.round((iPageCount + iNext) / 2), true, '...');
|
||||
}
|
||||
|
||||
// first and last
|
||||
if (1 < iPrev)
|
||||
{
|
||||
fAdd(1, false);
|
||||
}
|
||||
|
||||
if (iPageCount > iNext)
|
||||
{
|
||||
fAdd(iPageCount, true);
|
||||
}
|
||||
}
|
||||
|
||||
return aResult;
|
||||
|
||||
}, this);
|
||||
|
||||
this.checkAll = ko.computed({
|
||||
'read': function () {
|
||||
return 0 < RL.data().messageListCheckedOrSelected().length;
|
||||
},
|
||||
|
||||
'write': function (bValue) {
|
||||
bValue = !!bValue;
|
||||
_.each(RL.data().messageList(), function (oMessage) {
|
||||
oMessage.checked(bValue);
|
||||
});
|
||||
|
||||
if (!bValue)
|
||||
{
|
||||
RL.data().message(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.inputMessageListSearchFocus = ko.observable(false);
|
||||
|
||||
this.sLastSearchValue = '';
|
||||
this.inputProxyMessageListSearch = ko.computed({
|
||||
'read': this.mainMessageListSearch,
|
||||
'write': function (sValue) {
|
||||
this.sLastSearchValue = sValue;
|
||||
},
|
||||
'owner': this
|
||||
});
|
||||
|
||||
this.isIncompleteChecked = ko.computed(function () {
|
||||
var
|
||||
iM = RL.data().messageList().length,
|
||||
iC = RL.data().messageListCheckedOrSelected().length
|
||||
;
|
||||
return 0 < iM && 0 < iC && iM > iC;
|
||||
}, this);
|
||||
|
||||
this.hasMessages = ko.computed(function () {
|
||||
return 0 < this.messageList().length;
|
||||
}, this);
|
||||
|
||||
this.hasCheckedLines = ko.computed(function () {
|
||||
return 0 < this.messageListChecked().length;
|
||||
}, this);
|
||||
|
||||
this.hasCheckedOrSelectedLines = ko.computed(function () {
|
||||
return 0 < this.messageListCheckedOrSelected().length;
|
||||
}, this);
|
||||
|
||||
this.isSpamFolder = ko.computed(function () {
|
||||
return RL.data().spamFolder() === this.messageListEndFolder();
|
||||
}, this);
|
||||
|
||||
this.isTrashFolder = ko.computed(function () {
|
||||
return RL.data().trashFolder() === this.messageListEndFolder();
|
||||
}, this);
|
||||
|
||||
this.canBeMoved = this.hasCheckedOrSelectedLines;
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
kn.showScreenPopup(PopupsFolderClearViewModel, [RL.data().currentFolder()]);
|
||||
});
|
||||
|
||||
this.multyForwardCommand = Utils.createCommand(this, function () {
|
||||
kn.showScreenPopup(PopupsComposeViewModel, [Enums.ComposeType.ForwardAsAttachment, RL.data().messageListCheckedOrSelected()]);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
|
||||
this.deleteSelectedMessageFromCurrentFolder(Enums.FolderType.Trash, false);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.deleteCommand = Utils.createCommand(this, function () {
|
||||
this.deleteSelectedMessageFromCurrentFolder(Enums.FolderType.Trash, true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.spamCommand = Utils.createCommand(this, function () {
|
||||
this.deleteSelectedMessageFromCurrentFolder(Enums.FolderType.Spam, true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.moveCommand = Utils.createCommand(this, Utils.emptyFunction, this.canBeMoved);
|
||||
|
||||
this.setCommand = Utils.createCommand(this, Utils.emptyFunction, this.hasCheckedLines);
|
||||
|
||||
this.checkCommand = Utils.createCommand(this, Utils.emptyFunction, this.hasCheckedLines);
|
||||
|
||||
this.reloadCommand = Utils.createCommand(this, function () {
|
||||
if (!RL.data().messageListCompleteLoadingThrottle())
|
||||
{
|
||||
RL.reloadMessageList(false, true);
|
||||
}
|
||||
});
|
||||
|
||||
this.quotaTooltip = _.bind(this.quotaTooltip, this);
|
||||
|
||||
this.selector = new Selector(this.messageList, this.currentMessage,
|
||||
'.messageListItem .actionHandle', '.messageListItem.selected', '.messageListItem .checkboxMessage');
|
||||
|
||||
this.selector.on('onItemSelect', _.bind(function (oMessage) {
|
||||
if (oMessage)
|
||||
{
|
||||
oData.message(oData.staticMessageList.populateByMessageListItem(oMessage));
|
||||
this.populateMessageBody(oData.message());
|
||||
}
|
||||
else
|
||||
{
|
||||
oData.message(null);
|
||||
}
|
||||
}, this));
|
||||
|
||||
this.selector.on('onItemGetUid', function (oMessage) {
|
||||
return oMessage ? oMessage.generateUid() : '';
|
||||
});
|
||||
|
||||
this.selector.on('onDelete', _.bind(function () {
|
||||
if (0 < RL.data().messageListCheckedOrSelected().length)
|
||||
{
|
||||
this.deleteCommand();
|
||||
}
|
||||
}, this));
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('MailBoxMessageListViewModel', MailBoxMessageListViewModel);
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.emptySubjectValue = '';
|
||||
|
||||
MailBoxMessageListViewModel.prototype.searchEnterAction = function ()
|
||||
{
|
||||
this.mainMessageListSearch(this.sLastSearchValue);
|
||||
this.inputMessageListSearchFocus(false);
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.cancelSearch = function ()
|
||||
{
|
||||
this.mainMessageListSearch('');
|
||||
this.inputMessageListSearchFocus(false);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFromFolderFullNameRaw
|
||||
* @param {Array} aUidForRemove
|
||||
* @param {string=} sToFolderFullNameRaw
|
||||
* @param {boolean=} bVisialEffectOnly = false
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.removeMessagesFromList = function (sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bVisialEffectOnly)
|
||||
{
|
||||
sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : '';
|
||||
bVisialEffectOnly = Utils.isUnd(bVisialEffectOnly) ? false : !!bVisialEffectOnly;
|
||||
|
||||
var
|
||||
iUnseenCount = 0 ,
|
||||
oData = RL.data(),
|
||||
oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw),
|
||||
oToFolder = '' === sToFolderFullNameRaw ? null : RL.cache().getFolderFromCacheList(sToFolderFullNameRaw || ''),
|
||||
sCurrentFolderFullNameRaw = oData.currentFolderFullNameRaw(),
|
||||
oCurrentMessage = oData.message(),
|
||||
aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(oData.messageList(), function (oMessage) {
|
||||
return oMessage && -1 < Utils.inArray(oMessage.uid, aUidForRemove);
|
||||
}) : []
|
||||
;
|
||||
|
||||
if (!bVisialEffectOnly)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oMessage && oMessage.unseen())
|
||||
{
|
||||
iUnseenCount++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (oFromFolder && !bVisialEffectOnly)
|
||||
{
|
||||
oFromFolder.messageCountAll(0 <= oFromFolder.messageCountAll() - aUidForRemove.length ?
|
||||
oFromFolder.messageCountAll() - aUidForRemove.length : 0);
|
||||
|
||||
if (0 < iUnseenCount)
|
||||
{
|
||||
oFromFolder.messageCountUnread(0 <= oFromFolder.messageCountUnread() - iUnseenCount ?
|
||||
oFromFolder.messageCountUnread() - iUnseenCount : 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (oToFolder && !bVisialEffectOnly)
|
||||
{
|
||||
oToFolder.messageCountAll(oToFolder.messageCountAll() + aUidForRemove.length);
|
||||
if (0 < iUnseenCount)
|
||||
{
|
||||
oToFolder.messageCountUnread(oToFolder.messageCountUnread() + iUnseenCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < aMessages.length)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oCurrentMessage && oCurrentMessage.requestHash === oMessage.requestHash)
|
||||
{
|
||||
oCurrentMessage = null;
|
||||
oData.message(null);
|
||||
}
|
||||
|
||||
oMessage.deleted(true);
|
||||
});
|
||||
|
||||
_.delay(function () {
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oData.messageList.remove(oMessage);
|
||||
});
|
||||
}, 400);
|
||||
|
||||
if (!bVisialEffectOnly)
|
||||
{
|
||||
RL.data().messageListIsNotCompleted(true);
|
||||
RL.cache().setFolderHash(sFromFolderFullNameRaw, '');
|
||||
|
||||
if (Utils.isNormal(sToFolderFullNameRaw))
|
||||
{
|
||||
RL.cache().setFolderHash(sToFolderFullNameRaw || '', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string=} sToFolderFullNameRaw
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.removeCheckedOrSelectedMessagesFromList = function (sToFolderFullNameRaw)
|
||||
{
|
||||
this.removeMessagesFromList(RL.data().currentFolderFullNameRaw(), _.map(RL.data().messageListCheckedOrSelected(), function (oMessage) {
|
||||
return oMessage.uid;
|
||||
}), sToFolderFullNameRaw);
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.moveOrDeleteResponse = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && RL.data().currentFolder())
|
||||
{
|
||||
if (oData && Utils.isArray(oData.Result) && 2 === oData.Result.length)
|
||||
{
|
||||
RL.cache().setFolderHash(oData.Result[0], oData.Result[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData && Enums.Notification.CantMoveMessage === oData.ErrorCode)
|
||||
{
|
||||
window.alert(Utils.getNotification(Enums.Notification.CantMoveMessage));
|
||||
}
|
||||
|
||||
RL.cache().setFolderHash(RL.data().currentFolderFullNameRaw(), '');
|
||||
}
|
||||
|
||||
RL.reloadMessageList();
|
||||
|
||||
RL.quotaDebounce();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFromFolderFullNameRaw
|
||||
* @param {Array} aUidForRemove
|
||||
* @param {string} sToFolderFullNameRaw
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw)
|
||||
{
|
||||
if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForRemove) && 0 < aUidForRemove.length)
|
||||
{
|
||||
var
|
||||
oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw),
|
||||
oToFolder = RL.cache().getFolderFromCacheList(sToFolderFullNameRaw)
|
||||
;
|
||||
|
||||
if (oFromFolder && oToFolder)
|
||||
{
|
||||
RL.remote().messagesMove(
|
||||
_.bind(this.moveOrDeleteResponse, this),
|
||||
oFromFolder.fullNameRaw,
|
||||
oToFolder.fullNameRaw,
|
||||
aUidForRemove
|
||||
);
|
||||
|
||||
oToFolder.actionBlink(true);
|
||||
|
||||
this.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sToFolderFullNameRaw
|
||||
* @return {boolean}
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.moveSelectedMessagesToFolder = function (sToFolderFullNameRaw)
|
||||
{
|
||||
if (this.canBeMoved())
|
||||
{
|
||||
return this.moveMessagesToFolder(RL.data().currentFolderFullNameRaw(),
|
||||
RL.data().messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} iType
|
||||
* @param {boolean=} bUseFolder = true
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.deleteSelectedMessageFromCurrentFolder = function (iType, bUseFolder)
|
||||
{
|
||||
if (this.canBeMoved())
|
||||
{
|
||||
bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder;
|
||||
var oTrashOrSpamFolder = RL.cache().getFolderFromCacheList(
|
||||
Enums.FolderType.Spam === iType ? RL.data().spamFolder() : RL.data().trashFolder());
|
||||
|
||||
if (!oTrashOrSpamFolder && bUseFolder)
|
||||
{
|
||||
kn.showScreenPopup(PopupsFolderSystemViewModel, [
|
||||
Enums.FolderType.Spam === iType ? Enums.SetSystemFoldersNotification.Spam : Enums.SetSystemFoldersNotification.Trash]);
|
||||
}
|
||||
else if (!bUseFolder || (oTrashOrSpamFolder && (Consts.Values.UnuseOptionValue === oTrashOrSpamFolder.fullNameRaw ||
|
||||
RL.data().currentFolderFullNameRaw() === oTrashOrSpamFolder.fullNameRaw)))
|
||||
{
|
||||
RL.remote().messagesDelete(
|
||||
_.bind(this.moveOrDeleteResponse, this),
|
||||
RL.data().currentFolderFullNameRaw(),
|
||||
RL.data().messageListCheckedOrSelectedUidsWithSubMails()
|
||||
);
|
||||
|
||||
this.removeCheckedOrSelectedMessagesFromList();
|
||||
}
|
||||
else if (oTrashOrSpamFolder)
|
||||
{
|
||||
RL.remote().messagesMove(
|
||||
_.bind(this.moveOrDeleteResponse, this),
|
||||
RL.data().currentFolderFullNameRaw(),
|
||||
oTrashOrSpamFolder.fullNameRaw,
|
||||
RL.data().messageListCheckedOrSelectedUidsWithSubMails()
|
||||
);
|
||||
|
||||
oTrashOrSpamFolder.actionBlink(true);
|
||||
this.removeCheckedOrSelectedMessagesFromList(oTrashOrSpamFolder.fullNameRaw);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageListItem)
|
||||
{
|
||||
if (oMessageListItem)
|
||||
{
|
||||
oMessageListItem.checked(true);
|
||||
}
|
||||
|
||||
var oEl = Utils.draggeblePlace();
|
||||
oEl.data('rl-folder', RL.data().currentFolderFullNameRaw());
|
||||
oEl.data('rl-uids', RL.data().messageListCheckedOrSelectedUidsWithSubMails());
|
||||
oEl.find('.text').text(RL.data().messageListCheckedOrSelectedUidsWithSubMails().length);
|
||||
|
||||
return oEl;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sResult
|
||||
* @param {AjaxJsonDefaultResponse} oData
|
||||
* @param {boolean} bCached
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.onMessageResponse = function (sResult, oData, bCached)
|
||||
{
|
||||
var oRainLoopData = RL.data();
|
||||
|
||||
oRainLoopData.messageLoading(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
oRainLoopData.setMessage(oData, bCached);
|
||||
}
|
||||
else if (Enums.StorageResultType.Unload === sResult)
|
||||
{
|
||||
oRainLoopData.message(null);
|
||||
oRainLoopData.messageError('');
|
||||
}
|
||||
else if (Enums.StorageResultType.Abort !== sResult)
|
||||
{
|
||||
oRainLoopData.message(null);
|
||||
oRainLoopData.messageError((oData && oData.ErrorCode ?
|
||||
Utils.getNotification(oData.ErrorCode) :
|
||||
Utils.getNotification(Enums.Notification.UnknownError)));
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.populateMessageBody = function (oMessage)
|
||||
{
|
||||
if (oMessage)
|
||||
{
|
||||
if (RL.remote().message(this.onMessageResponse, oMessage.folderFullNameRaw, oMessage.uid))
|
||||
{
|
||||
RL.data().messageLoading(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.log('Error: Unknown message request: ' + oMessage.folderFullNameRaw + ' ~ ' + oMessage.uid + ' [e-101]');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFolderFullNameRaw
|
||||
* @param {number} iSetAction
|
||||
* @param {Array=} aMessages = null
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.setAction = function (sFolderFullNameRaw, iSetAction, aMessages)
|
||||
{
|
||||
var
|
||||
aUids = [],
|
||||
oFolder = null,
|
||||
oCache = RL.cache(),
|
||||
iAlreadyUnread = 0
|
||||
;
|
||||
|
||||
if (Utils.isUnd(aMessages))
|
||||
{
|
||||
aMessages = RL.data().messageListChecked();
|
||||
}
|
||||
|
||||
aUids = _.map(aMessages, function (oMessage) {
|
||||
return oMessage.uid;
|
||||
});
|
||||
|
||||
if ('' !== sFolderFullNameRaw && 0 < aUids.length)
|
||||
{
|
||||
switch (iSetAction) {
|
||||
case Enums.MessageSetAction.SetSeen:
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oMessage.unseen())
|
||||
{
|
||||
iAlreadyUnread++;
|
||||
}
|
||||
|
||||
oMessage.unseen(false);
|
||||
oCache.storeMessageFlagsToCache(oMessage);
|
||||
});
|
||||
|
||||
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread);
|
||||
}
|
||||
|
||||
RL.remote().messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, true);
|
||||
break;
|
||||
case Enums.MessageSetAction.UnsetSeen:
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oMessage.unseen())
|
||||
{
|
||||
iAlreadyUnread++;
|
||||
}
|
||||
|
||||
oMessage.unseen(true);
|
||||
oCache.storeMessageFlagsToCache(oMessage);
|
||||
});
|
||||
|
||||
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread + aUids.length);
|
||||
}
|
||||
RL.remote().messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, false);
|
||||
break;
|
||||
case Enums.MessageSetAction.SetFlag:
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.flagged(true);
|
||||
oCache.storeMessageFlagsToCache(oMessage);
|
||||
});
|
||||
RL.remote().messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, true);
|
||||
break;
|
||||
case Enums.MessageSetAction.UnsetFlag:
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.flagged(false);
|
||||
oCache.storeMessageFlagsToCache(oMessage);
|
||||
});
|
||||
RL.remote().messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, false);
|
||||
break;
|
||||
}
|
||||
|
||||
RL.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFolderFullNameRaw
|
||||
* @param {number} iSetAction
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.setActionForAll = function (sFolderFullNameRaw, iSetAction)
|
||||
{
|
||||
var
|
||||
oFolder = null,
|
||||
aMessages = RL.data().messageList(),
|
||||
oCache = RL.cache()
|
||||
;
|
||||
|
||||
if ('' !== sFolderFullNameRaw)
|
||||
{
|
||||
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
|
||||
if (oFolder)
|
||||
{
|
||||
switch (iSetAction) {
|
||||
case Enums.MessageSetAction.SetSeen:
|
||||
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.unseen(false);
|
||||
});
|
||||
|
||||
oFolder.messageCountUnread(0);
|
||||
oCache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
|
||||
}
|
||||
|
||||
RL.remote().messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, true);
|
||||
break;
|
||||
case Enums.MessageSetAction.UnsetSeen:
|
||||
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.unseen(true);
|
||||
});
|
||||
|
||||
oFolder.messageCountUnread(oFolder.messageCountAll());
|
||||
oCache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
|
||||
}
|
||||
RL.remote().messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, false);
|
||||
break;
|
||||
}
|
||||
|
||||
RL.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.listSetSeen = function ()
|
||||
{
|
||||
this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen, RL.data().messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.listSetAllSeen = function ()
|
||||
{
|
||||
this.setActionForAll(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen);
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.listUnsetSeen = function ()
|
||||
{
|
||||
this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetSeen, RL.data().messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.listSetFlags = function ()
|
||||
{
|
||||
this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetFlag, RL.data().messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.listUnsetFlags = function ()
|
||||
{
|
||||
this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetFlag, RL.data().messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oData = RL.data()
|
||||
;
|
||||
|
||||
this.oContentVisible = $('.b-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
this.oContentVisible.on('click', '.fullThreadHandle', function () {
|
||||
var
|
||||
aList = [],
|
||||
oMessage = ko.dataFor(this)
|
||||
;
|
||||
|
||||
if (oMessage && !oMessage.lastInCollapsedThreadLoading())
|
||||
{
|
||||
RL.data().messageListThreadFolder(oMessage.folderFullNameRaw);
|
||||
|
||||
aList = RL.data().messageListThreadUids();
|
||||
|
||||
if (oMessage.lastInCollapsedThread())
|
||||
{
|
||||
aList.push(0 < oMessage.parentUid() ? oMessage.parentUid() : oMessage.uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
aList = _.without(aList, 0 < oMessage.parentUid() ? oMessage.parentUid() : oMessage.uid);
|
||||
}
|
||||
|
||||
RL.data().messageListThreadUids(_.uniq(aList));
|
||||
|
||||
oMessage.lastInCollapsedThreadLoading(true);
|
||||
oMessage.lastInCollapsedThread(!oMessage.lastInCollapsedThread());
|
||||
RL.reloadMessageList();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
this.selector.init(this.oContentVisible, this.oContentScrollable);
|
||||
|
||||
$document.on('keydown', function (oEvent) {
|
||||
|
||||
var
|
||||
bResult = true,
|
||||
iKeyCode = oEvent ? oEvent.keyCode : 0
|
||||
;
|
||||
|
||||
if (oEvent && self.viewModelVisibility() && oData.useKeyboardShortcuts() && !RL.popupVisibility() && !oData.messageFullScreenMode() && !Utils.inFocus())
|
||||
{
|
||||
if (oData.usePreviewPane() || (!oData.message() && (Enums.EventKeyCode.Delete === iKeyCode || Enums.EventKeyCode.A === iKeyCode)))
|
||||
{
|
||||
if (oEvent.ctrlKey && Enums.EventKeyCode.A === iKeyCode)
|
||||
{
|
||||
self.checkAll(!(self.checkAll() && !self.isIncompleteChecked()));
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bResult;
|
||||
});
|
||||
|
||||
oDom
|
||||
.on('click', '.pagenator .page', function () {
|
||||
var oPage = ko.dataFor(this);
|
||||
if (oPage)
|
||||
{
|
||||
kn.setHash(RL.link().mailBox(
|
||||
oData.currentFolderFullNameHash(),
|
||||
oPage.value,
|
||||
oData.messageListSearch()
|
||||
));
|
||||
}
|
||||
})
|
||||
.on('click', '.messageList .checkboxCkeckAll', function () {
|
||||
self.checkAll(!self.checkAll());
|
||||
})
|
||||
.on('click', '.messageList .messageListItem .flagParent', function () {
|
||||
|
||||
var
|
||||
oMessage = ko.dataFor(this),
|
||||
aChecked = oData.messageListCheckedOrSelected(),
|
||||
aCheckedUids = []
|
||||
;
|
||||
|
||||
if (oMessage)
|
||||
{
|
||||
if (0 < aChecked.length)
|
||||
{
|
||||
aCheckedUids = _.map(aChecked, function (oMessage) {
|
||||
return oMessage.uid;
|
||||
});
|
||||
}
|
||||
|
||||
if (0 < aCheckedUids.length && -1 < Utils.inArray(oMessage.uid, aCheckedUids))
|
||||
{
|
||||
self.setAction(oMessage.folderFullNameRaw, oMessage.flagged() ?
|
||||
Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.setAction(oMessage.folderFullNameRaw, oMessage.flagged() ?
|
||||
Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oMessage]);
|
||||
}
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
ko.computed(function () {
|
||||
|
||||
var
|
||||
oData = RL.data(),
|
||||
bViewModelVisibility = this.viewModelVisibility(),
|
||||
bPopupVisibility = RL.popupVisibility(),
|
||||
bUseKeyboardShortcuts = oData.useKeyboardShortcuts(),
|
||||
bMessageFullScreenMode = oData.messageFullScreenMode()
|
||||
;
|
||||
|
||||
this.selector.useKeyboard(bViewModelVisibility && bUseKeyboardShortcuts && !bMessageFullScreenMode && !bPopupVisibility);
|
||||
|
||||
}, this).extend({'notify': 'always'});
|
||||
|
||||
this.initUploaderForAppend();
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(PopupsComposeViewModel);
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.advancedSearchClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(PopupsAdvancedSearchViewModel);
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.quotaTooltip = function ()
|
||||
{
|
||||
return Utils.i18n('MESSAGE_LIST/QUOTA_SIZE', {
|
||||
'SIZE': Utils.friendlySize(this.userUsageSize()),
|
||||
'PROC': this.userUsageProc(),
|
||||
'LIMIT': Utils.friendlySize(this.userQuota())
|
||||
});
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.initUploaderForAppend = function ()
|
||||
{
|
||||
if (!RL.settingsGet('AllowAppendMessage') || !this.dragOverArea())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var oJua = new Jua({
|
||||
'action': RL.link().append(),
|
||||
'name': 'AppendFile',
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'disableFolderDragAndDrop': true,
|
||||
'hidden': {
|
||||
'Folder': function () {
|
||||
return RL.data().currentFolderFullNameRaw();
|
||||
}
|
||||
},
|
||||
'dragAndDropElement': this.dragOverArea(),
|
||||
'dragAndDropBodyElement': this.dragOverBodyArea(),
|
||||
'onDragEnter': _.bind(function () {
|
||||
this.dragOverEnter(true);
|
||||
}, this),
|
||||
'onDragLeave': _.bind(function () {
|
||||
this.dragOverEnter(false);
|
||||
}, this),
|
||||
'onBodyDragEnter': _.bind(function () {
|
||||
this.dragOver(true);
|
||||
}, this),
|
||||
'onBodyDragLeave': _.bind(function () {
|
||||
this.dragOver(false);
|
||||
}, this),
|
||||
'onSelect': _.bind(function (sUid, oData) {
|
||||
if (sUid && oData && 'message/rfc822' === oData['Type'])
|
||||
{
|
||||
RL.data().messageListLoading(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}),
|
||||
'onComplete': _.bind(function () {
|
||||
RL.reloadMessageList(true, true);
|
||||
}, this)
|
||||
});
|
||||
|
||||
return !!oJua;
|
||||
};
|
||||
320
dev/ViewModels/MailBoxMessageViewViewModel.js
Normal file
320
dev/ViewModels/MailBoxMessageViewViewModel.js
Normal file
|
|
@ -0,0 +1,320 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function MailBoxMessageViewViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'MailMessageView');
|
||||
|
||||
var
|
||||
sPic = '',
|
||||
oData = RL.data(),
|
||||
self = this,
|
||||
createCommandHelper = function (sType) {
|
||||
return Utils.createCommand(self, function () {
|
||||
this.replyOrforward(sType);
|
||||
}, self.canBeRepliedOrForwarded);
|
||||
}
|
||||
;
|
||||
|
||||
this.oMessageScrollerDom = null;
|
||||
|
||||
this.message = oData.message;
|
||||
this.messageLoading = oData.messageLoading;
|
||||
this.messageLoadingThrottle = oData.messageLoadingThrottle;
|
||||
this.messagesBodiesDom = oData.messagesBodiesDom;
|
||||
this.useThreads = oData.useThreads;
|
||||
this.replySameFolder = oData.replySameFolder;
|
||||
this.usePreviewPane = oData.usePreviewPane;
|
||||
this.isMessageSelected = oData.isMessageSelected;
|
||||
this.messageActiveDom = oData.messageActiveDom;
|
||||
this.messageError = oData.messageError;
|
||||
|
||||
this.fullScreenMode = oData.messageFullScreenMode;
|
||||
|
||||
this.showFullInfo = ko.observable(false);
|
||||
|
||||
this.messageVisibility = ko.computed(function () {
|
||||
return !this.messageLoadingThrottle() && !!this.message();
|
||||
}, this);
|
||||
|
||||
this.canBeRepliedOrForwarded = this.messageVisibility;
|
||||
|
||||
// commands
|
||||
this.closeMessage = Utils.createCommand(this, function () {
|
||||
oData.message(null);
|
||||
});
|
||||
|
||||
this.replyCommand = createCommandHelper(Enums.ComposeType.Reply);
|
||||
this.replyAllCommand = createCommandHelper(Enums.ComposeType.ReplyAll);
|
||||
this.forwardCommand = createCommandHelper(Enums.ComposeType.Forward);
|
||||
this.forwardAsAttachmentCommand = createCommandHelper(Enums.ComposeType.ForwardAsAttachment);
|
||||
|
||||
this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility);
|
||||
|
||||
this.messageEditCommand = Utils.createCommand(this, function () {
|
||||
this.editMessage();
|
||||
}, this.messageVisibility);
|
||||
|
||||
// viewer
|
||||
this.viewSubject = ko.observable('');
|
||||
this.viewFromShort = ko.observable('');
|
||||
this.viewToShort = ko.observable('');
|
||||
this.viewFrom = ko.observable('');
|
||||
this.viewTo = ko.observable('');
|
||||
this.viewCc = ko.observable('');
|
||||
this.viewBcc = ko.observable('');
|
||||
this.viewDate = ko.observable('');
|
||||
this.viewMoment = ko.observable('');
|
||||
this.viewLineAsCcc = ko.observable('');
|
||||
this.viewHasImages = ko.observable(false);
|
||||
this.viewHasVisibleAttachments = ko.observable(false);
|
||||
this.viewAttachments = ko.observableArray([]);
|
||||
this.viewIsHtml = ko.observable(false);
|
||||
this.viewIsRtl = ko.observable(false);
|
||||
this.viewViewLink = ko.observable('');
|
||||
this.viewDownloadLink = ko.observable('');
|
||||
this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic);
|
||||
this.viewUserPicVisible = ko.observable(false);
|
||||
|
||||
this.message.subscribe(function (oMessage) {
|
||||
|
||||
this.messageActiveDom(null);
|
||||
|
||||
if (oMessage)
|
||||
{
|
||||
this.viewSubject(oMessage.subject());
|
||||
this.viewFromShort(oMessage.fromToLine(true, true));
|
||||
this.viewToShort(oMessage.toToLine(true, true));
|
||||
this.viewFrom(oMessage.fromToLine(false));
|
||||
this.viewTo(oMessage.toToLine(false));
|
||||
this.viewCc(oMessage.ccToLine(false));
|
||||
this.viewBcc(oMessage.bccToLine(false));
|
||||
this.viewDate(oMessage.fullFormatDateValue());
|
||||
this.viewMoment(oMessage.momentDate());
|
||||
this.viewLineAsCcc(oMessage.lineAsCcc());
|
||||
this.viewHasImages(oMessage.hasImages());
|
||||
this.viewHasVisibleAttachments(oMessage.hasVisibleAttachments());
|
||||
this.viewAttachments(oMessage.attachments());
|
||||
this.viewIsHtml(oMessage.isHtml());
|
||||
this.viewIsRtl(oMessage.isRtl());
|
||||
this.viewViewLink(oMessage.viewLink());
|
||||
this.viewDownloadLink(oMessage.downloadLink());
|
||||
|
||||
sPic = RL.cache().getUserPic(oMessage.fromAsSingleEmail());
|
||||
if (sPic !== this.viewUserPic())
|
||||
{
|
||||
this.viewUserPicVisible(false);
|
||||
this.viewUserPic(Consts.DataImages.UserDotPic);
|
||||
if ('' !== sPic)
|
||||
{
|
||||
this.viewUserPicVisible(true);
|
||||
this.viewUserPic(sPic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
||||
this.fullScreenMode.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
$html.addClass('rl-message-fullscreen');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html.removeClass('rl-message-fullscreen');
|
||||
}
|
||||
|
||||
Utils.windowResize();
|
||||
});
|
||||
|
||||
this.messageLoadingThrottle.subscribe(function (bV) {
|
||||
if (bV)
|
||||
{
|
||||
Utils.windowResize();
|
||||
}
|
||||
});
|
||||
|
||||
this.messageActiveDom.subscribe(function () {
|
||||
this.scrollMessageToTop();
|
||||
}, this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('MailBoxMessageViewViewModel', MailBoxMessageViewViewModel);
|
||||
|
||||
MailBoxMessageViewViewModel.prototype.scrollToTop = function ()
|
||||
{
|
||||
var oCont = $('.messageItem.nano .content', this.viewModelDom);
|
||||
if (oCont && oCont[0])
|
||||
{
|
||||
// oCont.animate({'scrollTop': 0}, 300);
|
||||
oCont.scrollTop(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// $('.messageItem', this.viewModelDom).animate({'scrollTop': 0}, 300);
|
||||
$('.messageItem', this.viewModelDom).scrollTop(0);
|
||||
}
|
||||
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
MailBoxMessageViewViewModel.prototype.fullScreen = function ()
|
||||
{
|
||||
this.fullScreenMode(true);
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
MailBoxMessageViewViewModel.prototype.unFullScreen = function ()
|
||||
{
|
||||
this.fullScreenMode(false);
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
MailBoxMessageViewViewModel.prototype.toggleFullScreen = function ()
|
||||
{
|
||||
Utils.removeSelection();
|
||||
|
||||
this.fullScreenMode(!this.fullScreenMode());
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sType
|
||||
*/
|
||||
MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType)
|
||||
{
|
||||
kn.showScreenPopup(PopupsComposeViewModel, [sType, RL.data().message()]);
|
||||
};
|
||||
|
||||
MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oData = RL.data()
|
||||
;
|
||||
|
||||
$document.on('keydown', function (oEvent) {
|
||||
|
||||
var
|
||||
bResult = true,
|
||||
iKeyCode = oEvent ? oEvent.keyCode : 0
|
||||
;
|
||||
|
||||
if (0 < iKeyCode && (Enums.EventKeyCode.Backspace === iKeyCode || Enums.EventKeyCode.Esc === iKeyCode) &&
|
||||
self.viewModelVisibility() && oData.useKeyboardShortcuts() && !Utils.inFocus() && oData.message())
|
||||
{
|
||||
self.fullScreenMode(false);
|
||||
if (!oData.usePreviewPane())
|
||||
{
|
||||
oData.message(null);
|
||||
}
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
});
|
||||
|
||||
$('.attachmentsPlace', oDom).magnificPopup({
|
||||
'delegate': '.magnificPopupImage:visible',
|
||||
'type': 'image',
|
||||
'gallery': {
|
||||
'enabled': true,
|
||||
'preload': [1, 1],
|
||||
'navigateByImgClick': true
|
||||
},
|
||||
'callbacks': {
|
||||
'open': function() {
|
||||
oData.useKeyboardShortcuts(false);
|
||||
},
|
||||
'close': function() {
|
||||
oData.useKeyboardShortcuts(true);
|
||||
}
|
||||
},
|
||||
'mainClass': 'mfp-fade',
|
||||
'removalDelay': 400
|
||||
});
|
||||
|
||||
oDom
|
||||
.on('click', '.attachmentsPlace .attachmentPreview', function (oEvent) {
|
||||
if (oEvent && oEvent.stopPropagation)
|
||||
{
|
||||
oEvent.stopPropagation();
|
||||
}
|
||||
})
|
||||
.on('click', '.attachmentsPlace .attachmentItem', function () {
|
||||
|
||||
var
|
||||
oAttachment = ko.dataFor(this)
|
||||
;
|
||||
|
||||
if (oAttachment && oAttachment.download)
|
||||
{
|
||||
RL.download(oAttachment.linkDownload());
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
this.oMessageScrollerDom = oDom.find('.messageItem .content');
|
||||
this.oMessageScrollerDom = this.oMessageScrollerDom && this.oMessageScrollerDom[0] ? this.oMessageScrollerDom : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MailBoxMessageViewViewModel.prototype.isDraftFolder = function ()
|
||||
{
|
||||
return RL.data().message() && RL.data().draftFolder() === RL.data().message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MailBoxMessageViewViewModel.prototype.isSentFolder = function ()
|
||||
{
|
||||
return RL.data().message() && RL.data().sentFolder() === RL.data().message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MailBoxMessageViewViewModel.prototype.isDraftOrSentFolder = function ()
|
||||
{
|
||||
return this.isDraftFolder() || this.isSentFolder();
|
||||
};
|
||||
|
||||
MailBoxMessageViewViewModel.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(PopupsComposeViewModel);
|
||||
};
|
||||
|
||||
MailBoxMessageViewViewModel.prototype.editMessage = function ()
|
||||
{
|
||||
if (RL.data().message())
|
||||
{
|
||||
kn.showScreenPopup(PopupsComposeViewModel, [Enums.ComposeType.Draft, RL.data().message()]);
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxMessageViewViewModel.prototype.scrollMessageToTop = function ()
|
||||
{
|
||||
if (this.oMessageScrollerDom)
|
||||
{
|
||||
this.oMessageScrollerDom.scrollTop(0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MailBoxMessageViewViewModel.prototype.showImages = function (oMessage)
|
||||
{
|
||||
if (oMessage && oMessage.showExternalImages)
|
||||
{
|
||||
oMessage.showExternalImages(true);
|
||||
}
|
||||
};
|
||||
12
dev/ViewModels/MailBoxSystemDropDownViewModel.js
Normal file
12
dev/ViewModels/MailBoxSystemDropDownViewModel.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownViewModel
|
||||
*/
|
||||
function MailBoxSystemDropDownViewModel()
|
||||
{
|
||||
AbstractSystemDropDownViewModel.call(this);
|
||||
}
|
||||
|
||||
_.extend(MailBoxSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype);
|
||||
110
dev/ViewModels/PopupsActivateViewModel.js
Normal file
110
dev/ViewModels/PopupsActivateViewModel.js
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsActivateViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsActivate');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
|
||||
this.licenseTrigger = RL.data().licenseTrigger;
|
||||
|
||||
this.activateProcess = ko.observable(false);
|
||||
this.activateText = ko.observable('');
|
||||
this.activateText.isError = ko.observable(false);
|
||||
|
||||
this.key.subscribe(function () {
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
}, this);
|
||||
|
||||
this.activationSuccessed.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.activateCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey())
|
||||
{
|
||||
RL.remote().licensingActivate(function (sResult, oData) {
|
||||
|
||||
self.activateProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
if (true === oData.Result)
|
||||
{
|
||||
self.activationSuccessed(true);
|
||||
self.activateText('Subscription Key Activated Successfully');
|
||||
self.activateText.isError(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(oData.Result);
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
self.activateText(Utils.getNotification(oData.ErrorCode));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
|
||||
}, this.domain(), this.key());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.activateProcess(false);
|
||||
this.activateText('Invalid Subscription Key');
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
|
||||
}, function () {
|
||||
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
|
||||
});
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsActivateViewModel', PopupsActivateViewModel);
|
||||
|
||||
PopupsActivateViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.domain(RL.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
this.key('');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
|
||||
this.key.focus(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
PopupsActivateViewModel.prototype.validateSubscriptionKey = function ()
|
||||
{
|
||||
var sValue = this.key();
|
||||
return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue));
|
||||
};
|
||||
113
dev/ViewModels/PopupsAddAccountViewModel.js
Normal file
113
dev/ViewModels/PopupsAddAccountViewModel.js
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAddAccountViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddAccount');
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
}, this);
|
||||
|
||||
this.login.subscribe(function () {
|
||||
this.loginError(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.allowCustomLogin = ko.observable(false);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
this.loginFocus = ko.observable(false);
|
||||
|
||||
this.addAccountCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
RL.remote().accountAdd(_.bind(function (sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AccountAdd' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.email(), this.login(), this.password());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.loginFocus.subscribe(function (bValue) {
|
||||
if (bValue && '' === this.login() && '' !== this.email())
|
||||
{
|
||||
this.login(this.email());
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsAddAccountViewModel', PopupsAddAccountViewModel);
|
||||
|
||||
PopupsAddAccountViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.email('');
|
||||
this.login('');
|
||||
this.password('');
|
||||
|
||||
this.emailError(false);
|
||||
this.loginError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
PopupsAddAccountViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
this.emailFocus(true);
|
||||
};
|
||||
|
||||
|
||||
PopupsAddAccountViewModel.prototype.onBuild = function ()
|
||||
{
|
||||
this.allowCustomLogin(!!RL.settingsGet('AllowCustomLogin'));
|
||||
};
|
||||
105
dev/ViewModels/PopupsAdvancedSearchViewModel.js
Normal file
105
dev/ViewModels/PopupsAdvancedSearchViewModel.js
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAdvancedSearchViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAdvancedSearch');
|
||||
|
||||
this.fromFocus = ko.observable(false);
|
||||
|
||||
this.from = ko.observable('');
|
||||
this.to = ko.observable('');
|
||||
this.subject = ko.observable('');
|
||||
this.text = ko.observable('');
|
||||
this.selectedDateValue = ko.observable(-1);
|
||||
this.hasAttachments = ko.observable(false);
|
||||
|
||||
this.searchCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var sSearch = this.buildSearchString();
|
||||
if ('' !== sSearch)
|
||||
{
|
||||
RL.data().mainMessageListSearch(sSearch);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
});
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsAdvancedSearchViewModel', PopupsAdvancedSearchViewModel);
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.buildSearchStringValue = function (sValue)
|
||||
{
|
||||
if (-1 < sValue.indexOf(' '))
|
||||
{
|
||||
sValue = '"' + sValue + '"';
|
||||
}
|
||||
|
||||
return sValue;
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.buildSearchString = function ()
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
sFrom = Utils.trim(this.from()),
|
||||
sTo = Utils.trim(this.to()),
|
||||
sSubject = Utils.trim(this.subject()),
|
||||
sText = Utils.trim(this.text())
|
||||
;
|
||||
|
||||
if (sFrom && '' !== sFrom)
|
||||
{
|
||||
aResult.push('from:' + this.buildSearchStringValue(sFrom));
|
||||
}
|
||||
|
||||
if (sTo && '' !== sTo)
|
||||
{
|
||||
aResult.push('to:' + this.buildSearchStringValue(sTo));
|
||||
}
|
||||
|
||||
if (sSubject && '' !== sSubject)
|
||||
{
|
||||
aResult.push('subject:' + this.buildSearchStringValue(sSubject));
|
||||
}
|
||||
|
||||
if (this.hasAttachments())
|
||||
{
|
||||
aResult.push('has:attachments');
|
||||
}
|
||||
|
||||
if (-1 < this.selectedDateValue())
|
||||
{
|
||||
aResult.push('date:' + moment().subtract('days', this.selectedDateValue()).format('YYYY.MM.DD') + '/');
|
||||
}
|
||||
|
||||
if (sText && '' !== sText)
|
||||
{
|
||||
aResult.push('text:' + this.buildSearchStringValue(sText));
|
||||
}
|
||||
|
||||
return Utils.trim(aResult.join(' '));
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.from('');
|
||||
this.to('');
|
||||
this.subject('');
|
||||
this.text('');
|
||||
|
||||
this.selectedDateValue(-1);
|
||||
this.hasAttachments(false);
|
||||
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.fromFocus(true);
|
||||
};
|
||||
1367
dev/ViewModels/PopupsComposeViewModel.js
Normal file
1367
dev/ViewModels/PopupsComposeViewModel.js
Normal file
File diff suppressed because it is too large
Load diff
385
dev/ViewModels/PopupsContactsViewModel.js
Normal file
385
dev/ViewModels/PopupsContactsViewModel.js
Normal file
|
|
@ -0,0 +1,385 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsContactsViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsContacts');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.imageUploader = ko.observable(null);
|
||||
this.imageDom = ko.observable(null);
|
||||
this.imageTrigger = ko.observable(false);
|
||||
|
||||
this.search = ko.observable('');
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.currentContact = ko.observable(null);
|
||||
|
||||
this.emptySelection = ko.observable(true);
|
||||
this.viewClearSearch = ko.observable(false);
|
||||
|
||||
this.viewID = ko.observable('');
|
||||
this.viewName = ko.observable('');
|
||||
this.viewName.focused = ko.observable(false);
|
||||
this.viewEmail = ko.observable('').validateEmail();
|
||||
this.viewEmail.focused = ko.observable(false);
|
||||
this.viewImageUrl = ko.observable(RL.link().emptyContactPic());
|
||||
|
||||
this.viewSaving = ko.observable(false);
|
||||
|
||||
this.useCheckboxesInList = RL.data().useCheckboxesInList;
|
||||
|
||||
this.search.subscribe(function () {
|
||||
this.reloadContactList();
|
||||
}, this);
|
||||
|
||||
this.contacts.subscribe(function () {
|
||||
Utils.windowResize();
|
||||
}, this);
|
||||
|
||||
this.viewImageUrl.subscribe(function (sUrl) {
|
||||
this.imageDom()['src'] = sUrl;
|
||||
}, this);
|
||||
|
||||
this.contactsChecked = ko.computed(function () {
|
||||
return _.filter(this.contacts(), function (oItem) {
|
||||
return oItem.checked();
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.contactsCheckedOrSelected = ko.computed(function () {
|
||||
|
||||
var
|
||||
aChecked = this.contactsChecked(),
|
||||
oSelected = this.currentContact()
|
||||
;
|
||||
|
||||
return _.union(aChecked, oSelected ? [oSelected] : []);
|
||||
|
||||
}, this);
|
||||
|
||||
this.contactsCheckedOrSelectedUids = ko.computed(function () {
|
||||
return _.map(this.contactsCheckedOrSelected(), function (oContact) {
|
||||
return oContact.idContact;
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.newCommand = Utils.createCommand(this, function () {
|
||||
this.populateViewContact(null);
|
||||
});
|
||||
|
||||
this.selector = new Selector(this.contacts, this.currentContact,
|
||||
'.e-contact-item .actionHandle', '.e-contact-item.selected', '.e-contact-item .checkboxItem');
|
||||
|
||||
this.selector.on('onItemSelect', _.bind(function (oContact) {
|
||||
this.populateViewContact(oContact ? oContact : null);
|
||||
}, this));
|
||||
|
||||
this.selector.on('onItemGetUid', function (oContact) {
|
||||
return oContact ? oContact.generateUid() : '';
|
||||
});
|
||||
|
||||
this.selector.on('onDelete', _.bind(function () {
|
||||
this.deleteCommand();
|
||||
}, this));
|
||||
|
||||
this.newCommand = Utils.createCommand(this, function () {
|
||||
this.populateViewContact(null);
|
||||
this.currentContact(null);
|
||||
});
|
||||
|
||||
this.deleteCommand = Utils.createCommand(this, function () {
|
||||
this.deleteSelectedContacts();
|
||||
}, function () {
|
||||
return 0 < this.contactsCheckedOrSelected().length;
|
||||
});
|
||||
|
||||
this.newMessageCommand = Utils.createCommand(this, function () {
|
||||
var aC = this.contactsCheckedOrSelected(), aE = [];
|
||||
if (Utils.isNonEmptyArray(aC))
|
||||
{
|
||||
aE = _.map(aC, function (oItem) {
|
||||
if (oItem && oItem['emails'])
|
||||
{
|
||||
var oEmail = new EmailModel(oItem['emails'][0] || '', oItem['name']);
|
||||
if (oEmail.validate())
|
||||
{
|
||||
return oEmail;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
aE = _.compact(aE);
|
||||
}
|
||||
|
||||
if (Utils.isNonEmptyArray(aC))
|
||||
{
|
||||
kn.hideScreenPopup(PopupsContactsViewModel);
|
||||
kn.showScreenPopup(PopupsComposeViewModel, [Enums.ComposeType.Empty, null, aE]);
|
||||
}
|
||||
|
||||
}, function () {
|
||||
return 0 < this.contactsCheckedOrSelected().length;
|
||||
});
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
this.search('');
|
||||
});
|
||||
|
||||
this.saveCommand = Utils.createCommand(this, function () {
|
||||
var
|
||||
sRequestUid = Utils.fakeMd5(),
|
||||
bImageTrigger = this.imageTrigger()
|
||||
;
|
||||
|
||||
this.viewSaving(true);
|
||||
RL.remote().contactSave(function (sResult, oData) {
|
||||
|
||||
self.viewSaving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
oData.Result.RequestUid === sRequestUid && 0 < Utils.pInt(oData.Result.ResultID))
|
||||
{
|
||||
if ('' === self.viewID())
|
||||
{
|
||||
self.viewID(Utils.pInt(oData.Result.ResultID));
|
||||
}
|
||||
|
||||
self.reloadContactList();
|
||||
if (bImageTrigger)
|
||||
{
|
||||
RL.emailsPicsHashes();
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// // TODO
|
||||
// }
|
||||
|
||||
}, sRequestUid, this.viewID(), this.viewName(), this.viewEmail(), bImageTrigger ? this.imageDom()['src'] : '');
|
||||
|
||||
}, function () {
|
||||
var
|
||||
sViewName = this.viewName(),
|
||||
sViewEmail = this.viewEmail()
|
||||
;
|
||||
|
||||
return !this.viewSaving() &&
|
||||
('' !== sViewName || '' !== sViewEmail);
|
||||
});
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsContactsViewModel', PopupsContactsViewModel);
|
||||
|
||||
PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oKoContacts = this.contacts,
|
||||
oCurrentContact = this.currentContact(),
|
||||
aContacts = this.contactsCheckedOrSelected()
|
||||
;
|
||||
|
||||
if (0 < aContacts.length)
|
||||
{
|
||||
_.each(aContacts, function (oContact) {
|
||||
|
||||
if (oCurrentContact && oCurrentContact.idContact === oContact.idContact)
|
||||
{
|
||||
oCurrentContact = null;
|
||||
self.currentContact(null);
|
||||
}
|
||||
|
||||
oContact.deleted(true);
|
||||
});
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
_.each(aContacts, function (oContact) {
|
||||
oKoContacts.remove(oContact);
|
||||
});
|
||||
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.deleteSelectedContacts = function ()
|
||||
{
|
||||
if (0 < this.contactsCheckedOrSelected().length)
|
||||
{
|
||||
RL.remote().contactsDelete(
|
||||
_.bind(this.deleteResponse, this),
|
||||
this.contactsCheckedOrSelectedUids()
|
||||
);
|
||||
|
||||
this.removeCheckedOrSelectedContactsFromList();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sResult
|
||||
* @param {AjaxJsonDefaultResponse} oData
|
||||
*/
|
||||
PopupsContactsViewModel.prototype.deleteResponse = function (sResult, oData)
|
||||
{
|
||||
if (500 < (Enums.StorageResultType.Success === sResult && oData && oData.Time ? Utils.pInt(oData.Time) : 0))
|
||||
{
|
||||
this.reloadContactList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_.delay((function (self) {
|
||||
return function () {
|
||||
self.reloadContactList();
|
||||
};
|
||||
}(this)), 500);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?ContactModel} oContact
|
||||
*/
|
||||
PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
|
||||
{
|
||||
this.imageTrigger(false);
|
||||
this.emptySelection(false);
|
||||
|
||||
if (oContact)
|
||||
{
|
||||
this.viewID(oContact.idContact);
|
||||
this.viewName(oContact.name);
|
||||
this.viewEmail(oContact.emails[0] || '');
|
||||
this.viewImageUrl(oContact.srcAttr());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.viewID('');
|
||||
this.viewName('');
|
||||
this.viewEmail('');
|
||||
this.viewImageUrl(RL.link().emptyContactPic());
|
||||
}
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.reloadContactList = function ()
|
||||
{
|
||||
var self = this;
|
||||
this.contacts.loading(true);
|
||||
RL.remote().contacts(function (sResult, oData) {
|
||||
var aList = [];
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List)
|
||||
{
|
||||
if (Utils.isNonEmptyArray(oData.Result.List))
|
||||
{
|
||||
aList = _.map(oData.Result.List, function (oItem) {
|
||||
var oContact = new ContactModel();
|
||||
return oContact.parse(oItem) ? oContact : null;
|
||||
});
|
||||
|
||||
aList = _.compact(aList);
|
||||
}
|
||||
}
|
||||
|
||||
self.contacts(aList);
|
||||
self.viewClearSearch('' !== self.search());
|
||||
self.contacts.loading(false);
|
||||
|
||||
if ('' !== self.viewID() && !self.currentContact() && self.contacts.setSelectedByUid)
|
||||
{
|
||||
self.contacts.setSelectedByUid('' + self.viewID());
|
||||
}
|
||||
|
||||
}, this.search());
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.onBuild = function (oDom)
|
||||
{
|
||||
this.initUploader();
|
||||
|
||||
this.oContentVisible = $('.b-list-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
this.selector.init(this.oContentVisible, this.oContentScrollable);
|
||||
|
||||
this.viewImageUrl.valueHasMutated();
|
||||
|
||||
ko.computed(function () {
|
||||
var
|
||||
bModalVisibility = this.modalVisibility(),
|
||||
bUseKeyboardShortcuts = RL.data().useKeyboardShortcuts()
|
||||
;
|
||||
this.selector.useKeyboard(bModalVisibility && bUseKeyboardShortcuts);
|
||||
}, this).extend({'notify': 'always'});
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.initUploader = function ()
|
||||
{
|
||||
var self = this, oJua = null;
|
||||
if (window.File && window.FileReader && this.imageUploader())
|
||||
{
|
||||
oJua = new Jua({
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'clickElement': this.imageUploader(),
|
||||
'disableDragAndDrop': true,
|
||||
'disableMultiple': true,
|
||||
'onSelect': function (sId, oData) {
|
||||
|
||||
if (oData && oData['File'] && oData['File']['type'])
|
||||
{
|
||||
var
|
||||
oReader = null,
|
||||
oFile = oData['File'],
|
||||
sType = oData['File']['type']
|
||||
;
|
||||
|
||||
if (!sType.match(/image.*/))
|
||||
{
|
||||
window.alert('this file is not an image.');
|
||||
}
|
||||
else
|
||||
{
|
||||
oReader = new window.FileReader();
|
||||
oReader.onload = function (oEvent) {
|
||||
if (oEvent && oEvent.target && oEvent.target.result)
|
||||
{
|
||||
Utils.resizeAndCrop(oEvent.target.result, 150, function (sUrl) {
|
||||
self.viewImageUrl(sUrl);
|
||||
self.imageTrigger(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
oReader.readAsDataURL(oFile);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return oJua;
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
this.reloadContactList();
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.onHide = function ()
|
||||
{
|
||||
kn.routeOn();
|
||||
this.currentContact(null);
|
||||
this.emptySelection(true);
|
||||
this.search('');
|
||||
|
||||
_.each(this.contacts(), function (oItem) {
|
||||
oItem.checked(false);
|
||||
});
|
||||
};
|
||||
205
dev/ViewModels/PopupsDomainViewModel.js
Normal file
205
dev/ViewModels/PopupsDomainViewModel.js
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsDomainViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsDomain');
|
||||
|
||||
this.edit = ko.observable(false);
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.whiteListPage = ko.observable(false);
|
||||
|
||||
this.testing = ko.observable(false);
|
||||
this.testingDone = ko.observable(false);
|
||||
this.testingImapError = ko.observable(false);
|
||||
this.testingSmtpError = ko.observable(false);
|
||||
|
||||
this.imapServerFocus = ko.observable(false);
|
||||
this.smtpServerFocus = ko.observable(false);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.imapServer = ko.observable('');
|
||||
this.imapPort = ko.observable(Consts.Values.ImapDefaulPort);
|
||||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.smtpServer = ko.observable('');
|
||||
this.smtpPort = ko.observable(Consts.Values.SmtpDefaulPort);
|
||||
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin = ko.observable(false);
|
||||
this.smtpAuth = ko.observable(true);
|
||||
this.whiteList = ko.observable('');
|
||||
|
||||
this.imapServerFocus.subscribe(function (bValue) {
|
||||
if (bValue && '' !== this.name() && '' === this.imapServer())
|
||||
{
|
||||
this.imapServer(this.name());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.smtpServerFocus.subscribe(function (bValue) {
|
||||
if (bValue && '' !== this.imapServer() && '' === this.smtpServer())
|
||||
{
|
||||
this.smtpServer(this.imapServer());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.headerText = ko.computed(function () {
|
||||
var sName = this.name();
|
||||
return this.edit() ? 'Edit Domain "' + sName + '"' :
|
||||
'Add Domain' + ('' === sName ? '' : ' "' + sName + '"');
|
||||
}, this);
|
||||
|
||||
this.domainIsComputed = ko.computed(function () {
|
||||
return '' !== this.name() &&
|
||||
'' !== this.imapServer() &&
|
||||
'' !== this.imapPort() &&
|
||||
'' !== this.smtpServer() &&
|
||||
'' !== this.smtpPort();
|
||||
}, this);
|
||||
|
||||
this.canBeTested = ko.computed(function () {
|
||||
return !this.testing() && this.domainIsComputed();
|
||||
}, this);
|
||||
|
||||
this.canBeSaved = ko.computed(function () {
|
||||
return !this.saving() && this.domainIsComputed();
|
||||
}, this);
|
||||
|
||||
this.createOrAddCommand = Utils.createCommand(this, function () {
|
||||
this.saving(true);
|
||||
RL.remote().createOrUpdateDomain(
|
||||
_.bind(this.onDomainCreateOrSaveResponse, this),
|
||||
!this.edit(),
|
||||
this.name(),
|
||||
this.imapServer(),
|
||||
this.imapPort(),
|
||||
this.imapSecure(),
|
||||
this.imapShortLogin(),
|
||||
this.smtpServer(),
|
||||
this.smtpPort(),
|
||||
this.smtpSecure(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
this.whiteList()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
this.testConnectionCommand = Utils.createCommand(this, function () {
|
||||
this.whiteListPage(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSmtpError(false);
|
||||
this.testing(true);
|
||||
RL.remote().testConnectionForDomain(
|
||||
_.bind(this.onTestConnectionResponse, this),
|
||||
this.imapServer(),
|
||||
this.imapPort(),
|
||||
this.imapSecure(),
|
||||
this.smtpServer(),
|
||||
this.smtpPort(),
|
||||
this.smtpSecure(),
|
||||
this.smtpAuth()
|
||||
);
|
||||
}, this.canBeTested);
|
||||
|
||||
this.whiteListCommand = Utils.createCommand(this, function () {
|
||||
this.whiteListPage(!this.whiteListPage());
|
||||
});
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsDomainViewModel', PopupsDomainViewModel);
|
||||
|
||||
PopupsDomainViewModel.prototype.onTestConnectionResponse = function (sResult, oData)
|
||||
{
|
||||
this.testing(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
this.testingDone(true);
|
||||
this.testingImapError(false === oData.Result.Imap);
|
||||
this.testingSmtpError(false === oData.Result.Smtp);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testingImapError(true);
|
||||
this.testingSmtpError(true);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError('Domain already exists');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError('Unknown error');
|
||||
}
|
||||
};
|
||||
|
||||
PopupsDomainViewModel.prototype.onHide = function ()
|
||||
{
|
||||
this.whiteListPage(false);
|
||||
};
|
||||
|
||||
PopupsDomainViewModel.prototype.onShow = function (oDomain)
|
||||
{
|
||||
this.saving(false);
|
||||
this.whiteListPage(false);
|
||||
|
||||
this.testing(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSmtpError(false);
|
||||
|
||||
this.clearForm();
|
||||
if (oDomain)
|
||||
{
|
||||
this.edit(true);
|
||||
|
||||
this.name(Utils.trim(oDomain.Name));
|
||||
this.imapServer(Utils.trim(oDomain.IncHost));
|
||||
this.imapPort(Utils.pInt(oDomain.IncPort));
|
||||
this.imapSecure(Utils.trim(oDomain.IncSecure));
|
||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||
this.smtpServer(Utils.trim(oDomain.OutHost));
|
||||
this.smtpPort(Utils.pInt(oDomain.OutPort));
|
||||
this.smtpSecure(Utils.trim(oDomain.OutSecure));
|
||||
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
||||
this.smtpAuth(!!oDomain.OutAuth);
|
||||
this.whiteList(Utils.trim(oDomain.WhiteList));
|
||||
}
|
||||
};
|
||||
|
||||
PopupsDomainViewModel.prototype.clearForm = function ()
|
||||
{
|
||||
this.edit(false);
|
||||
this.whiteListPage(false);
|
||||
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.imapServer('');
|
||||
this.imapPort(Consts.Values.ImapDefaulPort);
|
||||
this.imapSecure(Enums.ServerSecure.None);
|
||||
this.imapShortLogin(false);
|
||||
this.smtpServer('');
|
||||
this.smtpPort(Consts.Values.SmtpDefaulPort);
|
||||
this.smtpSecure(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin(false);
|
||||
this.smtpAuth(true);
|
||||
this.whiteList('');
|
||||
};
|
||||
95
dev/ViewModels/PopupsFolderClearViewModel.js
Normal file
95
dev/ViewModels/PopupsFolderClearViewModel.js
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderClearViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderClear');
|
||||
|
||||
this.selectedFolder = ko.observable(null);
|
||||
this.clearingProcess = ko.observable(false);
|
||||
this.clearingError = ko.observable('');
|
||||
|
||||
this.folderFullNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.printableFullName() : '';
|
||||
}, this);
|
||||
|
||||
this.folderNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.localName() : '';
|
||||
}, this);
|
||||
|
||||
this.dangerDescHtml = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', {
|
||||
'FOLDER': this.folderNameForClear()
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
oFolderToClear = this.selectedFolder()
|
||||
;
|
||||
|
||||
if (oFolderToClear)
|
||||
{
|
||||
RL.data().message(null);
|
||||
RL.data().messageList([]);
|
||||
|
||||
this.clearingProcess(true);
|
||||
|
||||
RL.cache().setFolderHash(oFolderToClear.fullNameRaw, '');
|
||||
RL.remote().folderClear(function (sResult, oData) {
|
||||
|
||||
self.clearingProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
RL.reloadMessageList(true);
|
||||
self.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
self.clearingError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
self.clearingError(Utils.getNotification(Enums.Notification.MailServerError));
|
||||
}
|
||||
}
|
||||
}, oFolderToClear.fullNameRaw);
|
||||
}
|
||||
|
||||
}, function () {
|
||||
|
||||
var
|
||||
oFolder = this.selectedFolder(),
|
||||
bIsClearing = this.clearingProcess()
|
||||
;
|
||||
|
||||
return !bIsClearing && null !== oFolder;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsFolderClearViewModel', PopupsFolderClearViewModel);
|
||||
|
||||
PopupsFolderClearViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.clearingProcess(false);
|
||||
this.selectedFolder(null);
|
||||
};
|
||||
|
||||
PopupsFolderClearViewModel.prototype.onShow = function (oFolder)
|
||||
{
|
||||
this.clearPopup();
|
||||
if (oFolder)
|
||||
{
|
||||
this.selectedFolder(oFolder);
|
||||
}
|
||||
};
|
||||
105
dev/ViewModels/PopupsFolderCreateViewModel.js
Normal file
105
dev/ViewModels/PopupsFolderCreateViewModel.js
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderCreateViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderCreate');
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sNoParentText = Utils.i18n('POPUPS_CREATE_FOLDER/SELECT_NO_PARENT');
|
||||
}, this);
|
||||
|
||||
this.folderName = ko.observable('');
|
||||
this.focusTrigger = ko.observable(false);
|
||||
|
||||
this.selectedParentValue = ko.observable(Consts.Values.UnuseOptionValue);
|
||||
|
||||
this.parentFolderSelectList = ko.computed(function () {
|
||||
|
||||
var
|
||||
oData = RL.data(),
|
||||
aTop = [],
|
||||
fDisableCallback = null,
|
||||
fVisibleCallback = null,
|
||||
aList = oData.folderList(),
|
||||
fRenameCallback = function (oItem) {
|
||||
return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '';
|
||||
}
|
||||
;
|
||||
|
||||
aTop.push(['', this.sNoParentText]);
|
||||
|
||||
if ('' !== oData.namespace)
|
||||
{
|
||||
fDisableCallback = function (oItem)
|
||||
{
|
||||
return oData.namespace !== oItem.fullNameRaw.substr(0, oData.namespace.length);
|
||||
};
|
||||
}
|
||||
|
||||
return RL.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback);
|
||||
|
||||
}, this);
|
||||
|
||||
// commands
|
||||
this.createFolder = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
oData = RL.data(),
|
||||
sParentFolderName = this.selectedParentValue()
|
||||
;
|
||||
|
||||
if ('' === sParentFolderName && 1 < oData.namespace.length)
|
||||
{
|
||||
sParentFolderName = oData.namespace.substr(0, oData.namespace.length - 1);
|
||||
}
|
||||
|
||||
oData.foldersCreating(true);
|
||||
RL.remote().folderCreate(function (sResult, oData) {
|
||||
|
||||
RL.data().foldersCreating(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
RL.folders(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RL.data().foldersListError(
|
||||
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER'));
|
||||
}
|
||||
|
||||
}, this.folderName(), sParentFolderName);
|
||||
|
||||
this.cancelCommand();
|
||||
|
||||
}, function () {
|
||||
return this.simpleFolderNameValidation(this.folderName());
|
||||
});
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsFolderCreateViewModel', PopupsFolderCreateViewModel);
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.sNoParentText = '';
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.simpleFolderNameValidation = function (sName)
|
||||
{
|
||||
return (/^[^\\\/]+$/g).test(Utils.trim(sName));
|
||||
};
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.folderName('');
|
||||
this.selectedParentValue('');
|
||||
this.focusTrigger(false);
|
||||
};
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
this.focusTrigger(true);
|
||||
};
|
||||
103
dev/ViewModels/PopupsFolderSystemViewModel.js
Normal file
103
dev/ViewModels/PopupsFolderSystemViewModel.js
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderSystemViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderSystem');
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sChooseOnText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
|
||||
this.sUnuseText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
|
||||
}, this);
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.folderSelectList = ko.computed(function () {
|
||||
return RL.folderListOptionsBuilder([], RL.data().folderList(), RL.data().folderListSystemNames(), [
|
||||
['', this.sChooseOnText],
|
||||
[Consts.Values.UnuseOptionValue, this.sUnuseText]
|
||||
]);
|
||||
}, this);
|
||||
|
||||
var
|
||||
oData = RL.data(),
|
||||
self = this,
|
||||
fSaveSystemFolders = null,
|
||||
fCallback = null
|
||||
;
|
||||
|
||||
this.sentFolder = oData.sentFolder;
|
||||
this.draftFolder = oData.draftFolder;
|
||||
this.spamFolder = oData.spamFolder;
|
||||
this.trashFolder = oData.trashFolder;
|
||||
|
||||
fSaveSystemFolders = _.debounce(function () {
|
||||
|
||||
RL.settingsSet('SentFolder', self.sentFolder());
|
||||
RL.settingsSet('DraftFolder', self.draftFolder());
|
||||
RL.settingsSet('SpamFolder', self.spamFolder());
|
||||
RL.settingsSet('TrashFolder', self.trashFolder());
|
||||
|
||||
RL.remote().saveSystemFolders(Utils.emptyFunction, {
|
||||
'SentFolder': self.sentFolder(),
|
||||
'DraftFolder': self.draftFolder(),
|
||||
'SpamFolder': self.spamFolder(),
|
||||
'TrashFolder': self.trashFolder()
|
||||
});
|
||||
|
||||
}, 1000);
|
||||
|
||||
fCallback = function () {
|
||||
|
||||
RL.settingsSet('SentFolder', self.sentFolder());
|
||||
RL.settingsSet('DraftFolder', self.draftFolder());
|
||||
RL.settingsSet('SpamFolder', self.spamFolder());
|
||||
RL.settingsSet('TrashFolder', self.trashFolder());
|
||||
|
||||
fSaveSystemFolders();
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fCallback);
|
||||
this.draftFolder.subscribe(fCallback);
|
||||
this.spamFolder.subscribe(fCallback);
|
||||
this.trashFolder.subscribe(fCallback);
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsFolderSystemViewModel', PopupsFolderSystemViewModel);
|
||||
|
||||
PopupsFolderSystemViewModel.prototype.sChooseOnText = '';
|
||||
PopupsFolderSystemViewModel.prototype.sUnuseText = '';
|
||||
|
||||
/**
|
||||
* @param {number=} iNotificationType = Enums.SetSystemFoldersNotification.None
|
||||
*/
|
||||
PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType)
|
||||
{
|
||||
var sNotification = '';
|
||||
|
||||
iNotificationType = Utils.isUnd(iNotificationType) ? Enums.SetSystemFoldersNotification.None : iNotificationType;
|
||||
|
||||
switch (iNotificationType)
|
||||
{
|
||||
case Enums.SetSystemFoldersNotification.Sent:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Draft:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Spam:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Trash:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH');
|
||||
break;
|
||||
}
|
||||
|
||||
this.notification(sNotification);
|
||||
};
|
||||
|
||||
145
dev/ViewModels/PopupsIdentityViewModel.js
Normal file
145
dev/ViewModels/PopupsIdentityViewModel.js
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsIdentityViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsIdentity');
|
||||
|
||||
this.id = '';
|
||||
this.edit = ko.observable(false);
|
||||
this.owner = ko.observable(false);
|
||||
|
||||
this.email = ko.observable('').validateEmail();
|
||||
this.email.focused = ko.observable(false);
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
this.replyTo = ko.observable('').validateSimpleEmail();
|
||||
this.replyTo.focused = ko.observable(false);
|
||||
this.bcc = ko.observable('').validateSimpleEmail();
|
||||
this.bcc.focused = ko.observable(false);
|
||||
|
||||
// this.email.subscribe(function () {
|
||||
// this.email.hasError(false);
|
||||
// }, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.addOrEditIdentityCommand = Utils.createCommand(this, function () {
|
||||
|
||||
if (!this.email.hasError())
|
||||
{
|
||||
this.email.hasError('' === Utils.trim(this.email()));
|
||||
}
|
||||
|
||||
if (this.email.hasError())
|
||||
{
|
||||
if (!this.owner())
|
||||
{
|
||||
this.email.focused(true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.replyTo.hasError())
|
||||
{
|
||||
this.replyTo.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.bcc.hasError())
|
||||
{
|
||||
this.bcc.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
RL.remote().identityUpdate(_.bind(function (sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.id, this.email(), this.name(), this.replyTo(), this.bcc());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.label = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'TITLE_UPDATE_IDENTITY': 'TITLE_ADD_IDENTITY'));
|
||||
}, this);
|
||||
|
||||
this.button = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'BUTTON_UPDATE_IDENTITY': 'BUTTON_ADD_IDENTITY'));
|
||||
}, this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsIdentityViewModel', PopupsIdentityViewModel);
|
||||
|
||||
PopupsIdentityViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.id = '';
|
||||
this.edit(false);
|
||||
this.owner(false);
|
||||
|
||||
this.name('');
|
||||
this.email('');
|
||||
this.replyTo('');
|
||||
this.bcc('');
|
||||
|
||||
this.email.hasError(false);
|
||||
this.replyTo.hasError(false);
|
||||
this.bcc.hasError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {?IdentityModel} oIdentity
|
||||
*/
|
||||
PopupsIdentityViewModel.prototype.onShow = function (oIdentity)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
if (oIdentity)
|
||||
{
|
||||
this.edit(true);
|
||||
|
||||
this.id = oIdentity.id;
|
||||
this.name(oIdentity.name());
|
||||
this.email(oIdentity.email());
|
||||
this.replyTo(oIdentity.replyTo());
|
||||
this.bcc(oIdentity.bcc());
|
||||
|
||||
this.owner(this.id === RL.data().accountEmail());
|
||||
}
|
||||
|
||||
if (!this.owner())
|
||||
{
|
||||
this.email.focused(true);
|
||||
}
|
||||
};
|
||||
45
dev/ViewModels/PopupsLanguagesViewModel.js
Normal file
45
dev/ViewModels/PopupsLanguagesViewModel.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsLanguagesViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsLanguages');
|
||||
|
||||
this.exp = ko.observable(false);
|
||||
|
||||
this.languages = ko.computed(function () {
|
||||
var sCurrent = RL.data().mainLanguage();
|
||||
return _.map(RL.data().languages(), function (sLanguage) {
|
||||
return {
|
||||
'key': sLanguage,
|
||||
'selected': sLanguage === sCurrent,
|
||||
'fullName': Utils.convertLangName(sLanguage)
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsLanguagesViewModel', PopupsLanguagesViewModel);
|
||||
|
||||
PopupsLanguagesViewModel.prototype.onShow = function ()
|
||||
{
|
||||
// var self = this;
|
||||
// _.defer(function () {
|
||||
// self.exp(true);
|
||||
// });
|
||||
this.exp(true);
|
||||
};
|
||||
|
||||
PopupsLanguagesViewModel.prototype.onHide = function ()
|
||||
{
|
||||
this.exp(false);
|
||||
};
|
||||
|
||||
PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
|
||||
{
|
||||
RL.data().mainLanguage(sLang);
|
||||
this.cancelCommand();
|
||||
};
|
||||
111
dev/ViewModels/PopupsPluginViewModel.js
Normal file
111
dev/ViewModels/PopupsPluginViewModel.js
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsPluginViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsPlugin');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.onPluginSettingsUpdateResponse = _.bind(this.onPluginSettingsUpdateResponse, this);
|
||||
|
||||
this.saveError = ko.observable('');
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.readme = ko.observable('');
|
||||
|
||||
this.configures = ko.observableArray([]);
|
||||
|
||||
this.hasReadme = ko.computed(function () {
|
||||
return '' !== this.readme();
|
||||
}, this);
|
||||
|
||||
this.hasConfiguration = ko.computed(function () {
|
||||
return 0 < this.configures().length;
|
||||
}, this);
|
||||
|
||||
this.readmePopoverConf = {
|
||||
'placement': 'top',
|
||||
'trigger': 'hover',
|
||||
'title': 'About',
|
||||
'content': function () {
|
||||
return self.readme();
|
||||
}
|
||||
};
|
||||
|
||||
this.saveCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var oList = {};
|
||||
|
||||
oList['Name'] = this.name();
|
||||
|
||||
_.each(this.configures(), function (oItem) {
|
||||
|
||||
var mValue = oItem.value();
|
||||
if (false === mValue || true === mValue)
|
||||
{
|
||||
mValue = mValue ? '1' : '0';
|
||||
}
|
||||
|
||||
oList['_' + oItem['Name']] = mValue;
|
||||
|
||||
}, this);
|
||||
|
||||
this.saveError('');
|
||||
RL.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, oList);
|
||||
|
||||
}, this.hasConfiguration);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsPluginViewModel', PopupsPluginViewModel);
|
||||
|
||||
PopupsPluginViewModel.prototype.onPluginSettingsUpdateResponse = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
this.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveError('');
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
this.saveError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveError(Utils.getNotification(Enums.Notification.CantSavePluginSettings));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PopupsPluginViewModel.prototype.onShow = function (oPlugin)
|
||||
{
|
||||
this.name();
|
||||
this.readme();
|
||||
this.configures([]);
|
||||
|
||||
if (oPlugin)
|
||||
{
|
||||
this.name(oPlugin['Name']);
|
||||
this.readme(oPlugin['Readme']);
|
||||
|
||||
var aConfig = oPlugin['Config'];
|
||||
if (Utils.isNonEmptyArray(aConfig))
|
||||
{
|
||||
this.configures(_.map(aConfig, function (aItem) {
|
||||
return {
|
||||
'value': ko.observable(aItem[0]),
|
||||
'Name': aItem[1],
|
||||
'Type': aItem[2],
|
||||
'Label': aItem[3],
|
||||
'Default': aItem[4],
|
||||
'Desc': aItem[5]
|
||||
};
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
26
dev/ViewModels/SettingsMenuViewModel.js
Normal file
26
dev/ViewModels/SettingsMenuViewModel.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function SettingsMenuViewModel(oScreen)
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu');
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('SettingsMenuViewModel', SettingsMenuViewModel);
|
||||
|
||||
SettingsMenuViewModel.prototype.link = function (sRoute)
|
||||
{
|
||||
return RL.link().settings(sRoute);
|
||||
};
|
||||
|
||||
SettingsMenuViewModel.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(RL.link().inbox());
|
||||
};
|
||||
22
dev/ViewModels/SettingsPaneViewModel.js
Normal file
22
dev/ViewModels/SettingsPaneViewModel.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function SettingsPaneViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane');
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('SettingsPaneViewModel', SettingsPaneViewModel);
|
||||
|
||||
SettingsPaneViewModel.prototype.onShow = function ()
|
||||
{
|
||||
RL.data().message(null);
|
||||
};
|
||||
|
||||
SettingsPaneViewModel.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(RL.link().inbox());
|
||||
};
|
||||
12
dev/ViewModels/SettingsSystemDropDownViewModel.js
Normal file
12
dev/ViewModels/SettingsSystemDropDownViewModel.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownViewModel
|
||||
*/
|
||||
function SettingsSystemDropDownViewModel()
|
||||
{
|
||||
AbstractSystemDropDownViewModel.call(this);
|
||||
}
|
||||
|
||||
_.extend(SettingsSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype);
|
||||
Loading…
Add table
Add a link
Reference in a new issue