Преглед изворни кода

Fix courses visibility toggler button (#257)

Signed-off-by: hossainemruz <hossainemruz@gmail.com>
Emruz Hossain пре 4 година
родитељ
комит
2af89479be

+ 5 - 2
i18n/bn.toml

@@ -68,8 +68,11 @@ other = "অর্জিত ক্রেডিট"
 [extracurricular_activities]
 other = "পাঠক্রম বহির্ভূত কার্যক্রম"
 
-[see_more]
-other = "আরো দেখুন"
+[show_more]
+other = "আরো দেখান"
+
+[show_less]
+other = "কম দেখান"
 
 [responsibilities]
 other = "দায়িত্বসমুহ:"

+ 4 - 1
i18n/cn.toml

@@ -71,9 +71,12 @@ other = "获得分数"
 [extracurricular_activities]
 other = "课外活动"
 
-[see_more]
+[show_more]
 other = "查看更多"
 
+[show_less]
+other = "显示较少"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/de.toml

@@ -71,9 +71,12 @@ other = "Krediet verkregen"
 [extracurricular_activities]
 other = "Buitenschoolse activiteiten"
 
-[see_more]
+[show_more]
 other = "Bekijk meer"
 
+[show_less]
+other = "Laat minder zien"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 5 - 2
i18n/en.toml

@@ -71,8 +71,11 @@ other = "Obtained Credit"
 [extracurricular_activities]
 other = "Extracurricular Activities"
 
-[see_more]
-other = "See More"
+[show_more]
+other = "Show More"
+
+[show_less]
+other = "Show Less"
 
 [responsibilities]
 other = "Responsibilities:"

+ 4 - 1
i18n/es.toml

@@ -71,9 +71,12 @@ other = "Crédito obtenido"
 [extracurricular_activities]
 other = "Actividades extracurriculares"
 
-[see_more]
+[show_more]
 other = "Ver más"
 
+[show_less]
+other = "Muestra menos"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/fr.toml

@@ -71,9 +71,12 @@ other = "Crédit obtenu"
 [extracurricular_activities]
 other = "Activités extra-scolaires"
 
-[see_more]
+[show_more]
 other = "En savoir plus"
 
+[show_less]
+other = "Montrer moins"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/hi.toml

@@ -71,9 +71,12 @@ other = "श्रेय प्राप्त किया"
 [extracurricular_activities]
 other = "अतिरिक्त पाठयक्रम गतिविधियों"
 
-[see_more]
+[show_more]
 other = "और देखें"
 
+[show_less]
+other = "कम दिखाएं"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/id.toml

@@ -71,9 +71,12 @@ other = "Memperoleh Kredit"
 [extracurricular_activities]
 other = "Kegiatan ekstrakulikuler"
 
-[see_more]
+[show_more]
 other = "Lihat Selengkapnya"
 
+[show_less]
+other = "Tampilkan Lebih Sedikit"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/it.toml

@@ -71,9 +71,12 @@ other = "Credito ottenuto"
 [extracurricular_activities]
 other = "Attività extracurriculari"
 
-[see_more]
+[show_more]
 other = "Vedi altro"
 
+[show_less]
+other = "Mostra meno"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/jp.toml

@@ -68,9 +68,12 @@ other = "取得したクレジット"
 [extracurricular_activities]
 other = "課外活動"
 
-[see_more]
+[show_more]
 other = "続きを見る"
 
+[show_less]
+other = "表示を減らす"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/ko.toml

@@ -71,9 +71,12 @@ other = "획득한 수익"
 [extracurricular_activities]
 other = "기타 활동"
 
-[see_more]
+[show_more]
 other = "더보기"
 
+[show_less]
+other = "간단히보기"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/ru.toml

@@ -71,9 +71,12 @@ other = "Полученный кредит"
 [extracurricular_activities]
 other = "Внеклассные занятия"
 
-[see_more]
+[show_more]
 other = "Узнать больше"
 
+[show_less]
+other = "Показывай меньше"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 4 - 1
i18n/vn.toml

@@ -71,9 +71,12 @@ other = "Tín dụng thu được"
 [extracurricular_activities]
 other = "Các hoạt động ngoại khóa"
 
-[see_more]
+[show_more]
 other = "Xem thêm"
 
+[show_less]
+other = "Hiện ít hơn"
+
 # [responsibilities]
 # other = "Responsibilities:"
 

+ 3 - 1
layouts/partials/sections/education-alt.html

@@ -78,7 +78,9 @@
                                 {{ end }}
                                 {{ if gt (len .takenCourses.courses) 2 }}
                                     <button type="button" class="btn btn-link show-more-btn pt-0 {{ if .takenCourses.showGrades }}ml-1{{ else }}ml-2{{ end }}"
-                                    onclick="showMoreCourses(this);">{{ i18n "see_more"}}</button>
+                                    onclick="toggleCourseVisibility(this);" id="show-more-btn">{{ i18n "show_more"}}</button>
+                                    <button type="button" class="btn btn-link show-more-btn hidden pt-0 {{ if .takenCourses.showGrades }}ml-1{{ else }}ml-2{{ end }}"
+                                    onclick="toggleCourseVisibility(this);" id="show-less-btn">{{ i18n "show_less"}}</button>
                                 {{ end }}
                             </div>
                             {{ end }}

+ 3 - 1
layouts/partials/sections/education.html

@@ -78,7 +78,9 @@
                                 {{ end }}
                                 {{ if gt (len .takenCourses.courses ) 2 }}
                                     <button type="button" class="btn btn-link show-more-btn pt-0 {{ if .takenCourses.showGrades }}ml-1{{ else }}ml-2{{ end }}"
-                                    onclick="showMoreCourses(this);">{{ i18n "see_more"}}</button>
+                                    onclick="toggleCourseVisibility(this);" id="show-more-btn">{{ i18n "show_more"}}</button>
+                                    <button type="button" class="btn btn-link show-more-btn hidden pt-0 {{ if .takenCourses.showGrades }}ml-1{{ else }}ml-2{{ end }}"
+                                    onclick="toggleCourseVisibility(this);" id="show-less-btn">{{ i18n "show_less"}}</button>
                                 {{ end }}
                             </div>
                             {{ end }}

+ 8 - 7
static/js/main.js

@@ -139,7 +139,7 @@ function toggleTOC() {
 }
 
 // Show more rows in the taken courses table
-function showMoreCourses(elem) {
+function toggleCourseVisibility(elem) {
 
   // find the courses
   let courses = elem.parentNode.getElementsByClassName("course");
@@ -154,11 +154,12 @@ function showMoreCourses(elem) {
     }
   }
 
-  // toggle the button text
-  let btnText = elem.innerText;
-  if (btnText == "Show More") {
-    elem.innerText = "Show Less";
-  } else {
-    elem.innerText = "Show More";
+  // toggle the current button visibility
+  elem.classList.toggle("hidden");
+  // toggle the alternate button visibility
+  if  (elem.id === "show-more-btn"){
+    document.getElementById("show-less-btn").classList.toggle("hidden");
+  }else{
+    document.getElementById("show-more-btn").classList.toggle("hidden");
   }
 }