| 1 |
jQuery( function($){ |
| 2 |
|
| 3 |
$('.propertyhive_meta_box #property_rooms').sortable({ |
| 4 |
opacity: 0.8, |
| 5 |
revert: true, |
| 6 |
handle: 'h3' |
| 7 |
}); |
| 8 |
|
| 9 |
$('.propertyhive_meta_box #property_features').sortable({ |
| 10 |
opacity: 0.8, |
| 11 |
revert: true, |
| 12 |
handle: 'label' |
| 13 |
}); |
| 14 |
|
| 15 |
$('.propertyhive_meta_box #property_virtual_tours').sortable({ |
| 16 |
opacity: 0.8, |
| 17 |
revert: true, |
| 18 |
handle: 'label' |
| 19 |
}); |
| 20 |
|
| 21 |
initialise_datepicker(); |
| 22 |
|
| 23 |
// TABS |
| 24 |
$('ul.ph-tabs').show(); |
| 25 |
$('div.panel-wrap').each(function(){ |
| 26 |
$(this).find('div.panel:not(:first)').hide(); |
| 27 |
}); |
| 28 |
$('ul.ph-tabs a').click(function(){ |
| 29 |
var panel_wrap = $(this).closest('div.panel-wrap'); |
| 30 |
$('ul.ph-tabs li', panel_wrap).removeClass('active'); |
| 31 |
$(this).parent().addClass('active'); |
| 32 |
$('div.panel', panel_wrap).hide(); |
| 33 |
$( $(this).attr('href') ).show(); |
| 34 |
return false; |
| 35 |
}); |
| 36 |
$('ul.ph-tabs li:visible').eq(0).find('a').click(); |
| 37 |
|
| 38 |
// Notes |
| 39 |
$('#propertyhive-property-notes, #propertyhive-contact-notes, #propertyhive-enquiry-notes, #propertyhive-viewing-notes, #propertyhive-offer-notes, #propertyhive-sale-notes').on( 'click', 'a.add_note', function() { |
| 40 |
if ( ! $('textarea#add_note').val() ) return; |
| 41 |
|
| 42 |
var data = { |
| 43 |
action: 'propertyhive_add_note', |
| 44 |
post_id: propertyhive_admin_meta_boxes.post_id, |
| 45 |
note: $('textarea#add_note').val(), |
| 46 |
note_type: 'propertyhive_note', |
| 47 |
security: propertyhive_admin_meta_boxes.add_note_nonce, |
| 48 |
}; |
| 49 |
|
| 50 |
$.post( propertyhive_admin_meta_boxes.ajax_url, data, function(response) { |
| 51 |
$('ul.record_notes').prepend( response ); |
| 52 |
$('li#no_notes').hide(); |
| 53 |
$('#add_note').val(''); |
| 54 |
}); |
| 55 |
|
| 56 |
return false; |
| 57 |
|
| 58 |
}); |
| 59 |
|
| 60 |
$('#propertyhive-property-notes, #propertyhive-contact-notes, #propertyhive-enquiry-notes, #propertyhive-viewing-notes, #propertyhive-offer-notes, #propertyhive-sale-notes').on( 'click', 'a.delete_note', function() { |
| 61 |
|
| 62 |
var confirm_box = confirm('Are you sure you wish to delete this note?'); |
| 63 |
if (!confirm_box) |
| 64 |
{ |
| 65 |
return false; |
| 66 |
} |
| 67 |
|
| 68 |
var note = $(this).closest('li.note'); |
| 69 |
|
| 70 |
var data = { |
| 71 |
action: 'propertyhive_delete_note', |
| 72 |
note_id: $(note).attr('rel'), |
| 73 |
security: propertyhive_admin_meta_boxes.delete_note_nonce, |
| 74 |
}; |
| 75 |
|
| 76 |
$.post( propertyhive_admin_meta_boxes.ajax_url, data, function(response) { |
| 77 |
$(note).remove(); |
| 78 |
|
| 79 |
if ($('ul.record_notes li').length <= 1) |
| 80 |
{ |
| 81 |
$('li#no_notes').show(); |
| 82 |
} |
| 83 |
}); |
| 84 |
|
| 85 |
return false; |
| 86 |
}); |
| 87 |
|
| 88 |
// Multiselect |
| 89 |
$(".propertyhive_meta_box select.multiselect").chosen(); |
| 90 |
|
| 91 |
}); |
| 92 |
|
| 93 |
function initialise_datepicker() { |
| 94 |
jQuery( ".date-picker" ).datepicker({ |
| 95 |
dateFormat: "yy-mm-dd", |
| 96 |
numberOfMonths: 1, |
| 97 |
showButtonPanel: true |
| 98 |
}); |
| 99 |
} |