/**
 * @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);
	});
}
示例#2
0
	/**
	 * @param {boolean=} admin = false
	 * @param {boolean=} logout = false
	 * @param {boolean=} close = false
	 */
	loginAndLogoutReload(admin = false, logout = false, close = false) {

		const inIframe = !!Settings.appSettingsGet('inIframe');
		let customLogoutLink = pString(Settings.appSettingsGet('customLogoutLink'));

		if (logout)
		{
			this.clearClientSideToken();
		}

		if (logout && close && window.close)
		{
			window.close();
		}

		customLogoutLink = customLogoutLink || (admin ? rootAdmin() : rootUser());

		if (logout && window.location.href !== customLogoutLink)
		{
			_.delay(() => {

				if (inIframe && window.parent)
				{
					window.parent.location.href = customLogoutLink;
				}
				else
				{
					window.location.href = customLogoutLink;
				}

				$win.trigger('rl.tooltips.diactivate');

			}, Magics.Time100ms);
		}
		else
		{
			routeOff();
			setHash(root(), true);
			routeOff();

			_.delay(() => {

				if (inIframe && window.parent)
				{
					window.parent.location.reload();
				}
				else
				{
					window.location.reload();
				}

				$win.trigger('rl.tooltips.diactivate');

			}, Magics.Time100ms);
		}
	}
示例#3
0
	populate() {
		const
			aLanguages = Settings.appSettingsGet('languages'),
			aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');

		this.languages(isArray(aLanguages) ? aLanguages : []);
		this.languagesAdmin(isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);

		this.language(Settings.settingsGet('Language'));
		this.languageAdmin(Settings.settingsGet('LanguageAdmin'));

		this.userLanguage(Settings.settingsGet('UserLanguage'));
		this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
	}
	LanguageStore.prototype.populate = function ()
	{
		var
			aLanguages = Settings.appSettingsGet('languages'),
			aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin')
		;

		this.languages(Utils.isArray(aLanguages) ? aLanguages : []);
		this.languagesAdmin(Utils.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);

		this.language(Settings.settingsGet('Language'));
		this.languageAdmin(Settings.settingsGet('LanguageAdmin'));

		this.userLanguage(Settings.settingsGet('UserLanguage'));
		this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
	};
MessageListMailBoxUserView.prototype.initUploaderForAppend = function()
{
	if (!Settings.appSettingsGet('allowAppendMessage') || !this.dragOverArea())
	{
		return false;
	}

	var
		oJua = new Jua({
			action: Links.append(),
			name: 'AppendFile',
			queueSize: 1,
			multipleSizeLimit: 1,
			hidden: {
				Folder: function() {
					return FolderStore.currentFolderFullNameRaw();
				}
			},
			dragAndDropElement: this.dragOverArea(),
			dragAndDropBodyElement: this.dragOverBodyArea()
		});

	this.dragOver.subscribe(function(bValue) {
		if (bValue)
		{
			this.selector.scrollToTop();
		}
	}, this);

	oJua
		.on('onDragEnter', _.bind(function() {
			this.dragOverEnter(true);
		}, this))
		.on('onDragLeave', _.bind(function() {
			this.dragOverEnter(false);
		}, this))
		.on('onBodyDragEnter', _.bind(function() {
			this.dragOver(true);
		}, this))
		.on('onBodyDragLeave', _.bind(function() {
			this.dragOver(false);
		}, this))
		.on('onSelect', _.bind(function(sUid, oData) {

			if (sUid && oData && 'message/rfc822' === oData.Type)
			{
				MessageStore.messageListLoading(true);
				return true;
			}

			return false;

		}, this))
		.on('onComplete', _.bind(function() {
			require('App/User').default.reloadMessageList(true, true);
		}, this));

	return !!oJua;
};
示例#6
0
	populate() {
		const themes = Settings.appSettingsGet('themes');

		this.themes(isArray(themes) ? themes : []);
		this.theme(Settings.settingsGet('Theme'));
		this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
		this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
	}
示例#7
0
	constructor() {
		this.version = ko.observable(appSettingsGet('version'));
		this.access = ko.observable(!!settingsGet('CoreAccess'));
		this.errorDesc = ko.observable('');

		this.coreReal = CoreStore.coreReal;
		this.coreChannel = CoreStore.coreChannel;
		this.coreType = CoreStore.coreType;
		this.coreUpdatable = CoreStore.coreUpdatable;
		this.coreAccess = CoreStore.coreAccess;
		this.coreChecking = CoreStore.coreChecking;
		this.coreUpdating = CoreStore.coreUpdating;
		this.coreWarning = CoreStore.coreWarning;
		this.coreVersion = CoreStore.coreVersion;
		this.coreRemoteVersion = CoreStore.coreRemoteVersion;
		this.coreRemoteRelease = CoreStore.coreRemoteRelease;
		this.coreVersionCompare = CoreStore.coreVersionCompare;

		this.community = RL_COMMUNITY || AppStore.community();

		this.coreRemoteVersionHtmlDesc = ko.computed(() => {
			translatorTrigger();
			return i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
		});

		this.statusType = ko.computed(() => {
			let type = '';
			const
				versionToCompare = this.coreVersionCompare(),
				isChecking = this.coreChecking(),
				isUpdating = this.coreUpdating(),
				isReal = this.coreReal();

			if (isChecking)
			{
				type = 'checking';
			}
			else if (isUpdating)
			{
				type = 'updating';
			}
			else if (isReal && 0 === versionToCompare)
			{
				type = 'up-to-date';
			}
			else if (isReal && -1 === versionToCompare)
			{
				type = 'available';
			}
			else if (!isReal)
			{
				type = 'error';
				this.errorDesc('Cannot access the repository at the moment.');
			}

			return type;
		});
	}
示例#8
0
	ThemeStore.prototype.populate = function ()
	{
		var aThemes = Settings.appSettingsGet('themes');

		this.themes(Utils.isArray(aThemes) ? aThemes : []);
		this.theme(Settings.settingsGet('Theme'));
		this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
		this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
	};
示例#9
0
	onShow() {
		this.setSettingsTitle();
		keyScope(KeyState.Settings);
		leftPanelType('');

		if (Settings.appSettingsGet('mobile'))
		{
			leftPanelDisabled(true);
		}
	}
