/**
	 * @constructor
	 *
	 * @param {Object} oParams
	 *
	 * @extends AbstractComponent
	 */
	function AbstracCheckbox(oParams)
	{
		AbstractComponent.call(this);

		this.value = oParams.value;
		if (Utils.isUnd(this.value) || !this.value.subscribe)
		{
			this.value = ko.observable(Utils.isUnd(this.value) ? false : !!this.value);
		}

		this.enable = oParams.enable;
		if (Utils.isUnd(this.enable) || !this.enable.subscribe)
		{
			this.enable = ko.observable(Utils.isUnd(this.enable) ? true : !!this.enable);
		}

		this.disable = oParams.disable;
		if (Utils.isUnd(this.disable) || !this.disable.subscribe)
		{
			this.disable = ko.observable(Utils.isUnd(this.disable) ? false : !!this.disable);
		}

		this.label = oParams.label || '';
		this.inline = Utils.isUnd(oParams.inline) ? false : oParams.inline;

		this.readOnly = Utils.isUnd(oParams.readOnly) ? false : !!oParams.readOnly;
		this.inverted = Utils.isUnd(oParams.inverted) ? false : !!oParams.inverted;

		this.labeled = !Utils.isUnd(oParams.label);
		this.labelAnimated = !!oParams.labelAnimated;
	}
	/**
	 * @constructor
	 *
	 * @param {Object} oParams
	 *
	 * @extends AbstractComponent
	 */
	function AbstracRadio(oParams)
	{
		AbstractComponent.call(this);

		this.values = ko.observableArray([]);

		this.value = oParams.value;
		if (Utils.isUnd(this.value) || !this.value.subscribe)
		{
			this.value = ko.observable('');
		}

		this.inline = Utils.isUnd(oParams.inline) ? false : oParams.inline;
		this.readOnly = Utils.isUnd(oParams.readOnly) ? false : !!oParams.readOnly;

		if (oParams.values)
		{
			var aValues = _.map(oParams.values, function (sLabel, sValue) {
				return {
					'label': sLabel,
					'value': sValue
				};
			});

			this.values(aValues);
		}

		this.click = _.bind(this.click, this);
	}
Example #3
0
	/**
	 * @param {Object} params = {}
	 */
	constructor(params = {}) {

		super();

		this.value = params.value;
		if (isUnd(this.value) || !this.value.subscribe)
		{
			this.value = ko.observable(isUnd(this.value) ? false : !!this.value);
		}

		this.enable = params.enable;
		if (isUnd(this.enable) || !this.enable.subscribe)
		{
			this.enable = ko.observable(isUnd(this.enable) ? true : !!this.enable);
		}

		this.disable = params.disable;
		if (isUnd(this.disable) || !this.disable.subscribe)
		{
			this.disable = ko.observable(isUnd(this.disable) ? false : !!this.disable);
		}

		this.label = params.label || '';
		this.inline = isUnd(params.inline) ? false : params.inline;

		this.readOnly = isUnd(params.readOnly) ? false : !!params.readOnly;
		this.inverted = isUnd(params.inverted) ? false : !!params.inverted;

		this.labeled = !isUnd(params.label);
		this.labelAnimated = !!params.labelAnimated;
	}
	/**
	 * @constructor
	 * @param {string} sId
	 * @param {string} sFileName
	 * @param {?number=} nSize
	 * @param {boolean=} bInline
	 * @param {boolean=} bLinked
	 * @param {string=} sCID
	 * @param {string=} sContentLocation
	 */
	function ComposeAttachmentModel(sId, sFileName, nSize, bInline, bLinked, sCID, sContentLocation)
	{
		AbstractModel.call(this, 'ComposeAttachmentModel');

		this.id = sId;
		this.isInline = Utils.isUnd(bInline) ? false : !!bInline;
		this.isLinked = Utils.isUnd(bLinked) ? false : !!bLinked;
		this.CID = Utils.isUnd(sCID) ? '' : sCID;
		this.contentLocation = Utils.isUnd(sContentLocation) ? '' : sContentLocation;
		this.fromMessage = false;

		this.fileName = ko.observable(sFileName);
		this.size = ko.observable(Utils.isUnd(nSize) ? null : nSize);
		this.tempName = ko.observable('');

		this.progress = ko.observable('');
		this.error = ko.observable('');
		this.waiting = ko.observable(true);
		this.uploading = ko.observable(false);
		this.enabled = ko.observable(true);

		this.friendlySize = ko.computed(function () {
			var mSize = this.size();
			return null === mSize ? '' : Utils.friendlySize(this.size());
		}, this);

		this.regDisposables([this.friendlySize]);
	}
