vue-programmatic-invisible-google-recaptcha
Advanced tools
Comparing version 2.0.0 to 2.0.1
// rollup.config.js | ||
// https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html | ||
import vue from 'rollup-plugin-vue'; | ||
import buble from 'rollup-plugin-buble'; | ||
import uglify from 'rollup-plugin-uglify-es'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import minimist from 'minimist'; | ||
@@ -19,2 +22,8 @@ | ||
plugins: [ | ||
commonjs(), | ||
resolve({ | ||
jsnext: true, | ||
main: true, | ||
browser: true, | ||
}), | ||
vue({ | ||
@@ -31,5 +40,5 @@ css: true, | ||
if (argv.format === 'iife') { | ||
config.plugins.push(uglify()); | ||
config.plugins.push(terser()); | ||
} | ||
export default config; |
# CHANGELOG.md | ||
## 2.0.1 (2019-02-19) | ||
- Adjusting iife build | ||
## 2.0.0 (2018-11-16) | ||
@@ -4,0 +8,0 @@ |
@@ -1,1 +0,144 @@ | ||
var VueProgrammaticInvisibleGoogleRecaptcha=function(e){"use strict";function t(e){t.installed||(t.installed=!0,e.component("VueProgrammaticInvisibleGoogleRecaptcha",a))}!function(){if("undefined"!=typeof document){var e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style"),a=".grecaptcha-badge { z-index: 1000; } .g-recaptcha--left .grecaptcha-badge { width: 70px !important; overflow: hidden; transition: all 0.2s ease !important; left: 0px; } .g-recaptcha--left .grecaptcha-badge:hover { width: 256px !important; } @media (max-width: 992px) { .g-recaptcha--mobile-hidden .grecaptcha-badge { display: none; } } @media (min-width: 992px) { .g-recaptcha--desktop-hidden .grecaptcha-badge { display: none; } } ";t.type="text/css",t.styleSheet?t.styleSheet.cssText=a:t.appendChild(document.createTextNode(a)),e.appendChild(t)}}();var a={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{staticClass:"g-recaptcha",class:e.styleClassObject,attrs:{id:e.elementId,"data-sitekey":e.sitekey}})},staticRenderFns:[],name:"vue-programmatic-invisible-google-recaptcha",props:{sitekey:{type:String,required:!0},elementId:{type:String,required:!0},showBadgeMobile:{type:Boolean,default:!0},showBadgeDesktop:{type:Boolean,default:!0},badgePosition:{type:String}},data:function(){return{gAssignedId:null,captchaReady:!1,checkInterval:null,checkIntervalRunCount:0}},computed:{styleClassObject:function(){return{"g-recaptcha--left":"left"===this.badgePosition,"g-recaptcha--mobile-hidden":!this.showBadgeMobile,"g-recaptcha--desktop-hidden":!this.showBadgeDesktop}}},methods:{execute:function(){window.grecaptcha.execute(this.gAssignedId)},reset:function(){window.grecaptcha.reset(this.gAssignedId)},callback:function(e){this.$emit("recaptcha-callback",e),this.reset()},render:function(){var e=this;this.gAssignedId=window.grecaptcha.render(this.elementId,{sitekey:this.sitekey,size:"invisible",callback:function(t){e.callback(t)},"expired-callback":function(){e.reset()}})},init:function(){var e=this;this.checkInterval=setInterval(function(){e.checkIntervalRunCount++,window.grecaptcha&&window.grecaptcha.hasOwnProperty("render")&&(e.captchaReady=!0)},1e3)}},watch:{captchaReady:function(e){e&&(clearInterval(this.checkInterval),this.render())}},mounted:function(){this.init()}},n={install:t},i=null;return"undefined"!=typeof window?i=window.Vue:"undefined"!=typeof global&&(i=global.Vue),i&&i.use(n),e.install=t,e.default=a,e}({}); | ||
var VueProgrammaticInvisibleGoogleRecaptcha = (function (exports) { | ||
'use strict'; | ||
(function(){ if(typeof document !== 'undefined'){ var head=document.head||document.getElementsByTagName('head')[0], style=document.createElement('style'), css=".grecaptcha-badge { z-index: 1000; } .g-recaptcha--left .grecaptcha-badge { width: 70px !important; overflow: hidden; transition: all 0.2s ease !important; left: 0px; } .g-recaptcha--left .grecaptcha-badge:hover { width: 256px !important; } @media (max-width: 992px) { .g-recaptcha--mobile-hidden .grecaptcha-badge { display: none; } } @media (min-width: 992px) { .g-recaptcha--desktop-hidden .grecaptcha-badge { display: none; } } "; style.type='text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); } })(); | ||
var component = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"g-recaptcha",class:_vm.styleClassObject,attrs:{"id":_vm.elementId,"data-sitekey":_vm.sitekey}})},staticRenderFns: [], | ||
name: 'vue-programmatic-invisible-google-recaptcha', | ||
props: { | ||
sitekey: { | ||
type: String, | ||
required: true | ||
}, | ||
elementId: { | ||
type: String, | ||
required: true | ||
}, | ||
showBadgeMobile: { | ||
type: Boolean, | ||
default: true | ||
}, | ||
showBadgeDesktop: { | ||
type: Boolean, | ||
default: true | ||
}, | ||
badgePosition: { | ||
type: String | ||
} | ||
}, | ||
data: function data () { | ||
return { | ||
gAssignedId: null, | ||
captchaReady: false, | ||
checkInterval: null, | ||
checkIntervalRunCount: 0 | ||
} | ||
}, | ||
computed: { | ||
styleClassObject: function () { | ||
return { | ||
'g-recaptcha--left': (this.badgePosition === 'left'), | ||
'g-recaptcha--mobile-hidden': (!this.showBadgeMobile), | ||
'g-recaptcha--desktop-hidden': (!this.showBadgeDesktop) | ||
} | ||
} | ||
}, | ||
methods: { | ||
execute: function execute () { | ||
window.grecaptcha.execute(this.gAssignedId); | ||
}, | ||
reset: function reset () { | ||
window.grecaptcha.reset(this.gAssignedId); | ||
}, | ||
callback: function callback (recaptchaToken) { | ||
// Emit an event called recaptchaCallback with the recaptchaToken as payload | ||
this.$emit('recaptcha-callback', recaptchaToken); | ||
// Reset the recaptcha widget so you can execute it again | ||
this.reset(); | ||
}, | ||
render: function render () { | ||
var this$1 = this; | ||
this.gAssignedId = window.grecaptcha.render(this.elementId, { | ||
sitekey: this.sitekey, | ||
size: 'invisible', | ||
// the callback executed when the user solve the recaptcha | ||
'callback': function (recaptchaToken) { | ||
this$1.callback(recaptchaToken); | ||
}, | ||
'expired-callback': function () { | ||
this$1.reset(); | ||
} | ||
}); | ||
}, | ||
init: function init() { | ||
var this$1 = this; | ||
// render the recaptcha widget when the component is mounted | ||
// we'll watch the captchaReady value in order to | ||
this.checkInterval = setInterval(function () { | ||
this$1.checkIntervalRunCount++; | ||
if (window.grecaptcha && window.grecaptcha.hasOwnProperty('render')){ | ||
this$1.captchaReady = true; | ||
} | ||
}, 1000); | ||
} | ||
}, | ||
watch: { | ||
captchaReady: function(data) { | ||
if (data) { | ||
clearInterval(this.checkInterval); | ||
this.render(); | ||
} | ||
} | ||
}, | ||
mounted: function mounted () { | ||
// Initialize the recaptcha | ||
this.init(); | ||
} | ||
} | ||
// Import vue component | ||
// install function executed by Vue.use() | ||
function install(Vue) { | ||
if (install.installed) { return; } | ||
install.installed = true; | ||
Vue.component('VueProgrammaticInvisibleGoogleRecaptcha', component); | ||
} | ||
// Create module definition for Vue.use() | ||
var plugin = { | ||
install: install, | ||
}; | ||
// To auto-install when vue is found | ||
var GlobalVue = null; | ||
if (typeof window !== 'undefined') { | ||
GlobalVue = window.Vue; | ||
} else if (typeof global !== 'undefined') { | ||
GlobalVue = global.Vue; | ||
} | ||
if (GlobalVue) { | ||
GlobalVue.use(plugin); | ||
} | ||
// It's possible to expose named exports when writing components that can | ||
// also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo'; | ||
// export const RollupDemoDirective = component; | ||
exports.install = install; | ||
exports.default = component; | ||
return exports; | ||
}({})); |
{ | ||
"name": "vue-programmatic-invisible-google-recaptcha", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "A simple invisible Google reCAPTCHA component focused solely on programmatic invocation.", | ||
@@ -54,4 +54,5 @@ "author": "John Datserakis <johndatserakis@gmail.com>", | ||
"rollup-plugin-buble": "^0.19.2", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-uglify-es": "0.0.1", | ||
"rollup-plugin-terser": "^4.0.3", | ||
"rollup-plugin-vue": "^3.0.0", | ||
@@ -58,0 +59,0 @@ "sass-loader": "^7.0.1", |
1025611
1030
26