Skip to content

Commit 6c71881

Browse files
committed
share projects in project page
1 parent 03ece86 commit 6c71881

File tree

5 files changed

+78
-39
lines changed

5 files changed

+78
-39
lines changed

bower.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
"angular": "^1.6.6",
2020
"angular-route": "^1.6.6",
2121
"font-awesome": "^4.7.0",
22-
"sweetalert":"1.1.3",
22+
"sweetalert": "1.1.3",
2323
"ngSweetAlert": "latest",
2424
"ng-tags-input": "3.2.0",
2525
"angular-jwt": "^0.1.9",
2626
"ng-file-upload": "^12.2.13",
27-
"AngularJS-Toaster": "angularjs-toaster#^2.2.0"
27+
"AngularJS-Toaster": "angularjs-toaster#^2.2.0",
28+
"angular-socialshare": "angularjs-socialshare#^2.3.11"
2829
}
2930
}

public/app/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
angular.module('mainApp', ['ngRoute', 'oitozero.ngSweetAlert', 'ngTagsInput', 'angular-jwt', 'ngFileUpload', 'toaster', 'ngAnimate'])
1+
angular.module('mainApp', ['ngRoute', 'oitozero.ngSweetAlert', '720kb.socialshare', 'ngTagsInput', 'angular-jwt', 'ngFileUpload', 'toaster', 'ngAnimate'])
22

33
.config(function ($httpProvider) {
44
$httpProvider.interceptors.push('authInterceptor')

public/app/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
<script src="https://code.angularjs.org/1.6.5/angular-animate.min.js" ></script>
5959
<script src="https://cdnjs.cloudflare.com/ajax/libs/angularjs-toaster/1.1.0/toaster.min.js"></script>
6060

61+
<!-- share -->
62+
<script src="../bower_components/angular-socialshare/dist/angular-socialshare.min.js"></script>
63+
6164
<!-- app js -->
6265
<script src="app.js"></script>
6366

public/app/routes/projectPage/controller.js

+68-33
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
angular.module('mainApp')
2-
.controller('projectPageController', function($scope, $routeParams, $location, dataService, $rootScope, toaster, SweetAlert) {
2+
.controller('projectPageController', function($scope, Socialshare, $routeParams, $location, dataService, $rootScope, toaster, SweetAlert) {
33

44
const id = $routeParams.id
55

66
dataService.getProjectPage(id)
77
.then(data => {
8-
$scope.project = data.data.data
9-
$scope.creator = data.data.creator
10-
})
8+
$scope.project = data.data.data
9+
$scope.creator = data.data.creator
10+
})
1111

1212
$scope.enableEditor = function(toggle) {
1313
if($scope.options === true){
@@ -121,42 +121,77 @@ $scope.followProject = function(){
121121
SweetAlert.swal({
122122
title: 'Project already following',
123123
type: 'info',
124-
})
125-
}
126-
})
124+
})
127125
}
126+
})
127+
}
128128

129-
$scope.clickMeToShowMessageEdit = function(options) {
130-
$scope.options = options
131-
if($scope.options === true){
132-
SweetAlert.swal({
133-
title: 'Edit mode ON',
134-
text: "You can edit content!",
135-
type: 'info',
136-
})
137-
}
138-
}
129+
$scope.clickMeToShowMessageEdit = function(options) {
130+
$scope.options = options
131+
if($scope.options === true){
132+
SweetAlert.swal({
133+
title: 'Edit mode ON',
134+
text: "You can edit content!",
135+
type: 'info',
136+
})
137+
}
138+
}
139139

140-
$scope.joinProject = function (){
141-
const user = $rootScope.loggedUser
142-
const {creatorName, creatorMail} = $scope.project
143-
toaster.info('Sending mail to project admin')
144-
dataService.joinProject(user, creatorMail, creatorName)
145-
.then(mail => {
146-
toaster.success("Mail sended succes, admin project will response you as soon as posible!");
147-
})
140+
$scope.joinProject = function (){
141+
const user = $rootScope.loggedUser
142+
const {creatorName, creatorMail} = $scope.project
143+
toaster.info('Sending mail to project admin')
144+
dataService.joinProject(user, creatorMail, creatorName)
145+
.then(mail => {
146+
toaster.success("Mail sended succes, admin project will response you as soon as posible!");
147+
})
148148

149+
}
150+
151+
$('.myAffix').affix({
152+
offset: {
153+
top: 475,
154+
bottom: function () {
155+
return (this.bottom = $('.footer').outerHeight(true))
149156
}
157+
}
158+
})
159+
160+
$scope.shareFacebook = function(){
161+
const actualUrl = $location.$$absUrl
162+
Socialshare.share({
163+
'provider': 'facebook',
164+
'attrs': {
165+
'socialshareQuote': 'One of the amazin proejcts of web-developers!',
166+
'socialshareUrl': actualUrl
167+
}
168+
});
169+
}
150170

151-
$('.myAffix').affix({
152-
offset: {
153-
top: 475,
154-
bottom: function () {
155-
return (this.bottom = $('.footer').outerHeight(true))
156-
}
171+
$scope.shareTwitter = function(){
172+
const actualUrl = $location.$$absUrl
173+
Socialshare.share({
174+
'provider': 'twitter',
175+
'attrs': {
176+
'socialshareText': 'One of the amazin proejcts of web-developers!',
177+
'socialshareUrl': actualUrl,
178+
'socialshareHashtags': 'webdeveloper, angular, project'
157179
}
158-
})
180+
});
181+
}
182+
183+
$scope.shareGoogle = function(){
184+
const actualUrl = $location.$$absUrl
185+
Socialshare.share({
186+
'provider': 'google',
187+
'attrs': {
188+
'socialshareText': 'One of the amazin proejcts of web-developers!',
189+
'socialshareUrl': actualUrl,
190+
'socialshareHashtags': 'webdeveloper, angular, project'
191+
}
192+
});
193+
}
159194

160195

161196

162-
})
197+
})

public/app/routes/projectPage/template.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ <h3>Developers needed:</h3>
7676
<button class="btn btn-primary center-block" ng-click='followProject()'>Follow this project</button>
7777
<nav class="navbar">
7878
<ul class="nav navbar-nav">
79-
<li><a href="#"><i class="fa fa-facebook"></i></a></li>
80-
<li><a href="#"><i class="fa fa-twitter"></i></a></li>
81-
<li><a href="#"><i class="fa fa-google-plus"></i></a></li>
79+
<li><a ng-click="shareFacebook()"><i class="fa fa-facebook"></i></a></li>
80+
<li><a ng-click="shareTwitter()"><i class="fa fa-twitter"></i></a></li>
81+
<li><a ng-click="shareGoogle()"><i class="fa fa-google-plus"></i></a></li>
8282
</ul>
8383
</nav>
8484
</div>

0 commit comments

Comments
 (0)