Commit caabb1a55511d214247c4f92a4135317a95fb8bc
1 parent
0c10ee05
Exists in
master
and in
10 other branches
Pequenos ajustes no main.js
Showing
1 changed file
with
13 additions
and
14 deletions
Show diff stats
js/main.js
@@ -245,18 +245,18 @@ function loadRandomProposal(topic_id, private_token) { | @@ -245,18 +245,18 @@ function loadRandomProposal(topic_id, private_token) { | ||
245 | $resultsContainer.toggle(); | 245 | $resultsContainer.toggle(); |
246 | 246 | ||
247 | if($resultsContainer.is(':visible')) { | 247 | if($resultsContainer.is(':visible')) { |
248 | - var $loading = $resultsContainer.find('.loading'); | ||
249 | - var $resultsContent = $resultsContainer.find('.results-content'); | ||
250 | 248 | ||
251 | - $loading.show(); | ||
252 | - $resultsContent.hide(); | 249 | + $resultsContainer.find('.loading').show(); |
250 | + $resultsContainer.find('.results-content').hide(); | ||
253 | 251 | ||
254 | var url = host + '/api/v1/articles/' + topic_id + '/children' + '?private_token=' + private_token + '&limit=10&order=votes_score&fields=id,name,abstract,votes_for,votes_against&content_type=ProposalsDiscussionPlugin::Proposal'; | 252 | var url = host + '/api/v1/articles/' + topic_id + '/children' + '?private_token=' + private_token + '&limit=10&order=votes_score&fields=id,name,abstract,votes_for,votes_against&content_type=ProposalsDiscussionPlugin::Proposal'; |
255 | $.getJSON(url).done(function( data ) { | 253 | $.getJSON(url).done(function( data ) { |
256 | 254 | ||
257 | $resultsContainer.html(resultsTemplate(data)); | 255 | $resultsContainer.html(resultsTemplate(data)); |
258 | - $('.results-container .loading').hide(); | ||
259 | - $('.results-container .results-content').show(); | 256 | + $resultsContainer.find('.loading').hide(); |
257 | + $resultsContainer.find('.results-content').show(); | ||
258 | + | ||
259 | + // scroll to the end | ||
260 | $('html, body').animate({ | 260 | $('html, body').animate({ |
261 | scrollTop: $(document).height() | 261 | scrollTop: $(document).height() |
262 | }, 'fast'); | 262 | }, 'fast'); |
@@ -267,6 +267,7 @@ function loadRandomProposal(topic_id, private_token) { | @@ -267,6 +267,7 @@ function loadRandomProposal(topic_id, private_token) { | ||
267 | $('.experience-proposal-container').show(); | 267 | $('.experience-proposal-container').show(); |
268 | $('.talk-proposal-container').show(); | 268 | $('.talk-proposal-container').show(); |
269 | } | 269 | } |
270 | + | ||
270 | e.preventDefault(); | 271 | e.preventDefault(); |
271 | }); | 272 | }); |
272 | }); | 273 | }); |
@@ -396,7 +397,6 @@ function display_proposal_detail(){ | @@ -396,7 +397,6 @@ function display_proposal_detail(){ | ||
396 | $('.talk-proposal-container').hide(); | 397 | $('.talk-proposal-container').hide(); |
397 | 398 | ||
398 | $('.body').show(); | 399 | $('.body').show(); |
399 | - $('html, body').animate({ scrollTop: 0 }, 'fast'); | ||
400 | } | 400 | } |
401 | 401 | ||
402 | function display_proposal_by_category(item){ | 402 | function display_proposal_by_category(item){ |
@@ -451,8 +451,6 @@ function navigateTo(hash){ | @@ -451,8 +451,6 @@ function navigateTo(hash){ | ||
451 | // go to proposal | 451 | // go to proposal |
452 | var proposalId = parts[2]; | 452 | var proposalId = parts[2]; |
453 | navigateToProposal(proposalId); | 453 | navigateToProposal(proposalId); |
454 | - | ||
455 | - return; | ||
456 | } | 454 | } |
457 | 455 | ||
458 | if( isCategory ){ | 456 | if( isCategory ){ |
@@ -460,14 +458,15 @@ function navigateTo(hash){ | @@ -460,14 +458,15 @@ function navigateTo(hash){ | ||
460 | // go to category | 458 | // go to category |
461 | var categoryId = parts[3]; | 459 | var categoryId = parts[3]; |
462 | navigateToCategory(categoryId); | 460 | navigateToCategory(categoryId); |
463 | - | ||
464 | - return; | ||
465 | } | 461 | } |
466 | 462 | ||
467 | // default | 463 | // default |
468 | - // show the 'index' -> category tab | ||
469 | - display_category_tab(); | ||
470 | - console.log('route not handled', hash); | 464 | + if( !isProposal && !isCategory ){ |
465 | + // show the 'index' -> category tab | ||
466 | + display_category_tab(); | ||
467 | + } | ||
468 | + | ||
469 | + $('html, body').animate({ scrollTop: 0 }, 'fast'); | ||
471 | } | 470 | } |
472 | 471 | ||
473 | function navigateToProposal(proposalId){ | 472 | function navigateToProposal(proposalId){ |