Example #1
0
	/**
	 * @constructor
	 * @param {RemoteStorage|AdminRemoteStorage} Remote
	 * @extends AbstractBoot
	 */
	function AbstractApp(Remote)
	{
		AbstractBoot.call(this);

		this.isLocalAutocomplete = true;

		this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');

		Globals.$win.on('error', function (oEvent) {
			if (oEvent && oEvent.originalEvent && oEvent.originalEvent.message &&
				-1 === Utils.inArray(oEvent.originalEvent.message, [
					'Script error.', 'Uncaught Error: Error calling method on NPObject.'
				]))
			{
				Remote.jsError(
					Utils.emptyFunction,
					oEvent.originalEvent.message,
					oEvent.originalEvent.filename,
					oEvent.originalEvent.lineno,
					window.location && window.location.toString ? window.location.toString() : '',
					Globals.$html.attr('class'),
					Utils.microtime() - Globals.now
				);
			}
		});

		Globals.$doc.on('keydown', function (oEvent) {
			if (oEvent && oEvent.ctrlKey)
			{
				Globals.$html.addClass('rl-ctrl-key-pressed');
			}
		}).on('keyup', function (oEvent) {
			if (oEvent && !oEvent.ctrlKey)
			{
				Globals.$html.removeClass('rl-ctrl-key-pressed');
			}
		});
	}
	/**
	 * @constructor
	 * @param {RemoteStorage|AdminRemoteStorage} Remote
	 * @extends AbstractBoot
	 */
	function AbstractApp(Remote)
	{
		AbstractBoot.call(this);

		this.isLocalAutocomplete = true;

		this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');

		Globals.$win.on('error', function (oEvent) {
			if (oEvent && oEvent.originalEvent && oEvent.originalEvent.message &&
				-1 === Utils.inArray(oEvent.originalEvent.message, [
					'Script error.', 'Uncaught Error: Error calling method on NPObject.'
				]))
			{
				Remote.jsError(
					Utils.emptyFunction,
					oEvent.originalEvent.message,
					oEvent.originalEvent.filename,
					oEvent.originalEvent.lineno,
					window.location && window.location.toString ? window.location.toString() : '',
					Globals.$html.attr('class'),
					Utils.microtime() - Globals.startMicrotime
				);
			}
		});

		Globals.$win.on('resize', function () {
			Events.pub('window.resize');
		});

		Events.sub('window.resize', _.throttle(function () {

			var
				iH = Globals.$win.height(),
				iW = Globals.$win.height()
			;

			if (Globals.$win.__sizes[0] !== iH || Globals.$win.__sizes[1] !== iW)
			{
				Globals.$win.__sizes[0] = iH;
				Globals.$win.__sizes[1] = iW;

				Events.pub('window.resize.real');
			}

		}, 50));

		 // DEBUG
//		Events.sub({
//			'window.resize': function () {
//				window.console.log('window.resize');
//			},
//			'window.resize.real': function () {
//				window.console.log('window.resize.real');
//			}
//		});

		Globals.$doc.on('keydown', function (oEvent) {
			if (oEvent && oEvent.ctrlKey)
			{
				Globals.$html.addClass('rl-ctrl-key-pressed');
			}
		}).on('keyup', function (oEvent) {
			if (oEvent && !oEvent.ctrlKey)
			{
				Globals.$html.removeClass('rl-ctrl-key-pressed');
			}
		});

		Globals.$doc.on('mousemove keypress click', _.debounce(function () {
			Events.pub('rl.auto-logout-refresh');
		}, 5000));

		key('esc, enter', Enums.KeyState.All, _.bind(function () {
			Utils.detectDropdownVisibility();
		}, this));
	}