ContactsPopupView.prototype.onShow = function(bBackToCompose, sLastComposeFocusedField)
{
	this.bBackToCompose = Utils.isUnd(bBackToCompose) ? false : !!bBackToCompose;
	this.sLastComposeFocusedField = Utils.isUnd(sLastComposeFocusedField) ? '' : sLastComposeFocusedField;

	kn.routeOff();
	this.reloadContactList(true);
};
	AbstractApp.prototype.loginAndLogoutReload = function (bAdmin, bLogout, bClose)
	{
		var
			kn = require('Knoin/Knoin'),
			sCustomLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')),
			bInIframe = !!Settings.settingsGet('InIframe')
		;

		bLogout = Utils.isUnd(bLogout) ? false : !!bLogout;
		bClose = Utils.isUnd(bClose) ? false : !!bClose;

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

		if (bLogout && bClose && window.close)
		{
			window.close();
		}

		sCustomLogoutLink = sCustomLogoutLink || (bAdmin ? Links.rootAdmin() : Links.rootUser());

		if (bLogout && window.location.href !== sCustomLogoutLink)
		{
			_.delay(function () {
				if (bInIframe && window.parent)
				{
					window.parent.location.href = sCustomLogoutLink;
				}
				else
				{
					window.location.href = sCustomLogoutLink;
				}
			}, 100);
		}
		else
		{
			kn.routeOff();
			kn.setHash(Links.root(), true);
			kn.routeOff();

			_.delay(function () {
				if (bInIframe && window.parent)
				{
					window.parent.location.reload();
				}
				else
				{
					window.location.reload();
				}
			}, 100);
		}
	};
Example #7
0
	AppUser.prototype.reloadMessageList = function (bDropPagePosition, bDropCurrenFolderCache)
	{
		var
			iOffset = (MessageStore.messageListPage() - 1) * SettingsStore.messagesPerPage()
		;

		if (Utils.isUnd(bDropCurrenFolderCache) ? false : !!bDropCurrenFolderCache)
		{
			Cache.setFolderHash(FolderStore.currentFolderFullNameRaw(), '');
		}

		if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition)
		{
			MessageStore.messageListPage(1);
			MessageStore.messageListPageBeforeThread(1);
			iOffset = 0;

			kn.setHash(Links.mailBox(
				FolderStore.currentFolderFullNameHash(),
				MessageStore.messageListPage(),
				MessageStore.messageListSearch(),
				MessageStore.messageListThreadUid()
			), true, true);
		}

		MessageStore.messageListLoading(true);
		Remote.messageList(function (sResult, oData, bCached) {

			if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
			{
				MessageStore.messageListError('');
				MessageStore.messageListLoading(false);

				MessageStore.setMessageList(oData, bCached);
			}
			else if (Enums.StorageResultType.Unload === sResult)
			{
				MessageStore.messageListError('');
				MessageStore.messageListLoading(false);
			}
			else if (Enums.StorageResultType.Abort !== sResult)
			{
				MessageStore.messageList([]);
				MessageStore.messageListLoading(false);
				MessageStore.messageListError(oData && oData.ErrorCode ?
					Translator.getNotification(oData.ErrorCode) : Translator.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST')
				);
			}

		}, FolderStore.currentFolderFullNameRaw(), iOffset, SettingsStore.messagesPerPage(),
			MessageStore.messageListSearch(), MessageStore.messageListThreadUid());
	};
	ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment)
	{
		var bResult = false;
		if (oJsonAttachment)
		{
			this.fileName(oJsonAttachment.Name);
			this.size(Utils.isUnd(oJsonAttachment.Size) ? 0 : Utils.pInt(oJsonAttachment.Size));
			this.tempName(Utils.isUnd(oJsonAttachment.TempName) ? '' : oJsonAttachment.TempName);
			this.isInline = false;

			bResult = true;
		}

		return bResult;
	};
	MessageModel.prototype.replyAllEmails = function (oExcludeEmails, bLast)
	{
		var
			aData = [],
			aToResult = [],
			aCcResult = [],
			oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails
		;

		MessageHelper.replyHelper(this.replyTo, oUnic, aToResult);
		if (0 === aToResult.length)
		{
			MessageHelper.replyHelper(this.from, oUnic, aToResult);
		}

		MessageHelper.replyHelper(this.to, oUnic, aToResult);
		MessageHelper.replyHelper(this.cc, oUnic, aCcResult);

		if (0 === aToResult.length && !bLast)
		{
			aData = this.replyAllEmails({}, true);
			return [aData[0], aCcResult];
		}

		return [aToResult, aCcResult];
	};
