Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ if(placeOfOutdatedQuestionInfo){
if(questionElemExist){
const outdatedInfoContainerClassList = questionElemExist.classList;

const areThereAnswersForQuestion = !CKEDITOR.instances.a_content ? true : false;
const areThereAnswersForQuestion = !CKEDITOR.instances.a_content;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Czy nie brakuje tutaj drugiej negacji - !!CKEDITOR.instances.a_content? W obecnej formie, jeśli a_content jest falsy (czyli np. puste pole edytora z odpowiedzią), to w areThereAnswersForQuestion będzie true (bo jest pojedyncza negacja), a chyba chcemy odwrotnie. Pisałem o tym w komentarzu.

Copy link
Contributor Author

@wizarddos wizarddos Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Czy nie brakuje tutaj drugiej negacji

Nie nie brakuje. jeżeli od razu jest wyświetlana instancja CKEditora to wyrażenie zwraca false, ponieważ nie ma przycisku anuluj, więc po co dodawać event listenera do czegoś co nie istnieje?
Trochę się tutaj jednak pomyliłem przy nazywaniu. Powinno to być bardziej coś w stylu cancelButtonExist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.




document.querySelector('#q_doanswer').addEventListener('click', ()=>{
outdatedInfoContainerClassList.contains('hidden') ? outdatedInfoContainerClassList.remove('hidden') : outdatedInfoContainerClassList.add('hidden');
outdatedInfoContainerClassList.toggle('hidden');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie .toggle('hidden') tylko .remove('hidden') - eksplicytnie usuwamy klasę (pokazując tym samym komunikat) na kliknięcie w przycisk dodający odpowiedź. Tak jak pokazałem w komentarzu.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie jestem pewny czy to mogłoby zadziałać. Formularz odpowiedzi możemy zamknąć również przyciskiem otwierania odpowiedzi, a nie tylko czerwonym anuluj. Toggle jest tu aby nie było jasno narzucone, którym przyciskiem mamy zamykać formularz

Copy link
Member

@ScriptyChris ScriptyChris Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faktycznie, przycisk "Odpowiedz" toggluje formularz z edytorem - nie zauważyłem. Więc .toggle('hidden') może zostać.

if(areThereAnswersForQuestion){
const cancelAnswer = CKEDITOR.instances.a_content.element.$.form.docancel;
cancelAnswer.addEventListener('click', ()=>{
outdatedInfoContainerClassList.contains('hidden') ? outdatedInfoContainerClassList.remove('hidden') : outdatedInfoContainerClassList.add('hidden');
outdatedInfoContainerClassList.toggle('hidden');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie .toggle('hidden') tylko .add('hidden') - eksplicytnie dodajemy klasę (ukrywając tym samym komunikat) na kliknięcie w przycisk anulujący odpowiedź. Tak jak pokazałem w komentarzu.

}, {once: true});
}
})
Expand Down