var clickEventType; var qaSettings = { id: '64f2ebeb5108133a5dba51c2', link: 'https://api.questadmin.ru/integrations/getIframe?id=64f2ebeb5108133a5dba51c2&style=customStyle&room=64f304745108133a5dba5482', btnColor: true && false ? 'rgb(62, 74, 90)' : 'rgb(94, 106, 121)', btnWavesColor: true && false ? 'rgba(62, 74, 90, 0)' : 'rgb(94, 106, 121)', openWidgetGa: 'undefined', openWidgetYa: 'undefined', yaCounter: 'undefined', addStyle: function() { var style = document.createElement('link'); style.type = "text/css"; style.rel = "stylesheet"; style.href = "https://api.questadmin.ru/styles/integrationToSite.css"; document.getElementsByTagName('head')[0].appendChild(style); }, createWaves: function() { var el = document.createElement('div'); el.style.borderColor = qaSettings.btnWavesColor; el.style.color = qaSettings.btnWavesColor; el.className = 'qWaves'; return el; }, createText: function() { var text = document.createTextNode('Забронировать'), textWrap = document.createElement('div'); textWrap.className = 'tableCell'; textWrap.appendChild(text); return textWrap; }, createButton: function() { var button = document.createElement('a'), wave = qaSettings.createWaves(), text = qaSettings.createText(), lock = document.createElement('div'); button.href = '#'; button.className = 'questBtn'; lock.className = 'qaLock'; lock.style.backgroundColor = qaSettings.btnColor; if (true && false) { lock.appendChild(text); button.style.color = 'rgb(255, 255, 255)'; } else { lock.style.backgroundImage = 'url(https://api.questadmin.ru/images/lock.png)'; lock.style.display = 'block'; } button.appendChild(wave); button.appendChild(lock); button.addEventListener(clickEventType, function(e) { e.preventDefault(); qaSettings.show(); }, false); document.getElementsByTagName('body')[0].appendChild(button); return button; }, createWidgetBlock: function() { var block = document.createElement('div'); block.className = 'qaSettingsBlock'; document.getElementsByTagName('body')[0].appendChild(block); qaSettings.iFrame = qaSettings.createIFrame(); block.appendChild(qaSettings.iFrame); return block; }, createBackground: function() { var bg = document.createElement('div'); bg.className = 'closeBg'; bg.addEventListener(clickEventType, function(e) { e.preventDefault(); qaSettings.hide(); }, false); document.getElementsByTagName('body')[0].appendChild(bg); return bg; }, createIFrame: function() { var iFrame = document.createElement('iframe'); iFrame.className = 'qaSettingsIFrame'; iFrame.setAttribute('frameborder', 0); iFrame.setAttribute('allowtransparency', 'true'); iFrame.src = qaSettings.link; return iFrame; }, createCloseBtn: function() { var button = document.createElement('a'); button.className = 'closeBtn'; button.innerHTML = '×'; button.href = '#'; button.addEventListener(clickEventType, function(e) { e.preventDefault(); qaSettings.hide(); }, false); document.getElementsByTagName('body')[0].appendChild(button); return button; }, init: function() { qaSettings.addStyle(); qaSettings.createButton(); qaSettings.cover = qaSettings.createBackground(); qaSettings.closeIcon = qaSettings.createCloseBtn(); qaSettings.block = qaSettings.createWidgetBlock(); }, show: function(url) { qaSettings.block.style.display = 'block'; qaSettings.cover.style.display = 'block'; qaSettings.closeIcon.style.display = 'block'; if (window['yaCounter' + qaSettings.yaCounter] && qaSettings.openWidgetYa && qaSettings.yaCounter) { console.log('Ya'); window['yaCounter' + qaSettings.yaCounter].reachGoal(qaSettings.openWidgetYa); } if (window['ga'] && qaSettings.openWidgetGa) { console.log('Ga'); ga('send', 'event', qaSettings.openWidgetGa); } return false; }, hide: function() { qaSettings.block.style.display = 'none'; qaSettings.cover.style.display = 'none'; qaSettings.closeIcon.style.display = 'none'; } } document.addEventListener('DOMContentLoaded', function() { clickEventType = ((document.ontouchstart !== null) ? 'click' : 'touchstart'); qaSettings.init(); }, false);