Commit dca0efe7d13958811989973fa5c53d1b15ea0580
1 parent
2d655dfb
Exists in
master
and in
5 other branches
Article back button
Showing
2 changed files
with
14 additions
and
7 deletions
Show diff stats
index.html
| ... | ... | @@ -109,7 +109,10 @@ |
| 109 | 109 | </div> |
| 110 | 110 | </header> |
| 111 | 111 | |
| 112 | - <div id="article-container" class="article-container hide"></div> | |
| 112 | + <div id="article-container" class="article-container hide"> | |
| 113 | + <a href="#" class="go-back">Voltar</a> | |
| 114 | + <div class="article-content"></div> | |
| 115 | + </div> | |
| 113 | 116 | |
| 114 | 117 | <div id="content" class="container"> |
| 115 | 118 | <div class="embed-responsive embed-responsive-16by9"> | ... | ... |
js/main.js
| ... | ... | @@ -18,13 +18,15 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 18 | 18 | |
| 19 | 19 | var loginButton; |
| 20 | 20 | |
| 21 | + var lastHash; | |
| 22 | + | |
| 21 | 23 | var participa = true; |
| 22 | 24 | |
| 23 | 25 | //Detects for localhost settings |
| 24 | 26 | var patt = new RegExp(":3000/"); |
| 25 | 27 | if(patt.test(window.location.href)) |
| 26 | 28 | participa = false; |
| 27 | - | |
| 29 | + | |
| 28 | 30 | if(participa){ |
| 29 | 31 | var host = 'http://www.participa.br'; |
| 30 | 32 | var proposal_discussion = '103358'; //participa |
| ... | ... | @@ -226,15 +228,16 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 226 | 228 | } |
| 227 | 229 | return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); |
| 228 | 230 | }, |
| 229 | - display_article: function(article_id) { | |
| 231 | + display_article: function(article_id, backTo) { | |
| 230 | 232 | var url = host + '/api/v1/articles/' + article_id + '?private_token=' + Main.private_token; |
| 231 | 233 | $.getJSON(url).done(function( data ) { |
| 232 | - $('#article-container').html(articleTemplate(data.article)); | |
| 234 | + $('#article-container .article-content').html(articleTemplate(data.article)); | |
| 233 | 235 | $('#article-container').show(); |
| 234 | 236 | $('#proposal-categories').hide(); |
| 235 | 237 | $('#proposal-group').hide(); |
| 236 | 238 | $('nav').hide(); |
| 237 | 239 | $('#content').hide(); |
| 240 | + $('#article-container .go-back').attr('href', backTo); | |
| 238 | 241 | }); |
| 239 | 242 | }, |
| 240 | 243 | // inicio Eduardo |
| ... | ... | @@ -430,9 +433,10 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 430 | 433 | }, |
| 431 | 434 | locationHashChanged: function(){ |
| 432 | 435 | var hash = window.location.hash; |
| 433 | - this.navigateTo(hash); | |
| 436 | + this.navigateTo(hash, lastHash); | |
| 437 | + lastHash = hash; | |
| 434 | 438 | }, |
| 435 | - navigateTo: function(hash){ | |
| 439 | + navigateTo: function(hash, lastHash) { | |
| 436 | 440 | var scrollTop = 0; |
| 437 | 441 | var $nav = $('nav[role="tabpanel"]'); |
| 438 | 442 | var navOffset = $nav.offset(); |
| ... | ... | @@ -458,7 +462,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 458 | 462 | var isArticle = regexArticle.exec(hash) !== null; |
| 459 | 463 | |
| 460 | 464 | if(isArticle) { |
| 461 | - this.display_article(hash.split('/')[2]); | |
| 465 | + this.display_article(hash.split('/')[2], lastHash); | |
| 462 | 466 | } |
| 463 | 467 | |
| 464 | 468 | if( isProposal ){ | ... | ... |