From 14516ea63ba1de5739672ef8519d97ec54775d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Thu, 10 Oct 2013 22:18:12 -0400 Subject: [PATCH] Add item links for the feed-items page --- assets/js/app.js | 38 ++++++++++++++++++++++++++++++++++++-- index.php | 12 ++++++++---- templates/feed_items.php | 34 ++++++++++++++++++++++++++++++---- templates/history.php | 1 + templates/unread_items.php | 1 + 5 files changed, 76 insertions(+), 10 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 273f0ff..49792a6 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -78,7 +78,16 @@ if (response.status == "read" || response.status == "unread") { find_next_item(); - if (hide) remove_item(response.item_id); + + if (hide) { + remove_item(response.item_id); + } + else if (response.status == "read") { + show_item_as_read(item_id); + } + else if (response.status == "unread") { + show_item_as_unread(item_id); + } } } } @@ -147,6 +156,31 @@ } } + // Show an item as read (change title color and add icon) + function show_item_as_read(item_id) + { + var link = document.getElementById("open-" + item_id); + + if (link) { + link.className = "read"; + + var icon = document.createElement("span"); + icon.id = "read-icon-" + item_id; + icon.appendChild(document.createTextNode("☑ ")); + link.parentNode.insertBefore(icon, link); + } + } + + // Show an item as unread (change title color and remove read icon) + function show_item_as_unread(item_id) + { + var link = document.getElementById("open-" + item_id); + if (link) link.className = ""; + + var icon = document.getElementById("read-icon-" + item_id); + if (icon) icon.parentNode.removeChild(icon); + } + // Show the refresh icon when updating a feed function show_refresh_icon(feed_id) { @@ -260,7 +294,7 @@ if (item.getAttribute("data-item-id") != item_id) item = false; } - if (item) { + if (item && item.getAttribute("data-hide")) { item.parentNode.removeChild(item); var container = document.getElementById("page-counter"); diff --git a/index.php b/index.php index 6693434..0a30bf5 100644 --- a/index.php +++ b/index.php @@ -138,10 +138,11 @@ Router\get_action('mark-item-read', function() { $id = Request\param('id'); $redirect = Request\param('redirect', 'unread'); $offset = Request\int_param('offset', 0); + $feed_id = Request\int_param('feed_id', 0); Model\set_item_read($id); - Response\Redirect('?action='.$redirect.'&offset='.$offset); + Response\Redirect('?action='.$redirect.'&offset='.$offset.'&feed_id='.$feed_id.'#item-'.$id); }); @@ -151,10 +152,11 @@ Router\get_action('mark-item-unread', function() { $id = Request\param('id'); $redirect = Request\param('redirect', 'history'); $offset = Request\int_param('offset', 0); + $feed_id = Request\int_param('feed_id', 0); Model\set_item_unread($id); - Response\Redirect('?action='.$redirect.'&offset='.$offset); + Response\Redirect('?action='.$redirect.'&offset='.$offset.'&feed_id='.$feed_id.'#item-'.$id); }); @@ -164,10 +166,11 @@ Router\get_action('mark-item-removed', function() { $id = Request\param('id'); $redirect = Request\param('redirect', 'history'); $offset = Request\int_param('offset', 0); + $feed_id = Request\int_param('feed_id', 0); Model\set_item_removed($id); - Response\Redirect('?action='.$redirect.'&offset='.$offset); + Response\Redirect('?action='.$redirect.'&offset='.$offset.'&feed_id='.$feed_id); }); @@ -224,6 +227,7 @@ Router\get_action('bookmark', function() { $menu = Request\param('menu', 'unread'); $source = Request\param('source', 'unread'); $offset = Request\int_param('offset', 0); + $feed_id = Request\int_param('feed_id', 0); Model\set_bookmark_value($id, Request\int_param('value')); @@ -231,7 +235,7 @@ Router\get_action('bookmark', function() { Response\Redirect('?action=show&menu='.$menu.'&id='.$id); } - Response\Redirect('?action='.$menu.'&offset='.$offset); + Response\Redirect('?action='.$menu.'&offset='.$offset.'&feed_id='.$feed_id.'#item-'.$id); }); diff --git a/templates/feed_items.php b/templates/feed_items.php index 52641b2..dc9417d 100644 --- a/templates/feed_items.php +++ b/templates/feed_items.php @@ -20,10 +20,10 @@
-
+

- - + ★ ' : '' ?> + ☑ ' : '' ?>

| - | + | + + + + | + + | + + + + + + + | + + + + | + + + + | + | diff --git a/templates/unread_items.php b/templates/unread_items.php index 78b97b0..d151c50 100644 --- a/templates/unread_items.php +++ b/templates/unread_items.php @@ -48,6 +48,7 @@ href="?action=mark-item-read&id=&offset=" data-action="mark-read" data-item-id="" + data-hide="true" > |