summaryrefslogtreecommitdiff
path: root/script/feedback/feedback.js
blob: 97940cf37575aa3ee525231532dcb9d4979bef33 (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
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: {
	      		'skip' : {
		        	text: 'Skip',
		        	id: 'postman-feedback-dialog-skip',
		        	click: function() {
		          		$( this ).dialog( "close" );

		          		location.href = deactivateLink;
		        	}				      			
	      		},	      		
	      		'go' : {
		        	text: 'Continue',
		        	id: 'postman-feedback-dialog-go',
					class: 'button',
		        	click: function() {
		          		$( this ).dialog( "close" );

		          		var form = $( this ).find( 'form' ).serializeArray(),
							result = {};

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

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

							$.post( post_feedback.admin_ajax, result, function(result) {

							});
						}

		          		// Remove this comment to deactivate plugin
		          		location.href = deactivateLink;
		        	},				      			
	      		},
	      		'cancel' : {
		        	text: 'Cancel',
		        	id: 'postman-feedback-dialog-cancel',
		        	class: 'button button-primary',
		        	click: function() {
		          		$( this ).dialog( "close" );
		        	}				      			
	      		}
	      	}
	    });

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

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