| Current Path : /var/www/media/com_gsd/js/ |
| Current File : /var/www/media/com_gsd/js/fastedit.js |
var GSD_Fast_Edit=function(){function t(){this.el=document.querySelector(".gsdFastEdit"),this.options=Joomla.getOptions("gsd_fastedit"),this.baseURL=this.options.base_url+"/index.php?option=com_gsd&view=gsd&format=raw",this.thing=this.options.thing_id,this.plugin=this.options.plugin,this.modal=this.el.querySelector(".modal"),this.init()}var i,e=t.prototype;function n(t,e){return i.apply(this,arguments)}return e.init=function(){this.thing&&this.get(),this.initEvents()},e.initEvents=function(){document.addEventListener("click",function(t){this.handleModalOpen(t),this.removeItem(t)}.bind(this))},e.handleModalOpen=function(t){var e=t.target.closest('a[href="#gsdModal"]');if(e){var i=!e.classList.contains("btn-secondary"),n=i?Joomla.JText._("GSD_ADD_SNIPPET"):Joomla.JText._("GSD_EDIT_SNIPPET");if(this.modal.querySelector(".modal-header h3").innerHTML=n,i)var s=e.closest(".gsdFastEdit").dataset.src+"&contenttype="+e.dataset.contenttype;else s=e.dataset.src;this.modal.querySelector("iframe").src=s,this.modal.querySelector("iframe").addEventListener("load",function(){this.get()}.bind(this))}},e.removeItem=function(t){var e=t.target.closest(".gsdRemove");e&&(t.preventDefault(),confirm(Joomla.JText._("NR_ARE_YOU_SURE"))&&this._remove(e.closest("tr").dataset.pk))},e.get=function(){var e=this;this.fetch("&plugin="+this.plugin+"&thing="+this.thing+"&assignment="+this.options.plugin_assignment_name,function(t){e.el.querySelector(".items").innerHTML=t})},e._remove=function(t){var e=this;this.fetch("&do=delete&pk="+t,function(){e.get()})},e.fetch=(i=function(t,e){var i=this;this.el.classList.add("working"),fetch(this.baseURL+t).then(function(t){return t.text()}).then(function(t){i.el.classList.remove("working"),e(t)})},n.toString=function(){return i.toString()},n),t}();document.addEventListener("DOMContentLoaded",function(){new GSD_Fast_Edit});