Widget:GroupSelect: mudanças entre as edições

sem sumário de edição
Sem resumo de edição
Sem resumo de edição
Linha 33: Linha 33:
     options<!--{$id|default:''|escape:'html'}--> = wrapper<!--{$id|default:''|escape:'html'}-->.querySelector(".selectwithSearch__options.<!--{$id|default:''|escape:'html'}-->");
     options<!--{$id|default:''|escape:'html'}--> = wrapper<!--{$id|default:''|escape:'html'}-->.querySelector(".selectwithSearch__options.<!--{$id|default:''|escape:'html'}-->");


function addOptions(selectedOpt) {
function addOptions<!--{$id|default:''|escape:'html'}-->(selectedOpt) {
     options<!--{$id|default:''|escape:'html'}-->.innerHTML = "";
     options<!--{$id|default:''|escape:'html'}-->.innerHTML = "";


Linha 43: Linha 43:


         option.phrases.map(phrase => {
         option.phrases.map(phrase => {
             let li = `<li onclick="updateName('${option.group}', '${option.img}', '${option.obs}')"> ${phrase} </li>`;
             let li = `<li onclick="updateName<!--{$id|default:''|escape:'html'}-->('${option.group}', '${option.img}', '${option.obs}')"> ${phrase} </li>`;
             options<!--{$id|default:''|escape:'html'}-->.insertAdjacentHTML("beforeend", li);
             options<!--{$id|default:''|escape:'html'}-->.insertAdjacentHTML("beforeend", li);
         });
         });
Linha 49: Linha 49:
}
}


addOptions();
addOptions<!--{$id|default:''|escape:'html'}-->();


function updateName(selectedValue, img, obs) {
function updateName<!--{$id|default:''|escape:'html'}-->(selectedValue, img, obs) {
     searchInp<!--{$id|default:''|escape:'html'}-->.value = "";
     searchInp<!--{$id|default:''|escape:'html'}-->.value = "";
     addOptions(selectedValue);
     addOptions<!--{$id|default:''|escape:'html'}-->(selectedValue);
     wrapper<!--{$id|default:''|escape:'html'}-->.classList.remove("active");
     wrapper<!--{$id|default:''|escape:'html'}-->.classList.remove("active");
     document.querySelector('#img-select<!--{$id|default:''|escape:'html'}-->').src = window.location.origin + img;
     document.querySelector('#img-select<!--{$id|default:''|escape:'html'}-->').src = window.location.origin + img;