Example #10
0
	MailBoxUserScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPreview)
	{
		if (Utils.isUnd(bPreview) ? false : !!bPreview)
		{
			if (Enums.Layout.NoPreview === Data.layout() && !Data.message())
			{
				require('App/User').historyBack();
			}
		}
		else
		{
			var
				sFolderFullNameRaw = Cache.getFolderFullNameRaw(sFolderHash),
				oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw)
			;

			if (oFolder)
			{
				Data
					.currentFolder(oFolder)
					.messageListPage(iPage)
					.messageListSearch(sSearch)
				;

				if (Enums.Layout.NoPreview === Data.layout() && Data.message())
				{
					Data.message(null);
				}

				require('App/User').reloadMessageList();
			}
		}
	};
Example #11
0
AbstractAjaxPromises.prototype.getRequest = function(sAction, fTrigger, sAdditionalGetString, iTimeOut)
{
	sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString);
	sAdditionalGetString = sAction + '/' + sAdditionalGetString;

	return this.ajaxRequest(sAction, false, iTimeOut, null, sAdditionalGetString, fTrigger);
};
	FolderSystemPopupView.prototype.onShow = function (iNotificationType)
	{
		var sNotification = '';

		iNotificationType = Utils.isUnd(iNotificationType) ? Enums.SetSystemFoldersNotification.None : iNotificationType;

		switch (iNotificationType)
		{
			case Enums.SetSystemFoldersNotification.Sent:
				sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT');
				break;
			case Enums.SetSystemFoldersNotification.Draft:
				sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS');
				break;
			case Enums.SetSystemFoldersNotification.Spam:
				sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM');
				break;
			case Enums.SetSystemFoldersNotification.Trash:
				sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH');
				break;
			case Enums.SetSystemFoldersNotification.Archive:
				sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE');
				break;
		}

		this.notification(sNotification);
	};
Example #13
0
					.on('onStart', _.bind(function (sId) {

						var
							oItem = null
						;

						if (Utils.isUnd(oUploadCache[sId]))
						{
							oItem = this.getAttachmentById(sId);
							if (oItem)
							{
								oUploadCache[sId] = oItem;
							}
						}
						else
						{
							oItem = oUploadCache[sId];
						}

						if (oItem)
						{
							oItem.waiting(false);
							oItem.uploading(true);
						}

					}, this))
