Commit b12434f3c278c647285fcd5d578635e30907a715
1 parent
239472ef
Exists in
master
and in
2 other branches
Share proposal on Twitter and Facebook
Showing
5 changed files
with
58 additions
and
3 deletions
Show diff stats
ConfJuvApp/www/html/_proposal.html
... | ... | @@ -2,21 +2,29 @@ |
2 | 2 | <ion-content> |
3 | 3 | <h1 class="title"> |
4 | 4 | <span> |
5 | - {{proposal.title}} | |
5 | + <span id="proposal-title">{{proposal.title}}</span> | |
6 | 6 | <br /> |
7 | 7 | <small>Autoria: {{proposal.author.name}}</small> |
8 | 8 | </span> |
9 | 9 | <a class="back icon-left ion-reply" ng-click="closeProposal()">Voltar</a> |
10 | 10 | </h1> |
11 | 11 | |
12 | + <span id="proposal-id" style="display: none;">{{proposal.id}}</span> | |
13 | + | |
12 | 14 | <p class="proposal-buttons"> |
13 | 15 | |
14 | 16 | <button class="button tag" ng-click="openTagForm()" ng-show="proposal.author.id == user.id"> |
15 | 17 | <i class="icon ion-pricetags"></i> Adicionar Tag |
16 | 18 | </button> |
17 | - <button ripple class="button icon-left ion-chatbox-working comment" ng-click="openCommentForm()"> | |
19 | + <button class="button icon-left ion-chatbox-working comment" ng-click="openCommentForm()"> | |
18 | 20 | Comentar |
19 | 21 | </button> |
22 | + <button class="button icon-left ion-social-twitter" onclick="window.open(ConfJuvAppUtils.shareOnTwitter(), '_system')"> | |
23 | + Compartilhar no Twitter | |
24 | + </button> | |
25 | + <button class="button icon-left ion-social-facebook" onclick="window.open(ConfJuvAppUtils.shareOnFacebook(), '_system')"> | |
26 | + Compartilhar no Facebook | |
27 | + </button> | |
20 | 28 | </p> |
21 | 29 | |
22 | 30 | <p style="clear: both;"></p> | ... | ... |
ConfJuvApp/www/index.html
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | <head> |
4 | 4 | <meta charset="utf-8"> |
5 | 5 | <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width, height=device-height"> |
6 | + <meta property="og:description" content="Participe da 3ª Conferência Nacional de Juventude!" /> | |
6 | 7 | |
7 | 8 | <title>#3confjuv</title> |
8 | 9 | ... | ... |
ConfJuvApp/www/js/config.js.example
1 | 1 | var ConfJuvAppConfig = { |
2 | 2 | noosferoApiHost: 'http://juventude.gov.br', |
3 | + noosferoApiPublicHost: 'http://app.juventude.gov.br', | |
3 | 4 | noosferoApiVersion: 'v1', |
4 | 5 | noosferoDiscussion: 99895, |
5 | 6 | noosferoStatutePath: 'articles/participatorio/0010/2309/Resolucao-01-2015-etapa-digital.pdf', | ... | ... |
ConfJuvApp/www/js/controllers.js
... | ... | @@ -25,6 +25,8 @@ angular.module('confjuvapp.controllers', []) |
25 | 25 | $scope.loggedIn = true; |
26 | 26 | $scope.loadMe(); |
27 | 27 | $scope.loadTopics($scope.token); |
28 | + | |
29 | + $scope.parseURLParams(); | |
28 | 30 | } else if ($scope.modal) { |
29 | 31 | $scope.modal.show(); |
30 | 32 | } else { |
... | ... | @@ -39,6 +41,34 @@ angular.module('confjuvapp.controllers', []) |
39 | 41 | } |
40 | 42 | }; |
41 | 43 | |
44 | + $scope.parseURLParams = function() { | |
45 | + var params = document.location.search.replace(/^\?/, '').split('&'); | |
46 | + for (var i=0; i < params.length; i++) { | |
47 | + var pair = params[i].split('='); | |
48 | + | |
49 | + if (pair[0] == 'proposal') { | |
50 | + $scope.loadSingleProposal(pair[1]); | |
51 | + } | |
52 | + } | |
53 | + }; | |
54 | + | |
55 | + $scope.loadSingleProposal = function(pid) { | |
56 | + $scope.loading = true; | |
57 | + | |
58 | + var params = '?private_token=' + $scope.token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal'; | |
59 | + | |
60 | + var path = 'articles/' + pid + params; | |
61 | + | |
62 | + $http.get(ConfJuvAppUtils.pathTo(path)) | |
63 | + .then(function(resp) { | |
64 | + $scope.openProposal(resp.data.article); | |
65 | + $scope.loading = false; | |
66 | + }, function(err) { | |
67 | + $ionicPopup.alert({ title: 'Proposta', template: 'Não foi possível carregar a proposta com id ' + pid }); | |
68 | + $scope.loading = false; | |
69 | + }); | |
70 | + }; | |
71 | + | |
42 | 72 | // Function to logout |
43 | 73 | $scope.logout = function() { |
44 | 74 | ConfJuvAppUtils.setPrivateToken(null); | ... | ... |
ConfJuvApp/www/js/utils.js
... | ... | @@ -21,6 +21,21 @@ var ConfJuvAppUtils = { |
21 | 21 | |
22 | 22 | getPrivateToken: function() { |
23 | 23 | return window.localStorage['private_token']; |
24 | - } | |
24 | + }, | |
25 | 25 | |
26 | + shareOnTwitter: function() { | |
27 | + var title = document.getElementById('proposal-title').innerHTML, | |
28 | + id = document.getElementById('proposal-id').innerHTML, | |
29 | + text = 'Apoie a minha proposta para a #3ConfJuv: ' + title + ' ' + ConfJuvAppConfig.noosferoApiPublicHost + '/?proposal=' + id, | |
30 | + url = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(text); | |
31 | + return url; | |
32 | + }, | |
33 | + | |
34 | + shareOnFacebook: function() { | |
35 | + var title = document.getElementById('proposal-title').innerHTML, | |
36 | + id = document.getElementById('proposal-id').innerHTML, | |
37 | + link = ConfJuvAppConfig.noosferoApiPublicHost + '/?proposal=' + id, | |
38 | + url = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(link); | |
39 | + return url; | |
40 | + } | |
26 | 41 | }; | ... | ... |