/* Preview Plugin */ (function () { var _screenwidth = window.innerWidth; if (_screenwidth <= 640) return; var html = '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
1440px
' + "
" + "
" + "
" + "
" + "
" + "
" + "
" + '
' + "
" + '' + "
" + "
" + '' + "" + '' + '' + "" + ""; _cb.addHtml(html); var css = ""; _cb.addCss(css); var button_html = '"; var modal = document.querySelector(".is-modal.previewcontent"); _cb.addButton('preview', button_html, '.previewcontent-button', function (e) { _cb.showModal(modal); //check if builder is inside iframe if(window.frameElement) { var c = getFramedWindow(window.frameElement); var doc = c.document; } else { var doc = parent.document; } var basehref = ""; var base = doc.querySelectorAll("base[href]"); if (base.length > 0) { basehref = ''; } var csslinks = ""; var styles = doc.querySelectorAll("link[href]"); for (var i = 0; i < styles.length; i++) { if ( styles[i].href.indexOf(".css") != -1 && styles[i].href.indexOf("contentbox.css") == -1 && styles[i].href.indexOf("contentbuilder.css") == -1 ) { csslinks += ''; } } var jsincludes = ""; var scripts = doc.querySelectorAll("script[src]"); for (var i = 0; i < scripts.length; i++) { if ( scripts[i].src.indexOf(".js") != -1 && scripts[i].src.indexOf("index.js") == -1 && scripts[i].src.indexOf("contentbox.js") == -1 && scripts[i].src.indexOf("contentbox.min.js") == -1 && scripts[i].src.indexOf("contentbuilder.js") == -1 && scripts[i].src.indexOf("contentbuilder.min.js") == -1 && scripts[i].src.indexOf("plugin.js") == -1 && scripts[i].src.indexOf("config.js") == -1 && scripts[i].src.indexOf("en.js") == -1 && scripts[i].src.indexOf("minimalist-blocks") == -1 ) { jsincludes += ''; } } // No script jsincludes = ''; /* Get Page */ if (!document.querySelector(".is-wrapper")) { var maxwidth = "800px"; var maxw = window.getComputedStyle(document.querySelector(".is-builder")).getPropertyValue('max-width'); if (!isNaN(parseInt(maxw))) maxwidth = maxw; var content = _cb.html(); var doc = modal.querySelector('iframe').contentWindow.document; doc.open(); doc.write( "" + "" + basehref + '' + "" + csslinks + "" + '' + "" + "" + '
' + content + "
" + jsincludes + "" + "" ); doc.close(); } else { // ContentBox var content = jQuery(".is-wrapper") .data("contentbox") .html(); var doc = modal.querySelector('iframe').contentWindow.document; doc.open(); doc.write( "" + "" + basehref + '' + "" + csslinks + "" + '' + "" + "" + '
' + content + "
" + jsincludes + "" + "" ); doc.close(); } //Or you can specify your custom preview page: //modal.find('iframe').attr('src','preview.html'); e.preventDefault(); }); var btnClose = modal.querySelector('.is-modal-close'); btnClose.addEventListener('click', function(e){ _cb.hideModal(modal); }); var sizeControls = modal.querySelectorAll(".size-control"); Array.prototype.forEach.call(sizeControls, function(sizeControl){ sizeControl.addEventListener('mouseover', function(e) { var elms = modal.querySelectorAll(".size-control"); Array.prototype.forEach.call(elms, function(elm){ elm.style.background = "#ddd"; }); sizeControl.style.background = "#aaa"; elms = sizeControl.querySelectorAll(".size-control"); Array.prototype.forEach.call(elms, function(elm){ elm.style.background = "#aaa"; }); modal.querySelector(".size-control-info").style.color = '#fff'; var w = sizeControl.getAttribute('data-width'); modal.querySelector(".size-control-info").innerHTML = w + 'px'; e.preventDefault(); e.stopImmediatePropagation(); }); sizeControl.addEventListener('mouseout', function(e) { var elms = modal.querySelectorAll(".size-control"); Array.prototype.forEach.call(elms, function(elm){ elm.style.background = "#ddd"; }); modal.querySelector(".size-control-info").style.color = '#000'; var currW = modal.querySelector("iframe").getAttribute('data-width'); modal.querySelector(".size-control-info").innerText = currW + 'px'; }); sizeControl.addEventListener('click', function(e) { var w = sizeControl.getAttribute('data-width'); modal.querySelector("iframe").style.maxWidth = w + 'px'; modal.querySelector("iframe").setAttribute('data-width', w); e.preventDefault(); e.stopImmediatePropagation(); }); }); })(); function getFramedWindow(f) { if(f.parentNode == null) f = document.body.appendChild(f); var w = (f.contentWindow || f.contentDocument); if(w && w.nodeType && w.nodeType==9) w = (w.defaultView || w.parentWindow); return w; }