Ejemplo n.º 1
0
	/**
	 * @constructor
	 * @extends AbstractView
	 */
	function FolderListMailBoxUserView()
	{
		AbstractView.call(this, 'Left', 'MailFolderList');

		this.oContentVisible = null;
		this.oContentScrollable = null;

		this.composeInEdit = AppStore.composeInEdit;

		this.messageList = MessageStore.messageList;
		this.folderList = FolderStore.folderList;
		this.folderListSystem = FolderStore.folderListSystem;
		this.foldersChanging = FolderStore.foldersChanging;

		this.foldersListWithSingleInboxRootFolder = FolderStore.foldersListWithSingleInboxRootFolder;

		this.leftPanelDisabled = Globals.leftPanelDisabled;

		this.iDropOverTimer = 0;

		this.allowComposer = !!Settings.capa(Enums.Capa.Composer);
		this.allowContacts = !!AppStore.contactsIsAllowed();
		this.allowFolders = !!Settings.capa(Enums.Capa.Folders);

		this.folderListFocused = ko.computed(function () {
			return Enums.Focused.FolderList === AppStore.focusedState();
		});

		kn.constructorEnd(this);
	}
/**
 * @constructor
 * @extends AbstractView
 */
function AbstractSystemDropDownUserView()
{
	AbstractView.call(this, 'Right', 'SystemDropDown');

	this.logoImg = Utils.trim(Settings.settingsGet('UserLogo'));
	this.logoTitle = Utils.trim(Settings.settingsGet('UserLogoTitle'));

	this.mobile = !!Settings.appSettingsGet('mobile');
	this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');

	this.allowSettings = !!Settings.capa(Enums.Capa.Settings);
	this.allowHelp = !!Settings.capa(Enums.Capa.Help);

	this.currentAudio = AppStore.currentAudio;

	this.accountEmail = AccountStore.email;

	this.accounts = AccountStore.accounts;
	this.accountsUnreadCount = AccountStore.accountsUnreadCount;

	this.accountMenuDropdownTrigger = ko.observable(false);
	this.capaAdditionalAccounts = ko.observable(Settings.capa(Enums.Capa.AdditionalAccounts));

	this.accountClick = _.bind(this.accountClick, this);

	this.accountClick = _.bind(this.accountClick, this);

	Events.sub('audio.stop', function() {
		AppStore.currentAudio('');
	});

	Events.sub('audio.start', function(sName) {
		AppStore.currentAudio(sName);
	});
}
Ejemplo n.º 3
0
	constructor() {
		this.allowAdditionalAccount = capa(Capa.AdditionalAccounts);
		this.allowIdentities = capa(Capa.Identities);

		this.accounts = AccountStore.accounts;
		this.identities = IdentityStore.identities;

		this.accountForDeletion = ko.observable(null).deleteAccessHelper();
		this.identityForDeletion = ko.observable(null).deleteAccessHelper();
	}
Ejemplo n.º 4
0
	MessageListMailBoxUserView.prototype.advancedSearchClick = function ()
	{
		if (Settings.capa(Enums.Capa.SearchAdv))
		{
			kn.showScreenPopup(require('View/Popup/AdvancedSearch'));
		}
	};
Ejemplo n.º 5
0
	FolderListMailBoxUserView.prototype.composeClick = function ()
	{
		if (Settings.capa(Enums.Capa.Composer))
		{
			kn.showScreenPopup(require('View/Popup/Compose'));
		}
	};
Ejemplo n.º 6
0
	MessageViewMailBoxUserView.prototype.editMessage = function ()
	{
		if (Settings.capa(Enums.Capa.Composer) && MessageStore.message())
		{
			kn.showScreenPopup(require('View/Popup/Compose'), [Enums.ComposeType.Draft, MessageStore.message()]);
		}
	};
AbstractSystemDropDownUserView.prototype.settingsHelp = function()
{
	if (Settings.capa(Enums.Capa.Help))
	{
		require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
	}
};
AbstractSystemDropDownUserView.prototype.settingsClick = function()
{
	if (Settings.capa(Enums.Capa.Settings))
	{
		require('Knoin/Knoin').setHash(Links.settings());
	}
};
Ejemplo n.º 9
0
	MessageViewMailBoxUserView.prototype.replyOrforward = function (sType)
	{
		if (Settings.capa(Enums.Capa.Composer))
		{
			kn.showScreenPopup(require('View/Popup/Compose'), [sType, MessageStore.message()]);
		}
	};
Ejemplo n.º 10
0
		this.multyForwardCommand = Utils.createCommand(this, function () {
			if (Settings.capa(Enums.Capa.Composer))
			{
				kn.showScreenPopup(require('View/Popup/Compose'), [
					Enums.ComposeType.ForwardAsAttachment, MessageStore.messageListCheckedOrSelected()]);
			}
		}, this.canBeMoved);
Ejemplo n.º 11
0
	MailBoxAppScreen.prototype.onStart = function ()
	{
		var
			fResizeFunction = function () {
				Utils.windowResize();
			}
		;

		if (Settings.capa(Enums.Capa.AdditionalAccounts) || Settings.capa(Enums.Capa.AdditionalIdentities))
		{
			require('App/App').accountsAndIdentities();
		}

		_.delay(function () {
			if ('INBOX' !== Data.currentFolderFullNameRaw())
			{
				require('App/App').folderInformation('INBOX');
			}
		}, 1000);

		_.delay(function () {
			require('App/App').quota();
		}, 5000);

		_.delay(function () {
			Remote.appDelayStart(Utils.emptyFunction);
		}, 35000);

		Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === Data.layout());

		Data.folderList.subscribe(fResizeFunction);
		Data.messageList.subscribe(fResizeFunction);
		Data.message.subscribe(fResizeFunction);

		Data.layout.subscribe(function (nValue) {
			Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue);
		});

		Events.sub('mailbox.inbox-unread-count', function (nCount) {
			Data.foldersInboxUnreadCount(nCount);
		});

		Data.foldersInboxUnreadCount.subscribe(function () {
			this.setNewTitle();
		}, this);
	};
Ejemplo n.º 12
0
		this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
			if (Settings.capa(Enums.Capa.DangerousActions))
			{
				require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Trash,
					FolderStore.currentFolderFullNameRaw(),
					MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), false);
			}
		}, this.canBeMoved);
Ejemplo n.º 13
0
	MailBoxUserScreen.prototype.onShow = function ()
	{
		this.updateWindowTitle();

		AppStore.focusedState(Enums.Focused.None);
		AppStore.focusedState(Enums.Focused.MessageList);

		if (!Settings.capa(Enums.Capa.Folders))
		{
			Globals.leftPanelType(
				Settings.capa(Enums.Capa.Composer) || Settings.capa(Enums.Capa.Contacts) ? 'short' : 'none');
		}
		else
		{
			Globals.leftPanelType('');
		}
	};