Example #14
0
	MessageListMailBoxUserView.prototype.flagMessagesFast = function (bFlag)
	{
		var
			aChecked = this.messageListCheckedOrSelected(),
			aFlagged = []
		;

		if (0 < aChecked.length)
		{
			aFlagged = _.filter(aChecked, function (oMessage) {
				return oMessage.flagged();
			});

			if (Utils.isUnd(bFlag))
			{
				this.setAction(aChecked[0].folderFullNameRaw, true,
					aChecked.length === aFlagged.length ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
			}
			else
			{
				this.setAction(aChecked[0].folderFullNameRaw, true,
					!bFlag ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
			}
		}
	};
Example #15
0
	/**
	 * @constructor
	 *
	 * @param {Object} oParams
	 *
	 * @extends AbstractInput
	 */
	function TextAreaComponent(oParams) {

		AbstractInput.call(this, oParams);

		this.rows = oParams.rows || 5;
		this.spellcheck = Utils.isUnd(oParams.spellcheck) ? false : !!oParams.spellcheck;
	};
Example #16
0
	MessageListMailBoxUserView.prototype.seenMessagesFast = function (bSeen)
	{
		var
			aChecked = this.messageListCheckedOrSelected(),
			aUnseen = []
		;

		if (0 < aChecked.length)
		{
			aUnseen = _.filter(aChecked, function (oMessage) {
				return oMessage.unseen();
			});

			if (Utils.isUnd(bSeen))
			{
				this.setAction(aChecked[0].folderFullNameRaw, true,
					0 < aUnseen.length ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked);
			}
			else
			{
				this.setAction(aChecked[0].folderFullNameRaw, true,
					bSeen ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked);
			}
		}
	};
Example #17
0
	AppUser.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForMove, sToFolderFullNameRaw, bCopy)
	{
		if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForMove) && 0 < aUidForMove.length)
		{
			var
				oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw),
				oToFolder = Cache.getFolderFromCacheList(sToFolderFullNameRaw)
			;

			if (oFromFolder && oToFolder)
			{
				if (Utils.isUnd(bCopy) ? false : !!bCopy)
				{
					this.messagesCopyHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove);
				}
				else
				{
					this.messagesMoveHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove);
				}

				MessageStore.removeMessagesFromList(oFromFolder.fullNameRaw, aUidForMove, oToFolder.fullNameRaw, bCopy);
				return true;
			}
		}

		return false;
	};
Example #18
0
	ContactsPopupView.prototype.reloadContactList = function (bDropPagePosition)
	{
		var
			self = this,
			iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage
		;

		this.bDropPageAfterDelete = false;

		if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition)
		{
			this.contactsPage(1);
			iOffset = 0;
		}

		this.contacts.loading(true);
		Remote.contacts(function (sResult, oData) {
			var
				iCount = 0,
				aList = [],
				aTagsList = []
			;

			if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List)
			{
				if (Utils.isNonEmptyArray(oData.Result.List))
				{
					aList = _.map(oData.Result.List, function (oItem) {
						var oContact = new ContactModel();
						return oContact.parse(oItem) ? oContact : null;
					});

					aList = _.compact(aList);

					iCount = Utils.pInt(oData.Result.Count);
					iCount = 0 < iCount ? iCount : 0;
				}

				if (Utils.isNonEmptyArray(oData.Result.Tags))
				{
					aTagsList = _.map(oData.Result.Tags, function (oItem) {
						var oContactTag = new ContactTagModel();
						return oContactTag.parse(oItem) ? oContactTag : null;
					});

					aTagsList = _.compact(aTagsList);
				}
			}

			self.contactsCount(iCount);

			self.contacts(aList);
			self.contacts.loading(false);
			self.contactTags(aTagsList);

			self.viewClearSearch('' !== self.search());

		}, iOffset, Consts.Defaults.ContactsPerPage, this.search());
	};
Example #19
0
	RemoteUserAjax.prototype.messageList = function (fCallback, sFolderFullNameRaw, iOffset, iLimit, sSearch, sThreadUid, bSilent)
	{
		sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw);

		var
			sFolderHash = Cache.getFolderHash(sFolderFullNameRaw),
			bUseThreads = AppStore.threadsAllowed() && SettingsStore.useThreads(),
			sInboxUidNext = Cache.getFolderInboxName() === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : ''
		;

		bSilent = Utils.isUnd(bSilent) ? false : !!bSilent;
		iOffset = Utils.isUnd(iOffset) ? 0 : Utils.pInt(iOffset);
		iLimit = Utils.isUnd(iOffset) ? 20 : Utils.pInt(iLimit);
		sSearch = Utils.pString(sSearch);
		sThreadUid = Utils.pString(sThreadUid);

		if ('' !== sFolderHash && ('' === sSearch || -1 === sSearch.indexOf('is:')))
		{
			return this.defaultRequest(fCallback, 'MessageList', {},
				'' === sSearch ? Consts.DEFAULT_AJAX_TIMEOUT : Consts.SEARCH_AJAX_TIMEOUT,
				'MessageList/' + Links.subQueryPrefix() + '/' + Base64.urlsafe_encode([
					sFolderFullNameRaw,
					iOffset,
					iLimit,
					sSearch,
					AppStore.projectHash(),
					sFolderHash,
					sInboxUidNext,
					bUseThreads ? '1' : '0',
					bUseThreads ? sThreadUid : ''
				].join(String.fromCharCode(0))), bSilent ? [] : ['MessageList']);
		}
		else
		{
			return this.defaultRequest(fCallback, 'MessageList', {
				'Folder': sFolderFullNameRaw,
				'Offset': iOffset,
				'Limit': iLimit,
				'Search': sSearch,
				'UidNext': sInboxUidNext,
				'UseThreads': bUseThreads ? '1' : '0',
				'ThreadUid': bUseThreads ? sThreadUid : ''
			}, '' === sSearch ? Consts.DEFAULT_AJAX_TIMEOUT : Consts.SEARCH_AJAX_TIMEOUT,
				'', bSilent ? [] : ['MessageList']);
		}
	};
	AbstractRemoteStorage.prototype.jsInfo = function (fCallback, sType, mData, bIsError)
	{
		this.defaultRequest(fCallback, 'JsInfo', {
			'Type': sType,
			'Data': mData,
			'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0'
		});
	};
