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,21 +2,29 @@ | ||
2 | <ion-content> | 2 | <ion-content> |
3 | <h1 class="title"> | 3 | <h1 class="title"> |
4 | <span> | 4 | <span> |
5 | - {{proposal.title}} | 5 | + <span id="proposal-title">{{proposal.title}}</span> |
6 | <br /> | 6 | <br /> |
7 | <small>Autoria: {{proposal.author.name}}</small> | 7 | <small>Autoria: {{proposal.author.name}}</small> |
8 | </span> | 8 | </span> |
9 | <a class="back icon-left ion-reply" ng-click="closeProposal()">Voltar</a> | 9 | <a class="back icon-left ion-reply" ng-click="closeProposal()">Voltar</a> |
10 | </h1> | 10 | </h1> |
11 | 11 | ||
12 | + <span id="proposal-id" style="display: none;">{{proposal.id}}</span> | ||
13 | + | ||
12 | <p class="proposal-buttons"> | 14 | <p class="proposal-buttons"> |
13 | 15 | ||
14 | <button class="button tag" ng-click="openTagForm()" ng-show="proposal.author.id == user.id"> | 16 | <button class="button tag" ng-click="openTagForm()" ng-show="proposal.author.id == user.id"> |
15 | <i class="icon ion-pricetags"></i> Adicionar Tag | 17 | <i class="icon ion-pricetags"></i> Adicionar Tag |
16 | </button> | 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 | Comentar | 20 | Comentar |
19 | </button> | 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 | </p> | 28 | </p> |
21 | 29 | ||
22 | <p style="clear: both;"></p> | 30 | <p style="clear: both;"></p> |
ConfJuvApp/www/index.html
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | <head> | 3 | <head> |
4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
5 | <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width, height=device-height"> | 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 | <title>#3confjuv</title> | 8 | <title>#3confjuv</title> |
8 | 9 |
ConfJuvApp/www/js/config.js.example
1 | var ConfJuvAppConfig = { | 1 | var ConfJuvAppConfig = { |
2 | noosferoApiHost: 'http://juventude.gov.br', | 2 | noosferoApiHost: 'http://juventude.gov.br', |
3 | + noosferoApiPublicHost: 'http://app.juventude.gov.br', | ||
3 | noosferoApiVersion: 'v1', | 4 | noosferoApiVersion: 'v1', |
4 | noosferoDiscussion: 99895, | 5 | noosferoDiscussion: 99895, |
5 | noosferoStatutePath: 'articles/participatorio/0010/2309/Resolucao-01-2015-etapa-digital.pdf', | 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,6 +25,8 @@ angular.module('confjuvapp.controllers', []) | ||
25 | $scope.loggedIn = true; | 25 | $scope.loggedIn = true; |
26 | $scope.loadMe(); | 26 | $scope.loadMe(); |
27 | $scope.loadTopics($scope.token); | 27 | $scope.loadTopics($scope.token); |
28 | + | ||
29 | + $scope.parseURLParams(); | ||
28 | } else if ($scope.modal) { | 30 | } else if ($scope.modal) { |
29 | $scope.modal.show(); | 31 | $scope.modal.show(); |
30 | } else { | 32 | } else { |
@@ -39,6 +41,34 @@ angular.module('confjuvapp.controllers', []) | @@ -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 | // Function to logout | 72 | // Function to logout |
43 | $scope.logout = function() { | 73 | $scope.logout = function() { |
44 | ConfJuvAppUtils.setPrivateToken(null); | 74 | ConfJuvAppUtils.setPrivateToken(null); |
ConfJuvApp/www/js/utils.js
@@ -21,6 +21,21 @@ var ConfJuvAppUtils = { | @@ -21,6 +21,21 @@ var ConfJuvAppUtils = { | ||
21 | 21 | ||
22 | getPrivateToken: function() { | 22 | getPrivateToken: function() { |
23 | return window.localStorage['private_token']; | 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 | }; |