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 | 367 | <a href="#" class="skip button box-footer">Pular</a> |
| 368 | 368 | </div> |
| 369 | 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 | 371 | </div> |
| 372 | 372 | <div class="social"> |
| 373 | 373 | <span>Compartilhe esta proposta</span> | ... | ... |
js/main.js
| ... | ... | @@ -18,7 +18,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 18 | 18 | |
| 19 | 19 | var loginButton; |
| 20 | 20 | |
| 21 | - var lastHash; | |
| 21 | + var lastHash = window.location.hash; | |
| 22 | 22 | |
| 23 | 23 | var participa = true; |
| 24 | 24 | |
| ... | ... | @@ -137,6 +137,8 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 137 | 137 | |
| 138 | 138 | $body.off('click', '.vote-result'); |
| 139 | 139 | $body.on('click', '.vote-result', function(e) { |
| 140 | + // e.preventDefault(); | |
| 141 | + | |
| 140 | 142 | var $this = $(this); |
| 141 | 143 | var $proposalDetail = $this.parents('.proposal-detail'); |
| 142 | 144 | var $resultsContainer = $proposalDetail.find('.results-container'); |
| ... | ... | @@ -144,12 +146,18 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 144 | 146 | if($resultsContainer.css('display') === 'none') { |
| 145 | 147 | Main.loadRanking($resultsContainer, topic_id, 1); |
| 146 | 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 | 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 | 161 | }).fail(function(){ |
| 154 | 162 | $loading.hide(); |
| 155 | 163 | $('.support-proposal .alert').show(); |
| ... | ... | @@ -197,10 +205,14 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 197 | 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 | 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 | 217 | $('.experience-proposal-container').hide(); |
| 206 | 218 | $('.talk-proposal-container').hide(); |
| ... | ... | @@ -469,6 +481,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 469 | 481 | var regexCategory = /#\/temas/; |
| 470 | 482 | var regexHideBarra = /barra=false$/; |
| 471 | 483 | var regexArticle = /#\/artigo/; |
| 484 | + var regexResultados = /resultados$/; | |
| 472 | 485 | |
| 473 | 486 | if( !(regexHideBarra.exec(hash) !== null) && !HIDE_BARRA_DO_GOVERNO ){ |
| 474 | 487 | this.addBarraDoGoverno(); |
| ... | ... | @@ -484,6 +497,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 484 | 497 | var isProposal = regexProposals.exec(hash) !== null; |
| 485 | 498 | var isCategory = regexCategory.exec(hash) !== null; |
| 486 | 499 | var isArticle = regexArticle.exec(hash) !== null; |
| 500 | + var isResultados = regexResultados.exec(hash) !== null; | |
| 487 | 501 | |
| 488 | 502 | if(isArticle) { |
| 489 | 503 | this.display_article(hash.split('/')[2], lastHash); |
| ... | ... | @@ -506,6 +520,23 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 506 | 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 | 542 | if( isCategory ){ |
| ... | ... | @@ -529,20 +560,15 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 529 | 560 | if( !isProposal && !isCategory ){ |
| 530 | 561 | // show the 'index' -> category tab |
| 531 | 562 | this.display_category_tab(); |
| 532 | - | |
| 533 | - | |
| 534 | - // if(navOffset){ | |
| 535 | - // scrollTop = navOffset.top; | |
| 536 | - // } | |
| 537 | 563 | } |
| 538 | 564 | |
| 539 | 565 | $('html, body').animate({ scrollTop: scrollTop }, 'fast'); |
| 540 | 566 | }, |
| 541 | 567 | navigateToProposal: function(proposalId){ |
| 542 | - var regexSubpages = /sobre-o-programa$/; | |
| 568 | + var regexSobreOPrograma = /sobre-o-programa$/; | |
| 543 | 569 | if(proposalId === undefined){ |
| 544 | 570 | this.display_proposals_tab(); |
| 545 | - }else if(regexSubpages.exec(window.location.hash) == null){ | |
| 571 | + }else if(regexSobreOPrograma.exec(window.location.hash) == null){ | |
| 546 | 572 | this.display_proposal('proposal-item-' + proposalId); |
| 547 | 573 | }else{ |
| 548 | 574 | this.display_proposal_detail(proposalId); |
| ... | ... | @@ -754,8 +780,8 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 754 | 780 | e.preventDefault(); |
| 755 | 781 | |
| 756 | 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 | 785 | var newHash = '#/temas'; // default page |
| 760 | 786 | |
| 761 | 787 | if(isSubpage){ | ... | ... |