Commit f2639707ca3aaede03fd503d9fd5f99a05285962
Exists in
master
and in
5 other branches
Merge branch 'merlin'
Showing
2 changed files
with
154 additions
and
155 deletions
Show diff stats
index.html
| ... | ... | @@ -331,11 +331,11 @@ |
| 331 | 331 | <p class="box-subtitle">{{stripTags (trimString abstract 200)}}</p> |
| 332 | 332 | </div> |
| 333 | 333 | <div class="vote-actions"> |
| 334 | - <a href="#" class="icon icon-vote vote-action dislike" data-vote-value="-1"><span class="fa fa-times"></span></a> | |
| 335 | - <a href="#" class="icon icon-vote vote-action like" data-vote-value="1"><span class="fa fa-check"></span></a> | |
| 334 | + <button class="icon icon-vote vote-action dislike" data-vote-value="-1"><span class="fa fa-times"></span></button> | |
| 335 | + <button class="icon icon-vote vote-action like" data-vote-value="1"><span class="fa fa-check"></span></button> | |
| 336 | 336 | <div class="row"> |
| 337 | 337 | <div class="col-sm-6 col-sm-offset-3"> |
| 338 | - <a href="#" class="skip button box-footer">Pular</a> | |
| 338 | + <button class="skip button button-block box-footer">Pular</button> | |
| 339 | 339 | </div> |
| 340 | 340 | </div> |
| 341 | 341 | <a href="#/programas/{{parent.id}}/resultados" class="vote-result box-bottom">Resultados</a> | ... | ... |
js/main.js
| 1 | -define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], function($, Handlebars, FastClick){ | |
| 2 | - | |
| 3 | - /* global Handlebars, $ */ | |
| 1 | +/* global define */ | |
| 2 | +define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers', 'piwik'], function($, Handlebars, FastClick, ProposalApp){ | |
| 3 | + // 'use strict'; | |
| 4 | + | |
| 4 | 5 | // The template code |
| 5 | 6 | var templateSource = $('#proposal-template').html(); |
| 6 | 7 | |
| ... | ... | @@ -21,36 +22,45 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 21 | 22 | |
| 22 | 23 | var lastHash = window.location.hash; |
| 23 | 24 | |
| 24 | - var participa = true; | |
| 25 | + var host = 'http://login.dialoga.gov.br'; | |
| 26 | + var dialoga_community = 19195; | |
| 27 | + var proposal_discussion = '103358'; //participa | |
| 28 | + var cat_saude = 180; | |
| 29 | + // var cat_seguranca_publica = 182; | |
| 30 | + // var cat_educacao = 181; | |
| 31 | + // var cat_reducao_da_pobreza = 183; | |
| 32 | + var recaptchaSiteKey = '6LcLPAcTAAAAAKsd0bxY_TArhD_A7OL19SRCW7_i'; | |
| 25 | 33 | |
| 26 | 34 | |
| 27 | 35 | //Detects for localhost settings |
| 28 | - var patt = new RegExp(":3001/"); | |
| 29 | - if(patt.test(window.location.href)) | |
| 30 | - participa = false; | |
| 31 | - | |
| 32 | - if(participa){ | |
| 33 | - var host = 'http://login.dialoga.gov.br'; | |
| 34 | - window.dialoga_community = 19195; | |
| 35 | - proposal_discussion = '103358'; //participa | |
| 36 | - var cat_saude = 180; | |
| 37 | - var cat_seguranca_publica = 182; | |
| 38 | - var cat_educacao = 181; | |
| 39 | - var cat_reducao_da_pobreza = 183; | |
| 40 | - window.recaptchaSiteKey = '6LcLPAcTAAAAAKsd0bxY_TArhD_A7OL19SRCW7_i' | |
| 41 | - }else{ | |
| 42 | - var host = 'http://noosfero.com:3001'; | |
| 43 | - window.dialoga_community = 104; | |
| 44 | -// var proposal_discussion = '392'; //local serpro | |
| 45 | - var proposal_discussion = '413'; //casa | |
| 46 | - window.recaptchaSiteKey = '6LdsWAcTAAAAAChTUUD6yu9fCDhdIZzNd7F53zf-' //http://noosfero.com/ | |
| 47 | - var cat_saude = 23; | |
| 36 | + var patt = new RegExp(':3001/'); | |
| 37 | + if(patt.test(window.location.href)){ | |
| 38 | + host = 'http://noosfero.com:3001'; | |
| 39 | + dialoga_community = 104; | |
| 40 | + proposal_discussion = '413'; //casa | |
| 41 | + recaptchaSiteKey = '6LdsWAcTAAAAAChTUUD6yu9fCDhdIZzNd7F53zf-'; //http://noosfero.com/ | |
| 42 | + cat_saude = 23; | |
| 48 | 43 | } |
| 49 | - window.proposal_discussion = proposal_discussion; | |
| 44 | + | |
| 50 | 45 | var BARRA_ADDED = false; |
| 51 | 46 | var HIDE_BARRA_DO_GOVERNO = false; |
| 52 | 47 | |
| 53 | - Main = (function(){ | |
| 48 | + var Main; | |
| 49 | + window.Main = Main = (function(){ | |
| 50 | + | |
| 51 | + var API = { | |
| 52 | + articles: '', | |
| 53 | + proposals: '/api/v1/articles/{topic_id}/children', | |
| 54 | + | |
| 55 | + }; | |
| 56 | + | |
| 57 | + API.getProposalsURL = function (topicId){ | |
| 58 | + return host + replace(API.proposals, '{topic_id}', topicId); | |
| 59 | + }; | |
| 60 | + | |
| 61 | + function replace(str, pattern, value){ | |
| 62 | + return str.replace(new RegExp(pattern, 'g'), value); | |
| 63 | + } | |
| 54 | 64 | |
| 55 | 65 | return { |
| 56 | 66 | private_token: '375bee7e17d0021af7160ce664874618', |
| ... | ... | @@ -67,8 +77,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 67 | 77 | |
| 68 | 78 | return proposalId; |
| 69 | 79 | }, |
| 70 | - loadRandomProposal: function (topic_id) { | |
| 71 | - var private_token = Main.private_token; | |
| 80 | + loadRandomProposal: function (topic_id, force) { | |
| 81 | + var private_token = window.Main.private_token; | |
| 72 | 82 | var $noProposals = $('.no-proposals'); |
| 73 | 83 | var $loading = $('.loading'); |
| 74 | 84 | var $randomProposal = $('.random-proposal'); |
| ... | ... | @@ -80,13 +90,13 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 80 | 90 | $loading.show(); |
| 81 | 91 | $randomProposal.html(''); |
| 82 | 92 | |
| 83 | - var url = host + '/api/v1/articles/' + topic_id + '/children'; | |
| 93 | + var url = API.getProposalsURL(topic_id); | |
| 84 | 94 | var childId = this.getProposalId(); |
| 85 | 95 | |
| 86 | - if(childId != 0){ | |
| 87 | - url += '/'+childId; | |
| 96 | + if(childId !== 0 && !force){ | |
| 97 | + url += '/' + childId; | |
| 88 | 98 | } |
| 89 | - url += '?private_token=' + Main.private_token + '&limit=1&order=random()&_='+new Date().getTime()+'&fields=id,name,slug,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal'; | |
| 99 | + url += '?private_token=' + private_token + '&limit=1&order=random()&_='+new Date().getTime()+'&fields=id,name,slug,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal'; | |
| 90 | 100 | |
| 91 | 101 | $.getJSON(url).done(function( data ) { |
| 92 | 102 | $loading.hide(); |
| ... | ... | @@ -104,25 +114,24 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 104 | 114 | $randomProposal.html(supportProposalTemplate(article)); |
| 105 | 115 | $body.off('click', '.vote-actions .skip'); |
| 106 | 116 | $body.on('click', '.vote-actions .skip', function(e) { |
| 107 | - contextMain.loadRandomProposal(topic_id); | |
| 108 | 117 | e.preventDefault(); |
| 118 | + contextMain.loadRandomProposal(topic_id, true); | |
| 109 | 119 | }); |
| 110 | 120 | $body.off('click', '.vote-actions .vote-action'); |
| 111 | 121 | $body.on('click', '.vote-actions .vote-action', function(e) { |
| 112 | 122 | //Helps to prevent more than one vote per proposal |
| 113 | 123 | var button = $(this); |
| 124 | + e.preventDefault(); | |
| 114 | 125 | |
| 115 | 126 | if(!logged_in) { |
| 116 | 127 | $(this).closest('.require-login-container').find('.button-send a').click(); |
| 117 | - e.preventDefault(); | |
| 118 | 128 | return; |
| 119 | 129 | } |
| 120 | 130 | |
| 121 | 131 | if(ProposalApp.hasProposalbeenVoted(article.id)){ |
| 122 | 132 | // console.debug("Proposta " + article.id + " já havia sido votada"); |
| 123 | 133 | Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800); |
| 124 | - contextMain.loadRandomProposal(topic_id); | |
| 125 | - e.preventDefault(); | |
| 134 | + contextMain.loadRandomProposal(topic_id, true); | |
| 126 | 135 | return; |
| 127 | 136 | } |
| 128 | 137 | |
| ... | ... | @@ -140,9 +149,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 140 | 149 | Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800); |
| 141 | 150 | } |
| 142 | 151 | ProposalApp.addVotedProposal(article.id); |
| 143 | - contextMain.loadRandomProposal(topic_id); | |
| 152 | + contextMain.loadRandomProposal(topic_id, true); | |
| 144 | 153 | }); |
| 145 | - e.preventDefault(); | |
| 146 | 154 | }); |
| 147 | 155 | |
| 148 | 156 | $body.off('click', '.vote-result'); |
| ... | ... | @@ -166,12 +174,6 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 166 | 174 | } |
| 167 | 175 | }); |
| 168 | 176 | |
| 169 | - // $body.off('click', '.question-link'); | |
| 170 | - // $body.on('click', '.question-link', function(e) { | |
| 171 | - // var $this = $(this); | |
| 172 | - | |
| 173 | - // // Main.navigateTo($this.attr('href'), backTo); | |
| 174 | - // }); | |
| 175 | 177 | }).fail(function(){ |
| 176 | 178 | $loading.hide(); |
| 177 | 179 | $('.support-proposal .alert').show(); |
| ... | ... | @@ -196,7 +198,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 196 | 198 | $resultsContainer.html(resultsTemplate(data)); |
| 197 | 199 | $resultsContainer.find('.loading').hide(); |
| 198 | 200 | $resultsContainer.find('.results-content').show(); |
| 199 | - $(".timeago").timeago(); | |
| 201 | + $('.timeago').timeago(); | |
| 200 | 202 | $resultsContainer.show(); |
| 201 | 203 | |
| 202 | 204 | $('.footable').footable(); |
| ... | ... | @@ -401,7 +403,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 401 | 403 | }) |
| 402 | 404 | .fail(function( jqxhr, textStatus, error ) { |
| 403 | 405 | var err = textStatus + ', ' + error; |
| 404 | - // console.log( 'Request Failed: ' + err ); | |
| 406 | + console.error( 'Request Failed: ' + err ); | |
| 405 | 407 | }); |
| 406 | 408 | }, |
| 407 | 409 | display_proposal_by_category: function(item){ |
| ... | ... | @@ -504,7 +506,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 504 | 506 | var regexResultados = /resultados$/; |
| 505 | 507 | var regexSobreOPrograma = /sobre-o-programa$/; |
| 506 | 508 | |
| 507 | - if( !(regexHideBarra.exec(hash) !== null) && !HIDE_BARRA_DO_GOVERNO ){ | |
| 509 | + if( (regexHideBarra.exec(hash) === null) && !HIDE_BARRA_DO_GOVERNO ){ | |
| 508 | 510 | this.addBarraDoGoverno(); |
| 509 | 511 | }else{ |
| 510 | 512 | HIDE_BARRA_DO_GOVERNO = true; |
| ... | ... | @@ -525,6 +527,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 525 | 527 | this.display_article(hash.split('/')[2], lastHash); |
| 526 | 528 | } |
| 527 | 529 | |
| 530 | + var proposalTitle; | |
| 531 | + | |
| 528 | 532 | if( isProposal ){ |
| 529 | 533 | |
| 530 | 534 | // go to proposal |
| ... | ... | @@ -532,8 +536,9 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 532 | 536 | this.navigateToProposal(proposalId); |
| 533 | 537 | |
| 534 | 538 | var $proposal = $('#proposal-item-' + proposalId); |
| 535 | - var proposalTitle = $proposal.find('.title').text(); | |
| 539 | + proposalTitle = $proposal.find('.title').text(); | |
| 536 | 540 | var proposalOffset = $proposal.offset(); |
| 541 | + | |
| 537 | 542 | if(proposalOffset){ |
| 538 | 543 | scrollTop = proposalOffset.top; |
| 539 | 544 | }else{ |
| ... | ... | @@ -550,22 +555,24 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 550 | 555 | if($resultsContainer.css('display') === 'none') { |
| 551 | 556 | Main.loadRanking($resultsContainer, proposalId, 1); |
| 552 | 557 | } else { |
| 553 | - $proposalDetail.find('.experience-proposal-container').show(); | |
| 554 | - $proposalDetail.find('.talk-proposal-container').show(); | |
| 558 | + $proposal.find('.experience-proposal-container').show(); | |
| 559 | + $proposal.find('.talk-proposal-container').show(); | |
| 555 | 560 | $resultsContainer.hide(); |
| 556 | 561 | } |
| 557 | 562 | |
| 558 | - var proposalOffset = $resultsContainer.offset(); | |
| 563 | + proposalOffset = $resultsContainer.offset(); | |
| 559 | 564 | if(proposalOffset){ |
| 560 | 565 | scrollTop = proposalOffset.top; |
| 561 | 566 | } |
| 562 | 567 | } |
| 563 | 568 | } |
| 564 | 569 | |
| 570 | + var categorySlug; | |
| 571 | + | |
| 565 | 572 | if( isCategory ){ |
| 566 | 573 | |
| 567 | 574 | // go to category |
| 568 | - var categorySlug = parts[2]; | |
| 575 | + categorySlug = parts[2]; | |
| 569 | 576 | var categoryId = parts[3]; |
| 570 | 577 | this.navigateToCategory(categoryId); |
| 571 | 578 | |
| ... | ... | @@ -594,7 +601,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 594 | 601 | |
| 595 | 602 | var trackPageTitle = ''; |
| 596 | 603 | if(isArticle){ |
| 597 | - trackPageTitle = 'Página: Sobre' | |
| 604 | + trackPageTitle = 'Página: Sobre'; | |
| 598 | 605 | } |
| 599 | 606 | |
| 600 | 607 | if(isProposal){ |
| ... | ... | @@ -624,7 +631,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 624 | 631 | var regexSobreOPrograma = /sobre-o-programa$/; |
| 625 | 632 | if(proposalId === undefined){ |
| 626 | 633 | this.display_proposals_tab(); |
| 627 | - }else if(regexSobreOPrograma.exec(window.location.hash) == null){ | |
| 634 | + }else if(regexSobreOPrograma.exec(window.location.hash) === null){ | |
| 628 | 635 | this.display_proposal('proposal-item-' + proposalId); |
| 629 | 636 | }else{ |
| 630 | 637 | this.display_proposal_detail(proposalId); |
| ... | ... | @@ -638,11 +645,13 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 638 | 645 | } |
| 639 | 646 | }, |
| 640 | 647 | oauthClientAction: function(url) { |
| 641 | - var child = window.open(url, "_blank"); | |
| 648 | + var child = window.open(url, '_blank'); | |
| 642 | 649 | var interval = setInterval(function() { |
| 643 | 650 | try { |
| 644 | 651 | if(!child.closed) { |
| 645 | - child.postMessage({ message: "requestOauthClientPluginResult" }, "*"); | |
| 652 | + child.postMessage({ | |
| 653 | + message: 'requestOauthClientPluginResult' | |
| 654 | + }, '*'); | |
| 646 | 655 | } |
| 647 | 656 | } |
| 648 | 657 | catch(e) { |
| ... | ... | @@ -662,10 +671,10 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 662 | 671 | successPanel.find('.message').html(text); |
| 663 | 672 | successPanel.appendTo(container.closest('.categories')); |
| 664 | 673 | successPanel.show(); |
| 665 | - successPanel.css("top", Math.max(0, ((container.height() - successPanel.outerHeight()) / 2) + container.offset().top) + "px"); | |
| 666 | - successPanel.css("left", Math.max(0, ((container.width() - successPanel.outerWidth()) / 2) + container.offset().left) + "px"); | |
| 674 | + successPanel.css('top', Math.max(0, ((container.height() - successPanel.outerHeight()) / 2) + container.offset().top) + 'px'); | |
| 675 | + successPanel.css('left', Math.max(0, ((container.width() - successPanel.outerWidth()) / 2) + container.offset().left) + 'px'); | |
| 667 | 676 | |
| 668 | - var interval = setTimeout(function() { | |
| 677 | + setTimeout(function() { | |
| 669 | 678 | successPanel.hide(); |
| 670 | 679 | container.css('opacity', 1); |
| 671 | 680 | successPanel.remove(); |
| ... | ... | @@ -693,28 +702,32 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 693 | 702 | }, |
| 694 | 703 | responseToText: function(responseJSONmessage){ |
| 695 | 704 | var o = JSON.parse(responseJSONmessage); |
| 696 | - var msg = ""; | |
| 705 | + var msg = ''; | |
| 697 | 706 | var fn; |
| 698 | 707 | |
| 699 | 708 | for (var key in o) { |
| 700 | 709 | if (o[key] instanceof Array) { |
| 701 | 710 | fn = key; |
| 702 | 711 | for (var i = 0; i < o[key].length; i++) { |
| 703 | - msg += fn + " " + o[key][i] + "</br>"; | |
| 712 | + msg += fn + ' ' + o[key][i] + '</br>'; | |
| 704 | 713 | } |
| 705 | 714 | } |
| 706 | 715 | } |
| 707 | - msg = msg.replace('password_confirmation', "campo 'confirmação da senha'"); | |
| 708 | - msg = msg.replace(/password/g, "campo 'senha'"); | |
| 709 | - msg = msg.replace('login', "campo 'nome de usuário'"); | |
| 710 | - msg = msg.replace('email', "campo 'e-mail'"); | |
| 711 | - msg = msg.substring(0, msg.length - 5) + "."; | |
| 716 | + msg = msg.replace('password_confirmation', 'campo "confirmação da senha"'); | |
| 717 | + msg = msg.replace(/password/g, 'campo "senha"'); | |
| 718 | + msg = msg.replace('login', 'campo "nome de usuário"'); | |
| 719 | + msg = msg.replace('email', 'campo "e-mail"'); | |
| 720 | + msg = msg.substring(0, msg.length - 5) + '.'; | |
| 712 | 721 | return msg; |
| 713 | 722 | }, |
| 714 | 723 | display_events: function(cat_id, active_category) { |
| 715 | - var url = host + '/api/v1/communities/' + window.dialoga_community + '/articles?categories_ids[]=' + cat_id + '&content_type=Event&private_token=' + '375bee7e17d0021af7160ce664874618'; | |
| 724 | + var url = host + '/api/v1/communities/' + dialoga_community + '/articles?categories_ids[]=' + cat_id + '&content_type=Event&private_token=' + '375bee7e17d0021af7160ce664874618'; | |
| 716 | 725 | $.getJSON(url).done(function (data) { |
| 717 | - if(data.articles.length==0) return; | |
| 726 | + | |
| 727 | + if(data.articles.length === 0){ | |
| 728 | + return; | |
| 729 | + } | |
| 730 | + | |
| 718 | 731 | var dt = data.articles[0].start_date; |
| 719 | 732 | var date = dt.substr(8, 2) + '/' + dt.substr(5, 2) + '/' + dt.substr(0, 4); |
| 720 | 733 | var dd = new Date(dt); |
| ... | ... | @@ -722,7 +735,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 722 | 735 | var params = {event: data.articles[0], date: date, time: time, category: data.articles[0].categories[0].name, category_class: active_category}; |
| 723 | 736 | $.getJSON(host+'/api/v1/articles/'+data.articles[0].id+'/followers?private_token=' + '375bee7e17d0021af7160ce664874618' + '&_='+new Date().getTime()).done(function (data) { |
| 724 | 737 | //FIXME do not depend on this request |
| 725 | - params['total_followers'] = data.total_followers; | |
| 738 | + params.total_followers = data.total_followers; | |
| 726 | 739 | $('.calendar-container').html(calendarTemplate(params)); |
| 727 | 740 | $('.calendar-container .calendar.' + active_category).show(); |
| 728 | 741 | // $('.calendar-container .calendar').slick(); |
| ... | ... | @@ -770,7 +783,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 770 | 783 | var $paragraph = $proposalItemEl.find('p'); |
| 771 | 784 | var lines = Main.computeLines($paragraph); |
| 772 | 785 | if(lines > maxLinesByParagraph ){ |
| 773 | - maxLinesByParagraph = lines | |
| 786 | + maxLinesByParagraph = lines; | |
| 774 | 787 | } |
| 775 | 788 | }); |
| 776 | 789 | // console.log('maxLinesByParagraph', maxLinesByParagraph); |
| ... | ... | @@ -781,7 +794,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 781 | 794 | var $title = $proposalItemEl.find('.box__title'); |
| 782 | 795 | var lines = Main.computeLines($title); |
| 783 | 796 | if(lines > maxLinesByTitle ){ |
| 784 | - maxLinesByTitle = lines | |
| 797 | + maxLinesByTitle = lines; | |
| 785 | 798 | } |
| 786 | 799 | }); |
| 787 | 800 | // console.log('maxLinesByTitle', maxLinesByTitle); |
| ... | ... | @@ -818,9 +831,9 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 818 | 831 | Main.loginCallback(true, data.private_token); |
| 819 | 832 | }, |
| 820 | 833 | handleLoginFail: function (e){ |
| 821 | - // console.log('Event', e); | |
| 834 | + console.error('handleLoginFail', e); | |
| 822 | 835 | } |
| 823 | - } | |
| 836 | + }; | |
| 824 | 837 | })(); |
| 825 | 838 | |
| 826 | 839 | |
| ... | ... | @@ -848,7 +861,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 848 | 861 | var url = abstract.substring(startSrcUrl , endSrcUrl); |
| 849 | 862 | // console.log('url', url); |
| 850 | 863 | |
| 851 | - if(url.indexOf("wmode=opaque") !== -1){ | |
| 864 | + if(url.indexOf('wmode=opaque') !== -1){ | |
| 852 | 865 | // already in opaque mode |
| 853 | 866 | // console.debug('already in opaque mode'); |
| 854 | 867 | return; |
| ... | ... | @@ -858,10 +871,11 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 858 | 871 | c = '&'; |
| 859 | 872 | } |
| 860 | 873 | |
| 861 | - var resultUrl = url+c+"wmode=opaque"; | |
| 874 | + var resultUrl = url + c + 'wmode=opaque'; | |
| 862 | 875 | article.abstract = abstract.replace(url, resultUrl); |
| 863 | 876 | // console.log('article.abstract', article.abstract); |
| 864 | - }; | |
| 877 | + } | |
| 878 | + | |
| 865 | 879 | forceWmodeIframe(data.article); |
| 866 | 880 | |
| 867 | 881 | resultsPlaceholder.innerHTML = template(data); |
| ... | ... | @@ -919,7 +933,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 919 | 933 | $(document).keyup(function(e) { |
| 920 | 934 | |
| 921 | 935 | // escape key maps to keycode `27` |
| 922 | - if (e.keyCode == 27) { // ESC | |
| 936 | + if (e.keyCode === 27) { // ESC | |
| 923 | 937 | $loginPanel.hide(); |
| 924 | 938 | } |
| 925 | 939 | }); |
| ... | ... | @@ -977,7 +991,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 977 | 991 | // return to proposal page |
| 978 | 992 | newHash = oldHash.split('/sobre-o-programa')[0]; |
| 979 | 993 | }else{ |
| 980 | - $link = $(this).siblings('.proposal-link'); | |
| 994 | + var $link = $(this).siblings('.proposal-link'); | |
| 981 | 995 | newHash = $link.attr('href'); |
| 982 | 996 | } |
| 983 | 997 | |
| ... | ... | @@ -1027,10 +1041,10 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1027 | 1041 | Main.updateHash($link.attr('href')); |
| 1028 | 1042 | }); |
| 1029 | 1043 | |
| 1030 | - $( '.proposal-selection' ).change(function(e){ | |
| 1044 | + $( '.proposal-selection' ).change(function(){ | |
| 1031 | 1045 | // Update URL and Navigate |
| 1032 | 1046 | Main.updateHash('#/programas/' + this.value); |
| 1033 | - $(this).val($(this).data("proposal")).trigger("chosen:updated"); | |
| 1047 | + $(this).val($(this).data('proposal')).trigger('chosen:updated'); | |
| 1034 | 1048 | }); |
| 1035 | 1049 | |
| 1036 | 1050 | var availableTags = [ ]; |
| ... | ... | @@ -1055,8 +1069,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1055 | 1069 | |
| 1056 | 1070 | $('.save-article-form').submit(function (e) { |
| 1057 | 1071 | e.preventDefault(); |
| 1058 | - var proposal_id = this.id.split('-').pop(); | |
| 1059 | - var form = this; | |
| 1072 | + // var proposal_id = this.id.split('-').pop(); | |
| 1073 | + // var form = this; | |
| 1060 | 1074 | var $form = $(this); |
| 1061 | 1075 | var $message = $form.find('.message'); |
| 1062 | 1076 | $message.hide(); |
| ... | ... | @@ -1076,7 +1090,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1076 | 1090 | }) |
| 1077 | 1091 | .fail(function( jqxhr, textStatus, error ) { |
| 1078 | 1092 | var err = textStatus + ', ' + error; |
| 1079 | - // console.log( 'Request Failed: ' + err ); | |
| 1093 | + console.error( 'Request Failed: ' + err ); | |
| 1080 | 1094 | $message.show(); |
| 1081 | 1095 | $message.text('Não foi possível enviar.'); |
| 1082 | 1096 | }); |
| ... | ... | @@ -1084,7 +1098,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1084 | 1098 | }) |
| 1085 | 1099 | .fail(function( jqxhr, textStatus, error ) { |
| 1086 | 1100 | var err = textStatus + ', ' + error; |
| 1087 | - // console.log( 'Request Failed: ' + err ); | |
| 1101 | + console.error( 'Request Failed: ' + err ); | |
| 1088 | 1102 | }); |
| 1089 | 1103 | |
| 1090 | 1104 | $(document).ready(function($) { |
| ... | ... | @@ -1151,7 +1165,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1151 | 1165 | }).fail(function(data) { |
| 1152 | 1166 | |
| 1153 | 1167 | $message.show(); |
| 1154 | - if(data.status==401){ | |
| 1168 | + if(data.status === 401){ | |
| 1155 | 1169 | $message.text('Nome de usuário, e-mail ou senha incorretos, não foi possível acessar.'); |
| 1156 | 1170 | }else{ |
| 1157 | 1171 | $message.text('Um erro inesperado ocorreu'); |
| ... | ... | @@ -1176,24 +1190,32 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1176 | 1190 | }); |
| 1177 | 1191 | |
| 1178 | 1192 | $(document).on('click', '.new-user', function(e) { |
| 1179 | - if(window.lastCaptcha) | |
| 1193 | + | |
| 1194 | + if(window.lastCaptcha){ | |
| 1180 | 1195 | window.lastCaptcha.destruir(); |
| 1196 | + } | |
| 1197 | + | |
| 1181 | 1198 | var loginForm = $(this).parents('#login-form'); |
| 1182 | 1199 | var signupForm = loginForm.siblings('#signup-form'); |
| 1183 | 1200 | window.signupForm = signupForm; |
| 1201 | + | |
| 1184 | 1202 | loginForm.hide(); |
| 1185 | 1203 | signupForm.show(); |
| 1186 | - signupForm.find(".password").show(); | |
| 1187 | - signupForm.find(".password-confirmation").show(); | |
| 1204 | + | |
| 1205 | + signupForm.find('.password').show(); | |
| 1206 | + signupForm.find('.password-confirmation').show(); | |
| 1188 | 1207 | loginForm.find('.message').hide(); |
| 1189 | 1208 | signupForm.find('#serpro_captcha').empty(); |
| 1209 | + | |
| 1190 | 1210 | var oCaptcha_serpro_gov_br; |
| 1191 | 1211 | oCaptcha_serpro_gov_br = new captcha_serpro_gov_br(); |
| 1192 | 1212 | window.lastCaptcha = oCaptcha_serpro_gov_br; |
| 1193 | - oCaptcha_serpro_gov_br.clienteId = "fdbcdc7a0b754ee7ae9d865fda740f17"; | |
| 1194 | - oCaptcha_serpro_gov_br.criarUI(signupForm.find('#serpro_captcha')[0], "css", "input", "serpro_captcha_component_"); | |
| 1213 | + | |
| 1214 | + oCaptcha_serpro_gov_br.clienteId = 'fdbcdc7a0b754ee7ae9d865fda740f17'; | |
| 1215 | + oCaptcha_serpro_gov_br.criarUI(signupForm.find('#serpro_captcha')[0], 'css', 'input', 'serpro_captcha_component_'); | |
| 1216 | + | |
| 1195 | 1217 | e.preventDefault(); |
| 1196 | - }) | |
| 1218 | + }); | |
| 1197 | 1219 | |
| 1198 | 1220 | $(document).on('click', '.cancel-signup', function(e) { |
| 1199 | 1221 | var signupForm = $(this).parents('#signup-form'); |
| ... | ... | @@ -1223,7 +1245,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1223 | 1245 | var hasUsername = $inputUsername && $inputUsername.val().length > 0; |
| 1224 | 1246 | var hasPassword = $inputPassword && $inputPassword.val().length > 0; |
| 1225 | 1247 | var hasPasswordConfirmation = $inputPasswordConfirmation && $inputPasswordConfirmation.val().length > 0; |
| 1226 | - var hasPasswordEquals = $inputPassword.val() == $inputPasswordConfirmation.val(); | |
| 1248 | + var hasPasswordEquals = $inputPassword.val() === $inputPasswordConfirmation.val(); | |
| 1227 | 1249 | var hasAcceptation = $inputAcceptation.val(); |
| 1228 | 1250 | var hasCaptcha = $inputCaptcha.val().length > 0; |
| 1229 | 1251 | var hasError = (!hasEmail || !hasUsername || !hasPassword || !hasPasswordConfirmation || !hasPasswordEquals || !hasAcceptation || !hasCaptcha); |
| ... | ... | @@ -1290,11 +1312,13 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1290 | 1312 | } |
| 1291 | 1313 | $(document).trigger('login:success', data); |
| 1292 | 1314 | }) |
| 1293 | - .fail(function (data, var2) { | |
| 1294 | - var msg = ""; | |
| 1315 | + .fail(function (data) { | |
| 1316 | + var msg = ''; | |
| 1295 | 1317 | // Reload captcha here |
| 1296 | - if(window.lastCaptcha) | |
| 1318 | + if(window.lastCaptcha){ | |
| 1297 | 1319 | window.lastCaptcha.recarregar(); |
| 1320 | + } | |
| 1321 | + | |
| 1298 | 1322 | if(data.responseJSON){ |
| 1299 | 1323 | try{ |
| 1300 | 1324 | msg = Main.responseToText(data.responseJSON.message); |
| ... | ... | @@ -1325,32 +1349,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1325 | 1349 | } |
| 1326 | 1350 | }); |
| 1327 | 1351 | |
| 1328 | - // var popupCenter = function(url, title, w, h) { | |
| 1329 | - // var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left; | |
| 1330 | - // var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top; | |
| 1331 | - | |
| 1332 | - // var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; | |
| 1333 | - // var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; | |
| 1334 | - | |
| 1335 | - // var left = ((width / 2) - (w / 2)) + dualScreenLeft; | |
| 1336 | - // var top = ((height / 3) - (h / 3)) + dualScreenTop; | |
| 1337 | - | |
| 1338 | - // var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); | |
| 1339 | - | |
| 1340 | - // // Puts focus on the newWindow | |
| 1341 | - // if (window.focus) { | |
| 1342 | - // newWindow.focus(); | |
| 1343 | - // } | |
| 1344 | - // }; | |
| 1345 | - | |
| 1346 | - // $(document).on('click', '.social a.popup', {}, function popUp(e) { | |
| 1347 | - // var self = $(this); | |
| 1348 | - // popupCenter(self.attr('href'), self.find('.rrssb-text').html(), 580, 470); | |
| 1349 | - // e.preventDefault(); | |
| 1350 | - // }); | |
| 1351 | - | |
| 1352 | 1352 | $(document).on('click', '#logout-button', function (e){ |
| 1353 | - var self = $(this); | |
| 1354 | 1353 | $.removeCookie('_dialoga_session'); |
| 1355 | 1354 | $.removeCookie('votedProposals'); |
| 1356 | 1355 | $.removeCookie('*'); |
| ... | ... | @@ -1365,36 +1364,36 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1365 | 1364 | }); |
| 1366 | 1365 | |
| 1367 | 1366 | // hack-fix to support z-index over video/iframe |
| 1368 | - function checkIframes () { | |
| 1369 | - | |
| 1370 | - $('iframe').each(function(){ | |
| 1371 | - var $iframe = $(this); | |
| 1372 | - var url = $iframe.attr('src'); | |
| 1373 | - var c = '?'; | |
| 1374 | - | |
| 1375 | - if(url.indexOf("youtube") === -1){ | |
| 1376 | - // is not a iframe of youtube | |
| 1377 | - // console.debug('is not a iframe of youtube'); | |
| 1378 | - return; | |
| 1379 | - } | |
| 1380 | - | |
| 1381 | - if(url.indexOf("wmode=opaque") !== -1){ | |
| 1382 | - // already in opaque mode | |
| 1383 | - // console.debug('already in opaque mode'); | |
| 1384 | - return; | |
| 1385 | - } | |
| 1386 | - | |
| 1387 | - if(url.indexOf('?') !== -1){ | |
| 1388 | - c = '&'; | |
| 1389 | - } | |
| 1367 | + // function checkIframes () { | |
| 1368 | + | |
| 1369 | + // $('iframe').each(function(){ | |
| 1370 | + // var $iframe = $(this); | |
| 1371 | + // var url = $iframe.attr('src'); | |
| 1372 | + // var c = '?'; | |
| 1373 | + | |
| 1374 | + // if(url.indexOf("youtube") === -1){ | |
| 1375 | + // // is not a iframe of youtube | |
| 1376 | + // // console.debug('is not a iframe of youtube'); | |
| 1377 | + // return; | |
| 1378 | + // } | |
| 1379 | + | |
| 1380 | + // if(url.indexOf("wmode=opaque") !== -1){ | |
| 1381 | + // // already in opaque mode | |
| 1382 | + // // console.debug('already in opaque mode'); | |
| 1383 | + // return; | |
| 1384 | + // } | |
| 1385 | + | |
| 1386 | + // if(url.indexOf('?') !== -1){ | |
| 1387 | + // c = '&'; | |
| 1388 | + // } | |
| 1390 | 1389 | |
| 1391 | - $iframe.attr("src",url+c+"wmode=opaque"); | |
| 1392 | - // console.debug('iframe changed to opaque mode'); | |
| 1393 | - }); | |
| 1390 | + // $iframe.attr("src",url+c+"wmode=opaque"); | |
| 1391 | + // // console.debug('iframe changed to opaque mode'); | |
| 1392 | + // }); | |
| 1394 | 1393 | |
| 1395 | - setTimeout(checkIframes, 500); | |
| 1396 | - } | |
| 1397 | - checkIframes(); | |
| 1394 | + // setTimeout(checkIframes, 500); | |
| 1395 | + // } | |
| 1396 | + // checkIframes(); | |
| 1398 | 1397 | |
| 1399 | 1398 | }); |
| 1400 | 1399 | |
| ... | ... | @@ -1406,11 +1405,11 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1406 | 1405 | }); |
| 1407 | 1406 | |
| 1408 | 1407 | if('onhashchange' in window){ |
| 1409 | - window.onhashchange = function(){ | |
| 1408 | + window.onhashchange = function(){ | |
| 1410 | 1409 | Main.locationHashChanged.apply(Main); |
| 1411 | - } | |
| 1410 | + }; | |
| 1412 | 1411 | }else{ |
| 1413 | - // console.log('The browser not supports the hashchange event!'); | |
| 1412 | + console.warn('The browser not supports the hashchange event!'); | |
| 1414 | 1413 | } |
| 1415 | 1414 | |
| 1416 | 1415 | // Handle resize event |
| ... | ... | @@ -1439,7 +1438,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1439 | 1438 | |
| 1440 | 1439 | timeout = setTimeout(delayed, threshold || 100); |
| 1441 | 1440 | }; |
| 1442 | - } | |
| 1441 | + }; | |
| 1443 | 1442 | |
| 1444 | 1443 | // smartresize |
| 1445 | 1444 | jQuery.fn[sr] = function(fn){ | ... | ... |