Ejemplo n.º 14
0
	/**
	 * @constructor
	 */
	function AccountsUserSettings()
	{
		this.allowAdditionalAccount = Settings.capa(Enums.Capa.AdditionalAccounts);
		this.allowIdentities = true;

		this.accounts = AccountStore.accounts;
		this.identities = IdentityStore.identities;

		this.accountForDeletion = ko.observable(null).deleteAccessHelper();
		this.identityForDeletion = ko.observable(null).deleteAccessHelper();
	}
Ejemplo n.º 15
0
	MessageListMailBoxUserView.prototype.onBuild = function (oDom)
	{
		var self = this;

		this.oContentVisible = $('.b-content', oDom);
		this.oContentScrollable = $('.content', this.oContentVisible);

		this.selector.init(this.oContentVisible, this.oContentScrollable, Enums.KeyState.MessageList);

		if (this.mobile)
		{
			oDom
				.on('click', function () {
					Globals.leftPanelDisabled(true);
				})
			;
		}

		oDom
			.on('click', '.messageList .b-message-list-wrapper', function () {
				if (Enums.Focused.MessageView === AppStore.focusedState())
				{
					AppStore.focusedState(Enums.Focused.MessageList);
				}
			})
			.on('click', '.e-pagenator .e-page', function () {
				self.gotoPage(ko.dataFor(this));
			})
			.on('click', '.messageList .checkboxCkeckAll', function () {
				self.checkAll(!self.checkAll());
			})
			.on('click', '.messageList .messageListItem .flagParent', function () {
				self.flagMessages(ko.dataFor(this));
			})
			.on('click', '.messageList .messageListItem .threads-len', function () {
				self.gotoThread(ko.dataFor(this));
			})
			.on('dblclick', '.messageList .messageListItem .actionHandle', function () {
				self.gotoThread(ko.dataFor(this));
			})
		;

		this.initUploaderForAppend();
		this.initShortcuts();

		if (!Globals.bMobileDevice && ifvisible && Settings.capa(Enums.Capa.Prefetch))
		{
			ifvisible.setIdleDuration(10);

			ifvisible.idle(function () {
				self.prefetchNextTick();
			});
		}
	};
Ejemplo n.º 16
0
	/**
	 * @constructor
	 */
	function CacheUserStorage()
	{
		this.oFoldersCache = {};
		this.oFoldersNamesCache = {};
		this.oFolderHashCache = {};
		this.oFolderUidNextCache = {};
		this.oMessageListHashCache = {};
		this.oMessageFlagsCache = {};
		this.oNewMessage = {};
		this.oRequestedMessage = {};

		this.bCapaGravatar = Settings.capa(Enums.Capa.Gravatar);
	}
	/**
	 * @constructor
	 * @extends AbstractView
	 */
	function AbstractSystemDropDownUserView()
	{
		AbstractView.call(this, 'Right', 'SystemDropDown');

		this.accountEmail = AccountStore.email;

		this.accounts = AccountStore.accounts;
		this.accountsUnreadCount = AccountStore.accountsUnreadCount;

		this.accountMenuDropdownTrigger = ko.observable(false);
		this.capaAdditionalAccounts = ko.observable(Settings.capa(Enums.Capa.AdditionalAccounts));

		this.accountClick = _.bind(this.accountClick, this);
	}
	/**
	 * @constructor
	 * @extends AbstractView
	 */
	function AbstractSystemDropDownAppView()
	{
		AbstractView.call(this, 'Right', 'SystemDropDown');

		this.accounts = Data.accounts;
		this.accountEmail = Data.accountEmail;
		this.accountsLoading = Data.accountsLoading;

		this.accountMenuDropdownTrigger = ko.observable(false);

		this.capaAdditionalAccounts = Settings.capa(Enums.Capa.AdditionalAccounts);

		this.loading = ko.computed(function () {
			return this.accountsLoading();
		}, this);

		this.accountClick = _.bind(this.accountClick, this);
	}
Ejemplo n.º 19
0
ContactsPopupView.prototype.onHide = function()
{
	kn.routeOn();

	this.currentContact(null);
	this.emptySelection(true);
	this.search('');
	this.contactsCount(0);

	Utils.delegateRunOnDestroy(this.contacts());
	this.contacts([]);

	this.sLastComposeFocusedField = '';

	if (this.bBackToCompose)
	{
		this.bBackToCompose = false;

		if (Settings.capa(Enums.Capa.Composer))
		{
			kn.showScreenPopup(require('View/Popup/Compose'));
		}
	}
};
Ejemplo n.º 20
0
			.on('click', 'a', function (oEvent) {
				// setup maito protocol
				return !(!!oEvent && 3 !== oEvent['which'] && Utils.mailToHelper($(this).attr('href'),
					Settings.capa(Enums.Capa.Composer) ? require('View/Popup/Compose') : null));
			})
