Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created December 4, 2019 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kcko/ecee5539537120e383940d7e87f76a26 to your computer and use it in GitHub Desktop.
Save Kcko/ecee5539537120e383940d7e87f76a26 to your computer and use it in GitHub Desktop.
var rescueModal = (function(){
$(document).ready(function() {
var modalShow = sessionStorage.getItem('rescue-modal') || 0;
console.log(document.location);
if (modalShow)
return;
$('head').append('<link rel="stylesheet" href="http://vhgastro-modal.r.dev.andweb.cz/rescue-modal.css" type="text/css" />');
var recenter = function() {
var modalWrapper = $('.modal-wrapper');
var h = modalWrapper.outerHeight(true) / 2;
modalWrapper.css('margin-top', '-' + h + 'px');
};
var modalClose = function() {
modalOverlay.hide();
modalWrapper.hide()
};
var modalOverlay = $('<div class="modal-overlay"></div>');
var modalWrapper = $('<div class="modal-wrapper"></div>');
var htmlTpl = "<h1>Důležité upozornění</h1> \
<p>Náš e-shop právě prochází rozsáhlou rekonstrukcí. Uvedené ceny a dostupnosti u produktů jsou proto pouze orientační.</p> \
<p>Pro ověření Vaší objednávky nás kontaktujte na e-mailu: <a href=''mailto:info@vhgastro.cz'>info@vhgastro.cz</a>, nebo na telefonním čísle: +<b>420 603 256 194</b>.</p> \
<p>Děkujeme za pochopení.</p> \
<p>Tým HOFMANN Strakonice s.r.o.</p> \
<a class='btn-navigation active'>&times; Zavřít</a> \
";
modalWrapper.html(htmlTpl);
modalOverlay.hide().prependTo(document.body);
modalWrapper.hide().prependTo(document.body);
modalWrapper.find('a.btn-navigation').on('click', function(e){
modalClose();
});
setTimeout(function(){
recenter();
modalOverlay.show();
modalWrapper.show();
}, 500);
sessionStorage.setItem('rescue-modal', 1);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment