Files
Testing/tbs/wp-content/plugins/age-gate/admin/js/age-gate-editor.js
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

1 line
3.3 KiB
JavaScript

!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=8)}({8:function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=function(){function e(){var t=this;n(this,e),jQuery.ajax({url:ajaxurl,method:"POST",data:{action:"get_textarea"}}).done(function(e){jQuery(".ag-css-editor").after(e),t.textarea=document.querySelector("#wp_age_gate_custom_css"),t.editor=ace.edit("css-editor"),t.warning=document.querySelector(".css-warning"),t.init()}).error(function(e){})}return i(e,[{key:"init",value:function(){this.initModal(),this.editor.renderer.on("afterRender",this.errorCheck.bind(this)),this.editor.setTheme("ace/theme/monokai"),this.editor.getSession().setMode("ace/mode/css"),this.editor.getSession().setValue(this.textarea.value),this.editor.getSession().on("change",this.updateOutput.bind(this)),this.editor.on("blur",this.errorCheck.bind(this)),this.textarea.style.display="none",jQuery(".restore-css").prop("disabled",!1).attr("title","").on("click",this.recoverStyle.bind(this)),jQuery(".css-ref").on("click",this.showModal.bind(this)),jQuery(".load-default-css").on("click",this.loadCss.bind(this))}},{key:"updateOutput",value:function(){this.textarea.value=this.editor.getSession().getValue()}},{key:"recoverStyle",value:function(){var e=this;jQuery.ajax({url:ajaxurl,method:"POST",data:{action:"recover_css"}}).done(function(t){e.textarea.value=t,e.editor.getSession().setValue(e.textarea.value)}).error(function(e){})}},{key:"errorCheck",value:function(){var e=this;this.counts={warning:0,error:0},this.editor.getSession().getAnnotations().forEach(function(t){e.counts[t.type]++}),jQuery('input[type="submit"]').prop("disabled",this.counts.error),this.counts.error?this.warning.innerHTML='\n <div class="notice notice-error">\n <p><span class="dashicons dashicons-warning error" aria-hidden="true"></span> '+ag.css.error+"</p>\n </div>\n ":this.warning.innerHTML=""}},{key:"loadCss",value:function(e){var t=this;e.preventDefault(),jQuery.ajax({url:ajaxurl,method:"POST",data:{action:"editor_css"}}).done(function(e){t.editor.getSession().setValue(e)}).error(function(e){})}},{key:"initModal",value:function(){jQuery("#css-reference").dialog({title:"CSS Reference",dialogClass:"wp-dialog",autoOpen:!1,draggable:!1,width:"auto",modal:!0,resizable:!1,closeOnEscape:!0,position:{my:"center",at:"center",of:window},open:function(){jQuery(".ui-widget-overlay").bind("click",function(){jQuery("#css-reference").dialog("close")})},create:function(){jQuery(".ui-dialog-titlebar-close").addClass("ui-button")}})}},{key:"showModal",value:function(e){e.preventDefault(),jQuery(jQuery(e.target).attr("href")).dialog("open")}}]),e}();!function(e){e(function(){new o})}(jQuery)}});