Ejemplo n.º 21
0
	/**
	 * @constructor
	 * @extends AbstractView
	 */
	function MessageViewMailBoxUserView()
	{
		AbstractView.call(this, 'Right', 'MailMessageView');

		var
			self = this,
			sLastEmail = '',
			createCommandHelper = function (sType) {
				return Utils.createCommand(self, function () {
					this.lastReplyAction(sType);
					this.replyOrforward(sType);
				}, self.canBeRepliedOrForwarded);
			}
		;

		this.oDom = null;
		this.oHeaderDom = null;
		this.oMessageScrollerDom = null;

		this.bodyBackgroundColor = ko.observable('');

		this.pswp = null;

		this.allowComposer = !!Settings.capa(Enums.Capa.Composer);
		this.allowMessageActions = !!Settings.capa(Enums.Capa.MessageActions);
		this.allowMessageListActions = !!Settings.capa(Enums.Capa.MessageListActions);

		this.logoImg = Utils.trim(Settings.settingsGet('UserLogoMessage'));
		this.logoIframe = Utils.trim(Settings.settingsGet('UserIframeMessage'));

		this.attachmentsActions = AppStore.attachmentsActions;

		this.message = MessageStore.message;
		this.messageListChecked = MessageStore.messageListChecked;
		this.hasCheckedMessages = MessageStore.hasCheckedMessages;
		this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails;
		this.messageLoadingThrottle = MessageStore.messageLoadingThrottle;
		this.messagesBodiesDom = MessageStore.messagesBodiesDom;
		this.useThreads = SettingsStore.useThreads;
		this.replySameFolder = SettingsStore.replySameFolder;
		this.layout = SettingsStore.layout;
		this.usePreviewPane = SettingsStore.usePreviewPane;
		this.isMessageSelected = MessageStore.isMessageSelected;
		this.messageActiveDom = MessageStore.messageActiveDom;
		this.messageError = MessageStore.messageError;

		this.fullScreenMode = MessageStore.messageFullScreenMode;

		this.messageListOfThreadsLoading = ko.observable(false).extend({'rateLimit': 1});

		this.highlightUnselectedAttachments = ko.observable(false).extend({'falseTimeout': 2000});

		this.showAttachmnetControls = ko.observable(false);

		this.allowAttachmnetControls = ko.computed(function () {
			return 0 < this.attachmentsActions().length &&
				Settings.capa(Enums.Capa.AttachmentsActions);
		}, this);

		this.downloadAsZipAllowed = ko.computed(function () {
			return -1 < Utils.inArray('zip', this.attachmentsActions()) &&
				this.allowAttachmnetControls();
		}, this);

		this.downloadAsZipLoading = ko.observable(false);
		this.downloadAsZipError = ko.observable(false).extend({'falseTimeout': 7000});

		this.saveToOwnCloudAllowed = ko.computed(function () {
			return -1 < Utils.inArray('owncloud', this.attachmentsActions()) &&
				this.allowAttachmnetControls();
		}, this);

		this.saveToOwnCloudLoading = ko.observable(false);
		this.saveToOwnCloudSuccess = ko.observable(false).extend({'falseTimeout': 2000});
		this.saveToOwnCloudError = ko.observable(false).extend({'falseTimeout': 7000});

		this.saveToOwnCloudSuccess.subscribe(function (bV) {
			if (bV)
			{
				this.saveToOwnCloudError(false);
			}
		}, this);

		this.saveToOwnCloudError.subscribe(function (bV) {
			if (bV)
			{
				this.saveToOwnCloudSuccess(false);
			}
		}, this);

		this.saveToDropboxAllowed = ko.computed(function () {
			return -1 < Utils.inArray('dropbox', this.attachmentsActions()) &&
				this.allowAttachmnetControls();
		}, this);

		this.saveToDropboxLoading = ko.observable(false);
		this.saveToDropboxSuccess = ko.observable(false).extend({'falseTimeout': 2000});
		this.saveToDropboxError = ko.observable(false).extend({'falseTimeout': 7000});

		this.saveToDropboxSuccess.subscribe(function (bV) {
			if (bV)
			{
				this.saveToDropboxError(false);
			}
		}, this);

		this.saveToDropboxError.subscribe(function (bV) {
			if (bV)
			{
				this.saveToDropboxSuccess(false);
			}
		}, this);

		this.showAttachmnetControls.subscribe(function (bV) {
			if (this.message())
			{
				_.each(this.message().attachments(), function (oItem) {
					if (oItem)
					{
						oItem.checked(!!bV);
					}
				});
			}
		}, this);

		this.lastReplyAction_ = ko.observable('');
		this.lastReplyAction = ko.computed({
			read: this.lastReplyAction_,
			write: function (sValue) {
				sValue = -1 === Utils.inArray(sValue, [
					Enums.ComposeType.Reply, Enums.ComposeType.ReplyAll, Enums.ComposeType.Forward
				]) ? Enums.ComposeType.Reply : sValue;
				this.lastReplyAction_(sValue);
			},
			owner: this
		});

		this.lastReplyAction(Local.get(Enums.ClientSideKeyName.LastReplyAction) || Enums.ComposeType.Reply);
		this.lastReplyAction_.subscribe(function (sValue) {
			Local.set(Enums.ClientSideKeyName.LastReplyAction, sValue);
		});

		this.showFullInfo = ko.observable(false);
		this.moreDropdownTrigger = ko.observable(false);
		this.messageDomFocused = ko.observable(false).extend({'rateLimit': 0});

		this.messageVisibility = ko.computed(function () {
			return !this.messageLoadingThrottle() && !!this.message();
		}, this);

		this.message.subscribe(function (oMessage) {
			if (!oMessage)
			{
				MessageStore.selectorMessageSelected(null);
			}
		}, this);

		this.canBeRepliedOrForwarded = ko.computed(function () {
			var bV = this.messageVisibility();
			return !this.isDraftFolder() && bV;
		}, this);

		// commands
		this.closeMessage = Utils.createCommand(this, function () {
			MessageStore.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.editAsNewCommand = createCommandHelper(Enums.ComposeType.EditAsNew);

		this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility);

		this.messageEditCommand = Utils.createCommand(this, function () {
			this.editMessage();
		}, this.messageVisibility);

		this.deleteCommand = Utils.createCommand(this, function () {
			var oMessage = this.message();
			if (oMessage && this.allowMessageListActions)
			{
				this.message(null);
				require('App/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
					oMessage.folderFullNameRaw, [oMessage.uid], true);
			}
		}, this.messageVisibility);

		this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
			var oMessage = this.message();
			if (oMessage && this.allowMessageListActions)
			{
				this.message(null);
				require('App/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
					oMessage.folderFullNameRaw, [oMessage.uid], false);
			}
		}, this.messageVisibility);

		this.archiveCommand = Utils.createCommand(this, function () {
			var oMessage = this.message();
			if (oMessage && this.allowMessageListActions)
			{
				this.message(null);
				require('App/User').deleteMessagesFromFolder(Enums.FolderType.Archive,
					oMessage.folderFullNameRaw, [oMessage.uid], true);
			}
		}, this.messageVisibility);

		this.spamCommand = Utils.createCommand(this, function () {
			var oMessage = this.message();
			if (oMessage && this.allowMessageListActions)
			{
				this.message(null);
				require('App/User').deleteMessagesFromFolder(Enums.FolderType.Spam,
					oMessage.folderFullNameRaw, [oMessage.uid], true);
			}
		}, this.messageVisibility);

		this.notSpamCommand = Utils.createCommand(this, function () {
			var oMessage = this.message();
			if (oMessage && this.allowMessageListActions)
			{
				this.message(null);
				require('App/User').deleteMessagesFromFolder(Enums.FolderType.NotSpam,
					oMessage.folderFullNameRaw, [oMessage.uid], true);
			}
		}, this.messageVisibility);

		this.dropboxEnabled = SocialStore.dropbox.enabled;
		this.dropboxApiKey = SocialStore.dropbox.apiKey;

		// viewer

		this.viewBodyTopValue = ko.observable(0);

		this.viewFolder = '';
		this.viewUid = '';
		this.viewHash = '';
		this.viewSubject = ko.observable('');
		this.viewFromShort = ko.observable('');
		this.viewFromDkimData = ko.observable(['none', '']);
		this.viewToShort = ko.observable('');
		this.viewFrom = ko.observable('');
		this.viewTo = ko.observable('');
		this.viewCc = ko.observable('');
		this.viewBcc = ko.observable('');
		this.viewReplyTo = ko.observable('');
		this.viewTimeStamp = ko.observable(0);
		this.viewSize = ko.observable('');
		this.viewLineAsCss = ko.observable('');
		this.viewViewLink = ko.observable('');
		this.viewDownloadLink = ko.observable('');
		this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic);
		this.viewUserPicVisible = ko.observable(false);
		this.viewIsImportant = ko.observable(false);
		this.viewIsFlagged = ko.observable(false);

		this.viewFromDkimStatusIconClass = ko.computed(function () {

			var sResult = 'icon-none iconcolor-display-none';
//			var sResult = 'icon-warning-alt iconcolor-grey';
			switch (this.viewFromDkimData()[0])
			{
				case 'none':
					break;
				case 'pass':
					sResult = 'icon-ok iconcolor-green';
//					sResult = 'icon-warning-alt iconcolor-green';
					break;
				default:
					sResult = 'icon-warning-alt iconcolor-red';
					break;
			}

			return sResult;

		}, this);

		this.viewFromDkimStatusTitle = ko.computed(function () {

			var aStatus = this.viewFromDkimData();
			if (Utils.isNonEmptyArray(aStatus))
			{
				if (aStatus[0] && aStatus[1])
				{
					return aStatus[1];
				}
				else if (aStatus[0])
				{
					return 'DKIM: ' + aStatus[0];
				}
			}

			return '';

		}, this);

		this.messageActiveDom.subscribe(function (oDom) {
			this.bodyBackgroundColor(oDom ? this.detectDomBackgroundColor(oDom): '');
		}, this);

		this.message.subscribe(function (oMessage) {

			this.messageActiveDom(null);

			if (oMessage)
			{
				this.showAttachmnetControls(false);

				if (this.viewHash !== oMessage.hash)
				{
					this.scrollMessageToTop();
				}

				this.viewFolder = oMessage.folderFullNameRaw;
				this.viewUid = oMessage.uid;
				this.viewHash = oMessage.hash;
				this.viewSubject(oMessage.subject());
				this.viewFromShort(oMessage.fromToLine(true, true));
				this.viewFromDkimData(oMessage.fromDkimData());
				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.viewReplyTo(oMessage.replyToToLine(false));
				this.viewTimeStamp(oMessage.dateTimeStampInUTC());
				this.viewSize(oMessage.friendlySize());
				this.viewLineAsCss(oMessage.lineAsCss());
				this.viewViewLink(oMessage.viewLink());
				this.viewDownloadLink(oMessage.downloadLink());
				this.viewIsImportant(oMessage.isImportant());
				this.viewIsFlagged(oMessage.flagged());

				sLastEmail = oMessage.fromAsSingleEmail();
				Cache.getUserPic(sLastEmail, function (sPic, sEmail) {
					if (sPic !== self.viewUserPic() && sLastEmail === sEmail)
					{
						self.viewUserPicVisible(false);
						self.viewUserPic(Consts.DataImages.UserDotPic);
						if ('' !== sPic)
						{
							self.viewUserPicVisible(true);
							self.viewUserPic(sPic);
						}
					}
				});
			}
			else
			{
				this.viewFolder = '';
				this.viewUid = '';
				this.viewHash = '';

				this.scrollMessageToTop();
			}

		}, this);

		this.message.viewTrigger.subscribe(function () {
			var oMessage = this.message();
			if (oMessage)
			{
				this.viewIsFlagged(oMessage.flagged());
			}
			else
			{
				this.viewIsFlagged(false);
			}
		}, this);

		this.fullScreenMode.subscribe(function (bValue) {
			Globals.$html.toggleClass('rl-message-fullscreen', bValue);
			Utils.windowResize();
		});

		this.messageLoadingThrottle.subscribe(Utils.windowResizeCallback);

		this.messageFocused = ko.computed(function () {
			return Enums.Focused.MessageView === AppStore.focusedState();
		});

		this.messageListAndMessageViewLoading = ko.computed(function () {
			return MessageStore.messageListCompleteLoadingThrottle() || MessageStore.messageLoadingThrottle();
		});

		this.goUpCommand = Utils.createCommand(this, function () {
			Events.pub('mailbox.message-list.selector.go-up', [
				Enums.Layout.NoPreview === this.layout() ? !!this.message() : true
			]);
		}, function () {
			return !this.messageListAndMessageViewLoading();
		});

		this.goDownCommand = Utils.createCommand(this, function () {
			Events.pub('mailbox.message-list.selector.go-down', [
				Enums.Layout.NoPreview === this.layout() ? !!this.message() : true
			]);
		}, function () {
			return !this.messageListAndMessageViewLoading();
		});

		Events.sub('mailbox.message-view.toggle-full-screen', function () {
			this.toggleFullScreen();
		}, this);

		kn.constructorEnd(this);
	}
