PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
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 / notices.js

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

128 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // All notices =====================================================================================
2 (function($, d, w, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names
3
4 /**
5 * Close an Imagify notice.
6 */
7 $(document).on('click', '.imagify-notice-dismiss', function ( e ) {
8 var $this = $( this ),
9 $parent = $this.parents( '.imagify-welcome, .imagify-notice, .imagify-rkt-notice, .imagify-upsell, .imagify-upsell-admin-bar' ),
10 href = $this.attr( 'href' );
11
12 e.preventDefault();
13
14 // Hide the notice.
15 $parent.fadeTo( 100 , 0, function() {
16 $( this ).slideUp( 100, function() {
17 $( this ).remove();
18 } );
19 } );
20
21 // Save the dismiss notice.
22 $.get( href.replace( 'admin-post.php', 'admin-ajax.php' ) );
23 } );
24
25 } )(jQuery, document, window);
26
27
28 // The "welcome steps" notice + "wrong API key" notice =============================================
29 (function($, d, w, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names
30
31 /**
32 * 1. Create a new Imagify account.
33 */
34 $( '#imagify-signup' ).on( 'click.imagify', function( e ) {
35 e.preventDefault();
36
37 // Display the sign up form.
38 swal( {
39 title: imagifyNotices.labels.signupTitle,
40 html: imagifyNotices.labels.signupText,
41 confirmButtonText: imagifyNotices.labels.signupConfirmButtonText,
42 input: 'email',
43 padding: 0,
44 showLoaderOnConfirm: true,
45 customClass: 'imagify-sweet-alert imagify-sweet-alert-signup',
46 inputValidator: function( inputValue ) {
47 return new Promise( function( resolve, reject ) {
48 if ( String( inputValue ).trim() === '' || ! inputValue ) {
49 reject( imagifyNotices.labels.signupErrorEmptyEmail );
50 } else {
51 resolve();
52 }
53 } );
54 },
55 preConfirm: function( inputValue ) {
56 return new Promise( function( resolve, reject ) {
57 setTimeout( function() {
58 $.get( ajaxurl + w.imagify.concat + 'action=imagify_signup&email=' + inputValue + '&imagifysignupnonce=' + $( '#imagifysignupnonce' ).val() )
59 .done( function( response ) {
60 if ( ! response.success ) {
61 reject( response.data );
62 } else {
63 resolve();
64 }
65 } );
66 }, 2000 );
67 } );
68 },
69 } ).then( function() {
70 swal( {
71 title: imagifyNotices.labels.signupSuccessTitle,
72 html: imagifyNotices.labels.signupSuccessText,
73 type: 'success',
74 padding: 0,
75 customClass: 'imagify-sweet-alert'
76 } );
77 } );
78 } );
79
80 /**
81 * 2. Check and save the Imagify API Key.
82 */
83 $( '#imagify-save-api-key' ).on( 'click.imagify', function( e ) {
84 e.preventDefault();
85
86 // Display the API key form.
87 swal( {
88 title: imagifyNotices.labels.saveApiKeyTitle,
89 html: imagifyNotices.labels.saveApiKeyText,
90 confirmButtonText: imagifyNotices.labels.saveApiKeyConfirmButtonText,
91 input: 'text',
92 padding: 0,
93 showLoaderOnConfirm: true,
94 customClass: 'imagify-sweet-alert imagify-sweet-alert-signup',
95 inputValidator: function( inputValue ) {
96 return new Promise( function( resolve, reject ) {
97 if ( String( inputValue ).trim() === '' || ! inputValue ) {
98 reject( imagifyNotices.labels.ApiKeyErrorEmpty );
99 } else {
100 resolve();
101 }
102 } );
103 },
104 preConfirm: function( inputValue ) {
105 return new Promise( function( resolve, reject ) {
106 $.get( ajaxurl + w.imagify.concat + 'action=imagify_check_api_key_validity&api_key=' + inputValue + '&imagifycheckapikeynonce=' + $( '#imagifycheckapikeynonce' ).val() )
107 .done( function( response ) {
108 if ( ! response.success ) {
109 reject( response.data );
110 } else {
111 resolve();
112 }
113 } );
114 } );
115 },
116 } ).then( function() {
117 swal( {
118 title: imagifyNotices.labels.ApiKeyCheckSuccessTitle,
119 html: imagifyNotices.labels.ApiKeyCheckSuccessText,
120 type: 'success',
121 padding: 0,
122 customClass: 'imagify-sweet-alert'
123 } );
124 } );
125 } );
126
127 } )(jQuery, document, window);
128