Browse Source

Change link state when marking all entries as read

Frédéric Guillot 8 months ago
parent
commit
d4c1677e38

+ 1
- 0
generate.go View File

@@ -198,6 +198,7 @@ func main() {
198 198
 			"ui/static/js/menu_handler.js",
199 199
 			"ui/static/js/modal_handler.js",
200 200
 			"ui/static/js/nav_handler.js",
201
+			"ui/static/js/link_state_handler.js",
201 202
 			"ui/static/js/bootstrap.js",
202 203
 		},
203 204
 		"sw": []string{

+ 15
- 8
locale/translations.go View File

@@ -38,6 +38,7 @@ var translations = map[string]string{
38 38
     "menu.create_category": "Kategorie anlegen",
39 39
     "menu.mark_page_as_read": "Diese Seite als gelesen markieren",
40 40
     "menu.mark_all_as_read": "Alle als gelesen markieren",
41
+    "menu.mark_all_as_read_wip": "In Arbeit...",
41 42
     "menu.refresh_feed": "Aktualisieren",
42 43
     "menu.refresh_all_feeds": "Alle Abonnements im Hintergrund aktualisieren",
43 44
     "menu.edit_feed": "Bearbeiten",
@@ -326,8 +327,9 @@ var translations = map[string]string{
326 327
     "menu.create_category": "Create a category",
327 328
     "menu.mark_page_as_read": "Mark this page as read",
328 329
     "menu.mark_all_as_read": "Mark all as read",
330
+    "menu.mark_all_as_read_wip": "Operation in progress...",
329 331
     "menu.refresh_feed": "Refresh",
330
-    "menu.refresh_all_feeds": "Refresh all feeds in background",
332
+    "menu.refresh_all_feeds": "Refresh all feeds in the background",
331 333
     "menu.edit_feed": "Edit",
332 334
     "menu.edit_category": "Edit",
333 335
     "menu.add_feed": "Add subscription",
@@ -594,6 +596,7 @@ var translations = map[string]string{
594 596
     "menu.create_category": "Créer une catégorie",
595 597
     "menu.mark_page_as_read": "Marquer cette page comme lu",
596 598
     "menu.mark_all_as_read": "Tout marquer comme lu",
599
+    "menu.mark_all_as_read_wip": "Opération en cours...",
597 600
     "menu.refresh_feed": "Actualiser",
598 601
     "menu.refresh_all_feeds": "Actualiser les abonnements en arrière-plan",
599 602
     "menu.edit_feed": "Modifier",
@@ -882,6 +885,7 @@ var translations = map[string]string{
882 885
     "menu.create_category": "Categorie toevoegen",
883 886
     "menu.mark_page_as_read": "Markeer deze pagina als gelezen",
884 887
     "menu.mark_all_as_read": "Markeer alle items als gelezen",
888
+    "menu.mark_all_as_read_wip": "Bezig...",
885 889
     "menu.refresh_feed": "Vernieuwen",
886 890
     "menu.refresh_all_feeds": "Vernieuw alle feeds in de achtergrond",
887 891
     "menu.edit_feed": "Bewerken",
@@ -1168,6 +1172,7 @@ var translations = map[string]string{
1168 1172
     "menu.create_category": "Utwórz kategorię",
1169 1173
     "menu.mark_page_as_read": "Oznacz jako przeczytane",
1170 1174
     "menu.mark_all_as_read": "Oznacz wszystko jako przeczytane",
1175
+    "menu.mark_all_as_read_wip": "W toku...",
1171 1176
     "menu.refresh_feed": "Odśwież",
1172 1177
     "menu.refresh_all_feeds": "Odśwież wszystkie subskrypcje w tle",
1173 1178
     "menu.edit_feed": "Edytuj",
@@ -1462,6 +1467,7 @@ var translations = map[string]string{
1462 1467
     "menu.create_category": "Создать категорию",
1463 1468
     "menu.mark_page_as_read": "Отметить эту страницу прочитанной",
1464 1469
     "menu.mark_all_as_read": "Отметить всё как прочитанное",
1470
+    "menu.mark_all_as_read_wip": "В процессе…",
1465 1471
     "menu.refresh_feed": "Обновить",
1466 1472
     "menu.refresh_all_feeds": "Обновить все подписки в фоне",
1467 1473
     "menu.edit_feed": "Изменить",
@@ -1738,6 +1744,7 @@ var translations = map[string]string{
1738 1744
     "menu.create_category": "新建分类",
1739 1745
     "menu.mark_page_as_read": "标记为已读",
1740 1746
     "menu.mark_all_as_read": "全标记为已读",
1747
+    "menu.mark_all_as_read_wip": "执行中...",
1741 1748
     "menu.refresh_feed": "更新",
1742 1749
     "menu.refresh_all_feeds": "在后台更新全部源",
1743 1750
     "menu.edit_feed": "编辑",
@@ -1984,11 +1991,11 @@ var translations = map[string]string{
1984 1991
 }
1985 1992
 
1986 1993
 var translationsChecksums = map[string]string{
1987
-	"de_DE": "604b7a957e7633da81585553d17ef401326914e2b6605cfe50450b8f4df44310",
1988
-	"en_US": "7dcc212a35180ba1800d5dcb5c8455e746a5eb0c3c5c79b3b31ca0eb8dc46356",
1989
-	"fr_FR": "e6ebd22a6c75cebf666e18424d489db254f0b34dc15a7002a574929179efb09a",
1990
-	"nl_NL": "3bf3fd429bdf3e46a0be7f7e89eb06b8272a1833a04aca47ed8dd959fcac13a3",
1991
-	"pl_PL": "6fcf2c429ad68cb99e357825e76bc8f79d9ca3b5d01217beed5e502df2eaa5c9",
1992
-	"ru_RU": "5cd9093807f75f27580a1a20f0b4e4b1a4f2dc3c60b93d4fd53b5b01ecd34d71",
1993
-	"zh_CN": "b16c175c71358b073e6098bf053e0387f0c1e4c6ce67794d9074d15b45928d5a",
1994
+	"de_DE": "099dea24a10c4f842674db2ae44f99e99b9c880a6f83e3a42502603fa228fd32",
1995
+	"en_US": "c23d1f16d1dbea72c1e1ba558c7a9c25e0ee8ffda420d50c998efe2fb4d9aa55",
1996
+	"fr_FR": "b123c66c61cda3ae4a978465b7a0e332a83cf386032e1df11c033ed8def9203c",
1997
+	"nl_NL": "b1e548c2b21f013b1b54a07df7df7c06c776cbd7d26fc1fed288bd6970e99c3c",
1998
+	"pl_PL": "8cb856dede8b4f75e4c6aeb0a45f09507c5010f782692e887aae357e99674218",
1999
+	"ru_RU": "0544db0800811fc678521b2e9a7141380919b9ae259b3158524619bf120600ab",
2000
+	"zh_CN": "92687fecfaaf74489714c52903987e7027d8c1cda45b60aa081f7b2165ccaed5",
1994 2001
 }

+ 1
- 0
locale/translations/de_DE.json View File

@@ -33,6 +33,7 @@
33 33
     "menu.create_category": "Kategorie anlegen",
34 34
     "menu.mark_page_as_read": "Diese Seite als gelesen markieren",
35 35
     "menu.mark_all_as_read": "Alle als gelesen markieren",
36
+    "menu.mark_all_as_read_wip": "In Arbeit...",
36 37
     "menu.refresh_feed": "Aktualisieren",
37 38
     "menu.refresh_all_feeds": "Alle Abonnements im Hintergrund aktualisieren",
38 39
     "menu.edit_feed": "Bearbeiten",

+ 2
- 1
locale/translations/en_US.json View File

@@ -33,8 +33,9 @@
33 33
     "menu.create_category": "Create a category",
34 34
     "menu.mark_page_as_read": "Mark this page as read",
35 35
     "menu.mark_all_as_read": "Mark all as read",
36
+    "menu.mark_all_as_read_wip": "Operation in progress...",
36 37
     "menu.refresh_feed": "Refresh",
37
-    "menu.refresh_all_feeds": "Refresh all feeds in background",
38
+    "menu.refresh_all_feeds": "Refresh all feeds in the background",
38 39
     "menu.edit_feed": "Edit",
39 40
     "menu.edit_category": "Edit",
40 41
     "menu.add_feed": "Add subscription",

+ 1
- 0
locale/translations/fr_FR.json View File

@@ -33,6 +33,7 @@
33 33
     "menu.create_category": "Créer une catégorie",
34 34
     "menu.mark_page_as_read": "Marquer cette page comme lu",
35 35
     "menu.mark_all_as_read": "Tout marquer comme lu",
36
+    "menu.mark_all_as_read_wip": "Opération en cours...",
36 37
     "menu.refresh_feed": "Actualiser",
37 38
     "menu.refresh_all_feeds": "Actualiser les abonnements en arrière-plan",
38 39
     "menu.edit_feed": "Modifier",

+ 1
- 0
locale/translations/nl_NL.json View File

@@ -33,6 +33,7 @@
33 33
     "menu.create_category": "Categorie toevoegen",
34 34
     "menu.mark_page_as_read": "Markeer deze pagina als gelezen",
35 35
     "menu.mark_all_as_read": "Markeer alle items als gelezen",
36
+    "menu.mark_all_as_read_wip": "Bezig...",
36 37
     "menu.refresh_feed": "Vernieuwen",
37 38
     "menu.refresh_all_feeds": "Vernieuw alle feeds in de achtergrond",
38 39
     "menu.edit_feed": "Bewerken",

+ 1
- 0
locale/translations/pl_PL.json View File

@@ -33,6 +33,7 @@
33 33
     "menu.create_category": "Utwórz kategorię",
34 34
     "menu.mark_page_as_read": "Oznacz jako przeczytane",
35 35
     "menu.mark_all_as_read": "Oznacz wszystko jako przeczytane",
36
+    "menu.mark_all_as_read_wip": "W toku...",
36 37
     "menu.refresh_feed": "Odśwież",
37 38
     "menu.refresh_all_feeds": "Odśwież wszystkie subskrypcje w tle",
38 39
     "menu.edit_feed": "Edytuj",

+ 1
- 0
locale/translations/ru_RU.json View File

@@ -33,6 +33,7 @@
33 33
     "menu.create_category": "Создать категорию",
34 34
     "menu.mark_page_as_read": "Отметить эту страницу прочитанной",
35 35
     "menu.mark_all_as_read": "Отметить всё как прочитанное",
36
+    "menu.mark_all_as_read_wip": "В процессе…",
36 37
     "menu.refresh_feed": "Обновить",
37 38
     "menu.refresh_all_feeds": "Обновить все подписки в фоне",
38 39
     "menu.edit_feed": "Изменить",

+ 1
- 0
locale/translations/zh_CN.json View File

@@ -33,6 +33,7 @@
33 33
     "menu.create_category": "新建分类",
34 34
     "menu.mark_page_as_read": "标记为已读",
35 35
     "menu.mark_all_as_read": "全标记为已读",
36
+    "menu.mark_all_as_read_wip": "执行中...",
36 37
     "menu.refresh_feed": "更新",
37 38
     "menu.refresh_all_feeds": "在后台更新全部源",
38 39
     "menu.edit_feed": "编辑",

+ 3
- 1
template/html/unread_entries.html View File

@@ -9,7 +9,9 @@
9 9
             <a href="#" data-on-click="markPageAsRead">{{ t "menu.mark_page_as_read" }}</a>
10 10
         </li>
11 11
         <li>
12
-            <a href="{{ route "markAllAsRead" }}">{{ t "menu.mark_all_as_read" }}</a>
12
+            <a data-link-state="flip"
13
+               data-label-new-state="{{ t "menu.mark_all_as_read_wip" }}"
14
+               href="{{ route "markAllAsRead" }}">{{ t "menu.mark_all_as_read" }}</a>
13 15
         </li>
14 16
     </ul>
15 17
     {{ end }}

+ 4
- 2
template/views.go View File

@@ -1261,7 +1261,9 @@ var templateViewsMap = map[string]string{
1261 1261
             <a href="#" data-on-click="markPageAsRead">{{ t "menu.mark_page_as_read" }}</a>
1262 1262
         </li>
1263 1263
         <li>
1264
-            <a href="{{ route "markAllAsRead" }}">{{ t "menu.mark_all_as_read" }}</a>
1264
+            <a data-link-state="flip"
1265
+               data-label-new-state="{{ t "menu.mark_all_as_read_wip" }}"
1266
+               href="{{ route "markAllAsRead" }}">{{ t "menu.mark_all_as_read" }}</a>
1265 1267
         </li>
1266 1268
     </ul>
1267 1269
     {{ end }}
@@ -1387,6 +1389,6 @@ var templateViewsMapChecksums = map[string]string{
1387 1389
 	"search_entries":      "d71849a4f2b0573c7c76ad0ea941812009e9f022de60895987a781d3e6f08a01",
1388 1390
 	"sessions":            "1b3ec0970a4111b81f86d6ed187bb410f88972e2ede6723b9febcc4c7e5fc921",
1389 1391
 	"settings":            "bc04faf83dd977306825973375954600bd014619340188e1243fd9e2f5d5e1a9",
1390
-	"unread_entries":      "058d918592b25bd209c84660dd546b7426f19b1083da868a8672fde9bbcf1b17",
1392
+	"unread_entries":      "880018cbc59ec09b23dd800c4010fadad944d7023e0d36a3872c09b5d4952799",
1391 1393
 	"users":               "4b56cc76fbcc424e7c870d0efca93bb44dbfcc2a08b685cf799c773fbb8dfb2f",
1392 1394
 }

+ 6
- 6
ui/static/css.go
File diff suppressed because it is too large
View File


+ 4
- 0
ui/static/css/common.css View File

@@ -37,6 +37,10 @@ a:hover {
37 37
     text-decoration: none;
38 38
 }
39 39
 
40
+.link-flipped-state {
41
+    font-style: italic;
42
+}
43
+
40 44
 /* Header and main menu */
41 45
 .header {
42 46
     margin-top: 10px;

+ 6
- 4
ui/static/js.go View File

@@ -36,7 +36,7 @@ if(this.queue.length>=2){this.queue=[];}};}
36 36
 isEventIgnored(event){return event.target.tagName==="INPUT"||event.target.tagName==="TEXTAREA";}
37 37
 getKey(event){const mapping={'Esc':'Escape','Up':'ArrowUp','Down':'ArrowDown','Left':'ArrowLeft','Right':'ArrowRight'};for(let key in mapping){if(mapping.hasOwnProperty(key)&&key===event.key){return mapping[key];}}
38 38
 return event.key;}}
39
-class MouseHandler{onClick(selector,callback){let elements=document.querySelectorAll(selector);elements.forEach((element)=>{element.onclick=(event)=>{event.preventDefault();callback(event);};});}}class FormHandler{static handleSubmitButtons(){let elements=document.querySelectorAll("form");elements.forEach((element)=>{element.onsubmit=()=>{let button=document.querySelector("button");if(button){button.innerHTML=button.dataset.labelLoading;button.disabled=true;}};});}}
39
+class MouseHandler{onClick(selector,callback,noPreventDefault){let elements=document.querySelectorAll(selector);elements.forEach((element)=>{element.onclick=(event)=>{noPreventDefault||event.preventDefault();callback(event);};});}}class FormHandler{static handleSubmitButtons(){let elements=document.querySelectorAll("form");elements.forEach((element)=>{element.onsubmit=()=>{let button=document.querySelector("button");if(button){button.innerHTML=button.dataset.labelLoading;button.disabled=true;}};});}}
40 40
 class RequestBuilder{constructor(url){this.callback=null;this.url=url;this.options={method:"POST",cache:"no-cache",credentials:"include",body:null,headers:new Headers({"Content-Type":"application/json","X-Csrf-Token":this.getCsrfToken()})};}
41 41
 withBody(body){this.options.body=JSON.stringify(body);return this;}
42 42
 withCallback(callback){this.callback=callback;return this;}
@@ -91,13 +91,15 @@ if(currentItem===null){items[0].classList.add("current-item");items[0].querySele
91 91
 for(let i=0;i<items.length;i++){if(items[i].classList.contains("current-item")){items[i].classList.remove("current-item");if(i+1<items.length){items[i+1].classList.add("current-item");DomHelper.scrollPageTo(items[i+1]);items[i+1].querySelector('.item-header a').focus();}
92 92
 break;}}}
93 93
 isListView(){return document.querySelector(".items")!==null;}}
94
-document.addEventListener("DOMContentLoaded",function(){FormHandler.handleSubmitButtons();let touchHandler=new TouchHandler();touchHandler.listen();let navHandler=new NavHandler();let keyboardHandler=new KeyboardHandler();keyboardHandler.on("g u",()=>navHandler.goToPage("unread"));keyboardHandler.on("g b",()=>navHandler.goToPage("starred"));keyboardHandler.on("g h",()=>navHandler.goToPage("history"));keyboardHandler.on("g f",()=>navHandler.goToPage("feeds"));keyboardHandler.on("g c",()=>navHandler.goToPage("categories"));keyboardHandler.on("g s",()=>navHandler.goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>navHandler.goToPrevious());keyboardHandler.on("ArrowRight",()=>navHandler.goToNext());keyboardHandler.on("j",()=>navHandler.goToPrevious());keyboardHandler.on("p",()=>navHandler.goToPrevious());keyboardHandler.on("k",()=>navHandler.goToNext());keyboardHandler.on("n",()=>navHandler.goToNext());keyboardHandler.on("h",()=>navHandler.goToPage("previous"));keyboardHandler.on("l",()=>navHandler.goToPage("next"));keyboardHandler.on("o",()=>navHandler.openSelectedItem());keyboardHandler.on("v",()=>navHandler.openOriginalLink());keyboardHandler.on("m",()=>navHandler.toggleEntryStatus());keyboardHandler.on("A",()=>navHandler.markPageAsRead());keyboardHandler.on("s",()=>navHandler.saveEntry());keyboardHandler.on("d",()=>navHandler.fetchOriginalContent());keyboardHandler.on("f",()=>navHandler.toggleBookmark());keyboardHandler.on("?",()=>navHandler.showKeyboardShortcuts());keyboardHandler.on("/",(e)=>navHandler.setFocusToSearchInput(e));keyboardHandler.on("Escape",()=>ModalHandler.close());keyboardHandler.listen();let mouseHandler=new MouseHandler();mouseHandler.onClick("a[data-save-entry]",(event)=>{event.preventDefault();EntryHandler.saveEntry(event.target);});mouseHandler.onClick("a[data-toggle-bookmark]",(event)=>{event.preventDefault();EntryHandler.toggleBookmark(event.target);});mouseHandler.onClick("a[data-toggle-status]",(event)=>{event.preventDefault();let currentItem=DomHelper.findParent(event.target,"entry");if(!currentItem){currentItem=DomHelper.findParent(event.target,"item");}
95
-if(currentItem){EntryHandler.toggleEntryStatus(currentItem);}});mouseHandler.onClick("a[data-fetch-content-entry]",(event)=>{event.preventDefault();EntryHandler.fetchOriginalContent(event.target);});mouseHandler.onClick("a[data-on-click=markPageAsRead]",()=>navHandler.markPageAsRead());mouseHandler.onClick("a[data-confirm]",(event)=>{(new ConfirmHandler()).handle(event);});mouseHandler.onClick("a[data-action=search]",(event)=>{navHandler.setFocusToSearchInput(event);});if(document.documentElement.clientWidth<600){let menuHandler=new MenuHandler();mouseHandler.onClick(".logo",()=>menuHandler.toggleMainMenu());mouseHandler.onClick(".header nav li",(event)=>menuHandler.clickMenuListItem(event));}
94
+class LinkStateHandler{static flip(element){let labelElement=document.createElement("span")
95
+labelElement.className="link-flipped-state";labelElement.appendChild(document.createTextNode(element.dataset.labelNewState));element.parentNode.appendChild(labelElement);element.parentNode.removeChild(element);}}
96
+document.addEventListener("DOMContentLoaded",function(){FormHandler.handleSubmitButtons();let touchHandler=new TouchHandler();touchHandler.listen();let navHandler=new NavHandler();let keyboardHandler=new KeyboardHandler();keyboardHandler.on("g u",()=>navHandler.goToPage("unread"));keyboardHandler.on("g b",()=>navHandler.goToPage("starred"));keyboardHandler.on("g h",()=>navHandler.goToPage("history"));keyboardHandler.on("g f",()=>navHandler.goToPage("feeds"));keyboardHandler.on("g c",()=>navHandler.goToPage("categories"));keyboardHandler.on("g s",()=>navHandler.goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>navHandler.goToPrevious());keyboardHandler.on("ArrowRight",()=>navHandler.goToNext());keyboardHandler.on("j",()=>navHandler.goToPrevious());keyboardHandler.on("p",()=>navHandler.goToPrevious());keyboardHandler.on("k",()=>navHandler.goToNext());keyboardHandler.on("n",()=>navHandler.goToNext());keyboardHandler.on("h",()=>navHandler.goToPage("previous"));keyboardHandler.on("l",()=>navHandler.goToPage("next"));keyboardHandler.on("o",()=>navHandler.openSelectedItem());keyboardHandler.on("v",()=>navHandler.openOriginalLink());keyboardHandler.on("m",()=>navHandler.toggleEntryStatus());keyboardHandler.on("A",()=>navHandler.markPageAsRead());keyboardHandler.on("s",()=>navHandler.saveEntry());keyboardHandler.on("d",()=>navHandler.fetchOriginalContent());keyboardHandler.on("f",()=>navHandler.toggleBookmark());keyboardHandler.on("?",()=>navHandler.showKeyboardShortcuts());keyboardHandler.on("/",(e)=>navHandler.setFocusToSearchInput(e));keyboardHandler.on("Escape",()=>ModalHandler.close());keyboardHandler.listen();let mouseHandler=new MouseHandler();mouseHandler.onClick("a[data-save-entry]",(event)=>{EntryHandler.saveEntry(event.target);});mouseHandler.onClick("a[data-toggle-bookmark]",(event)=>{EntryHandler.toggleBookmark(event.target);});mouseHandler.onClick("a[data-toggle-status]",(event)=>{let currentItem=DomHelper.findParent(event.target,"entry");if(!currentItem){currentItem=DomHelper.findParent(event.target,"item");}
97
+if(currentItem){EntryHandler.toggleEntryStatus(currentItem);}});mouseHandler.onClick("a[data-fetch-content-entry]",(event)=>{EntryHandler.fetchOriginalContent(event.target);});mouseHandler.onClick("a[data-on-click=markPageAsRead]",()=>navHandler.markPageAsRead());mouseHandler.onClick("a[data-confirm]",(event)=>{(new ConfirmHandler()).handle(event);});mouseHandler.onClick("a[data-action=search]",(event)=>{navHandler.setFocusToSearchInput(event);});mouseHandler.onClick("a[data-link-state=flip]",(event)=>{LinkStateHandler.flip(event.target);},true);if(document.documentElement.clientWidth<600){let menuHandler=new MenuHandler();mouseHandler.onClick(".logo",()=>menuHandler.toggleMainMenu());mouseHandler.onClick(".header nav li",(event)=>menuHandler.clickMenuListItem(event));}
96 98
 if("serviceWorker"in navigator){let scriptElement=document.getElementById("service-worker-script");if(scriptElement){navigator.serviceWorker.register(scriptElement.src);}}});})();`,
97 99
 	"sw": `'use strict';self.addEventListener("fetch",(event)=>{if(event.request.url.includes("/feed/icon/")){event.respondWith(caches.open("feed_icons").then((cache)=>{return cache.match(event.request).then((response)=>{return response||fetch(event.request).then((response)=>{cache.put(event.request,response.clone());return response;});});}));}});`,
98 100
 }
99 101
 
100 102
 var JavascriptsChecksums = map[string]string{
101
-	"app": "583320452ca24912512d41f6b31221b14a3e0d53f02511e55246a60d0b56d095",
103
+	"app": "e47094cfa9d58b7306e93c047fc8fd7530c2350f1959aa27e5bff525c4c2c50e",
102 104
 	"sw":  "55fffa223919cc18572788fb9c62fccf92166c0eb5d3a1d6f91c31f24d020be9",
103 105
 }

+ 4
- 5
ui/static/js/bootstrap.js View File

@@ -34,18 +34,14 @@ document.addEventListener("DOMContentLoaded", function() {
34 34
 
35 35
     let mouseHandler = new MouseHandler();
36 36
     mouseHandler.onClick("a[data-save-entry]", (event) => {
37
-        event.preventDefault();
38 37
         EntryHandler.saveEntry(event.target);
39 38
     });
40 39
 
41 40
     mouseHandler.onClick("a[data-toggle-bookmark]", (event) => {
42
-        event.preventDefault();
43 41
         EntryHandler.toggleBookmark(event.target);
44 42
     });
45 43
 
46 44
     mouseHandler.onClick("a[data-toggle-status]", (event) => {
47
-        event.preventDefault();
48
-
49 45
         let currentItem = DomHelper.findParent(event.target, "entry");
50 46
         if (! currentItem) {
51 47
             currentItem = DomHelper.findParent(event.target, "item");
@@ -57,7 +53,6 @@ document.addEventListener("DOMContentLoaded", function() {
57 53
     });
58 54
 
59 55
     mouseHandler.onClick("a[data-fetch-content-entry]", (event) => {
60
-        event.preventDefault();
61 56
         EntryHandler.fetchOriginalContent(event.target);
62 57
     });
63 58
 
@@ -71,6 +66,10 @@ document.addEventListener("DOMContentLoaded", function() {
71 66
         navHandler.setFocusToSearchInput(event);
72 67
     });
73 68
 
69
+    mouseHandler.onClick("a[data-link-state=flip]", (event) => {
70
+        LinkStateHandler.flip(event.target);
71
+    }, true);
72
+
74 73
     if (document.documentElement.clientWidth < 600) {
75 74
         let menuHandler = new MenuHandler();
76 75
         mouseHandler.onClick(".logo", () => menuHandler.toggleMainMenu());

+ 10
- 0
ui/static/js/link_state_handler.js View File

@@ -0,0 +1,10 @@
1
+class LinkStateHandler {
2
+    static flip(element) {
3
+        let labelElement = document.createElement("span")
4
+        labelElement.className = "link-flipped-state";
5
+        labelElement.appendChild(document.createTextNode(element.dataset.labelNewState));
6
+
7
+        element.parentNode.appendChild(labelElement);
8
+        element.parentNode.removeChild(element);
9
+    }
10
+}

+ 2
- 2
ui/static/js/mouse_handler.js View File

@@ -1,9 +1,9 @@
1 1
 class MouseHandler {
2
-    onClick(selector, callback) {
2
+    onClick(selector, callback, noPreventDefault) {
3 3
         let elements = document.querySelectorAll(selector);
4 4
         elements.forEach((element) => {
5 5
             element.onclick = (event) => {
6
-                event.preventDefault();
6
+                noPreventDefault || event.preventDefault();
7 7
                 callback(event);
8 8
             };
9 9
         });

Loading…
Cancel
Save