示例#10
0
	PromisesUserPopulator.prototype.foldersAdditionalParameters = function (oData)
	{
		if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] &&
			oData['@Collection'] && Utils.isArray(oData['@Collection']))
		{
			if (!Utils.isUnd(oData.Namespace))
			{
				FolderStore.namespace = oData.Namespace;
			}

			AppStore.threadsAllowed(!!Settings.appSettingsGet('useImapThread') && oData.IsThreadsSupported && true);

			FolderStore.folderList.optimized(!!oData.Optimized);

			var bUpdate = false;

			if (oData['SystemFolders'] && '' === '' +
				Settings.settingsGet('SentFolder') +
				Settings.settingsGet('DraftFolder') +
				Settings.settingsGet('SpamFolder') +
				Settings.settingsGet('TrashFolder') +
				Settings.settingsGet('ArchiveFolder') +
				Settings.settingsGet('NullFolder'))
			{
				Settings.settingsSet('SentFolder', oData['SystemFolders'][Enums.ServerFolderType.SENT] || null);
				Settings.settingsSet('DraftFolder', oData['SystemFolders'][Enums.ServerFolderType.DRAFTS] || null);
				Settings.settingsSet('SpamFolder', oData['SystemFolders'][Enums.ServerFolderType.JUNK] || null);
				Settings.settingsSet('TrashFolder', oData['SystemFolders'][Enums.ServerFolderType.TRASH] || null);
				Settings.settingsSet('ArchiveFolder', oData['SystemFolders'][Enums.ServerFolderType.ALL] || null);

				bUpdate = true;
			}

			FolderStore.sentFolder(this.normalizeFolder(Settings.settingsGet('SentFolder')));
			FolderStore.draftFolder(this.normalizeFolder(Settings.settingsGet('DraftFolder')));
			FolderStore.spamFolder(this.normalizeFolder(Settings.settingsGet('SpamFolder')));
			FolderStore.trashFolder(this.normalizeFolder(Settings.settingsGet('TrashFolder')));
			FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder')));

			if (bUpdate)
			{
				require('Remote/User/Ajax').saveSystemFolders(Utils.emptyFunction, {
					'SentFolder': FolderStore.sentFolder(),
					'DraftFolder': FolderStore.draftFolder(),
					'SpamFolder': FolderStore.spamFolder(),
					'TrashFolder': FolderStore.trashFolder(),
					'ArchiveFolder': FolderStore.archiveFolder(),
					'NullFolder': 'NullFolder'
				});
			}

			Local.set(Enums.ClientSideKeyName.FoldersLashHash, oData.FoldersHash);
		}
	};
示例#11
0
/**
 * @constructor
 * @param {Object} oScreen
 */
function MenuSettingsUserView(oScreen)
{
	AbstractView.call(this, 'Left', 'SettingsMenu');

	this.leftPanelDisabled = Globals.leftPanelDisabled;

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

	this.menu = oScreen.menu;

	kn.constructorEnd(this);
}
示例#12
0
	foldersAdditionalParameters(oData) {
		if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] &&
			oData['@Collection'] && isArray(oData['@Collection']))
		{
			if (!isUnd(oData.Namespace))
			{
				FolderStore.namespace = oData.Namespace;
			}

			AppStore.threadsAllowed(!!Settings.appSettingsGet('useImapThread') && oData.IsThreadsSupported && true);

			FolderStore.folderList.optimized(!!oData.Optimized);

			let update = false;

			if (oData.SystemFolders && '' === '' +
				Settings.settingsGet('SentFolder') +
				Settings.settingsGet('DraftFolder') +
				Settings.settingsGet('SpamFolder') +
				Settings.settingsGet('TrashFolder') +
				Settings.settingsGet('ArchiveFolder') +
				Settings.settingsGet('NullFolder'))
			{
				Settings.settingsSet('SentFolder', oData.SystemFolders[ServerFolderType.SENT] || null);
				Settings.settingsSet('DraftFolder', oData.SystemFolders[ServerFolderType.DRAFTS] || null);
				Settings.settingsSet('SpamFolder', oData.SystemFolders[ServerFolderType.JUNK] || null);
				Settings.settingsSet('TrashFolder', oData.SystemFolders[ServerFolderType.TRASH] || null);
				Settings.settingsSet('ArchiveFolder', oData.SystemFolders[ServerFolderType.ALL] || null);

				update = true;
			}

			FolderStore.sentFolder(this.normalizeFolder(Settings.settingsGet('SentFolder')));
			FolderStore.draftFolder(this.normalizeFolder(Settings.settingsGet('DraftFolder')));
			FolderStore.spamFolder(this.normalizeFolder(Settings.settingsGet('SpamFolder')));
			FolderStore.trashFolder(this.normalizeFolder(Settings.settingsGet('TrashFolder')));
			FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder')));

			if (update)
			{
				Remote.saveSystemFolders(noop, {
					SentFolder: FolderStore.sentFolder(),
					DraftFolder: FolderStore.draftFolder(),
					SpamFolder: FolderStore.spamFolder(),
					TrashFolder: FolderStore.trashFolder(),
					ArchiveFolder: FolderStore.archiveFolder(),
					NullFolder: 'NullFolder'
				});
			}

			Local.set(ClientSideKeyName.FoldersLashHash, oData.FoldersHash);
		}
	}
