Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Assuming you have [aurelia-validation](https://github.com/aurelia/validation) co

```html
<form submit.delegate="submit()">
<aup-google-recaptcha callback.call="recaptcha($event)" value.bind="response & validate"></aup-google-recaptcha>
<aup-google-recaptcha callback.call="recaptcha($event)" expire.call="recaptchaExpired($event)" value.bind="response & validate"></aup-google-recaptcha>
<button type="submit">Submit</button>
</form>
```
Expand All @@ -118,6 +118,10 @@ export class App {
this.response = response;
}

recaptchaExpired(){
this.response = undefined;
}

async submit() {
try {
const errors = await this.validationController.validate();
Expand Down Expand Up @@ -155,4 +159,4 @@ export class App {
window.grecaptcha.execute(this.widgetId);
}
}
```
```
4 changes: 2 additions & 2 deletions dist/amd/aurelia-plugins-google-recaptcha-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export declare class Recaptcha {
_scriptPromise: any;
badge: string;
callback: any;
expire: any;
size: string;
theme: string;
type: string;
widgetId: any;
constructor(element: any, config: any);
bind(): void;
_initialize(): Promise<void>;
bind(): Promise<void>;
_loadApiScript(): void;
}
35 changes: 18 additions & 17 deletions dist/amd/aurelia-plugins-google-recaptcha-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ define(['exports', 'aurelia-binding', 'aurelia-dependency-injection', 'aurelia-t
throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
}

var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6;
var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;

var Recaptcha = exports.Recaptcha = (_dec = (0, _aureliaTemplating.customElement)('aup-google-recaptcha'), _dec2 = (0, _aureliaTemplating.noView)(), _dec3 = (0, _aureliaDependencyInjection.inject)(Element, _aureliaPluginsGoogleRecaptchaConfig.Config), _dec4 = (0, _aureliaTemplating.bindable)({ defaultBindingMode: _aureliaBinding.bindingMode.twoWay }), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = function () {
function Recaptcha(element, config) {
Expand All @@ -96,25 +96,23 @@ define(['exports', 'aurelia-binding', 'aurelia-dependency-injection', 'aurelia-t

_initDefineProp(this, 'callback', _descriptor2, this);

_initDefineProp(this, 'size', _descriptor3, this);
_initDefineProp(this, 'expire', _descriptor3, this);

_initDefineProp(this, 'theme', _descriptor4, this);
_initDefineProp(this, 'size', _descriptor4, this);

_initDefineProp(this, 'type', _descriptor5, this);
_initDefineProp(this, 'theme', _descriptor5, this);

_initDefineProp(this, 'widgetId', _descriptor6, this);
_initDefineProp(this, 'type', _descriptor6, this);

_initDefineProp(this, 'widgetId', _descriptor7, this);

this._config = config;
this._element = element;
if (!this._config.get('siteKey')) return console.error('No sitekey has been specified.');
this._loadApiScript();
}

Recaptcha.prototype.bind = function bind() {
this._initialize();
};

Recaptcha.prototype._initialize = function () {
Recaptcha.prototype.bind = function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
Expand All @@ -124,7 +122,7 @@ define(['exports', 'aurelia-binding', 'aurelia-dependency-injection', 'aurelia-t
return this._scriptPromise;

case 2:
this.widgetId = window.grecaptcha.render(this._element, { badge: this.badge, callback: this.callback, sitekey: this._config.get('siteKey'), size: this.size, theme: this.theme, type: this.type });
this.widgetId = window.grecaptcha.render(this._element, { badge: this.badge, callback: this.callback, 'expired-callback': this.expire, sitekey: this._config.get('siteKey'), size: this.size, theme: this.theme, type: this.type });

case 3:
case 'end':
Expand All @@ -134,11 +132,11 @@ define(['exports', 'aurelia-binding', 'aurelia-dependency-injection', 'aurelia-t
}, _callee, this);
}));

function _initialize() {
function bind() {
return _ref.apply(this, arguments);
}

return _initialize;
return bind;
}();

Recaptcha.prototype._loadApiScript = function _loadApiScript() {
Expand Down Expand Up @@ -172,22 +170,25 @@ define(['exports', 'aurelia-binding', 'aurelia-dependency-injection', 'aurelia-t
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'callback', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: null
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'size', [_aureliaTemplating.bindable], {
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'expire', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: null
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'size', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: function initializer() {
return 'normal';
}
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'theme', [_aureliaTemplating.bindable], {
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'theme', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: function initializer() {
return 'light';
}
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'type', [_aureliaTemplating.bindable], {
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'type', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: function initializer() {
return 'image';
}
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'widgetId', [_dec4], {
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'widgetId', [_dec4], {
enumerable: true,
initializer: null
})), _class2)) || _class) || _class) || _class);
Expand Down
4 changes: 2 additions & 2 deletions dist/commonjs/aurelia-plugins-google-recaptcha-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export declare class Recaptcha {
_scriptPromise: any;
badge: string;
callback: any;
expire: any;
size: string;
theme: string;
type: string;
widgetId: any;
constructor(element: any, config: any);
bind(): void;
_initialize(): Promise<void>;
bind(): Promise<void>;
_loadApiScript(): void;
}
35 changes: 18 additions & 17 deletions dist/commonjs/aurelia-plugins-google-recaptcha-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
});
exports.Recaptcha = undefined;

var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6;
var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;

var _aureliaBinding = require('aurelia-binding');

Expand Down Expand Up @@ -72,25 +72,23 @@ var Recaptcha = exports.Recaptcha = (_dec = (0, _aureliaTemplating.customElement

_initDefineProp(this, 'callback', _descriptor2, this);

_initDefineProp(this, 'size', _descriptor3, this);
_initDefineProp(this, 'expire', _descriptor3, this);

_initDefineProp(this, 'theme', _descriptor4, this);
_initDefineProp(this, 'size', _descriptor4, this);

_initDefineProp(this, 'type', _descriptor5, this);
_initDefineProp(this, 'theme', _descriptor5, this);

_initDefineProp(this, 'widgetId', _descriptor6, this);
_initDefineProp(this, 'type', _descriptor6, this);

_initDefineProp(this, 'widgetId', _descriptor7, this);

this._config = config;
this._element = element;
if (!this._config.get('siteKey')) return console.error('No sitekey has been specified.');
this._loadApiScript();
}

Recaptcha.prototype.bind = function bind() {
this._initialize();
};

Recaptcha.prototype._initialize = function () {
Recaptcha.prototype.bind = function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
Expand All @@ -100,7 +98,7 @@ var Recaptcha = exports.Recaptcha = (_dec = (0, _aureliaTemplating.customElement
return this._scriptPromise;

case 2:
this.widgetId = window.grecaptcha.render(this._element, { badge: this.badge, callback: this.callback, sitekey: this._config.get('siteKey'), size: this.size, theme: this.theme, type: this.type });
this.widgetId = window.grecaptcha.render(this._element, { badge: this.badge, callback: this.callback, 'expired-callback': this.expire, sitekey: this._config.get('siteKey'), size: this.size, theme: this.theme, type: this.type });

case 3:
case 'end':
Expand All @@ -110,11 +108,11 @@ var Recaptcha = exports.Recaptcha = (_dec = (0, _aureliaTemplating.customElement
}, _callee, this);
}));

function _initialize() {
function bind() {
return _ref.apply(this, arguments);
}

return _initialize;
return bind;
}();

Recaptcha.prototype._loadApiScript = function _loadApiScript() {
Expand Down Expand Up @@ -148,22 +146,25 @@ var Recaptcha = exports.Recaptcha = (_dec = (0, _aureliaTemplating.customElement
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'callback', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: null
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'size', [_aureliaTemplating.bindable], {
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'expire', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: null
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'size', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: function initializer() {
return 'normal';
}
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'theme', [_aureliaTemplating.bindable], {
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'theme', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: function initializer() {
return 'light';
}
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'type', [_aureliaTemplating.bindable], {
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'type', [_aureliaTemplating.bindable], {
enumerable: true,
initializer: function initializer() {
return 'image';
}
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'widgetId', [_dec4], {
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'widgetId', [_dec4], {
enumerable: true,
initializer: null
})), _class2)) || _class) || _class) || _class);
4 changes: 2 additions & 2 deletions dist/es2015/aurelia-plugins-google-recaptcha-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export declare class Recaptcha {
_scriptPromise: any;
badge: string;
callback: any;
expire: any;
size: string;
theme: string;
type: string;
widgetId: any;
constructor(element: any, config: any);
bind(): void;
_initialize(): Promise<void>;
bind(): Promise<void>;
_loadApiScript(): void;
}
29 changes: 15 additions & 14 deletions dist/es2015/aurelia-plugins-google-recaptcha-element.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6;
var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

Expand Down Expand Up @@ -59,13 +59,15 @@ export let Recaptcha = (_dec = customElement('aup-google-recaptcha'), _dec2 = no

_initDefineProp(this, 'callback', _descriptor2, this);

_initDefineProp(this, 'size', _descriptor3, this);
_initDefineProp(this, 'expire', _descriptor3, this);

_initDefineProp(this, 'theme', _descriptor4, this);
_initDefineProp(this, 'size', _descriptor4, this);

_initDefineProp(this, 'type', _descriptor5, this);
_initDefineProp(this, 'theme', _descriptor5, this);

_initDefineProp(this, 'widgetId', _descriptor6, this);
_initDefineProp(this, 'type', _descriptor6, this);

_initDefineProp(this, 'widgetId', _descriptor7, this);

this._config = config;
this._element = element;
Expand All @@ -74,15 +76,11 @@ export let Recaptcha = (_dec = customElement('aup-google-recaptcha'), _dec2 = no
}

bind() {
this._initialize();
}

_initialize() {
var _this = this;

return _asyncToGenerator(function* () {
yield _this._scriptPromise;
_this.widgetId = window.grecaptcha.render(_this._element, { badge: _this.badge, callback: _this.callback, sitekey: _this._config.get('siteKey'), size: _this.size, theme: _this.theme, type: _this.type });
_this.widgetId = window.grecaptcha.render(_this._element, { badge: _this.badge, callback: _this.callback, 'expired-callback': _this.expire, sitekey: _this._config.get('siteKey'), size: _this.size, theme: _this.theme, type: _this.type });
})();
}

Expand All @@ -109,22 +107,25 @@ export let Recaptcha = (_dec = customElement('aup-google-recaptcha'), _dec2 = no
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'callback', [bindable], {
enumerable: true,
initializer: null
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'size', [bindable], {
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'expire', [bindable], {
enumerable: true,
initializer: null
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'size', [bindable], {
enumerable: true,
initializer: function () {
return 'normal';
}
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'theme', [bindable], {
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'theme', [bindable], {
enumerable: true,
initializer: function () {
return 'light';
}
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'type', [bindable], {
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'type', [bindable], {
enumerable: true,
initializer: function () {
return 'image';
}
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'widgetId', [_dec4], {
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'widgetId', [_dec4], {
enumerable: true,
initializer: null
})), _class2)) || _class) || _class) || _class);
4 changes: 2 additions & 2 deletions dist/system/aurelia-plugins-google-recaptcha-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export declare class Recaptcha {
_scriptPromise: any;
badge: string;
callback: any;
expire: any;
size: string;
theme: string;
type: string;
widgetId: any;
constructor(element: any, config: any);
bind(): void;
_initialize(): Promise<void>;
bind(): Promise<void>;
_loadApiScript(): void;
}
Loading