Commit 63465cfa111d4cfc393f267e674c44746c4cad0a
1 parent
2c192b31
Exists in
master
and in
6 other branches
Fix share buttons
Showing
3 changed files
with
18 additions
and
11 deletions
Show diff stats
index.html
| @@ -297,7 +297,7 @@ | @@ -297,7 +297,7 @@ | ||
| 297 | </div> | 297 | </div> |
| 298 | <div class="social"> | 298 | <div class="social"> |
| 299 | <span>Compartilhe esta proposta</span> | 299 | <span>Compartilhe esta proposta</span> |
| 300 | - {{#social_share parent.title abstract "#/programas/{{parent.id}}/propostas/{{id}}"}}{{/social_share}} | 300 | + {{{social_share parent.title abstract (proposal_url parent.id id)}}} |
| 301 | </div> | 301 | </div> |
| 302 | </script> | 302 | </script> |
| 303 | 303 | ||
| @@ -384,10 +384,10 @@ | @@ -384,10 +384,10 @@ | ||
| 384 | 384 | ||
| 385 | <script id="social-share" type="text/x-handlebars-template"> | 385 | <script id="social-share" type="text/x-handlebars-template"> |
| 386 | <ul> | 386 | <ul> |
| 387 | - <li><a href="#/programas/{{parent.id}}/propostas/{{id}}" class="fb-share icon icon-facebook" data-caption="{{parent.title}}" data-description="{{stripTags abstract}}">Compartilhar no Facebook</a></li> | ||
| 388 | - <li><a href="https://twitter.com/intent/tweet?text={{stripTags abstract}}" class="tw-share icon icon-twitter popup">Compartilhar no Twitter</a></li> | ||
| 389 | - <li><a href="https://plus.google.com/share?url=http://dialoga.gov.br" class="gp-share icon icon-gplus popup">Compartilhar no Google Plus</a></li> | ||
| 390 | - <li><a class="ws-share disabled icon icon-whatsapp">Compartilhar no WhatsApp</a></li> | 387 | + <li><a href="{{url}}" class="fb-share icon icon-facebook" data-caption="{{title}}" data-description="{{stripTags description}}">Compartilhar no Facebook</a></li> |
| 388 | + <li><a href="https://twitter.com/intent/tweet?url={{encodeURI url}}&text={{stripTags description}}" class="tw-share icon icon-twitter popup">Compartilhar no Twitter</a></li> | ||
| 389 | + <li><a href="https://plus.google.com/share?url={{encodeURI url}}" class="gp-share icon icon-gplus popup">Compartilhar no Google Plus</a></li> | ||
| 390 | + <li><a href="whatsapp://send" data-text="{{stripTags description}}" data-href="{{url}}" class="ws-share icon icon-whatsapp">Compartilhar no WhatsApp</a></li> | ||
| 391 | </ul> | 391 | </ul> |
| 392 | </script> | 392 | </script> |
| 393 | 393 |
js/handlebars-helpers.js
| @@ -96,7 +96,19 @@ define(['handlebars'], function(Handlebars){ | @@ -96,7 +96,19 @@ define(['handlebars'], function(Handlebars){ | ||
| 96 | 96 | ||
| 97 | Handlebars.registerHelper('social_share', function(title, description, url) { | 97 | Handlebars.registerHelper('social_share', function(title, description, url) { |
| 98 | var template = Handlebars.compile($('#social-share').html()); | 98 | var template = Handlebars.compile($('#social-share').html()); |
| 99 | - return template(); | 99 | + if(url==='#') { |
| 100 | + url = ''; | ||
| 101 | + } | ||
| 102 | + url = 'http:'+Url.addBaseUrl(url); | ||
| 103 | + return template({title: title, description: description, url: url}); | ||
| 104 | + }); | ||
| 105 | + | ||
| 106 | + Handlebars.registerHelper('proposal_url', function(parent_id, id) { | ||
| 107 | + return "#/programas/"+parent_id+"/propostas/"+id; | ||
| 108 | + }); | ||
| 109 | + | ||
| 110 | + Handlebars.registerHelper('encodeURI', function(uri) { | ||
| 111 | + return encodeURIComponent(uri); | ||
| 100 | }); | 112 | }); |
| 101 | 113 | ||
| 102 | function proposal_has_category(proposal, category_slug) { | 114 | function proposal_has_category(proposal, category_slug) { |
js/main.js
| @@ -675,11 +675,6 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -675,11 +675,6 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 675 | 675 | ||
| 676 | $(document).on('click', '.social .fb-share', function(e) { | 676 | $(document).on('click', '.social .fb-share', function(e) { |
| 677 | var link = $(this).attr('href'); | 677 | var link = $(this).attr('href'); |
| 678 | - if(link==='#' || link ==='') { | ||
| 679 | - link = window.location.href; | ||
| 680 | - } else { | ||
| 681 | - link = 'http:'+Url.addBaseUrl(link); | ||
| 682 | - } | ||
| 683 | FB.ui({ | 678 | FB.ui({ |
| 684 | method: 'feed', | 679 | method: 'feed', |
| 685 | link: link, | 680 | link: link, |