示例#13
0
PromisesUserPopulator.prototype.foldersList = function(oData)
{
	if (oData && 'Collection/FolderCollection' === oData['@Object'] &&
		oData['@Collection'] && Utils.isArray(oData['@Collection']))
	{
		var
			iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')),
			iC = Utils.pInt(oData.CountRec);

		iLimit = 100 < iLimit ? 100 : (10 > iLimit ? 10 : iLimit);

		FolderStore.displaySpecSetting(0 >= iC || iLimit < iC);
		FolderStore.folderList(this.folderResponseParseRec(
			Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection']));
	}
};
示例#14
0
	init: function(oElement) {

		var
			Globals = require('Common/Globals'),
			Settings = require('Storage/Settings');

		if (!Globals.bDisableNanoScroll && !Settings.appSettingsGet('useNativeScrollbars'))
		{
			$(oElement)
				.addClass('nano')
				.nanoScroller({
					'iOSNativeScrolling': false,
					'preventPageScrolling': true
				});
		}
	}
示例#15
0
	foldersList(oData) {
		if (oData && 'Collection/FolderCollection' === oData['@Object'] &&
			oData['@Collection'] && isArray(oData['@Collection']))
		{
			const
				expandedFolders = Local.get(ClientSideKeyName.ExpandedFolders),
				cnt = pInt(oData.CountRec);

			let limit = pInt(Settings.appSettingsGet('folderSpecLimit'));
			limit = 100 < limit ? 100 : (10 > limit ? 10 : limit);

			FolderStore.displaySpecSetting(0 >= cnt || limit < cnt);

			FolderStore.folderList(this.folderResponseParseRec(
				isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders)); // @todo optimization required
		}
	}
示例#16
0
/**
 * @constructor
 */
function FoldersUserSettings()
{
	this.displaySpecSetting = FolderStore.displaySpecSetting;
	this.folderList = FolderStore.folderList;

	this.folderListHelp = ko.observable('').extend({'throttle': 100});

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

		var
			bLoading = FolderStore.foldersLoading(),
			bCreating = FolderStore.foldersCreating(),
			bDeleting = FolderStore.foldersDeleting(),
			bRenaming = FolderStore.foldersRenaming();

		return bLoading || bCreating || bDeleting || bRenaming;

	}, this);

	this.folderForDeletion = ko.observable(null).deleteAccessHelper();

	this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this,
		function(oPrev) {
			if (oPrev)
			{
				oPrev.edited(false);
			}
		}, function(oNext) {
			if (oNext && oNext.canBeEdited())
			{
				oNext.edited(true);
			}
		}
	]});

	this.useImapSubscribe = !!Settings.appSettingsGet('useImapSubscribe');
}
/**
 * @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.mobile = !!Settings.appSettingsGet('mobile');

	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('1' === Local.get(Enums.ClientSideKeyName.MessageHeaderFullInfo));
	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.noop, 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').default.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').default.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').default.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').default.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').default.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.DATA_IMAGE_USER_DOT_PIC);
	this.viewUserPicVisible = ko.observable(false);
	this.viewIsImportant = ko.observable(false);
	this.viewIsFlagged = ko.observable(false);

	this.viewFromDkimVisibility = ko.computed(function() {
		return 'none' !== this.viewFromDkimData()[0];
	}, this);

	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;
			// no default
		}

		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.DATA_IMAGE_USER_DOT_PIC);
					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);

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

	kn.constructorEnd(this);
}
示例#18
0
/**
 * @constructor
 */
function AboutAdminSettings()
{
	this.version = ko.observable(Settings.appSettingsGet('version'));
	this.access = ko.observable(!!Settings.settingsGet('CoreAccess'));
	this.errorDesc = ko.observable('');

	this.coreReal = CoreStore.coreReal;
	this.coreChannel = CoreStore.coreChannel;
	this.coreType = CoreStore.coreType;
	this.coreUpdatable = CoreStore.coreUpdatable;
	this.coreAccess = CoreStore.coreAccess;
	this.coreChecking = CoreStore.coreChecking;
	this.coreUpdating = CoreStore.coreUpdating;
	this.coreWarning = CoreStore.coreWarning;
	this.coreVersion = CoreStore.coreVersion;
	this.coreRemoteVersion = CoreStore.coreRemoteVersion;
	this.coreRemoteRelease = CoreStore.coreRemoteRelease;
	this.coreVersionCompare = CoreStore.coreVersionCompare;

	this.community = RL_COMMUNITY || AppStore.community();

	this.coreRemoteVersionHtmlDesc = ko.computed(function() {
		Translator.trigger();
		return Translator.i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
	}, this);

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

		var
			sType = '',
			iVersionCompare = this.coreVersionCompare(),
			bChecking = this.coreChecking(),
			bUpdating = this.coreUpdating(),
			bReal = this.coreReal();

		if (bChecking)
		{
			sType = 'checking';
		}
		else if (bUpdating)
		{
			sType = 'updating';
		}
		else if (bReal && 0 === iVersionCompare)
		{
			sType = 'up-to-date';
		}
		else if (bReal && -1 === iVersionCompare)
		{
			sType = 'available';
		}
		else if (!bReal)
		{
			sType = 'error';
			this.errorDesc('Cannot access the repository at the moment.');
		}

		return sType;

	}, this);
}
示例#19
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);
	}
示例#20
0
	/**
	 * @param {RemoteStorage|AdminRemoteStorage} Remote
	 */
	constructor(Remote)
	{
		super();

		this.googlePreviewSupportedCache = null;
		this.isLocalAutocomplete = true;
		this.iframe = null;
		this.lastErrorTime = 0;

		this.iframe = $('<iframe class="internal-hiddden" />').appendTo('body');

		$win.on('error', (event) => {
			if (event && event.originalEvent && event.originalEvent.message &&
				-1 === inArray(event.originalEvent.message, [
					'Script error.', 'Uncaught Error: Error calling method on NPObject.'
				]))
			{
				const time = timestamp();
				if (this.lastErrorTime >= time)
				{
					return;
				}

				this.lastErrorTime = time;

				Remote.jsError(
					noop,
					event.originalEvent.message,
					event.originalEvent.filename,
					event.originalEvent.lineno,
					window.location && window.location.toString ? window.location.toString() : '',
					$html.attr('class'),
					microtime() - startMicrotime
				);
			}
		});

		$win.on('resize', () => {
			Events.pub('window.resize');
		});

		Events.sub('window.resize', _.throttle(() => {
			const
				iH = $win.height(),
				iW = $win.height();

			if ($win.__sizes[0] !== iH || $win.__sizes[1] !== iW)
			{
				$win.__sizes[0] = iH;
				$win.__sizes[1] = iW;

				Events.pub('window.resize.real');
			}
		}, Magics.Time50ms));

		// DEBUG
		//		Events.sub({
		//			'window.resize': function() {
		//				window.console.log('window.resize');
		//			},
		//			'window.resize.real': function() {
		//				window.console.log('window.resize.real');
		//			}
		//		});

		$doc.on('keydown', (event) => {
			if (event && event.ctrlKey)
			{
				$html.addClass('rl-ctrl-key-pressed');
			}
		}).on('keyup', (event) => {
			if (event && !event.ctrlKey)
			{
				$html.removeClass('rl-ctrl-key-pressed');
			}
		});

		$doc.on('mousemove keypress click', _.debounce(() => {
			Events.pub('rl.auto-logout-refresh');
		}, Magics.Time5s));

		key('esc, enter', KeyState.All, () => {
			detectDropdownVisibility();
		});

		if (Settings.appSettingsGet('allowCmdInterface'))
		{
			key('ctrl+shift+`', KeyState.All, () => {
				toggleCmd();
			});
		}
	}
