From 5690f91fb7b256f830898093b4b1d20d727cc3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Tue, 23 Dec 2014 22:13:23 -0500 Subject: [PATCH] Add keyboard shortcut to toggle RTL mode --- assets/js/all.min.js | 40 ++++++++++++++++---------------- assets/js/event.js | 3 +++ assets/js/item.js | 28 +++++++++++++++++----- locales/cs_CZ/translations.php | 1 + locales/de_DE/translations.php | 1 + locales/es_ES/translations.php | 1 + locales/fr_FR/translations.php | 1 + locales/it_IT/translations.php | 1 + locales/pt_BR/translations.php | 1 + locales/zh_CN/translations.php | 1 + scripts/make-js.sh | 3 +++ templates/keyboard_shortcuts.php | 1 + 12 files changed, 56 insertions(+), 26 deletions(-) diff --git a/assets/js/all.min.js b/assets/js/all.min.js index c79e567..ff35db5 100644 --- a/assets/js/all.min.js +++ b/assets/js/all.min.js @@ -1,20 +1,20 @@ -var Miniflux={};Miniflux.App=function(){return{BlinkIcon:function(){var e=document.querySelectorAll(".loading-icon");[].forEach.call(e,function(c){c.classList.toggle("loading-icon-blink")})},Run:function(){Miniflux.Event.ListenKeyboardEvents();Miniflux.Event.ListenMouseEvents()}}}(); -Miniflux.Feed=function(){function e(d){if(d=document.getElementById("loading-feed-"+d))d.appendChild(document.createTextNode("\u2600")),d.classList.add("loading-icon-blink");f||(f=setInterval(Miniflux.App.BlinkIcon,500))}function c(){for(var d=document.getElementsByTagName("a"),k=0,a=d.length;ka.length;){var c=b.shift();a.push(c);Miniflux.Feed.Update(c, -function(c){c=a.indexOf(c.feed_id);0<=c&&a.splice(c,1);0==b.length&&0==a.length&&(clearInterval(d),clearInterval(f),window.location.href="?action=unread")})}},100)}}}(); -Miniflux.Item=function(){function e(d){return item_id=d.getAttribute("data-item-id")}function c(d){if(d&&d.hasAttribute("data-reverse-label")){var b=d.innerHTML;d.innerHTML=d.getAttribute("data-reverse-label");d.setAttribute("data-reverse-label",b)}}function b(d){"mouse"!==Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();d.parentNode.removeChild(d);var b=document.getElementById("page-counter");if(b){d=d.getAttribute("data-item-page");var c=parseInt(b.textContent,10)-1,a=document.getElementsByTagName("article"); -if(0===c||0===a.length)window.location=location.href;b.textContent=c;switch(d){case "unread":document.title="Miniflux ("+c+")";document.getElementById("nav-counter").textContent=c;break;case "feed-items":document.title="("+c+") "+b.parentNode.firstChild.nodeValue;break;default:document.title=b.parentNode.firstChild.nodeValue+" ("+c+")"}}}function a(d){var a=e(d),g=new XMLHttpRequest;g.onload=function(){if(Miniflux.Nav.IsListing())if(d.getAttribute("data-hide"))b(d);else{d.setAttribute("data-item-status", -"read");var a=d.querySelector("a.mark");c(a);(a=d.querySelector("a.mark"))&&a.setAttribute("data-action","mark-unread")}};g.open("POST","?action=mark-item-read&id="+a,!0);g.send()}function f(d){var a=e(d),g=new XMLHttpRequest;g.onload=function(){if(Miniflux.Nav.IsListing())if(d.getAttribute("data-hide"))b(d);else{d.setAttribute("data-item-status","unread");var a=d.querySelector("a.mark");c(a);(a=d.querySelector("a.mark"))&&a.setAttribute("data-action","mark-read")}};g.open("POST","?action=mark-item-unread&id="+ -a,!0);g.send()}return{MarkAsRead:a,MarkAsUnread:f,MarkAsRemoved:function(d){var c=e(d),a=new XMLHttpRequest;a.onload=function(){Miniflux.Nav.IsListing()&&b(d)};a.open("POST","?action=mark-item-removed&id="+c,!0);a.send()},SwitchBookmark:function(d){var a=e(d),g="1"===d.getAttribute("data-item-bookmark")?"0":"1",h=new XMLHttpRequest;h.onload=function(){if(Miniflux.Nav.IsListing()&&"bookmarks"===d.getAttribute("data-item-page"))b(d);else if(d.setAttribute("data-item-bookmark",g),Miniflux.Nav.IsListing()){var a= -d.querySelector("a.bookmark");c(a)}else if((a=d.querySelector("a.bookmark-icon"))&&a.hasAttribute("data-reverse-title")){var k=a.getAttribute("title");a.setAttribute("title",a.getAttribute("data-reverse-title"));a.setAttribute("data-reverse-title",k)}};h.open("POST","?action=bookmark&id="+a+"&value="+g,!0);h.send()},SwitchStatus:function(d){var b=d.getAttribute("data-item-status");"read"===b?f(d):"unread"===b&&a(d)},Show:function(a){(a=a.querySelector("a.show"))&&a.click()},OpenOriginal:function(b){var c= -b.querySelector("a.original");c&&("unread"===b.getAttribute("data-item-status")&&a(b),c.removeAttribute("data-action"),c.click())},DownloadContent:function(a){var b=document.getElementById("download-item");if(b){a=e(a);var c=b.getAttribute("data-before-message"),h=document.createElement("span");h.appendChild(document.createTextNode("\u2600"));h.className="loading-icon";b.innerHTML="";b.className="downloading";b.appendChild(h);b.appendChild(document.createTextNode(" "+c));var f=setInterval(Miniflux.App.BlinkIcon, -250),l=new XMLHttpRequest;l.onload=function(){var a=JSON.parse(l.responseText);clearInterval(f);if(a.result){var c=document.getElementById("item-content");c&&(c.innerHTML=a.content);b&&(a=b.getAttribute("data-after-message"),b.innerHTML="",b.appendChild(document.createTextNode(" "+a)))}else b&&(a=b.getAttribute("data-failure-message"),b.innerHTML="",b.appendChild(document.createTextNode(" "+a)))};l.open("POST","?action=download-item&id="+a,!0);l.send()}},MarkListingAsRead:function(b){for(var a=document.getElementsByTagName("article"), -c=[],f=0,m=a.length;fa-(b.offsetTop+b.offsetHeight)||a-b.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,b.offsetTop-10)}function c(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var b=document.getElementById("next-page");b&&b.click()},OpenPreviousPage:function(){var b=document.getElementById("previous-page");b&&b.click()},SelectNextItem:function(){var b=document.getElementById("next-item"); -if(b)b.click();else if(c())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=0,f=b.length;aa.length;){var h=b.shift();a.push(h);Miniflux.Feed.Update(h, +function(h){h=a.indexOf(h.feed_id);0<=h&&a.splice(h,1);0==b.length&&0==a.length&&(clearInterval(c),clearInterval(f),window.location.href="?action=unread")})}},100)}}}(); +Miniflux.Item=function(){function e(c){return item_id=c.getAttribute("data-item-id")}function d(c){if(c&&c.hasAttribute("data-reverse-label")){var b=c.innerHTML;c.innerHTML=c.getAttribute("data-reverse-label");c.setAttribute("data-reverse-label",b)}}function b(c){"mouse"!==Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();c.parentNode.removeChild(c);var b=document.getElementById("page-counter");if(b){c=c.getAttribute("data-item-page");var a=parseInt(b.textContent,10)-1,d=document.getElementsByTagName("article"); +if(0===a||0===d.length)window.location=location.href;b.textContent=a;switch(c){case "unread":document.title="Miniflux ("+a+")";document.getElementById("nav-counter").textContent=a;break;case "feed-items":document.title="("+a+") "+b.parentNode.firstChild.nodeValue;break;default:document.title=b.parentNode.firstChild.nodeValue+" ("+a+")"}}}function a(c){var a=e(c),g=new XMLHttpRequest;g.onload=function(){if(Miniflux.Nav.IsListing())if(c.getAttribute("data-hide"))b(c);else{c.setAttribute("data-item-status", +"read");var a=c.querySelector("a.mark");d(a);(a=c.querySelector("a.mark"))&&a.setAttribute("data-action","mark-unread")}};g.open("POST","?action=mark-item-read&id="+a,!0);g.send()}function f(c){var a=e(c),g=new XMLHttpRequest;g.onload=function(){if(Miniflux.Nav.IsListing())if(c.getAttribute("data-hide"))b(c);else{c.setAttribute("data-item-status","unread");var a=c.querySelector("a.mark");d(a);(a=c.querySelector("a.mark"))&&a.setAttribute("data-action","mark-read")}};g.open("POST","?action=mark-item-unread&id="+ +a,!0);g.send()}return{MarkAsRead:a,MarkAsUnread:f,MarkAsRemoved:function(c){var a=e(c),d=new XMLHttpRequest;d.onload=function(){Miniflux.Nav.IsListing()&&b(c)};d.open("POST","?action=mark-item-removed&id="+a,!0);d.send()},SwitchBookmark:function(c){var a=e(c),g="1"===c.getAttribute("data-item-bookmark")?"0":"1",k=new XMLHttpRequest;k.onload=function(){if(Miniflux.Nav.IsListing()&&"bookmarks"===c.getAttribute("data-item-page"))b(c);else if(c.setAttribute("data-item-bookmark",g),Miniflux.Nav.IsListing()){var a= +c.querySelector("a.bookmark");d(a)}else if((a=c.querySelector("a.bookmark-icon"))&&a.hasAttribute("data-reverse-title")){var h=a.getAttribute("title");a.setAttribute("title",a.getAttribute("data-reverse-title"));a.setAttribute("data-reverse-title",h)}};k.open("POST","?action=bookmark&id="+a+"&value="+g,!0);k.send()},SwitchStatus:function(c){var b=c.getAttribute("data-item-status");"read"===b?f(c):"unread"===b&&a(c)},Show:function(a){(a=a.querySelector("a.show"))&&a.click()},OpenOriginal:function(b){var d= +b.querySelector("a.original");d&&("unread"===b.getAttribute("data-item-status")&&a(b),d.removeAttribute("data-action"),d.click())},DownloadContent:function(a){var b=document.getElementById("download-item");if(b){a=e(a);var d=b.getAttribute("data-before-message"),k=document.createElement("span");k.appendChild(document.createTextNode("\u2600"));k.className="loading-icon";b.innerHTML="";b.className="downloading";b.appendChild(k);b.appendChild(document.createTextNode(" "+d));var f=setInterval(Miniflux.App.BlinkIcon, +250),l=new XMLHttpRequest;l.onload=function(){var a=JSON.parse(l.responseText);clearInterval(f);if(a.result){var c=document.getElementById("item-content");c&&(c.innerHTML=a.content);b&&(a=b.getAttribute("data-after-message"),b.innerHTML="",b.appendChild(document.createTextNode(" "+a)))}else b&&(a=b.getAttribute("data-failure-message"),b.innerHTML="",b.appendChild(document.createTextNode(" "+a)))};l.open("POST","?action=download-item&id="+a,!0);l.send()}},MarkListingAsRead:function(a){for(var b=document.getElementsByTagName("article"), +d=[],f=0,m=b.length;fa-(b.offsetTop+b.offsetHeight)||a-b.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,b.offsetTop-10)}function d(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var b=document.getElementById("next-page");b&&b.click()},OpenPreviousPage:function(){var b=document.getElementById("previous-page");b&&b.click()},SelectNextItem:function(){var b=document.getElementById("next-item"); +if(b)b.click();else if(d())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=0,f=b.length;a '', // 'Must be an integer' => '', // 'Remove automatically unread items' => '', + // 'Toggle RTL mode' => '', ); diff --git a/locales/de_DE/translations.php b/locales/de_DE/translations.php index 08d0431..11b302a 100644 --- a/locales/de_DE/translations.php +++ b/locales/de_DE/translations.php @@ -216,4 +216,5 @@ return array( 'Value required' => 'Wert ist erforderlich', 'Must be an integer' => 'Muss eine Ganzzahl sein', // 'Remove automatically unread items' => '', + // 'Toggle RTL mode' => '', ); diff --git a/locales/es_ES/translations.php b/locales/es_ES/translations.php index d938d92..5cb1ecf 100644 --- a/locales/es_ES/translations.php +++ b/locales/es_ES/translations.php @@ -216,4 +216,5 @@ return array( // 'Value required' => '', // 'Must be an integer' => '', // 'Remove automatically unread items' => '', + // 'Toggle RTL mode' => '', ); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index d11165c..c6178e1 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -216,4 +216,5 @@ return array( 'Value required' => 'Value required', 'Must be an integer' => 'Must be an integer', 'Remove automatically unread items' => 'Supprimer automatiquement les éléments non lus', + 'Toggle RTL mode' => 'Basculer entre le mode RTL', ); diff --git a/locales/it_IT/translations.php b/locales/it_IT/translations.php index c1df5ba..e843604 100644 --- a/locales/it_IT/translations.php +++ b/locales/it_IT/translations.php @@ -216,4 +216,5 @@ return array( // 'Value required' => '', // 'Must be an integer' => '', // 'Remove automatically unread items' => '', + // 'Toggle RTL mode' => '', ); diff --git a/locales/pt_BR/translations.php b/locales/pt_BR/translations.php index d1c4c33..2b10c93 100644 --- a/locales/pt_BR/translations.php +++ b/locales/pt_BR/translations.php @@ -216,4 +216,5 @@ return array( // 'Value required' => '', // 'Must be an integer' => '', // 'Remove automatically unread items' => '', + // 'Toggle RTL mode' => '', ); diff --git a/locales/zh_CN/translations.php b/locales/zh_CN/translations.php index 2e3206c..6758552 100644 --- a/locales/zh_CN/translations.php +++ b/locales/zh_CN/translations.php @@ -216,4 +216,5 @@ return array( // 'Value required' => '', // 'Must be an integer' => '', // 'Remove automatically unread items' => '', + // 'Toggle RTL mode' => '', ); diff --git a/scripts/make-js.sh b/scripts/make-js.sh index 0bf2ada..d9c615e 100755 --- a/scripts/make-js.sh +++ b/scripts/make-js.sh @@ -3,6 +3,9 @@ in=assets/js/all.js out=assets/js/all.min.js +rm -f $in 2>/dev/null +rm -f $out 2>/dev/null + cat assets/js/app.js assets/js/feed.js assets/js/item.js assets/js/event.js assets/js/nav.js > $in echo "Miniflux.App.Run();" >> $in diff --git a/templates/keyboard_shortcuts.php b/templates/keyboard_shortcuts.php index c922db1..b6969af 100644 --- a/templates/keyboard_shortcuts.php +++ b/templates/keyboard_shortcuts.php @@ -16,6 +16,7 @@
  • = f
  • = h
  • = l
  • +
  • = z
  • = ?
  • = q