Skip to content

Commit 145c606

Browse files
Add option to not use audio
1 parent c266e1e commit 145c606

3 files changed

Lines changed: 30 additions & 17 deletions

File tree

visualcaptcha.angular.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,12 @@ define( 'visualcaptcha/core',[],function() {
560560

561561
// Check if the device supports the HTML5 audio element, for accessibility
562562
// I'm using an IIFE just because I don't want audioElement to be in the rest of the scope
563-
_supportsAudio = function() {
563+
_supportsAudio = function(config) {
564+
565+
if (!config.allowAudio) {
566+
return false;
567+
}
568+
564569
var audioElement,
565570
support = false;
566571

@@ -587,7 +592,8 @@ define( 'visualcaptcha/core',[],function() {
587592
imageFieldName,
588593
audioFieldName,
589594
namespace,
590-
namespaceFieldName;
595+
namespaceFieldName,
596+
supportsAudio;
591597

592598
refresh = function() {
593599
return _refresh.call( this, config );
@@ -637,6 +643,10 @@ define( 'visualcaptcha/core',[],function() {
637643
return config.namespaceFieldName;
638644
};
639645

646+
supportsAudio = function() {
647+
return _supportsAudio.call(this, config);
648+
};
649+
640650
core = {
641651
refresh: refresh,
642652
isLoading: isLoading,
@@ -651,7 +661,7 @@ define( 'visualcaptcha/core',[],function() {
651661
namespace: namespace,
652662
namespaceFieldName: namespaceFieldName,
653663
isRetina: _isRetina,
654-
supportsAudio: _supportsAudio
664+
supportsAudio: supportsAudio
655665
};
656666

657667
// Load the data if auto refresh is enabled
@@ -718,6 +728,7 @@ define('visualcaptcha/config',[ 'visualcaptcha/xhr-request' ], function( xhrRequ
718728
imageFieldName: '',
719729
imageName: '',
720730
imageValues: [],
731+
allowAudio: false,
721732
/* CALLBACKS */
722733
callbacks: {},
723734
_loading: function() {},
@@ -904,6 +915,9 @@ define( 'visualcaptcha/helpers',[],function() {
904915
};
905916

906917
_bindClick = function( element, callback ) {
918+
if (element === undefined) {
919+
return false;
920+
}
907921
if ( Array.isArray( element ) ) {
908922
for ( var i = 0; i < element.length; i++ ) {
909923
_bindClick( element[ i ], callback );
@@ -962,7 +976,7 @@ define( 'visualcaptcha/templates',[],function() {
962976

963977
btnRefresh =
964978
'<div class="visualCaptcha-refresh-button">' +
965-
'<a href="#"><img src="{path}refresh{retinaExtra}.png" title="{refreshTitle}" alt="{refreshAlt}" /></a>' +
979+
'<a href="#"><i class="fas fa-redo"></i></a>' +
966980
'</div>';
967981

968982
string =

visualcaptcha.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

visualcaptcha.src.css

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,16 @@
7676
.visualCaptcha-possibilities {
7777
vertical-align: middle;
7878
}
79-
@media only screen and (min-width: 750px) {
80-
.visualCaptcha-possibilities {
81-
margin-right: 15px;
82-
}
83-
}
8479
.visualCaptcha-possibilities .img {
85-
padding: 4px;
80+
padding: 2px;
81+
margin: 0 6px;
8682
border: 1px solid #ffffff;
8783
display: inline-block;
8884
}
8985
@media only screen and (min-width: 750px) {
9086
.visualCaptcha-possibilities .img {
91-
padding: 10px;
87+
padding: 2px;
88+
margin: 0 8px;
9289
border: 3px solid #ffffff;
9390
}
9491
}
@@ -115,15 +112,17 @@
115112
}
116113
.visualCaptcha-possibilities .visualCaptcha-selected {
117114
background-color: #c1f7e8;
118-
-webkit-border-radius: 4px;
119-
-moz-border-radius: 4px;
120-
border-radius: 4px;
121-
padding: 4px;
115+
-webkit-border-radius: 8px;
116+
-moz-border-radius: 8px;
117+
border-radius: 8px;
118+
padding: 2px;
119+
margin: 0 6px;
122120
border: 1px dashed #099a9f;
123121
}
124122
@media only screen and (min-width: 750px) {
125123
.visualCaptcha-possibilities .visualCaptcha-selected {
126-
padding: 10px;
124+
padding: 2px;
125+
margin: 0 8px;
127126
border: 3px dashed #099a9f;
128127
}
129128
}

0 commit comments

Comments
 (0)