modal-fields.js
2.18 KB
!function(){"use strict";window.processModalParent=function(e,t,d,n,a,o,r){var l=document.getElementById(e+"_id"),m=document.getElementById(e+"_name");return t=t||"",d=d||"",n=n||"",r=r||"",a=a||"",o=o||"",t?(l.value=t,m.value=d,document.getElementById(e+"_select")&&jQuery("#"+e+"_select").addClass("hidden"),document.getElementById(e+"_new")&&jQuery("#"+e+"_new").addClass("hidden"),document.getElementById(e+"_edit")&&jQuery("#"+e+"_edit").removeClass("hidden"),document.getElementById(e+"_clear")&&jQuery("#"+e+"_clear").removeClass("hidden"),document.getElementById(e+"_propagate")&&jQuery("#"+e+"_propagate").removeClass("hidden")):(l.value="",m.value=l.getAttribute("data-text"),document.getElementById(e+"_select")&&jQuery("#"+e+"_select").removeClass("hidden"),document.getElementById(e+"_new")&&jQuery("#"+e+"_new").removeClass("hidden"),document.getElementById(e+"_edit")&&jQuery("#"+e+"_edit").addClass("hidden"),document.getElementById(e+"_clear")&&jQuery("#"+e+"_clear").addClass("hidden"),document.getElementById(e+"_propagate")&&jQuery("#"+e+"_propagate").addClass("hidden")),"1"==l.getAttribute("data-required")&&(document.formvalidator.validate(l),document.formvalidator.validate(m)),!1},window.processModalEdit=function(e,t,d,n,a,o,r,l){o=o||n.toLowerCase()+"-form",r=r||"jform_id",l=l||"jform_title";var m=e.parentNode.parentNode.id,u=a;jQuery("#"+m+" iframe").get(0).id="Frame_"+m;var i=jQuery("#Frame_"+m).contents().get(0);return"cancel"===a?(document.getElementById("Frame_"+m).contentWindow.Joomla.submitbutton(n.toLowerCase()+"."+a),jQuery("#"+m).modal("hide")):(jQuery("#Frame_"+m).on("load",function(){(i=jQuery(this).contents().get(0)).getElementById(r)&&"0"!=i.getElementById(r).value&&(window.processModalParent(t,i.getElementById(r).value,i.getElementById(l).value),"save"===a&&window.processModalEdit(e,t,"edit",n,"cancel",o,r,l)),jQuery("#"+m+" iframe").removeClass("hidden")}),i.formvalidator.isValid(i.getElementById(o))&&("save"===a&&(u="apply"),document.getElementById("Frame_"+m).contentWindow.Joomla.submitbutton(n.toLowerCase()+"."+u))),!1},window.processModalSelect=function(e,t,d,n,a,o,r,l){return window.processModalParent(t,d,n,a,r,l,o),jQuery("#ModalSelect"+e+"_"+t).modal("hide"),!1}}();