Ejemplo n.º 22
0
	SettingsAppScreen.prototype.setupSettings = function (fCallback)
	{
		kn.addSettingsViewModel(require('Settings/App/General'),
			'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);

		if (Settings.settingsGet('ContactsIsAllowed'))
		{
			kn.addSettingsViewModel(require('Settings/App/Contacts'),
				'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
		}

		if (Settings.capa(Enums.Capa.AdditionalAccounts))
		{
			kn.addSettingsViewModel(require('Settings/App/Accounts'),
				'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts');
		}

		if (Settings.capa(Enums.Capa.AdditionalIdentities))
		{
			kn.addSettingsViewModel(require('Settings/App/Identities'),
				'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities');
		}
		else
		{
			kn.addSettingsViewModel(require('Settings/App/Identity'),
				'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity');
		}

		if (Settings.capa(Enums.Capa.Filters))
		{
			kn.addSettingsViewModel(require('Settings/App/Filters'),
				'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
		}

		if (Settings.capa(Enums.Capa.TwoFactor))
		{
			kn.addSettingsViewModel(require('Settings/App/Security'),
				'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
		}

		if (Settings.settingsGet('AllowGoogleSocial') ||
			Settings.settingsGet('AllowFacebookSocial') ||
			Settings.settingsGet('AllowTwitterSocial'))
		{
			kn.addSettingsViewModel(require('Settings/App/Social'),
				'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');
		}

		if (Settings.settingsGet('ChangePasswordIsAllowed'))
		{
			kn.addSettingsViewModel(require('Settings/App/ChangePassword'),
				'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
		}

		kn.addSettingsViewModel(require('Settings/App/Folders'),
			'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');

		if (Settings.capa(Enums.Capa.Themes))
		{
			kn.addSettingsViewModel(require('Settings/App/Themes'),
				'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
		}

		if (Settings.capa(Enums.Capa.OpenPGP))
		{
			kn.addSettingsViewModel(require('Settings/App/OpenPGP'),
				'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
		}

		if (fCallback)
		{
			fCallback();
		}
	};
Ejemplo n.º 23
0
		this.allowAttachmnetControls = ko.computed(function () {
			return 0 < this.attachmentsActions().length &&
				Settings.capa(Enums.Capa.AttachmentsActions);
		}, this);
Ejemplo n.º 24
0
	MessageListMailBoxAppView.prototype.onBuild = function (oDom)
	{
		var self = this;

		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())
			{
				Data.messageListThreadFolder(oMessage.folderFullNameRaw);

				aList = 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);
				}

				Data.messageListThreadUids(_.uniq(aList));

				oMessage.lastInCollapsedThreadLoading(true);
				oMessage.lastInCollapsedThread(!oMessage.lastInCollapsedThread());

				require('App/App').reloadMessageList();
			}

			return false;
		});

		this.selector.init(this.oContentVisible, this.oContentScrollable, Enums.KeyState.MessageList);

		oDom
			.on('click', '.messageList .b-message-list-wrapper', function () {
				if (self.message.focused())
				{
					self.message.focused(false);
				}
			})
			.on('click', '.e-pagenator .e-page', function () {
				var oPage = ko.dataFor(this);
				if (oPage)
				{
					kn.setHash(Links.mailBox(
						Data.currentFolderFullNameHash(),
						oPage.value,
						Data.messageListSearch()
					));
				}
			})
			.on('click', '.messageList .checkboxCkeckAll', function () {
				self.checkAll(!self.checkAll());
			})
			.on('click', '.messageList .messageListItem .flagParent', function () {
				self.flagMessages(ko.dataFor(this));
			})
		;

		this.initUploaderForAppend();
		this.initShortcuts();

		if (!Globals.bMobileDevice && ifvisible && Settings.capa(Enums.Capa.Prefetch))
		{
			ifvisible.setIdleDuration(10);

			ifvisible.idle(function () {
				self.prefetchNextTick();
			});
		}
	};
Ejemplo n.º 25
0
	MessageListMailBoxUserView.prototype.initShortcuts = function ()
	{
		var self = this;

		// disable print
		key('ctrl+p, command+p', Enums.KeyState.MessageList, function () {
			return false;
		});

		key('enter', Enums.KeyState.MessageList, function () {
			if (self.message() && self.useAutoSelect())
			{
				Events.pub('mailbox.message-view.toggle-full-screen');
				return false;
			}
		});

		if (Settings.capa(Enums.Capa.MessageListActions))
		{
			// archive (zip)
			key('z', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
				self.archiveCommand();
				return false;
			});

			// delete
			key('delete, shift+delete, shift+3', Enums.KeyState.MessageList, function (event, handler) {
				if (event)
				{
					if (0 < MessageStore.messageListCheckedOrSelected().length)
					{
						if (handler && 'shift+delete' === handler.shortcut)
						{
							self.deleteWithoutMoveCommand();
						}
						else
						{
							self.deleteCommand();
						}
					}

					return false;
				}
			});
		}

		if (Settings.capa(Enums.Capa.Reload))
		{
			// check mail
			key('ctrl+r, command+r', [Enums.KeyState.FolderList, Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
				self.reloadCommand();
				return false;
			});
		}

		// check all
		key('ctrl+a, command+a', Enums.KeyState.MessageList, function () {
			self.checkAll(!(self.checkAll() && !self.isIncompleteChecked()));
			return false;
		});

		if (Settings.capa(Enums.Capa.Composer))
		{
			// write/compose (open compose popup)
			key('w,c', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
				kn.showScreenPopup(require('View/Popup/Compose'));
				return false;
			});
		}

		if (Settings.capa(Enums.Capa.MessageListActions))
		{
			// important - star/flag messages
			key('i', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
				self.flagMessagesFast();
				return false;
			});
		}

		key('t', [Enums.KeyState.MessageList], function () {

			var oMessage = self.selectorMessageSelected();
			if (!oMessage)
			{
				oMessage = self.selectorMessageFocused();
			}

			if (oMessage && 0 < oMessage.threadsLen())
			{
				self.gotoThread(oMessage);
			}

			return false;
		});

		if (Settings.capa(Enums.Capa.MessageListActions))
		{
			// move
			key('m', Enums.KeyState.MessageList, function () {
				self.moveDropdownTrigger(true);
				return false;
			});
		}

		if (Settings.capa(Enums.Capa.MessageListActions))
		{
			// read
			key('q', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
				self.seenMessagesFast(true);
				return false;
			});

			// unread
			key('u', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
				self.seenMessagesFast(false);
				return false;
			});
		}

		if (Settings.capa(Enums.Capa.Composer))
		{
			key('shift+f', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
				self.multyForwardCommand();
				return false;
			});
		}

		if (Settings.capa(Enums.Capa.Search))
		{
			// search input focus
			key('/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
				self.inputMessageListSearchFocus(true);
				return false;
			});
		}

		// cancel search
		key('esc', Enums.KeyState.MessageList, function () {
			if ('' !== self.messageListSearchDesc())
			{
				self.cancelSearch();
				return false;
			}
			else if ('' !== self.messageListEndThreadUid())
			{
				self.cancelThreadUid();
				return false;
			}
		});

		// change focused state
		key('tab, shift+tab, left, right', Enums.KeyState.MessageList, function (event, handler) {
			if (event && handler && ('shift+tab' === handler.shortcut || 'left' === handler.shortcut))
			{
				AppStore.focusedState(Enums.Focused.FolderList);
			}
			else if (self.message())
			{
				AppStore.focusedState(Enums.Focused.MessageView);
			}

			return false;
		});

		key('ctrl+left, command+left', Enums.KeyState.MessageView, function () {
			return false;
		});

		key('ctrl+right, command+right', Enums.KeyState.MessageView, function () {
			return false;
		});
	};
