Commit 66f5cb153cd454c219bfb3242b2a3aa7c98842d4

Authored by Evandro Jr
2 parents 19001814 2a4c4f2f

Merge branch 'master' of gitlab.com:participa/proposal-app

Conflicts:
	js/handlebars-helpers.js
	js/main.js
images/logo.png

6.36 KB | W: | H:

8.88 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
@@ -90,7 +90,6 @@ @@ -90,7 +90,6 @@
90 fjs.parentNode.insertBefore(js, fjs); 90 fjs.parentNode.insertBefore(js, fjs);
91 }(document, 'script', 'facebook-jssdk'));</script> 91 }(document, 'script', 'facebook-jssdk'));</script>
92 92
93 -  
94 <div class=""> 93 <div class="">
95 <div id="proposal-result"></div> 94 <div id="proposal-result"></div>
96 </div> 95 </div>
@@ -98,11 +97,20 @@ @@ -98,11 +97,20 @@
98 97
99 <script id="proposal-template" type="text/x-handlebars-template"> 98 <script id="proposal-template" type="text/x-handlebars-template">
100 <header class="container"> 99 <header class="container">
101 - <a id="display-contrast" href="#">Alto Contraste</a>  
102 - <div class="participar">  
103 - <!--<a href="#" class="button button-inline participe">Participe</a>-->  
104 - <a href="#" class="entrar">Entrar</a>  
105 - <a href="#" class="logout hide">Sair</a> 100 + <div class="row" style="margin: 10px 0 0 0">
  101 + <div class="col-xs-5">
  102 + <a id="display-contrast" href="#">Alto Contraste</a>
  103 + </div>
  104 + <div class="col-xs-7">
  105 + <div class="participar">
  106 + <!--<a href="#" class="button button-inline participe">Participe</a>-->
  107 + <a id="login-button" href="#" class="login"><i class="icon icon-login"></i>Entrar</a>
  108 + <a id="logout-button" href="#" class="logout hide"><i class="icon icon-login"></i><span class="name"></span>Sair</a>
  109 + </div>
  110 + </div>
  111 + <div class="col-xs-12">
  112 + <div id="login-panel" class="hide"></div>
  113 + </div>
