-
Notifications
You must be signed in to change notification settings - Fork 8
Informacja o dawno zadanym pytaniu #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
fac6f34
1c3a13e
657a33a
dd46a93
fa67d49
afce8f1
b3ea532
8d57fa0
e6348bb
ea2ee2d
80ec452
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| .qa-outdated-question-container{ | ||
| width: 100%; | ||
|
|
||
| text-align: center; | ||
| padding: 1%; | ||
|
|
||
| border: 6px solid #f74040; | ||
| margin-bottom: 2.5%; | ||
| font-size: 1.5rem; | ||
| } | ||
|
|
||
| .hidden{ | ||
| display: none; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| const placeOfOutdatedQuestionInfo = document.querySelector('.qa-a-form'); | ||
| if(placeOfOutdatedQuestionInfo){ | ||
| const publishDateSpan = document.querySelector('.published > .value-title'); | ||
| const now = new Date(); | ||
| const publishDate = new Date(publishDateSpan.title); | ||
| const publishYearOlderThanNow = publishDate.getFullYear() < now.getFullYear(); | ||
| const publishMonthNewerThanNow = publishDate.getMonth() - 1 >= now.getMonth(); | ||
|
|
||
| if (publishYearOlderThanNow && publishMonthNewerThanNow) { | ||
| let shouldBeDisplayed = ""; | ||
| if(placeOfOutdatedQuestionInfo.style.display === 'none'){ | ||
|
||
| shouldBeDisplayed = "hidden"; | ||
| } | ||
| placeOfOutdatedQuestionInfo.insertAdjacentHTML('beforebegin', | ||
| `<p class = "qa-outdated-question-container ${shouldBeDisplayed}"> | ||
| To pytanie zostało zadane już dawno temu i może być nieaktualne.<br/> | ||
| Upewnij się, że Twoja odpowiedź nadal będzie pomocna. | ||
| </p>`); | ||
| } | ||
| const QuestionElemExist = document.querySelector('.qa-outdated-question-container'); | ||
|
||
|
|
||
| if(QuestionElemExist){ | ||
| const cancelAnswer = document.querySelectorAll('input[name=docancel]')[1]; | ||
|
||
| const outdatedInfoContainerClassList = QuestionElemExist.classList; | ||
|
|
||
| cancelAnswer.addEventListener('click', ()=>{ | ||
| outdatedInfoContainerClassList.toggle('hidden'); | ||
| }, false) | ||
|
|
||
| document.querySelector('#q_doanswer').addEventListener('click', ()=>{ | ||
| outdatedInfoContainerClassList.toggle('hidden'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nie
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| }) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?php | ||
|
|
||
| class qa_html_theme_layer extends qa_html_theme_base | ||
| { | ||
| public function head_script(){ | ||
| parent::head_script(); | ||
| $this->output(' | ||
| <script src = "'. QA_HTML_THEME_LAYER_URLTOROOT .'frontend/show-outdated-question-info.js?v=" defer></script> | ||
| <link rel = "stylesheet" href = "'. QA_HTML_THEME_LAYER_URLTOROOT .'frontend/css/styles.css?v=" /> | ||
| '); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?php | ||
|
|
||
| //Don't let this page to be available directly from browser | ||
| if (!defined('QA_VERSION')) { | ||
| header('Location: ../../'); | ||
| exit; | ||
| } | ||
|
|
||
| qa_register_plugin_layer('qa-outdated-question-info-layer.php', 'Outdated Question Info'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Można to przypisanie zrobić przy pomocy ternarki:
Poza tym, nazwa zmiennej sugeruje, że to boolean, a nie string z nazwą klasy, więc to bym poprawił.