示例#21
0
FolderListMailBoxUserView.prototype.onBuild = function(oDom)
{
	this.oContentVisible = $('.b-content', oDom);
	this.oContentScrollable = $('.content', this.oContentVisible);

	var
		self = this,
		bMobile = Settings.appSettingsGet('mobile'),
		fSelectFolder = function(oEvent, bStarred) {

			if (bMobile)
			{
				Globals.leftPanelDisabled(true);
			}

			oEvent.preventDefault();

			if (bStarred)
			{
				oEvent.stopPropagation();
			}

			var
				oFolder = ko.dataFor(this);

			if (oFolder)
			{
				if (Enums.Layout.NoPreview === SettingsStore.layout())
				{
					MessageStore.message(null);
				}

				if (oFolder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
				{
					Cache.setFolderHash(oFolder.fullNameRaw, '');
				}

				if (bStarred)
				{
					kn.setHash(Links.mailBox(oFolder.fullNameHash, 1, 'is:flagged'));
				}
				else
				{
					kn.setHash(Links.mailBox(oFolder.fullNameHash));
				}
			}
		};

	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();
				require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);

				oFolder.collapsed(!bCollapsed);
				oEvent.preventDefault();
				oEvent.stopPropagation();
			}
		})
		.on('click', '.b-folders .e-item .e-link.selectable .inbox-star-icon', function(oEvent) {
			fSelectFolder.call(this, oEvent, !self.isInboxStarred());
		})
		.on('click', '.b-folders .e-item .e-link.selectable', function(oEvent) {
			fSelectFolder.call(this, oEvent, false);
		});

	key('up, down', Enums.KeyState.FolderList, function(event, handler) {

		var
			iIndex = -1,
			iKeyCode = handler && 'up' === handler.shortcut ? Enums.EventKeyCode.Up : Enums.EventKeyCode.Down,
			$items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom);

		if (event && $items.length)
		{
			iIndex = $items.index($items.filter('.focused'));
			if (-1 < iIndex)
			{
				$items.eq(iIndex).removeClass('focused');
			}

			if (Enums.EventKeyCode.Up === iKeyCode && 0 < iIndex)
			{
				iIndex -= 1;
			}
			else if (Enums.EventKeyCode.Down === iKeyCode && iIndex < $items.length - 1)
			{
				iIndex += 1;
			}

			$items.eq(iIndex).addClass('focused');
			self.scrollToFocused();
		}

		return false;
	});

	key('enter', Enums.KeyState.FolderList, function() {
		var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
		if ($items.length && $items[0])
		{
			AppStore.focusedState(Enums.Focused.MessageList);
			$items.click();
		}

		return false;
	});

	key('space', Enums.KeyState.FolderList, function() {
		var
			bCollapsed = true,
			oFolder = null,
			$items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);

		if ($items.length && $items[0])
		{
			oFolder = ko.dataFor($items[0]);
			if (oFolder)
			{
				bCollapsed = oFolder.collapsed();
				require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
				oFolder.collapsed(!bCollapsed);
			}
		}

		return false;
	});

	key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function() {
		AppStore.focusedState(Enums.Focused.MessageList);
		return false;
	});

	AppStore.focusedState.subscribe(function(mValue) {
		$('.b-folders .e-item .e-link.focused', oDom).removeClass('focused');
		if (Enums.Focused.FolderList === mValue)
		{
			$('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
		}
	});
};
示例#22
0
	return new Promise(function(resolve, reject) {

		var
			oH = null,
			iStart = Utils.microtime();

		iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : Consts.DEFAULT_AJAX_TIMEOUT;
		sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString);

		if (bPost)
		{
			oParameters.XToken = Settings.appSettingsGet('token');
		}

		Plugins.runHook('ajax-default-request', [sAction, oParameters, sAdditionalGetString]);

		self.setTrigger(fTrigger, true);

		oH = $.ajax({
			type: bPost ? 'POST' : 'GET',
			url: Links.ajax(sAdditionalGetString),
			async: true,
			dataType: 'json',
			data: bPost ? (oParameters || {}) : {},
			timeout: iTimeOut,
			global: true
		}).always(function(oData, sTextStatus) {

			var bCached = false, oErrorData = null, sType = Enums.StorageResultType.Error;
			if (oData && oData.Time)
			{
				bCached = Utils.pInt(oData.Time) > Utils.microtime() - iStart;
			}

			// backward capability
			switch (true)
			{
				case 'success' === sTextStatus && oData && oData.Result && sAction === oData.Action:
					sType = Enums.StorageResultType.Success;
					break;
				case 'abort' === sTextStatus && (!oData || !oData.__aborted__):
					sType = Enums.StorageResultType.Abort;
					break;
				// no default
			}

			Plugins.runHook('ajax-default-response', [sAction,
				Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oParameters]);

			if ('success' === sTextStatus)
			{
				if (oData && oData.Result && sAction === oData.Action)
				{
					oData.__cached__ = bCached;
					resolve(oData);
				}
				else if (oData && oData.Action)
				{
					oErrorData = oData;
					reject(oData.ErrorCode ? oData.ErrorCode : Enums.Notification.AjaxFalse);
				}
				else
				{
					oErrorData = oData;
					reject(Enums.Notification.AjaxParse);
				}
			}
			else if ('timeout' === sTextStatus)
			{
				oErrorData = oData;
				reject(Enums.Notification.AjaxTimeout);
			}
			else if ('abort' === sTextStatus)
			{
				if (!oData || !oData.__aborted__)
				{
					reject(Enums.Notification.AjaxAbort);
				}
			}
			else
			{
				oErrorData = oData;
				reject(Enums.Notification.AjaxParse);
			}

			if (self.oRequests[sAction])
			{
				self.oRequests[sAction] = null;
				delete self.oRequests[sAction];
			}

			self.setTrigger(fTrigger, false);

			if (oErrorData)
			{
				if (-1 < Utils.inArray(oErrorData.ErrorCode, [
					Enums.Notification.AuthError, Enums.Notification.AccessError,
					Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed,
					Enums.Notification.MailServerError,	Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
				]))
				{
					Globals.data.iAjaxErrorCount += 1;
				}

				if (Enums.Notification.InvalidToken === oErrorData.ErrorCode)
				{
					Globals.data.iTokenErrorCount += 1;
				}

				if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount)
				{
					if (Globals.data.__APP__ && Globals.data.__APP__.loginAndLogoutReload)
					{
						Globals.data.__APP__.loginAndLogoutReload(false, true);
					}
				}

				if (oErrorData.ClearAuth || oErrorData.Logout || Consts.AJAX_ERROR_LIMIT < Globals.data.iAjaxErrorCount)
				{
					if (Globals.data.__APP__ && Globals.data.__APP__.clearClientSideToken)
					{
						Globals.data.__APP__.clearClientSideToken();
					}

					if (Globals.data.__APP__ && !oErrorData.ClearAuth && Globals.data.__APP__.loginAndLogoutReload)
					{
						Globals.data.__APP__.loginAndLogoutReload(false, true);
					}
				}
			}

		});

		if (oH)
		{
			if (self.oRequests[sAction])
			{
				self.oRequests[sAction] = null;
				delete self.oRequests[sAction];
			}

			self.oRequests[sAction] = oH;
		}
	});
