feat(TouristAttractionsAutoJs): Cria condição para aplicar o slick somente com o class do slick

This commit is contained in:
William Simão Cavalcante 2022-11-26 10:48:23 -03:00
parent 9e48537903
commit d9311cec6e

View File

@ -28,7 +28,7 @@ export class TouristAttractions {
this.events(); this.events();
this.carrossel(); this.carrossel();
this.renderListItems(); this.renderListItems();
this.removeSlick(); this.slickAdd();
} }
selectors () { selectors () {
@ -71,6 +71,25 @@ export class TouristAttractions {
} }
}; };
addProperty (e) {
e.preventDefault();
const spotImg = this.spanInput.children[0].src
const spotTitle = e.target['input-title'].value
const spotDescription = e.target['input-description'].value
if (spotImg != '' && spotTitle != '' && spotDescription != '') {
const spot = {
image: spotImg,
titulo: spotTitle,
description: spotDescription,
};
this.list.push(spot);
this.renderListItems();
this.resetInputs();
}
};
renderListItems () { renderListItems () {
let spotStructure = ''; let spotStructure = '';
@ -111,26 +130,14 @@ export class TouristAttractions {
} }
}; };
slickAdd () {
addProperty (e) { const ulListSlick = this.ulList;
e.preventDefault(); if (ulListSlick.classList.value === 'slick-initialized') {
this.carrossel();
const spotImg = this.spanInput.children[0].src }else {
const spotTitle = e.target['input-title'].value this.removeSlick();
const spotDescription = e.target['input-description'].value
if (spotImg != '' && spotTitle != '' && spotDescription != '') {
const spot = {
image: spotImg,
titulo: spotTitle,
description: spotDescription,
};
this.list.push(spot);
this.renderListItems();
this.resetInputs();
} }
}; }
resetInputs () { resetInputs () {
this.inputTitle.value = ''; this.inputTitle.value = '';