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