106 </div> 114 </div>
107 <h1> 115 <h1>
108 <a href="#" class='logo'>{{article.title}}</a> 116 <a href="#" class='logo'>{{article.title}}</a>
@@ -304,34 +312,34 @@ @@ -304,34 +312,34 @@
304 312
305 <div class="talk-proposal-container col-sm-12"> 313 <div class="talk-proposal-container col-sm-12">
306 <section class="talk-proposal box box-propostas"> 314 <section class="talk-proposal box box-propostas">
307 - <div class="container-title box-title">Bate-papo com os ministros</div> 315 + <div class="container-title box-title">Bate-papo com ministras e ministros</div>
308 <p>Confira as datas e horários:</p> 316 <p>Confira as datas e horários:</p>
309 <ul class="calendar saude" data-slick='{"infinite": false, "rows": 2}'> 317 <ul class="calendar saude" data-slick='{"infinite": false, "rows": 2}'>
310 <li> 318 <li>
311 - <span id='ep0'>Arthur Chioro</span> 319 + <span id='ep0'></span>
312 <span>Saúde</span> 320 <span>Saúde</span>
313 - <div id='ed0' class="date"><i class="fa fa-calendar"></i> 17/06/2015</div><div class="time"><i class="fa fa-clock-o"></i> 19:00</div> 321 + <div id='ed0' class="date"><i class="fa fa-calendar"></i></div><div class="time"><i class="fa fa-clock-o"></i> 19:00</div>
314 </li> 322 </li>
315 </ul> 323 </ul>
316 <ul class="calendar seguranca-publica" data-slick='{"infinite": false, "rows": 2}'> 324 <ul class="calendar seguranca-publica" data-slick='{"infinite": false, "rows": 2}'>
317 <li> 325 <li>
318 - <span id='ep1'>José Eduardo Cardozo</span> 326 + <span id='ep1'></span>
319 <span id='ed1'>Justiça</span> 327 <span id='ed1'>Justiça</span>
320 - <div class="date"><i class="fa fa-calendar"></i> 25/04/2015</div><div class="time"><i class="fa fa-clock-o"></i> 19:00</div> 328 + <div class="date"><i class="fa fa-calendar"></i></div><div class="time"><i class="fa fa-clock-o"></i> 19:00</div>
321 </li> 329 </li>
322 </ul> 330 </ul>
323 <ul class="calendar educacao" data-slick='{"infinite": false, "rows": 2}'> 331 <ul class="calendar educacao" data-slick='{"infinite": false, "rows": 2}'>
324 <li> 332 <li>
325 - <span id='ep2'>Renato Janine Ribeiro</span> 333 + <span id='ep2'></span>
326 <span>Educação</span> 334 <span>Educação</span>
327 - <div id='ed2' class="date"><i class="fa fa-calendar"></i> 24/06/2015</div><div class="time"><i class="fa fa-clock-o"></i> 19:00</div> 335 + <div id='ed2' class="date"><i class="fa fa-calendar"></i></div><div class="time"><i class="fa fa-clock-o"></i> 19:00</div>
328 </li> 336 </li>
329 </ul> 337 </ul>
330 <ul class="calendar reducao-da-pobreza" data-slick='{"infinite": false, "rows": 2}'> 338 <ul class="calendar reducao-da-pobreza" data-slick='{"infinite": false, "rows": 2}'>
331 <li> 339 <li>
332 - <span id='ep3'>Tereza Campello</span> 340 + <span id='ep3'></span>
333 <span>Desenvolvimento Social</span> 341 <span>Desenvolvimento Social</span>
334 - <div id='ed3' class="date"><i class="fa fa-calendar"></i> 18/06/2015</div><div class="time"><i class="fa fa-clock-o"></i> 19:00</div> 342 + <div id='ed3' class="date"><i class="fa fa-calendar"></i></div><div class="time"><i class="fa fa-clock-o"></i> 19:00</div>
335 </li> 343 </li>
336 </ul> 344 </ul>
337 </section> 345 </section>
@@ -359,7 +367,7 @@ @@ -359,7 +367,7 @@
359 <a href="#" class="skip button box-footer">Pular</a> 367 <a href="#" class="skip button box-footer">Pular</a>
360 </div> 368 </div>
361 </div> 369 </div>
362 - <a href="#" class="vote-result box-bottom">Resultados</a> 370 + <a href="#/programas/{{parent.id}}/resultados" class="vote-result box-bottom">Resultados</a>
363 </div> 371 </div>
364 <div class="social"> 372 <div class="social">
365 <span>Compartilhe esta proposta</span> 373 <span>Compartilhe esta proposta</span>
@@ -367,13 +375,13 @@ @@ -367,13 +375,13 @@
367 </div> 375 </div>
368 </script> 376 </script>
369 377
370 - <script id="results" type="text/x-handlebars-template"> 378 + <script id="results-template" type="text/x-handlebars-template">
371 <div class="box box-propostas"> 379 <div class="box box-propostas">
372 <div class="loading">Carregando...</div> 380 <div class="loading">Carregando...</div>
373 <div class="results-content hide"> 381 <div class="results-content hide">
374 <a href="#" class="vote-result"><span class="sr-only">Fechar</span><span class="fa fa-times"></span></a> 382 <a href="#" class="vote-result"><span class="sr-only">Fechar</span><span class="fa fa-times"></span></a>
375 <h2>Resultados</h2> 383 <h2>Resultados</h2>
376 - <span class="total">Total de propostas: <strong class="value">{{pagination.total}}</strong></span> 384 + <span class="total">Total de propostas para o programa {{title}}: <strong class="value">{{pagination.total}}</strong></span>
377 <div class="updated-at"> 385 <div class="updated-at">
378 <span>Última atualização </span> 386 <span>Última atualização </span>
379 <span class="timeago" title="{{updated_at}}"></span> 387 <span class="timeago" title="{{updated_at}}"></span>
@@ -382,7 +390,7 @@ @@ -382,7 +390,7 @@
382 <table class="footable"> 390 <table class="footable">
383 <thead> 391 <thead>
384 <tr class="header"> 392 <tr class="header">
385 - <th class="position">Posição <a href="#/artigo/108047" class="hidden-xs"><span class="fa fa-question"></span></a></th> 393 + <th class="position">Posição <a href="#/artigo/108047" class="question-link"><span class="fa fa-question"></span></a></th>
386 <th class="abstract-text" data-toggle="true">Propostas</th> 394 <th class="abstract-text" data-toggle="true">Propostas</th>
387 <th class="views" data-hide="phone">Exibições</th> 395 <th class="views" data-hide="phone">Exibições</th>
388 <th class="votes-for" data-hide="phone"><span class="sr-only">A favor</span><span class="fa fa-check"></span></th> 396 <th class="votes-for" data-hide="phone"><span class="sr-only">A favor</span><span class="fa fa-check"></span></th>
@@ -407,7 +415,7 @@ @@ -407,7 +415,7 @@
407 </div> 415 </div>
408 </script> 416 </script>
409 417
410 - <script id="login" type="text/x-handlebars-template"> 418 + <script id="login-template" type="text/x-handlebars-template">
411 <div class="loading">Carregando...</div> 419 <div class="loading">Carregando...</div>
412 <form id="login-form" class="login"> 420 <form id="login-form" class="login">
413 <div class="message hide"></div> 421 <div class="message hide"></div>
@@ -485,7 +493,7 @@ @@ -485,7 +493,7 @@
485 </ul> 493 </ul>
486 </script> 494 </script>
487 495
488 - <script id="article" type="text/x-handlebars-template"> 496 + <script id="article-template" type="text/x-handlebars-template">
489 <div class="title"> 497 <div class="title">
490 {{{title}}} 498 {{{title}}}
491 </div> 499 </div>
@@ -506,11 +514,11 @@ @@ -506,11 +514,11 @@
506 <a href="#/artigo/107880">Termos de uso</a> 514 <a href="#/artigo/107880">Termos de uso</a>
507 </div> 515 </div>
508 516
509 - <script type='text/javascript' > 517 + <script type="text/javascript">
510 loadRequireJS(); 518 loadRequireJS();
511 </script> 519 </script>
512 520
513 - <script src='https://www.google.com/recaptcha/api.js?hl=pt-BR' async defer></script> 521 + <script src="https://www.google.com/recaptcha/api.js?hl=pt-BR" async defer></script>
514 522
515 </body> 523 </body>
516 524
js/handlebars-helpers.js
@@ -18,26 +18,34 @@ define([&#39;handlebars&#39;], function(Handlebars){ @@ -18,26 +18,34 @@ define([&#39;handlebars&#39;], function(Handlebars){
18 var ret = ""; 18 var ret = "";
19 for(var i=0, j=proposals.length; i<j; i++) { 19 for(var i=0, j=proposals.length; i<j; i++) {
20 var proposal = proposals[i]; 20 var proposal = proposals[i];
21 -  
22 - element = '<li class="proposal-item col-sm-6">' +  
23 - '<a href="#/programas/'+proposal.id+'" data-target="proposal-item-'+proposal.id+'" class="proposal-link box">' + 21 +
  22 + element = '<li class="proposal-item col-sm-6">' +
  23 + '<a href="#/programas/' + proposal.id + '" data-target="proposal-item-' + proposal.id + '" class="proposal-link box">' +
24 '<div class="box-header item">'; 24 '<div class="box-header item">';
25 category = "<div class='category box-category'>"; 25 category = "<div class='category box-category'>";
26 -  
27 -  
28 - for(var x=0, y=proposal.categories.length; x<y; x++) {  
29 - if((options.hash['category'] != null) && (options.hash['category'] != proposal.categories[x].slug)){ 26 +
  27 +
  28 + for (var x = 0, y = proposal.categories.length; x < y; x++) {
  29 + if ((options.hash['category'] != null) && (options.hash['category'] != proposal.categories[x].slug)) {
30 element = ''; 30 element = '';
31 continue; 31 continue;
32 - }  
33 - category = category + '<div class="category-'+proposal.categories[x].slug+'">' + proposal.categories[x].name + '</div>'; 32 + }
  33 + category = category + '<div class="category-' + proposal.categories[x].slug + '">' + proposal.categories[x].name + '</div>';
34 } 34 }
35 - if(element == ''){ 35 + if (element == '') {
36 continue; 36 continue;
37 } 37 }
  38 + if (proposal.image) {
  39 + category = category + '</div>' +
  40 + '<div class="box-body">' +
  41 + // '<div class="box__image">' + '<img src="' + options.hash['host'] + proposal.image.url + '" alt="Imagem de apresentação do programa."/>' + '</div>' +
  42 + '<div class="box__image" style="background-image:url(' + (options.hash['host'] + proposal.image.url) + ')"></div>' +
  43 + '<div class="box__title">' + proposal.title + '</div>' +
  44 + (proposal.abstract ? '<div class="box__abstract">' + proposal.abstract + '</div>' : '') +
  45 + '<div class="box__footer">' + '<span class="button participe">OPINE NESTE PROGRAMA</span>' + '</div>' +
  46 + '</div>';
  47 + }
38 48
39 - if(proposal.image)  
40 - category = category + '</div>' + '<div class="box-body">' + '<img src="' + options.hash['host'] + proposal.image.url + '" alt="Imagem de apresentação do programa."/>' + proposal.title + (proposal.abstract ? proposal.abstract : '') + '<span class="button participe">OPINE NESTE PROGRAMA</span></div>';  
41 // element = element + options.fn(proposal); 49 // element = element + options.fn(proposal);
42 50
43 element = element + category; 51 element = element + category;
js/jquery.equalHeights.js 0 → 100644
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
  1 +$.fn.equalHeights = function(px) {
  2 + 'use strict';
  3 +
  4 + var currentTallest = 0;
  5 + $(this).each(function(index, item){
  6 + var $item = $(item);
  7 + $item.height('auto'); // force a 'recalc' height
  8 +
  9 + if ($item.height() > currentTallest) { currentTallest = $item.height(); }
  10 + if (!px && Number.prototype.pxToEm) { currentTallest = currentTallest.pxToEm(); } //use ems unless px is specified
  11 + // for ie6, set height since min-height isn't supported
  12 + if (typeof(document.body.style.minHeight) === 'undefined') { $item.css({'height': currentTallest}); }
  13 + $item.css({'height': currentTallest});
  14 + });
  15 + return this;
  16 +};
  17 +
  18 +// just in case you need it...
  19 +// $.fn.equalWidths = function(px) {
  20 +// $(this).each(function(){
  21 +// var currentWidest = 0;
  22 +// $(this).children().each(function(i){
  23 +// if($(this).width() > currentWidest) { currentWidest = $(this).width(); }
  24 +// });
  25 +// if(!px && Number.prototype.pxToEm) currentWidest = currentWidest.pxToEm(); //use ems unless px is specified
  26 +// // for ie6, set width since min-width isn't supported
  27 +// if (typeof(document.body.style.minHeight) === "undefined") { $(this).children().css({'width': currentWidest}); }
  28 +// $(this).children().css({'min-width': currentWidest});
  29 +// });
  30 +// return this;
  31 +// };
0 \ No newline at end of file 32 \ No newline at end of file
@@ -7,9 +7,9 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -7,9 +7,9 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
7 // compile the template 7 // compile the template
8 var template = Handlebars.compile(templateSource); 8 var template = Handlebars.compile(templateSource);
9 var supportProposalTemplate = Handlebars.compile(document.getElementById('support-proposal-template').innerHTML); 9 var supportProposalTemplate = Handlebars.compile(document.getElementById('support-proposal-template').innerHTML);
10 - var loginTemplate = Handlebars.compile(document.getElementById('login').innerHTML);  
11 - var resultsTemplate = Handlebars.compile(document.getElementById('results').innerHTML);  
12 - var articleTemplate = Handlebars.compile(document.getElementById('article').innerHTML); 10 + var loginTemplate = Handlebars.compile(document.getElementById('login-template').innerHTML);
  11 + var resultsTemplate = Handlebars.compile(document.getElementById('results-template').innerHTML);
  12 + var articleTemplate = Handlebars.compile(document.getElementById('article-template').innerHTML);
13 13
14 // The div/container that we are going to display the results in 14 // The div/container that we are going to display the results in
15 var resultsPlaceholder = document.getElementById('proposal-result'); 15 var resultsPlaceholder = document.getElementById('proposal-result');
@@ -18,7 +18,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -18,7 +18,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
18 18
19 var loginButton; 19 var loginButton;
20 20
21 - var lastHash; 21 + var lastHash = window.location.hash;
22 22
23 var participa = true; 23 var participa = true;
24 24
@@ -130,7 +130,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -130,7 +130,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
130 130
131 if(ProposalApp.hasProposalbeenVoted(article.id)){ 131 if(ProposalApp.hasProposalbeenVoted(article.id)){
132 console.log("Proposta " + article.id + " já havia sido votada"); 132 console.log("Proposta " + article.id + " já havia sido votada");
133 - Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Voto realizado com sucesso', 800); 133 + Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800);
134 contextMain.loadRandomProposal(topic_id); 134 contextMain.loadRandomProposal(topic_id);
135 e.preventDefault(); 135 e.preventDefault();
136 return; 136 return;
@@ -143,8 +143,12 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -143,8 +143,12 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
143 value: $(this).data('vote-value'), 143 value: $(this).data('vote-value'),
144 private_token: Main.private_token 144 private_token: Main.private_token
145 } 145 }
146 - }).done(function( /*data*/ ) {  
147 - Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Voto realizado com sucesso', 800); 146 + }).done(function(data) {
  147 + if(data.vote) {
  148 + Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Voto realizado com sucesso', 800);
  149 + } else {
  150 + Main.displaySuccess(button.closest('.support-proposal .section-content'), 'Seu voto já foi computado nesta proposta', 800);
  151 + }
148 ProposalApp.addVotedProposal(article.id); 152 ProposalApp.addVotedProposal(article.id);
149 contextMain.loadRandomProposal(topic_id); 153 contextMain.loadRandomProposal(topic_id);
150 }); 154 });
@@ -153,6 +157,8 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -153,6 +157,8 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
153 157
154 $body.off('click', '.vote-result'); 158 $body.off('click', '.vote-result');
155 $body.on('click', '.vote-result', function(e) { 159 $body.on('click', '.vote-result', function(e) {
  160 + // e.preventDefault();
  161 +
156 var $this = $(this); 162 var $this = $(this);
157 var $proposalDetail = $this.parents('.proposal-detail'); 163 var $proposalDetail = $this.parents('.proposal-detail');
158 var $resultsContainer = $proposalDetail.find('.results-container'); 164 var $resultsContainer = $proposalDetail.find('.results-container');
@@ -160,463 +166,494 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -160,463 +166,494 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
160 if($resultsContainer.css('display') === 'none') { 166 if($resultsContainer.css('display') === 'none') {
161 Main.loadRanking($resultsContainer, topic_id, 1); 167 Main.loadRanking($resultsContainer, topic_id, 1);
162 } else { 168 } else {
163 - $('.experience-proposal-container').show();  
164 - $('.talk-proposal-container').show(); 169 + $proposalDetail.find('.experience-proposal-container').show();
  170 + $proposalDetail.find('.talk-proposal-container').show();
165 $resultsContainer.hide(); 171 $resultsContainer.hide();
166 } 172 }
167 - e.preventDefault();  
168 }); 173 });
  174 +
  175 + // $body.off('click', '.question-link');
  176 + // $body.on('click', '.question-link', function(e) {
  177 + // var $this = $(this);
  178 +
  179 + // // Main.navigateTo($this.attr('href'), backTo);
  180 + // });
