Skip to content

Commit

Permalink
load more section backbone fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Rondio committed Mar 28, 2014
1 parent 462cb93 commit 296e817
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 11 deletions.
35 changes: 29 additions & 6 deletions _js/infiniteScroll/model_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,41 @@ $(function() {
window.articleModel = Backbone.Model.extend({

isHighlighted : function(){
try
{
if (this.get('fields').highlight=="1") return true;
}
catch(err)
{
return false;
}

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

return false;
},
getDeck : function (){
try
{
if (this.get('fields').deck) return this.get('fields').deck;
}
catch(err)
{
try
{
if (this.get('fields').teaser) return this.get('fields').teaser;
}catch(error){
return '';
}

}
return '';
},
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 decodeURIComponent(renditions[i].link);
}
}
return false;
Expand Down Expand Up @@ -48,17 +71,17 @@ $(function() {
}else{
window.lapp.hideMoreButton();
}
}
return response.items;
}
return response.items;


}
}





});
});



Expand Down
7 changes: 7 additions & 0 deletions _js/infiniteScroll/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ window.listView = Backbone.View.extend({

var images = $('#masonry_container img.loading');
var nimages = images.length;
if (!nimages){
$("div.new").fadeIn().removeClass("new");

that.$el.masonry('reload');
progressJs().end();
};

images.load(function() {
nimages--;
$(this).removeClass("loading");
Expand Down
11 changes: 7 additions & 4 deletions _tpl/section_cont.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
<article class="news_item">

<% var rendition = false;
if (item.get('fields').highlight=="1"){
if (item.isHighlighted()){
rendition = item.getRendition("front_big");
}else{
rendition = item.getRendition("front_small");
}
rendition = decodeURIComponent(rendition) ;

if(rendition){
console.log(rendition);
%>
<a href="<%= item.get('number') %>" class="thumbnail">
<img src="//<%= rendition %>" alt="here should be a caption" class="loading" />
<img src="//<%= rendition %>" alt="" class="loading" />
</a>
<% } %>
Expand All @@ -37,7 +40,7 @@

<h3 class="title"><a href="<%= item.get('number') %>"> <%= item.get('title') %></a></h3>

<p> <%= item.get('fields').deck.replace(/^(.{200}[^\s]*).*/, "$1") %></p>
<p> <%= item.getDeck().replace(/^(.{200}[^\s]*).*/, "$1") %></p>
</div>


Expand Down
2 changes: 1 addition & 1 deletion _tpl/user-content.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div>
<ul>

{{ list_articles ignore_publication="true" ignore_issue="true" ignore_section="true" constraints="author is `$escapedName`" order="ByPublishDate desc" length="5" }}
{{ list_articles ignore_publication="true" ignore_issue="true" ignore_section="true" constraints="author is `$escapedName` type is news" order="ByPublishDate desc" length="5" }}
<li class="news_item">
{{ image rendition="section" }}
<a href="{{url options="article"}}" class="thumbnail">
Expand Down

0 comments on commit 296e817

Please sign in to comment.