-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
permissions.min.js
1 lines (1 loc) · 1.93 KB
/
permissions.min.js
1
Joomla=window.Joomla||{},function(e,t){"use strict";e.sendPermissions=function(a){var r=a.target,s=t.getElementById("icon_"+this.id);s.removeAttribute("class"),s.setAttribute("class","fa fa-spinner fa-spin");var o="not",i=e.getUrlParam("component"),n=e.getUrlParam("extension"),l=e.getUrlParam("option"),m=e.getUrlParam("view"),u=i,c=this.value,d="";t.getElementById("jform_context")&&(d=(d=t.getElementById("jform_context").value).split(".")[0]),"com_config"==l&&0==i&&0==n?o="root.1":0==n&&"component"==m?o=i:d?(o="group"==m?d+".fieldgroup."+e.getUrlParam("id"):d+".field."+e.getUrlParam("id"),u=t.getElementById("jform_title").value):0!=n&&0!=m?(o=n+"."+m+"."+e.getUrlParam("id"),u=t.getElementById("jform_title").value):0==n&&0!=m&&(o=l+"."+m+"."+e.getUrlParam("id"),u=t.getElementById("jform_title").value);var g=this.id.replace("jform_rules_",""),f=g.lastIndexOf("_"),p={comp:o,action:g.substring(0,f),rule:g.substring(f+1),value:c,title:u};e.removeMessages(),e.request({url:t.getElementById("permissions-sliders").getAttribute("data-ajaxuri"),method:"POST",data:JSON.stringify(p),perform:!0,headers:{"Content-Type":"application/json"},onSuccess:function(t,a){try{t=JSON.parse(t)}catch(e){console.log(e)}if(s.removeAttribute("class"),t.data&&!0===t.data.result){s.setAttribute("class","fa fa-check");var o=r.parentNode.parentNode.nextElementSibling.querySelector("span");o.removeAttribute("class"),o.setAttribute("class",t.data.class),o.innerHTML=t.data.text}"object"==typeof t.messages&&null!==t.messages&&(e.renderMessages(t.messages),t.data&&!0===t.data.result?s.setAttribute("class","fa fa-check"):s.setAttribute("class","fa fa-times"))},onError:function(t){s.removeAttribute("style"),e.renderMessages(e.ajaxErrorsMessages(jqXHR,textStatus,error)),s.setAttribute("class","fa fa-times")}})},e.getUrlParam=function(e){for(var t=window.location.search.substring(1).split("&"),a=0;a<t.length;a++){var r=t[a].split("=");if(r[0]==e)return r[1]}return!1}}(Joomla,document);