diff --git a/media/system/js/associations-edit-uncompressed.js b/media/system/js/associations-edit-uncompressed.js index a24d899436b5f..1ab98012feefb 100644 --- a/media/system/js/associations-edit-uncompressed.js +++ b/media/system/js/associations-edit-uncompressed.js @@ -17,7 +17,7 @@ window.hideAssociation = function(formControl, languageCode) jQuery('#associations .control-group').each(function() { // Current selected language. Hide it. - if (jQuery(this).find('.control-label label').attr('for').replace('_id', '') == formControl + '_associations_' + languageCode.replace('-', '_')) + if (jQuery(this).find('.control-label label').attr('for').replace(new RegExp('_id$'), '') == formControl + '_associations_' + languageCode.replace('-', '_')) { jQuery(this).hide(); } @@ -33,25 +33,25 @@ window.showAssociationMessage = function() /** * Inject associations into other association fields * - * This function is called whenever the Ajax request within propagateAssociation() completes successfully. + * This function is called whenever the Ajax request within propagateAssociation() completes successfully. * Its purpose is to inject the associations which have been returned in the Ajax response into the other - * association fields in the form. + * association fields in the form. * It does this by invoking the various callback functions of those association fields (i.e. the function which * gets called whenever the administrator selects an association via the modal), and passing the appropriate * associated record details. * - * @param js object result The response from the Ajax request. - * Its structure is that generated by the JResponseJson class, + * @param js object result The response from the Ajax request. + * Its structure is that generated by the JResponseJson class, * with the data field containing the associations * @param string fieldPrefix The stem of the html ids for the elements comprising the modal field - * @param string callbackFunctionPrefix The name of the callback function which the modal window uses to set the + * @param string callbackFunctionPrefix The name of the callback function which the modal window uses to set the * selected item as the association, but minus the language tag at the end * * @return boolean * * @since 3.9.0 */ - Joomla.injectAssociations = function(result, callbackFunctionPrefix) + Joomla.injectAssociations = function(result, callbackFunctionPrefix) { var functionName; @@ -81,26 +81,26 @@ window.showAssociationMessage = function() /** * Propagate associations from this field into other association fields * - * This function is called whenever an administrator populates an association (in the association modal field) - * and then clicks on the Propagate button. - * The purpose of this function is to find what other records (if any) are associated with the one which the + * This function is called whenever an administrator populates an association (in the association modal field) + * and then clicks on the Propagate button. + * The purpose of this function is to find what other records (if any) are associated with the one which the * administrator has selected, and populate the other association fields with these records. (Otherwise, if the * administrator just clicks on Save without clicking on Propagate, those other associations will be deleted). * It does this by finding the id of the selected associated record (from a hidden field) and makes an Ajax call * to the server to find the other associations, also passing up the language of the record currently being edited, - * as it should be excluded. + * as it should be excluded. * Once it has received from the server the other associations it calls injectAssociations to inject them into - * the other association fields within the form. + * the other association fields within the form. * * @param string fieldPrefix The stem of the html ids for the elements comprising the modal field - * @param string callbackFunctionPrefix The name of the callback function which the modal window uses to set the + * @param string callbackFunctionPrefix The name of the callback function which the modal window uses to set the * selected item as the association, but minus the language tag at the end * * @return boolean * * @since 3.9.0 */ - Joomla.propagateAssociation = function(fieldPrefix, callbackFunctionPrefix) + Joomla.propagateAssociation = function(fieldPrefix, callbackFunctionPrefix) { // Find the id of the record which has been set as an assocation var assocId = jQuery("#" + fieldPrefix + "_id").val(); @@ -131,7 +131,7 @@ window.showAssociationMessage = function() !(function() { jQuery(document).ready(function($) - { + { var associationsEditOptions = Joomla.getOptions('system.associations.edit'), formControl = associationsEditOptions.formControl || 'jform'; // Hide the associations tab if needed. diff --git a/media/system/js/associations-edit.js b/media/system/js/associations-edit.js index a4b70bc16a550..763516a37deca 100644 --- a/media/system/js/associations-edit.js +++ b/media/system/js/associations-edit.js @@ -1 +1 @@ -window.hideAssociation=function(o,a){jQuery("#associations .control-group").each(function(){jQuery(this).find(".control-label label").attr("for").replace("_id","")==o+"_associations_"+a.replace("-","_")&&jQuery(this).hide()})},window.showAssociationMessage=function(){jQuery("#associations .control-group").hide(),jQuery("#associations").prepend('
'+Joomla.JText._("JGLOBAL_ASSOC_NOT_POSSIBLE")+"
")},Joomla.injectAssociations=function(o,a){var s;if(o.success){if(0!==o.data.length)for(var e in o.data)s=a+e.replace("-","_"),window[s](o.data[e].id,o.data[e].title,o.data[e].catid,null,null,e);o.message&&Joomla.renderMessages({notice:[o.message]})}else Joomla.renderMessages({warning:[Joomla.JText._("JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED")]})},Joomla.propagateAssociation=function(o,a){var s=jQuery("#"+o+"_id").val(),e=jQuery("#jform_language").find(":selected").val(),i=Joomla.getOptions("csrf.token",""),n=jQuery("form[name='adminForm']").attr("action");return n+="&"+i+"=1",jQuery.ajax({url:n,data:{task:"ajax.fetchAssociations",format:"json",assocId:s,excludeLang:e},success:function(o,s,e){Joomla.injectAssociations(o,a)},error:function(){Joomla.renderMessages({warning:[Joomla.JText._("JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED")]})}}),!1},window,document,Joomla,jQuery(document).ready(function(o){var a=Joomla.getOptions("system.associations.edit"),s=a.formControl||"jform";1==a.hidden?window.showAssociationMessage():window.hideAssociation(s,o("#"+s+"_language").val()),o("#"+s+"_language").on("change",function(a){Joomla.removeMessages(),o("#associations-notice").remove();var e=!1;o("#associations .control-group").each(function(){var a=o(this).find(".control-label label").attr("for").replace("_id","").replace("jform_associations_","");o(this).show(),e||""===o("#"+s+"_associations_"+a+"_id").val()||(e=!0),o("#"+s+"_associations_"+a+"_clear").click()}),e&&Joomla.renderMessages({warning:[Joomla.JText._("JGLOBAL_ASSOCIATIONS_RESET_WARNING")]});var i=o(this).val();"*"==i?window.showAssociationMessage():window.hideAssociation(s,i)})}); \ No newline at end of file +window.hideAssociation=function(o,a){jQuery("#associations .control-group").each(function(){jQuery(this).find(".control-label label").attr("for").replace(new RegExp("_id$"),"")==o+"_associations_"+a.replace("-","_")&&jQuery(this).hide()})},window.showAssociationMessage=function(){jQuery("#associations .control-group").hide(),jQuery("#associations").prepend('
'+Joomla.JText._("JGLOBAL_ASSOC_NOT_POSSIBLE")+"
")},Joomla.injectAssociations=function(o,a){var s;if(o.success){if(0!==o.data.length)for(var e in o.data)s=a+e.replace("-","_"),window[s](o.data[e].id,o.data[e].title,o.data[e].catid,null,null,e);o.message&&Joomla.renderMessages({notice:[o.message]})}else Joomla.renderMessages({warning:[Joomla.JText._("JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED")]})},Joomla.propagateAssociation=function(o,a){var s=jQuery("#"+o+"_id").val(),e=jQuery("#jform_language").find(":selected").val(),i=Joomla.getOptions("csrf.token",""),n=jQuery("form[name='adminForm']").attr("action");return n+="&"+i+"=1",jQuery.ajax({url:n,data:{task:"ajax.fetchAssociations",format:"json",assocId:s,excludeLang:e},success:function(o,s,e){Joomla.injectAssociations(o,a)},error:function(){Joomla.renderMessages({warning:[Joomla.JText._("JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED")]})}}),!1},window,document,Joomla,jQuery(document).ready(function(o){var a=Joomla.getOptions("system.associations.edit"),s=a.formControl||"jform";1==a.hidden?window.showAssociationMessage():window.hideAssociation(s,o("#"+s+"_language").val()),o("#"+s+"_language").on("change",function(a){Joomla.removeMessages(),o("#associations-notice").remove();var e=!1;o("#associations .control-group").each(function(){var a=o(this).find(".control-label label").attr("for").replace("_id","").replace("jform_associations_","");o(this).show(),e||""===o("#"+s+"_associations_"+a+"_id").val()||(e=!0),o("#"+s+"_associations_"+a+"_clear").click()}),e&&Joomla.renderMessages({warning:[Joomla.JText._("JGLOBAL_ASSOCIATIONS_RESET_WARNING")]});var i=o(this).val();"*"==i?window.showAssociationMessage():window.hideAssociation(s,i)})});