Commit 44c19a89f695f9ec35a16175b409fba6daff2357
1 parent
6747beed
Exists in
master
and in
6 other branches
Share on twitter and g+
Showing
3 changed files
with
40 additions
and
18 deletions
Show diff stats
index.html
... | ... | @@ -97,12 +97,7 @@ |
97 | 97 | <h1><a href="#">{{article.title}}</a></h1> |
98 | 98 | <a id="display-contrast" href="#">Alto Contraste</a> |
99 | 99 | <div class="social top"> |
100 | - <ul> | |
101 | - <li><a href="#" class="fb-share icon icon-facebook" data-description="Aqui suas ideias viram propostas e você ajuda a melhorar as ações do governo">Compartilhar no Facebook</a></li> | |
102 | - <li><a class="tw-share disabled icon icon-twitter">Compartilhar no Twitter</a></li> | |
103 | - <li><a class="gp-share disabled icon icon-gplus">Compartilhar no Google Plus</a></li> | |
104 | - <li><a class="ws-share disabled icon icon-whatsapp">Compartilhar no WhatsApp</a></li> | |
105 | - </ul> | |
100 | + {{#social_share "Dialoga Brasil" "Aqui suas ideias viram propostas e você ajuda a melhorar as ações do governo" "#"}}{{/social_share}} | |
106 | 101 | </div> |
107 | 102 | </header> |
108 | 103 | |
... | ... | @@ -204,12 +199,7 @@ |
204 | 199 | <div class="col-sm-4 col-sm-offset-4"> |
205 | 200 | <div class="social right"> |
206 | 201 | <span>COMPARTILHE<br>ESTE PROGRAMA</span> |
207 | - <ul> | |
208 | - <li><a href="#" class="fb-share icon icon-facebook" data-caption="{{title}}" data-description="{{stripTags abstract}}">Compartilhar no Facebook</a></li> | |
209 | - <li><a class="tw-share disabled icon icon-twitter">Compartilhar no Twitter</a></li> | |
210 | - <li><a class="gp-share disabled icon icon-gplus">Compartilhar no Google Plus</a></li> | |
211 | - <li><a class="ws-share disabled icon icon-whatsapp">Compartilhar no WhatsApp</a></li> | |
212 | - </ul> | |
202 | + {{#social_share title abstract '#'}}{{/social_share}} | |
213 | 203 | </div> |
214 | 204 | </div> |
215 | 205 | </div> |
... | ... | @@ -307,12 +297,7 @@ |
307 | 297 | </div> |
308 | 298 | <div class="social"> |
309 | 299 | <span>Compartilhe esta proposta</span> |
310 | - <ul> | |
311 | - <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> | |
312 | - <li><a class="tw-share disabled icon icon-twitter">Compartilhar no Twitter</a></li> | |
313 | - <li><a class="gp-share disabled icon icon-gplus">Compartilhar no Google Plus</a></li> | |
314 | - <li><a class="ws-share disabled icon icon-whatsapp">Compartilhar no WhatsApp</a></li> | |
315 | - </ul> | |
300 | + {{#social_share parent.title abstract "#/programas/{{parent.id}}/propostas/{{id}}"}}{{/social_share}} | |
316 | 301 | </div> |
317 | 302 | </script> |
318 | 303 | |
... | ... | @@ -397,6 +382,14 @@ |
397 | 382 | </form> |
398 | 383 | </script> |
399 | 384 | |
385 | + <script id="social-share" type="text/x-handlebars-template"> | |
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> | |
391 | + </ul> | |
392 | + </script> | |
400 | 393 | |
401 | 394 | <script type='text/javascript' > |
402 | 395 | loadRequireJS(); | ... | ... |
js/handlebars-helpers.js
... | ... | @@ -94,6 +94,11 @@ define(['handlebars'], function(Handlebars){ |
94 | 94 | return +(Math.round(num + "e+2") + "e-2"); |
95 | 95 | }); |
96 | 96 | |
97 | + Handlebars.registerHelper('social_share', function(title, description, url) { | |
98 | + var template = Handlebars.compile($('#social-share').html()); | |
99 | + return template(); | |
100 | + }); | |
101 | + | |
97 | 102 | function proposal_has_category(proposal, category_slug) { |
98 | 103 | for(var i=0; i<proposal.categories.length; i++) { |
99 | 104 | if(proposal.categories[i].slug == category_slug) | ... | ... |
js/main.js
... | ... | @@ -730,6 +730,30 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
730 | 730 | }); |
731 | 731 | e.preventDefault(); |
732 | 732 | }); |
733 | + | |
734 | + var popupCenter = function(url, title, w, h) { | |
735 | + var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left; | |
736 | + var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top; | |
737 | + | |
738 | + var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; | |
739 | + var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; | |
740 | + | |
741 | + var left = ((width / 2) - (w / 2)) + dualScreenLeft; | |
742 | + var top = ((height / 3) - (h / 3)) + dualScreenTop; | |
743 | + | |
744 | + var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); | |
745 | + | |
746 | + // Puts focus on the newWindow | |
747 | + if (window.focus) { | |
748 | + newWindow.focus(); | |
749 | + } | |
750 | + }; | |
751 | + | |
752 | + $(document).on('click', '.social a.popup', {}, function popUp(e) { | |
753 | + var self = $(this); | |
754 | + popupCenter(self.attr('href'), self.find('.rrssb-text').html(), 580, 470); | |
755 | + e.preventDefault(); | |
756 | + }); | |
733 | 757 | }); |
734 | 758 | |
735 | 759 | window.addEventListener("message", function(ev) { | ... | ... |