Commit 40a0f7abf3f41d0cc009e22c5a741862d81c697c
1 parent
da015b9f
Exists in
master
and in
5 other branches
Fix 'go back to results' (fix #304)
Showing
2 changed files
with
43 additions
and
17 deletions
Show diff stats
index.html
@@ -367,7 +367,7 @@ | @@ -367,7 +367,7 @@ | ||
367 | <a href="#" class="skip button box-footer">Pular</a> | 367 | <a href="#" class="skip button box-footer">Pular</a> |
368 | </div> | 368 | </div> |
369 | </div> | 369 | </div> |
370 | - <a href="#" class="vote-result box-bottom">Resultados</a> | 370 | + <a href="#/programas/{{parent.id}}/resultados" class="vote-result box-bottom">Resultados</a> |
371 | </div> | 371 | </div> |
372 | <div class="social"> | 372 | <div class="social"> |
373 | <span>Compartilhe esta proposta</span> | 373 | <span>Compartilhe esta proposta</span> |
js/main.js
@@ -18,7 +18,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -18,7 +18,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
18 | 18 | ||
19 | var loginButton; | 19 | var loginButton; |
20 | 20 | ||
21 | - var lastHash; | 21 | + var lastHash = window.location.hash; |
22 | 22 | ||
23 | var participa = true; | 23 | var participa = true; |
24 | 24 | ||
@@ -137,6 +137,8 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -137,6 +137,8 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
137 | 137 | ||
138 | $body.off('click', '.vote-result'); | 138 | $body.off('click', '.vote-result'); |
139 | $body.on('click', '.vote-result', function(e) { | 139 | $body.on('click', '.vote-result', function(e) { |
140 | + // e.preventDefault(); | ||
141 | + | ||
140 | var $this = $(this); | 142 | var $this = $(this); |
141 | var $proposalDetail = $this.parents('.proposal-detail'); | 143 | var $proposalDetail = $this.parents('.proposal-detail'); |
142 | var $resultsContainer = $proposalDetail.find('.results-container'); | 144 | var $resultsContainer = $proposalDetail.find('.results-container'); |
@@ -144,12 +146,18 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -144,12 +146,18 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
144 | if($resultsContainer.css('display') === 'none') { | 146 | if($resultsContainer.css('display') === 'none') { |
145 | Main.loadRanking($resultsContainer, topic_id, 1); | 147 | Main.loadRanking($resultsContainer, topic_id, 1); |
146 | } else { | 148 | } else { |
147 | - $('.experience-proposal-container').show(); | ||
148 | - $('.talk-proposal-container').show(); | 149 | + $proposalDetail.find('.experience-proposal-container').show(); |
150 | + $proposalDetail.find('.talk-proposal-container').show(); | ||
149 | $resultsContainer.hide(); | 151 | $resultsContainer.hide(); |
150 | } | 152 | } |
151 | - e.preventDefault(); | ||
152 | }); | 153 | }); |
154 | + | ||
155 | + // $body.off('click', '.question-link'); | ||
156 | + // $body.on('click', '.question-link', function(e) { | ||
157 | + // var $this = $(this); | ||
158 | + | ||
159 | + // // Main.navigateTo($this.attr('href'), backTo); | ||
160 | + // }); | ||
153 | }).fail(function(){ | 161 | }).fail(function(){ |
154 | $loading.hide(); | 162 | $loading.hide(); |
155 | $('.support-proposal .alert').show(); | 163 | $('.support-proposal .alert').show(); |
@@ -197,10 +205,14 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -197,10 +205,14 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
197 | $(this).toggleClass('truncated'); | 205 | $(this).toggleClass('truncated'); |
198 | }); | 206 | }); |
199 | 207 | ||
208 | + var scrollTop = $(document).height(); | ||
209 | + var proposalOffset = $resultsContainer.offset(); | ||
210 | + if(proposalOffset){ | ||
211 | + scrollTop = proposalOffset.top; | ||
212 | + } | ||
213 | + | ||
200 | // scroll to the end | 214 | // scroll to the end |
201 | - $('html, body').animate({ | ||
202 | - scrollTop: $(document).height() | ||
203 | - }, 'fast'); | 215 | + $('html, body').animate({scrollTop: scrollTop }, 'fast'); |
204 | }); | 216 | }); |
205 | $('.experience-proposal-container').hide(); | 217 | $('.experience-proposal-container').hide(); |
206 | $('.talk-proposal-container').hide(); | 218 | $('.talk-proposal-container').hide(); |
@@ -469,6 +481,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -469,6 +481,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
469 | var regexCategory = /#\/temas/; | 481 | var regexCategory = /#\/temas/; |
470 | var regexHideBarra = /barra=false$/; | 482 | var regexHideBarra = /barra=false$/; |
471 | var regexArticle = /#\/artigo/; | 483 | var regexArticle = /#\/artigo/; |
484 | + var regexResultados = /resultados$/; | ||
472 | 485 | ||
473 | if( !(regexHideBarra.exec(hash) !== null) && !HIDE_BARRA_DO_GOVERNO ){ | 486 | if( !(regexHideBarra.exec(hash) !== null) && !HIDE_BARRA_DO_GOVERNO ){ |
474 | this.addBarraDoGoverno(); | 487 | this.addBarraDoGoverno(); |
@@ -484,6 +497,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -484,6 +497,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
484 | var isProposal = regexProposals.exec(hash) !== null; | 497 | var isProposal = regexProposals.exec(hash) !== null; |
485 | var isCategory = regexCategory.exec(hash) !== null; | 498 | var isCategory = regexCategory.exec(hash) !== null; |
486 | var isArticle = regexArticle.exec(hash) !== null; | 499 | var isArticle = regexArticle.exec(hash) !== null; |
500 | + var isResultados = regexResultados.exec(hash) !== null; | ||
487 | 501 | ||
488 | if(isArticle) { | 502 | if(isArticle) { |
489 | this.display_article(hash.split('/')[2], lastHash); | 503 | this.display_article(hash.split('/')[2], lastHash); |
@@ -506,6 +520,23 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -506,6 +520,23 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
506 | scrollTop = $('#proposal-group').offset().top; | 520 | scrollTop = $('#proposal-group').offset().top; |
507 | } | 521 | } |
508 | } | 522 | } |
523 | + | ||
524 | + if(isResultados){ | ||
525 | + var $resultsContainer = $proposal.find('.results-container'); | ||
526 | + | ||
527 | + if($resultsContainer.css('display') === 'none') { | ||
528 | + Main.loadRanking($resultsContainer, proposalId, 1); | ||
529 | + } else { | ||
530 | + $proposalDetail.find('.experience-proposal-container').show(); | ||
531 | + $proposalDetail.find('.talk-proposal-container').show(); | ||
532 | + $resultsContainer.hide(); | ||
533 | + } | ||
534 | + | ||
535 | + var proposalOffset = $resultsContainer.offset(); | ||
536 | + if(proposalOffset){ | ||
537 | + scrollTop = proposalOffset.top; | ||
538 | + } | ||
539 | + } | ||
509 | } | 540 | } |
510 | 541 | ||
511 | if( isCategory ){ | 542 | if( isCategory ){ |
@@ -529,20 +560,15 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -529,20 +560,15 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
529 | if( !isProposal && !isCategory ){ | 560 | if( !isProposal && !isCategory ){ |
530 | // show the 'index' -> category tab | 561 | // show the 'index' -> category tab |
531 | this.display_category_tab(); | 562 | this.display_category_tab(); |
532 | - | ||
533 | - | ||
534 | - // if(navOffset){ | ||
535 | - // scrollTop = navOffset.top; | ||
536 | - // } | ||
537 | } | 563 | } |
538 | 564 | ||
539 | $('html, body').animate({ scrollTop: scrollTop }, 'fast'); | 565 | $('html, body').animate({ scrollTop: scrollTop }, 'fast'); |
540 | }, | 566 | }, |
541 | navigateToProposal: function(proposalId){ | 567 | navigateToProposal: function(proposalId){ |
542 | - var regexSubpages = /sobre-o-programa$/; | 568 | + var regexSobreOPrograma = /sobre-o-programa$/; |
543 | if(proposalId === undefined){ | 569 | if(proposalId === undefined){ |
544 | this.display_proposals_tab(); | 570 | this.display_proposals_tab(); |
545 | - }else if(regexSubpages.exec(window.location.hash) == null){ | 571 | + }else if(regexSobreOPrograma.exec(window.location.hash) == null){ |
546 | this.display_proposal('proposal-item-' + proposalId); | 572 | this.display_proposal('proposal-item-' + proposalId); |
547 | }else{ | 573 | }else{ |
548 | this.display_proposal_detail(proposalId); | 574 | this.display_proposal_detail(proposalId); |
@@ -754,8 +780,8 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -754,8 +780,8 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
754 | e.preventDefault(); | 780 | e.preventDefault(); |
755 | 781 | ||
756 | var oldHash = window.location.hash; | 782 | var oldHash = window.location.hash; |
757 | - var regexSubpages = /sobre-o-programa$/; | ||
758 | - var isSubpage = regexSubpages.exec(oldHash) !== null; | 783 | + var regexSobreOPrograma = /sobre-o-programa$/; |
784 | + var isSubpage = regexSobreOPrograma.exec(oldHash) !== null; | ||
759 | var newHash = '#/temas'; // default page | 785 | var newHash = '#/temas'; // default page |
760 | 786 | ||
761 | if(isSubpage){ | 787 | if(isSubpage){ |