169 }).fail(function(){ 181 }).fail(function(){
170 $loading.hide(); 182 $loading.hide();
171 $('.support-proposal .alert').show(); 183 $('.support-proposal .alert').show();
172 }); 184 });
173 - },  
174 -  
175 - loadRanking: function($resultsContainer, topic_id, page) {  
176 - $resultsContainer.find('.loading').show();  
177 - $resultsContainer.find('.results-content').hide();  
178 -  
179 - var per_page = 10;  
180 - var url = host + '/api/v1/proposals_discussion_plugin/' + topic_id + '/ranking' + '?private_token=' + Main.private_token + '&per_page='+per_page+'&page='+page;  
181 - $.getJSON(url).done(function( data, stats, xhr ) {  
182 - data.pagination = {  
183 - total: parseInt(xhr.getResponseHeader('Total')),  
184 - per_page: parseInt(xhr.getResponseHeader('Per-Page')),  
185 - page: page,  
186 - };  
187 -  
188 - $resultsContainer.html(resultsTemplate(data));  
189 - $resultsContainer.find('.loading').hide();  
190 - $resultsContainer.find('.results-content').show();  
191 - $(".timeago").timeago();  
192 - $resultsContainer.show();  
193 -  
194 - $('.footable').footable();  
195 -  
196 - if(data.pagination.total > data.pagination.per_page) {  
197 - $resultsContainer.find('.paging').pagination({  
198 - items: data.pagination.total,  
199 - itemsOnPage: data.pagination.per_page,  
200 - currentPage: data.pagination.page,  
201 - prevText: '«',  
202 - nextText: '»',  
203 - cssStyle: 'compact-theme',  
204 - onPageClick: function(page, e) {  
205 - Main.loadRanking($resultsContainer, topic_id, page);  
206 - e.preventDefault();  
207 - }  
208 - });  
209 - }  
210 - $resultsContainer.find('.abstract-text .truncated').click(function() {  
211 - $(this).toggleClass('truncated'); 185 + },
  186 + loadRanking: function($resultsContainer, topic_id, page) {
  187 + $resultsContainer.find('.loading').show();
  188 + $resultsContainer.find('.results-content').hide();
  189 +
  190 + var per_page = 10;
  191 + var url = host + '/api/v1/proposals_discussion_plugin/' + topic_id + '/ranking' + '?private_token=' + Main.private_token + '&per_page='+per_page+'&page='+page;
  192 + $.getJSON(url).done(function( data, stats, xhr ) {
  193 + data.pagination = {
  194 + total: parseInt(xhr.getResponseHeader('Total')),
  195 + per_page: parseInt(xhr.getResponseHeader('Per-Page')),
  196 + page: page,
  197 + };
  198 +
  199 + // hack: add title to result table
  200 + data.title = $resultsContainer.closest('.categories').find('.proposal-header .title').text();
  201 +
  202 + $resultsContainer.html(resultsTemplate(data));
  203 + $resultsContainer.find('.loading').hide();
  204 + $resultsContainer.find('.results-content').show();
  205 + $(".timeago").timeago();
  206 + $resultsContainer.show();
  207 +
  208 + $('.footable').footable();
  209 +
  210 + if(data.pagination.total > data.pagination.per_page) {
  211 + $resultsContainer.find('.paging').pagination({
  212 + items: data.pagination.total,
  213 + itemsOnPage: data.pagination.per_page,
  214 + currentPage: data.pagination.page,
  215 + prevText: '«',
  216 + nextText: '»',
  217 + cssStyle: 'compact-theme',
  218 + onPageClick: function(page, e) {
  219 + Main.loadRanking($resultsContainer, topic_id, page);
  220 + e.preventDefault();
  221 + }
212 }); 222 });
213 -  
214 - // scroll to the end  
215 - $('html, body').animate({  
216 - scrollTop: $(document).height()  
217 - }, 'fast'); 223 + }
  224 + $resultsContainer.find('.abstract-text .truncated').click(function() {
  225 + $(this).toggleClass('truncated');
218 }); 226 });
219 - $('.experience-proposal-container').hide();  
220 - $('.talk-proposal-container').hide();  
221 - },  
222 227
223 - loginCallback: function(loggedIn, token, user) {  
224 - logged_in = loggedIn;  
225 - $('.login .message').text('');  
226 - var requireLoginContainer = loginButton.closest('.require-login-container');  
227 -  
228 - if(logged_in) {  
229 - Main.showLogout();  
230 - if(token){  
231 - Main.private_token = token;  
232 - }  
233 - requireLoginContainer = $('.require-login-container');  
234 - requireLoginContainer.find('.require-login').show();  
235 - requireLoginContainer.find('.require-login .message').show();  
236 - requireLoginContainer.find('.login-container').hide();  
237 - $.cookie('_dialoga_session', Main.private_token);  
238 - } else if (user) {  
239 - var loginContainer = requireLoginContainer.find('.login-container');  
240 - loginContainer.show();  
241 - loginContainer.find('.new-user').click();  
242 - var signupForm = loginContainer.find('#signup-form');  
243 - signupForm.find("#user_email").val(user.email);  
244 - signupForm.find("#user_name").val(user.login);  
245 - signupForm.find("#user_oauth_providers").val(user.oauth_providers);  
246 - //signupForm.find(".password").hide();  
247 - //signupForm.find(".password-confirmation").hide();  
248 - } else {  
249 - requireLoginContainer.find('.require-login').hide();  
250 - requireLoginContainer.find('.login-container').show();  
251 - Main.showLogin(); 228 + var scrollTop = $(document).height();
  229 + var proposalOffset = $resultsContainer.offset();
  230 + if(proposalOffset){
  231 + scrollTop = proposalOffset.top;
252 } 232 }
253 - },  
254 - guid: function() {  
255 - function s4() {  
256 - return Math.floor((1 + Math.random()) * 0x10000)  
257 - .toString(16)  
258 - .substring(1); 233 +
  234 + // scroll to the end
  235 + $('html, body').animate({scrollTop: scrollTop }, 'fast');
  236 + });
  237 + $('.experience-proposal-container').hide();
  238 + $('.talk-proposal-container').hide();
  239 + },
  240 + loginCallback: function(loggedIn, token, user) {
  241 + logged_in = loggedIn;
  242 + $('.login .message').text('');
  243 + var requireLoginContainer = loginButton.closest('.require-login-container');
  244 +
  245 + if(logged_in) {
  246 + Main.showLogout();
  247 + if(token){
  248 + Main.private_token = token;
259 } 249 }
260 - return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();  
261 - },  
262 - display_article: function(article_id, backTo) {  
263 - var url = host + '/api/v1/articles/' + article_id + '?private_token=' + Main.private_token;  
264 - $.getJSON(url).done(function( data ) {  
265 - $('#article-container .article-content').html(articleTemplate(data.article));  
266 - $('#article-container').show();  
267 - $('#proposal-categories').hide();  
268 - $('#proposal-group').hide();  
269 - $('nav').hide();  
270 - $('#content').hide();  
271 - $('#article-container .go-back').attr('href', backTo);  
272 - });  
273 - },  
274 - // inicio Eduardo  
275 - randomProposalByTheme: function(themeClasses) {  
276 - $('#proposal-group .proposal-list .proposal-item').hide();  
277 - $.each(themeClasses, function(i, themeClass) {  
278 - var proposalsByTheme = $('#proposal-group .proposal-list .proposal-item').find('.' + themeClass);  
279 - var randomizedIndex = Math.floor(Math.random() * proposalsByTheme.length);  
280 - var proposalToShow = $(proposalsByTheme[randomizedIndex]).parents().filter('.proposal-item');  
281 - $(proposalToShow).show();  
282 - });  
283 - },  
284 - display_category_tab: function(){  
285 - // $('#proposal-group').hide();  
286 - this.randomProposalByTheme(['category-saude', 'category-seguranca-publica', 'category-educacao', 'category-reducao-da-pobreza']);  
287 - $('#proposal-group').show(); /* Show random proposals*/  
288 - $('.content').addClass('background'); /* Add class background */ 250 + // requireLoginContainer = $('.require-login-container');
  251 + requireLoginContainer.find('.require-login').show();
  252 + requireLoginContainer.find('.require-login .message').show();
  253 + requireLoginContainer.find('.login-container').hide();
  254 + $.cookie('_dialoga_session', Main.private_token);
  255 + } else if (user) {
  256 + var loginContainer = requireLoginContainer.find('.login-container');
  257 + loginContainer.show();
  258 + loginContainer.find('.new-user').click();
  259 + var signupForm = loginContainer.find('#signup-form');
  260 + signupForm.find('#user_email').val(user.email);
  261 + signupForm.find('#user_name').val(user.login);
  262 + signupForm.find('#user_oauth_providers').val(user.oauth_providers);
  263 + //signupForm.find(".password").hide();
  264 + //signupForm.find(".password-confirmation").hide();
  265 + } else {
  266 + requireLoginContainer.find('.require-login').hide();
  267 + requireLoginContainer.find('.login-container').show();
  268 + Main.showLogin();
  269 + }
  270 + },
  271 + guid: function() {
  272 + function s4() {
  273 + return Math.floor((1 + Math.random()) * 0x10000)
  274 + .toString(16)
  275 + .substring(1);
  276 + }
  277 + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
  278 + },
  279 + display_article: function(article_id, backTo) {
  280 + var url = host + '/api/v1/articles/' + article_id + '?private_token=' + Main.private_token;
  281 + $.getJSON(url).done(function( data ) {
  282 + $('#article-container .article-content').html(articleTemplate(data.article));
  283 + $('#article-container').show();
  284 + $('#proposal-categories').hide();
  285 + $('#proposal-group').hide();
  286 + $('nav').hide();
  287 + $('#content').hide();
  288 + $('#article-container .go-back').attr('href', backTo);
  289 + });
  290 + },
  291 + // inicio Eduardo
  292 + randomProposalByTheme: function(themeClasses) {
  293 + $('#proposal-group .proposal-list .proposal-item').hide();
  294 + $.each(themeClasses, function(i, themeClass) {
  295 + var proposalsByTheme = $('#proposal-group .proposal-list .proposal-item').find('.' + themeClass);
  296 + var randomizedIndex = Math.floor(Math.random() * proposalsByTheme.length);
  297 + var proposalToShow = $(proposalsByTheme[randomizedIndex]).parents().filter('.proposal-item');
  298 + $(proposalToShow).show();
  299 + });
  300 + },
  301 + display_category_tab: function(){
  302 + // $('#proposal-group').hide();
  303 + this.randomProposalByTheme(['category-saude', 'category-seguranca-publica', 'category-educacao', 'category-reducao-da-pobreza']);
  304 + $('#proposal-group').show(); /* Show random proposals*/
  305 + $('.content').addClass('background'); /* Add class background */
  306 + $('#proposal-categories').show();
  307 + $('#nav-proposal-categories a').addClass('active');
  308 + $('#nav-proposal-group a').removeClass('active');
  309 + $('.proposal-category-items').hide();
  310 + $('.proposal-category .arrow-box').hide();
  311 + $('.proposal-detail').hide();
  312 + $('#article-container').hide();
  313 +
  314 + $('#content').show();
  315 + $('nav').show();
  316 +
  317 + this.computeBoxHeight();
  318 + },
  319 + display_proposals_tab: function(){
  320 + // $('#proposal-categories').hide();
  321 + // this.randomProposalByTheme(['category-saude', 'category-seguranca-publica', 'category-educacao', 'category-reducao-da-pobreza']);
  322 + $('.proposal-item').show(); /* Show all programs */
  323 + $('#proposal-group').show();
  324 + $('#proposal-categories').show();
  325 + $('.proposal-category-items').hide();
  326 + $('#nav-proposal-group a').addClass('active');
  327 + $('#nav-proposal-categories a').removeClass('active');
  328 + $('#content').show();
  329 + $('#article-container').hide();
  330 + $('nav').show();
  331 + $('html, body').animate({ scrollTop: $('#proposal-group').offset().top }, 'fast');
  332 +
  333 + this.computeBoxHeight();
  334 + },
  335 + // fim Eduardo
  336 + display_proposal: function(proposal_id){
  337 + $('#proposal-categories').hide();
  338 + $('#proposal-group').hide();
  339 + $('.proposal-category-items').hide(); /* Hide Category Items */
  340 + $('.content').removeClass('background'); /* Remove class background*/
  341 + $('nav').hide();
  342 + $('#content').hide();
  343 + $('#article-container').hide();
  344 + // $('.make-proposal-form').hide();
  345 + // $('.login-container').hide();
  346 + $('.proposal-detail').hide(); // hide all proposals
  347 + // $('.proposal-detail-base').hide();
  348 + var $proposal = $('#' + proposal_id);
  349 + $proposal.find('.proposal-detail-base').hide();
  350 + $proposal.show();
  351 + $proposal.find('.proposal-header').show();
  352 + $proposal.find('.make-proposal-container').show();
  353 + $proposal.find('.support-proposal-container').show();
  354 + $proposal.find('.results-container').hide();
  355 + $proposal.find('.results-container .loading').hide();
  356 + $proposal.find('.results-container .results-content').hide();
  357 + $proposal.find('.experience-proposal-container').show();
  358 + $proposal.find('.talk-proposal-container').show();
  359 + $proposal.find('.calendar').hide();
  360 + var active_category = '';
  361 + switch($proposal.find('.categories').attr('class')) {
  362 + case 'categories saude':
  363 + active_category = 'saude';
  364 + break;
  365 + case 'categories educacao':
  366 + active_category = 'educacao';
  367 + break;
  368 + case 'categories seguranca-publica':
  369 + active_category = 'seguranca-publica';
  370 + break;
  371 + case 'categories reducao-da-pobreza':
  372 + active_category = 'reducao-da-pobreza';
  373 + break;
  374 + }
  375 +
  376 + $proposal.find('.calendar.' + active_category).show();
  377 + $proposal.find('.calendar').slick();
  378 +
  379 + var topic_id = proposal_id.split('-').pop();
  380 + this.loadRandomProposal(topic_id);
  381 + },
  382 + display_proposal_detail: function(proposal_id){
  383 + $('.content').removeClass('background'); /* Remove class background */
  384 + $('#proposal-categories').hide();
  385 + $('#proposal-group').hide();
  386 + $('nav').hide();
  387 + $('#content').hide();
  388 + $('#article-container').hide();
  389 + var $proposal = $('#proposal-item-' + proposal_id);
  390 + $proposal.find('.proposal-header').hide();
  391 + $proposal.find('.make-proposal-container').hide();
  392 + $proposal.find('.support-proposal-container').hide();
  393 + $proposal.find('.results-container').hide();
  394 + $proposal.find('.experience-proposal-container').hide();
  395 + $proposal.find('.talk-proposal-container').hide();
  396 + $proposal.find('.body').show();
  397 + $proposal.show();
  398 +
  399 + var url = host + '/api/v1/articles/' + proposal_id + '?private_token=' + Main.private_token + '&fields=id,body&content_type=ProposalsDiscussionPlugin::Topic';
  400 + $.getJSON(url).done(function( data ) {
  401 + $('#proposal-item-' + proposal_id + ' .body-content').replaceWith(data.article.body);
  402 + })
  403 + .fail(function( jqxhr, textStatus, error ) {
  404 + var err = textStatus + ', ' + error;
  405 + console.log( 'Request Failed: ' + err );
  406 + });
  407 + },
  408 + display_proposal_by_category: function(item){
  409 + var $item = $('#' + item);
  410 +
  411 + if($item.hasClass('proposal-category-items')){
  412 + //Display Topics or Discussion by category
  413 + $('nav').show();
  414 + $('#content').show();
289 $('#proposal-categories').show(); 415 $('#proposal-categories').show();
290 $('#nav-proposal-categories a').addClass('active'); 416 $('#nav-proposal-categories a').addClass('active');
291 $('#nav-proposal-group a').removeClass('active'); 417 $('#nav-proposal-group a').removeClass('active');
  418 + $('#proposal-group').hide(); /* Hide section "Programas" */
  419 + $('.content').addClass('background'); /* Add class background */
292 $('.proposal-category-items').hide(); 420 $('.proposal-category-items').hide();
293 - $('.proposal-category .arrow-box').hide();  
294 $('.proposal-detail').hide(); 421 $('.proposal-detail').hide();
295 - $('#article-container').hide();  
296 -  
297 - $('#content').show();  
298 - $('nav').show();  
299 - },  
300 - display_proposals_tab: function(){  
301 - // $('#proposal-categories').hide();  
302 - // this.randomProposalByTheme(['category-saude', 'category-seguranca-publica', 'category-educacao', 'category-reducao-da-pobreza']);  
303 - $('.proposal-item').show(); /* Show all programs */  
304 - $('#proposal-group').show();  
305 - $('#proposal-categories').show();  
306 - $('.proposal-category-items').hide();  
307 - $('#nav-proposal-group a').addClass('active');  
308 - $('#nav-proposal-categories a').removeClass('active');  
309 - $('#content').show();  
310 - $('#article-container').hide();  
311 - $('nav').show();  
312 - $('html, body').animate({ scrollTop: $('#proposal-group').offset().top }, 'fast');  
313 - },  
314 - // fim Eduardo  
315 - display_proposal: function(proposal_id){  
316 - $('#proposal-categories').hide();  
317 - $('#proposal-group').hide();  
318 - $('.proposal-category-items').hide(); /* Hide Category Items */  
319 - $('.content').removeClass('background'); /* Remove class background*/  
320 - $('nav').hide();  
321 - $('#content').hide();  
322 - $('#article-container').hide();  
323 - // $('.make-proposal-form').hide();  
324 - // $('.login-container').hide();  
325 - $('.proposal-detail').hide(); // hide all proposals  
326 - // $('.proposal-detail-base').hide();  
327 - $proposal = $('#' + proposal_id);  
328 - $proposal.find('.proposal-detail-base').hide();  
329 - $proposal.show();  
330 - $proposal.find('.proposal-header').show();  
331 - $proposal.find('.make-proposal-container').show();  
332 - $proposal.find('.support-proposal-container').show();  
333 - $proposal.find('.results-container').hide();  
334 - $proposal.find('.results-container .loading').hide();  
335 - $proposal.find('.results-container .results-content').hide();  
336 - $proposal.find('.experience-proposal-container').show();  
337 - $proposal.find('.talk-proposal-container').show();  
338 - $proposal.find('.calendar').hide();  
339 - var active_category = '';  
340 - switch($proposal.find('.categories').attr('class')) {  
341 - case 'categories saude':  
342 - active_category = 'saude';  
343 - break;  
344 - case 'categories educacao':  
345 - active_category = 'educacao';  
346 - break;  
347 - case 'categories seguranca-publica':  
348 - active_category = 'seguranca-publica';  
349 - break;  
350 - case 'categories reducao-da-pobreza':  
351 - active_category = 'reducao-da-pobreza';  
352 - break;  
353 - }  
354 -  
355 - $proposal.find('.calendar.' + active_category).show();  
356 - $proposal.find('.calendar').slick();  
357 -  
358 - var topic_id = proposal_id.split('-').pop();  
359 - this.loadRandomProposal(topic_id);  
360 - },  
361 - display_proposal_detail: function(proposal_id){  
362 - $('.content').removeClass('background'); /* Remove class background */  
363 - $('#proposal-categories').hide();  
364 - $('#proposal-group').hide();  
365 - $('nav').hide();  
366 - $('#content').hide();  
367 - $('#article-container').hide();  
368 - $proposal = $('#proposal-item-' + proposal_id);  
369 - $proposal.find('.proposal-header').hide();  
370 - $proposal.find('.make-proposal-container').hide();  
371 - $proposal.find('.support-proposal-container').hide();  
372 - $proposal.find('.results-container').hide();  
373 - $proposal.find('.experience-proposal-container').hide();  
374 - $proposal.find('.talk-proposal-container').hide();  
375 - $proposal.find('.body').show();  
376 - $proposal.show();  
377 -  
378 - var url = host + '/api/v1/articles/' + proposal_id + '?private_token=' + Main.private_token + '&fields=id,body&content_type=ProposalsDiscussionPlugin::Topic';  
379 - $.getJSON(url).done(function( data ) {  
380 - $('#proposal-item-' + proposal_id + ' .body-content').replaceWith(data.article.body);  
381 - })  
382 - .fail(function( jqxhr, textStatus, error ) {  
383 - var err = textStatus + ', ' + error;  
384 - console.log( 'Request Failed: ' + err );  
385 - });  
386 - },  
387 - display_proposal_by_category: function(item){  
388 - var $item = $('#' + item);  
389 -  
390 - if($item.hasClass('proposal-category-items')){  
391 - //Display Topics or Discussion by category  
392 - $('nav').show();  
393 - $('#content').show();  
394 - $('#proposal-categories').show();  
395 - $('#nav-proposal-categories a').addClass('active');  
396 - $('#nav-proposal-group a').removeClass('active');  
397 - $('#proposal-group').hide(); /* Hide section "Programas" */  
398 - $('.content').addClass('background'); /* Add class background */  
399 - $('.proposal-category-items').hide();  
400 - $('.proposal-detail').hide();  
401 - $item.toggle( 'blind', 200, function () {  
402 - var itemOffset = $item.offset();  
403 - if(itemOffset){  
404 - $('html, body').animate({ scrollTop: itemOffset.top }, 'fast');  
405 - }  
406 - } );  
407 - $('.proposal-category .arrow-box').hide();  
408 - var categorySlug = $item.data('category');  
409 - $('#proposal-category-' + categorySlug).find('.arrow-box').show(); 422 + $item.toggle( 'blind', 200, function () {
  423 + var itemOffset = $item.offset();
  424 + if(itemOffset){
  425 + $('html, body').animate({ scrollTop: itemOffset.top }, 'fast');
  426 + }
  427 + } );
  428 + $('.proposal-category .arrow-box').hide();
  429 + var categorySlug = $item.data('category');
  430 + $('#proposal-category-' + categorySlug).find('.arrow-box').show();
410 431
411 - }  
412 - },  
413 - addBarraDoGoverno: function(){  
414 -  
415 - if( BARRA_ADDED ) { return; }  
416 -  
417 - var HTML_BODY_PREPEND = '' +  
418 - '<div id="barra-brasil" style="background:#7F7F7F; height: 20px; padding:0 0 0 10px;display:block;"> ' +  
419 - '<ul id="menu-barra-temp" style="list-style:none;">' +  
420 - '<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> ' +  
421 - '<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>' +  
422 - '</ul>' +  
423 - '</div>';  
424 -  
425 - var HTML_BODY_APPEND = ''+  
426 - '<footer id="footer-brasil"></footer>' +  
427 - '<script defer="defer" src="http://barra.brasil.gov.br/barra.js" type="text/javascript"></script>';  
428 -  
429 - var STYLE_TEMA_AZUL = '' +  
430 - '<style>'+  
431 - '#footer-brasil {'+  
432 - 'background: none repeat scroll 0% 0% #0042b1;'+  
433 - 'padding: 1em 0px;'+  
434 - 'max-width: 100%;'+  
435 - 'margin-top: 40px;'+  
436 - '}'+  
437 - '#barra-brasil ul {'+  
438 - 'width: auto;'+  
439 - '}'+  
440 - '<style>'; 432 + this.computeBoxHeight();
441 433
442 - var $body = $(document.body);  
443 - $body.prepend(HTML_BODY_PREPEND);  
444 - $body.append(HTML_BODY_APPEND);  
445 - $body.append(STYLE_TEMA_AZUL); 434 + }
  435 + },
  436 + addBarraDoGoverno: function(){
  437 +
  438 + if( BARRA_ADDED ) { return; }
  439 +
  440 + var HTML_BODY_PREPEND = '' +
  441 + '<div id="barra-brasil" style="background:#7F7F7F; height: 20px; padding:0 0 0 10px;display:block;"> ' +
  442 + '<ul id="menu-barra-temp" style="list-style:none;">' +
  443 + '<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> ' +
  444 + '<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>' +
  445 + '</ul>' +
  446 + '</div>';
  447 +
  448 + var HTML_BODY_APPEND = ''+
  449 + '<footer id="footer-brasil"></footer>' +
  450 + '<script defer="defer" src="http://barra.brasil.gov.br/barra.js" type="text/javascript"></script>';
  451 +
  452 + var STYLE_TEMA_AZUL = '' +
  453 + '<style>'+
  454 + '#footer-brasil {'+
  455 + 'background: none repeat scroll 0% 0% #0042b1;'+
  456 + 'padding: 1em 0px;'+
  457 + 'max-width: 100%;'+
  458 + 'margin-top: 40px;'+
  459 + '}'+
  460 + '#barra-brasil ul {'+
  461 + 'width: auto;'+
  462 + '}'+
  463 + '<style>';
  464 +
  465 + var $body = $(document.body);
  466 + $body.prepend(HTML_BODY_PREPEND);
  467 + $body.append(HTML_BODY_APPEND);
  468 + $body.append(STYLE_TEMA_AZUL);
  469 +
  470 + BARRA_ADDED = true;
  471 + },
  472 + updateHash: function(hash){
  473 + var id = hash.replace(/^.*#/, '');
  474 + var elem = document.getElementById(id);
446 475
447 - BARRA_ADDED = true;  
448 - },  
449 - updateHash: function(hash){  
450 - var id = hash.replace(/^.*#/, '');  
451 - var elem = document.getElementById(id);  
452 -  
453 - // preserve the query param  
454 - // if (HIDE_BARRA_DO_GOVERNO && (hash.indexOf('?barra=false') === -1)){  
455 - // hash += '?barra=false';  
456 - // }  
457 -  
458 - if ( !elem ) {  
459 - window.location.hash = hash;  
460 - return;  
461 - } 476 + // preserve the query param
  477 + // if (HIDE_BARRA_DO_GOVERNO && (hash.indexOf('?barra=false') === -1)){
  478 + // hash += '?barra=false';
  479 + // }
462 480
463 - elem.id = id+'-tmp'; 481 + if ( !elem ) {
464 window.location.hash = hash; 482 window.location.hash = hash;
465 - elem.id = id;  
466 - },  
467 - locationHashChanged: function(){  
468 - var hash = window.location.hash;  
469 - this.navigateTo(hash, lastHash);  
470 - lastHash = hash;  
471 - },  
472 - navigateTo: function(hash, lastHash) {  
473 - var scrollTop = 0;  
474 - var $nav = $('nav[role="tabpanel"]');  
475 - var navOffset = $nav.offset();  
476 -  
477 - var regexProposals = /#\/programas/;  
478 - var regexCategory = /#\/temas/;  
479 - var regexHideBarra = /barra=false$/;  
480 - var regexArticle = /#\/artigo/;  
481 -  
482 - if( !(regexHideBarra.exec(hash) !== null) && !HIDE_BARRA_DO_GOVERNO ){  
483 - this.addBarraDoGoverno();  
484 - }else{  
485 - HIDE_BARRA_DO_GOVERNO = true;  
486 - } 483 + return;
  484 + }
487 485
488 - // remove query params  
489 - hash = hash.split('?')[0]; 486 + elem.id = id+'-tmp';
  487 + window.location.hash = hash;
  488 + elem.id = id;
  489 + },
  490 + locationHashChanged: function(){
  491 + var hash = window.location.hash;
  492 + this.navigateTo(hash, lastHash);
  493 + lastHash = hash;
  494 + },
  495 + navigateTo: function(hash, lastHash) {
  496 + var scrollTop = 0;
  497 + var $nav = $('nav[role="tabpanel"]');
  498 + var navOffset = $nav.offset();
  499 +
  500 + var regexProposals = /#\/programas/;
  501 + var regexCategory = /#\/temas/;
  502 + var regexHideBarra = /barra=false$/;
  503 + var regexArticle = /#\/artigo/;
  504 + var regexResultados = /resultados$/;
  505 +
  506 + if( !(regexHideBarra.exec(hash) !== null) && !HIDE_BARRA_DO_GOVERNO ){
  507 + this.addBarraDoGoverno();
  508 + }else{
  509 + HIDE_BARRA_DO_GOVERNO = true;
  510 + }
490 511
491 - var parts = hash.split('/'); 512 + // remove query params
  513 + hash = hash.split('?')[0];
492 514
493 - var isProposal = regexProposals.exec(hash) !== null;  
494 - var isCategory = regexCategory.exec(hash) !== null;  
495 - var isArticle = regexArticle.exec(hash) !== null; 515 + var parts = hash.split('/');
496 516
497 - if(isArticle) {  
498 - this.display_article(hash.split('/')[2], lastHash);  
499 - } 517 + var isProposal = regexProposals.exec(hash) !== null;
  518 + var isCategory = regexCategory.exec(hash) !== null;
  519 + var isArticle = regexArticle.exec(hash) !== null;
  520 + var isResultados = regexResultados.exec(hash) !== null;
500 521
501 - if( isProposal ){ 522 + if(isArticle) {
  523 + this.display_article(hash.split('/')[2], lastHash);
  524 + }
502 525
503 - // go to proposal  
504 - var proposalId = parts[2];  
505 - this.navigateToProposal(proposalId); 526 + if( isProposal ){
506 527
507 - var $proposal = $('#proposal-item-' + proposalId);  
508 - var proposalOffset = $proposal.offset();  
509 - if(proposalOffset){  
510 - scrollTop = proposalOffset.top;  
511 - }else{  
512 - if(navOffset){  
513 - scrollTop = navOffset.top;  
514 - } else {  
515 - scrollTop = $('#proposal-group').offset().top;  
516 - } 528 + // go to proposal
  529 + var proposalId = parts[2];
  530 + this.navigateToProposal(proposalId);
  531 +
  532 + var $proposal = $('#proposal-item-' + proposalId);
  533 + var proposalOffset = $proposal.offset();
  534 + if(proposalOffset){
  535 + scrollTop = proposalOffset.top;
  536 + }else{
  537 + if(navOffset){
  538 + scrollTop = navOffset.top;
  539 + } else {
  540 + scrollTop = $('#proposal-group').offset().top;
517 } 541 }
518 } 542 }
519 543
520 - if( isCategory ){ 544 + if(isResultados){
  545 + var $resultsContainer = $proposal.find('.results-container');
521 546
522 - // go to category  
523 - var categoryId = parts[3];  
524 - this.navigateToCategory(categoryId); 547 + if($resultsContainer.css('display') === 'none') {
  548 + Main.loadRanking($resultsContainer, proposalId, 1);
  549 + } else {
  550 + $proposalDetail.find('.experience-proposal-container').show();
  551 + $proposalDetail.find('.talk-proposal-container').show();
  552 + $resultsContainer.hide();
  553 + }
525 554
526 - var $category = $('#proposal-item-' + categoryId);  
527 - var categoryOffset = $category.offset();  
528 - if(categoryOffset){  
529 - scrollTop = categoryOffset.top;  
530 - }else{  
531 - if(navOffset){  
532 - scrollTop = navOffset.top;  
533 - } 555 + var proposalOffset = $resultsContainer.offset();
  556 + if(proposalOffset){
  557 + scrollTop = proposalOffset.top;
534 } 558 }
535 } 559 }
  560 + }
536 561
537 - // default  
538 - if( !isProposal && !isCategory ){  
539 - // show the 'index' -> category tab  
540 - this.display_category_tab();  
541 - 562 + if( isCategory ){
542 563
543 - // if(navOffset){  
544 - // scrollTop = navOffset.top;  
545 - // }  
546 - } 564 + // go to category
  565 + var categoryId = parts[3];
  566 + this.navigateToCategory(categoryId);
547 567
548 - $('html, body').animate({ scrollTop: scrollTop }, 'fast');  
549 - },  
550 - navigateToProposal: function(proposalId){  
551 - var regexSubpages = /sobre-o-programa$/;  
552 - if(proposalId === undefined){  
553 - this.display_proposals_tab();  
554 - }else if(regexSubpages.exec(window.location.hash) == null){  
555 - this.display_proposal('proposal-item-' + proposalId);  
556 - }else{  
557 - this.display_proposal_detail(proposalId);  
558 - }  
559 - },  
560 - navigateToCategory: function(categoryId){  
561 - if(categoryId === undefined){  
562 - this.display_category_tab(); 568 + var $category = $('#proposal-item-' + categoryId);
  569 + var categoryOffset = $category.offset();
  570 + if(categoryOffset){
  571 + scrollTop = categoryOffset.top;
563 }else{ 572 }else{
564 - this.display_proposal_by_category('proposal-item-' + categoryId); 573 + if(navOffset){
  574 + scrollTop = navOffset.top;
  575 + }
565 } 576 }
566 - },  
567 - oauthClientAction: function(url) {  
568 - var child = window.open(url, "_blank");  
569 - var interval = setInterval(function() {  
570 - try {  
571 - if(!child.closed) {  
572 - child.postMessage({ message: "requestOauthClientPluginResult" }, "*");  
573 - }  
574 - }  
575 - catch(e) {  
576 - // we're here when the child window has been navigated away or closed  
577 - if (child.closed) {  
578 - clearInterval(interval);  
579 - return;  
580 - } 577 + }
  578 +
  579 + // default
  580 + if( !isProposal && !isCategory ){
  581 + // show the 'index' -> category tab
  582 + this.display_category_tab();
  583 + }
  584 +
  585 + $('html, body').animate({ scrollTop: scrollTop }, 'fast');
  586 + },
  587 + navigateToProposal: function(proposalId){
  588 + var regexSobreOPrograma = /sobre-o-programa$/;
  589 + if(proposalId === undefined){
  590 + this.display_proposals_tab();
  591 + }else if(regexSobreOPrograma.exec(window.location.hash) == null){
  592 + this.display_proposal('proposal-item-' + proposalId);
  593 + }else{
  594 + this.display_proposal_detail(proposalId);
  595 + }
  596 + },
  597 + navigateToCategory: function(categoryId){
  598 + if(categoryId === undefined){
  599 + this.display_category_tab();
  600 + }else{
  601 + this.display_proposal_by_category('proposal-item-' + categoryId);
  602 + }
  603 + },
  604 + oauthClientAction: function(url) {
  605 + var child = window.open(url, "_blank");
  606 + var interval = setInterval(function() {
  607 + try {
  608 + if(!child.closed) {
  609 + child.postMessage({ message: "requestOauthClientPluginResult" }, "*");
581 } 610 }
582 - }, 300);  
583 - },  
584 - displaySuccess: function(container, text, timeout, iconClass) {  
585 - timeout = typeof timeout !== 'undefined' ? timeout : 2000;  
586 - container.css('opacity', 0.1);  
587 - var successPanel = $('.success-panel').clone();  
588 - successPanel.find('.icon').addClass(iconClass);  
589 - successPanel.find('.message').html(text);  
590 - successPanel.appendTo(container.closest('.categories'));  
591 - successPanel.show();  
592 - successPanel.css("top", Math.max(0, ((container.height() - successPanel.outerHeight()) / 2) + container.offset().top) + "px");  
593 - successPanel.css("left", Math.max(0, ((container.width() - successPanel.outerWidth()) / 2) + container.offset().left) + "px");  
594 -  
595 - var interval = setTimeout(function() {  
596 - successPanel.hide();  
597 - container.css('opacity', 1);  
598 - successPanel.remove();  
599 - }, timeout);  
600 - },  
601 - setUser: function(user){  
602 - this.user = user;  
603 - },  
604 - getUser: function(){  
605 - return this.user;  
606 - },  
607 - showLogin: function(){  
608 - $('.entrar').show();  
609 - $('.logout').hide();  
610 - },  
611 - showLogout: function(){  
612 - $('.entrar').hide();  
613 - var name = '';  
614 - if(this.user){  
615 - name = this.user.person.name + ' | ';  
616 - }  
617 - $('.logout').text(name + 'Sair');  
618 - $('.logout').show();  
619 - }, 611 + }
  612 + catch(e) {
  613 + // we're here when the child window has been navigated away or closed
  614 + if (child.closed) {
  615 + clearInterval(interval);
  616 + return;
  617 + }
  618 + }
  619 + }, 300);
  620 + },
  621 + displaySuccess: function(container, text, timeout, iconClass) {
  622 + timeout = typeof timeout !== 'undefined' ? timeout : 2000;
  623 + container.css('opacity', 0.1);
  624 + var successPanel = $('.success-panel').clone();
  625 + successPanel.find('.icon').addClass(iconClass);
  626 + successPanel.find('.message').html(text);
  627 + successPanel.appendTo(container.closest('.categories'));
  628 + successPanel.show();
  629 + successPanel.css("top", Math.max(0, ((container.height() - successPanel.outerHeight()) / 2) + container.offset().top) + "px");
  630 + successPanel.css("left", Math.max(0, ((container.width() - successPanel.outerWidth()) / 2) + container.offset().left) + "px");
  631 +
  632 + var interval = setTimeout(function() {
  633 + successPanel.hide();
  634 + container.css('opacity', 1);
  635 + successPanel.remove();
  636 + }, timeout);
  637 + },
  638 + setUser: function(user){
  639 + this.user = user;
  640 + },
  641 + getUser: function(){
  642 + return this.user;
  643 + },
  644 + showLogin: function(){
  645 + $('#login-button').show();
  646 + $('#logout-button').hide();
  647 + },
  648 + showLogout: function(){
  649 + $('#login-button').hide();
  650 + var name = '';
  651 + if(this.user){
  652 + name = this.user.person.name + ' - ';
  653 + }
  654 + $('#logout-button .name').text(name);
  655 + $('#logout-button').show();
  656 + },
620 responseToText: function(responseJSONmessage){ 657 responseToText: function(responseJSONmessage){
621 var o = JSON.parse(responseJSONmessage); 658 var o = JSON.parse(responseJSONmessage);
622 var msg = ""; 659 var msg = "";
@@ -641,20 +678,83 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -641,20 +678,83 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
641 // /api/v1/communities/64/articles?from=2013-04-04-14:41:43&until=2015-06-11-14:41:43&limit=10&categories_ids[]=7&categories_ids[]=8&private_token=a97b6a5cae2c4c54e4ae18dde1829a49 678 // /api/v1/communities/64/articles?from=2013-04-04-14:41:43&until=2015-06-11-14:41:43&limit=10&categories_ids[]=7&categories_ids[]=8&private_token=a97b6a5cae2c4c54e4ae18dde1829a49
642 var url; 679 var url;
643 count = 0; 680 count = 0;
644 - for(var i = 0; i < window.themes_cat.length; ++i){  
645 - url = host + '/api/v1/communities/' + window.dialoga_community + '/articles?categories_ids[]=' + window.themes_cat[i] + '&content_type=Event&private_token=' + Main.private_token; 681 + for (var i = 0; i < window.themes_cat.length; ++i) {
  682 + url = host + '/api/v1/communities/' + window.dialoga_community + '/articles?categories_ids[]=' + window.themes_cat[i] + '&content_type=Event&private_token=' + Main.private_token;
646 console.log(url); 683 console.log(url);
647 - $.getJSON(url).done(function( data ) { 684 + $.getJSON(url).done(function (data) {
648 console.log(data); 685 console.log(data);
649 $('#ep' + count).text(data.articles[0].author.name); 686 $('#ep' + count).text(data.articles[0].author.name);
650 var dt = data.articles[0].start_date; 687 var dt = data.articles[0].start_date;
651 - dia = dt.substr(8,2);  
652 - mes = dt.substr(5,2);  
653 - ano = dt.substr(0,4); 688 + dia = dt.substr(8, 2);
  689 + mes = dt.substr(5, 2);
  690 + ano = dt.substr(0, 4);
654 $('#ed' + count).text(dia + '/' + mes + '/' + ano); 691 $('#ed' + count).text(dia + '/' + mes + '/' + ano);
655 count++; 692 count++;
656 }); 693 });
657 } 694 }
  695 + },
  696 + computeBoxHeight: function(){
  697 + var hPerLineOnTitle = 25;
  698 + var hPerLineOnParagraph = 20;
  699 + var maxLinesByParagraph = 0;
  700 + var maxLinesByTitle = 0;
  701 + var $visibleProposals = $('.proposal-list .proposal-item:visible');
  702 +
  703 + // get the bigger paragraph
  704 + $visibleProposals.each(function(index, proposalItemEl){
  705 + var $proposalItemEl = $(proposalItemEl);
  706 + var $paragraph = $proposalItemEl.find('p');
  707 + var lines = Main.computeLines($paragraph);
  708 + if(lines > maxLinesByParagraph ){
  709 + maxLinesByParagraph = lines
  710 + }
  711 + });
  712 + // console.log('maxLinesByParagraph', maxLinesByParagraph);
  713 +
  714 + // get the bigger title
  715 + $visibleProposals.each(function(index, proposalItemEl){
  716 + var $proposalItemEl = $(proposalItemEl);
  717 + var $title = $proposalItemEl.find('.box__title');
  718 + var lines = Main.computeLines($title);
  719 + if(lines > maxLinesByTitle ){
  720 + maxLinesByTitle = lines
  721 + }
  722 + });
  723 + // console.log('maxLinesByTitle', maxLinesByTitle);
  724 +
  725 + $visibleProposals.each(function(index, proposalItemEl){
  726 + var $proposalItemEl = $(proposalItemEl);
  727 + var $title = $proposalItemEl.find('.box__title');
  728 + var $paragraph = $proposalItemEl.find('p');
  729 +
  730 + var newTitleHeight = maxLinesByTitle * hPerLineOnTitle;
  731 + var newParagraphHeight = maxLinesByParagraph * hPerLineOnParagraph;
  732 +
  733 + $title.css('height', newTitleHeight + 'px');
  734 + $paragraph.css('height', newParagraphHeight + 'px');
  735 + });
  736 +
  737 + // recalc box heights
  738 + var setAsPx = true;
  739 + $visibleProposals.equalHeights(setAsPx);
  740 + },
  741 + computeLines: function ($el) {
  742 + // reset height
  743 + $el.height('auto');
  744 +
  745 + var divHeight = $el.height();
  746 + var lineHeight = parseInt($el.css('lineHeight'));
  747 + var lines = Math.ceil(divHeight / lineHeight);
  748 + return lines;
  749 + },
  750 + handleLoginSuccess: function (e, data){
  751 + if(data.person){
  752 + Main.setUser({person: data.person});
  753 + }
  754 + Main.loginCallback(true, data.private_token);
  755 + },
  756 + handleLoginFail: function (e){
  757 + // console.log('Event', e);
658 } 758 }
659 } 759 }
660 })(); 760 })();
@@ -721,8 +821,8 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -721,8 +821,8 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
721 e.preventDefault(); 821 e.preventDefault();
722 822
723 var oldHash = window.location.hash; 823 var oldHash = window.location.hash;
724 - var regexSubpages = /sobre-o-programa$/;  
725 - var isSubpage = regexSubpages.exec(oldHash) !== null; 824 + var regexSobreOPrograma = /sobre-o-programa$/;
  825 + var isSubpage = regexSobreOPrograma.exec(oldHash) !== null;
