/** * @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); }); }
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')); }
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')); };
/** * @returns {boolean} */ googlePreviewSupported() { if (null === this.googlePreviewSupportedCache) { this.googlePreviewSupportedCache = !!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialPreview'); } return this.googlePreviewSupportedCache; }
Remote.logout(function () { if (window.__rlah_clear) { window.__rlah_clear(); } require('App/App').loginAndLogoutReload(true, Settings.settingsGet('ParentEmail') && 0 < Settings.settingsGet('ParentEmail').length); });
/** * @param {?Function} fCallback */ folders(fCallback) { this.defaultRequest(fCallback, 'Folders', { 'SentFolder': Settings.settingsGet('SentFolder'), 'DraftFolder': Settings.settingsGet('DraftFolder'), 'SpamFolder': Settings.settingsGet('SpamFolder'), 'TrashFolder': Settings.settingsGet('TrashFolder'), 'ArchiveFolder': Settings.settingsGet('ArchiveFolder') }, null, '', ['Folders']); }
/** * @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); }
/** * @param {string} title */ setWindowTitle(title) { title = ((isNormal(title) && 0 < title.length) ? '' + title : ''); if (Settings.settingsGet('Title')) { title += (title ? ' - ' : '') + Settings.settingsGet('Title'); } window.document.title = title + ' ...'; window.document.title = title; }
AbstractApp.prototype.googlePreviewSupported = function () { if (null === this.googlePreviewSupportedCache) { this.googlePreviewSupportedCache = !!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialPreview'); } return this.googlePreviewSupportedCache; };
RemoteUserAjax.prototype.folders = function(fCallback) { this.defaultRequest(fCallback, 'Folders', { 'SentFolder': Settings.settingsGet('SentFolder'), 'DraftFolder': Settings.settingsGet('DraftFolder'), 'SpamFolder': Settings.settingsGet('SpamFolder'), 'TrashFolder': Settings.settingsGet('TrashFolder'), 'ArchiveFolder': Settings.settingsGet('ArchiveFolder') }, null, '', ['Folders']); };
/** * @constructor * @extends AbstractView */ function PaneSettingsAdminView() { AbstractView.call(this, 'Right', 'AdminPane'); this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain')); this.version = ko.observable(Settings.settingsGet('Version')); this.adminManLoadingVisibility = Data.adminManLoadingVisibility; kn.constructorEnd(this); }
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); } };
_.delay(function () { try { window.navigator.registerProtocolHandler('mailto', window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', '' + (Settings.settingsGet('Title') || 'RainLoop')); } catch(e) {} if (Settings.settingsGet('MailToEmail')) { Utils.mailToHelper(Settings.settingsGet('MailToEmail'), require('View/Popup/Compose')); } }, 500);
populate() { super.populate(); this.determineUserLanguage(!!settingsGet('DetermineUserLanguage')); this.determineUserDomain(!!settingsGet('DetermineUserDomain')); this.weakPassword(!!settingsGet('WeakPassword')); this.useLocalProxyForExternalImages(!!settingsGet('UseLocalProxyForExternalImages')); if (settingsGet('Auth')) { $.get('./data/VERSION?' + window.Math.random()).then(() => this.dataFolderAccess(true)); } }
/** * @constructor */ function Links() { var Settings = require('Storage/Settings'); this.sBase = '#/'; this.sServer = './?'; this.sVersion = Settings.settingsGet('Version'); this.sAuthSuffix = Settings.settingsGet('AuthAccountHash') || '0'; this.sWebPrefix = Settings.settingsGet('WebPath') || ''; this.sVersionPrefix = Settings.settingsGet('WebVersionPath') || 'rainloop/v/' + this.sVersion + '/'; this.sStaticPrefix = this.sVersionPrefix + 'static/'; }
/** * @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); }
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')); }
SettingsUserStore.prototype.populate = function () { this.layout(Utils.pInt(Settings.settingsGet('Layout'))); this.editorDefaultType(Settings.settingsGet('EditorDefaultType')); this.autoLogout(Utils.pInt(Settings.settingsGet('AutoLogout'))); this.messagesPerPage(Settings.settingsGet('MPP')); this.showImages(!!Settings.settingsGet('ShowImages')); this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList')); this.useThreads(!!Settings.settingsGet('UseThreads')); this.replySameFolder(!!Settings.settingsGet('ReplySameFolder')); var self = this; Events.sub('rl.auto-logout-refresh', function () { window.clearTimeout(self.iAutoLogoutTimer); if (0 < self.autoLogout() && !Settings.settingsGet('AccountSignMe')) { self.iAutoLogoutTimer = window.setTimeout(function () { Events.pub('rl.auto-logout'); }, self.autoLogout() * 1000 * 60); } }); Events.pub('rl.auto-logout-refresh'); };
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')); };
AppUser.prototype.bootstartLoginScreen = function () { Globals.$html.removeClass('rl-user-auth').addClass('rl-user-no-auth'); var sCustomLoginLink = Utils.pString(Settings.settingsGet('CustomLoginLink')); if (!sCustomLoginLink) { kn.startScreens([ require('Screen/User/Login') ]); Plugins.runHook('rl-start-login-screens'); Events.pub('rl.bootstart-login-screens'); } else { kn.routeOff(); kn.setHash(Links.root(), true); kn.routeOff(); _.defer(function () { window.location.href = sCustomLoginLink; }); } };
}, function (oAuthResult) { if (oAuthResult && !oAuthResult.error) { var oAuthToken = window.gapi.auth.getToken(); if (oAuthToken) { self.driveCreatePiker(oAuthToken); } } else { window.gapi.auth.authorize({ 'client_id': Settings.settingsGet('GoogleClientID'), 'scope': 'https://www.googleapis.com/auth/drive.readonly', 'immediate': false }, function (oAuthResult) { if (oAuthResult && !oAuthResult.error) { var oAuthToken = window.gapi.auth.getToken(); if (oAuthToken) { self.driveCreatePiker(oAuthToken); } } }); } });
AbstractApp.prototype.setWindowTitle = function (sTitle) { sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') + Settings.settingsGet('Title') || ''; window.document.title = sTitle + ' ...'; window.document.title = sTitle; };
/** * @constructor * @extends AbstractView */ function AboutAppView() { AbstractView.call(this, 'Center', 'About'); this.version = ko.observable(Settings.settingsGet('Version')); kn.constructorEnd(this); }
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; }); }
/** * @constructor */ function BrandingAdminSettings() { var Enums = require('Common/Enums'), Settings = require('Storage/Settings') ; this.capa = !!Settings.settingsGet('PremType'); 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.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.loginPowered = ko.observable(!!Settings.settingsGet('LoginPowered')); }
Events.sub('rl.auto-logout-refresh', function () { window.clearTimeout(self.iAutoLogoutTimer); if (0 < self.autoLogout() && !Settings.settingsGet('AccountSignMe')) { self.iAutoLogoutTimer = window.setTimeout(function () { Events.pub('rl.auto-logout'); }, self.autoLogout() * 1000 * 60); } });
ComposePopupView.prototype.onBuild = function () { this.initUploader(); var self = this, oScript = null ; key('ctrl+q, command+q', Enums.KeyState.Compose, function () { self.identitiesDropdownTrigger(true); return false; }); key('ctrl+s, command+s', Enums.KeyState.Compose, function () { self.saveCommand(); return false; }); // key('ctrl+enter, command+enter', Enums.KeyState.Compose, function () { // self.sendCommand(); // return false; // }); key('esc', Enums.KeyState.Compose, function () { if (self.modalVisibility()) { self.tryToClosePopup(); } return false; }); Globals.$win.on('resize', function () { self.triggerForResize(); }); if (this.dropboxEnabled()) { oScript = window.document.createElement('script'); oScript.type = 'text/javascript'; oScript.src = 'https://www.dropbox.com/static/api/1/dropins.js'; $(oScript).attr('id', 'dropboxjs').attr('data-app-key', Settings.settingsGet('DropboxApiKey')); window.document.body.appendChild(oScript); } if (this.driveEnabled()) { $.getScript('https://apis.google.com/js/api.js', function () { if (window.gapi) { self.driveVisible(true); } }); } };
ActivatePopupView.prototype.onShow = function () { this.domain(Settings.settingsGet('AdminDomain')); if (!this.activateProcess()) { this.key(''); this.activateText(''); this.activateText.isError(false); this.activationSuccessed(false); } };
/** * @constructor */ function LoginAdminSettings() { this.determineUserLanguage = AppAdminStore.determineUserLanguage; this.determineUserDomain = AppAdminStore.determineUserDomain; this.defaultDomain = ko.observable(Settings.settingsGet('LoginDefaultDomain')); this.allowLanguagesOnLogin = AppAdminStore.allowLanguagesOnLogin; this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.dummy = ko.observable(false); }
MessageListMailBoxAppView.prototype.initUploaderForAppend = function () { if (!Settings.settingsGet('AllowAppendMessage') || !this.dragOverArea()) { return false; } var oJua = new Jua({ 'action': Links.append(), 'name': 'AppendFile', 'queueSize': 1, 'multipleSizeLimit': 1, 'disableFolderDragAndDrop': true, 'hidden': { 'Folder': function () { return Data.currentFolderFullNameRaw(); } }, 'dragAndDropElement': this.dragOverArea(), 'dragAndDropBodyElement': this.dragOverBodyArea() }) ; 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']) { Data.messageListLoading(true); return true; } return false; }, this)) .on('onComplete', _.bind(function () { require('App/App').reloadMessageList(true, true); }, this)) ; return !!oJua; };