4 var iframe = document.createElement('iframe');
5 iframe.setAttribute('src', '{{{remote}}}/snippet?version=1.0.8&{{{query}}}');
7 iframe.setAttribute('id', 'motion-chat-iframe');
8 iframe.setAttribute('width', window.innerWidth < 350 ? '300px' : '370px');
9 iframe.setAttribute('frameborder', '0');
10 iframe.setAttribute('scrolling', 'no');
11 iframe.setAttribute('style', 'position: fixed; \
17 -webkit-transition: all 0.7s ease-out; \
18 -moz-transition: all 0.7s ease-out; \
19 -ms-transition: all 0.7s ease-out; \
20 -o-transition: all 0.7s ease-out; \
22 transition: all 0.7s ease-out;');
24 document.body.appendChild(iframe);
26 // START Events management
27 window.addEventListener('message', function(evt) {
28 switch (evt.data.cmd) {
30 iframe.style.bottom = '0px';
33 iframe.style.bottom = '-385px';
39 // END Events management
41 // START Proactive action management
42 <% proactiveActions.forEach(function(action) { -%>
43 <% if (action.type == 'timeout') { -%>
44 setTimeout(function() {
45 iframe.style.bottom = '0px';
46 iframe.contentWindow.postMessage({
49 }, <%- action.timeout %> * 1000);
51 <% if (action.type == 'mouseOver') { -%>
52 var elements = document.querySelectorAll("<%- action.selector %>");
54 for (var i = 0; i < elements.length; i++) {
55 elements[i].onmouseover = function() {
56 iframe.style.bottom = '0px';
57 iframe.contentWindow.postMessage({
63 <% }); -%> // END Proactive action management