Commit f561d73e02b64d65229beabcc986a67ebadfe05d
1 parent
88f94323
Exists in
master
and in
7 other branches
Proposta para issue #217
Showing
1 changed file
with
20 additions
and
1 deletions
Show diff stats
js/main.js
| @@ -300,6 +300,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -300,6 +300,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 300 | this.navigateTo(hash); | 300 | this.navigateTo(hash); |
| 301 | }, | 301 | }, |
| 302 | navigateTo: function(hash){ | 302 | navigateTo: function(hash){ |
| 303 | + var scrollTop = 0; | ||
| 303 | var regexProposals = /#\/programas/; | 304 | var regexProposals = /#\/programas/; |
| 304 | var regexCategory = /#\/temas/; | 305 | var regexCategory = /#\/temas/; |
| 305 | var regexHideBarra = /barra=false$/; | 306 | var regexHideBarra = /barra=false$/; |
| @@ -323,6 +324,12 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -323,6 +324,12 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 323 | // go to proposal | 324 | // go to proposal |
| 324 | var proposalId = parts[2]; | 325 | var proposalId = parts[2]; |
| 325 | this.navigateToProposal(proposalId); | 326 | this.navigateToProposal(proposalId); |
| 327 | + | ||
| 328 | + var $proposal = $('#proposal-item-' + proposalId); | ||
| 329 | + var offset = $proposal.offset(); | ||
| 330 | + if(offset){ | ||
| 331 | + scrollTop = offset.top; | ||
| 332 | + } | ||
| 326 | } | 333 | } |
| 327 | 334 | ||
| 328 | if( isCategory ){ | 335 | if( isCategory ){ |
| @@ -330,15 +337,27 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -330,15 +337,27 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 330 | // go to category | 337 | // go to category |
| 331 | var categoryId = parts[3]; | 338 | var categoryId = parts[3]; |
| 332 | this.navigateToCategory(categoryId); | 339 | this.navigateToCategory(categoryId); |
| 340 | + | ||
| 341 | + var $category = $('#proposal-item-' + categoryId); | ||
| 342 | + var offset = $category.offset(); | ||
| 343 | + if(offset){ | ||
| 344 | + scrollTop = offset.top; | ||
| 345 | + } | ||
| 333 | } | 346 | } |
| 334 | 347 | ||
| 335 | // default | 348 | // default |
| 336 | if( !isProposal && !isCategory ){ | 349 | if( !isProposal && !isCategory ){ |
| 337 | // show the 'index' -> category tab | 350 | // show the 'index' -> category tab |
| 338 | this.display_category_tab(); | 351 | this.display_category_tab(); |
| 352 | + | ||
| 353 | + var $nav = $('nav[role="tabpanel"]'); | ||
| 354 | + var offset = $nav.offset(); | ||
| 355 | + if(offset){ | ||
| 356 | + scrollTop = offset.top; | ||
| 357 | + } | ||
| 339 | } | 358 | } |
| 340 | 359 | ||
| 341 | - $('html, body').animate({ scrollTop: 0 }, 'fast'); | 360 | + $('html, body').animate({ scrollTop: scrollTop }, 'fast'); |
| 342 | }, | 361 | }, |
| 343 | navigateToProposal: function(proposalId){ | 362 | navigateToProposal: function(proposalId){ |
| 344 | var regexSubpages = /sobre-o-programa$/; | 363 | var regexSubpages = /sobre-o-programa$/; |