Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
media/plg_captcha_recaptcha/js/recaptcha.js (#112)
Browse files Browse the repository at this point in the history
* converted to es6

* updated code to support IE

* compile es6
  • Loading branch information
kasvith authored and dneukirchen committed Apr 1, 2018
1 parent df1ba80 commit 25642a5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
22 changes: 22 additions & 0 deletions media/plg_captcha_recaptcha/js/recaptcha.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @package Joomla.JavaScript
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

window.JoomlaInitReCaptcha2 = () => {
'use strict';

const itemNodes = document.getElementsByClassName('g-recaptcha');
const items = [].slice.call(itemNodes);
items.forEach((item) => {
const options = item.dataset ? item.dataset : {
sitekey: item.getAttribute('data-sitekey'),
theme: item.getAttribute('data-theme'),
size: item.getAttribute('data-size'),
};

/* global grecaptcha */
grecaptcha.render(item, options);
});
};
39 changes: 23 additions & 16 deletions media/plg_captcha_recaptcha/js/recaptcha.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
/**
* @package Joomla.JavaScript
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
* @package Joomla.JavaScript
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

window.JoomlaInitReCaptcha2 = function() {
'use strict';
window.JoomlaInitReCaptcha2 = function () {
'use strict';

var itemNodes = document.getElementsByClassName('g-recaptcha');
var items = [].slice.call(itemNodes);
items.forEach(function (item) {
var options = item.dataset ? item.dataset : {
sitekey: item.getAttribute('data-sitekey'),
theme: item.getAttribute('data-theme'),
size: item.getAttribute('data-size')
};

var items = document.getElementsByClassName('g-recaptcha'), item, options;
for (var i = 0, l = items.length; i < l; i++) {
item = items[i];
options = item.dataset ? item.dataset : {
sitekey: item.getAttribute('data-sitekey'),
theme: item.getAttribute('data-theme'),
size: item.getAttribute('data-size')
};
grecaptcha.render(item, options);
}
}
/* global grecaptcha */
grecaptcha.render(item, options);
});
};

0 comments on commit 25642a5

Please sign in to comment.