PluginProbe
Property Hive / 1.4.54
Property Hive v1.4.54
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / assets / js / admin / meta-boxes.js

meta-boxes.js in Property Hive 1.4.54, at assets/js/admin/meta-boxes.js

174 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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_photo_urls').sortable({
16 opacity: 0.8,
17 revert: true,
18 handle: 'label'
19 });
20
21 $('.propertyhive_meta_box #property_floorplan_urls').sortable({
22 opacity: 0.8,
23 revert: true,
24 handle: 'label'
25 });
26
27 $('.propertyhive_meta_box #property_brochure_urls').sortable({
28 opacity: 0.8,
29 revert: true,
30 handle: 'label'
31 });
32
33 $('.propertyhive_meta_box #property_epc_urls').sortable({
34 opacity: 0.8,
35 revert: true,
36 handle: 'label'
37 });
38
39 $('.propertyhive_meta_box #property_virtual_tours').sortable({
40 opacity: 0.8,
41 revert: true,
42 handle: 'label'
43 });
44
45 initialise_datepicker();
46
47 // TABS
48 $('ul.ph-tabs').show();
49 $('div.panel-wrap').each(function(){
50 $(this).find('div.panel:not(:first)').hide();
51 });
52 $('ul.ph-tabs a').click(function(){
53 var panel_wrap = $(this).closest('div.panel-wrap');
54 $('ul.ph-tabs li', panel_wrap).removeClass('active');
55 $(this).parent().addClass('active');
56 $('div.panel', panel_wrap).hide();
57 $( $(this).attr('href') ).show();
58 return false;
59 });
60 $('ul.ph-tabs li:visible').eq(0).find('a').click();
61
62 // Notes
63 //$('#propertyhive-property-notes, #propertyhive-contact-notes, #propertyhive-enquiry-notes, #propertyhive-viewing-notes, #propertyhive-offer-notes, #propertyhive-sale-notes').on( 'click', 'a.add_note', function() {
64 $('[id^=\'propertyhive-\'][id$=\'-notes\']').on( 'click', 'a.add_note', function() {
65 if ( ! $('textarea#add_note').val() ) return;
66
67 var data = {
68 action: 'propertyhive_add_note',
69 post_id: propertyhive_admin_meta_boxes.post_id,
70 note: $('textarea#add_note').val(),
71 note_type: 'propertyhive_note',
72 security: propertyhive_admin_meta_boxes.add_note_nonce,
73 };
74
75 $.post( propertyhive_admin_meta_boxes.ajax_url, data, function(response) {
76 $('ul.record_notes').prepend( response );
77 $('li#no_notes').hide();
78 $('#add_note').val('');
79 });
80
81 return false;
82 });
83
84 $('[id^=\'propertyhive-\'][id$=\'-notes\']').on( 'click', 'a.delete_note', function() {
85
86 var confirm_box = confirm('Are you sure you wish to delete this note?');
87 if (!confirm_box)
88 {
89 return false;
90 }
91
92 var note = $(this).closest('li.note');
93
94 var data = {
95 action: 'propertyhive_delete_note',
96 note_id: $(note).attr('rel'),
97 security: propertyhive_admin_meta_boxes.delete_note_nonce,
98 };
99
100 $.post( propertyhive_admin_meta_boxes.ajax_url, data, function(response) {
101 $(note).remove();
102
103 if ($('ul.record_notes li').length <= 1)
104 {
105 $('li#no_notes').show();
106 }
107 });
108
109 return false;
110 });
111
112 // Notes filter
113 $('.notes-filter a').click(function(e)
114 {
115 e.preventDefault();
116
117 var note_type = $(this).attr('data-filter-class');
118
119 if ( note_type == '*' )
120 {
121 // show all notes
122 $('.record_notes li').show();
123
124 if ( $('.record_notes li').length > 1 )
125 {
126 $('.record_notes li#no_notes').hide();
127 }
128 }
129 else
130 {
131 $('.record_notes li').hide();
132 $('.record_notes li.' + note_type).show();
133 }
134
135 $('.notes-filter a').removeClass('current');
136 $(this).addClass('current');
137 });
138
139 // Multiselect
140 $(".propertyhive_meta_box select.multiselect").chosen();
141 });
142
143 function initialise_datepicker() {
144 jQuery( ".date-picker" ).datepicker({
145 dateFormat: "yy-mm-dd",
146 numberOfMonths: 1,
147 showButtonPanel: true
148 }).on("change", function(e) {
149 var curDate = jQuery(this).val();
150 var valid = true;
151
152 if ( curDate != '' )
153 {
154 var splitDate = curDate.split("-")
155 if ( splitDate.length != 3 )
156 {
157 valid = false;
158 }
159 else
160 {
161 if ( splitDate[0].length != 4 || splitDate[1].length != 2 || splitDate[2].length != 2 )
162 {
163 valid = false;
164 }
165 }
166
167 if (!valid)
168 {
169 alert("Invalid date entered. Please select a date from the calendar and ensure date is in the format YYYY-MM-DD");
170 }
171 }
172 });
173 }
174