示例#23
0
	/**
	 * @param {?Function} fResultCallback
	 * @param {Object} oParameters
	 * @param {?number=} iTimeOut = 20000
	 * @param {string=} sGetAdd = ''
	 * @param {Array=} aAbortActions = []
	 * @returns {jQuery.jqXHR}
	 */
	ajaxRequest(fResultCallback, params, iTimeOut = 20000, sGetAdd = '', abortActions = []) {
		const
			isPost = '' === sGetAdd,
			headers = {},
			start = (new window.Date()).getTime();

		let
			action = '';

		params = params || {};
		action = params.Action || '';

		if (action && 0 < abortActions.length)
		{
			_.each(abortActions, (actionToAbort) => {
				if (this.oRequests[actionToAbort])
				{
					this.oRequests[actionToAbort].__aborted = true;
					if (this.oRequests[actionToAbort].abort)
					{
						this.oRequests[actionToAbort].abort();
					}
					this.oRequests[actionToAbort] = null;
				}
			});
		}

		if (isPost)
		{
			params.XToken = Settings.appSettingsGet('token');
		}

		const oDefAjax = $.ajax({
			type: isPost ? 'POST' : 'GET',
			url: ajax(sGetAdd),
			async: true,
			dataType: 'json',
			data: isPost ? params : {},
			headers: headers,
			timeout: iTimeOut,
			global: true
		});

		oDefAjax.always((oData, sType) => {

			let cached = false;
			if (oData && oData.Time)
			{
				cached = pInt(oData.Time) > (new window.Date()).getTime() - start;
			}

			if (action && this.oRequests[action])
			{
				if (this.oRequests[action].__aborted)
				{
					sType = 'abort';
				}

				this.oRequests[action] = null;
			}

			this.defaultResponse(fResultCallback, action, sType, oData, cached, params);
		});

		if (action && 0 < abortActions.length && -1 < inArray(action, abortActions))
		{
			if (this.oRequests[action])
			{
				this.oRequests[action].__aborted = true;
				if (this.oRequests[action].abort)
				{
					this.oRequests[action].abort();
				}
				this.oRequests[action] = null;
			}

			this.oRequests[action] = oDefAjax;
		}

		return oDefAjax;
	}
示例#24
0
/**
 * @constructor
 * @extends AbstractView
 */
function LoginAdminView()
{
	AbstractView.call(this, 'Center', 'AdminLogin');

	this.logoPowered = !!Settings.settingsGet('LoginPowered');

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

	this.login = ko.observable('');
	this.password = ko.observable('');

	this.loginError = ko.observable(false);
	this.passwordError = ko.observable(false);

	this.loginErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
	this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});

	this.loginFocus = ko.observable(false);

	this.formHidden = ko.observable(false);

	this.formError = ko.computed(function() {
		return this.loginErrorAnimation() || this.passwordErrorAnimation();
	}, this);

	this.login.subscribe(function() {
		this.loginError(false);
	}, this);

	this.password.subscribe(function() {
		this.passwordError(false);
	}, this);

	this.loginError.subscribe(function(bV) {
		this.loginErrorAnimation(!!bV);
	}, this);

	this.passwordError.subscribe(function(bV) {
		this.passwordErrorAnimation(!!bV);
	}, this);

	this.submitRequest = ko.observable(false);
	this.submitError = ko.observable('');

	this.submitCommand = Utils.createCommand(this, function() {

		Utils.triggerAutocompleteInputChange();

		this.loginError(false);
		this.passwordError(false);

		this.loginError('' === Utils.trim(this.login()));
		this.passwordError('' === Utils.trim(this.password()));

		if (this.loginError() || this.passwordError())
		{
			return false;
		}

		this.submitRequest(true);

		Remote.adminLogin(_.bind(function(sResult, oData) {

			if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
			{
				if (oData.Result)
				{
					require('App/Admin').default.loginAndLogoutReload(true);
				}
				else if (oData.ErrorCode)
				{
					this.submitRequest(false);
					this.submitError(Translator.getNotification(oData.ErrorCode));
				}
			}
			else
			{
				this.submitRequest(false);
				this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
			}

		}, this), this.login(), this.password());

		return true;

	}, function() {
		return !this.submitRequest();
	});

	kn.constructorEnd(this);
}
示例#25
0
	AbstractAjaxRemote.prototype.ajaxRequest = function (fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions)
	{
		var
			self = this,
			bPost = '' === sGetAdd,
			oHeaders = {},
			iStart = (new window.Date()).getTime(),
			oDefAjax = null,
			sAction = ''
		;

		oParameters = oParameters || {};
		iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000;
		sGetAdd = Utils.isUnd(sGetAdd) ? '' : Utils.pString(sGetAdd);
		aAbortActions = Utils.isArray(aAbortActions) ? aAbortActions : [];

		sAction = oParameters.Action || '';

		if (sAction && 0 < aAbortActions.length)
		{
			_.each(aAbortActions, function (sActionToAbort) {
				if (self.oRequests[sActionToAbort])
				{
					self.oRequests[sActionToAbort].__aborted = true;
					if (self.oRequests[sActionToAbort].abort)
					{
						self.oRequests[sActionToAbort].abort();
					}
					self.oRequests[sActionToAbort] = null;
				}
			});
		}

		if (bPost)
		{
			oParameters['XToken'] = Settings.appSettingsGet('token');
		}

		oDefAjax = $.ajax({
			'type': bPost ? 'POST' : 'GET',
			'url': Links.ajax(sGetAdd),
			'async': true,
			'dataType': 'json',
			'data': bPost ? oParameters : {},
			'headers': oHeaders,
			'timeout': iTimeOut,
			'global': true
		});

		oDefAjax.always(function (oData, sType) {

			var bCached = false;
			if (oData && oData['Time'])
			{
				bCached = Utils.pInt(oData['Time']) > (new window.Date()).getTime() - iStart;
			}

			if (sAction && self.oRequests[sAction])
			{
				if (self.oRequests[sAction].__aborted)
				{
					sType = 'abort';
				}

				self.oRequests[sAction] = null;
			}

			self.defaultResponse(fResultCallback, sAction, sType, oData, bCached, oParameters);
		});

		if (sAction && 0 < aAbortActions.length && -1 < Utils.inArray(sAction, aAbortActions))
		{
			if (this.oRequests[sAction])
			{
				this.oRequests[sAction].__aborted = true;
				if (this.oRequests[sAction].abort)
				{
					this.oRequests[sAction].abort();
				}
				this.oRequests[sAction] = null;
			}

			this.oRequests[sAction] = oDefAjax;
		}

		return oDefAjax;
	};
