permissions.js 1.85 KB
function sendPermissions(e){var t=document.getElementById("icon_"+this.id);t.removeAttribute("class"),t.setAttribute("style","background: url(../media/system/images/modal/spinner.gif); display: inline-block; width: 16px; height: 16px");var a="not",s=getUrlParam("component"),r=getUrlParam("extension"),o=getUrlParam("option"),l=getUrlParam("view"),n=s,i=this.value,m="";document.getElementById("jform_context")&&(m=document.getElementById("jform_context").value,m=m.split(".")[0]),"com_config"==o&&0==s&&0==r?a="root.1":0==r&&"component"==l?a=s:m?(a="group"==l?m+".fieldgroup."+getUrlParam("id"):m+".field."+getUrlParam("id"),n=document.getElementById("jform_title").value):0!=r&&0!=l?(a=r+"."+l+"."+getUrlParam("id"),n=document.getElementById("jform_title").value):0==r&&0!=l&&(a=o+"."+l+"."+getUrlParam("id"),n=document.getElementById("jform_title").value);var d=this.id.replace("jform_rules_",""),u=d.lastIndexOf("_"),c={comp:a,action:d.substring(0,u),rule:d.substring(u+1),value:i,title:n};Joomla.removeMessages(),jQuery.ajax({method:"POST",url:document.getElementById("permissions-sliders").getAttribute("data-ajaxuri"),data:c,datatype:"json"}).fail(function(e,a,s){t.removeAttribute("style"),Joomla.renderMessages(Joomla.ajaxErrorsMessages(e,a,s)),window.scrollTo(0,0),t.setAttribute("class","icon-cancel")}).done(function(a){t.removeAttribute("style"),a.data&&1==a.data.result&&(t.setAttribute("class","icon-save"),jQuery(e.target).parents().next("td").find("span").removeClass().addClass(a.data["class"]).html(a.data.text)),"object"==typeof a.messages&&null!==a.messages&&(Joomla.renderMessages(a.messages),a.data&&1==a.data.result?t.setAttribute("class","icon-save"):t.setAttribute("class","icon-cancel"),window.scrollTo(0,0))})}function getUrlParam(e){for(var t=window.location.search.substring(1),a=t.split("&"),s=0;s<a.length;s++){var r=a[s].split("=");if(r[0]==e)return r[1]}return!1}