Ejemplo n.º 1
0
	MessageListMailBoxUserView.prototype.dragAndDronHelper = function (oMessageListItem)
	{
		if (oMessageListItem)
		{
			oMessageListItem.checked(true);
		}

		var
			oEl = Utils.draggablePlace(),
			aUids = MessageStore.messageListCheckedOrSelectedUidsWithSubMails()
		;

		oEl.data('rl-folder', FolderStore.currentFolderFullNameRaw());
		oEl.data('rl-uids', aUids);
		oEl.find('.text').text('' + aUids.length);

		_.defer(function () {
			var aUids = MessageStore.messageListCheckedOrSelectedUidsWithSubMails();

			oEl.data('rl-uids', aUids);
			oEl.find('.text').text('' + aUids.length);
		});

		return oEl;
	};
Ejemplo n.º 2
0
	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;
			});
		}
	};
Ejemplo n.º 3
0
		renderPeople: function(){
			this.renderCollection();
			var self = this;
			_.defer( function(){
				self.masonry( '.people' );
			} );
			return this;
		}
Ejemplo n.º 4
0
export function reload()
{
	_.defer(() => {
		$('.moment', window.document).each((index, item) => {
			momentToNode(item);
		});
	});
}
Ejemplo n.º 5
0
	MailBoxUserScreen.prototype.onBuild = function ()
	{
		if (!Globals.bMobileDevice)
		{
			_.defer(function () {
				require('App/User').initHorizontalLayoutResizer(Enums.ClientSideKeyName.MessageListSize);
			});
		}
	};
Ejemplo n.º 6
0
				Remote.accountDelete((result, data) => {

					if (StorageResultType.Success === result && data && data.Result && data.Reload)
					{
						routeOff();
						setHash(root(), true);
						routeOff();

						_.defer(() => window.location.reload());
					}
					else
					{
						getApp().accountsAndIdentities();
					}

				}, accountToRemove.email);
Ejemplo n.º 7
0
	Translator.prototype.i18nToNodes = function (oElements, bAnimate)
	{
		var self = this;
		_.defer(function () {

			$('[data-i18n]', oElements).each(function () {
				self.i18nToNode(this);
			});

			if (bAnimate && Globals.bAnimationSupported)
			{
				$('.i18n-animation[data-i18n]', oElements).letterfx({
					'fx': 'fall fade', 'backwards': false, 'timing': 50, 'fx_duration': '50ms', 'letter_end': 'restore', 'element_end': 'restore'
				});
			}
		});
	};
Ejemplo n.º 8
0
				Remote.accountDelete(function (sResult, oData) {

					if (Enums.StorageResultType.Success === sResult && oData &&
						oData.Result && oData.Reload)
					{
						kn.routeOff();
						kn.setHash(LinkBuilder.root(), true);
						kn.routeOff();

						_.defer(function () {
							window.location.reload();
						});
					}
					else
					{
						require('App:RainLoop').accountsAndIdentities();
					}

				}, oAccountToRemove.email);
Ejemplo n.º 9
0
	AdminApp.prototype.bootstart = function ()
	{
		AbstractApp.prototype.bootstart.call(this);

		require('Stores/Admin/App').populate();
		require('Stores/Admin/Capa').populate();

		kn.hideLoading();

		if (!Settings.settingsGet('AllowAdminPanel'))
		{
			kn.routeOff();
			kn.setHash(Links.root(), true);
			kn.routeOff();

			_.defer(function () {
				window.location.href = '/';
			});
		}
		else
		{
			if (!!Settings.settingsGet('Auth'))
			{
				kn.startScreens([
					require('Screen/Admin/Settings')
				]);
			}
			else
			{
				kn.startScreens([
					require('Screen/Admin/Login')
				]);
			}
		}

		if (SimplePace)
		{
			SimplePace.set(100);
		}
	};
Ejemplo n.º 10
0
	Utils.i18nToNode = function (oElement)
	{
		_.defer(function () {
			$('.i18n', oElement).each(function () {
				var
					jqThis = $(this),
					sKey = ''
				;

				sKey = jqThis.data('i18n-text');
				if (sKey)
				{
					jqThis.text(Utils.i18n(sKey));
				}
				else
				{
					sKey = jqThis.data('i18n-html');
					if (sKey)
					{
						jqThis.html(Utils.i18n(sKey));
					}

					sKey = jqThis.data('i18n-placeholder');
					if (sKey)
					{
						jqThis.attr('placeholder', Utils.i18n(sKey));
					}

					sKey = jqThis.data('i18n-title');
					if (sKey)
					{
						jqThis.attr('title', Utils.i18n(sKey));
					}
				}
			});
		});
	};
