diff --git a/administrator/components/com_associations/views/association/tmpl/edit.php b/administrator/components/com_associations/views/association/tmpl/edit.php index 408033369d06c..2fe76e58a7775 100644 --- a/administrator/components/com_associations/views/association/tmpl/edit.php +++ b/administrator/components/com_associations/views/association/tmpl/edit.php @@ -38,6 +38,7 @@ data-action="edit" data-item="typeName; ?>" data-id="referenceId; ?>" + data-title="referenceTitle; ?>" data-language="referenceLanguage; ?>" data-editurl="editUri); ?>"> @@ -56,6 +57,7 @@ data-action="targetAction; ?>" data-item="typeName; ?>" data-id="targetId; ?>" + data-title="targetTitle; ?>" data-language="targetLanguage; ?>" data-editurl="editUri); ?>"> diff --git a/administrator/components/com_associations/views/association/view.html.php b/administrator/components/com_associations/views/association/view.html.php index b82f2634f1c13..f071bec34671a 100644 --- a/administrator/components/com_associations/views/association/view.html.php +++ b/administrator/components/com_associations/views/association/view.html.php @@ -110,6 +110,7 @@ public function display($tpl = null) $reference = ArrayHelper::fromObject(AssociationsHelper::getItem($extensionName, $typeName, $referenceId)); $this->referenceLanguage = $reference[$languageField]; + $this->referenceTitle = AssociationsHelper::getTypeFieldName($extensionName, $typeName, 'title'); $options = array( 'option' => $typeName === 'category' ? 'com_categories' : $extensionName, @@ -126,6 +127,7 @@ public function display($tpl = null) $this->targetLanguage = ''; $this->defaultTargetSrc = ''; $this->targetAction = ''; + $this->targetTitle = ''; if ($target = $input->get('target', '', 'string')) { @@ -133,6 +135,7 @@ public function display($tpl = null) $this->targetAction = $matches[2]; $this->targetId = $matches[1]; $this->targetLanguage = $matches[0]; + $this->targetTitle = AssociationsHelper::getTypeFieldName($extensionName, $typeName, 'title'); $task = $typeName . '.' . $this->targetAction; $this->defaultTargetSrc = JRoute::_($this->editUri . '&task=' . $task . '&id=' . (int) $this->targetId); $this->form->setValue('itemlanguage', '', $this->targetLanguage . ':' . $this->targetId . ':' . $this->targetAction); diff --git a/media/com_associations/js/sidebyside-uncompressed.js b/media/com_associations/js/sidebyside-uncompressed.js index c583a391aeb30..0fbccca88edf2 100644 --- a/media/com_associations/js/sidebyside-uncompressed.js +++ b/media/com_associations/js/sidebyside-uncompressed.js @@ -258,9 +258,10 @@ jQuery(document).ready(function($) { } // Update the reference item associations tab. - var reference = document.getElementById('reference-association'); - var languageCode = targetLanguage.replace(/-/, '_'); - var title = $(this).contents().find('#jform_title').val() + var reference = document.getElementById('reference-association'); + var languageCode = targetLanguage.replace(/-/, '_'); + var referenceTitle = reference.getAttribute('data-title'); + var title = $(this).contents().find('#jform_' + referenceTitle).val(); // - For modal association selectors. $(reference).contents().find('#jform_associations_' + languageCode + '_id').val(targetLoadedId); @@ -276,7 +277,9 @@ jQuery(document).ready(function($) { var reference = document.getElementById('reference-association'); var referenceId = reference.getAttribute('data-id'); var languageCode = reference.getAttribute('data-language').replace(/-/, '_'); - var title = $(reference).contents().find('#jform_title').val(); + var target = document.getElementById('target-association'); + var targetTitle = target.getAttribute('data-title'); + var title = $(this).contents().find('#jform_' + targetTitle).val(); var target = $(this).contents(); // - For modal association selectors. diff --git a/media/com_associations/js/sidebyside.js b/media/com_associations/js/sidebyside.js index 8ce06d768b7d9..362e9316ba27f 100644 --- a/media/com_associations/js/sidebyside.js +++ b/media/com_associations/js/sidebyside.js @@ -1 +1 @@ -jQuery(document).ready(function(t){t("#toolbar-target").hide(),t("#toolbar-copy").hide(),Joomla.submitbutton=function(e){if("association.cancel"===e)Joomla.submitform(e);else if("copy"===e){Joomla.loadingLayer("show");var a=document.getElementById("target-association").getAttribute("data-language"),i=window.frames["reference-association"].document.getElementById("jform_language");i.removeAttribute("disabled"),i.value=a,window.frames["reference-association"].Joomla.submitbutton(document.getElementById("adminForm").getAttribute("data-associatedview")+".save2copy")}else if("undo-association"===e){var n=document.getElementById("reference-association"),o=document.getElementById("target-association"),s=(n.getAttribute("data-id"),n.getAttribute("data-language").replace(/-/,"_")),a=(o.getAttribute("data-id"),o.getAttribute("data-language").replace(/-/,"_"));n=t(n).contents(),o=t(o).contents(),n.find("#jform_associations_"+a+"_id").val(""),n.find("#jform_associations_"+a+"_name").val(""),n.find("#jform_associations_"+a+"_chzn").remove(),n.find("#jform_associations_"+a).val("").change().chosen();var d="";t("#jform_itemlanguage option").each(function(){d=t(this).val().split("|")[0],"undefined"!=typeof d&&(d=d.replace(/-/,"_"),o.find("#jform_associations_"+d+"_id").val(""),o.find("#jform_associations_"+d+"_chzn").remove(),o.find("#jform_associations_"+d).val("").change().chosen())}),o.find("#jform_associations_"+s+"_id").val(""),o.find("#jform_associations_"+s+"_name").val(""),o.find("#jform_associations_"+s+"_chzn").remove(),o.find("#jform_associations_"+s).val("").change().chosen();var r=t("#jform_itemlanguage").val(),c=a.replace(/_/,"-");t('#jform_itemlanguage option[value="'+r+'"]').val(c+":0:add"),t("#jform_itemlanguage").val("").change(),t("#jform_itemlanguage").trigger("liszt:updated"),Joomla.submitbutton("reference")}else t("#"+e+"-association").contents().find("#jform_language").attr("disabled",!1),window.frames[e+"-association"].Joomla.submitbutton(document.getElementById("adminForm").getAttribute("data-associatedview")+".apply");return!1},Joomla.loadingLayer("load"),t(document).on("click","#toogle-left-panel",function(){var e=this.getAttribute("data-hide-reference"),a=this.getAttribute("data-show-reference");t(this).text()===e?t(this).text(a):t(this).text(e),t("#left-panel").toggle(),t("#right-panel").toggleClass("full-width")}),t(document).on("change","#jform_itemlanguage",function(){var e=document.getElementById("target-association"),a=t(this).val();""!==a&&"undefined"!=typeof a?(e.setAttribute("data-action",a.split(":")[2]),e.setAttribute("data-id",a.split(":")[1]),e.setAttribute("data-language",a.split(":")[0]),Joomla.loadingLayer("show"),e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+"."+e.getAttribute("data-action")+"&id="+e.getAttribute("data-id")):(t("#toolbar-target").hide(),t("#toolbar-copy").hide(),t("#select-change").addClass("hidden"),t("#remove-assoc").addClass("hidden"),e.setAttribute("data-action",""),e.setAttribute("data-id","0"),e.setAttribute("data-language",""),e.src="")}),t("#reference-association").on("load",function(){if(document.getElementById("target-association").setAttribute("src",document.getElementById("target-association").getAttribute("src")),t(this).contents().find("#jform_id").val()!==this.getAttribute("data-id")){var e=document.getElementById("target-association");e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+".edit&id="+t(this).contents().find("#jform_id").val(),this.src=this.getAttribute("data-editurl")+"&task="+this.getAttribute("data-item")+".edit&id="+this.getAttribute("data-id")}var a=t(this).contents();a.find("#jform_language_chzn").remove(),a.find("#jform_language").attr("disabled",!0).chosen(),a.find("#associations").find(".btn").remove();var i="";t("#jform_itemlanguage option").each(function(){i=t(this).val().split(":"),"undefined"!=typeof i[0]&&(langAssociation=i[0].replace(/-/,"_"),""==a.find("#jform_associations_"+langAssociation+"_id").val()&&a.find("#jform_associations_"+langAssociation+"_name").val(document.getElementById("reference-association").getAttribute("data-no-assoc")))}),Joomla.loadingLayer("hide")}),t("#target-association").on("load",function(){if(""!=this.getAttribute("src")){t("#toolbar-target").show(),t("#toolbar-copy").show(),t("#select-change").removeClass("hidden");var e=this.getAttribute("data-language"),a=this.getAttribute("data-id"),i=t(this).contents().find("#jform_id").val()||"0";if(t(this).contents().find('a[href="#associations"]').parent().find(".btn").remove(),t(this).contents().find("#associations").find(".btn").remove(),t(this).contents().find("#associations").hasClass("active")&&(t(this).contents().find('a[href="#associations"]').parent().removeClass("active"),t(this).contents().find("#associations").removeClass("active"),t(this).contents().find(".nav-tabs").find("li").first().addClass("active"),t(this).contents().find(".tab-content").find(".tab-pane").first().addClass("active")),t(this).contents().find("#jform_language_chzn").remove(),t(this).contents().find("#jform_language").val(e).change().attr("disabled",!0).chosen(),"0"==i)document.getElementById("select-change-text").innerHTML=document.getElementById("select-change").getAttribute("data-select");else{document.getElementById("select-change-text").innerHTML=document.getElementById("select-change").getAttribute("data-change"),t("#remove-assoc").removeClass("hidden"),t("#toolbar-copy").hide();var n=document.getElementById("target-id").value,o=""==n?i:n+","+i;document.getElementById("target-id").value=o,i!=a&&(t('#jform_itemlanguage option[value^="'+e+":"+a+':add"]').val(e+":"+i+":edit"),this.setAttribute("data-id",i),this.setAttribute("data-action","edit"));var s=document.getElementById("reference-association"),d=e.replace(/-/,"_"),r=t(this).contents().find("#jform_title").val();t(s).contents().find("#jform_associations_"+d+"_id").val(i),t(s).contents().find("#jform_associations_"+d+"_name").val(r),t(s).contents().find("#jform_associations_"+d+"_chzn").remove(),t(s).contents().find("#jform_associations_"+d).append('"),t(s).contents().find("#jform_associations_"+d).val(i).change().chosen()}var s=document.getElementById("reference-association"),c=s.getAttribute("data-id"),d=s.getAttribute("data-language").replace(/-/,"_"),r=t(s).contents().find("#jform_title").val(),l=t(this).contents();l.find("#jform_associations_"+d+"_id").val(c),l.find("#jform_associations_"+d+"_name").val(r),l.find("#jform_associations_"+d+"_chzn").remove();var m=l.find("#jform_associations_"+d);m.append('"),m.val(c).change().chosen();var f,g;t("#jform_itemlanguage option").each(function(){f=t(this).val().split(":"),"undefined"!=typeof f[1]&&"0"!==f[1]&&(g=f[0].replace(/-/,"_"),l.find("#jform_associations_"+g+"_id").val(f[1]),l.find("#jform_associations_"+g+"_chzn").remove(),m=l.find("#jform_associations_"+g),m.append(''),m.val(f[1]).change().chosen())}),Joomla.loadingLayer("hide")}})}); \ No newline at end of file +jQuery(document).ready(function(t){t("#toolbar-target").hide(),t("#toolbar-copy").hide(),Joomla.submitbutton=function(e){if("association.cancel"===e)Joomla.submitform(e);else if("copy"===e){Joomla.loadingLayer("show");var a=document.getElementById("target-association").getAttribute("data-language"),i=window.frames["reference-association"].document.getElementById("jform_language");i.removeAttribute("disabled"),i.value=a,window.frames["reference-association"].Joomla.submitbutton(document.getElementById("adminForm").getAttribute("data-associatedview")+".save2copy")}else if("undo-association"===e){var n=document.getElementById("reference-association"),o=document.getElementById("target-association"),s=(n.getAttribute("data-id"),n.getAttribute("data-language").replace(/-/,"_"));o.getAttribute("data-id"),a=o.getAttribute("data-language").replace(/-/,"_");n=t(n).contents(),o=t(o).contents(),n.find("#jform_associations_"+a+"_id").val(""),n.find("#jform_associations_"+a+"_name").val(""),n.find("#jform_associations_"+a+"_chzn").remove(),n.find("#jform_associations_"+a).val("").change().chosen();var d="";t("#jform_itemlanguage option").each(function(){void 0!==(d=t(this).val().split("|")[0])&&(d=d.replace(/-/,"_"),o.find("#jform_associations_"+d+"_id").val(""),o.find("#jform_associations_"+d+"_chzn").remove(),o.find("#jform_associations_"+d).val("").change().chosen())}),o.find("#jform_associations_"+s+"_id").val(""),o.find("#jform_associations_"+s+"_name").val(""),o.find("#jform_associations_"+s+"_chzn").remove(),o.find("#jform_associations_"+s).val("").change().chosen();var r=t("#jform_itemlanguage").val(),c=a.replace(/_/,"-");t('#jform_itemlanguage option[value="'+r+'"]').val(c+":0:add"),t("#jform_itemlanguage").val("").change(),t("#jform_itemlanguage").trigger("liszt:updated"),Joomla.submitbutton("reference")}else t("#"+e+"-association").contents().find("#jform_language").attr("disabled",!1),window.frames[e+"-association"].Joomla.submitbutton(document.getElementById("adminForm").getAttribute("data-associatedview")+".apply");return!1},Joomla.loadingLayer("load"),t(document).on("click","#toogle-left-panel",function(){var e=this.getAttribute("data-hide-reference"),a=this.getAttribute("data-show-reference");t(this).text()===e?t(this).text(a):t(this).text(e),t("#left-panel").toggle(),t("#right-panel").toggleClass("full-width")}),t(document).on("change","#jform_itemlanguage",function(){var e=document.getElementById("target-association"),a=t(this).val();""!==a&&void 0!==a?(e.setAttribute("data-action",a.split(":")[2]),e.setAttribute("data-id",a.split(":")[1]),e.setAttribute("data-language",a.split(":")[0]),Joomla.loadingLayer("show"),e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+"."+e.getAttribute("data-action")+"&id="+e.getAttribute("data-id")):(t("#toolbar-target").hide(),t("#toolbar-copy").hide(),t("#select-change").addClass("hidden"),t("#remove-assoc").addClass("hidden"),e.setAttribute("data-action",""),e.setAttribute("data-id","0"),e.setAttribute("data-language",""),e.src="")}),t("#reference-association").on("load",function(){if(document.getElementById("target-association").setAttribute("src",document.getElementById("target-association").getAttribute("src")),t(this).contents().find("#jform_id").val()!==this.getAttribute("data-id")){var e=document.getElementById("target-association");e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+".edit&id="+t(this).contents().find("#jform_id").val(),this.src=this.getAttribute("data-editurl")+"&task="+this.getAttribute("data-item")+".edit&id="+this.getAttribute("data-id")}var a=t(this).contents();a.find("#jform_language_chzn").remove(),a.find("#jform_language").attr("disabled",!0).chosen(),a.find("#associations").find(".btn").remove();var i="";t("#jform_itemlanguage option").each(function(){void 0!==(i=t(this).val().split(":"))[0]&&(langAssociation=i[0].replace(/-/,"_"),""==a.find("#jform_associations_"+langAssociation+"_id").val()&&a.find("#jform_associations_"+langAssociation+"_name").val(document.getElementById("reference-association").getAttribute("data-no-assoc")))}),Joomla.loadingLayer("hide")}),t("#target-association").on("load",function(){if(""!=this.getAttribute("src")){t("#toolbar-target").show(),t("#toolbar-copy").show(),t("#select-change").removeClass("hidden");var e=this.getAttribute("data-language"),a=this.getAttribute("data-id"),i=t(this).contents().find("#jform_id").val()||"0";if(t(this).contents().find('a[href="#associations"]').parent().find(".btn").remove(),t(this).contents().find("#associations").find(".btn").remove(),t(this).contents().find("#associations").hasClass("active")&&(t(this).contents().find('a[href="#associations"]').parent().removeClass("active"),t(this).contents().find("#associations").removeClass("active"),t(this).contents().find(".nav-tabs").find("li").first().addClass("active"),t(this).contents().find(".tab-content").find(".tab-pane").first().addClass("active")),t(this).contents().find("#jform_language_chzn").remove(),t(this).contents().find("#jform_language").val(e).change().attr("disabled",!0).chosen(),"0"==i)document.getElementById("select-change-text").innerHTML=document.getElementById("select-change").getAttribute("data-select");else{document.getElementById("select-change-text").innerHTML=document.getElementById("select-change").getAttribute("data-change"),t("#remove-assoc").removeClass("hidden"),t("#toolbar-copy").hide();var n=document.getElementById("target-id").value,o=""==n?i:n+","+i;document.getElementById("target-id").value=o,i!=a&&(t('#jform_itemlanguage option[value^="'+e+":"+a+':add"]').val(e+":"+i+":edit"),this.setAttribute("data-id",i),this.setAttribute("data-action","edit"));var s=document.getElementById("reference-association"),d=e.replace(/-/,"_"),r=s.getAttribute("data-title"),c=t(this).contents().find("#jform_"+r).val();t(s).contents().find("#jform_associations_"+d+"_id").val(i),t(s).contents().find("#jform_associations_"+d+"_name").val(c),t(s).contents().find("#jform_associations_"+d+"_chzn").remove(),t(s).contents().find("#jform_associations_"+d).append('"),t(s).contents().find("#jform_associations_"+d).val(i).change().chosen()}var l,m=(s=document.getElementById("reference-association")).getAttribute("data-id"),g=(d=s.getAttribute("data-language").replace(/-/,"_"),(l=document.getElementById("target-association")).getAttribute("data-title"));c=t(this).contents().find("#jform_"+g).val();(l=t(this).contents()).find("#jform_associations_"+d+"_id").val(m),l.find("#jform_associations_"+d+"_name").val(c),l.find("#jform_associations_"+d+"_chzn").remove();var f,u,_=l.find("#jform_associations_"+d);_.append('"),_.val(m).change().chosen(),t("#jform_itemlanguage option").each(function(){void 0!==(f=t(this).val().split(":"))[1]&&"0"!==f[1]&&(u=f[0].replace(/-/,"_"),l.find("#jform_associations_"+u+"_id").val(f[1]),l.find("#jform_associations_"+u+"_chzn").remove(),(_=l.find("#jform_associations_"+u)).append(''),_.val(f[1]).change().chosen())}),Joomla.loadingLayer("hide")}})}); \ No newline at end of file