1
- /*global jQuery, document */
2
- ( function ( $ ) {
3
- 'use strict' ;
4
-
5
- $ . redux = $ . redux || { } ;
6
-
7
- $ ( document ) . ready ( function ( ) {
8
- $ . redux . edd ( ) ;
9
- } ) ;
10
-
11
- $ . redux . edd = function ( ) {
12
-
13
- jQuery ( '.redux-edd-input' ) . change ( function ( ) {
14
- jQuery ( this ) . parent ( ) . find ( '.redux-edd-status' ) . val ( '' ) ;
15
- } ) ;
16
- jQuery ( document ) . on ( "click" , ".redux-EDDAction" , function ( e ) {
17
- e . preventDefault ( ) ;
18
- var parent = jQuery ( this ) . parents ( '.redux-container-edd_license:first' ) ;
19
- var id = jQuery ( this ) . attr ( 'data-id' ) ;
20
-
21
- var theData = { } ;
22
- parent . find ( '.redux-edd' ) . each ( function ( ) {
23
- theData [ jQuery ( this ) . attr ( 'id' ) . replace ( id + '-' , '' ) ] = jQuery ( this ) . val ( ) ;
24
- } ) ;
25
- theData [ 'edd_action' ] = jQuery ( this ) . attr ( 'data-edd_action' ) ;
26
- theData [ 'opt_name' ] = redux_opts . opt_name ;
27
-
28
- jQuery . post (
29
- ajaxurl , {
30
- 'action' : 'redux_edd_' + redux_opts . opt_name + '_license' ,
31
- 'data' : theData
32
- } ,
33
- function ( response ) {
34
- response = jQuery . parseJSON ( response ) ;
35
- console . log ( response ) ;
36
- jQuery ( '#' + id + '-status' ) . val ( response . status ) ;
37
- jQuery ( '#' + id + '-status_notice' ) . html ( response . status ) ;
38
- if ( response . response === "valid" ) {
39
- //jQuery('#'+id+'-notice').switchClass( "big", "blue", 1000, "easeInOutQuad" );
40
- jQuery ( '#' + id + '-notice' ) . attr ( 'class' , "redux-info-field redux-success" ) ;
41
- } else if ( response . response === "deactivated" ) {
42
- jQuery ( '#' + id + '-notice' ) . attr ( 'class' , "redux-info-field redux-warning" ) ;
43
- } else { // Inactive or bad
44
-
45
- }
46
-
47
- }
48
- ) ;
49
- } ) ;
50
-
51
- }
52
-
53
- } ) ( jQuery ) ;
1
+ /*global jQuery, document, redux_opts, ajaxurl */
2
+ ( function ( $ ) {
3
+ 'use strict' ;
4
+ $ . redux = $ . redux || { } ;
5
+ $ ( document ) . ready ( function ( ) {
6
+ $ . redux . edd ( ) ;
7
+ } ) ;
8
+ $ . redux . edd = function ( ) {
9
+ jQuery ( '.redux-edd-input' ) . change ( function ( ) {
10
+ jQuery ( this ) . parent ( ) . find ( '.redux-edd-status' ) . val ( '' ) ;
11
+ } ) ;
12
+ jQuery ( document ) . on ( "click" , ".redux-EDDAction" , function ( e ) {
13
+ e . preventDefault ( ) ;
14
+ var parent = jQuery ( this ) . parents ( '.redux-container-edd_license:first' ) ;
15
+ var id = jQuery ( this ) . attr ( 'data-id' ) ;
16
+ var theData = { } ;
17
+ parent . find ( '.redux-edd' ) . each ( function ( ) {
18
+ theData [ jQuery ( this ) . attr ( 'id' ) . replace ( id + '-' , '' ) ] = jQuery ( this ) . val ( ) ;
19
+ } ) ;
20
+ theData . edd_action = jQuery ( this ) . attr ( 'data-edd_action' ) ;
21
+ theData . opt_name = redux_opts . opt_name ;
22
+ jQuery . post (
23
+ ajaxurl , {
24
+ 'action' : 'redux_edd_' + redux_opts . opt_name + '_license' ,
25
+ 'data' : theData
26
+ } , function ( response ) {
27
+ response = jQuery . parseJSON ( response ) ;
28
+ jQuery ( '#' + id + '-status' ) . val ( response . status ) ;
29
+ jQuery ( '#' + id + '-status_notice' ) . html ( response . status ) ;
30
+ if ( response . response === "valid" ) {
31
+ //jQuery('#'+id+'-notice').switchClass( "big", "blue", 1000, "easeInOutQuad" );
32
+ jQuery ( '#' + id + '-notice' ) . attr ( 'class' , "redux-info-field redux-success" ) ;
33
+ jQuery ( '#' + id + '-activate' ) . fadeOut ( 'medium' , function ( ) {
34
+ jQuery ( '#' + id + '-deactivate' ) . fadeIn ( ) . css ( "display" , "inline-block" ) ;
35
+ } ) ;
36
+ } else if ( response . response === "deactivated" ) {
37
+ jQuery ( '#' + id + '-notice' ) . attr ( 'class' , "redux-info-field redux-warning" ) ;
38
+ jQuery ( '#' + id + '-deactivate' ) . fadeOut ( 'medium' , function ( ) {
39
+ jQuery ( '#' + id + '-activate' ) . fadeIn ( ) . css ( "display" , "inline-block" ) ;
40
+ } ) ;
41
+ } else { // Inactive or bad
42
+ jQuery ( '#' + id + '-deactivate' ) . fadeOut ( 'medium' , function ( ) {
43
+ jQuery ( '#' + id + '-notice' ) . attr ( 'class' , "redux-info-field redux-critical" ) ;
44
+ jQuery ( '#' + id + '-activate' ) . fadeIn ( ) . css ( "display" , "inline-block" ) ;
45
+ } ) ;
46
+ }
47
+ } ) ;
48
+ } ) ;
49
+ } ;
50
+ } ) ( jQuery ) ;
0 commit comments