Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Make links use JSON for rendering articles
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Le Berrigaud committed Oct 9, 2012
1 parent 6065c74 commit 78af44c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 2 additions & 4 deletions public/js/aggregator/menu_view.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
var SMF = SMF || {};

SMF.MenuView = function(feeds) {
SMF.MenuView = function() {
this.$el = $('#feeds');
this.feeds = feeds;

this.allFeeds = [];
this.$links = $('a', this.$el);
};

SMF.MenuView.prototype = {
initFeeds: function(slugs) {
var self = this;
this.allFeeds = [];

this.$links.each(function() {
var feed = new SMF.Feed($(this));
Expand Down
12 changes: 11 additions & 1 deletion public/js/aggregator/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ SMF.Router.prototype = {
var path = _(document.location.href.split('/')).last();
var slugs = path.split('+');

this.menuView = new SMF.MenuView(this.allFeeds);
this.menuView = new SMF.MenuView();
this.menuView.initFeeds(slugs);

_(this.menuView.allFeeds).each(function(feed) {
feed.$link.click(function(e) {
e.preventDefault();
feed.isSelected = !feed.isSelected;

self.fetchArticlesForSelectedFeeds();
self.menuView.refreshLinks();
});
});
},

fetchArticlesForSelectedFeeds: function() {
Expand Down

0 comments on commit 78af44c

Please sign in to comment.