Example #1
0
	/**
	 * @constructor
	 */
	function GeneralAppSetting()
	{
		this.mainLanguage = Data.mainLanguage;
		this.mainMessagesPerPage = Data.mainMessagesPerPage;
		this.mainMessagesPerPageArray = Consts.Defaults.MessagesPerPageArray;
		this.editorDefaultType = Data.editorDefaultType;
		this.showImages = Data.showImages;
		this.interfaceAnimation = Data.interfaceAnimation;
		this.useDesktopNotifications = Data.useDesktopNotifications;
		this.threading = Data.threading;
		this.useThreads = Data.useThreads;
		this.replySameFolder = Data.replySameFolder;
		this.layout = Data.layout;
		this.usePreviewPane = Data.usePreviewPane;
		this.useCheckboxesInList = Data.useCheckboxesInList;
		this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings;

		this.isDesktopNotificationsSupported = ko.computed(function () {
			return Enums.DesktopNotifications.NotSupported !== Data.desktopNotificationsPermisions();
		});

		this.isDesktopNotificationsDenied = ko.computed(function () {
			return Enums.DesktopNotifications.NotSupported === Data.desktopNotificationsPermisions() ||
				Enums.DesktopNotifications.Denied === Data.desktopNotificationsPermisions();
		});

		this.mainLanguageFullName = ko.computed(function () {
			return Utils.convertLangName(this.mainLanguage());
		}, this);

		this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
		this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.isAnimationSupported = Globals.bAnimationSupported;
	}
Example #2
0
 utils.flag = function(init) {
     var value = ko.observable(Boolean(init));
     value.turn_on = function() {
         value(true);
     }
     value.turn_off = function() {
         value(false);
     }
     value.is_on = ko.computed(function() {
         return utils.is_on(value());
     });
     value.is_off = ko.computed(function() {
         return utils.is_off(value());
     });
     value.toggle = function() {
         value(!value());
     }
     // @param timeout: a canceller timeout. see utils.wait_for
     value.wait_for_on = function(timeout) {
         return utils.wait_for(value, utils.is_on, timeout);
     }
     // @param timeout: a canceller timeout. see utils.wait_for
     value.wait_for_off = function(timeout) {
         return utils.wait_for(value, utils.is_off, timeout);
     }
     return value;
 };
Example #3
0
export function createCommandLegacy(context, fExecute, fCanExecute = true)
{
	let fResult = null;
	const fNonEmpty = (...args) => {
		if (fResult && fResult.canExecute && fResult.canExecute())
		{
			fExecute.apply(context, args);
		}
		return false;
	};

	fResult = fExecute ? fNonEmpty : noop;
	fResult.enabled = ko.observable(true);
	fResult.isCommand = true;

	if (isFunc(fCanExecute))
	{
		fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && fCanExecute.call(context));
	}
	else
	{
		fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && !!fCanExecute);
	}

	return fResult;
}
Example #4
0
	Utils.createCommand = function (oContext, fExecute, fCanExecute)
	{
		var
			fNonEmpty = function () {
				if (fResult && fResult.canExecute && fResult.canExecute())
				{
					fExecute.apply(oContext, Array.prototype.slice.call(arguments));
				}
				return false;
			},
			fResult = fExecute ? fNonEmpty : Utils.emptyFunction
		;

		fResult.enabled = ko.observable(true);

		fCanExecute = Utils.isUnd(fCanExecute) ? true : fCanExecute;
		if (Utils.isFunc(fCanExecute))
		{
			fResult.canExecute = ko.computed(function () {
				return fResult.enabled() && fCanExecute.call(oContext);
			});
		}
		else
		{
			fResult.canExecute = ko.computed(function () {
				return fResult.enabled() && !!fCanExecute;
			});
		}

		return fResult;
	};
	/**
	 * @constructor
	 */
	function SettingsAccounts()
	{
		this.accounts = Data.accounts;

		this.processText = ko.computed(function () {
			return Data.accountsLoading() ? Utils.i18n('SETTINGS_ACCOUNTS/LOADING_PROCESS') : '';
		}, this);

		this.visibility = ko.computed(function () {
			return '' === this.processText() ? 'hidden' : 'visible';
		}, this);

		this.accountForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
			function (oPrev) {
				if (oPrev)
				{
					oPrev.deleteAccess(false);
				}
			}, function (oNext) {
				if (oNext)
				{
					oNext.deleteAccess(true);
				}
			}
		]});
	}