726 var newHash = '#/temas'; // default page 826 var newHash = '#/temas'; // default page
727 827
728 if(isSubpage){ 828 if(isSubpage){
@@ -742,10 +842,10 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -742,10 +842,10 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
742 842
743 //display form to send proposal (or login form for non-logged users) 843 //display form to send proposal (or login form for non-logged users)
744 var $this = $(this); 844 var $this = $(this);
745 - loginButton = $this.parents('.button-send'); 845 + loginButton = $this.closest('.button-send');
746 loginButton.hide(); 846 loginButton.hide();
747 - $this.parents('.success-proposal-sent').hide();  
748 - $wrapper = $this.parents('.make-proposal'); 847 + $this.closest('.success-proposal-sent').hide();
  848 + var $wrapper = $this.closest('.make-proposal');
749 $wrapper.find('.subtitle').show(); 849 $wrapper.find('.subtitle').show();
750 $wrapper.find('.info').show(); 850 $wrapper.find('.info').show();
751 Main.loginCallback(logged_in); 851 Main.loginCallback(logged_in);
@@ -859,30 +959,50 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -859,30 +959,50 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
859 }); 959 });
860 } 960 }
861 961
  962 + $(document).on('login:success', Main.handleLoginSuccess);
  963 + $(document).on('login:fail', Main.handleLoginFail);
  964 +
