//***************** START OF jquery.ba-postmessage.js************************ browser = {}; browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase()); browser.safari = /applewebkit/.test(navigator.userAgent.toLowerCase()); if (!browser.safari) { browser.chrome = /webkit/.test(navigator.userAgent.toLowerCase()); } else { browser.chrome = false; } browser.opera = /opera/.test(navigator.userAgent.toLowerCase()); browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); (function ($) { var g, d, j = 1, a, b = this, f = !1, h = "postMessage", e = "addEventListener", c, i = b[h] && !browser.opera; $[h] = function (k, l, m) { if (!l) { return } k = typeof k === "string" ? k : $.param(k); m = m || parent; if (i) { m[h](k, l.replace(/([^:]+:\/\/[^\/]+).*/, "$1")) } else { if (l) { m.location = l.replace(/#.*$/, "") + "#" + (+new Date) + (j++) + "&" + k } } }; $.receiveMessage = c = function (l, m, k) { if (i) { if (l) { a && c(); a = function (n) { if ((typeof m === "string" && n.origin !== m) || ($.isFunction(m) && m(n.origin) === f)) { return f } l(n) } } if (b[e]) { b[l ? e : "removeEventListener"]("message", a, f) } else { b[l ? "attachEvent" : "detachEvent"]("onmessage", a) } } else { g && clearInterval(g); g = null; if (l) { k = typeof m === "number" ? m : typeof k === "number" ? k : 100; g = setInterval(function () { var o = document.location.hash, n = /^#?\d+&/; if (o !== d && n.test(o)) { d = o; l({ data: o.replace(n, "") }) } }, k) } } } })(jQuery); //***************** END OF jquery.ba-postmessage.js************************ //***************** START OF clientCrossDomainFunctions.js************************ var jQSM; var brandLogoHidden = false; var skinName = "Classic"; var chatContainerHeight = 32; var frameHeight = 333; var frameAnimationDuration = 200; var SKIN_CLASSIC = "Classic"; var SKIN_MODERN = "Modern"; var SKIN_AIR = "Air"; var iframeDomain = ""; var popupWin = null; var moveLSWindow = false; var isChatOpened = true; var isDirectChatpage = false; var viewportContentWebsite = ""; var moveLSChatParams = { originalHeight: 0, originalWidth: 0, moveHeightWhenEmoticonsOpen: 20//the height of the move container, when emoticons are open, so the move div does not interfere with the emoticons div }; if (jqSMAvailable) { jQSM = jQuery; } else { jQSM = jQuery.noConflict(); } if (skin == SKIN_MODERN) { skinName = "Modern"; moveLSChatParams.moveHeightWhenEmoticonsOpen = 18;//the height of the move container, when emoticons are open, so the move div does not interfere with the emoticons div } else if (skin == SKIN_AIR) { skinName = "Air"; moveLSChatParams.moveHeightWhenEmoticonsOpen = 18;//the height of the move container, when emoticons are open, so the move div does not interfere with the emoticons div } var parentFunctions = { restrictedByCountry: false, isShowAsPopupOnly: false, chatWidth: 380, chatHeight: 440, accId: "", lng: "", originalUri: "", isEmoticonsOpen: false, initPopupWindowParams: function (chatWidth, chatHeight, accId, lng, originalUri) { this.chatWidth = chatWidth; this.chatHeight = chatHeight; this.accId = accId; this.lng = lng; this.originalUri = originalUri; }, popupChat: function (openedChatModernSkinWidth, openedChatModernSkinHeight, _isDirectChatpage) { if (this.isShowAsPopupOnly || this.restrictedByCountry) { return; } var liveSupportiChatContainer = jQSM(".chatContainer"); if (skinName == SKIN_CLASSIC) { liveSupportiChatContainer.css("box-shadow", "none"); liveSupportiChatContainer.css("-webkit-box-shadow", "none"); liveSupportiChatContainer.css("-moz-box-shadow", "none"); jQSM(".livesupporti-transparent").css("display", "none"); } else if (skinName == SKIN_MODERN) { liveSupportiChatContainer.css("box-shadow", "rgba(0, 0, 0, 0.26) 0px 0.2em 1em"); liveSupportiChatContainer.css("-webkit-box-shadow", "rgba(0, 0, 0, 0.26) 0px 0.2em 1em"); liveSupportiChatContainer.css("-moz-box-shadow", "rgba(0, 0, 0, 0.26) 0px 0.2em 1em"); jQSM(".livesupporti-transparent").css("display", "block"); } else if (skinName == SKIN_AIR) { liveSupportiChatContainer.css("box-shadow", "rgba(0, 0, 0, 0.26) 0px 0.2em 1em"); liveSupportiChatContainer.css("-webkit-box-shadow", "rgba(0, 0, 0, 0.26) 0px 0.2em 1em"); liveSupportiChatContainer.css("-moz-box-shadow", "rgba(0, 0, 0, 0.26) 0px 0.2em 1em"); jQSM(".livesupporti-transparent").css("display", "block"); } jQSM("#LiveSupportiMainFrame").css("display", "block"); if (_isDirectChatpage && _isDirectChatpage != "undefined" && _isDirectChatpage == "true") { isDirectChatpage = true; if (!isMobileDeviceLS) { positionChatBoxInCenter(openedChatModernSkinWidth, openedChatModernSkinHeight); } } jQSM("#divClosedChatBarImage").css("display", "none"); if (!jQSM(".chatContainer").is(":visible")) { jQSM(".chatContainer").css("display", "block"); } if (!isInPopup) { jQSM("#chatMoveContainer").css("display", "block"); if (moveLSChatParams.originalHeight == 0) { moveLSChatParams.originalHeight = jQSM("#chatMoveContainer").height(); } if (moveLSChatParams.originalWidth == 0) { moveLSChatParams.originalWidth = jQSM("#chatMoveContainer").width(); } frameHeight = openedChatModernSkinHeight; frameAnimationDuration = 0; liveSupportiChatContainer.css("bottom", "20px"); var lsOpenedWidth = openedChatModernSkinWidth; var lsOpenedHeight = openedChatModernSkinHeight; if (skinName == SKIN_CLASSIC) { // 16px = box-shadow lsOpenedWidth = (parseInt(openedChatModernSkinWidth) + 16); // 60px = 40px place for agent photo + 20px for box-shadow on chatMainDiv lsOpenedHeight = (parseInt(openedChatModernSkinHeight) + 60); liveSupportiChatContainer.css("bottom", "10px"); } liveSupportiChatContainer[0].style.removeProperty("width"); liveSupportiChatContainer[0].style.setProperty("width", lsOpenedWidth + "px", "important"); liveSupportiChatContainer[0].style.removeProperty("height"); liveSupportiChatContainer[0].style.setProperty("height", lsOpenedHeight + "px", "important"); moveLSChatParams.originalWidth = (lsOpenedWidth - 55); jQSM("#chatMoveContainer").css("width", moveLSChatParams.originalWidth + "px"); var previousTop = jQSM(".chatContainer").attr("prevtop"); var previousLeft = jQSM(".chatContainer").attr("prevleft"); if (typeof (previousTop) != "undefined" && previousTop.length > 0) { jQSM(".chatContainer").css("top", previousTop + "px"); } if (typeof (previousLeft) != "undefined" && previousLeft.length > 0) { jQSM(".chatContainer").css("left", previousLeft + "px"); } } else { jQSM("#chatMoveContainer").css("display", "none"); } jQSM("#LiveSupportiMainFrame").attr("class", "chatMainFrameOpened"); if (skinName == SKIN_CLASSIC) { jQSM(".livesupporti-transparent").css("display", "none"); jQSM("#chatMoveContainer").css("top", "40px"); } else if (skinName == SKIN_MODERN) { } else if (skinName == SKIN_AIR) { } if (!brandLogoHidden) { jQSM("div.linkHolder").fadeIn(); } if (!isMobileDeviceLS) { this.checkChatWindowBounds(); } else { var viewport = document.querySelector("meta[name=viewport]"); if (viewport != null) { viewportContentWebsite = viewport.getAttribute("content"); viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'); } if (_isDirectChatpage == "false" && document.body.className.indexOf("livesupporti-body-touch") == -1) { document.body.className += " " + "livesupporti-body-touch"; } liveSupportiChatContainer[0].style.removeProperty("width"); liveSupportiChatContainer[0].style.setProperty("width", "100%", "important"); liveSupportiChatContainer[0].style.removeProperty("height"); liveSupportiChatContainer[0].style.setProperty("height", "100%", "important"); liveSupportiChatContainer[0].style.removeProperty("top"); liveSupportiChatContainer[0].style.setProperty("top", "0px", "important"); liveSupportiChatContainer[0].style.removeProperty("right"); liveSupportiChatContainer[0].style.setProperty("right", "0px", "important"); liveSupportiChatContainer[0].style.removeProperty("left"); liveSupportiChatContainer[0].style.setProperty("left", "0px", "important"); jQSM("#chatMoveContainer").css("display", "none"); jQSM("div.linkHolder").css("bottom", "0px"); var currentLocation = jQSM("#LiveSupportiMainFrame").attr("src"); var scriptPrefix = ""; if (currentLocation.indexOf("https://") != -1) { scriptPrefix = "https://"; } else { scriptPrefix = "http://"; } var ifrDomain = currentLocation.substring(scriptPrefix.length); ifrDomain = ifrDomain.split('/')[0]; //get domain name only ifrDomain = scriptPrefix + ifrDomain; jQSM.postMessage( "setChatBoxOnFullScreen", ifrDomain, document.getElementById('LiveSupportiMainFrame').contentWindow ); } }, closeChat: function (closedChatModernSkinWidth, closedChatModernSkinHeight, closedChatShowImage, closedChatImageFile, closedChatImageMarginLeft, closedChatImageMarginTop, closedChatImageWidth, closedChatImageInFront, closedChatImageOnly, closedChatSideOffset) { if (this.isShowAsPopupOnly || this.restrictedByCountry) { return; } if (isMobileDeviceLS) { var viewport = document.querySelector("meta[name=viewport]"); if (viewport != null) { viewport.setAttribute('content', viewportContentWebsite); } document.body.className = document.body.className.replace("livesupporti-body-touch", ""); } var liveSupportiChatContainer = jQSM(".chatContainer"); jQSM("#chatMoveContainer").css("display", "none"); frameHeight = closedChatModernSkinHeight; frameAnimationDuration = 0; liveSupportiChatContainer[0].style.removeProperty("width"); liveSupportiChatContainer[0].style.setProperty("width", closedChatModernSkinWidth + "px", "important"); liveSupportiChatContainer[0].style.removeProperty("height"); liveSupportiChatContainer[0].style.setProperty("height", closedChatModernSkinHeight + "px", "important"); liveSupportiChatContainer.css("bottom", "0px"); liveSupportiChatContainer.css("right", closedChatSideOffset + "px"); if (closedChatShowImage != "") { showEyeCatcher(closedChatShowImage, accId, closedChatImageFile, closedChatImageMarginLeft, closedChatImageMarginTop, closedChatImageWidth, closedChatImageInFront, closedChatImageOnly, liveSupportiChatContainer); } else { jQSM("#divClosedChatBarImage").css("display", "none"); } jQSM("div.linkHolder").hide(); jQSM("#LiveSupportiMainFrame").attr("class", "chatMainFrameClosed"); jQSM(".chatContainer").css("top", ""); jQSM(".chatContainer").css("left", ""); if (jQSM(".chatContainer").attr("position") == "left") { this.showOnLeftSide(closedChatSideOffset); } }, setChatContainerWidthHeight: function (openedChatModernSkinWidth, openedChatModernSkinHeight, closedChatModernSkinWidth, closedChatModernSkinHeight, closedChatAnimation, closedChatShowImage, closedChatImageFile, closedChatImageMarginLeft, closedChatImageMarginTop, closedChatImageWidth, closedChatImageInFront, closedChatImageOnly, closedChatSideOffset) { if (isChatOpened) { var liveSupportiChatContainer = jQSM(".chatContainer"); var lsOpenedWidth = openedChatModernSkinWidth; var lsOpenedHeight = openedChatModernSkinHeight; if (skinName == SKIN_CLASSIC) { // 16px = box-shadow lsOpenedWidth = (parseInt(openedChatModernSkinWidth) + 16); // 60px = 40px place for agent photo + 20px for box-shadow on chatMainDiv lsOpenedHeight = (parseInt(openedChatModernSkinHeight) + 60); } liveSupportiChatContainer[0].style.removeProperty("width"); liveSupportiChatContainer[0].style.setProperty("width", lsOpenedWidth + "px", "important"); liveSupportiChatContainer[0].style.removeProperty("height"); liveSupportiChatContainer[0].style.setProperty("height", lsOpenedHeight + "px", "important"); moveLSChatParams.originalWidth = (lsOpenedWidth - 55); jQSM("#chatMoveContainer").css("width", moveLSChatParams.originalWidth + "px"); if (isDirectChatpage && !isMobileDeviceLS) { positionChatBoxInCenter(openedChatModernSkinWidth, openedChatModernSkinHeight); } } else { if (!(jQSM(".chatContainer").attr("position") == "left")) { liveSupportiChatContainer.css("right", closedChatSideOffset + "px"); } if (closedChatShowImage != "") { showEyeCatcher(closedChatShowImage, accId, closedChatImageFile, closedChatImageMarginLeft, closedChatImageMarginTop, closedChatImageWidth, closedChatImageInFront, closedChatImageOnly, liveSupportiChatContainer); } else { jQSM("#divClosedChatBarImage").css("display", "none"); } } }, checkChatWindowBounds: function () { if (!isInPopup) { var previousTop = jQSM(".chatContainer").attr("prevtop"); if (jQSM("#chatMoveContainer").css("display") != "none" && typeof (previousTop) != "undefined" && previousTop.length > 0) { var maxTop = jQSM(window).height() - jQSM(".chatContainer").outerHeight(); var maxLeft = jQSM(window).width() - jQSM(".chatContainer").outerWidth(); var actualTop = jQSM(".chatContainer").position().top; var actualLeft = jQSM(".chatContainer").position().left; if (actualTop > maxTop && maxTop >= 0) { jQSM(".chatContainer").css("top", maxTop + "px"); } if (actualLeft > maxLeft) { jQSM(".chatContainer").css("left", maxLeft + "px"); } } } }, restoreChatCustomPosition: function (top, left, _isDirectChatpage) { if (_isDirectChatpage == "false") { jQSM(".chatContainer").attr("prevtop", top); jQSM(".chatContainer").attr("prevleft", left); } }, openInPopup: function (chatWidth, chatHeight, accId, lng, originalUri) { if (this.restrictedByCountry) { return; } if (popupWin == null || popupWin.closed) { var scriptUri = "../js/client.js"; scriptUri += "?skin=" + skinName; scriptUri += "&acc=" + accId; if (lng.length > 0) { scriptUri += "&lng=" + lng; } scriptUri += isInTestMode + "&popupOnly=true&random=1&popup=true&originalUri=" + originalUri; var currentUriPath = jQSM("#LiveSupportiMainFrame").attr("src"); currentUriPath = currentUriPath.substring(0, currentUriPath.indexOf("clientGUI")); var popupPositioning = ""; if (screen && screen.height && screen.width) { var left = (screen.width / 2) - (chatWidth / 2); var top = (screen.height / 2) - (chatHeight / 2); popupPositioning = ", left=" + left + ", top=" + top; } popupWin = window.open("", "LiveSupporti chat", 'height=' + chatHeight + ',width=' + chatWidth + popupPositioning + ', directories=no, status=no, menubar=no, resizable=no, toolbar=no, scrollbars=no'); popupWin.document.write("LiveSupporti chat" + ""); } else { popupWin.focus(); } }, focusPopupWindow: function () { if (window.opener && !window.opener.closed && window.opener.focusChildPopupWindow) { window.opener.focusChildPopupWindow(); } }, popupWindowInitialized: function() { if (isInPopup) { var liveSupportiChatContainer = jQSM(".chatContainer"); liveSupportiChatContainer[0].style.removeProperty("width"); liveSupportiChatContainer[0].style.setProperty("width", "100%", "important"); liveSupportiChatContainer[0].style.removeProperty("height"); liveSupportiChatContainer[0].style.setProperty("height", "100%", "important"); liveSupportiChatContainer[0].style.removeProperty("top"); liveSupportiChatContainer[0].style.setProperty("top", "0px", "important"); liveSupportiChatContainer[0].style.removeProperty("right"); liveSupportiChatContainer[0].style.setProperty("right", "0px", "important"); liveSupportiChatContainer[0].style.removeProperty("left"); liveSupportiChatContainer[0].style.setProperty("left", "0px", "important"); jQSM("#chatMoveContainer").css("display", "none"); var currentLocation = jQSM("#LiveSupportiMainFrame").attr("src"); var scriptPrefix = ""; if (currentLocation.indexOf("https://") != -1) { scriptPrefix = "https://"; } else { scriptPrefix = "http://"; } var ifrDomain = currentLocation.substring(scriptPrefix.length); ifrDomain = ifrDomain.split('/')[0]; //get domain name only ifrDomain = scriptPrefix + ifrDomain; jQSM.postMessage( "setChatBoxOnFullScreen", ifrDomain, document.getElementById('LiveSupportiMainFrame').contentWindow ); window.addEventListener("resize", function () { jQSM.postMessage( "setChatMessageContainerHeightInPopupWindow$" + window.innerHeight, ifrDomain, document.getElementById('LiveSupportiMainFrame').contentWindow ); }); } }, showChatBar: function () { if (this.isShowAsPopupOnly || this.restrictedByCountry) { return; } if (!jQSM(".chatContainer").is(":visible")) { jQSM(".chatContainer").css("display", "block"); } }, showChatBarAnimation: function (closedChatModernSkinWidth, closedChatModernSkinHeight, closedChatAnimation, closedChatShowImage, closedChatImageFile, closedChatImageMarginLeft, closedChatImageMarginTop, closedChatImageWidth, closedChatImageInFront, closedChatImageOnly, closedChatSideOffset) { if (this.isShowAsPopupOnly || this.restrictedByCountry) { return; } isChatOpened = false; jQSM(".chatContainer").css("display", "block").css("height", "0px"); var liveSupportiChatContainer = jQSM(".chatContainer"); liveSupportiChatContainer[0].style.removeProperty("width"); liveSupportiChatContainer[0].style.setProperty("width", closedChatModernSkinWidth + "px", "important"); liveSupportiChatContainer[0].style.removeProperty("height"); liveSupportiChatContainer[0].style.setProperty("height", closedChatModernSkinHeight + "px", "important"); liveSupportiChatContainer.css("bottom", "0px"); if (!(jQSM(".chatContainer").attr("position") == "left")) { liveSupportiChatContainer.css("right", closedChatSideOffset + "px"); } if (closedChatShowImage != "") { showEyeCatcher(closedChatShowImage, accId, closedChatImageFile, closedChatImageMarginLeft, closedChatImageMarginTop, closedChatImageWidth, closedChatImageInFront, closedChatImageOnly, liveSupportiChatContainer); } var closedChat = jQSM(".chatContainer"); if (closedChatAnimation != "") { closedChatAnimation += ' animated'; var animationEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend"; closedChat.addClass(closedChatAnimation).one(animationEnd, function () { closedChat.removeClass(closedChatAnimation); }); } jQSM("div.linkHolder").hide(); }, hideChatBar: function () { jQSM(".chatContainer").css("display", "none"); }, styleTransparentBackground: function (color1, color2, opacity) { jQSM("div.chatContainer div.livesupporti-transparent").css("filter", "").css("background-image", "").css("background-color", "").css("background", ""); var currentBarStyle; if (skinName == SKIN_AIR) { jQSM("div.chatContainer div.livesupporti-transparent").css("background-color", "#FFFFFF"); currentBarStyle = jQSM("div.chatContainer div.livesupporti-transparent").attr("style"); currentBarStyle += ";background: linear-gradient(to bottom, " + "#FFFFFF" + ", " + "#FFFFFF" + ");" + "filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='" + "#FFFFFF" + "', endColorstr='" + "#FFFFFF" + "');" + "background: -webkit-gradient(linear, left top, left bottom, from(" + "#FFFFFF" + "), to(" + "#FFFFFF" + "));" + "background: -moz-linear-gradient(top, " + "#FFFFFF" + ", " + "#FFFFFF" + ");" + "background: -ms-linear-gradient(top, " + "#FFFFFF" + ", " + "#FFFFFF" + ");"; } else { jQSM("div.chatContainer div.livesupporti-transparent").css("background-color", color2); currentBarStyle = jQSM("div.chatContainer div.livesupporti-transparent").attr("style"); currentBarStyle += ";background: linear-gradient(to bottom, " + color1 + ", " + color2 + ");" + "filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='" + color1 + "', endColorstr='" + color2 + "');" + "background: -webkit-gradient(linear, left top, left bottom, from(" + color1 + "), to(" + color2 + "));" + "background: -moz-linear-gradient(top, " + color1 + ", " + color2 + ");" + "background: -ms-linear-gradient(top, " + color1 + ", " + color2 + ");"; } jQSM("div.chatContainer div.livesupporti-transparent").attr("style", currentBarStyle); jQSM("div.chatContainer div.livesupporti-transparent").css("opacity", opacity); }, forward: function (url) { window.location.href = unescape(url); }, hideBrandLogo: function () { jQSM("div.linkHolder").hide(); brandLogoHidden = true; }, showOnLeftSide: function (closedChatSideOffset) { if (!isDirectChatpage) { jQSM(".chatContainer").attr("position", "left"); jQSM(".chatContainer").css("left", closedChatSideOffset + "px"); jQSM(".chatContainer").css("right", ""); } }, showAsPopupOnly: function () { this.isShowAsPopupOnly = true; this.hideChatBar(); }, visitorRestrictedByCountry: function (redirectURI) { this.restrictedByCountry = true; this.hideChatBar(); //Check for redirect if (typeof redirectURI != "undefined" && redirectURI.length > 0) { this.forward(redirectURI); } }, visitorNotRestrictedByCountry: function () { this.restrictedByCountry = false; }, emoticonsOpen: function () { this.isEmoticonsOpen = true; if (moveLSChatParams.originalHeight == 0) { moveLSChatParams.originalHeight = jQSM("#chatMoveContainer").height(); } if (moveLSChatParams.originalWidth == 0) { moveLSChatParams.originalWidth = jQSM("#chatMoveContainer").width(); } jQSM("#chatMoveContainer").css("height", moveLSChatParams.moveHeightWhenEmoticonsOpen + "px"); }, emoticonsClosed: function () { this.isEmoticonsOpen = false; jQSM("#chatMoveContainer").css("height", moveLSChatParams.originalHeight + "px"); }, getShopifyCart: function () { jQSM.getJSON('/cart.js', function (cart) { invokeChatFrameFunction("setShopifyCart$" + JSON.stringify(cart)); }); } } jQSM.receiveMessage( function (e) { //this is a fix because of the new way we send LocalStorage data between iframe and parent page and back. //Only string data sent trough postMessage should be evale-d here. //this should be ultimately rewritten, so that we get rid of the 3rd party postMessage plugin. if (typeof e.data === "string"){ eval("parentFunctions." + e.data); } }, scriptDomain ); function hookUpChatOpeners() { jQSM(".popupLiveSupportiChat, a[href=\\#popupLiveSupportiChat]").unbind("click").click( function (e) { e.stopPropagation(); e.preventDefault(); parentFunctions.openInPopup(parentFunctions.chatWidth, parentFunctions.chatHeight, parentFunctions.accId, parentFunctions.lng, parentFunctions.originalUri); } ); jQSM(".openLiveSupportiChat, a[href=\\#openLiveSupportiChat]").unbind("click").click( function (e) { e.stopPropagation(); e.preventDefault(); invokeChatFrameFunction("openChat$false"); } ); } function positionChatBoxInCenter(openedChatModernSkinWidth, openedChatModernSkinHeight) { var windowWidth = jQSM(window.top).width(); var windowHeight = jQSM(window.top).height(); var chatContainerRightPosition = (windowWidth - openedChatModernSkinWidth) / 2; var chatContainerTopPosition = (windowHeight - openedChatModernSkinHeight) / 2; jQSM(".chatContainer").css("top", chatContainerTopPosition + "px"); jQSM(".chatContainer").css("right", chatContainerRightPosition + "px"); jQSM(".chatContainer").css("left", ""); } function showEyeCatcher(closedChatShowImage, accId, closedChatImageFile, closedChatImageMarginLeft, closedChatImageMarginTop, closedChatImageWidth, closedChatImageInFront, closedChatImageOnly, liveSupportiChatContainer) { var currentUriPath = jQSM("#LiveSupportiMainFrame").attr("src"); currentUriPath = currentUriPath.substring(0, currentUriPath.indexOf("clientGUI")); if (closedChatShowImage == "custom") { jQSM("#imgClosedChatBarImage").attr("src", currentUriPath + "../Eyecatchers/" + accId + "/" + closedChatImageFile); } else { jQSM("#imgClosedChatBarImage").attr("src", currentUriPath + "../Images/Chat/eye-catchers/" + closedChatImageFile + ".png"); } jQSM("#imgClosedChatBarImage").css("position", "absolute"); jQSM("#imgClosedChatBarImage").css("top", "0px"); jQSM("#imgClosedChatBarImage").css("left", "50%"); jQSM("#imgClosedChatBarImage").css("display", "block"); jQSM("#imgClosedChatBarImage").css("margin-left", closedChatImageMarginLeft + "px"); jQSM("#imgClosedChatBarImage").css("margin-top", closedChatImageMarginTop + "px"); jQSM("#imgClosedChatBarImage").css("width", closedChatImageWidth + "px"); jQSM("#imgClosedChatBarImage").css("max-width", closedChatImageWidth + "px"); jQSM("#imgClosedChatBarImage").css("max-height", "none"); jQSM("#imgClosedChatBarImage").css("cursor", "pointer"); if (closedChatImageInFront == "true") { jQSM("#imgClosedChatBarImage").css("z-index", "1000001"); } else { jQSM("#imgClosedChatBarImage").css("z-index", ""); } jQSM("#divClosedChatBarImage").css("display", "block"); if (closedChatImageOnly == "true") { liveSupportiChatContainer.css("box-shadow", "none"); liveSupportiChatContainer.css("-webkit-box-shadow", "none"); liveSupportiChatContainer.css("-moz-box-shadow", "none"); jQSM("#divClosedChatBarImage").css("z-index", "1000001"); jQSM("#divClosedChatBarImage").css("position", "absolute"); jQSM("#divClosedChatBarImage").css("bottom", "0px"); jQSM("#divClosedChatBarImage").css("left", "124px"); jQSM(".livesupporti-transparent").css("display", "none"); jQSM("#LiveSupportiMainFrame").css("display", "none"); } } jQSM(document).ready(function () { jQSM(window).mousemove(function () { //this is a hack to get the actual focus state, because the first time a page loads - it does not give info about its focused state. if (typeof (document.getElementById('LiveSupportiMainFrame').contentWindow) != "undefined") { invokeChatFrameFunction("parentPageFocused"); jQSM(window).unbind('mousemove');//unbind, after we are sure we are focused for the first time. } }); jQSM(window).focus(function () { invokeChatFrameFunction("parentPageFocused"); }).blur(function () { invokeChatFrameFunction("parentPageBlurred"); }); jQSM(window).keyup(function () { invokeChatFrameFunction("parentPageFocused"); }); hookUpChatOpeners(); var currentLocation = jQSM("#LiveSupportiMainFrame").attr("src"); var scriptPrefix = ""; if (currentLocation.indexOf("https://") != -1) { scriptPrefix = "https://"; } else { scriptPrefix = "http://"; } iframeDomain = currentLocation.substring(scriptPrefix.length); iframeDomain = iframeDomain.split('/')[0]; //get domain name only iframeDomain = scriptPrefix + iframeDomain; /** Move chat on drag - begin **/ jQSM("#chatMoveContainer").mousedown(function (clickEvent) { clickEvent.stopPropagation(); moveLSWindow = true; jQSM(".chatContainer").css("position", "fixed"); if (moveLSChatParams.originalHeight == 0) { moveLSChatParams.originalHeight = jQSM("#chatMoveContainer").height(); } if (moveLSChatParams.originalWidth == 0) { moveLSChatParams.originalWidth = jQSM("#chatMoveContainer").width(); } jQSM("#chatMoveContainer").css("height", "100%"); jQSM("#chatMoveContainer").css("width", "100%");//this is done, to cover up the iframe temporarily, because if the mouse gets over the iframe content, all events are lost! moveLSChatParams.correctionX = jQSM(".chatContainer").position().left - clickEvent.clientX; moveLSChatParams.correctionY = jQSM(".chatContainer").position().top - clickEvent.clientY; moveLSChatParams.maxTop = jQSM(window).height() - jQSM(".chatContainer").outerHeight(); moveLSChatParams.maxLeft = jQSM(window).width() - jQSM(".chatContainer").outerWidth(); jQSM("body").unbind("mousemove");//just in case, so we don't have it twice! jQSM("body").mousemove(function (e) { if (moveLSWindow) { e.stopPropagation(); var newLeft = e.clientX + moveLSChatParams.correctionX; var newTop = e.clientY + moveLSChatParams.correctionY; if (newLeft >= 0 && newLeft <= moveLSChatParams.maxLeft) { jQSM(".chatContainer").css("left", newLeft); } if (newTop >= 0 && newTop <= moveLSChatParams.maxTop) { jQSM(".chatContainer").css("top", newTop); } } }); }); jQSM("body").mouseup(function () { if (moveLSWindow) { moveLSWindow = false; jQSM("body").unbind("mousemove"); if (parentFunctions.isEmoticonsOpen) { jQSM("#chatMoveContainer").css("height", moveLSChatParams.moveHeightWhenEmoticonsOpen + "px"); } else { jQSM("#chatMoveContainer").css("height", moveLSChatParams.originalHeight + "px"); } jQSM("#chatMoveContainer").css("width", moveLSChatParams.originalWidth + "px"); jQSM(".chatContainer").attr("prevtop", jQSM(".chatContainer").position().top); jQSM(".chatContainer").attr("prevleft", jQSM(".chatContainer").position().left); invokeChatFrameFunction("saveWinPosition$" + jQSM(".chatContainer").position().top + "#" + jQSM(".chatContainer").position().left); } }); jQSM("#chatMoveContainer").css("display", "none"); jQSM(window).resize(function () { parentFunctions.checkChatWindowBounds(); }); /** Move chat on drag - end **/ jQSM("#divClosedChatBarImage").click(function () { invokeChatFrameFunction("openChat$false"); }); }); function invokeChatFrameFunction(functionName) { document.getElementById('LiveSupportiMainFrame').addEventListener("load", postMessageToLSiFrame(functionName)); } function postMessageToLSiFrame(functionName) { jQSM.postMessage( functionName, iframeDomain, document.getElementById('LiveSupportiMainFrame').contentWindow ); } //***************** END OF clientCrossDomainFunctions.js************************