Skip to content

Commit

Permalink
load more on section pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Rondio committed Mar 5, 2014
1 parent e1ca5a3 commit e23badc
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 285 deletions.
4 changes: 3 additions & 1 deletion _css/static.css
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ margin-right: 0px;




#load_more{
display:none;
}



Expand Down
36 changes: 36 additions & 0 deletions _js/infiniteScroll/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@


$(function() {





window.lapp = {






init : function(){



this.view = new window.listView();

},

showMoreButton : function (){
$("#load_more").css("display","block");
},

hideMoreButton : function (){
$("#load_more").css("display","none");
}

};

lapp.init();

});
55 changes: 37 additions & 18 deletions _js/infiniteScroll/model_collection.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,64 @@
$(function() {


window.articleModel = Backbone.Model.extend({
});
window.articleModel = Backbone.Model.extend({

isHighlighted : function(){

if (this.get('fields').highlight=="1") return true;

return false;
},

getRendition : function(name) {
// to be updated in API
var renditions = this.get('renditions');
for (var i=0 ; i< renditions.length; i++){
if(renditions[i].caption==name){
return renditions[i].link;
}
}
return false;

window.articlesCollection = Backbone.Collection.extend({
model: articleModel,
items_per_page: 10,
current_count: 0,
overall_count: 0,
nextPageLink : '',
}
});




url: function() {
return this.nextPageLink;
},

parse: function(response) {
window.articlesCollection = Backbone.Collection.extend({
model: articleModel,
nextPageLink : '',


this.nextPageLink = response.nextPageLink;
this.overall_count = response.itemsCount;
this.current_count = response.currentPage * response.itemsPerPage;


return response.items;
url: function() {
return this.nextPageLink;
},

parse: function(response) {

}
if('pagination' in response){
console.log(response.pagination.nextPageLink);
if (response.pagination.nextPageLink !== undefined){
this.nextPageLink = response.pagination.nextPageLink;
window.lapp.showMoreButton();
}else{
window.lapp.hideMoreButton();
}
}
return response.items;


}





});
});



Expand Down
Loading

0 comments on commit e23badc

Please sign in to comment.