summaryrefslogtreecommitdiff
path: root/script/feedback/feedback.js
blob: a151f3b8a922e01eaacc2a60851cd48cf81be12d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
jQuery(document).ready(function($) {

	$( '#the-list #postman-plugin-disbale-link' ).click(function(e) {
		e.preventDefault();

		var reason = $( '#postman-feedback-dialog-content .postman-reason' ),
			deactivateLink = $( this ).attr( 'href' );

	    $( "#postman-feedback-dialog-content" ).dialog({
	    	title: 'Post SMTP Feedback Form',
	    	dialogClass: 'postman-feedback-dialog-form',
	      	resizable: false,
	      	minWidth: 400,
	      	minHeight: 300,
	      	modal: true,
	      	buttons: {      		
	      		'go' : {
		        	text: 'Continue',
        			icons: { primary: "dashicons dashicons-update" },        	
		        	id: 'postman-feedback-dialog-go',
					class: 'button',
		        	click: function() {

		        		var dialog = $(this),
		        			go = $('#postman-feedback-dialog-go'),
		          			form = dialog.find( 'form' ).serializeArray(),
							result = {};

						$.each( form, function() {
							if ( '' !== this.value )
						    	result[ this.name ] = this.value;										
						});

						if ( ! jQuery.isEmptyObject( result ) ) {
							result.action = 'post_user_feedback';

						    $.ajax({
						        url: post_feedback.admin_ajax,
						        type: 'POST',
						        data: result,
						        error: function(){},
						        success: function(msg){},
						        beforeSend: function() { 
						        	go.addClass('postman-ajax-progress'); 
						        },
						        complete: function() { 
						        	go.removeClass('postman-ajax-progress'); 
			        	
						        	dialog.dialog( "close" );
						            location.href = deactivateLink;						        	
						        }						        
						    });		
	
						}


		        	},				      			
	      		},
	      		'cancel' : {
		        	text: 'Cancel',
		        	id: 'postman-feedback-dialog-cancel',
		        	class: 'button button-primary',
		        	click: function() {
		          		$( this ).dialog( "close" );
		        	}				      			
	      		},
	      		'skip' : {
		        	text: 'Skip',
		        	id: 'postman-feedback-dialog-skip',
		        	click: function() {
		          		$( this ).dialog( "close" );

		          		location.href = deactivateLink;
		        	}				      			
	      		},		      		
	      	}
	    });

		reason.change(function() {
			$( '.postman-reason-input' ).hide();

			if ( $( this ).hasClass( 'postman-custom-input' ) ) {
				$( '#postman-deactivate-reasons' ).next( '.postman-reason-input' ).show();
			}

			if ( $( this ).hasClass( 'postman-support-input' ) ) {
				console.log($(this));
				$( this ).find( '.postman-reason-input' ).show();
			}			
		});
				    
	});
});