Skip to content

Commit

Permalink
mark all as read button. close [#28]
Browse files Browse the repository at this point in the history
  • Loading branch information
tribela committed Jan 14, 2014
1 parent f55ec63 commit 103736c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions earthreader/web/static/css/master.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ input:not([type=button]):not([type=submit]):focus, textarea:focus {
padding: 1.5em 2em;
}

[role=main] > header a {
margin: 0 1em;
}

[role=main] article .entry-content {
padding: 1em 3em;
line-height: 1.4;
Expand Down
19 changes: 19 additions & 0 deletions earthreader/web/static/js/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ function getEntries(feed_url, filter) {
var header = $('<header>');
var h2 = $('<h2>');
var refresh = $('<a>');
var mark_all = $('<a>');

main.html(null);

Expand All @@ -398,6 +399,11 @@ function getEntries(feed_url, filter) {
refresh.text('crawl now');
header.append(refresh);

mark_all.addClass('mark_all');
mark_all.attr('href', obj.read_url);
mark_all.text('mark all as read');
header.append(mark_all);

main.append(header);

if (entries.length === 0) {
Expand Down Expand Up @@ -620,6 +626,18 @@ function refreshFeed() {
});
}

function markAllRead() {
var target = $('[role=main] .mark_all');
var url = target.attr('href');

target.addClass('requesting');
$.ajax(url, {'type': 'PUT'})
.done(function() {
target.removeClass('requesting');
$('.entry-title').addClass('read');
});
}

function clickLink(event) {
var target = event.target;

Expand Down Expand Up @@ -822,6 +840,7 @@ $(function () {
main.on('click', '.entry-title', clickEntry);
main.on('click', '.nextPage', loadNextPage);
main.on('click', '.refresh', refreshFeed);
main.on('click', '.mark_all', markAllRead);

var side = $('[role=complementary]');
side.on('click', '[data-action]', clickComplementaryMenu);
Expand Down

0 comments on commit 103736c

Please sign in to comment.