cf7-script.js 1.98 KB
Newer Older
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 94 95 96 97

jQuery(document).ready(function($){
	//delete
	$('#adb-delete-button').click(function(){
	
		if(!confirm('Are you sure?')) return;
		//gathering data
		alldataArr = [];
		
		var dataDiv = [];
		$('.adb-chk:checked').each(function(indx){
			dataObj = {};
			dataObj.id 	= $(this).data('id');
			dataObj.key = $(this).data('key');
			dataObj.val = $(this).val();
			alldataArr[indx] = dataObj;
			dataDiv[indx] = $(this);
		});
		
		
		//ajax call
		$.post(
			ajaxurl, {
				'action': 'delete_cf7_data',
				'data':   alldataArr
			}, 
			function(response){

				if(response=="success"){
					dataDiv.forEach(function(el){
						el.parent().parent().fadeOut();
					});
				}
			}
		);
	});
	
	//delete
	$('.del-button').click(function(){
	
		
		if(!confirm('Are you sure?')) return;
		
		$('#loading-panel').fadeIn();

		//gathering data
		dataArr = [];
		dataObjSingle = {};
		
			dataObjSingle.id 	= $(this).data('id');
			dataObjSingle.key 	= $(this).data('key');
			dataObjSingle.val 	= $(this).data('val');
			dataArr[0] 			= dataObjSingle;
			currentDiv 			= $(this);
		
		
		//ajax call
		$.post(
			ajaxurl, {
				'action': 'delete_cf7_data',
				'data':   dataArr
			}, 
			function(response){
				if(response=="success"){
						currentDiv.parent().parent().fadeOut(function(){
							$('#loading-panel').fadeOut();
						});
				}
			}
		);
	});
	
	$('#cf7-selector').change(function(){
		window.location = "?page=cf7-adb&id="+$(this).val();
	});
	//initiate tb paging
	 $('#property-lead-table').DataTable({'pageLength': 10});
	 
	 $('#property-lead-table tr').hover(function(){

		$(this).find('input').css('border-color','green');
	 },function(){
		$(this).find('input').css('border-color','#bbbbbb');
	 });
	 


	 jQuery('.cfdb-notif').delay(2000).fadeOut('slow');

	// Change Column name
	$('#property-lead-table_wrapper column-title span').click(function(){
		$(this).attr('contentEditable',true);
	})

	 
	 
});