示例#26
0
		this.submitCommand = Utils.createCommand(this, function () {

			Utils.triggerAutocompleteInputChange();

			this.emailError(false);
			this.passwordError(false);

			this.emailError('' === Utils.trim(this.email()));
			this.passwordError('' === Utils.trim(this.password()));

			if (this.additionalCode.visibility())
			{
				this.additionalCode.error(false);
				this.additionalCode.error('' === Utils.trim(this.additionalCode()));
			}

			if (this.emailError() || this.passwordError() ||
				(this.additionalCode.visibility() && this.additionalCode.error()))
			{
				switch (true)
				{
					case this.emailError():
						this.emailFocus(true);
						break;
					case this.passwordError():
						this.passwordFocus(true);
						break;
					case this.additionalCode.visibility() && this.additionalCode.error():
						this.additionalCode.focused(true);
						break;
				}

				return false;
			}

			var
				iPluginResultCode = 0,
				sPluginResultMessage = '',
				fSubmitResult = function (iResultCode, sResultMessage) {
					iPluginResultCode = iResultCode || 0;
					sPluginResultMessage = sResultMessage || '';
				}
			;

			Plugins.runHook('user-login-submit', [fSubmitResult]);
			if (0 < iPluginResultCode)
			{
				this.submitError(Translator.getNotification(iPluginResultCode));
				return false;
			}
			else if ('' !== sPluginResultMessage)
			{
				this.submitError(sPluginResultMessage);
				return false;
			}

			this.submitRequest(true);

			var
				self = this,
				sPassword = this.password(),

				fLoginRequest = _.bind(function (sPassword) {

					Remote.login(_.bind(function (sResult, oData) {

						if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
						{
							if (oData.Result)
							{
								if (oData.TwoFactorAuth)
								{
									this.additionalCode('');
									this.additionalCode.visibility(true);
									this.submitRequest(false);

									_.delay(function(){
										self.additionalCode.focused(true);
									}, 100);
								}
								else if (oData.Admin)
								{
									require('App/User').default.redirectToAdminPanel();
								}
								else
								{
									require('App/User').default.loginAndLogoutReload(false);
								}
							}
							else if (oData.ErrorCode)
							{
								this.submitRequest(false);
								if (-1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.InvalidInputArgument]))
								{
									oData.ErrorCode = Enums.Notification.AuthError;
								}

								this.submitError(Translator.getNotificationFromResponse(oData));

								if ('' === this.submitError())
								{
									this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
								}
								else
								{
									if (oData.ErrorMessageAdditional)
									{
										this.submitErrorAddidional(oData.ErrorMessageAdditional);
									}
								}
							}
							else
							{
								this.submitRequest(false);
							}
						}
						else
						{
							this.submitRequest(false);
							this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
						}

					}, this), this.email(), '', sPassword, !!this.signMe(),
						this.bSendLanguage ? this.language() : '',
						this.additionalCode.visibility() ? this.additionalCode() : '',
						this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
					);

					Local.set(Enums.ClientSideKeyName.LastSignMe, !!this.signMe() ? '-1-' : '-0-');

				}, this)
			;

			if (Settings.appSettingsGet('rsaPublicKey') && Utils.rsaEncode.supported)
			{
				fLoginRequest(Utils.rsaEncode(sPassword, Settings.appSettingsGet('rsaPublicKey')));
			}
			else
			{
				fLoginRequest(sPassword);
			}

			return true;

		}, function () {
示例#27
0
	bootstart() {

		// log('Ps' + 'ss, hac' + 'kers! The' + 're\'s not' + 'hing inte' + 'resting :' + ')');

		Events.pub('rl.bootstart');

		const mobile = Settings.appSettingsGet('mobile');

		ko.components.register('SaveTrigger', require('Component/SaveTrigger').default);
		ko.components.register('Input', require('Component/Input').default);
		ko.components.register('Select', require('Component/Select').default);
		ko.components.register('Radio', require('Component/Radio').default);
		ko.components.register('TextArea', require('Component/TextArea').default);
		ko.components.register('Date', require('Component/Date').default);

		ko.components.register('x-script', require('Component/Script').default);
		// ko.components.register('svg-icon', require('Component/SvgIcon').default);

		if (Settings.appSettingsGet('materialDesign') && bAnimationSupported)
		{
			ko.components.register('Checkbox', require('Component/MaterialDesign/Checkbox').default);
			ko.components.register('CheckboxSimple', require('Component/Checkbox').default);
		}
		else
		{
			// ko.components.register('Checkbox', require('Component/Classic/Checkbox').default);
			// ko.components.register('CheckboxSimple', require('Component/Classic/Checkbox').default);
			ko.components.register('Checkbox', require('Component/Checkbox').default);
			ko.components.register('CheckboxSimple', require('Component/Checkbox').default);
		}

		initOnStartOrLangChange(initNotificationLanguage);

		_.delay(windowResizeCallback, Magics.Time1s);

		Events.sub('ssm.mobile-enter', () => {
			leftPanelDisabled(true);
		});

		Events.sub('ssm.mobile-leave', () => {
			leftPanelDisabled(false);
		});

		if (!mobile)
		{
			$html.addClass('rl-desktop');

			ssm.addState({
				id: 'mobile',
				query: '(max-width: 767px)',
				onEnter: () => {
					$html.addClass('ssm-state-mobile');
					Events.pub('ssm.mobile-enter');
				},
				onLeave: () => {
					$html.removeClass('ssm-state-mobile');
					Events.pub('ssm.mobile-leave');
				}
			});

			ssm.addState({
				id: 'tablet',
				query: '(min-width: 768px) and (max-width: 999px)',
				onEnter: () => {
					$html.addClass('ssm-state-tablet');
				},
				onLeave: () => {
					$html.removeClass('ssm-state-tablet');
				}
			});

			ssm.addState({
				id: 'desktop',
				query: '(min-width: 1000px) and (max-width: 1400px)',
				onEnter: () => {
					$html.addClass('ssm-state-desktop');
				},
				onLeave: () => {
					$html.removeClass('ssm-state-desktop');
				}
			});

			ssm.addState({
				id: 'desktop-large',
				query: '(min-width: 1401px)',
				onEnter: () => {
					$html.addClass('ssm-state-desktop-large');
				},
				onLeave: () => {
					$html.removeClass('ssm-state-desktop-large');
				}
			});
		}
		else
		{
			$html.addClass('ssm-state-mobile').addClass('rl-mobile');
			Events.pub('ssm.mobile-enter');
		}

		leftPanelDisabled.subscribe((bValue) => {
			$html.toggleClass('rl-left-panel-disabled', bValue);
			$html.toggleClass('rl-left-panel-enabled', !bValue);
		});

		leftPanelType.subscribe((sValue) => {
			$html.toggleClass('rl-left-panel-none', 'none' === sValue);
			$html.toggleClass('rl-left-panel-short', 'short' === sValue);
		});

		leftPanelDisabled.valueHasMutated();

		LanguageStore.populate();
		ThemeStore.populate();
		SocialStore.populate();
	}
示例#28
0
LoginUserView.prototype.onBuild = function()
{
	var
		self = this,
		sSignMeLocal = Local.get(Enums.ClientSideKeyName.LastSignMe),
		sSignMe = (Settings.settingsGet('SignMe') || 'unused').toLowerCase(),
		sJsHash = Settings.appSettingsGet('jsHash'),
		fSocial = function(iErrorCode) {
			iErrorCode = Utils.pInt(iErrorCode);
			if (0 === iErrorCode)
			{
				self.submitRequest(true);
				require('App/User').default.loginAndLogoutReload(false);
			}
			else
			{
				self.submitError(Translator.getNotification(iErrorCode));
			}
		};

	this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
	this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
	this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
		!!Settings.settingsGet('AllowGoogleSocialAuth'));
	this.googleFastLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
		!!Settings.settingsGet('AllowGoogleSocialAuthFast'));

	switch (sSignMe)
	{
		case Enums.LoginSignMeTypeAsString.DefaultOff:
		case Enums.LoginSignMeTypeAsString.DefaultOn:

			this.signMeType(Enums.LoginSignMeTypeAsString.DefaultOn === sSignMe ?
				Enums.LoginSignMeType.DefaultOn : Enums.LoginSignMeType.DefaultOff);

			switch (sSignMeLocal)
			{
				case '-1-':
					this.signMeType(Enums.LoginSignMeType.DefaultOn);
					break;
				case '-0-':
					this.signMeType(Enums.LoginSignMeType.DefaultOff);
					break;
				// no default
			}

			break;
		case Enums.LoginSignMeTypeAsString.Unused:
		default:
			this.signMeType(Enums.LoginSignMeType.Unused);
			break;
	}

	this.email(AppStore.devEmail);
	this.password(AppStore.devPassword);

	if (this.googleLoginEnabled() || this.googleFastLoginEnabled())
	{
		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() {

		LanguageStore.language.subscribe(function(sValue) {

			self.langRequest(true);

			Translator.reload(false, sValue).then(function() {
				self.langRequest(false);
				self.bSendLanguage = true;
			}, function() {
				self.langRequest(false);
			});

		});

	}, Enums.Magics.Time50ms);

	Utils.triggerAutocompleteInputChange(true);
};
示例#29
0
/**
 * @constructor
 * @extends AbstractView
 */
