PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.3.6.1
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.3.6.1
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / assets / js / options.js

options.js in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.3.6.1, at assets/js/options.js

98 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(function($){
2 /*
3 * Process an API key check validity.
4 */
5 var busy = false,
6 xhr = false;
7
8 $('#imagify-settings #api_key').blur(function(){
9 var obj = $(this),
10 value = obj.val();
11
12 if( $.trim(value) === '' ) {
13 return false;
14 }
15
16 if( $('#check_api_key').val() === value ) {
17 $('#imagify-check-api-container').html('<span class="dashicons dashicons-yes"></span> ' + imagify.ValidApiKeyText);
18 return false;
19 }
20
21 if ( true === busy ) {
22 xhr.abort();
23 } else {
24 $('#imagify-check-api-container').remove();
25 obj.after( '<span id="imagify-check-api-container"><span class="imagify-spinner"></span>' + imagify.waitApiKeyCheckText + "</span>" );
26 }
27
28 busy = true;
29
30 xhr = $.get(ajaxurl+"?action=imagify_check_api_key_validity&api_key="+obj.val()+"&imagifycheckapikeynonce="+$('#imagifycheckapikeynonce').val())
31 .done(function(response){
32 if( !response.success ) {
33 $('#imagify-check-api-container').html( '<span class="dashicons dashicons-no"></span> ' + response.data);
34 } else {
35 $('#imagify-check-api-container').remove();
36 swal({
37 title: imagify.ApiKeyCheckSuccessTitle,
38 text: imagify.ApiKeyCheckSuccessText,
39 type: "success",
40 customClass: "imagify-sweet-alert"
41 },
42 function(){
43 location.reload();
44 });
45 }
46
47 busy = false;
48 });
49 });
50
51 /**
52 * Check the boxes by clicking "labels" (aria-describedby items)
53 */
54 $('.imagify-options-line').css('cursor', 'pointer').on('click', function(e){
55 if ( e.target.nodeName === 'INPUT' ) {
56 return;
57 }
58 $('input[aria-describedby="' + $(this).attr('id') + '"]').trigger('click');
59 return false;
60 });
61
62 $('.imagify-settings th span').on('click', function(e){
63 if ( $(this).parent().next('td').find('input:checkbox').length === 1 ) {
64 $(this).parent().next('td').find('input:checkbox').trigger('click');
65 }
66 })
67
68 /**
69 * Auto check on options-line input value change
70 */
71 $('.imagify-options-line').find('input').on('change focus', function(){
72 var $checkbox = $(this).closest('.imagify-options-line').prev('label').prev('input');
73 if ( ! $checkbox[0].checked ) {
74 $checkbox.prop('checked', true);
75 }
76 });
77
78 /**
79 * Imagify Backup alert
80 */
81 $('.imagify-settings-section').find('#backup').on('change', function(){
82 if ( ! $(this).is(':checked') ) {
83 var $_this = $(this);
84 swal({
85 title: imagifyOptions.noBackupTitle,
86 text: imagifyOptions.noBackupText,
87 type: "info",
88 customClass: "imagify-sweet-alert",
89 showCancelButton: true
90 }, function(isConfirm){
91 if ( ! isConfirm ) {
92 $_this.prop('checked', true);
93 }
94 });
95 }
96 });
97
98 });