Commit 24090512039d25fc8387b4789e4ea2ee1e7f2e34

Authored by Leonardo Merlin
1 parent ee4b4df8

Fix JSHint errors

Showing 1 changed file with 146 additions and 145 deletions   Show diff stats
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',
... ... @@ -68,7 +78,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
68 78 return proposalId;
69 79 },
70 80 loadRandomProposal: function (topic_id, force) {
71   - var private_token = Main.private_token;
  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 && !force){
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();
... ... @@ -164,12 +174,6 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
164 174 }
165 175 });
166 176  
167   - // $body.off('click', '.question-link');
168   - // $body.on('click', '.question-link', function(e) {
169   - // var $this = $(this);
170   -
171   - // // Main.navigateTo($this.attr('href'), backTo);
172   - // });
173 177 }).fail(function(){
174 178 $loading.hide();
175 179 $('.support-proposal .alert').show();
... ... @@ -194,7 +198,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
194 198 $resultsContainer.html(resultsTemplate(data));
195 199 $resultsContainer.find('.loading').hide();
196 200 $resultsContainer.find('.results-content').show();
197   - $(".timeago").timeago();
  201 + $('.timeago').timeago();
198 202 $resultsContainer.show();
199 203  
200 204 $('.footable').footable();
... ... @@ -399,7 +403,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
399 403 })
400 404 .fail(function( jqxhr, textStatus, error ) {
401 405 var err = textStatus + ', ' + error;
402   - // console.log( 'Request Failed: ' + err );
  406 + console.error( 'Request Failed: ' + err );
403 407 });
404 408 },
405 409 display_proposal_by_category: function(item){
... ... @@ -502,7 +506,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
502 506 var regexResultados = /resultados$/;
503 507 var regexSobreOPrograma = /sobre-o-programa$/;
504 508  
505   - if( !(regexHideBarra.exec(hash) !== null) && !HIDE_BARRA_DO_GOVERNO ){
  509 + if( (regexHideBarra.exec(hash) === null) && !HIDE_BARRA_DO_GOVERNO ){
506 510 this.addBarraDoGoverno();
507 511 }else{
508 512 HIDE_BARRA_DO_GOVERNO = true;
... ... @@ -523,6 +527,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
523 527 this.display_article(hash.split('/')[2], lastHash);
524 528 }
525 529  
  530 + var proposalTitle;
  531 +
526 532 if( isProposal ){
527 533  
528 534 // go to proposal
... ... @@ -530,8 +536,9 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
530 536 this.navigateToProposal(proposalId);
531 537  
532 538 var $proposal = $('#proposal-item-' + proposalId);
533   - var proposalTitle = $proposal.find('.title').text();
  539 + proposalTitle = $proposal.find('.title').text();
534 540 var proposalOffset = $proposal.offset();
  541 +
535 542 if(proposalOffset){
536 543 scrollTop = proposalOffset.top;
537 544 }else{
... ... @@ -548,22 +555,24 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
548 555 if($resultsContainer.css('display') === 'none') {
549 556 Main.loadRanking($resultsContainer, proposalId, 1);
550 557 } else {
551   - $proposalDetail.find('.experience-proposal-container').show();
552   - $proposalDetail.find('.talk-proposal-container').show();
  558 + $proposal.find('.experience-proposal-container').show();
  559 + $proposal.find('.talk-proposal-container').show();
553 560 $resultsContainer.hide();
554 561 }
555 562  
556   - var proposalOffset = $resultsContainer.offset();
  563 + proposalOffset = $resultsContainer.offset();
557 564 if(proposalOffset){
558 565 scrollTop = proposalOffset.top;
559 566 }
560 567 }
561 568 }
562 569  
  570 + var categorySlug;
  571 +
563 572 if( isCategory ){
564 573  
565 574 // go to category
566   - var categorySlug = parts[2];
  575 + categorySlug = parts[2];
567 576 var categoryId = parts[3];
568 577 this.navigateToCategory(categoryId);
569 578  
... ... @@ -592,7 +601,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
592 601  
593 602 var trackPageTitle = '';
594 603 if(isArticle){
595   - trackPageTitle = 'Página: Sobre'
  604 + trackPageTitle = 'Página: Sobre';
596 605 }
597 606  
598 607 if(isProposal){
... ... @@ -622,7 +631,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
622 631 var regexSobreOPrograma = /sobre-o-programa$/;
623 632 if(proposalId === undefined){
624 633 this.display_proposals_tab();
625   - }else if(regexSobreOPrograma.exec(window.location.hash) == null){
  634 + }else if(regexSobreOPrograma.exec(window.location.hash) === null){
626 635 this.display_proposal('proposal-item-' + proposalId);
627 636 }else{
628 637 this.display_proposal_detail(proposalId);
... ... @@ -636,11 +645,13 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
636 645 }
637 646 },
638 647 oauthClientAction: function(url) {
639   - var child = window.open(url, "_blank");
  648 + var child = window.open(url, '_blank');
640 649 var interval = setInterval(function() {
641 650 try {
642 651 if(!child.closed) {
643   - child.postMessage({ message: "requestOauthClientPluginResult" }, "*");
  652 + child.postMessage({
  653 + message: 'requestOauthClientPluginResult'
  654 + }, '*');
644 655 }
645 656 }
646 657 catch(e) {
... ... @@ -660,10 +671,10 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
660 671 successPanel.find('.message').html(text);
661 672 successPanel.appendTo(container.closest('.categories'));
662 673 successPanel.show();
663   - successPanel.css("top", Math.max(0, ((container.height() - successPanel.outerHeight()) / 2) + container.offset().top) + "px");
664   - 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');
665 676  
666   - var interval = setTimeout(function() {
  677 + setTimeout(function() {
667 678 successPanel.hide();
668 679 container.css('opacity', 1);
669 680 successPanel.remove();
... ... @@ -691,28 +702,32 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
691 702 },
692 703 responseToText: function(responseJSONmessage){
693 704 var o = JSON.parse(responseJSONmessage);
694   - var msg = "";
  705 + var msg = '';
695 706 var fn;
696 707  
697 708 for (var key in o) {
698 709 if (o[key] instanceof Array) {
699 710 fn = key;
700 711 for (var i = 0; i < o[key].length; i++) {
701   - msg += fn + " " + o[key][i] + "</br>";
  712 + msg += fn + ' ' + o[key][i] + '</br>';
702 713 }
703 714 }
704 715 }
705   - msg = msg.replace('password_confirmation', "campo 'confirmação da senha'");
706   - msg = msg.replace(/password/g, "campo 'senha'");
707   - msg = msg.replace('login', "campo 'nome de usuário'");
708   - msg = msg.replace('email', "campo 'e-mail'");
709   - 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) + '.';
710 721 return msg;
711 722 },
712 723 display_events: function(cat_id, active_category) {
713   - 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';
714 725 $.getJSON(url).done(function (data) {
715   - if(data.articles.length==0) return;
  726 +
  727 + if(data.articles.length === 0){
  728 + return;
  729 + }
  730 +
716 731 var dt = data.articles[0].start_date;
717 732 var date = dt.substr(8, 2) + '/' + dt.substr(5, 2) + '/' + dt.substr(0, 4);
718 733 var dd = new Date(dt);
... ... @@ -720,7 +735,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
720 735 var params = {event: data.articles[0], date: date, time: time, category: data.articles[0].categories[0].name, category_class: active_category};
721 736 $.getJSON(host+'/api/v1/articles/'+data.articles[0].id+'/followers?private_token=' + '375bee7e17d0021af7160ce664874618' + '&_='+new Date().getTime()).done(function (data) {
722 737 //FIXME do not depend on this request
723   - params['total_followers'] = data.total_followers;
  738 + params.total_followers = data.total_followers;
724 739 $('.calendar-container').html(calendarTemplate(params));
725 740 $('.calendar-container .calendar.' + active_category).show();
726 741 // $('.calendar-container .calendar').slick();
... ... @@ -768,7 +783,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
768 783 var $paragraph = $proposalItemEl.find('p');
769 784 var lines = Main.computeLines($paragraph);
770 785 if(lines > maxLinesByParagraph ){
771   - maxLinesByParagraph = lines
  786 + maxLinesByParagraph = lines;
772 787 }
773 788 });
774 789 // console.log('maxLinesByParagraph', maxLinesByParagraph);
... ... @@ -779,7 +794,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
779 794 var $title = $proposalItemEl.find('.box__title');
780 795 var lines = Main.computeLines($title);
781 796 if(lines > maxLinesByTitle ){
782   - maxLinesByTitle = lines
  797 + maxLinesByTitle = lines;
783 798 }
784 799 });
785 800 // console.log('maxLinesByTitle', maxLinesByTitle);
... ... @@ -816,9 +831,9 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
816 831 Main.loginCallback(true, data.private_token);
817 832 },
818 833 handleLoginFail: function (e){
819   - // console.log('Event', e);
  834 + console.error('handleLoginFail', e);
820 835 }
821   - }
  836 + };
822 837 })();
823 838  
824 839  
... ... @@ -846,7 +861,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
846 861 var url = abstract.substring(startSrcUrl , endSrcUrl);
847 862 // console.log('url', url);
848 863  
849   - if(url.indexOf("wmode=opaque") !== -1){
  864 + if(url.indexOf('wmode=opaque') !== -1){
850 865 // already in opaque mode
851 866 // console.debug('already in opaque mode');
852 867 return;
... ... @@ -856,10 +871,11 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
856 871 c = '&';
857 872 }
858 873  
859   - var resultUrl = url+c+"wmode=opaque";
  874 + var resultUrl = url + c + 'wmode=opaque';
860 875 article.abstract = abstract.replace(url, resultUrl);
861 876 // console.log('article.abstract', article.abstract);
862   - };
  877 + }
  878 +
863 879 forceWmodeIframe(data.article);
864 880  
865 881 resultsPlaceholder.innerHTML = template(data);
... ... @@ -917,7 +933,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
917 933 $(document).keyup(function(e) {
918 934  
919 935 // escape key maps to keycode `27`
920   - if (e.keyCode == 27) { // ESC
  936 + if (e.keyCode === 27) { // ESC
921 937 $loginPanel.hide();
922 938 }
923 939 });
... ... @@ -975,7 +991,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
975 991 // return to proposal page
976 992 newHash = oldHash.split('/sobre-o-programa')[0];
977 993 }else{
978   - $link = $(this).siblings('.proposal-link');
  994 + var $link = $(this).siblings('.proposal-link');
979 995 newHash = $link.attr('href');
980 996 }
981 997  
... ... @@ -1025,10 +1041,10 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1025 1041 Main.updateHash($link.attr('href'));
1026 1042 });
1027 1043  
1028   - $( '.proposal-selection' ).change(function(e){
  1044 + $( '.proposal-selection' ).change(function(){
1029 1045 // Update URL and Navigate
1030 1046 Main.updateHash('#/programas/' + this.value);
1031   - $(this).val($(this).data("proposal")).trigger("chosen:updated");
  1047 + $(this).val($(this).data('proposal')).trigger('chosen:updated');
1032 1048 });
1033 1049  
1034 1050 var availableTags = [ ];
... ... @@ -1053,8 +1069,8 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1053 1069  
1054 1070 $('.save-article-form').submit(function (e) {
1055 1071 e.preventDefault();
1056   - var proposal_id = this.id.split('-').pop();
1057   - var form = this;
  1072 + // var proposal_id = this.id.split('-').pop();
  1073 + // var form = this;
1058 1074 var $form = $(this);
1059 1075 var $message = $form.find('.message');
1060 1076 $message.hide();
... ... @@ -1074,7 +1090,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1074 1090 })
1075 1091 .fail(function( jqxhr, textStatus, error ) {
1076 1092 var err = textStatus + ', ' + error;
1077   - // console.log( 'Request Failed: ' + err );
  1093 + console.error( 'Request Failed: ' + err );
1078 1094 $message.show();
1079 1095 $message.text('Não foi possível enviar.');
1080 1096 });
... ... @@ -1082,7 +1098,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1082 1098 })
1083 1099 .fail(function( jqxhr, textStatus, error ) {
1084 1100 var err = textStatus + ', ' + error;
1085   - // console.log( 'Request Failed: ' + err );
  1101 + console.error( 'Request Failed: ' + err );
1086 1102 });
1087 1103  
1088 1104 $(document).ready(function($) {
... ... @@ -1149,7 +1165,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1149 1165 }).fail(function(data) {
1150 1166  
1151 1167 $message.show();
1152   - if(data.status==401){
  1168 + if(data.status === 401){
1153 1169 $message.text('Nome de usuário, e-mail ou senha incorretos, não foi possível acessar.');
1154 1170 }else{
1155 1171 $message.text('Um erro inesperado ocorreu');
... ... @@ -1174,24 +1190,32 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1174 1190 });
1175 1191  
1176 1192 $(document).on('click', '.new-user', function(e) {
1177   - if(window.lastCaptcha)
  1193 +
  1194 + if(window.lastCaptcha){
1178 1195 window.lastCaptcha.destruir();
  1196 + }
  1197 +
1179 1198 var loginForm = $(this).parents('#login-form');
1180 1199 var signupForm = loginForm.siblings('#signup-form');
1181 1200 window.signupForm = signupForm;
  1201 +
1182 1202 loginForm.hide();
1183 1203 signupForm.show();
1184   - signupForm.find(".password").show();
1185   - signupForm.find(".password-confirmation").show();
  1204 +
  1205 + signupForm.find('.password').show();
  1206 + signupForm.find('.password-confirmation').show();
1186 1207 loginForm.find('.message').hide();
1187 1208 signupForm.find('#serpro_captcha').empty();
  1209 +
1188 1210 var oCaptcha_serpro_gov_br;
1189 1211 oCaptcha_serpro_gov_br = new captcha_serpro_gov_br();
1190 1212 window.lastCaptcha = oCaptcha_serpro_gov_br;
1191   - oCaptcha_serpro_gov_br.clienteId = "fdbcdc7a0b754ee7ae9d865fda740f17";
1192   - 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 +
1193 1217 e.preventDefault();
1194   - })
  1218 + });
1195 1219  
1196 1220 $(document).on('click', '.cancel-signup', function(e) {
1197 1221 var signupForm = $(this).parents('#signup-form');
... ... @@ -1221,7 +1245,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1221 1245 var hasUsername = $inputUsername && $inputUsername.val().length > 0;
1222 1246 var hasPassword = $inputPassword && $inputPassword.val().length > 0;
1223 1247 var hasPasswordConfirmation = $inputPasswordConfirmation && $inputPasswordConfirmation.val().length > 0;
1224   - var hasPasswordEquals = $inputPassword.val() == $inputPasswordConfirmation.val();
  1248 + var hasPasswordEquals = $inputPassword.val() === $inputPasswordConfirmation.val();
1225 1249 var hasAcceptation = $inputAcceptation.val();
1226 1250 var hasCaptcha = $inputCaptcha.val().length > 0;
1227 1251 var hasError = (!hasEmail || !hasUsername || !hasPassword || !hasPasswordConfirmation || !hasPasswordEquals || !hasAcceptation || !hasCaptcha);
... ... @@ -1288,11 +1312,13 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1288 1312 }
1289 1313 $(document).trigger('login:success', data);
1290 1314 })
1291   - .fail(function (data, var2) {
1292   - var msg = "";
  1315 + .fail(function (data) {
  1316 + var msg = '';
1293 1317 // Reload captcha here
1294   - if(window.lastCaptcha)
  1318 + if(window.lastCaptcha){
1295 1319 window.lastCaptcha.recarregar();
  1320 + }
  1321 +
1296 1322 if(data.responseJSON){
1297 1323 try{
1298 1324 msg = Main.responseToText(data.responseJSON.message);
... ... @@ -1323,32 +1349,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1323 1349 }
1324 1350 });
1325 1351  
1326   - // var popupCenter = function(url, title, w, h) {
1327   - // var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left;
1328   - // var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top;
1329   -
1330   - // var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
1331   - // var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
1332   -
1333   - // var left = ((width / 2) - (w / 2)) + dualScreenLeft;
1334   - // var top = ((height / 3) - (h / 3)) + dualScreenTop;
1335   -
1336   - // var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
1337   -
1338   - // // Puts focus on the newWindow
1339   - // if (window.focus) {
1340   - // newWindow.focus();
1341   - // }
1342   - // };
1343   -
1344   - // $(document).on('click', '.social a.popup', {}, function popUp(e) {
1345   - // var self = $(this);
1346   - // popupCenter(self.attr('href'), self.find('.rrssb-text').html(), 580, 470);
1347   - // e.preventDefault();
1348   - // });
1349   -
1350 1352 $(document).on('click', '#logout-button', function (e){
1351   - var self = $(this);
1352 1353 $.removeCookie('_dialoga_session');
1353 1354 $.removeCookie('votedProposals');
1354 1355 $.removeCookie('*');
... ... @@ -1363,36 +1364,36 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1363 1364 });
1364 1365  
1365 1366 // hack-fix to support z-index over video/iframe
1366   - function checkIframes () {
1367   -
1368   - $('iframe').each(function(){
1369   - var $iframe = $(this);
1370   - var url = $iframe.attr('src');
1371   - var c = '?';
1372   -
1373   - if(url.indexOf("youtube") === -1){
1374   - // is not a iframe of youtube
1375   - // console.debug('is not a iframe of youtube');
1376   - return;
1377   - }
1378   -
1379   - if(url.indexOf("wmode=opaque") !== -1){
1380   - // already in opaque mode
1381   - // console.debug('already in opaque mode');
1382   - return;
1383   - }
1384   -
1385   - if(url.indexOf('?') !== -1){
1386   - c = '&';
1387   - }
  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 + // }
1388 1389  
1389   - $iframe.attr("src",url+c+"wmode=opaque");
1390   - // console.debug('iframe changed to opaque mode');
1391   - });
  1390 + // $iframe.attr("src",url+c+"wmode=opaque");
  1391 + // // console.debug('iframe changed to opaque mode');
  1392 + // });
1392 1393  
1393   - setTimeout(checkIframes, 500);
1394   - }
1395   - checkIframes();
  1394 + // setTimeout(checkIframes, 500);
  1395 + // }
  1396 + // checkIframes();
1396 1397  
1397 1398 });
1398 1399  
... ... @@ -1404,11 +1405,11 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1404 1405 });
1405 1406  
1406 1407 if('onhashchange' in window){
1407   - window.onhashchange = function(){
  1408 + window.onhashchange = function(){
1408 1409 Main.locationHashChanged.apply(Main);
1409   - }
  1410 + };
1410 1411 }else{
1411   - // console.log('The browser not supports the hashchange event!');
  1412 + console.warn('The browser not supports the hashchange event!');
1412 1413 }
1413 1414  
1414 1415 // Handle resize event
... ... @@ -1437,7 +1438,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;, &#39;piwik&#39;], fun
1437 1438  
1438 1439 timeout = setTimeout(delayed, threshold || 100);
1439 1440 };
1440   - }
  1441 + };
1441 1442  
1442 1443 // smartresize
1443 1444 jQuery.fn[sr] = function(fn){
... ...