Skip to content

Commit 723484b

Browse files
Merge pull request #1468 from Kommunicate-io/HrithikKrishna56-patch-2
Updated the script for full screen chat widget
2 parents bb49f6f + 0e558ea commit 723484b

1 file changed

Lines changed: 24 additions & 28 deletions

File tree

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
1+
<!-- Working:
2+
1. Create a <div> on your page and assign it an ID (e.g., widget-container)
3+
2. Set the desired width and height on that div
4+
3. Pass the div ID into the Kommunicate settings via the containerId parameter and replace App-Id with your actual App Id
5+
4. The chat widget will automatically take the dimensions of the div and open on page load -->
6+
17
<!DOCTYPE html>
2-
<html lang="en">
8+
<html>
9+
310
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7-
<title>Kommunicate Script</title>
11+
<meta charset="UTF-8" />
12+
<title>Kommunicate Container Test</title>
813
</head>
14+
915
<body>
16+
17+
<!-- Custom Container -->
18+
<div id="widget-container" style="width: 700px; height: 600px; border: 1px solid #ccc;">
19+
</div>
1020
<script type="text/javascript">
11-
(function(d, m){
12-
var kommunicateSettings = {"appId":"1c59bc4cac28d23cd3c21c876e60be920","conversationTitle":"Vibhor Sharma",
13-
"onInit": function() {
14-
var iframeStyle = document.createElement('style');
15-
var classSettings = ".change-kommunicate-iframe-height{height:100%!important;width:100%!important;right:0!important;bottom:0!important;max-height: 100%!important;}";
16-
iframeStyle.type = 'text/css';
17-
iframeStyle.innerHTML = classSettings;
18-
document.getElementsByTagName('head')[0].appendChild(iframeStyle);
19-
var launcherIconStyle = "@media(min-width: 510px){.mck-sidebox.fade.in,.mck-box .mck-box-sm{width:100%; height:100%;max-height:100%!important;border-radius:0px!important;}.mck-sidebox{right:0!important;bottom:0!important;}}";
20-
Kommunicate.customizeWidgetCss(launcherIconStyle);
21-
var iframe = window.top.document.getElementsByTagName("iframe")[0];
22-
var addClassToIframe = iframe.contentDocument.getElementById("kommunicate-widget-iframe");
23-
addClassToIframe.classList.add("change-kommunicate-iframe-height");
24-
KommunicateGlobal.document.getElementById('km-chat-widget-close-button').addEventListener('click',function(){
25-
var closeButtonClick = parent.document.getElementById("kommunicate-widget-iframe");
26-
closeButtonClick.classList.add("change-kommunicate-iframe-height");
27-
});
28-
}
29-
};
30-
var s = document.createElement("script"); s.type = "text/javascript"; s.async = true;
31-
s.src = "https://widget.kommunicate.io/v2/kommunicate.app";
32-
var h = document.getElementsByTagName("head")[0]; h.appendChild(s);
33-
window.kommunicate = m; m._globals = kommunicateSettings;
21+
(function (d, m) {
22+
var kommunicateSettings =
23+
{ "appId": "App-Id", "popupWidget": true, "containerId": "widget-container","automaticChatOpenOnNavigation": true };
24+
var s = document.createElement("script"); s.type = "text/javascript"; s.async = true;
25+
s.src = "https://widget.kommunicate.io/kommunicate-widget-3.0.min.js";
26+
var h = document.getElementsByTagName("head")[0]; h.appendChild(s);
27+
window.kommunicate = m; m._globals = kommunicateSettings;
3428
})(document, window.kommunicate || {});
29+
/* NOTE : Use web server to view HTML files as real-time update will not work if you directly open the HTML file in the browser. */
3530
</script>
3631
</body>
32+
3733
</html>

0 commit comments

Comments
 (0)