function LoginUserView()
{
	AbstractView.call(this, 'Center', 'Login');

	this.welcome = ko.observable(!!Settings.settingsGet('UseLoginWelcomePage'));

	this.email = ko.observable('');
	this.password = ko.observable('');
	this.signMe = ko.observable(false);

	this.additionalCode = ko.observable('');
	this.additionalCode.error = ko.observable(false);
	this.additionalCode.errorAnimation = ko.observable(false).extend({'falseTimeout': 500});
	this.additionalCode.focused = ko.observable(false);
	this.additionalCode.visibility = ko.observable(false);
	this.additionalCodeSignMe = ko.observable(false);

	this.logoImg = Utils.trim(Settings.settingsGet('LoginLogo'));
	this.logoPowered = !!Settings.settingsGet('LoginPowered');
	this.loginDescription = Utils.trim(Settings.settingsGet('LoginDescription'));

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

	this.forgotPasswordLinkUrl = Settings.appSettingsGet('forgotPasswordLinkUrl');
	this.registrationLinkUrl = Settings.appSettingsGet('registrationLinkUrl');

	this.emailError = ko.observable(false);
	this.passwordError = ko.observable(false);

	this.emailErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
	this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});

	this.formHidden = ko.observable(false);

	this.formError = ko.computed(function() {
		return this.emailErrorAnimation() || this.passwordErrorAnimation() ||
			(this.additionalCode.visibility() && this.additionalCode.errorAnimation());
	}, this);

	this.emailFocus = ko.observable(false);
	this.passwordFocus = ko.observable(false);
	this.submitFocus = ko.observable(false);

	this.email.subscribe(function() {
		this.emailError(false);
		this.additionalCode('');
		this.additionalCode.visibility(false);
	}, this);

	this.password.subscribe(function() {
		this.passwordError(false);
	}, this);

	this.additionalCode.subscribe(function() {
		this.additionalCode.error(false);
	}, this);

	this.additionalCode.visibility.subscribe(function() {
		this.additionalCode.error(false);
	}, this);

	this.emailError.subscribe(function(bV) {
		this.emailErrorAnimation(!!bV);
	}, this);

	this.passwordError.subscribe(function(bV) {
		this.passwordErrorAnimation(!!bV);
	}, this);

	this.additionalCode.error.subscribe(function(bV) {
		this.additionalCode.errorAnimation(!!bV);
	}, this);

	this.submitRequest = ko.observable(false);
	this.submitError = ko.observable('');
	this.submitErrorAddidional = ko.observable('');

	this.submitError.subscribe(function(sValue) {
		if ('' === sValue)
		{
			this.submitErrorAddidional('');
		}
	}, this);

	this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin;

	this.langRequest = ko.observable(false);
	this.language = LanguageStore.language;
	this.languages = LanguageStore.languages;

	this.bSendLanguage = false;

	this.languageFullName = ko.computed(function() {
		return Utils.convertLangName(this.language());
	}, 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() {
		Utils.triggerAutocompleteInputChange();

		this.emailError(false);
		this.passwordError(false);

		this.emailError('' === Utils.trim(this.email()));
		this.passwordError('' === Utils.trim(this.password()));

		if (this.additionalCode.visibility())
		{
			this.additionalCode.error(false);
			this.additionalCode.error('' === Utils.trim(this.additionalCode()));
		}

		if (this.emailError() || this.passwordError() ||
			(this.additionalCode.visibility() && this.additionalCode.error()))
		{
			switch (true)
			{
				case this.emailError():
					this.emailFocus(true);
					break;
				case this.passwordError():
					this.passwordFocus(true);
					break;
				case this.additionalCode.visibility() && this.additionalCode.error():
					this.additionalCode.focused(true);
					break;
				// no default
			}

			return false;
		}

		var
			iPluginResultCode = 0,
			sPluginResultMessage = '',
			fSubmitResult = function(iResultCode, sResultMessage) {
				iPluginResultCode = iResultCode || 0;
				sPluginResultMessage = sResultMessage || '';
			};

		Plugins.runHook('user-login-submit', [fSubmitResult]);
		if (0 < iPluginResultCode)
		{
			this.submitError(Translator.getNotification(iPluginResultCode));
			return false;
		}
		else if ('' !== sPluginResultMessage)
		{
			this.submitError(sPluginResultMessage);
			return false;
		}

		this.submitRequest(true);

		var
			self = this,
			sPassword = this.password(),

			fLoginRequest = _.bind(function(sLoginPassword) {

				Remote.login(_.bind(function(sResult, oData) {

					if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
					{
						if (oData.Result)
						{
							if (oData.TwoFactorAuth)
							{
								this.additionalCode('');
								this.additionalCode.visibility(true);
								this.submitRequest(false);

								_.delay(function() {
									self.additionalCode.focused(true);
								}, Enums.Magics.Time100ms);
							}
							else if (oData.Admin)
							{
								require('App/User').default.redirectToAdminPanel();
							}
							else
							{
								require('App/User').default.loginAndLogoutReload(false);
							}
						}
						else if (oData.ErrorCode)
						{
							this.submitRequest(false);
							if (-1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.InvalidInputArgument]))
							{
								oData.ErrorCode = Enums.Notification.AuthError;
							}

							this.submitError(Translator.getNotificationFromResponse(oData));

							if ('' === this.submitError())
							{
								this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
							}
							else
							{
								if (oData.ErrorMessageAdditional)
								{
									this.submitErrorAddidional(oData.ErrorMessageAdditional);
								}
							}
						}
						else
						{
							this.submitRequest(false);
						}
					}
					else
					{
						this.submitRequest(false);
						this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
					}

				}, this), this.email(), '', sLoginPassword, !!this.signMe(),
					this.bSendLanguage ? this.language() : '',
					this.additionalCode.visibility() ? this.additionalCode() : '',
					this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
				);

				Local.set(Enums.ClientSideKeyName.LastSignMe, this.signMe() ? '-1-' : '-0-');

			}, this);

		fLoginRequest(sPassword);

		return true;
	}, function() {
		return !this.submitRequest();
	});

	this.facebookLoginEnabled = ko.observable(false);

	this.facebookCommand = Utils.createCommand(this, function() {
		window.open(Links.socialFacebook(), 'Facebook',
			'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
		return true;
	}, function() {
		return !this.submitRequest() && this.facebookLoginEnabled();
	});

	this.googleLoginEnabled = ko.observable(false);
	this.googleFastLoginEnabled = ko.observable(false);

	this.googleCommand = Utils.createCommand(this, function() {
		window.open(Links.socialGoogle(), 'Google',
			'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
		return true;
	}, function() {
		return !this.submitRequest() && this.googleLoginEnabled();
	});

	this.googleFastCommand = Utils.createCommand(this, function() {
		window.open(Links.socialGoogle(true), 'Google',
			'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
		return true;
	}, function() {
		return !this.submitRequest() && this.googleFastLoginEnabled();
	});

	this.twitterLoginEnabled = ko.observable(false);

	this.twitterCommand = Utils.createCommand(this, function() {
		window.open(Links.socialTwitter(), 'Twitter',
			'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
		return true;
	}, function() {
		return !this.submitRequest() && this.twitterLoginEnabled();
	});

	this.socialLoginEnabled = ko.computed(function() {
		var
			bF = this.facebookLoginEnabled(),
			bG = this.googleLoginEnabled(),
			bT = this.twitterLoginEnabled();

		return bF || bG || bT;
	}, this);

	if (Settings.settingsGet('AdditionalLoginError') && !this.submitError())
	{
		this.submitError(Settings.settingsGet('AdditionalLoginError'));
	}

	kn.constructorEnd(this);
}