Ejemplo n.º 26
0
	/**
	 * @constructor
	 * @extends AbstractView
	 */
	function MessageListMailBoxUserView()
	{
		AbstractView.call(this, 'Right', 'MailMessageList');

		this.sLastUid = null;
		this.bPrefetch = false;
		this.emptySubjectValue = '';

		this.mobile = !!Settings.appSettingsGet('mobile');

		this.allowReload = !!Settings.capa(Enums.Capa.Reload);
		this.allowSearch = !!Settings.capa(Enums.Capa.Search);
		this.allowSearchAdv = !!Settings.capa(Enums.Capa.SearchAdv);
		this.allowComposer = !!Settings.capa(Enums.Capa.Composer);
		this.allowMessageListActions = !!Settings.capa(Enums.Capa.MessageListActions);
		this.allowDangerousActions = !!Settings.capa(Enums.Capa.DangerousActions);

		this.popupVisibility = Globals.popupVisibility;

		this.message = MessageStore.message;
		this.messageList = MessageStore.messageList;
		this.messageListDisableAutoSelect = MessageStore.messageListDisableAutoSelect;

		this.folderList = FolderStore.folderList;

		this.composeInEdit = AppStore.composeInEdit;
		this.leftPanelDisabled = Globals.leftPanelDisabled;

		this.selectorMessageSelected = MessageStore.selectorMessageSelected;
		this.selectorMessageFocused = MessageStore.selectorMessageFocused;
		this.isMessageSelected = MessageStore.isMessageSelected;
		this.messageListSearch = MessageStore.messageListSearch;
		this.messageListThreadUid = MessageStore.messageListThreadUid;
		this.messageListError = MessageStore.messageListError;
		this.folderMenuForMove = FolderStore.folderMenuForMove;

		this.useCheckboxesInList = SettingsStore.useCheckboxesInList;

		this.mainMessageListSearch = MessageStore.mainMessageListSearch;
		this.messageListEndFolder = MessageStore.messageListEndFolder;
		this.messageListEndThreadUid = MessageStore.messageListEndThreadUid;

		this.messageListChecked = MessageStore.messageListChecked;
		this.messageListCheckedOrSelected = MessageStore.messageListCheckedOrSelected;
		this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails;
		this.messageListCompleteLoadingThrottle = MessageStore.messageListCompleteLoadingThrottle;
		this.messageListCompleteLoadingThrottleForAnimation = MessageStore.messageListCompleteLoadingThrottleForAnimation;

		Translator.initOnStartOrLangChange(function () {
			this.emptySubjectValue = Translator.i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT');
		}, this);

		this.userQuota = QuotaStore.quota;
		this.userUsageSize = QuotaStore.usage;
		this.userUsageProc = QuotaStore.percentage;

		this.moveDropdownTrigger = ko.observable(false);
		this.moreDropdownTrigger = ko.observable(false);

		// 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 this.mobile || Enums.Layout.SidePreview === SettingsStore.layout() ?
				'MailMessageListItem' : 'MailMessageListItemNoPreviewPane';
		}, this);

		this.messageListSearchDesc = ko.computed(function () {
			var sValue = MessageStore.messageListEndSearch();
			return '' === sValue ? '' : Translator.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue});
		});

		this.messageListPagenator = ko.computed(Utils.computedPagenatorHelper(
			MessageStore.messageListPage, MessageStore.messageListPageCount));

		this.checkAll = ko.computed({
			'read': function () {
				return 0 < MessageStore.messageListChecked().length;
			},

			'write': function (bValue) {
				bValue = !!bValue;
				_.each(MessageStore.messageList(), function (oMessage) {
					oMessage.checked(bValue);
				});
			}
		});

		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 = MessageStore.messageList().length,
				iC = MessageStore.messageListChecked().length
			;
			return 0 < iM && 0 < iC && iM > iC;
		}, this);

		this.hasMessages = ko.computed(function () {
			return 0 < this.messageList().length;
		}, this);

		this.hasCheckedOrSelectedLines = ko.computed(function () {
			return 0 < this.messageListCheckedOrSelected().length;
		}, this);

		this.isSpamFolder = ko.computed(function () {
			return FolderStore.spamFolder() === this.messageListEndFolder() &&
				'' !== FolderStore.spamFolder();
		}, this);

		this.isSpamDisabled = ko.computed(function () {
			return Consts.UNUSED_OPTION_VALUE === FolderStore.spamFolder();
		}, this);

		this.isTrashFolder = ko.computed(function () {
			return FolderStore.trashFolder() === this.messageListEndFolder() &&
				'' !== FolderStore.trashFolder();
		}, this);

		this.isDraftFolder = ko.computed(function () {
			return FolderStore.draftFolder() === this.messageListEndFolder() &&
				'' !== FolderStore.draftFolder();
		}, this);

		this.isSentFolder = ko.computed(function () {
			return FolderStore.sentFolder() === this.messageListEndFolder() &&
				'' !== FolderStore.sentFolder();
		}, this);

		this.isArchiveFolder = ko.computed(function () {
			return FolderStore.archiveFolder() === this.messageListEndFolder() &&
				'' !== FolderStore.archiveFolder();
		}, this);

		this.isArchiveDisabled = ko.computed(function () {
			return Consts.UNUSED_OPTION_VALUE === FolderStore.archiveFolder();
		}, this);

		this.isArchiveVisible = ko.computed(function () {
			return !this.isArchiveFolder() && !this.isArchiveDisabled() && !this.isDraftFolder();
		}, this);

		this.isSpamVisible = ko.computed(function () {
			return !this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder();
		}, this);

		this.isUnSpamVisible = ko.computed(function () {
			return this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder();
		}, this);

		this.messageListFocused = ko.computed(function () {
			return Enums.Focused.MessageList === AppStore.focusedState();
		});

		this.canBeMoved = this.hasCheckedOrSelectedLines;

		this.clearCommand = Utils.createCommand(this, function () {
			if (Settings.capa(Enums.Capa.DangerousActions))
			{
				kn.showScreenPopup(require('View/Popup/FolderClear'), [FolderStore.currentFolder()]);
			}
		});

		this.multyForwardCommand = Utils.createCommand(this, function () {
			if (Settings.capa(Enums.Capa.Composer))
			{
				kn.showScreenPopup(require('View/Popup/Compose'), [
					Enums.ComposeType.ForwardAsAttachment, MessageStore.messageListCheckedOrSelected()]);
			}
		}, this.canBeMoved);

		this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
			if (Settings.capa(Enums.Capa.DangerousActions))
			{
				require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Trash,
					FolderStore.currentFolderFullNameRaw(),
					MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), false);
			}
		}, this.canBeMoved);

		this.deleteCommand = Utils.createCommand(this, function () {
			require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Trash,
				FolderStore.currentFolderFullNameRaw(),
				MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
		}, this.canBeMoved);

		this.archiveCommand = Utils.createCommand(this, function () {
			require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Archive,
				FolderStore.currentFolderFullNameRaw(),
				MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
		}, this.canBeMoved);

		this.spamCommand = Utils.createCommand(this, function () {
			require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Spam,
				FolderStore.currentFolderFullNameRaw(),
				MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
		}, this.canBeMoved);

		this.notSpamCommand = Utils.createCommand(this, function () {
			require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.NotSpam,
				FolderStore.currentFolderFullNameRaw(),
				MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
		}, this.canBeMoved);

		this.moveCommand = Utils.createCommand(this, Utils.emptyFunction, this.canBeMoved);

		this.reloadCommand = Utils.createCommand(this, function () {
			if (!MessageStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload)
			{
				require('App/User').default.reloadMessageList(false, true);
			}
		});

		this.quotaTooltip = _.bind(this.quotaTooltip, this);

		this.selector = new Selector(this.messageList, this.selectorMessageSelected, this.selectorMessageFocused,
			'.messageListItem .actionHandle', '.messageListItem.selected', '.messageListItem .checkboxMessage',
				'.messageListItem.focused');

		this.selector.on('onItemSelect', _.bind(function (oMessage) {
			MessageStore.selectMessage(oMessage);
		}, this));

		this.selector.on('onItemGetUid', function (oMessage) {
			return oMessage ? oMessage.generateUid() : '';
		});

		this.selector.on('onAutoSelect', _.bind(function () {
			return this.useAutoSelect();
		}, this));

		this.selector.on('onUpUpOrDownDown', _.bind(function (bV) {
			this.goToUpUpOrDownDown(bV);
		}, this));

		Events
			.sub('mailbox.message-list.selector.go-down', function (bSelect) {
				this.selector.goDown(bSelect);
			}, this)
			.sub('mailbox.message-list.selector.go-up', function (bSelect) {
				this.selector.goUp(bSelect);
			}, this)
		;

		Events
			.sub('mailbox.message.show', function (sFolder, sUid) {

				var oMessage = _.find(this.messageList(), function (oItem) {
					return oItem && sFolder === oItem.folderFullNameRaw && sUid === oItem.uid;
				});

				if ('INBOX' === sFolder)
				{
					kn.setHash(Links.mailBox(sFolder, 1));
				}

				if (oMessage)
				{
					this.selector.selectMessageItem(oMessage);
				}
				else
				{
					if ('INBOX' !== sFolder)
					{
						kn.setHash(Links.mailBox(sFolder, 1));
					}

					MessageStore.selectMessageByFolderAndUid(sFolder, sUid);
				}

			}, this)
		;

		MessageStore.messageListEndHash.subscribe(function () {
			this.selector.scrollToTop();
		}, this);

		kn.constructorEnd(this);
	}
