';
html += '
Aluno ' + (aluno.numero < 10 ? '0' + aluno.numero : aluno.numero) + '
';
html += '
Nome: ' + FWRViewAlunos.escapeHtml(aluno.nome || '-') + '
';
html += '
CPF: ' + FWRViewAlunos.escapeHtml(aluno.cpf || '-') + '
';
html += '
E-mail: ' + FWRViewAlunos.escapeHtml(aluno.email || '-') + '
';
html += '
Telefone: ' + FWRViewAlunos.escapeHtml(aluno.telefone || '-') + '
';
html += '
Município: ' + FWRViewAlunos.escapeHtml(aluno.municipio || '-') + '
';
html += '
Estado: ' + FWRViewAlunos.escapeHtml(aluno.estado || '-') + '
';
html += '
';
});
}
html += '';
html += '';
return html;
},
injectAll: function () {
var list = document.querySelector(this.listSelector);
if (!list) return;
var items = list.querySelectorAll(this.itemSelector);
var self = this;
items.forEach(function (item) {
self.injectItem(item);
});
},
injectItem: function (item) {
if (!item || item.getAttribute(this.injectedAttr) === '1') return;
var removeBtn = item.querySelector('.remove[data-add]');
if (!removeBtn) return;
var addMsg = removeBtn.getAttribute('data-add') || '';
if (
this.normalize(addMsg).indexOf(this.normalize('Nome Aluno')) === -1 &&
this.normalize(addMsg).indexOf(this.normalize('Aluno 01')) === -1 &&
this.normalize(addMsg).indexOf(this.normalize('Dados dos Alunos')) === -1
) {
return;
}
var lineDown = item.querySelector('.info-product .line-down');
if (!lineDown) return;
var alunos = this.parseAlunos(addMsg);
var wrapper = document.createElement('div');
wrapper.innerHTML = this.buildPanelHtml(alunos);
lineDown.insertAdjacentElement('afterend', wrapper.firstElementChild);
item.setAttribute(this.injectedAttr, '1');
},
observeCart: function () {
var self = this;
var list = document.querySelector(this.listSelector);
if (!list) {
setTimeout(function () {
self.observeCart();
}, 400);
return;
}
var observer = new MutationObserver(function () {
setTimeout(function () {
self.injectAll();
}, 80);
});
observer.observe(list, {
childList: true,
subtree: true
});
},
bindEvents: function () {
document.addEventListener('click', function (event) {
var button = event.target.closest('.fwr-view-alunos__btn');
if (!button) return;
event.preventDefault();
var box = button.closest('.fwr-view-alunos');
if (box) {
box.classList.toggle('is-open');
}
});
}
};
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function () {
FWRViewAlunos.init();
});
} else {
FWRViewAlunos.init();
}
})();