!function(t,o){"function"==typeof define&&define.amd?define(o):"object"==typeof exports&&(module.exports=o()),t.tingle=o()}(this,function(){function t(t){var o={onClose:null,onOpen:null,beforeOpen:null,beforeClose:null,stickyFooter:!1,footer:!1,cssClass:[],closeLabel:"Close",closeMethods:["overlay","button","escape"]};this.opts=r({},o,t),this.init()}function o(){this.modalBoxFooter&&(this.modalBoxFooter.style.width=this.modalBox.clientWidth+"px",this.modalBoxFooter.style.left=this.modalBox.offsetLeft+"px")}function e(){this.modal=document.createElement("div"),this.modal.classList.add("tingle-modal"),0!==this.opts.closeMethods.length&&-1!==this.opts.closeMethods.indexOf("overlay")||this.modal.classList.add("tingle-modal--noOverlayClose"),this.modal.style.display="none",this.opts.cssClass.forEach(function(t){"string"==typeof t&&this.modal.classList.add(t)},this),-1!==this.opts.closeMethods.indexOf("button")&&(this.modalCloseBtn=document.createElement("button"),this.modalCloseBtn.classList.add("tingle-modal__close"),this.modalCloseBtnIcon=document.createElement("span"),this.modalCloseBtnIcon.classList.add("tingle-modal__closeIcon"),this.modalCloseBtnIcon.innerHTML="×",this.modalCloseBtnLabel=document.createElement("span"),this.modalCloseBtnLabel.classList.add("tingle-modal__closeLabel"),this.modalCloseBtnLabel.innerHTML=this.opts.closeLabel,this.modalCloseBtn.appendChild(this.modalCloseBtnIcon),this.modalCloseBtn.appendChild(this.modalCloseBtnLabel)),this.modalBox=document.createElement("div"),this.modalBox.classList.add("tingle-modal-box"),this.modalBoxContent=document.createElement("div"),this.modalBoxContent.classList.add("tingle-modal-box__content"),this.modalBox.appendChild(this.modalBoxContent),-1!==this.opts.closeMethods.indexOf("button")&&this.modal.appendChild(this.modalCloseBtn),this.modal.appendChild(this.modalBox)}function s(){this.modalBoxFooter=document.createElement("div"),this.modalBoxFooter.classList.add("tingle-modal-box__footer"),this.modalBox.appendChild(this.modalBoxFooter)}function i(){this._events={clickCloseBtn:this.close.bind(this),clickOverlay:l.bind(this),resize:this.checkOverflow.bind(this),keyboardNav:n.bind(this)},-1!==this.opts.closeMethods.indexOf("button")&&this.modalCloseBtn.addEventListener("click",this._events.clickCloseBtn),this.modal.addEventListener("mousedown",this._events.clickOverlay),window.addEventListener("resize",this._events.resize),document.addEventListener("keydown",this._events.keyboardNav)}function n(t){-1!==this.opts.closeMethods.indexOf("escape")&&27===t.which&&this.isOpen()&&this.close()}function l(t){-1!==this.opts.closeMethods.indexOf("overlay")&&!d(t.target,"tingle-modal")&&t.clientX=t},t.prototype.checkOverflow=function(){this.modal.classList.contains("tingle-modal--visible")&&(this.isOverflow()?this.modal.classList.add("tingle-modal--overflow"):this.modal.classList.remove("tingle-modal--overflow"),!this.isOverflow()&&this.opts.stickyFooter?this.setStickyFooter(!1):this.isOverflow()&&this.opts.stickyFooter&&(o.call(this),this.setStickyFooter(!0)))},{modal:t}}); (function (arr) { arr.forEach(function (item) { if (item.hasOwnProperty('before')) { return; } Object.defineProperty(item, 'before', { configurable: true, enumerable: true, writable: true, value: function before() { var argArr = Array.prototype.slice.call(arguments), docFrag = document.createDocumentFragment(); argArr.forEach(function (argItem) { var isNode = argItem instanceof Node; docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); }); this.parentNode.insertBefore(docFrag, this); } }); }); })([Element.prototype, CharacterData.prototype, DocumentType.prototype]); (function(window, document, undefined) { var thatDoc = document; var btnType = 'css'; var pid = '60321'; var pl_id = '1837'; var playerType = 'mini'; var playerVer = '1'; var version = 1; var container_class = (version > 1) ? '.insights-qj1' : '.reviewtube'; var modal_class = 'js-tingle-modal'; var cssId = 'myCss'; if (!document.getElementById(cssId)) { var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.id = cssId; link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'https://www.reviewtube.com/embed/dist/tingle.min.css'; link.media = 'all'; head.appendChild(link); } var font = document.createElement('link'); font.setAttribute('rel', 'stylesheet'); font.setAttribute('type', 'text/css'); font.setAttribute('href', 'https://fonts.googleapis.com/css?family=Lato:400,700'); document.head.appendChild(font); function bindEvent(element, eventName, eventHandler) { if (element.addEventListener){ element.addEventListener(eventName, eventHandler, false); } else if (element.attachEvent) { element.attachEvent('on' + eventName, eventHandler); } } var sheet = (function() { var style = document.createElement("style"); style.appendChild(document.createTextNode("")); document.head.appendChild(style); return style.sheet; })(); var newstylesheet = sheet; newstylesheet.insertRule(container_class + " {width: 100%; position: relative; }", 0); newstylesheet.insertRule(".rtButton {border: 1px solid #ccc; }", 0); newstylesheet.insertRule(container_class + " iframe {position: absolute; width: 100%; height: 100%;}", 0); newstylesheet.insertRule(".tingle-modal { background: rgba(0,0,0,.5); }", 0); newstylesheet.insertRule(".tingle-modal-box__content { padding: 1rem !important; }", 0); newstylesheet.insertRule(".tingle-modal-box { width: 90% }", 0); newstylesheet.insertRule(".tingle-modal__close { font-size: 3rem; right: 15px !important; }", 0); newstylesheet.insertRule("@media only screen and (max-width: 540px) { .tingle-modal-box { width: 100% !important; } }", 0); var tubes = thatDoc.querySelectorAll(container_class), i; for (i = 0; i < tubes.length; ++i) { var vidid = tubes[i].getAttribute("embed"); //console.log(vidid); var viewType = tubes[i].getAttribute("viewType"); var plid = tubes[i].getAttribute("embedPL"); //var rtURL = "https://www.reviewtube.com/embed/insights_combined.php?type="+playerType+"&pid="+vidid+"&pl_id="+plid; var url = 'https://www.reviewtube.com/embed/insights_combined.php'; if(playerVer == '2') url = 'https://www.reviewtube.com/player_v2/'; var rtURL = url+'?type='+playerType+'&pid='+vidid+'&pl_id='+plid; if ( viewType == "modal" ) { if ( btnType == "css") { var btnOption = ''; var btnOne = document.createElement('div'); btnOne.setAttribute("id", "btnOption"); btnOne.innerHTML = btnOption; document.body.appendChild(btnOne); //var referenceNode = document.querySelector('.reviewtube'); var referenceNode = document.querySelector(container_class); //container_class must be unique to avoid duplicates when embedding multiple scripts referenceNode.before(btnOne); var btnModal1 = document.querySelector('.'+modal_class); btnModal1.addEventListener('click', function(){ var modalSurprise = new tingle.modal({ onClose: function(){ modalSurprise.destroy(); var vid = document.getElementById("mediaspace"); // vid.pause(); } }); modalSurprise.setContent(''); modalSurprise.open(); }); } else if ( btnType == "image") { var btnOption = ''; var btnTwo = document.createElement('div'); btnTwo.setAttribute("id", "btnOption"); btnTwo.innerHTML = btnOption; document.body.appendChild(btnTwo); //var referenceNode = document.querySelector('.reviewtube'); var referenceNode = document.querySelector(container_class); referenceNode.before(btnTwo); var btnModal2 = document.querySelector('.' + modal_class); btnModal2.addEventListener('click', function(){ var modalSurprise = new tingle.modal({ onClose: function(){ modalSurprise.destroy(); var vid = document.getElementById("mediaspace"); // vid.pause(); } }); modalSurprise.setContent(''); modalSurprise.open(); }); } // var btnOption = ""; //var btnEleven = document.createElement('div'); //btnEleven.setAttribute("id", "rtmodbt"); // btnEleven.innerHTML = btnOption; // document.body.appendChild(btnEleven); // var referenceNode = document.querySelector('.reviewtube'); //referenceNode.before(btnEleven); // referenceNode.innerHTML = btnOption; // var btnModal = document.querySelector('.js-tingle-modal'); // btnModal.addEventListener('click', function(){ // var modalSurprise = new tingle.modal({ // onClose: function(){ // modalSurprise.destroy(); // var vid = document.getElementById("mediaspace"); // //vid.pause(); // } // }); // modalSurprise.setContent(''); // modalSurprise.open(); // }); } else if ( viewType == "fullwidth" ) { newstylesheet.insertRule(container_class + ":after { display: block;content: '';width: 100%; padding-bottom: 56.25%;}", 0); newstylesheet.insertRule(container_class + " {width: 100%; position: relative; height: 905px;}", 0); newstylesheet.insertRule("@media only screen and (max-width: 420px) { "+ container_class +" { height: 860px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 768px) { "+ container_class +" { height: 1095px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 1024px) { "+ container_class +" { height: 865px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 1200px) { "+ container_class +" { height: 895px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 1400px) { "+ container_class +" { height: 905px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 420px) { "+ container_class +" iframe { height: 860px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 768px) { "+ container_class +" iframe { height: 1095px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 1024px) { "+ container_class +" iframe { height: 865px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 1200px) { "+ container_class +" iframe { height: 895px !important; } }", 0); newstylesheet.insertRule("@media only screen and (max-width: 1400px) { "+ container_class +" iframe { height: 905px !important; } }", 0); var iframe = thatDoc.createElement( "iframe" ); iframe.setAttribute( "frameborder", "0"); iframe.setAttribute( "allowfullscreen", ""); iframe.setAttribute( "webkitallowfullscreen", ""); iframe.setAttribute( "mozallowfullscreen", ""); iframe.setAttribute( "allow", "microphone"); iframe.setAttribute( "src", rtURL); iframe.setAttribute( "width", "100%"); tubes[i].innerHTML = ""; tubes[i].appendChild( iframe ); } } })(window, document);