setTimeout(function() {
var head = document.head || document.getElementsByTagName("head")[0];
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://mssg.me/static/widget/css/styles.css?v=5.20.3';
head.appendChild(link);
var tagline = "Если бы мне платили каждый раз";
var description = "каждый раз, когда я думаю о тебе...";
var mssg_widget = document.createElement("div");
mssg_widget.setAttribute("id", "mssgme_widget");
document.body.appendChild(mssg_widget);
mssg_widget = document.getElementById("mssgme_widget");
setTimeout(function(){
mssg_widget.innerHTML = "
";
var welcome_message_text = "" + tagline + "
" + description + "
";
var mssg_widget_box_text = "";
var widget_popup = document.getElementById("widget_popup");
widget_popup.innerHTML += welcome_message_text;
mssg_widget.innerHTML += mssg_widget_box_text;
var iframeWin = document.querySelector("#mssg_widget_box iframe").contentWindow;
var widget_close = document.getElementById("widget_close");
var welcome_message = document.getElementById("welcome_message");
var widget_circle = document.getElementById("widget_circle");
setTimeout(function() {
if ( getCookie("hide_mssgme_widget") == "yes" ) {
document.getElementById("widget_popup").style.display = "none";
} else {
welcome_message.style.opacity = "1";
}
setTimeout(function() {if (!popup_status() && !circle_status()) {show_popup();}}, 2000);
function setCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
widget_close.onclick = function(e) {
close_popup();
setCookie("hide_mssgme_widget", "yes", 1);
}
welcome_message.onclick = function(e) {
if (e.target != widget_close) {
toggleWidget();
}
};
widget_circle.onclick = function(e) {
toggleWidget();
}
function close_popup() {
var widget_popup = document.getElementById("widget_popup");
widget_popup.style.transform = "translate3d(0,20px,0)";
widget_popup.style.opacity = "0";
widget_popup.style.pointerEvents = "none";
setTimeout(function() {
widget_popup.style.transform = "translate3d(0,0px,0)";
widget_popup.style.zIndex = "-1";
widget_popup.setAttribute("rel", "");
}, 300);
}
function show_popup() {
var widget_popup = document.getElementById("widget_popup");
widget_popup.setAttribute("rel", "active");
widget_popup.style.transform = "translate3d(0,0px,0)";
widget_popup.style.opacity = "1";
widget_popup.style.pointerEvents = "auto";
widget_popup.style.zIndex = "100000";
}
function close_widget() {
var widget_popup = document.getElementById("mssg_widget_box");
widget_popup.style.transform = "translate3d(0,20px,0)";
widget_popup.style.opacity = "0";
widget_popup.style.pointerEvents = "none";
widget_popup.style.zIndex = "-1";
setTimeout(function() {
widget_popup.style.display = "none";
}, 300);
}
function show_widget() {
var widget_popup = document.getElementById("mssg_widget_box");
widget_popup.style.display = "block";
setTimeout(function() {
widget_popup.style.transform = "translate3d(0,0px,0)";
widget_popup.style.opacity = "1";
widget_popup.style.pointerEvents = "auto";
widget_popup.style.zIndex = "100000";
}, 300);
}
function popup_status() {
if (widget_popup.getAttribute("rel") == "active") {
return true;
} else {
return false;
}
}
function circle_status() {
if (widget_circle.getAttribute("rel") == "active") {
return true;
} else {
return false;
}
}
function toggleWidget() {
if (!circle_status()) {
document.getElementById("widget_logo").style.opacity = "0";
document.getElementById("widget_logo").style.transform = "scale(0.5) rotate(-120deg)";
document.getElementById("widget_circle").style.maxWidth = "60px";
setTimeout(function() {
document.getElementById("circle_close").style.opacity = "1";
document.getElementById("circle_close").style.transform = "rotate(0deg) scale(1)";
}, 300);
widget_circle.setAttribute("rel", "active");
close_popup();
show_widget();
iframeWin.postMessage('widget_opened', "*");
} else {
document.getElementById("circle_close").style.opacity = "0";
document.getElementById("circle_close").style.transform = "rotate(120deg) scale(1)";
setTimeout(function() {
document.getElementById("widget_logo").style.opacity = "1";
document.getElementById("widget_logo").style.transform = "scale(1) rotate(0deg)";
document.getElementById("widget_circle").style.maxWidth = "220px";
}, 300);
widget_circle.setAttribute("rel", "");
widget_popup.setAttribute("rel", "active");
close_widget();
}
}
}, 300);
}, 100);
}, 400);