Ejemplo n.º 27
0
	AppUser.prototype.bootstart = function ()
	{
		AbstractApp.prototype.bootstart.call(this);

		require('Stores/User/App').populate();
		require('Stores/User/Settings').populate();
		require('Stores/User/Notification').populate();
		require('Stores/User/Account').populate();
		require('Stores/User/Contact').populate();

		var
			self = this,
			$LAB = require('$LAB'),
			sJsHash = Settings.settingsGet('JsHash'),
			sStartupUrl = Utils.pString(Settings.settingsGet('StartupUrl')),
			iContactsSyncInterval = Utils.pInt(Settings.settingsGet('ContactsSyncInterval')),
			bGoogle = Settings.settingsGet('AllowGoogleSocial'),
			bFacebook = Settings.settingsGet('AllowFacebookSocial'),
			bTwitter = Settings.settingsGet('AllowTwitterSocial')
		;

		if (progressJs)
		{
			progressJs().set(70);
		}

		Globals.leftPanelDisabled.subscribe(function (bValue) {
			Events.pub('left-panel.' + (bValue ? 'off' : 'on'));
		});

		this.setWindowTitle('');
		if (!!Settings.settingsGet('Auth'))
		{
			Globals.$html.addClass('rl-user-auth');

			if (Settings.capa(Enums.Capa.TwoFactor) &&
				Settings.capa(Enums.Capa.TwoFactorForce) &&
				Settings.settingsGet('RequireTwoFactor'))
			{

				this.bootend();
				this.bootstartTwoFactorScreen();
			}
			else
			{
				this.setWindowTitle(Translator.i18n('TITLES/LOADING'));

//require.ensure([], function() { // require code splitting

				self.foldersReload(_.bind(function (bValue) {

					this.bootend();

					if (bValue)
					{
						if ('' !== sStartupUrl)
						{
							kn.routeOff();
							kn.setHash(Links.root(sStartupUrl), true);
							kn.routeOn();
						}

						if ($LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP))
						{
							var fOpenpgpCallback = function (openpgp) {

								PgpStore.openpgp = openpgp;

								if (window.Worker)
								{
									PgpStore.openpgp.initWorker(Links.openPgpWorkerJs());
								}

//								PgpStore.openpgp.config.useWebCrypto = false;

								PgpStore.openpgpKeyring = new openpgp.Keyring();
								PgpStore.capaOpenPGP(true);

								Events.pub('openpgp.init');

								self.reloadOpenPgpKeys();
							};

							if (window.openpgp)
							{
								fOpenpgpCallback(window.openpgp);
							}
							else
							{
								$LAB.script(Links.openPgpJs()).wait(function () {
									if (window.openpgp)
									{
										fOpenpgpCallback(window.openpgp);
									}
								});
							}
						}
						else
						{
							PgpStore.capaOpenPGP(false);
						}

						kn.startScreens([
							require('Screen/User/MailBox'),
							Settings.capa(Enums.Capa.Settings) ? require('Screen/User/Settings') : null,
							false ? require('Screen/User/About') : null
						]);

						if (bGoogle || bFacebook || bTwitter)
						{
							self.socialUsers(true);
						}

						Events.sub('interval.2m', function () {
							self.folderInformation(Cache.getFolderInboxName());
						});

						Events.sub('interval.3m', function () {
							var sF = FolderStore.currentFolderFullNameRaw();
							if (Cache.getFolderInboxName() !== sF)
							{
								self.folderInformation(sF);
							}
						});

						Events.sub('interval.2m-after5m', function () {
							self.folderInformationMultiply();
						});

						Events.sub('interval.15m', function () {
							self.quota();
						});

						Events.sub('interval.20m', function () {
							self.foldersReload();
						});

						iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20;
						iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320;

						_.delay(function () {
							self.contactsSync();
						}, 10000);

						_.delay(function () {
							self.folderInformationMultiply(true);
						}, 2000);

						window.setInterval(function () {
							self.contactsSync();
						}, iContactsSyncInterval * 60000 + 5000);

						self.accountsAndIdentities(true);

						_.delay(function () {
							var sF = FolderStore.currentFolderFullNameRaw();
							if (Cache.getFolderInboxName() !== sF)
							{
								self.folderInformation(sF);
							}
						}, 1000);

						_.delay(function () {
							self.quota();
						}, 5000);

						_.delay(function () {
							Remote.appDelayStart(Utils.emptyFunction);
						}, 35000);

						Events.sub('rl.auto-logout', function () {
							self.logout();
						});

						Plugins.runHook('rl-start-user-screens');
						Events.pub('rl.bootstart-user-screens');

						if (Settings.settingsGet('WelcomePageUrl'))
						{
							_.delay(function () {
								self.bootstartWelcomePopup(Settings.settingsGet('WelcomePageUrl'));
							}, 1000);
						}

						if (!!Settings.settingsGet('AccountSignMe') &&
							window.navigator.registerProtocolHandler &&
							Settings.capa(Enums.Capa.Composer))
						{
							_.delay(function () {
								try {
									window.navigator.registerProtocolHandler('mailto',
										window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
										'' + (Settings.settingsGet('Title') || 'RainLoop'));
								} catch(e) {}

								if (Settings.settingsGet('MailToEmail'))
								{
									Utils.mailToHelper(Settings.settingsGet('MailToEmail'), require('View/Popup/Compose'));
								}
							}, 500);
						}

						if (!Globals.bMobileDevice)
						{
							_.defer(function () {
								self.initVerticalLayoutResizer(Enums.ClientSideKeyName.FolderListSize);
							});

							if (Tinycon && Settings.settingsGet('FaviconStatus') && !Settings.settingsGet('Filtered') )
							{
								Tinycon.setOptions({
									fallback: false
								});

								Events.sub('mailbox.inbox-unread-count', function (iCount) {
									Tinycon.setBubble(0 < iCount ? (99 < iCount ? 99 : iCount) : 0);
								});
							}
						}
					}
					else
					{
						this.logout();
					}

				}, self));

//}); // require code splitting

			}
		}
		else
		{
			this.bootend();
			this.bootstartLoginScreen();
		}

		if (bGoogle)
		{
			window['rl_' + sJsHash + '_google_service'] = function () {
				SocialStore.google.loading(true);
				self.socialUsers();
			};
		}

		if (bFacebook)
		{
			window['rl_' + sJsHash + '_facebook_service'] = function () {
				SocialStore.facebook.loading(true);
				self.socialUsers();
			};
		}

		if (bTwitter)
		{
			window['rl_' + sJsHash + '_twitter_service'] = function () {
				SocialStore.twitter.loading(true);
				self.socialUsers();
			};
		}

		Events.sub('interval.1m', function () {
			Momentor.reload();
		});

		Plugins.runHook('rl-start-screens');
		Events.pub('rl.bootstart-end');
	};