Example #21
0
					aList = _.compact(_.map(oData.Result.List, function (oItem) {
						if (oItem)
						{
							oItem['loading'] = ko.observable(!Utils.isUnd(aLoading[oItem['file']]));
							return 'core' === oItem['type'] && !oItem['canBeInstalled'] ? null : oItem;
						}
						return null;
					}));
Example #22
0
	AppUser.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFolderFullNameRaw, aUidForRemove, bUseFolder)
	{
		var
			self = this,
			oMoveFolder = null,
			nSetSystemFoldersNotification = null
		;

		switch (iDeleteType)
		{
			case Enums.FolderType.Spam:
				oMoveFolder = Cache.getFolderFromCacheList(FolderStore.spamFolder());
				nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Spam;
				break;
			case Enums.FolderType.NotSpam:
				oMoveFolder = Cache.getFolderFromCacheList(Cache.getFolderInboxName());
				break;
			case Enums.FolderType.Trash:
				oMoveFolder = Cache.getFolderFromCacheList(FolderStore.trashFolder());
				nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Trash;
				break;
			case Enums.FolderType.Archive:
				oMoveFolder = Cache.getFolderFromCacheList(FolderStore.archiveFolder());
				nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Archive;
				break;
		}

		bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder;
		if (bUseFolder)
		{
			if ((Enums.FolderType.Spam === iDeleteType && Consts.Values.UnuseOptionValue === FolderStore.spamFolder()) ||
				(Enums.FolderType.Trash === iDeleteType && Consts.Values.UnuseOptionValue === FolderStore.trashFolder()) ||
				(Enums.FolderType.Archive === iDeleteType && Consts.Values.UnuseOptionValue === FolderStore.archiveFolder()))
			{
				bUseFolder = false;
			}
		}

		if (!oMoveFolder && bUseFolder)
		{
			kn.showScreenPopup(require('View/Popup/FolderSystem'), [nSetSystemFoldersNotification]);
		}
		else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType &&
			(sFromFolderFullNameRaw === FolderStore.spamFolder() || sFromFolderFullNameRaw === FolderStore.trashFolder())))
		{
			kn.showScreenPopup(require('View/Popup/Ask'), [Translator.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () {

				self.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove);
				MessageStore.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove);

			}]);
		}
		else if (oMoveFolder)
		{
			this.messagesMoveHelper(sFromFolderFullNameRaw, oMoveFolder.fullNameRaw, aUidForRemove);
			MessageStore.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, oMoveFolder.fullNameRaw);
		}
	};
Example #23
0
	/**
	 * @constructor
	 *
	 * @param {string} sEmail
	 * @param {boolean=} bCanBeDelete = true
	 */
	function AccountModel(sEmail, bCanBeDelete)
	{
		AbstractModel.call(this, 'AccountModel');

		this.email = sEmail;

		this.deleteAccess = ko.observable(false);
		this.canBeDalete = ko.observable(Utils.isUnd(bCanBeDelete) ? true : !!bCanBeDelete);
	}
		this.addOptionClass = function (oDomOption, oItem) {

			self.defautOptionsAfterRender(oDomOption, oItem);

			if (oItem && !Utils.isUnd(oItem['class']) && oDomOption)
			{
				$(oDomOption).addClass(oItem['class']);
			}
		};
