remove multiple definition of data-item-page

This commit is contained in:
Mathias Kresin 2014-12-04 12:08:17 +01:00
parent a4d8abb631
commit 0aa5252c85
7 changed files with 36 additions and 27 deletions

30
assets/js/all.min.js vendored
View File

@ -1,19 +1,19 @@
var Miniflux={};Miniflux.App=function(){return{Run:function(){Miniflux.Event.ListenKeyboardEvents();Miniflux.Event.ListenMouseEvents()}}}();
Miniflux.Feed=function(){var e=[],d=[];return{Update:function(a,d){var e=document.getElementById("items-count-"+a);if(e){e.parentNode.className="loading-icon";var c=new XMLHttpRequest;c.onload=function(){e.parentNode.className="";var c=JSON.parse(this.responseText);if(c.result){var f=c.items_count,g=document.getElementById("items-count-"+a);g&&(g.innerHTML=f.items_unread+"/"+f.items_total)}d&&d(c)};c.open("POST","?action=refresh-feed&feed_id="+a,!0);c.send()}},UpdateAll:function(){for(var a=document.getElementsByTagName("a"),
b=0,h=a.length;b<h;b++){var c=a[b].getAttribute("data-feed-id");c&&e.push(parseInt(c))}var k=setInterval(function(){for(;0<e.length&&5>d.length;){var c=e.shift();d.push(c);Miniflux.Feed.Update(c,function(c){c=d.indexOf(c.feed_id);0<=c&&d.splice(c,1);0===e.length&&0===d.length&&(clearInterval(k),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 a=c.innerHTML;c.innerHTML=c.getAttribute("data-reverse-label");c.setAttribute("data-reverse-label",a)}}function a(c){"mouse"!==Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();c.parentNode.removeChild(c);var a=document.getElementById("page-counter");if(a){c=c.getAttribute("data-item-page");var d=parseInt(a.textContent,10)-1,b=document.getElementsByTagName("article");
if(0===d||0===b.length)window.location=location.href;a.textContent=d;switch(c){case "unread":document.title="Miniflux ("+d+")";document.getElementById("nav-counter").textContent=d;break;case "feed-items":document.title="("+d+") "+a.parentNode.firstChild.nodeValue;break;default:document.title=a.parentNode.firstChild.nodeValue+" ("+d+")"}}}function b(c){var b=e(c),f=new XMLHttpRequest;f.onload=function(){if(Miniflux.Nav.IsListing())if(c.getAttribute("data-hide"))a(c);else{c.setAttribute("data-item-status",
"read");var b=c.querySelector("a.mark");d(b);(b=c.querySelector("a.mark"))&&b.setAttribute("data-action","mark-unread")}};f.open("POST","?action=mark-item-read&id="+b,!0);f.send()}function h(c){var b=e(c),f=new XMLHttpRequest;f.onload=function(){if(Miniflux.Nav.IsListing())if(c.getAttribute("data-hide"))a(c);else{c.setAttribute("data-item-status","unread");var b=c.querySelector("a.mark");d(b);(b=c.querySelector("a.mark"))&&b.setAttribute("data-action","mark-read")}};f.open("POST","?action=mark-item-unread&id="+
b,!0);f.send()}return{MarkAsRead:b,MarkAsUnread:h,MarkAsRemoved:function(c){var b=e(c),d=new XMLHttpRequest;d.onload=function(){Miniflux.Nav.IsListing()&&a(c)};d.open("POST","?action=mark-item-removed&id="+b,!0);d.send()},SwitchBookmark:function(c){var b=e(c),f="1"===c.getAttribute("data-item-bookmark")?"0":"1",g=new XMLHttpRequest;g.onload=function(){if(Miniflux.Nav.IsListing()&&"bookmarks"===c.getAttribute("data-item-page"))a(c);else if(c.setAttribute("data-item-bookmark",f),Miniflux.Nav.IsListing()){var b=
c.querySelector("a.bookmark");d(b)}else if((b=c.querySelector("a.bookmark-icon"))&&b.hasAttribute("data-reverse-title")){var e=b.getAttribute("title");b.setAttribute("title",b.getAttribute("data-reverse-title"));b.setAttribute("data-reverse-title",e)}};g.open("POST","?action=bookmark&id="+b+"&value="+f,!0);g.send()},SwitchStatus:function(c){var a=c.getAttribute("data-item-status");"read"===a?h(c):"unread"===a&&b(c)},Show:function(c){(c=c.querySelector("a.show"))&&c.click()},OpenOriginal:function(c){var a=
c.querySelector("a.original");a&&("unread"===c.getAttribute("data-item-status")&&b(c),a.removeAttribute("data-action"),a.click())},DownloadContent:function(c){var a=document.getElementById("download-item");if(a){a.innerHTML=" "+a.getAttribute("data-before-message");a.className="loading-icon";var b=new XMLHttpRequest;b.onload=function(){var c=JSON.parse(b.responseText);a.className="";if(c.result){var d=document.getElementById("item-content");d&&(d.innerHTML=c.content);a.innerHTML=a.getAttribute("data-after-message")}else a.innerHTML=
a.getAttribute("data-failure-message")};c=e(c);b.open("POST","?action=download-item&id="+c,!0);b.send()}},MarkListingAsRead:function(a){for(var b=document.getElementsByTagName("article"),d=[],g=0,h=b.length;g<h;g++)d.push(e(b[g]));b=new XMLHttpRequest;b.onload=function(){window.location.href=a};b.open("POST","?action=mark-items-as-read",!0);b.send(JSON.stringify(d))},ToggleRTLMode:function(){for(var a=["#current-item h1","#item-content","#current-item h2","#current-item .preview"],b=0;b<a.length;b++){var d=
document.querySelector(a[b]);d&&(d.dir=""==d.dir?"rtl":"")}}}}();
Miniflux.Event=function(){var e=[];return{lastEventType:"",ListenMouseEvents:function(){document.onclick=function(d){var a=d.target.getAttribute("data-action");if(a){Miniflux.Event.lastEventType="mouse";var b;a:{for(element=d.target;element&&element.parentNode;)if(element=element.parentNode,element.tagName&&"article"===element.tagName.toLowerCase()){b=element;break a}b=null}switch(a){case "refresh-all":d.preventDefault();Miniflux.Feed.UpdateAll();break;case "refresh-feed":d.preventDefault();Miniflux.Feed.Update(d.target.getAttribute("data-feed-id"));
break;case "mark-read":d.preventDefault();Miniflux.Item.MarkAsRead(b);break;case "mark-unread":d.preventDefault();Miniflux.Item.MarkAsUnread(b);break;case "mark-removed":d.preventDefault();Miniflux.Item.MarkAsRemoved(b);break;case "bookmark":d.preventDefault();Miniflux.Item.SwitchBookmark(b);break;case "download-item":d.preventDefault();Miniflux.Item.DownloadContent(b);break;case "original-link":d.preventDefault();Miniflux.Item.OpenOriginal(b);break;case "mark-all-read":d.preventDefault();Miniflux.Item.MarkListingAsRead("?action=unread");
Miniflux.Feed=function(){var e=[],d=[];return{Update:function(a,d){var e=document.getElementById("items-count-"+a);if(e){e.parentNode.className="loading-icon";var b=new XMLHttpRequest;b.onload=function(){e.parentNode.className="";var b=JSON.parse(this.responseText);if(b.result){var f=b.items_count,h=document.getElementById("items-count-"+a);h&&(h.innerHTML=f.items_unread+"/"+f.items_total)}d&&d(b)};b.open("POST","?action=refresh-feed&feed_id="+a,!0);b.send()}},UpdateAll:function(){for(var a=document.getElementsByTagName("a"),
c=0,g=a.length;c<g;c++){var b=a[c].getAttribute("data-feed-id");b&&e.push(parseInt(b))}var k=setInterval(function(){for(;0<e.length&&5>d.length;){var b=e.shift();d.push(b);Miniflux.Feed.Update(b,function(b){b=d.indexOf(b.feed_id);0<=b&&d.splice(b,1);0===e.length&&0===d.length&&(clearInterval(k),window.location.href="?action=unread")})}},100)}}}();
Miniflux.Item=function(){function e(b){return item_id=b.getAttribute("data-item-id")}function d(b){if(b&&b.hasAttribute("data-reverse-label")){var a=b.innerHTML;b.innerHTML=b.getAttribute("data-reverse-label");b.setAttribute("data-reverse-label",a)}}function a(b){"mouse"!==Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();b.parentNode.removeChild(b);if(b=document.getElementById("page-counter")){var a=document.querySelector("section.page"),d=parseInt(b.textContent,10)-1,c=document.getElementsByTagName("article");
if(0===d||0===c.length)window.location=location.href;b.textContent=d;switch(a.getAttribute("data-item-page")){case "unread":document.title="Miniflux ("+d+")";document.getElementById("nav-counter").textContent=d;break;case "feed-items":document.title="("+d+") "+b.parentNode.firstChild.nodeValue;break;default:document.title=b.parentNode.firstChild.nodeValue+" ("+d+")"}}}function c(b){var c=e(b),f=new XMLHttpRequest;f.onload=function(){if(Miniflux.Nav.IsListing())if(b.getAttribute("data-hide"))a(b);
else{b.setAttribute("data-item-status","read");var c=b.querySelector("a.mark");d(c);(c=b.querySelector("a.mark"))&&c.setAttribute("data-action","mark-unread")}};f.open("POST","?action=mark-item-read&id="+c,!0);f.send()}function g(b){var c=e(b),f=new XMLHttpRequest;f.onload=function(){if(Miniflux.Nav.IsListing())if(b.getAttribute("data-hide"))a(b);else{b.setAttribute("data-item-status","unread");var c=b.querySelector("a.mark");d(c);(c=b.querySelector("a.mark"))&&c.setAttribute("data-action","mark-read")}};
f.open("POST","?action=mark-item-unread&id="+c,!0);f.send()}return{MarkAsRead:c,MarkAsUnread:g,MarkAsRemoved:function(b){var c=e(b),d=new XMLHttpRequest;d.onload=function(){Miniflux.Nav.IsListing()&&a(b)};d.open("POST","?action=mark-item-removed&id="+c,!0);d.send()},SwitchBookmark:function(b){var c=e(b),f="1"===b.getAttribute("data-item-bookmark")?"0":"1",h=new XMLHttpRequest;h.onload=function(){var c=document.querySelector("section.page");if(Miniflux.Nav.IsListing()&&"bookmarks"===c.getAttribute("data-item-page"))a(b);
else if(b.setAttribute("data-item-bookmark",f),Miniflux.Nav.IsListing())c=b.querySelector("a.bookmark"),d(c);else if((c=b.querySelector("a.bookmark-icon"))&&c.hasAttribute("data-reverse-title")){var e=c.getAttribute("title");c.setAttribute("title",c.getAttribute("data-reverse-title"));c.setAttribute("data-reverse-title",e)}};h.open("POST","?action=bookmark&id="+c+"&value="+f,!0);h.send()},SwitchStatus:function(b){var a=b.getAttribute("data-item-status");"read"===a?g(b):"unread"===a&&c(b)},Show:function(b){(b=
b.querySelector("a.show"))&&b.click()},OpenOriginal:function(b){var a=b.querySelector("a.original");a&&("unread"===b.getAttribute("data-item-status")&&c(b),a.removeAttribute("data-action"),a.click())},DownloadContent:function(b){var a=document.getElementById("download-item");if(a){a.innerHTML=" "+a.getAttribute("data-before-message");a.className="loading-icon";var c=new XMLHttpRequest;c.onload=function(){var b=JSON.parse(c.responseText);a.className="";if(b.result){var d=document.getElementById("item-content");
d&&(d.innerHTML=b.content);a.innerHTML=a.getAttribute("data-after-message")}else a.innerHTML=a.getAttribute("data-failure-message")};b=e(b);c.open("POST","?action=download-item&id="+b,!0);c.send()}},MarkListingAsRead:function(b){for(var a=document.getElementsByTagName("article"),c=[],d=0,g=a.length;d<g;d++)c.push(e(a[d]));a=new XMLHttpRequest;a.onload=function(){window.location.href=b};a.open("POST","?action=mark-items-as-read",!0);a.send(JSON.stringify(c))},ToggleRTLMode:function(){for(var a=["#current-item h1",
"#item-content","#current-item h2","#current-item .preview"],c=0;c<a.length;c++){var d=document.querySelector(a[c]);d&&(d.dir=""==d.dir?"rtl":"")}}}}();
Miniflux.Event=function(){var e=[];return{lastEventType:"",ListenMouseEvents:function(){document.onclick=function(d){var a=d.target.getAttribute("data-action");if(a){Miniflux.Event.lastEventType="mouse";var c;a:{for(element=d.target;element&&element.parentNode;)if(element=element.parentNode,element.tagName&&"article"===element.tagName.toLowerCase()){c=element;break a}c=null}switch(a){case "refresh-all":d.preventDefault();Miniflux.Feed.UpdateAll();break;case "refresh-feed":d.preventDefault();Miniflux.Feed.Update(d.target.getAttribute("data-feed-id"));
break;case "mark-read":d.preventDefault();Miniflux.Item.MarkAsRead(c);break;case "mark-unread":d.preventDefault();Miniflux.Item.MarkAsUnread(c);break;case "mark-removed":d.preventDefault();Miniflux.Item.MarkAsRemoved(c);break;case "bookmark":d.preventDefault();Miniflux.Item.SwitchBookmark(c);break;case "download-item":d.preventDefault();Miniflux.Item.DownloadContent(c);break;case "original-link":d.preventDefault();Miniflux.Item.OpenOriginal(c);break;case "mark-all-read":d.preventDefault();Miniflux.Item.MarkListingAsRead("?action=unread");
break;case "mark-feed-read":d.preventDefault(),Miniflux.Item.MarkListingAsRead("?action=feed-items&feed_id="+d.target.getAttribute("data-feed-id"))}}}},ListenKeyboardEvents:function(){document.onkeypress=function(d){if(63==d.keyCode||!(d.ctrlKey||d.shiftKey||d.altKey||d.metaKey)){var a=d.target||d.srcElement;if("INPUT"!=a.tagName&&"TEXTAREA"!=a.tagName)if(Miniflux.Event.lastEventType="keyboard",e.push(d.keyCode||d.which),103===e[0])switch(e[1]){case void 0:break;case 117:window.location.href="?action=unread";
e=[];break;case 98:window.location.href="?action=bookmarks";e=[];break;case 104:window.location.href="?action=history";e=[];break;case 115:window.location.href="?action=feeds";e=[];break;case 112:window.location.href="?action=config";e=[];break;default:e=[]}else switch(e=[],a=document.getElementById("current-item"),d.keyCode||d.which){case 100:Miniflux.Item.DownloadContent(a);break;case 112:case 107:Miniflux.Nav.SelectPreviousItem();break;case 110:case 106:Miniflux.Nav.SelectNextItem();break;case 118:Miniflux.Item.OpenOriginal(a);
break;case 111:Miniflux.Item.Show(a);break;case 109:Miniflux.Item.SwitchStatus(a);break;case 102:Miniflux.Item.SwitchBookmark(a);break;case 104:Miniflux.Nav.OpenPreviousPage();break;case 108:Miniflux.Nav.OpenNextPage();break;case 114:Miniflux.Feed.UpdateAll();break;case 63:Miniflux.Nav.ShowHelp();break;case 122:Miniflux.Item.ToggleRTLMode()}}}}}}();
Miniflux.Nav=function(){function e(a){var b=pageYOffset+document.documentElement.clientHeight;(0>b-(a.offsetTop+a.offsetHeight)||b-a.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function d(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var a=document.getElementById("next-page");a&&a.click()},OpenPreviousPage:function(){var a=document.getElementById("previous-page");a&&a.click()},SelectNextItem:function(){var a=document.getElementById("next-item");
if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=0,h=a.length;b<h;b++){if("current-item"===a[b].id){b+1<h&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b+1].id="current-item",e(a[b+1]));break}}else a[0].id="current-item",e(a[0])},SelectPreviousItem:function(){var a=document.getElementById("previous-item");if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=
a.length-1;0<=b;b--){if("current-item"===a[b].id){0<=b-1&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b-1].id="current-item",e(a[b-1]));break}}else a[a.length-1].id="current-item",e(a[a.length-1])},ShowHelp:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},IsListing:d}}();Miniflux.App.Run();
Miniflux.Nav=function(){function e(a){var c=pageYOffset+document.documentElement.clientHeight;(0>c-(a.offsetTop+a.offsetHeight)||c-a.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function d(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var a=document.getElementById("next-page");a&&a.click()},OpenPreviousPage:function(){var a=document.getElementById("previous-page");a&&a.click()},SelectNextItem:function(){var a=document.getElementById("next-item");
if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var c=0,g=a.length;c<g;c++){if("current-item"===a[c].id){c+1<g&&(a[c].id="item-"+a[c].getAttribute("data-item-id"),a[c+1].id="current-item",e(a[c+1]));break}}else a[0].id="current-item",e(a[0])},SelectPreviousItem:function(){var a=document.getElementById("previous-item");if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var c=
a.length-1;0<=c;c--){if("current-item"===a[c].id){0<=c-1&&(a[c].id="item-"+a[c].getAttribute("data-item-id"),a[c-1].id="current-item",e(a[c-1]));break}}else a[a.length-1].id="current-item",e(a[a.length-1])},ShowHelp:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},IsListing:d}}();Miniflux.App.Run();

View File

@ -67,7 +67,7 @@ Miniflux.Item = (function() {
var pageCounter = document.getElementById("page-counter");
if (pageCounter) {
var source = item.getAttribute("data-item-page");
var sectionElement = document.querySelector("section.page");
var counter = parseInt(pageCounter.textContent, 10) - 1;
var articles = document.getElementsByTagName("article");
@ -77,7 +77,7 @@ Miniflux.Item = (function() {
pageCounter.textContent = counter;
switch (source) {
switch (sectionElement.getAttribute("data-item-page")) {
case "unread":
document.title = "Miniflux (" + counter + ")";
document.getElementById("nav-counter").textContent = counter;
@ -137,7 +137,9 @@ Miniflux.Item = (function() {
var request = new XMLHttpRequest();
request.onload = function() {
if (Miniflux.Nav.IsListing() && item.getAttribute("data-item-page") === "bookmarks") {
var sectionElement = document.querySelector("section.page");
if (Miniflux.Nav.IsListing() && sectionElement.getAttribute("data-item-page") === "bookmarks") {
hideItem(item);
}
else {

View File

@ -4,7 +4,6 @@
data-item-id="<?= $item['id'] ?>"
data-item-status="<?= $item['status'] ?>"
data-item-bookmark="<?= $item['bookmark'] ?>"
data-item-page="<?= $menu ?>"
<?= $hide ? 'data-hide="true"' : '' ?>
>
<h2 <?= Helper\isRTL($item) ? 'dir="rtl"' : '' ?>>

View File

@ -46,7 +46,7 @@
</ul>
</nav>
</header>
<section class="page">
<section class="page" data-item-page="<?= $menu ?>">
<?= Helper\flash('<div class="alert alert-success">%s</div>') ?>
<?= Helper\flash_error('<div class="alert alert-error">%s</div>') ?>
<?= $content_for_layout ?>

View File

@ -7,7 +7,6 @@
data-item-id="<?= $item['id'] ?>"
data-item-status="<?= $item['status'] ?>"
data-item-bookmark="<?= $item['bookmark'] ?>"
data-item-page="<?= $menu ?>"
>
<?php if (isset($item_nav)): ?>

View File

@ -317,6 +317,9 @@ article[data-item-bookmark="1"] .bookmark-icon:before {
article[data-item-bookmark="0"] .bookmark-icon:before {
content: "☆"; }
section.page[data-item-page="feed-items"] article[data-item-status="read"] {
background-color: rgba(153, 153, 153, 0.7); }
.items article {
-moz-box-shadow: 0 3px 0 #006644;
-webkit-box-shadow: 0 3px 0 #006644;
@ -324,8 +327,6 @@ article[data-item-bookmark="0"] .bookmark-icon:before {
background-color: #fFFFFF;
margin-bottom: 15px;
padding: 10px 20px; }
.items article[data-item-status="read"][data-item-page="feed-items"] {
background-color: rgba(153, 153, 153, 0.7); }
.items article[data-item-status="read"] .read-icon:before {
content: "✔"; }
.items article[data-item-bookmark="1"] .item-menu a.bookmark:before {

View File

@ -12,6 +12,18 @@ article {
}
}
section {
&.page {
&[data-item-page="feed-items"] {
article {
&[data-item-status="read"] {
background-color: rgba(lighten(black,60%), .7);
}
}
}
}
}
.items {
article {
@ -21,10 +33,6 @@ article {
padding: 10px 20px;
&[data-item-status="read"] {
&[data-item-page="feed-items"] {
background-color: rgba(lighten(black,60%), .7);
}
.read-icon:before {
content: $icon-read;
}