Commit 6109b5ea6198c00b566f5d2838dcf93a85a89a1c
1 parent
dc0e8d34
Exists in
master
and in
10 other branches
Fix #51 Fix #91 - Barra do Governo
Showing
2 changed files
with
58 additions
and
1 deletions
Show diff stats
index.html
| @@ -97,6 +97,7 @@ | @@ -97,6 +97,7 @@ | ||
| 97 | <body> | 97 | <body> |
| 98 | 98 | ||
| 99 | <div id="proposal-result"></div> | 99 | <div id="proposal-result"></div> |
| 100 | + <div class="clearfix"></div> | ||
| 100 | 101 | ||
| 101 | <script id="proposal-template" type="text/x-handlebars-template"> | 102 | <script id="proposal-template" type="text/x-handlebars-template"> |
| 102 | <header> | 103 | <header> |
js/main.js
| @@ -421,10 +421,54 @@ function display_proposal_by_category(item){ | @@ -421,10 +421,54 @@ function display_proposal_by_category(item){ | ||
| 421 | } | 421 | } |
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | +var BARRA_ADDED = false; | ||
| 425 | +function addBarraDoGoverno(){ | ||
| 426 | + console.log('add barra'); | ||
| 427 | + | ||
| 428 | + if( BARRA_ADDED ) { return; } | ||
| 429 | + | ||
| 430 | + var HTML_BODY_PREPEND = '' + | ||
| 431 | + '<div id="barra-brasil" style="background:#7F7F7F; height: 20px; padding:0 0 0 10px;display:block;"> ' + | ||
| 432 | + '<ul id="menu-barra-temp" style="list-style:none;">' + | ||
| 433 | + '<li style="display:inline; float:left;padding-right:10px; margin-right:10px; border-right:1px solid #EDEDED"><a href="http://brasil.gov.br" style="font-family:sans,sans-serif; text-decoration:none; color:white;">Portal do Governo Brasileiro</a></li> ' + | ||
| 434 | + '<li><a style="font-family:sans,sans-serif; text-decoration:none; color:white;" href="http://epwg.governoeletronico.gov.br/barra/atualize.html">Atualize sua Barra de Governo</a></li>' + | ||
| 435 | + '</ul>' + | ||
| 436 | + '</div>'; | ||
| 437 | + | ||
| 438 | + var HTML_BODY_APPEND = ''+ | ||
| 439 | + '<div id="footer-brasil"></div>' + | ||
| 440 | + '<script defer="defer" src="//barra.brasil.gov.br/barra.js" type="text/javascript"></script>'; | ||
| 441 | + | ||
| 442 | + var STYLE_TEMA_AZUL = '' + | ||
| 443 | + '<style>'+ | ||
| 444 | + '#footer-brasil {'+ | ||
| 445 | + 'background: none repeat scroll 0% 0% #0042b1;'+ | ||
| 446 | + 'padding: 1em 0px;'+ | ||
| 447 | + 'max-width: 100%;'+ | ||
| 448 | + 'margin-top: 40px;'+ | ||
| 449 | + '}'+ | ||
| 450 | + '#barra-brasil ul {'+ | ||
| 451 | + 'width: auto;'+ | ||
| 452 | + '}'+ | ||
| 453 | + '<style>'; | ||
| 454 | + | ||
| 455 | + var $body = $(document.body); | ||
| 456 | + $body.prepend(HTML_BODY_PREPEND); | ||
| 457 | + $body.append(HTML_BODY_APPEND); | ||
| 458 | + $body.append(STYLE_TEMA_AZUL); | ||
| 459 | + | ||
| 460 | + BARRA_ADDED = true; | ||
| 461 | +} | ||
| 462 | + | ||
| 424 | function updateHash(hash){ | 463 | function updateHash(hash){ |
| 425 | var id = hash.replace(/^.*#/, ''); | 464 | var id = hash.replace(/^.*#/, ''); |
| 426 | var elem = document.getElementById(id); | 465 | var elem = document.getElementById(id); |
| 427 | 466 | ||
| 467 | + // preserve the query param | ||
| 468 | + // if (HIDE_BARRA_DO_GOVERNO && (hash.indexOf('?barra=false') === -1)){ | ||
| 469 | + // hash += '?barra=false'; | ||
| 470 | + // } | ||
| 471 | + | ||
| 428 | if ( !elem ) { | 472 | if ( !elem ) { |
| 429 | window.location.hash = hash; | 473 | window.location.hash = hash; |
| 430 | return; | 474 | return; |
| @@ -436,13 +480,25 @@ function updateHash(hash){ | @@ -436,13 +480,25 @@ function updateHash(hash){ | ||
| 436 | } | 480 | } |
| 437 | 481 | ||
| 438 | function locationHashChanged(){ | 482 | function locationHashChanged(){ |
| 439 | - var hash = location.hash; | 483 | + var hash = window.location.hash; |
| 440 | navigateTo(hash); | 484 | navigateTo(hash); |
| 441 | } | 485 | } |
| 442 | 486 | ||
| 487 | +var HIDE_BARRA_DO_GOVERNO = false; | ||
| 443 | function navigateTo(hash){ | 488 | function navigateTo(hash){ |
| 444 | var regexProposals = /#\/programas/; | 489 | var regexProposals = /#\/programas/; |
| 445 | var regexCategory = /#\/temas/; | 490 | var regexCategory = /#\/temas/; |
| 491 | + var regexHideBarra = /barra=false$/; | ||
| 492 | + | ||
| 493 | + if( !(regexHideBarra.exec(hash) !== null) && !HIDE_BARRA_DO_GOVERNO ){ | ||
| 494 | + addBarraDoGoverno(); | ||
| 495 | + }else{ | ||
| 496 | + HIDE_BARRA_DO_GOVERNO = true; | ||
| 497 | + } | ||
| 498 | + | ||
| 499 | + // remove query params | ||
| 500 | + hash = hash.split('?')[0]; | ||
| 501 | + | ||
| 446 | var parts = hash.split('/'); | 502 | var parts = hash.split('/'); |
| 447 | 503 | ||
| 448 | var isProposal = regexProposals.exec(hash) !== null; | 504 | var isProposal = regexProposals.exec(hash) !== null; |