-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[4.0] Recaptcha plugins javascript #26839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
build/media_source/plg_captcha_recaptcha_invisible/js/recaptcha.es6.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /** | ||
| * @package Joomla.JavaScript | ||
| * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved. | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
| Joomla = window.Joomla || {}; | ||
|
|
||
| ((window, document, Joomla) => { | ||
| Joomla.initReCaptchaInvisible = () => { | ||
| 'use strict'; | ||
|
|
||
| const elements = [].slice.call(document.getElementsByClassName('g-recaptcha')); | ||
| const optionKeys = ['sitekey', 'badge', 'size', 'tabindex', 'callback', 'expired-callback', 'error-callback']; | ||
|
|
||
| elements.forEach((element) => { | ||
| let options = {}; | ||
|
|
||
| if (element.dataset) { | ||
| options = element.dataset; | ||
| } else { | ||
| optionKeys.forEach((key) => { | ||
| const optionKeyFq = `data-${optionKeys[key]}`; | ||
|
|
||
| if (element.hasAttribute(optionKeyFq)) { | ||
| options[optionKeys[key]] = element.getAttribute(optionKeyFq); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| // Set the widget id of the recaptcha item | ||
| element.setAttribute( | ||
| 'data-recaptcha-widget-id', | ||
| window.grecaptcha.render(element, options), | ||
| ); | ||
|
|
||
| // Execute the invisible reCAPTCHA | ||
| window.grecaptcha.execute(element.getAttribute('data-recaptcha-widget-id')); | ||
| }); | ||
| }; | ||
| })(window, document, Joomla); |
37 changes: 0 additions & 37 deletions
37
build/media_source/plg_captcha_recaptcha_invisible/js/recaptcha.js
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
build/media_source/plg_captcha_recaptcha_invisible/js/recaptcha.min.js
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for an array slice call here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this script is targeting the front end thus is better to make sure that the es5 version will work down to IE9. Since there is the option to provide es5 scripts I think it would be better those scripts could live without the need for a polyfill...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE9? Haha ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that the ES5 scripts should reflect on the browsers that run on that version and IE9 is the oldest one that had pretty decent js engine. Also my idea here is to not put artificial barriers. Obviously I won't build a site with support for IE9 but all my deliverables are still fully functional on IE11. The idea of killing ES5 before IE11 is dead IMHO is a really bad one especially when there is a very well known and established practice that will fulfil both words (
type=module,nomodule)...