Ejemplo n.º 11
0
export function screenOnRoute(screenName, subPart)
{
	let
		vmScreen = null,
		isSameScreen = false,
		cross = null;

	if ('' === pString(screenName))
	{
		screenName = defaultScreenName;
	}

	if ('' !== screenName)
	{
		vmScreen = screen(screenName);
		if (!vmScreen)
		{
			vmScreen = screen(defaultScreenName);
			if (vmScreen)
			{
				subPart = screenName + '/' + subPart;
				screenName = defaultScreenName;
			}
		}

		if (vmScreen && vmScreen.__started)
		{
			isSameScreen = currentScreen && vmScreen === currentScreen;

			if (!vmScreen.__builded)
			{
				vmScreen.__builded = true;

				if (isNonEmptyArray(vmScreen.viewModels()))
				{
					_.each(vmScreen.viewModels(), (ViewModelClass) => {
						buildViewModel(ViewModelClass, vmScreen);
					});
				}

				delegateRun(vmScreen, 'onBuild');
			}

			_.defer(() => {
				// hide screen
				if (currentScreen && !isSameScreen)
				{
					delegateRun(currentScreen, 'onHide');
					delegateRun(currentScreen, 'onHideWithDelay', [], 500);

					if (currentScreen.onHideTrigger)
					{
						currentScreen.onHideTrigger(!currentScreen.onHideTrigger());
					}

					if (isNonEmptyArray(currentScreen.viewModels()))
					{
						_.each(currentScreen.viewModels(), (ViewModelClass) => {
							if (ViewModelClass.__vm && ViewModelClass.__dom && ViewType.Popup !== ViewModelClass.__vm.viewModelPosition)
							{
								ViewModelClass.__dom.hide();
								ViewModelClass.__vm.viewModelVisibility(false);

								delegateRun(ViewModelClass.__vm, 'onHide');
								delegateRun(ViewModelClass.__vm, 'onHideWithDelay', [], 500);

								if (ViewModelClass.__vm.onHideTrigger)
								{
									ViewModelClass.__vm.onHideTrigger(!ViewModelClass.__vm.onHideTrigger());
								}
							}
						});
					}
				}
				// --

				currentScreen = vmScreen;

				// show screen
				if (currentScreen && !isSameScreen)
				{
					delegateRun(currentScreen, 'onShow');
					if (currentScreen.onShowTrigger)
					{
						currentScreen.onShowTrigger(!currentScreen.onShowTrigger());
					}

					runHook('screen-on-show', [currentScreen.screenName(), currentScreen]);

					if (isNonEmptyArray(currentScreen.viewModels()))
					{
						_.each(currentScreen.viewModels(), (ViewModelClass) => {

							if (ViewModelClass.__vm && ViewModelClass.__dom && ViewType.Popup !== ViewModelClass.__vm.viewModelPosition)
							{
								delegateRun(ViewModelClass.__vm, 'onBeforeShow');

								ViewModelClass.__dom.show();
								ViewModelClass.__vm.viewModelVisibility(true);

								delegateRun(ViewModelClass.__vm, 'onShow');
								if (ViewModelClass.__vm.onShowTrigger)
								{
									ViewModelClass.__vm.onShowTrigger(!ViewModelClass.__vm.onShowTrigger());
								}

								delegateRun(ViewModelClass.__vm, 'onShowWithDelay', [], 200);
								vmRunHook('view-model-on-show', ViewModelClass);
							}

						});
					}
				}
				// --

				cross = vmScreen && vmScreen.__cross ? vmScreen.__cross() : null;
				if (cross)
				{
					cross.parse(subPart);
				}
			});
		}
	}
}
Ejemplo n.º 12
0
	onRoute(subName) {
		let
			settingsScreen = null,
			RoutedSettingsViewModel = null,
			viewModelPlace = null,
			viewModelDom = null;

		RoutedSettingsViewModel = _.find(VIEW_MODELS.settings,
			(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && subName === SettingsViewModel.__rlSettingsData.Route
		);

		if (RoutedSettingsViewModel)
		{
			if (_.find(VIEW_MODELS['settings-removed'], (DisabledSettingsViewModel) => DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel))
			{
				RoutedSettingsViewModel = null;
			}

			if (RoutedSettingsViewModel && _.find(VIEW_MODELS['settings-disabled'],
				(DisabledSettingsViewModel) => DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel))
			{
				RoutedSettingsViewModel = null;
			}
		}

		if (RoutedSettingsViewModel)
		{
			if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
			{
				settingsScreen = RoutedSettingsViewModel.__vm;
			}
			else
			{
				viewModelPlace = this.oViewModelPlace;
				if (viewModelPlace && 1 === viewModelPlace.length)
				{
					settingsScreen = new RoutedSettingsViewModel();

					viewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
					viewModelDom.appendTo(viewModelPlace);

					settingsScreen.viewModelDom = viewModelDom;

					settingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData;

					RoutedSettingsViewModel.__dom = viewModelDom;
					RoutedSettingsViewModel.__builded = true;
					RoutedSettingsViewModel.__vm = settingsScreen;

					const tmpl = {name: RoutedSettingsViewModel.__rlSettingsData.Template};
					ko.applyBindingAccessorsToNode(viewModelDom[0], {
						translatorInit: true,
						template: () => tmpl
					}, settingsScreen);

					delegateRun(settingsScreen, 'onBuild', [viewModelDom]);
				}
				else
				{
					log('Cannot find sub settings view model position: SettingsSubScreen');
				}
			}

			if (settingsScreen)
			{
				_.defer(() => {
					// hide
					if (this.oCurrentSubScreen)
					{
						delegateRun(this.oCurrentSubScreen, 'onHide');
						this.oCurrentSubScreen.viewModelDom.hide();
					}
					// --

					this.oCurrentSubScreen = settingsScreen;

					// show
					if (this.oCurrentSubScreen)
					{
						delegateRun(this.oCurrentSubScreen, 'onBeforeShow');
						this.oCurrentSubScreen.viewModelDom.show();
						delegateRun(this.oCurrentSubScreen, 'onShow');
						delegateRun(this.oCurrentSubScreen, 'onShowWithDelay', [], 200);

						_.each(this.menu(), (item) => {
							item.selected(settingsScreen && settingsScreen.__rlSettingsData && item.route === settingsScreen.__rlSettingsData.Route);
						});

						$('#rl-content .b-settings .b-content .content').scrollTop(0);
					}
					// --

					windowResize();
				});
			}
		}
		else
		{
			setHash(settings(), false, true);
		}
	}
Ejemplo n.º 13
0
	Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
	{
		var
			self = this,
			oScreen = null,
			bSameScreen= false,
			oCross = null
		;

		if ('' === Utils.pString(sScreenName))
		{
			sScreenName = this.sDefaultScreenName;
		}

		if ('' !== sScreenName)
		{
			oScreen = this.screen(sScreenName);
			if (!oScreen)
			{
				oScreen = this.screen(this.sDefaultScreenName);
				if (oScreen)
				{
					sSubPart = sScreenName + '/' + sSubPart;
					sScreenName = this.sDefaultScreenName;
				}
			}

			if (oScreen && oScreen.__started)
			{
				bSameScreen = this.oCurrentScreen && oScreen === this.oCurrentScreen;

				if (!oScreen.__builded)
				{
					oScreen.__builded = true;

					if (Utils.isNonEmptyArray(oScreen.viewModels()))
					{
						_.each(oScreen.viewModels(), function (ViewModelClass) {
							this.buildViewModel(ViewModelClass, oScreen);
						}, this);
					}

					Utils.delegateRun(oScreen, 'onBuild');
				}

				_.defer(function () {

					// hide screen
					if (self.oCurrentScreen && !bSameScreen)
					{
						Utils.delegateRun(self.oCurrentScreen, 'onHide');
						Utils.delegateRun(self.oCurrentScreen, 'onHideWithDelay', [], 500);

						if (self.oCurrentScreen.onHideTrigger)
						{
							self.oCurrentScreen.onHideTrigger(!self.oCurrentScreen.onHideTrigger());
						}

						if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
						{
							_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) {

								if (ViewModelClass.__vm && ViewModelClass.__dom &&
									'Popups' !== ViewModelClass.__vm.viewModelPosition())
								{
									ViewModelClass.__dom.hide();
									ViewModelClass.__vm.viewModelVisibility(false);

									Utils.delegateRun(ViewModelClass.__vm, 'onHide');
									Utils.delegateRun(ViewModelClass.__vm, 'onHideWithDelay', [], 500);

									if (ViewModelClass.__vm.onHideTrigger)
									{
										ViewModelClass.__vm.onHideTrigger(!ViewModelClass.__vm.onHideTrigger());
									}
								}

							});
						}
					}
					// --

					self.oCurrentScreen = oScreen;

					// show screen
					if (self.oCurrentScreen && !bSameScreen)
					{
						Utils.delegateRun(self.oCurrentScreen, 'onShow');
						if (self.oCurrentScreen.onShowTrigger)
						{
							self.oCurrentScreen.onShowTrigger(!self.oCurrentScreen.onShowTrigger());
						}

						Plugins.runHook('screen-on-show', [self.oCurrentScreen.screenName(), self.oCurrentScreen]);

						if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
						{
							_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) {

								if (ViewModelClass.__vm && ViewModelClass.__dom &&
									'Popups' !== ViewModelClass.__vm.viewModelPosition())
								{
									ViewModelClass.__dom.show();
									ViewModelClass.__vm.viewModelVisibility(true);

									Utils.delegateRun(ViewModelClass.__vm, 'onShow');
									if (ViewModelClass.__vm.onShowTrigger)
									{
										ViewModelClass.__vm.onShowTrigger(!ViewModelClass.__vm.onShowTrigger());
									}

									Utils.delegateRun(ViewModelClass.__vm, 'onShowWithDelay', [], 200);

									_.each(ViewModelClass.__names, function (sName) {
										Plugins.runHook('view-model-on-show', [sName, ViewModelClass.__vm]);
									});
								}

							}, self);
						}
					}
					// --

					oCross = oScreen.__cross ? oScreen.__cross() : null;
					if (oCross)
					{
						oCross.parse(sSubPart);
					}
				});
			}
		}
	};
Ejemplo n.º 14
0
				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)
								{
									PgpStore.openpgp.initWorker(Links.openPgpWorkerJs());
								}

//								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));