/* Button Editor Plugin */ (function () { var html = '
'; _cb.addHtml(html); var html_button = ''; var linkTool = document.querySelector('#divLinkTool'); linkTool.insertAdjacentHTML('afterBegin', html_button); //add button to existing #divLinkTool var buttonEdit = linkTool.querySelector('.button-edit'); //Extend onContentClick var oldget = _cb.opts.onContentClick; _cb.opts.onContentClick = function (e) { let elm = e.target; var ret = oldget.apply(this, arguments); var elmDisplay = getStyle(elm, 'display'); if((elm.tagName.toLowerCase() === 'a' && elmDisplay === 'inline-block')) { buttonEdit.style.display = 'block'; } else { buttonEdit.style.display = 'none'; } return ret; }; buttonEdit.addEventListener('click', function(){ var modal = document.querySelector('.is-modal.buttoneditor'); _cb.showModal(modal); _cb.saveForUndo(true); // checkLater = true var btnClose = modal.querySelector('.is-modal-close'); btnClose.addEventListener('click', function(e){ _cb.hideModal(modal); }); var scriptPath = _cb.getScriptPath(); modal.querySelector('iframe').src = scriptPath + 'plugins/buttoneditor/buttoneditor.html'; }); var getStyle = function(element, property) { return window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(property) : element.style[property.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); })]; } })();