コード例 #1
0
ファイル: User.js プロジェクト: Rona111/rainloop-webmail
	AppUser.prototype.bootend = function ()
	{
		if (progressJs)
		{
			kn.hideLoading();

			progressJs.onbeforeend(function () {
				$('.progressjs-container').hide().remove();
			});

			progressJs.set(100).end();
		}
		else
		{
			kn.hideLoading();
		}
	};
コード例 #2
0
ファイル: User.js プロジェクト: Rona111/rainloop-webmail
	AppUser.prototype.bootstart = function ()
	{
		AbstractApp.prototype.bootstart.call(this);

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

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

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

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

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

			if (Settings.capa(Enums.Capa.TwoFactor) &&
				Settings.capa(Enums.Capa.TwoFactorForce) &&
				Settings.settingsGet('RequireTwoFactor'))
			{
				this.bootend();
				this.bootstartTwoFactorScreen();
			}
			else
			{
				this.setWindowTitle(Translator.i18n('TITLES/LOADING'));

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

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

					this.bootend();

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

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

								PgpStore.openpgp = openpgp;

								if (window.Worker)
								{
									try
									{
										PgpStore.openpgp.initWorker(Links.openPgpWorkerJs());
									}
									catch (e)
									{
										Utils.log(e);
									}
								}

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

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

								Events.pub('openpgp.init');

								self.reloadOpenPgpKeys();
							};

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

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

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

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

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

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

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

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

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

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

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

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

						self.accountsAndIdentities(true);

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

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

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

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

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

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

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

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

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

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

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

				}, self));

//}); // require code splitting

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

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

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

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

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

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