Kcko
12/10/2019 - 12:35 PM

AwOverlay


(function(window, $, undefined) {

if (typeof $ !== 'function') {
	return console.error('AW Overlay: jQuery is missing, load it please');
}

var AWOverlay = function () {
	var inner = {
		self: this,
		initialized: false,
		settings: {},
	};




	this.load = function (settings) {

		$("<link/>", {
		   rel: "stylesheet",
		   type: "text/css",
		   href: "https://aw-overlay.pripravujeme.eu/assets/css/screen.css"
		}).appendTo("head");
		inner.settings = settings;

		// Using YQL and JSONP
		$.ajax({
		    url: "https:\/\/aw-overlay.pripravujeme.eu\/index\/overlay",
		 
		    // The name of the callback parameter, as specified by the YQL service
		    jsonp: "callback",
		 
		    // Tell jQuery we're expecting JSONP
		    dataType: "jsonp",
		 
		    // Tell YQL what we want and that we want JSON
		    data: settings,
		 
		    // Work with the response
		    success: function( response ) {
		        $('body').append(response);

		        if(settings.onLoad)
		        	settings.onLoad(inner.self);
		    }
		});
		
	};

	this.open = function() {
		//e.preventDefault();
		$('.aw-overlay').fadeIn();
		$('#aw-overlay-full').fadeIn();
		$('#aw-overlay-short').fadeOut();
		$('#aw-main-content').addClass('open').removeClass('close');

		//return false;
	};

	this.close = function() {
		$('.aw-overlay').fadeOut();
		$('#aw-overlay-full').fadeOut();
		$('#aw-overlay-short').fadeIn();
		$('#aw-main-content').addClass('close').removeClass('open');
		if(inner.settings.onClose)
			inner.settings.onClose(this);
		//return false;
	};

	this.closeImmediate = function(){
		$('.aw-overlay').hide();
		$('#aw-overlay-full').hide();
		$('#aw-overlay-short').show();
		$('#aw-main-content').addClass('close').removeClass('open');		
	}

};

window.awOverlay = new AWOverlay();


})(window, window.jQuery);
	require(['nette-base-module', 'jquery'], function(init, $) {
		require(['cookies', 'https://aw-overlay.pripravujeme.eu/index/loader'], function(Cookies) {
			$(function(){
				awOverlay.load({
					project: "novato\/novatocz",
					branch: "preprod",
					projectName: "novato.cz",
					versionName: "Klientská akceptační verze",
					versionDescription: "prostředí pro schvalování změn před vystavením do produkční verze",
					database: "6_novato",
					databaseDescription: "testovací databáze, změny v této verzi nemají vliv na produkční data",
					theme: "theme-2",
					onLoad: function(overlay){
						if (overlay && typeof Cookies !== "undefined" && Cookies.get("overlayHidden")) {
							awOverlay.closeImmediate();
						}
					},
					onClose: function(overlay) {
						if(overlay && typeof Cookies !== "undefined") {
							Cookies.set("overlayHidden", true, { path: '/' } );
						}
					}
				});
			});
		});
	});