862 $(document).on('click', '.login-action', function(e) { 965 $(document).on('click', '.login-action', function(e) {
863 - var message = $('.login .message');  
864 - message.hide();  
865 - message.text('');  
866 - var button = $(this); 966 + e.preventDefault();
  967 + // console.log('obj', obj);
  968 +
  969 + var $this = $(this); // button
  970 + var $form = $this.closest('#login-form');
  971 + var $message = $form.find('.message');
  972 + $message.text('').hide();
  973 +
  974 + loginButton = $this;
  975 +
867 $.ajax({ 976 $.ajax({
868 type: 'post', 977 type: 'post',
869 url: host + '/api/v1/login', 978 url: host + '/api/v1/login',
870 - data: $(this).parents('.login').serialize(), 979 + data: $form.serialize(),
871 xhrFields: { 980 xhrFields: {
872 //withCredentials: true 981 //withCredentials: true
873 } 982 }
874 }).done(function(data) { 983 }).done(function(data) {
875 - Main.loginCallback(true, data.private_token);  
876 - Main.displaySuccess(button.closest('.section-content'), 'Login efetuado com sucesso', 1000, 'icon-login-success'); 984 + $(document).trigger('login:success', data);
  985 +
  986 + var $sectionContent = $form.closest('.section-content');
  987 + if($sectionContent && $sectionContent.length > 0){
  988 + Main.displaySuccess($sectionContent, 'Login efetuado com sucesso', 1000, 'icon-login-success');
  989 + }
  990 +
  991 + var $loginPanel = $form.closest('#login-panel');
  992 + if($loginPanel && $loginPanel.length > 0){
  993 + $loginPanel.hide();
  994 + }
  995 +
877 }).fail(function(data) { 996 }).fail(function(data) {
878 - message.show(); 997 + $(document).trigger('login:fail', data);
  998 +
  999 + $message.show();
879 if(data.status==401){ 1000 if(data.status==401){
880 - message.text('Nome de usuário, e-mail ou senha incorretos, não foi possível acessar.'); 1001 + $message.text('Nome de usuário, e-mail ou senha incorretos, não foi possível acessar.');
881 }else{ 1002 }else{
882 - message.text('Um erro inesperado ocorreu'); 1003 + $message.text('Um erro inesperado ocorreu');
883 } 1004 }
884 }); 1005 });
885 - e.preventDefault();  
886 }); 1006 });
887 1007
888 $(document).on('click', '.social .fb-share', function(e) { 1008 $(document).on('click', '.social .fb-share', function(e) {
@@ -973,7 +1093,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -973,7 +1093,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
973 e.preventDefault(); 1093 e.preventDefault();
974 }); 1094 });
975 1095
976 - $(document).on('click', '.logout', function (e){ 1096 + $(document).on('click', '#logout-button', function (e){
977 var self = $(this); 1097 var self = $(this);
978 $.removeCookie('_dialoga_session'); 1098 $.removeCookie('_dialoga_session');
979 $.removeCookie('votedProposals'); 1099 $.removeCookie('votedProposals');
@@ -984,6 +1104,29 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -984,6 +1104,29 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
984 e.preventDefault(); 1104 e.preventDefault();
985 }); 1105 });
986 1106
  1107 + // create login panel on header
  1108 + (function (){
  1109 + var $loginPanel = $('#login-panel');
  1110 + $loginPanel.hide();
  1111 + $loginPanel.removeClass('hide');
  1112 + $loginPanel.append(loginTemplate());
  1113 + $loginPanel.find('.actions')
  1114 + .removeClass('col-sm-4')
  1115 + .addClass('col-sm-12');
  1116 + $loginPanel.find('.oauth')
  1117 + .removeClass('col-sm-8')
  1118 + .addClass('col-sm-12');
  1119 + $loginPanel.find('.new-user').parent()
  1120 + .removeClass('col-sm-4')
  1121 + .addClass('col-sm-12');
  1122 +
  1123 + $(document).on('click', '#login-button', function (e){
  1124 + e.preventDefault();
  1125 +
  1126 + $loginPanel.toggle();
  1127 + });
  1128 + })();
  1129 +
