Skip to content

Commit

Permalink
Fixed issue esvit#33. Now it's possible to use values coming from aja…
Browse files Browse the repository at this point in the history
…x calls.
  • Loading branch information
marloncarvalho committed Jun 3, 2015
1 parent bddc5e2 commit 45b7ea5
Show file tree
Hide file tree
Showing 16 changed files with 416 additions and 204 deletions.
2 changes: 1 addition & 1 deletion angular-social.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion angular-social.map

Large diffs are not rendered by default.

305 changes: 205 additions & 100 deletions angular-social.src.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions examples/demo1.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
<li class="ng-social-odnoklassniki">Одноклассники</li>
<li class="ng-social-mailru">Мой мир</li>
<li class="ng-social-pinterest">Pinterest</li>
<li class="ng-social-github" user="esvit" repository="ng-table">GitHub</li>
<li class="ng-social-github-forks" user="esvit" repository="ng-table">Forks</li>
<li class="ng-social-github" user="'esvit'" repository="'ng-table'">GitHub</li>
<li class="ng-social-github-forks" user="user" repository="repository">Forks</li>
<li class="ng-social-stumbleupon">StumbleUpon</li>
<li class="ng-social-moi-krug">Мой круг</li>
<li class="ng-social-linkedin">LinkedIn</li>
Expand All @@ -78,6 +78,8 @@
controller('DemoCtrl', function($scope) {
$scope.current_title = 'Test';
$scope.current_description = 'Test description';
$scope.user = 'esvit';
$scope.repository = 'ng-table';
})
</script>
</div>
Expand Down
24 changes: 17 additions & 7 deletions src/scripts/02-facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ app.directive('ngSocialFacebook', ['$parse', function ($parse) {
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
scope: {
url: "=url",
description: "=description",
title: "=title"
},
replace: true,
transclude: true,
template: '<li>' +
Expand All @@ -42,12 +46,18 @@ app.directive('ngSocialFacebook', ['$parse', function ($parse) {
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
scope.$watchGroup(['title', 'url', 'description'], function(newValues, oldValues) {
if(newValues) {
options.urlOptions = {
title: newValues[0],
url: newValues[1],
description: newValues[2]
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
};
}]);
26 changes: 18 additions & 8 deletions src/scripts/03-twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ app.directive('ngSocialTwitter', ['$parse', function ($parse) {
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
scope: {
url: "=url",
title: "=title",
description: "=description"
},
replace: true,
transclude: true,
template: '<li> \
Expand All @@ -41,13 +45,19 @@ app.directive('ngSocialTwitter', ['$parse', function ($parse) {
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope),
title: $parse(attrs.title)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);

scope.$watchGroup(['title', 'url', 'description'], function(newValues, oldValues) {
if(newValues) {
options.urlOptions = {
title: newValues[0],
url: newValues[1],
description: newValues[2]
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
}
}]);
24 changes: 17 additions & 7 deletions src/scripts/04-google-plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ app.directive('ngSocialGooglePlus', ['$parse', function ($parse) {
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
scope: {
url: "=url",
description: "=description",
title: "=title"
},
replace: true,
transclude: true,
template: '<li> \
Expand All @@ -52,12 +56,18 @@ app.directive('ngSocialGooglePlus', ['$parse', function ($parse) {
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
scope.$watchGroup(['title', 'url', 'description'], function(newValues, oldValues) {
if(newValues) {
options.urlOptions = {
title: newValues[0],
url: newValues[1],
description: newValues[2]
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
};
}]);
30 changes: 20 additions & 10 deletions src/scripts/05-vk.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ app.directive('ngSocialVk', ['$parse', function ($parse) {
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
replace: true,
scope: {
url: "=url",
description: "=description",
title: "=title",
image: "=image"
},
transclude: true,
template: '<li> \
<a ng-href="{{ctrl.link(options)}}" target="_blank" ng-click="ctrl.clickShare($event, options)" class="ng-social-button"> \
Expand All @@ -48,15 +53,20 @@ app.directive('ngSocialVk', ['$parse', function ($parse) {
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope),
title: $parse(attrs.title)(scope),
description: $parse(attrs.description)(scope),
image: $parse(attrs.image)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);

scope.$watchGroup(['url', 'description', 'title', 'image'], function(newValues, oldValues) {
if(newValues) {
options.urlOptions = {
url: newValues[0],
description: newValues[1],
title: newValues[2],
image: newValues[3]
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
}
}]);
21 changes: 14 additions & 7 deletions src/scripts/06-odnoklassniki.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ angular.module("ngSocial").directive('ngSocialOdnoklassniki', ['$parse', functio
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
replace: true,
scope: {
url: "=url"
},
transclude: true,
template: '<li> \
<a ng-href="{{ctrl.link(options)}}" target="_blank" ng-click="ctrl.clickShare($event, options)" class="ng-social-button"> \
Expand All @@ -46,12 +48,17 @@ angular.module("ngSocial").directive('ngSocialOdnoklassniki', ['$parse', functio
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);

scope.$watch('url', function(newValue, oldValue) {
if(newValue) {
options.urlOptions = {
url: newValue
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
}
}]);
24 changes: 16 additions & 8 deletions src/scripts/07-mailru.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ angular.module("ngSocial").directive('ngSocialMailru', ['$parse', function ($par
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
replace: true,
scope: {
url: "=url",
title: "=title"
},
transclude: true,
template: '<li> \
<a ng-href="{{ctrl.link(options)}}" target="_blank" ng-click="ctrl.clickShare($event, options)" class="ng-social-button"> \
Expand All @@ -34,13 +37,18 @@ angular.module("ngSocial").directive('ngSocialMailru', ['$parse', function ($par
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope),
title: $parse(attrs.title)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);

scope.$watchGroup(['title', 'url'], function(newValues, oldValues) {
if(newValues) {
options.urlOptions = {
title: newValues[0],
url: newValues[1]
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
}
}]);
27 changes: 18 additions & 9 deletions src/scripts/08-pinterest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ angular.module("ngSocial").directive('ngSocialPinterest', ['$parse', function ($
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
scope: {
url: "=url",
title: "=title",
image: "=image"
},
replace: true,
transclude: true,
template: '<li> \
Expand All @@ -32,14 +36,19 @@ angular.module("ngSocial").directive('ngSocialPinterest', ['$parse', function ($
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope),
title: $parse(attrs.title)(scope),
image: $parse(attrs.image)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);

scope.$watchGroup(['title', 'url', 'image'], function(newValues, oldValues) {
if(newValues) {
options.urlOptions = {
title: newValues[0],
url: newValues[1],
image: newValues[2]
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
}
}]);
24 changes: 16 additions & 8 deletions src/scripts/09-github-forks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ angular.module("ngSocial").directive('ngSocialGithubForks', function () {
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
scope: {
user: "=user",
repository: "=repository"
},
replace: true,
transclude: true,
template: '<li> \
Expand All @@ -28,13 +31,18 @@ angular.module("ngSocial").directive('ngSocialGithubForks', function () {
if (!ctrl) {
return;
}
options.urlOptions = {
'user': attrs.user,
'repository': attrs.repository
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);

scope.$watchGroup(['user', 'repository'], function(newValues, oldValues) {
if(newValues) {
options.urlOptions = {
user: newValues[0],
repository: newValues[1]
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
}
});
24 changes: 16 additions & 8 deletions src/scripts/09-github.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ angular.module("ngSocial").directive('ngSocialGithub', function () {
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
scope: {
user: "=user",
repository: "=repository"
},
replace: true,
transclude: true,
template: '<li> \
Expand All @@ -28,13 +31,18 @@ angular.module("ngSocial").directive('ngSocialGithub', function () {
if (!ctrl) {
return;
}
options.urlOptions = {
'user': attrs.user,
'repository': attrs.repository
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);

scope.$watchGroup(['user', 'repository'], function(newValues, oldValues) {
if(newValues) {
options.urlOptions = {
user: newValues[0],
repository: newValues[1]
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
});
}
}
});
Loading

0 comments on commit 45b7ea5

Please sign in to comment.