Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into alexandrenorman-master
  • Loading branch information
mboinet committed May 20, 2013
2 parents 3a1eb6b + bafc7c8 commit dd40e88
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ <h1>Settings</h1>
id="articles-number" value="10" type="number">
<input name="artOldestFirst" id="articles-oldest-first" type="checkbox">
<label for="articles-oldest-first">Show oldest articles first</label>
<input name="hideEmptyCategories" id="hide-empty-categories" type="checkbox">
<label for="hide-empty-categories">Hide empty categories</label>
</form>
</div>
<div class="version">
Expand Down
11 changes: 7 additions & 4 deletions src/scripts/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ define(['api','backbone','utils'],
// only action for a category: read
var request = {
op: "getCategories",
enable_nested: "false"
enable_nested: "false",
include_empty: (settings.attributes.hideEmptyCategories=="false"), // do not get empty categories
unread_only: settings.attributes.hideEmptyCategories // get only feeds with unread articles
// we want nested ones but they will not be
// nested yet
};
Expand Down Expand Up @@ -131,7 +133,8 @@ define(['api','backbone','utils'],
var request = {
op: "getFeeds",
cat_id: catId,
include_nested: false
include_nested: false,
unread_only: settings.attributes.hideEmptyCategories // get only feeds with unread articles
};

api.ttRssApiCall(
Expand Down Expand Up @@ -166,7 +169,7 @@ define(['api','backbone','utils'],
function(m){

if (m.length == 0){
utils.log("ArticleModel.sync: recived nothing for article " +
utils.log("ArticleModel.sync: received nothing for article " +
model.id);
model.set("title", "Error");
model.set("content",
Expand Down Expand Up @@ -298,7 +301,7 @@ define(['api','backbone','utils'],
if (collection.feedId != feedId){
/* this is another feed, force a clean
to trigger delete/add events */
collection.set({});
collection.set([]); // works on HP touchpad but collection.set({}) stopped the execution of code right here
}

// efficiently set the collection
Expand Down
43 changes: 25 additions & 18 deletions src/scripts/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ define(['jquery', 'models', 'templates','conf','utils'],
if (this.model.get('unread') == 0){
this.el.classList.add('read');
}

return this;
},

Expand Down Expand Up @@ -73,24 +72,24 @@ define(['jquery', 'models', 'templates','conf','utils'],

// li element to add
var li = row.render().el;

// add an id to the li element
li.id = 'cat' + catId;

if (catId < 0){
// Special category comes at the top with a separator
this.$lv.prepend(tpl.listSeparator({ text: '&nbsp;' }));

//TODO Labels category can be added here

this.$lv.prepend(li);
} else {
// Other categories comes at the bottom, we order them
// accordingly to the collection order

// current position in the collection
var pos = this.collection.indexOf(row.model);

if (pos == this.collection.length - 1){
// the last one in the collection
this.$lv.append(li);
Expand All @@ -106,7 +105,6 @@ define(['jquery', 'models', 'templates','conf','utils'],
}
}
}

}, //addCat

// called when the data must be refreshed
Expand Down Expand Up @@ -244,7 +242,7 @@ define(['jquery', 'models', 'templates','conf','utils'],
if (this.model.get('unread') == 0){
this.el.classList.add('read');
} else {
this.el.classList.remove('read');
// this.el.classList.remove('read'); // BUG HERE on HP Touchpad
}
},

Expand Down Expand Up @@ -311,17 +309,18 @@ define(['jquery', 'models', 'templates','conf','utils'],
this.$lv.empty();
}

var row = new FeedRowView({model: model});

var row = new FeedRowView({model: model});

// li element to add
var li = row.render().el;

// add an id to the li element to find it back easily later
li.id = 'feed' + model.id;

// append it to the list at the good position
var pos = this.collection.indexOf(row.model);

if (pos == this.collection.length - 1){
// the last one in the collection
this.$lv.append(li);
Expand All @@ -336,7 +335,6 @@ define(['jquery', 'models', 'templates','conf','utils'],
this.$lv.append(li);
}
}

}, //addFeed

// called when the data must be refreshed
Expand Down Expand Up @@ -464,14 +462,20 @@ define(['jquery', 'models', 'templates','conf','utils'],

this.el.innerHTML = html;
if (! unread){
this.el.classList.add("read");
this.el.classList.add('read');
}

return this;
}, // render

updateUnread: function(){
this.el.classList.toggle("read");
// make articles with 0 unread not bold
//this.el.classList.toggle('read'); // BUG on HP touchpad !
if (this.model.get('unread') == 0){
this.model.set('unread', false);
} else {
this.model.set('unread', true);
}
},

initialize: function() {
Expand Down Expand Up @@ -702,7 +706,7 @@ define(['jquery', 'models', 'templates','conf','utils'],
this.model = new models.article({id: artId});
}
}

// update the view parts
this.updateBackButton();

Expand Down Expand Up @@ -758,7 +762,7 @@ define(['jquery', 'models', 'templates','conf','utils'],
} else {
this.renderPrevNext();
}

this.renderUnreadToggleButton();
this.listenTo(this.model, "change:unread",
this.renderUnreadToggleButton);
Expand Down Expand Up @@ -1029,8 +1033,10 @@ define(['jquery', 'models', 'templates','conf','utils'],
render: function(){
var artNumber = this.model.get("articlesNumber");
var artOldestFirst = this.model.get("articlesOldestFirst");
var hideEmptyCategories = this.model.get("hideEmptyCategories");
this.$("#articles-number").attr("value", artNumber);
this.$("#articles-oldest-first").prop("checked", artOldestFirst).checkboxradio("refresh");
this.$("#hide-empty-categories").prop("checked", hideEmptyCategories).checkboxradio("refresh");
return this;
},

Expand All @@ -1040,7 +1046,8 @@ define(['jquery', 'models', 'templates','conf','utils'],
event.data.model.set(
{
articlesNumber: $("#articles-number").val(),
articlesOldestFirst: $("#articles-oldest-first").prop("checked")
articlesOldestFirst: $("#articles-oldest-first").prop("checked"),
hideEmptyCategories: $("#hide-empty-categories").prop("checked")
},
{validate: true}
);
Expand Down
1 change: 0 additions & 1 deletion src/style/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ div#read div[data-role=content]>div.main pre {
padding-top: 0em;
padding-bottom: 0em;
}

0 comments on commit dd40e88

Please sign in to comment.