Example #25
0
	PromisesUserPopulator.prototype.foldersList = function (oData)
	{
		if (oData && 'Collection/FolderCollection' === oData['@Object'] &&
			oData['@Collection'] && Utils.isArray(oData['@Collection']))
		{
			FolderStore.folderList(this.folderResponseParseRec(
				Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection']));
		}
	};
	/**
	 * @constructor
	 *
	 * @param {Object} oParams
	 *
	 * @extends AbstractComponent
	 */
	function AbstractInput(oParams)
	{
		AbstractComponent.call(this);

		this.value = oParams.value || '';
		this.size = oParams.size || 0;
		this.label = oParams.label || '';
		this.enable = Utils.isUnd(oParams.enable) ? true : oParams.enable;
		this.trigger = oParams.trigger && oParams.trigger.subscribe ? oParams.trigger : null;
		this.placeholder = oParams.placeholder || '';

		this.labeled = !Utils.isUnd(oParams.label);
		this.triggered = !Utils.isUnd(oParams.trigger) && !!this.trigger;

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

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

			var
				iSize = ko.unwrap(this.size),
				sSuffixValue = this.trigger ?
					' ' + Utils.trim('settings-saved-trigger-input ' + this.classForTrigger()) : ''
			;

			return (0 < iSize ? 'span' + iSize : '') + sSuffixValue;

		}, this);

		if (!Utils.isUnd(oParams.width) && oParams.element)
		{
			oParams.element.find('input,select,textarea').css('width', oParams.width);
		}

		this.disposable.push(this.className);

		if (this.trigger)
		{
			this.setTriggerState(this.trigger());

			this.disposable.push(
				this.trigger.subscribe(this.setTriggerState, this)
			);
		}
	}
Example #27
0
	DataAppStorage.prototype.getNextFolderNames = function (bBoot)
	{
		bBoot = Utils.isUnd(bBoot) ? false : !!bBoot;

		var
			aResult = [],
			iLimit = 10,
			iUtc = moment().unix(),
			iTimeout = iUtc - 60 * 5,
			aTimeouts = [],
			fSearchFunction = function (aList) {
				_.each(aList, function (oFolder) {
					if (oFolder && 'INBOX' !== oFolder.fullNameRaw &&
						oFolder.selectable && oFolder.existen &&
						iTimeout > oFolder.interval &&
						(!bBoot || oFolder.subScribed()))
					{
						aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]);
					}

					if (oFolder && 0 < oFolder.subFolders().length)
					{
						fSearchFunction(oFolder.subFolders());
					}
				});
			}
		;

		fSearchFunction(this.folderList());

		aTimeouts.sort(function(a, b) {
			if (a[0] < b[0])
			{
				return -1;
			}
			else if (a[0] > b[0])
			{
				return 1;
			}

			return 0;
		});

		_.find(aTimeouts, function (aItem) {
			var oFolder = Cache.getFolderFromCacheList(aItem[1]);
			if (oFolder)
			{
				oFolder.interval = iUtc;
				aResult.push(aItem[1]);
			}

			return iLimit <= aResult.length;
		});

		return _.uniq(aResult);
	};
Example #28
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.settingsGet('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);
		}
	};
Example #29
0
	Links.prototype.settings = function (sScreenName)
	{
		var sResult = this.sBase + 'settings';
		if (!Utils.isUnd(sScreenName) && '' !== sScreenName)
		{
			sResult += '/' + sScreenName;
		}

		return sResult;
	};
Example #30
0
RemoteUserAjax.prototype.accountSetup = function(fCallback, sEmail, sPassword, bNew)
{
	bNew = Utils.isUnd(bNew) ? true : !!bNew;

	this.defaultRequest(fCallback, 'AccountSetup', {
		'Email': sEmail,
		'Password': sPassword,
		'New': bNew ? '1' : '0'
	});
};