987 }); 1130 });
988 1131
989 window.addEventListener("message", function(ev) { 1132 window.addEventListener("message", function(ev) {
@@ -1001,5 +1144,45 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -1001,5 +1144,45 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
1001 console.log('The browser not supports the hashchange event!'); 1144 console.log('The browser not supports the hashchange event!');
1002 } 1145 }
1003 1146
  1147 + // Handle resize event
  1148 + (function($,sr){
  1149 +
  1150 + // debouncing function from John Hann
  1151 + // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
  1152 + var debounce = function (func, threshold, execAsap) {
  1153 + var timeout;
  1154 +
  1155 + return function debounced () {
  1156 + var obj = this, args = arguments;
  1157 +
  1158 + function delayed () {
  1159 + if (!execAsap){
  1160 + func.apply(obj, args);
  1161 + }
  1162 + timeout = null;
  1163 + }
  1164 +
  1165 + if (timeout){
  1166 + clearTimeout(timeout);
  1167 + }else if (execAsap){
  1168 + func.apply(obj, args);
  1169 + }
  1170 +
  1171 + timeout = setTimeout(delayed, threshold || 100);
  1172 + };
  1173 + }
  1174 +
  1175 + // smartresize
  1176 + jQuery.fn[sr] = function(fn){
  1177 + return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr);
  1178 + };
  1179 +
  1180 + })(jQuery, 'smartresize');
  1181 +
  1182 + $(window).smartresize(function(){
  1183 + // console.log('window resized');
  1184 + Main.computeBoxHeight();
  1185 + });
  1186 +
1004 return Main; 1187 return Main;
1005 }); 1188 });
js/requirejs-config.js
@@ -15,6 +15,7 @@ requirejs.config({ @@ -15,6 +15,7 @@ requirejs.config({
15 jquery_timeago: 'jquery.timeago', 15 jquery_timeago: 'jquery.timeago',
16 jquery_timeago_pt: 'jquery.timeago.pt-br', 16 jquery_timeago_pt: 'jquery.timeago.pt-br',
17 jquery_simplePagination: 'jquery.simplePagination', 17 jquery_simplePagination: 'jquery.simplePagination',
  18 + jquery_equalHeights: 'jquery.equalHeights',
18 jquery_footable: 'footable', 19 jquery_footable: 'footable',
19 handlebars: 'handlebars-v3.0.1', 20 handlebars: 'handlebars-v3.0.1',
20 handlebars_helpers: 'handlebars-helpers', 21 handlebars_helpers: 'handlebars-helpers',
@@ -42,6 +43,9 @@ requirejs.config({ @@ -42,6 +43,9 @@ requirejs.config({
42 'jquery_simplePagination': { 43 'jquery_simplePagination': {
43 deps: ['jquery'] 44 deps: ['jquery']
44 }, 45 },
  46 + 'jquery_equalHeights': {
  47 + deps: ['jquery']
  48 + },
45 'footable': { 49 'footable': {
46 deps: ['jquery'] 50 deps: ['jquery']
47 }, 51 },
@@ -70,5 +74,5 @@ requirejs.config({ @@ -70,5 +74,5 @@ requirejs.config({
70 } 74 }
71 }); 75 });
72 76
73 -requirejs(['jquery', 'proposal_app', 'jquery_ui', 'jquery_xdomainrequest', 'jquery_timeago_pt', 'jquery_simplePagination', 'footable', 'handlebars_helpers']); 77 +requirejs(['jquery', 'proposal_app', 'jquery_ui', 'jquery_xdomainrequest', 'jquery_timeago_pt', 'jquery_simplePagination', 'jquery_equalHeights', 'footable', 'handlebars_helpers']);
74 requirejs(['slick', 'fastclick', 'jquery_maxlength', 'layout','main']); 78 requirejs(['slick', 'fastclick', 'jquery_maxlength', 'layout','main']);
sass/style.sass
@@ -176,6 +176,7 @@ textarea @@ -176,6 +176,7 @@ textarea
176 padding-right: $gutter * 0.5 176 padding-right: $gutter * 0.5
177 padding-top: $gutter * 0.25 177 padding-top: $gutter * 0.25
178 width: 100% 178 width: 100%
  179 + height: 100px
179 180
180 181
181 // ------------------------------------ 182 // ------------------------------------
@@ -371,7 +372,7 @@ h1 @@ -371,7 +372,7 @@ h1
371 display: inline-block 372 display: inline-block
372 height: 80px 373 height: 80px
373 text-indent: -99999px 374 text-indent: -99999px
374 - width: 160px 375 + width: 180px
375 376
376 // 6.3 - menu topo 377 // 6.3 - menu topo
377 .top-menu 378 .top-menu
@@ -436,6 +437,7 @@ h1 @@ -436,6 +437,7 @@ h1
436 border-bottom: 1px solid #f1f1f1 437 border-bottom: 1px solid #f1f1f1
437 display: block 438 display: block
438 font-size: $font-size-base 439 font-size: $font-size-base
  440 + position: relative
439 a 441 a
440 background-color: #fff 442 background-color: #fff
441 color: #484848 443 color: #484848
@@ -453,24 +455,27 @@ h1 @@ -453,24 +455,27 @@ h1
453 text-decoration: none 455 text-decoration: none
454 .fa 456 .fa
455 color: #898989 457 color: #898989
456 - float: right  
457 font-size: 45px 458 font-size: 45px
  459 + position: absolute
  460 + top: 50%
  461 + margin-top: -22px
  462 + right: 8px
458 &-name 463 &-name
459 display: inline-block 464 display: inline-block
460 width: 50% 465 width: 50%
461 vertical-align: middle 466 vertical-align: middle
462 - .arrow-box  
463 - position: relative  
464 - top: $gutter  
465 - &:after  
466 - bottom: 100%  
467 - left: 50%  
468 - border: solid transparent  
469 - content: ""  
470 - position: absolute  
471 - border-bottom-color: #000  
472 - border-width: 8px  
473 - margin-left: -8px 467 + // .arrow-box
  468 + // position: relative
  469 + // top: $gutter
  470 + // &:after
  471 + // bottom: 100%
  472 + // left: 50%
  473 + // border: solid transparent
  474 + // content: ""
  475 + // position: absolute
  476 + // border-bottom-color: #000
  477 + // border-width: 8px
  478 + // margin-left: -8px
474 479
475 // 6.7 - listagem dos programas aleatorios 480 // 6.7 - listagem dos programas aleatorios
476 .ver-todos 481 .ver-todos
@@ -486,6 +491,8 @@ h1 @@ -486,6 +491,8 @@ h1
486 &-list 491 &-list
487 list-style: none 492 list-style: none
488 padding-left: 0 493 padding-left: 0
  494 + .proposal-item
  495 + margin-bottom: $gutter
489 &-group 496 &-group
490 ul 497 ul
491 list-style: none 498 list-style: none
@@ -500,6 +507,7 @@ h1 @@ -500,6 +507,7 @@ h1
500 color: #000 507 color: #000
501 display: block 508 display: block
502 margin-top: $gutter * 1.5 509 margin-top: $gutter * 1.5
  510 + height: 100%
503 overflow: hidden 511 overflow: hidden
504 transition: all 400ms 512 transition: all 400ms
505 +hover(#fff,$darken) 513 +hover(#fff,$darken)
@@ -534,15 +542,28 @@ h1 @@ -534,15 +542,28 @@ h1
534 font-size: $font-size-small 542 font-size: $font-size-small
535 font-weight: 500 543 font-weight: 500
536 margin-top: $gutter * 0.5 544 margin-top: $gutter * 0.5
537 - height: $gutter * 2 545 + // height: $gutter * 2
  546 + // @media (min-width: 768px)
  547 + // height: $gutter * 3
538 &-body 548 &-body
539 padding: $gutter 549 padding: $gutter
540 - img  
541 - margin-left: $gutter * (-1)  
542 - margin-right: $gutter * (-1)  
543 - margin-top: $gutter * (-1)  
544 - margin-bottom: $gutter  
545 - height: 170px 550 + // img
  551 + // margin-left: $gutter * (-1)
  552 + // margin-right: $gutter * (-1)
  553 + // margin-top: $gutter * (-1)
  554 + // margin-bottom: $gutter
  555 + // height: 170px
  556 + &__image
  557 + background-size: cover
  558 + height: 170px
  559 + margin: -20px -20px 10px
  560 + background-position: center center
  561 + // &__footer
  562 + // position: absolute
  563 + // left: 0
  564 + // width: 100%
  565 + // bottom: $gutter
  566 + // padding: 0 10%
546 &-category 567 &-category
547 font-size: $font-size-small 568 font-size: $font-size-small
548 font-weight: 700 569 font-weight: 700
@@ -663,21 +684,38 @@ h1 @@ -663,21 +684,38 @@ h1
663 684
664 // 6.11 - login form 685 // 6.11 - login form
665 .participar 686 .participar
  687 + position: relative
666 text-align: right 688 text-align: right
667 .participe 689 .participe
668 font-size: 14px 690 font-size: 14px
669 padding: 2px 10px 691 padding: 2px 10px
670 - .entrar 692 + .icon-login
  693 + display: inline-block
  694 + position: relative
  695 + top: -2px
  696 + right: 5px
  697 + width: 20px
  698 + height: 20px
  699 + padding: 12px
  700 + vertical-align: middle
  701 + border: 1px solid #ccc !important
671 background: url(images/icons/icon-user.png) no-repeat 20px 50% 702 background: url(images/icons/icon-user.png) no-repeat 20px 50%
672 - // border-left: 1px solid #bcbcbc  
673 - // margin-left: 20px  
674 - padding-left: 40px 703 + .login
  704 + margin-left: 20px
675 .logout 705 .logout
676 - background: url(images/icons/icon-user.png) no-repeat 20px 50%  
677 - // border-left: 1px solid #bcbcbc  
678 - // margin-left: 20px  
679 - padding-left: 40px  
680 -.login,.signup 706 + margin-left: 20px
  707 +#login-panel
  708 + position: absolute
  709 + top: 0
  710 + right: 0
  711 + padding: 20px
  712 + z-index: 9999
  713 + background-color: #fff
  714 + border: 1px solid #ccc
  715 + .loading
  716 + display: none
  717 +.login,
  718 +.signup
681 text-align: left 719 text-align: left
682 .message 720 .message
683 background: #fcc 721 background: #fcc
@@ -833,10 +871,79 @@ td @@ -833,10 +871,79 @@ td
833 display: table 871 display: table
834 table-layout: fixed 872 table-layout: fixed
835 width: 100% 873 width: 100%
  874 + @media (max-width: 567px)
  875 + width: 90%
836 .truncated 876 .truncated
837 overflow-x: hidden 877 overflow-x: hidden
838 text-overflow: ellipsis 878 text-overflow: ellipsis
839 white-space: nowrap 879 white-space: nowrap
  880 + &.phone
  881 + .footable-toggle
  882 + float: right
  883 + padding: 5px 0 !important
  884 + width: 10%
  885 + text-align: center
  886 + background-color: #e0e0e0
  887 + .footable-row-detail-row
  888 + display: inline-block
  889 + &:not(:last-child)
  890 + margin-right: 10px
  891 + padding-right: 10px
  892 + border-right: 1px solid #ccc
  893 + .footable-row-detail-inner
  894 + margin: 0 auto
  895 + .footable-row-detail-cell
  896 + background-color: #e0e0e0
  897 + .footable-row-detail-name
  898 + display: block
  899 + text-transform: uppercase
  900 + .footable-row-detail-value
  901 + display: block
  902 +
  903 + // fix height
  904 + .footable-row-detail-row:nth-child(1)
  905 + .footable-row-detail-value:before
  906 + height: 30px
  907 +
  908 + // check icon
  909 + .footable-row-detail-row:nth-child(2)
  910 + .footable-row-detail-name
  911 + display: none
  912 + .footable-row-detail-value:before
  913 + content: '\f00c'
  914 + font: normal normal normal 14px/1 'FontAwesome'
  915 + display: block
  916 + background-color: #32dbb5
  917 + border: 2px solid #ffffff
  918 + border-radius: 100%
  919 + color: #fff
  920 + font-size: 16px
  921 + height: 30px
  922 + padding: 5px 0
  923 + text-align: center
  924 + transition: all 200ms ease 0s
  925 + width: 30px
  926 + margin: 0 20px
  927 +
  928 + // check icon
  929 + .footable-row-detail-row:nth-child(3)
  930 + .footable-row-detail-name
  931 + display: none
  932 + .footable-row-detail-value:before
  933 + content: '\f00d'
  934 + font: normal normal normal 14px/1 'FontAwesome'
  935 + display: block
  936 + background-color: #DB4127
  937 + border: 2px solid #ffffff
  938 + border-radius: 100%
  939 + color: #fff
  940 + font-size: 16px
  941 + height: 30px
  942 + padding: 5px 0
  943 + text-align: center
  944 + transition: all 200ms ease 0s
  945 + width: 30px
  946 + margin: 0 20px
840 947
841 // 6.15 - paginador 948 // 6.15 - paginador
842 .paging 949 .paging
@@ -1242,9 +1349,19 @@ h3.titulo-destaque @@ -1242,9 +1349,19 @@ h3.titulo-destaque
1242 width: 100% 1349 width: 100%
1243 p 1350 p
1244 padding-bottom: $gutter 1351 padding-bottom: $gutter
  1352 + .proposal-list
  1353 + .proposal-item,
  1354 + .box__title,
  1355 + .box__abstract p
  1356 + height: auto !important
1245 .select 1357 .select
1246 .proposal 1358 .proposal
1247 &-selection 1359 &-selection
1248 float: none 1360 float: none
1249 margin: 0 1361 margin: 0
1250 width: 100% 1362 width: 100%
  1363 + table
  1364 + .position
  1365 + a
  1366 + margin-left: 0
  1367 + margin-top: 5px
1251 \ No newline at end of file 1368 \ No newline at end of file