From e8bc097edfd8403817348f1847c05c9dd45e0190 Mon Sep 17 00:00:00 2001 From: Ismael Ambrosi Date: Wed, 9 May 2018 15:43:11 -0300 Subject: [PATCH] [release] --- bower.json | 2 +- package.json | 2 +- release/angular-recaptcha.js | 10 +++++++--- release/angular-recaptcha.min.js | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index 3c55b33..b522b78 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-recaptcha", - "version": "4.1.4", + "version": "4.1.5", "keywords": ["angular", "captcha", "recaptcha", "vividcortex", "human", "form", "validation", "signup", "security", "login"], "main": "release/angular-recaptcha.js", "ignore": [ diff --git a/package.json b/package.json index ecacb1e..1963897 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-recaptcha", - "version": "4.1.4", + "version": "4.1.5", "description": "An AngularJS module to ease usage of reCaptcha inside a form", "author": "VividCortex", "license": "MIT", diff --git a/release/angular-recaptcha.js b/release/angular-recaptcha.js index 333e931..bd0bb3e 100644 --- a/release/angular-recaptcha.js +++ b/release/angular-recaptcha.js @@ -1,5 +1,5 @@ /** - * @license angular-recaptcha build:2018-05-03 + * @license angular-recaptcha build:2018-05-09 * https://github.com/vividcortex/angular-recaptcha * Copyright (c) 2018 VividCortex **/ @@ -152,14 +152,18 @@ } } + function isRenderFunctionAvailable() { + return ng.isFunction(($window.grecaptcha || {}).render); + } + // Check if grecaptcha.render is not defined already. - if (ng.isFunction(($window.grecaptcha || {}).render)) { + if (isRenderFunctionAvailable()) { callback(); } else if ($window.document.querySelector('script[src^="https://www.google.com/recaptcha/api.js"]')) { // wait for script to be loaded. var intervalWait = $interval(function() { - if (ng.isDefined($window.grecaptcha)) { + if (isRenderFunctionAvailable()) { $interval.cancel(intervalWait); callback(); } diff --git a/release/angular-recaptcha.min.js b/release/angular-recaptcha.min.js index e86963f..3cb7886 100644 --- a/release/angular-recaptcha.min.js +++ b/release/angular-recaptcha.min.js @@ -1,8 +1,8 @@ /** - * @license angular-recaptcha build:2018-05-03 + * @license angular-recaptcha build:2018-05-09 * https://github.com/vividcortex/angular-recaptcha * Copyright (c) 2018 VividCortex **/ -!function(a){"use strict";a.module("vcRecaptcha",[])}(angular),function(a){"use strict";function b(){throw new Error('You need to set the "key" attribute to your public reCaptcha key. If you don\'t have a key, please get one from https://www.google.com/recaptcha/admin/create')}a.module("vcRecaptcha").provider("vcRecaptchaService",function(){var c=this,d={};c.onLoadFunctionName="vcRecaptchaApiLoaded",c.setDefaults=function(b){a.copy(b,d)},c.setSiteKey=function(a){d.key=a},c.setTheme=function(a){d.theme=a},c.setStoken=function(a){d.stoken=a},c.setSize=function(a){d.size=a},c.setType=function(a){d.type=a},c.setLang=function(a){d.lang=a},c.setBadge=function(a){d.badge=a},c.setOnLoadFunctionName=function(a){c.onLoadFunctionName=a},c.$get=["$rootScope","$window","$q","$document","$interval",function(e,f,g,h,i){function j(){return l?g.when(l):n}function k(){if(!l)throw new Error("reCaptcha has not been loaded yet.")}var l,m=g.defer(),n=m.promise,o={};f.vcRecaptchaApiLoadedCallback=f.vcRecaptchaApiLoadedCallback||[];var p=function(){l=f.grecaptcha,m.resolve(l)};if(f.vcRecaptchaApiLoadedCallback.push(p),f[c.onLoadFunctionName]=function(){f.vcRecaptchaApiLoadedCallback.forEach(function(a){a()})},a.isFunction((f.grecaptcha||{}).render))p();else if(f.document.querySelector('script[src^="https://www.google.com/recaptcha/api.js"]'))var q=i(function(){a.isDefined(f.grecaptcha)&&(i.cancel(q),p())},25);else{var r=f.document.createElement("script");r.async=!0,r.defer=!0,r.src="https://www.google.com/recaptcha/api.js?onload="+c.onLoadFunctionName+"&render=explicit",h.find("body")[0].appendChild(r)}return{create:function(a,c){return c.sitekey=c.key||d.key,c.theme=c.theme||d.theme,c.stoken=c.stoken||d.stoken,c.size=c.size||d.size,c.type=c.type||d.type,c.hl=c.lang||d.lang,c.badge=c.badge||d.badge,c.sitekey||b(),j().then(function(b){var d=b.render(a,c);return o[d]=a,d})},reload:function(a){k(),l.reset(a),e.$broadcast("reCaptchaReset",a)},execute:function(a){k(),l.execute(a)},useLang:function(a,b){var c=o[a];if(!c)throw new Error("reCaptcha Widget ID not exists",a);var d=c.querySelector("iframe");if(!b)return d&&d.src&&/[?&]hl=\w+/.test(d.src)?d.src.replace(/.+[?&]hl=(\w+)([^\w].+)?/,"$1"):null;if(d&&d.src){var e=d.src;/[?&]hl=/.test(e)?e=e.replace(/([?&]hl=)\w+/,"$1"+b):e+=(-1===e.indexOf("?")?"?":"&")+"hl="+b,d.src=e}},getResponse:function(a){return k(),l.getResponse(a)},getInstance:function(a){return o[a]},destroy:function(a){delete o[a]}}}]})}(angular),function(a){"use strict";a.module("vcRecaptcha").directive("vcRecaptcha",["$document","$timeout","vcRecaptchaService",function(b,c,d){return{restrict:"A",require:"?^^form",scope:{response:"=?ngModel",key:"=?",stoken:"=?",theme:"=?",size:"=?",type:"=?",lang:"=?",badge:"=?",tabindex:"=?",required:"=?",onCreate:"&",onSuccess:"&",onExpire:"&"},link:function(e,f,g,h){function i(){h&&h.$setValidity("recaptcha",null),l()}function j(){c(function(){e.response="",k(),e.onExpire({widgetId:e.widgetId})})}function k(){h&&h.$setValidity("recaptcha",!1===e.required?null:Boolean(e.response))}function l(){d.destroy(e.widgetId),a.element(b[0].querySelectorAll(".pls-container")).parent().remove()}e.widgetId=null,h&&a.isDefined(g.required)&&e.$watch("required",k);var m=e.$watch("key",function(b){var h=function(a){c(function(){e.response=a,k(),e.onSuccess({response:a,widgetId:e.widgetId})})};d.create(f[0],{callback:h,key:b,stoken:e.stoken||g.stoken||null,theme:e.theme||g.theme||null,type:e.type||g.type||null,lang:e.lang||g.lang||null,tabindex:e.tabindex||g.tabindex||null,size:e.size||g.size||null,badge:e.badge||g.badge||null,"expired-callback":j}).then(function(b){k(),e.widgetId=b,e.onCreate({widgetId:b}),e.$on("$destroy",i),e.$on("reCaptchaReset",function(c,d){(a.isUndefined(d)||b===d)&&(e.response="",k())})}),m()})}}}])}(angular); \ No newline at end of file +!function(a){"use strict";a.module("vcRecaptcha",[])}(angular),function(a){"use strict";function b(){throw new Error('You need to set the "key" attribute to your public reCaptcha key. If you don\'t have a key, please get one from https://www.google.com/recaptcha/admin/create')}a.module("vcRecaptcha").provider("vcRecaptchaService",function(){var c=this,d={};c.onLoadFunctionName="vcRecaptchaApiLoaded",c.setDefaults=function(b){a.copy(b,d)},c.setSiteKey=function(a){d.key=a},c.setTheme=function(a){d.theme=a},c.setStoken=function(a){d.stoken=a},c.setSize=function(a){d.size=a},c.setType=function(a){d.type=a},c.setLang=function(a){d.lang=a},c.setBadge=function(a){d.badge=a},c.setOnLoadFunctionName=function(a){c.onLoadFunctionName=a},c.$get=["$rootScope","$window","$q","$document","$interval",function(e,f,g,h,i){function j(){return m?g.when(m):o}function k(){if(!m)throw new Error("reCaptcha has not been loaded yet.")}function l(){return a.isFunction((f.grecaptcha||{}).render)}var m,n=g.defer(),o=n.promise,p={};f.vcRecaptchaApiLoadedCallback=f.vcRecaptchaApiLoadedCallback||[];var q=function(){m=f.grecaptcha,n.resolve(m)};if(f.vcRecaptchaApiLoadedCallback.push(q),f[c.onLoadFunctionName]=function(){f.vcRecaptchaApiLoadedCallback.forEach(function(a){a()})},l())q();else if(f.document.querySelector('script[src^="https://www.google.com/recaptcha/api.js"]'))var r=i(function(){l()&&(i.cancel(r),q())},25);else{var s=f.document.createElement("script");s.async=!0,s.defer=!0,s.src="https://www.google.com/recaptcha/api.js?onload="+c.onLoadFunctionName+"&render=explicit",h.find("body")[0].appendChild(s)}return{create:function(a,c){return c.sitekey=c.key||d.key,c.theme=c.theme||d.theme,c.stoken=c.stoken||d.stoken,c.size=c.size||d.size,c.type=c.type||d.type,c.hl=c.lang||d.lang,c.badge=c.badge||d.badge,c.sitekey||b(),j().then(function(b){var d=b.render(a,c);return p[d]=a,d})},reload:function(a){k(),m.reset(a),e.$broadcast("reCaptchaReset",a)},execute:function(a){k(),m.execute(a)},useLang:function(a,b){var c=p[a];if(!c)throw new Error("reCaptcha Widget ID not exists",a);var d=c.querySelector("iframe");if(!b)return d&&d.src&&/[?&]hl=\w+/.test(d.src)?d.src.replace(/.+[?&]hl=(\w+)([^\w].+)?/,"$1"):null;if(d&&d.src){var e=d.src;/[?&]hl=/.test(e)?e=e.replace(/([?&]hl=)\w+/,"$1"+b):e+=(-1===e.indexOf("?")?"?":"&")+"hl="+b,d.src=e}},getResponse:function(a){return k(),m.getResponse(a)},getInstance:function(a){return p[a]},destroy:function(a){delete p[a]}}}]})}(angular),function(a){"use strict";a.module("vcRecaptcha").directive("vcRecaptcha",["$document","$timeout","vcRecaptchaService",function(b,c,d){return{restrict:"A",require:"?^^form",scope:{response:"=?ngModel",key:"=?",stoken:"=?",theme:"=?",size:"=?",type:"=?",lang:"=?",badge:"=?",tabindex:"=?",required:"=?",onCreate:"&",onSuccess:"&",onExpire:"&"},link:function(e,f,g,h){function i(){h&&h.$setValidity("recaptcha",null),l()}function j(){c(function(){e.response="",k(),e.onExpire({widgetId:e.widgetId})})}function k(){h&&h.$setValidity("recaptcha",!1===e.required?null:Boolean(e.response))}function l(){d.destroy(e.widgetId),a.element(b[0].querySelectorAll(".pls-container")).parent().remove()}e.widgetId=null,h&&a.isDefined(g.required)&&e.$watch("required",k);var m=e.$watch("key",function(b){var h=function(a){c(function(){e.response=a,k(),e.onSuccess({response:a,widgetId:e.widgetId})})};d.create(f[0],{callback:h,key:b,stoken:e.stoken||g.stoken||null,theme:e.theme||g.theme||null,type:e.type||g.type||null,lang:e.lang||g.lang||null,tabindex:e.tabindex||g.tabindex||null,size:e.size||g.size||null,badge:e.badge||g.badge||null,"expired-callback":j}).then(function(b){k(),e.widgetId=b,e.onCreate({widgetId:b}),e.$on("$destroy",i),e.$on("reCaptchaReset",function(c,d){(a.isUndefined(d)||b===d)&&(e.response="",k())})}),m()})}}}])}(angular); \ No newline at end of file