Subversion Repositories SmartDukaan

Rev

Rev 36890 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36890 Rev 36892
Line 62... Line 62...
62
				alert((response && response.message) ? response.message : 'Could not save contact.');
62
				alert((response && response.message) ? response.message : 'Could not save contact.');
63
			}
63
			}
64
		});
64
		});
65
	});
65
	});
66
 
66
 
67
	// Soft-delete an entry.
67
	// Soft-delete an entry (with a styled confirmation).
68
	$(document).on('click', ".contact-delete-btn", function() {
68
	$(document).on('click', ".contact-delete-btn", function() {
69
		var name = $(this).data('name');
69
		var name = $(this).data('name');
-
 
70
		var id = $(this).data('id');
-
 
71
		var doDelete = function() {
-
 
72
			doPostAjaxRequestWithParamsHandler(context + "/contactUs/delete", { id: id }, function(response) {
-
 
73
				if (response && response.success) {
-
 
74
					contactUs("main-content");
-
 
75
				} else {
-
 
76
					alert((response && response.message) ? response.message : 'Could not remove contact.');
-
 
77
				}
-
 
78
			});
-
 
79
		};
-
 
80
		if (typeof bootbox !== 'undefined' && bootbox.confirm) {
-
 
81
			bootbox.confirm({
-
 
82
				title: "Delete contact",
-
 
83
				message: "Are you sure you want to remove <b>" + name + "</b> from the contact list?",
-
 
84
				buttons: {
-
 
85
					confirm: { label: '<i class="fa fa-trash"></i> Yes, delete', className: 'btn-danger' },
-
 
86
					cancel: { label: 'Cancel', className: 'btn-default' }
-
 
87
				},
-
 
88
				callback: function(result) { if (result) { doDelete(); } }
-
 
89
			});
70
		if (!confirm('Remove ' + name + ' from the contact list?')) {
90
		} else if (confirm('Remove ' + name + ' from the contact list?')) {
71
			return;
91
			doDelete();
72
		}
92
		}
73
		doPostAjaxRequestWithParamsHandler(context + "/contactUs/delete", { id: $(this).data('id') }, function(response) {
-
 
74
			if (response && response.success) {
-
 
75
				contactUs("main-content");
-
 
76
			} else {
-
 
77
				alert((response && response.message) ? response.message : 'Could not remove contact.');
-
 
78
			}
-
 
79
		});
-
 
80
	});
93
	});
81
 
94
 
82
});
95
});
83
 
96
 
84
function contactUs(domId){
97
function contactUs(domId){