Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Shows related cases in case detail

  • Loading branch information...
commit 36766652ee164f1eb8b3eef045c9492fb19e5509 1 parent 341766f
@Ferdev Ferdev authored
View
32 css/style.css
@@ -122,7 +122,7 @@ a:hover {text-decoration:underline; color:#C93B00;}
#openbudget header nav .filters li:last-child {
padding-bottom:4px;
- }
+ }
#openbudget header nav .filters a {
display: block;
@@ -368,6 +368,36 @@ a:hover {text-decoration:underline; color:#C93B00;}
font-size: 15px;
}
+ #openbudget #case_detail #experiencies {
+ }
+
+ #openbudget #case_detail #experiencies h4 {
+ margin: 0;
+ }
+
+ #openbudget #case_detail #experiencies ul {
+ padding: 0;
+ list-style-type: none;
+ }
+
+ #openbudget #case_detail #experiencies ul li {
+ margin: 10px 0;
+ }
+
+ #openbudget #case_detail #experiencies ul li h3 {
+ margin: 0;
+ }
+
+ #openbudget #case_detail #experiencies ul li h3 a {
+ color: #EB4600;
+ text-transform: none;
+ }
+
+ #openbudget #case_detail #experiencies ul li span {
+ color: #cccccc;
+ font-size: 15px;
+ }
+
#openbudget #case_detail #mini_map{
position:relative;
width: 298px;
View
7 index.html
@@ -164,7 +164,7 @@
</div>
<div id="experiencies" class="container">
- <h5>Related experiences</h5>
+ <h4>Related experiences</h4>
<ul></ul>
</div>
@@ -267,9 +267,8 @@
<script id="detail_related_item" type="text/html">
<li>
- <h3><a href="#" rel="{{cartodb_id}}">{{title}}</a></h3>
- <a href="#" rel="{{cartodb_id}}" class="desc">{{subtitle}}</a>
- <a href="#" rel="{{cartodb_id}}" class="where">Open Budget in {{country}}</a>
+ <h3><a href="detail/{{cartodb_id}}">{{title}}</a></h3>
+ <span>{{subtitle}}</span>
</li>
</script>
View
2  js/backbone/collections/case_studies.js
@@ -43,7 +43,7 @@ var CaseStudies = CartoDB.CartoDBCollection.extend({
if (filter){
this.where_ = filter + " = " + id;
}
- this.fetch();
+ this.fetch({success: callback});
},
textFilter: function(text, callback){
View
8 js/backbone/models/case_study.js
@@ -11,5 +11,13 @@ var CaseStudy = Backbone.Model.extend({
getLatLong: function(){
return $.parseJSON(Countries.getByCartoDBId(this.get('country_id')).get('latlon'));
+ },
+
+ getRelated: function(callback){
+ var related = new CaseStudies();
+ related.filterBy('category', this.get('category_id'), function(){
+ console.log(related.models);
+ callback.call(this, related.models);
+ });
}
});
View
20 js/backbone/views/detail.js
@@ -9,7 +9,8 @@ window.DetailView = Backbone.View.extend({
},
events: {
- 'click #back': 'showIndex'
+ 'click #back' : 'showIndex',
+ 'click div#experiencies ul li h3 a' : 'showDetail'
},
render: function(){
@@ -24,6 +25,8 @@ window.DetailView = Backbone.View.extend({
this.$el.html(this.template);
+ this._showRelated();
+
$(document).scrollTop(0);
return this;
@@ -33,5 +36,20 @@ window.DetailView = Backbone.View.extend({
evt.preventDefault();
this.router.navigate('', true)
+ },
+
+ showDetail: function(evt){
+ evt.preventDefault();
+ this.router.navigate($(evt.target).attr('href'), true);
+ },
+
+ _showRelated: function(){
+ var self = this;
+ Case.getRelated(function(cases){
+ self.$el.find('#experiencies ul').empty();
+ _.each(cases, function(case_study){
+ self.$el.find('#experiencies ul').append(ich.detail_related_item(case_study.toJSON()));
+ });
+ })
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.