Ejemplo n.º 28
0
				self.foldersReload(_.bind(function (bValue) {

					this.bootend();

					if (bValue)
					{
						if ('' !== sStartupUrl)
						{
							kn.routeOff();
							kn.setHash(Links.root(sStartupUrl), true);
							kn.routeOn();
						}

						if ($LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP))
						{
							var fOpenpgpCallback = function (openpgp) {

								PgpStore.openpgp = openpgp;

								if (window.Worker)
								{
									PgpStore.openpgp.initWorker(Links.openPgpWorkerJs());
								}

//								PgpStore.openpgp.config.useWebCrypto = false;

								PgpStore.openpgpKeyring = new openpgp.Keyring();
								PgpStore.capaOpenPGP(true);

								Events.pub('openpgp.init');

								self.reloadOpenPgpKeys();
							};

							if (window.openpgp)
							{
								fOpenpgpCallback(window.openpgp);
							}
							else
							{
								$LAB.script(Links.openPgpJs()).wait(function () {
									if (window.openpgp)
									{
										fOpenpgpCallback(window.openpgp);
									}
								});
							}
						}
						else
						{
							PgpStore.capaOpenPGP(false);
						}

						kn.startScreens([
							require('Screen/User/MailBox'),
							Settings.capa(Enums.Capa.Settings) ? require('Screen/User/Settings') : null,
							false ? require('Screen/User/About') : null
						]);

						if (bGoogle || bFacebook || bTwitter)
						{
							self.socialUsers(true);
						}

						Events.sub('interval.2m', function () {
							self.folderInformation(Cache.getFolderInboxName());
						});

						Events.sub('interval.3m', function () {
							var sF = FolderStore.currentFolderFullNameRaw();
							if (Cache.getFolderInboxName() !== sF)
							{
								self.folderInformation(sF);
							}
						});

						Events.sub('interval.2m-after5m', function () {
							self.folderInformationMultiply();
						});

						Events.sub('interval.15m', function () {
							self.quota();
						});

						Events.sub('interval.20m', function () {
							self.foldersReload();
						});

						iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20;
						iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320;

						_.delay(function () {
							self.contactsSync();
						}, 10000);

						_.delay(function () {
							self.folderInformationMultiply(true);
						}, 2000);

						window.setInterval(function () {
							self.contactsSync();
						}, iContactsSyncInterval * 60000 + 5000);

						self.accountsAndIdentities(true);

						_.delay(function () {
							var sF = FolderStore.currentFolderFullNameRaw();
							if (Cache.getFolderInboxName() !== sF)
							{
								self.folderInformation(sF);
							}
						}, 1000);

						_.delay(function () {
							self.quota();
						}, 5000);

						_.delay(function () {
							Remote.appDelayStart(Utils.emptyFunction);
						}, 35000);

						Events.sub('rl.auto-logout', function () {
							self.logout();
						});

						Plugins.runHook('rl-start-user-screens');
						Events.pub('rl.bootstart-user-screens');

						if (Settings.settingsGet('WelcomePageUrl'))
						{
							_.delay(function () {
								self.bootstartWelcomePopup(Settings.settingsGet('WelcomePageUrl'));
							}, 1000);
						}

						if (!!Settings.settingsGet('AccountSignMe') &&
							window.navigator.registerProtocolHandler &&
							Settings.capa(Enums.Capa.Composer))
						{
							_.delay(function () {
								try {
									window.navigator.registerProtocolHandler('mailto',
										window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
										'' + (Settings.settingsGet('Title') || 'RainLoop'));
								} catch(e) {}

								if (Settings.settingsGet('MailToEmail'))
								{
									Utils.mailToHelper(Settings.settingsGet('MailToEmail'), require('View/Popup/Compose'));
								}
							}, 500);
						}

						if (!Globals.bMobileDevice)
						{
							_.defer(function () {
								self.initVerticalLayoutResizer(Enums.ClientSideKeyName.FolderListSize);
							});

							if (Tinycon && Settings.settingsGet('FaviconStatus') && !Settings.settingsGet('Filtered') )
							{
								Tinycon.setOptions({
									fallback: false
								});

								Events.sub('mailbox.inbox-unread-count', function (iCount) {
									Tinycon.setBubble(0 < iCount ? (99 < iCount ? 99 : iCount) : 0);
								});
							}
						}
					}
					else
					{
						this.logout();
					}

				}, self));
