PluginProbe
Property Hive / 2.2.6
Property Hive v2.2.6
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 / inline-edit-key_date.js

inline-edit-key_date.js in Property Hive 2.2.6, at assets/js/admin/inline-edit-key_date.js

84 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(function($) {
2
3 var wp_inline_edit_function = inlineEditPost.edit;
4
5 inlineEditPost.edit = function( id ) {
6
7 wp_inline_edit_function.apply( this, arguments );
8
9 if ( typeof( id ) == 'object' ) {
10 id = parseInt( this.getId( id ) );
11 }
12
13 if ( id > 0 ) {
14
15 var data = {
16 action: 'propertyhive_check_key_date_recurrence',
17 post_id: id,
18 };
19
20 jQuery.post( propertyhive_admin_meta_boxes.ajax_url, data, function(response)
21 {
22 if ( response == '' )
23 {
24 $( '#book_next_key_date_label', specific_post_edit_row ).addClass("disabled");
25 }
26 else
27 {
28 $( ':input[name="next_date_due"]', specific_post_edit_row).val(response);
29 }
30 });
31
32 var specific_post_edit_row = $( '#edit-' + id ),
33 quick_edit_save_button = $( 'button.save', specific_post_edit_row ),
34 specific_post_row = $( '#post-' + id ),
35 description = $( '.column-description .cell-main-content', specific_post_row ).text(),
36 property = $( '.column-property .cell-main-content', specific_post_row ).text(),
37 display_status = $( '.column-status .cell-main-content', specific_post_row ).text(),
38 real_status = ["pending", "upcoming", "overdue"].includes(display_status.toLowerCase()) ? 'pending' : display_status.toLowerCase();
39
40 // Replace classes so quick edit Update button is next to Cancel
41 quick_edit_save_button.addClass('alignmiddle').removeClass('alignright').before(' ');
42
43 $( ':input[name="_key_date_status"] option[value="' + real_status + '"]', specific_post_edit_row ).attr("selected", "selected").text(display_status);
44 $( ':input[name="_key_date_description"]', specific_post_edit_row).val(description);
45 $( '.key_date-property', specific_post_edit_row ).text(property);
46 }
47
48 $( ':input[name="_key_date_status"]', specific_post_edit_row ).on( 'change', function() {
49
50 if ( !$( '#book_next_key_date_label', specific_post_edit_row ).hasClass('disabled') )
51 {
52 if ( this.value == 'complete' )
53 {
54 // Show Book Next checkbox
55 $( '#book_next_key_date_label', specific_post_edit_row ).show();
56 }
57 else
58 {
59 // Hide Book Next checkbox
60 $( '#book_next_key_date_label', specific_post_edit_row ).hide();
61
62 // Hide Next Key Date field, if visible
63 $( '#next_date_due_label', specific_post_edit_row ).hide();
64
65 // Uncheck Book Next checkbox
66 $( '#book_next_key_date_checkbox', specific_post_edit_row ).prop( 'checked', false );
67 }
68 }
69 });
70
71 $( '#book_next_key_date_checkbox', specific_post_edit_row ).on( 'click', function() {
72
73 // Show/Hide Next Key Date field when checkbox is checked and unchecked
74 if( this.checked )
75 {
76 $( '#next_date_due_label', specific_post_edit_row ).show();
77 }
78 else
79 {
80 $( '#next_date_due_label', specific_post_edit_row ).hide();
81 }
82 });
83 }
84 });