Example #6
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;
		});
	}
Example #7
0
	/**
	 * @constructor
	 */
	function GeneralUserSettings()
	{
		this.language = LanguageStore.language;
		this.languages = LanguageStore.languages;
		this.messagesPerPage = SettingsStore.messagesPerPage;
		this.messagesPerPageArray = Consts.Defaults.MessagesPerPageArray;

		this.editorDefaultType = SettingsStore.editorDefaultType;
		this.layout = SettingsStore.layout;
		this.usePreviewPane = SettingsStore.usePreviewPane;

		this.soundNotificationIsSupported = NotificationStore.soundNotificationIsSupported;
		this.enableSoundNotification = NotificationStore.enableSoundNotification;

		this.enableDesktopNotification = NotificationStore.enableDesktopNotification;
		this.isDesktopNotificationSupported = NotificationStore.isDesktopNotificationSupported;
		this.isDesktopNotificationDenied = NotificationStore.isDesktopNotificationDenied;

		this.showImages = SettingsStore.showImages;
		this.useCheckboxesInList = SettingsStore.useCheckboxesInList;
		this.threadsAllowed = AppStore.threadsAllowed;
		this.useThreads = SettingsStore.useThreads;
		this.replySameFolder = SettingsStore.replySameFolder;
		this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings;

		this.languageFullName = ko.computed(function () {
			return Utils.convertLangName(this.language());
		}, this);

		this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});

		this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
		this.editorDefaultTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
		this.layoutTrigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.isAnimationSupported = Globals.bAnimationSupported;

		this.editorDefaultTypes = ko.computed(function () {
			Translator.trigger();
			return [
				{'id': Enums.EditorDefaultType.Html, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML')},
				{'id': Enums.EditorDefaultType.Plain, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN')},
				{'id': Enums.EditorDefaultType.HtmlForced, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML_FORCED')},
				{'id': Enums.EditorDefaultType.PlainForced, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN_FORCED')}
			];
		}, this);

		this.layoutTypes = ko.computed(function () {
			Translator.trigger();
			return [
				{'id': Enums.Layout.NoPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT')},
				{'id': Enums.Layout.SidePreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_VERTICAL_SPLIT')},
				{'id': Enums.Layout.BottomPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT')}
			];
		}, this);
	}
Example #8
0
NotificationUserStore.prototype.computers = function()
{
	this.isDesktopNotificationSupported = ko.computed(function() {
		return Enums.DesktopNotification.NotSupported !== this.desktopNotificationPermissions();
	}, this);

	this.isDesktopNotificationDenied = ko.computed(function() {
		return Enums.DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
			Enums.DesktopNotification.Denied === this.desktopNotificationPermissions();
	}, this);
};
Example #9
0
	constructor() {
		this.google = {};
		this.twitter = {};
		this.facebook = {};
		this.dropbox = {};

		// Google
		this.google.enabled = ko.observable(false);

		this.google.clientID = ko.observable('');
		this.google.clientSecret = ko.observable('');
		this.google.apiKey = ko.observable('');

		this.google.loading = ko.observable(false);
		this.google.userName = ko.observable('');

		this.google.loggined = ko.computed(() => '' !== this.google.userName());

		this.google.capa = {};
		this.google.capa.auth = ko.observable(false);
		this.google.capa.authFast = ko.observable(false);
		this.google.capa.drive = ko.observable(false);
		this.google.capa.preview = ko.observable(false);

		this.google.require = {};
		this.google.require.clientSettings = ko.computed(
			() => this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive()));

		this.google.require.apiKeySettings = ko.computed(() => this.google.enabled() && this.google.capa.drive());

		// Facebook
		this.facebook.enabled = ko.observable(false);
		this.facebook.appID = ko.observable('');
		this.facebook.appSecret = ko.observable('');
		this.facebook.loading = ko.observable(false);
		this.facebook.userName = ko.observable('');
		this.facebook.supported = ko.observable(false);

		this.facebook.loggined = ko.computed(() => '' !== this.facebook.userName());

		// Twitter
		this.twitter.enabled = ko.observable(false);
		this.twitter.consumerKey = ko.observable('');
		this.twitter.consumerSecret = ko.observable('');
		this.twitter.loading = ko.observable(false);
		this.twitter.userName = ko.observable('');

		this.twitter.loggined = ko.computed(() => '' !== this.twitter.userName());

		// Dropbox
		this.dropbox.enabled = ko.observable(false);
		this.dropbox.apiKey = ko.observable('');
	}
Example #10
0
	/**
	 * @constructor
	 */
	function TemplatesUserSettings()
	{
		this.templates = TemplateStore.templates;

		this.processText = ko.computed(function () {
			return TemplateStore.templates.loading() ? Translator.i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : '';
		}, this);

		this.visibility = ko.computed(function () {
			return '' === this.processText() ? 'hidden' : 'visible';
		}, this);

		this.templateForDeletion = ko.observable(null).deleteAccessHelper();
	}
Example #11
0
	/**
	 * @constructor
	 */
	function GeneralAdminSettings()
	{
		this.language = LanguageStore.language;
		this.languages = LanguageStore.languages;
		this.languageAdmin = LanguageStore.languageAdmin;
		this.languagesAdmin = LanguageStore.languagesAdmin;

		this.theme = ThemeStore.theme;
		this.themes = ThemeStore.themes;

		this.capaThemes = CapaAdminStore.themes;
		this.capaUserBackground = CapaAdminStore.userBackground;
		this.capaGravatar = CapaAdminStore.gravatar;
		this.capaAdditionalAccounts = CapaAdminStore.additionalAccounts;
		this.capaIdentities = CapaAdminStore.identities;
		this.capaAttachmentThumbnails = CapaAdminStore.attachmentThumbnails;
		this.capaTemplates = CapaAdminStore.templates;

		this.allowLanguagesOnSettings = AppAdminStore.allowLanguagesOnSettings;
		this.weakPassword = AppAdminStore.weakPassword;

		this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
		this.uploadData = Settings.settingsGet('PhpUploadSizes');
		this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ? [
			this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '',
			this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : ''
		].join('') : '';

		this.themesOptions = ko.computed(function () {
			return _.map(this.themes(), function (sTheme) {
				return {
					'optValue': sTheme,
					'optText': Utils.convertThemeName(sTheme)
				};
			});
		}, this);

		this.languageFullName = ko.computed(function () {
			return Utils.convertLangName(this.language());
		}, this);

		this.languageAdminFullName = ko.computed(function () {
			return Utils.convertLangName(this.languageAdmin());
		}, this);

		this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
		this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
		this.languageAdminTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
		this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
	}
Example #12
0
	/**
	 * @constructor
	 */
	function DomainsAdminSettings()
	{
		this.domains = Data.domains;

		this.iDomainForDeletionTimeout = 0;

		this.visibility = ko.computed(function () {
			return Data.domains.loading() ? 'visible' : 'hidden';
		}, this);

		this.domainForDeletion = ko.observable(null).extend({'toggleSubscribe': [this,
			function (oPrev) {
				if (oPrev)
				{
					oPrev.deleteAccess(false);
				}
			}, function (oNext) {
				if (oNext)
				{
					oNext.deleteAccess(true);
					this.startDomainForDeletionTimeout();
				}
			}
		]});
	}
Example #13
0
/**
 * @constructor
 * @extends AbstractView
 */
function FolderCreateView()
{
	AbstractView.call(this, 'Popups', 'PopupsFolderCreate');

	this.folderName = ko.observable('');
	this.folderName.focused = ko.observable(false);

	this.selectedParentValue = ko.observable(Consts.UNUSED_OPTION_VALUE);

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

		var
			aTop = [],
			fDisableCallback = null,
			fVisibleCallback = null,
			aList = FolderStore.folderList(),
			fRenameCallback = function(oItem) {
				return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '';
			};

		aTop.push(['', '']);

		if ('' !== FolderStore.namespace)
		{
			fDisableCallback = function(oItem)
			{
				return FolderStore.namespace !== oItem.fullNameRaw.substr(0, FolderStore.namespace.length);
			};
		}

		return Utils.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback);

	}, this);

	// commands
	this.createFolder = Utils.createCommand(this, function() {

		var
			sParentFolderName = this.selectedParentValue();

		if ('' === sParentFolderName && 1 < FolderStore.namespace.length)
		{
			sParentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1);
		}

		require('App/User').default.foldersPromisesActionHelper(
			Promises.folderCreate(this.folderName(), sParentFolderName, FolderStore.foldersCreating),
			Enums.Notification.CantCreateFolder
		);

		this.cancelCommand();

	}, function() {
		return this.simpleFolderNameValidation(this.folderName());
	});

	this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;

	kn.constructorEnd(this);
}
	/**
	 * @constructor
	 * @extends AbstractView
	 */
	function LanguagesPopupView()
	{
		AbstractView.call(this, 'Popups', 'PopupsLanguages');

		var self = this;

		this.fLang = null;
		this.userLanguage = ko.observable('');

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

		this.languages = ko.computed(function () {
			var sUserLanguage = self.userLanguage();
			return _.map(self.langs(), function (sLanguage) {
				return {
					'key': sLanguage,
					'user': sLanguage === sUserLanguage,
					'selected': ko.observable(false),
					'fullName': Utils.convertLangName(sLanguage)
				};
			});
		});

		this.langs.subscribe(function () {
			this.setLanguageSelection();
		}, this);

		kn.constructorEnd(this);
	}
Example #15
0
                addStepMethods = function (step) {

                	step.showErrors = ko.observable(false);
                	step.hasErrors = ko.computed(function () {
                		return _.some(step.checkFields, function (field) {
                			return !field.isValid();
                		});
                	});
                	step.error = ko.observable(null);
                	step.showError = function (field) {
                		return step.showErrors() && !field.isValid();
                	};
                	step.checkForm = function () {
                		return step.checkFields.forEach(function (field) {
                			field.valueHasMutated();
                		});
                	};

                	step.compositionComplete = function () {
                		isTransitioning(false);
                	};

                	if (!step.activate) {
                		step.activate = function () {
                			reset(step);
                		};
                	}
                },
function LoginViewModel() {
	this.errorMessage = ko.observable( '' );
	this.hasError = ko.computed( function() {
		return !this.errorMessage();
	}, this );
	this._loggedIn = false;
}
Example #17
0
	/**
	 * @constructor
	 */
	function SecurityUserSetting()
	{
		this.processing = ko.observable(false);
		this.clearing = ko.observable(false);
		this.secreting = ko.observable(false);

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

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

		this.bFirst = true;

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

		this.onResult = _.bind(this.onResult, this);
		this.onSecretResult = _.bind(this.onSecretResult, this);
	}
	/**
	 * @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]);
	}
Example #19
0
	/**
	 * @constructor
	 */
	function ContactsUserSetting()
	{
		this.contactsAutosave = Data.contactsAutosave;

		this.allowContactsSync = Data.allowContactsSync;
		this.enableContactsSync = Data.enableContactsSync;
		this.contactsSyncUrl = Data.contactsSyncUrl;
		this.contactsSyncUser = Data.contactsSyncUser;
		this.contactsSyncPass = Data.contactsSyncPass;

		this.saveTrigger = ko.computed(function () {
			return [
				this.enableContactsSync() ? '1' : '0',
				this.contactsSyncUrl(),
				this.contactsSyncUser(),
				this.contactsSyncPass()
			].join('|');
		}, this).extend({'throttle': 500});

		this.saveTrigger.subscribe(function () {
			Remote.saveContactsSyncData(null,
				this.enableContactsSync(),
				this.contactsSyncUrl(),
				this.contactsSyncUser(),
				this.contactsSyncPass()
			);
		}, this);
	}
Example #20
0
	/**
	 * @constructor
	 */
	function PackagesAdminSetting()
	{
		this.packagesError = ko.observable('');

		this.packages = Data.packages;
		this.packagesLoading = Data.packagesLoading;
		this.packagesReal = Data.packagesReal;
		this.packagesMainUpdatable = Data.packagesMainUpdatable;

		this.packagesCurrent = this.packages.filter(function (oItem) {
			return oItem && '' !== oItem['installed'] && !oItem['compare'];
		});

		this.packagesAvailableForUpdate = this.packages.filter(function (oItem) {
			return oItem && '' !== oItem['installed'] && !!oItem['compare'];
		});

		this.packagesAvailableForInstallation = this.packages.filter(function (oItem) {
			return oItem && '' === oItem['installed'];
		});

		this.visibility = ko.computed(function () {
			return Data.packagesLoading() ? 'visible' : 'hidden';
		}, this);
	}
Example #21
0
	/**
	 * @constructor
	 * @extends AbstractView
	 */
	function FolderListMailBoxUserView()
	{
		AbstractView.call(this, 'Left', 'MailFolderList');

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

		this.composeInEdit = AppStore.composeInEdit;

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

		this.foldersListWithSingleInboxRootFolder = FolderStore.foldersListWithSingleInboxRootFolder;

		this.leftPanelDisabled = Globals.leftPanelDisabled;

		this.iDropOverTimer = 0;

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

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

		kn.constructorEnd(this);
	}
Example #22
0
	/**
	 * @constructor
	 */
	function BrandingAdminSettings()
	{
		var
			Enums = require('Common/Enums'),
			Settings = require('Storage/Settings'),
			AppStore = require('Stores/Admin/App')
		;

		this.capa = AppStore.prem;

		this.title = ko.observable(Settings.settingsGet('Title'));
		this.title.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.loadingDesc = ko.observable(Settings.settingsGet('LoadingDescription'));
		this.loadingDesc.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.loginLogo = ko.observable(Settings.settingsGet('LoginLogo') || '');
		this.loginLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.loginBackground = ko.observable(Settings.settingsGet('LoginBackground') || '');
		this.loginBackground.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.userLogo = ko.observable(Settings.settingsGet('UserLogo') || '');
		this.userLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.userLogoMessage = ko.observable(Settings.settingsGet('UserLogoMessage') || '');
		this.userLogoMessage.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.userLogoTitle = ko.observable(Settings.settingsGet('UserLogoTitle') || '');
		this.userLogoTitle.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.loginDescription = ko.observable(Settings.settingsGet('LoginDescription'));
		this.loginDescription.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.loginCss = ko.observable(Settings.settingsGet('LoginCss'));
		this.loginCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.userCss = ko.observable(Settings.settingsGet('UserCss'));
		this.userCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.welcomePageUrl = ko.observable(Settings.settingsGet('WelcomePageUrl'));
		this.welcomePageUrl.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.welcomePageDisplay = ko.observable(Settings.settingsGet('WelcomePageDisplay'));
		this.welcomePageDisplay.trigger = ko.observable(Enums.SaveSettingsStep.Idle);

		this.welcomePageDisplay.options = ko.computed(function () {
			Translator.trigger();
			return [
				{'optValue': 'none', 'optText': Translator.i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_NONE')},
				{'optValue': 'once', 'optText': Translator.i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_ONCE')},
				{'optValue': 'always', 'optText': Translator.i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_ALWAYS')}
			];
		});

		this.loginPowered = ko.observable(!!Settings.settingsGet('LoginPowered'));

		this.community = RL_COMMUNITY || AppStore.community();
	}
Example #23
0
	/**
	 * @constructor
	 */
	function AboutAdminSetting()
	{
		var
			Settings = require('Storage/Settings'),
			Data = require('Storage/Admin/Data')
		;

		this.version = ko.observable(Settings.settingsGet('Version'));
		this.access = ko.observable(!!Settings.settingsGet('CoreAccess'));
		this.errorDesc = ko.observable('');

		this.coreReal = Data.coreReal;
		this.coreUpdatable = Data.coreUpdatable;
		this.coreAccess = Data.coreAccess;
		this.coreChecking = Data.coreChecking;
		this.coreUpdating = Data.coreUpdating;
		this.coreRemoteVersion = Data.coreRemoteVersion;
		this.coreRemoteRelease = Data.coreRemoteRelease;
		this.coreVersionCompare = Data.coreVersionCompare;

		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);
	}
Example #24
0
    function ViewModel(){
        var self = this;//save the this ref

        self.projectName='OneLib 演示站点';

        self.firstVisibleIndex=ko.observable(-1);

        self.demos=[];

        self.showCount=5;

        self.demosVisible = ko.computed(function(){
            var idx = this.firstVisibleIndex();
            var r =[],s=self.showCount;
            while(s--){
                r.push(this.demos[idx+ r.length]);
            }
            return r;
        },self);

        self.curDemo=ko.observable(self.demos[0]);

        self.demoClick = function(demo){
            self.curDemo().isCur(false);
            demo.isCur(true);
            self.curDemo(demo);
        };

        self.canRollLeft = ko.computed(function(){
            return self.firstVisibleIndex()>0;
        },self);

        self.canRollRight = ko.computed(function(){
            return self.demos.length-self.firstVisibleIndex()-self.showCount>0;
        },self);

        self.rollLeft = function(){
            self.canRollLeft()&& self.firstVisibleIndex(self.firstVisibleIndex()-1);
        };
        self.rollRight = function(){
            self.canRollRight()&& self.firstVisibleIndex(self.firstVisibleIndex()+1);
        };
    }
Example #25
0
	/**
	 * @constructor
	 */
	function DomainsAdminSettings()
	{
		this.domains = DomainStore.domains;

		this.visibility = ko.computed(function () {
			return this.domains.loading() ? 'visible' : 'hidden';
		}, this);

		this.domainForDeletion = ko.observable(null).deleteAccessHelper();
	}
Example #26
0
	constructor() {
		this.domains = DomainStore.domains;

		this.visibility = ko.computed(() => (this.domains.loading() ? 'visible' : 'hidden'));

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

		this.onDomainListChangeRequest = _.bind(this.onDomainListChangeRequest, this);
		this.onDomainLoadRequest = _.bind(this.onDomainLoadRequest, this);
	}
Example #27
0
	/**
	 * @constructor
	 */
	function MessageUserStore()
	{
		this.staticMessage = new MessageModel();

		this.messageList = ko.observableArray([]).extend({'rateLimit': 0});

		this.messageListCount = ko.observable(0);
		this.messageListSearch = ko.observable('');
		this.messageListThreadUid = ko.observable('');
		this.messageListPage = ko.observable(1);
		this.messageListPageBeforeThread = ko.observable(1);
		this.messageListError = ko.observable('');

		this.messageListEndFolder = ko.observable('');
		this.messageListEndSearch = ko.observable('');
		this.messageListEndThreadUid = ko.observable('');
		this.messageListEndPage = ko.observable(1);

		this.messageListLoading = ko.observable(false);
		this.messageListIsNotCompleted = ko.observable(false);
		this.messageListCompleteLoadingThrottle = ko.observable(false).extend({'throttle': 200});
		this.messageListCompleteLoadingThrottleForAnimation = ko.observable(false).extend({'specialThrottle': 700});

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

		this.selectorMessageSelected = ko.observable(null);
		this.selectorMessageFocused = ko.observable(null);

		// message viewer
		this.message = ko.observable(null);

		this.message.viewTrigger = ko.observable(false);

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

		this.messageCurrentLoading = ko.observable(false);

		this.messageLoading = ko.computed(function () {
			return this.messageCurrentLoading();
		}, this);

		this.messageLoadingThrottle = ko.observable(false).extend({'throttle': 50});

		this.messageFullScreenMode = ko.observable(false);

		this.messagesBodiesDom = ko.observable(null);
		this.messageActiveDom = ko.observable(null);

		this.computers();
		this.subscribers();

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

		this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, 1000 * 30);
	}
	/**
	 * @constructor
	 * @extends AbstractData
	 */
	function AdminDataStorage()
	{
		AbstractData.call(this);

		this.domainsLoading = ko.observable(false).extend({'throttle': 100});
		this.domains = ko.observableArray([]);

		this.pluginsLoading = ko.observable(false).extend({'throttle': 100});
		this.plugins = ko.observableArray([]);

		this.packagesReal = ko.observable(true);
		this.packagesMainUpdatable = ko.observable(true);
		this.packagesLoading = ko.observable(false).extend({'throttle': 100});
		this.packages = ko.observableArray([]);

		this.coreReal = ko.observable(true);
		this.coreUpdatable = ko.observable(true);
		this.coreAccess = ko.observable(true);
		this.coreChecking = ko.observable(false).extend({'throttle': 100});
		this.coreUpdating = ko.observable(false).extend({'throttle': 100});
		this.coreRemoteVersion = ko.observable('');
		this.coreRemoteRelease = ko.observable('');
		this.coreVersionCompare = ko.observable(-2);

		this.licensing = ko.observable(false);
		this.licensingProcess = ko.observable(false);
		this.licenseValid = ko.observable(false);
		this.licenseExpired = ko.observable(0);
		this.licenseError = ko.observable('');

		this.licenseTrigger = ko.observable(false);

		this.adminManLoading = ko.computed(function () {
			return '000' !== [this.domainsLoading() ? '1' : '0', this.pluginsLoading() ? '1' : '0', this.packagesLoading() ? '1' : '0'].join('');
		}, this);

		this.adminManLoadingVisibility = ko.computed(function () {
			return this.adminManLoading() ? 'visible' : 'hidden';
		}, this).extend({'rateLimit': 300});
	}
	/**
	 * @constructor
	 * @param {number=} iType = Enums.ContactPropertyType.Unknown
	 * @param {string=} sTypeStr = ''
	 * @param {string=} sValue = ''
	 * @param {boolean=} bFocused = false
	 * @param {string=} sPlaceholder = ''
	 */
	function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder)
	{
		AbstractModel.call(this, 'ContactPropertyModel');

		this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType);
		this.typeStr = ko.observable(Utils.isUnd(sTypeStr) ? '' : sTypeStr);
		this.focused = ko.observable(Utils.isUnd(bFocused) ? false : !!bFocused);
		this.value = ko.observable(Utils.pString(sValue));

		this.placeholder = ko.observable(sPlaceholder || '');

		this.placeholderValue = ko.computed(function () {
			var sPlaceholder = this.placeholder();
			return sPlaceholder ? Utils.i18n(sPlaceholder) : '';
		}, this);

		this.largeValue = ko.computed(function () {
			return Enums.ContactPropertyType.Note === this.type();
		}, this);

		this.regDisposables([this.placeholderValue, this.largeValue]);
	}
Example #30
0
	Utils.createMomentDate = function (oObject)
	{
		if (Utils.isUnd(oObject.moment))
		{
			oObject.moment = ko.observable(moment());
		}

		return ko.computed(function () {
			Globals.momentTrigger();
			var oMoment = this.moment();
			return 1970 === oMoment.year() ? '' : oMoment.fromNow();
		}, oObject);
	};