Skip to content

Commit 06ec373

Browse files
author
Tuomo Jokimies
committed
Support size parameter
1 parent ccbe6ff commit 06ec373

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/angular-no-captcha.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,26 @@ angular
2424
}])
2525
.provider('noCAPTCHA', function noCaptchaProvider(){
2626
var siteKey,
27+
size,
2728
theme;
2829

2930
this.setSiteKey = function (_siteKey){
3031
siteKey = _siteKey;
3132
};
3233

34+
this.setSize = function (_size){
35+
size = _size;
36+
};
37+
3338
this.setTheme = function (_theme){
3439
theme = _theme;
3540
};
3641

3742
this.$get = [function noCaptchaFactory(){
3843
return {
3944
theme: theme,
40-
siteKey: siteKey
45+
siteKey: siteKey,
46+
size: size
4147
}
4248
}];
4349
})
@@ -74,6 +80,7 @@ angular
7480
scope: {
7581
gRecaptchaResponse: '=',
7682
siteKey: '@',
83+
size: '@',
7784
theme: '@',
7885
control: '=?',
7986
expiredCallback: '=?'
@@ -88,6 +95,7 @@ angular
8895

8996
grecaptchaCreateParameters = {
9097
sitekey: scope.siteKey || noCaptcha.siteKey,
98+
size: scope.size || noCaptcha.size,
9199
theme: scope.theme || noCaptcha.theme,
92100
callback: function (r){
93101
scope.$apply(function (){

tests/no-captcha.provider.test.mocha.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ describe('noCAPTCHA provider', function() {
2525
}]));
2626
});
2727

28+
describe('set site size', function() {
29+
var testSize = 'compact';
30+
31+
beforeEach(function() {
32+
noCAPTCHAProvider.setSize(testSize);
33+
});
34+
35+
it('should remember the value', inject(['noCAPTCHA', function(noCAPTCHA) {
36+
expect(noCAPTCHA.size).to.equal(testSize);
37+
}]));
38+
});
39+
2840
describe('set theme', function() {
2941
var theme = 'dark';
3042

0 commit comments

Comments
 (0)