PluginProbe
Additional Terms Lite for WooCommerce / 1.5.2
Additional Terms Lite for WooCommerce v1.5.2
1.7.3 1.7.2.1 trunk 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.6.3 All 35 releases
woo-additional-terms / assets / js / admin.js

admin.js in Additional Terms Lite for WooCommerce 1.5.2, at assets/js/admin.js

54 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global jQuery, ajaxurl, watVars */
2
3 ( function ( wp, $ ) {
4 'use strict';
5
6 if ( ! wp ) {
7 return;
8 }
9
10 const watAdmin = {
11 cache() {
12 this.vars = {};
13 this.vars.rate = '#woo-additional-terms-dismiss-rate .notice-dismiss';
14 this.vars.rate += ', #woo-additional-terms-dismiss-rate .notice-dismiss-later';
15 this.vars.rated = '#woo-additional-terms-dismiss-rate .notice-dismiss-rated';
16 this.vars.upsell = '#woo-additional-terms-dismiss-upsell .notice-dismiss';
17 },
18
19 init() {
20 this.cache();
21 this.bindEvents();
22 },
23
24 bindEvents() {
25 $( document.body )
26 .on( 'click', this.vars.rate, ( event ) => this.handleOnDismiss( event, 'rate' ) )
27 .on( 'click', this.vars.rated, ( event ) => this.handleOnDismiss( event, 'rated' ) )
28 .on( 'click', this.vars.upsell, ( event ) => this.handleOnDismiss( event, 'upsell' ) );
29 },
30
31 handleOnDismiss( event, action ) {
32 const $this = $( event.target );
33
34 if ( ! $this.attr( 'href' ) ) {
35 event.preventDefault();
36 }
37
38 $.ajax( {
39 type: 'POST',
40 url: ajaxurl,
41 dataType: 'json',
42 data: {
43 _ajax_nonce: watVars.dismiss_nonce,
44 action: `woo_additional_terms_dismiss_${ action }`,
45 },
46 } ).always( () => {
47 $this.closest( 'div.notice:visible' ).slideUp();
48 } );
49 },
50 };
51
52 watAdmin.init();
53 } )( window.wp, jQuery );
54