Ejemplo n.º 29
0
	/**
	 * @constructor
	 */
	function SecurityUserSettings()
	{
		this.capaAutoLogout = Settings.capa(Enums.Capa.AutoLogout);
		this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor);

		this.autoLogout = SettinsStore.autoLogout;
		this.autoLogout.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.autoLogoutOptions = ko.computed(function () {
			Translator.trigger();
			return [
				{'id': 0, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')},
				{'id': 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 5})},
				{'id': 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 10})},
				{'id': 30, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 30})},
				{'id': 60, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 60})}
			];
		});

		this.processing = ko.observable(false);
		this.clearing = ko.observable(false);
		this.secreting = ko.observable(false);

		this.viewUser = ko.observable('');
		this.twoFactorStatus = ko.observable(false);

		this.twoFactorTested = ko.observable(false);

		this.viewSecret = ko.observable('');
		this.viewBackupCodes = ko.observable('');
		this.viewUrl = ko.observable('');

		this.viewEnable_ = ko.observable(false);

		this.viewEnable = ko.computed({
			'owner': this,
			'read': this.viewEnable_,
			'write': function (bValue) {

				var self = this;

				bValue = !!bValue;

				if (bValue && this.twoFactorTested())
				{
					this.viewEnable_(bValue);

					Remote.enableTwoFactor(function (sResult, oData) {
						if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
						{
							self.viewEnable_(false);
						}

					}, true);
				}
				else
				{
					if (!bValue)
					{
						this.viewEnable_(bValue);
					}

					Remote.enableTwoFactor(function (sResult, oData) {
						if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
						{
							self.viewEnable_(false);
						}

					}, false);
				}
			}
		});

		this.viewTwoFactorEnableTooltip = ko.computed(function () {
			Translator.trigger();
			return this.twoFactorTested() || this.viewEnable_() ? '' :
				Translator.i18n('SETTINGS_SECURITY/TWO_FACTOR_SECRET_TEST_BEFORE_DESC');
		}, this);

		this.viewTwoFactorStatus = ko.computed(function () {
			Translator.trigger();
			return Translator.i18n(
				this.twoFactorStatus() ?
					'SETTINGS_SECURITY/TWO_FACTOR_SECRET_CONFIGURED_DESC' :
					'SETTINGS_SECURITY/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC'
			);
		}, this);

		this.twoFactorAllowedEnable = ko.computed(function () {
			return this.viewEnable() || this.twoFactorTested();
		}, this);

		this.onResult = _.bind(this.onResult, this);
		this.onShowSecretResult = _.bind(this.onShowSecretResult, this);
	}
Ejemplo n.º 30
0
		this.clearCommand = Utils.createCommand(this, function () {
			if (Settings.capa(Enums.Capa.DangerousActions))
			{
				kn.showScreenPopup(require('View/Popup/FolderClear'), [FolderStore.currentFolder()]);
			}
		});