| 1 |
/** |
| 2 |
* ==================================================================================================================== |
| 3 |
* includes/__js/cal/days_select_custom.js |
| 4 |
* ==================================================================================================================== |
| 5 |
*/ |
| 6 |
|
| 7 |
// FixIn: 9.8.9.2. |
| 8 |
|
| 9 |
/** |
| 10 |
* Re-Init Calendar and Re-Render it. |
| 11 |
* |
| 12 |
* @param resource_id |
| 13 |
*/ |
| 14 |
function wpbc_cal__re_init( resource_id ){ |
| 15 |
|
| 16 |
// Remove CLASS for ability to re-render and reinit calendar. |
| 17 |
jQuery( '#calendar_booking' + resource_id ).removeClass( 'hasDatepick' ); |
| 18 |
wpbc_calendar_show( resource_id ); |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
/** |
| 23 |
* Re-Init previously saved days selection variables. |
| 24 |
* |
| 25 |
* @param resource_id |
| 26 |
*/ |
| 27 |
function wpbc_cal_days_select__re_init( resource_id ){ |
| 28 |
|
| 29 |
_wpbc.calendar__set_param_value( resource_id, 'saved_variable___days_select_initial' |
| 30 |
, { |
| 31 |
'dynamic__days_min' : _wpbc.calendar__get_param_value( resource_id, 'dynamic__days_min' ), |
| 32 |
'dynamic__days_max' : _wpbc.calendar__get_param_value( resource_id, 'dynamic__days_max' ), |
| 33 |
'dynamic__days_specific' : _wpbc.calendar__get_param_value( resource_id, 'dynamic__days_specific' ), |
| 34 |
'dynamic__week_days__start': _wpbc.calendar__get_param_value( resource_id, 'dynamic__week_days__start' ), |
| 35 |
'fixed__days_num' : _wpbc.calendar__get_param_value( resource_id, 'fixed__days_num' ), |
| 36 |
'fixed__week_days__start' : _wpbc.calendar__get_param_value( resource_id, 'fixed__week_days__start' ) |
| 37 |
} |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
// --------------------------------------------------------------------------------------------------------------------- |
| 42 |
|
| 43 |
/** |
| 44 |
* Set Single Day selection - after page load |
| 45 |
* |
| 46 |
* @param resource_id ID of booking resource |
| 47 |
*/ |
| 48 |
function wpbc_cal_ready_days_select__single( resource_id ){ |
| 49 |
|
| 50 |
// Re-define selection, only after page loaded with all init vars |
| 51 |
jQuery(document).ready(function(){ |
| 52 |
|
| 53 |
// Wait 1 second, just to be sure, that all init vars defined |
| 54 |
setTimeout(function(){ |
| 55 |
|
| 56 |
wpbc_cal_days_select__single( resource_id ); |
| 57 |
|
| 58 |
}, 1000); |
| 59 |
}); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Set Single Day selection |
| 64 |
* Can be run at any time, when calendar defined - useful for console run. |
| 65 |
* |
| 66 |
* @param resource_id ID of booking resource |
| 67 |
*/ |
| 68 |
function wpbc_cal_days_select__single( resource_id ){ |
| 69 |
|
| 70 |
_wpbc.calendar__set_parameters( resource_id, {'days_select_mode': 'single'} ); |
| 71 |
|
| 72 |
wpbc_cal_days_select__re_init( resource_id ); |
| 73 |
wpbc_cal__re_init( resource_id ); |
| 74 |
} |
| 75 |
|
| 76 |
// --------------------------------------------------------------------------------------------------------------------- |
| 77 |
|
| 78 |
/** |
| 79 |
* Set Multiple Days selection - after page load |
| 80 |
* |
| 81 |
* @param resource_id ID of booking resource |
| 82 |
*/ |
| 83 |
function wpbc_cal_ready_days_select__multiple( resource_id ){ |
| 84 |
|
| 85 |
// Re-define selection, only after page loaded with all init vars |
| 86 |
jQuery(document).ready(function(){ |
| 87 |
|
| 88 |
// Wait 1 second, just to be sure, that all init vars defined |
| 89 |
setTimeout(function(){ |
| 90 |
|
| 91 |
wpbc_cal_days_select__multiple( resource_id ); |
| 92 |
|
| 93 |
}, 1000); |
| 94 |
}); |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
/** |
| 99 |
* Set Multiple Days selection |
| 100 |
* Can be run at any time, when calendar defined - useful for console run. |
| 101 |
* |
| 102 |
* @param resource_id ID of booking resource |
| 103 |
*/ |
| 104 |
function wpbc_cal_days_select__multiple( resource_id ){ |
| 105 |
|
| 106 |
_wpbc.calendar__set_parameters( resource_id, {'days_select_mode': 'multiple'} ); |
| 107 |
|
| 108 |
wpbc_cal_days_select__re_init( resource_id ); |
| 109 |
wpbc_cal__re_init( resource_id ); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
// --------------------------------------------------------------------------------------------------------------------- |
| 114 |
|
| 115 |
/** |
| 116 |
* Set Fixed Days selection with 1 mouse click - after page load |
| 117 |
* |
| 118 |
* @integer resource_id - 1 -- ID of booking resource (calendar) - |
| 119 |
* @integer days_number - 3 -- number of days to select - |
| 120 |
* @array week_days__start - [-1] | [ 1, 5] -- { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat } |
| 121 |
*/ |
| 122 |
function wpbc_cal_ready_days_select__fixed( resource_id, days_number, week_days__start = [-1] ){ |
| 123 |
|
| 124 |
// Re-define selection, only after page loaded with all init vars |
| 125 |
jQuery(document).ready(function(){ |
| 126 |
|
| 127 |
// Wait 1 second, just to be sure, that all init vars defined |
| 128 |
setTimeout(function(){ |
| 129 |
|
| 130 |
wpbc_cal_days_select__fixed( resource_id, days_number, week_days__start ); |
| 131 |
|
| 132 |
}, 1000); |
| 133 |
}); |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
/** |
| 138 |
* Set Fixed Days selection with 1 mouse click |
| 139 |
* Can be run at any time, when calendar defined - useful for console run. |
| 140 |
* |
| 141 |
* @integer resource_id - 1 -- ID of booking resource (calendar) - |
| 142 |
* @integer days_number - 3 -- number of days to select - |
| 143 |
* @array week_days__start - [-1] | [ 1, 5] -- { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat } |
| 144 |
*/ |
| 145 |
function wpbc_cal_days_select__fixed( resource_id, days_number, week_days__start = [-1] ){ |
| 146 |
|
| 147 |
_wpbc.calendar__set_parameters( resource_id, {'days_select_mode': 'fixed'} ); |
| 148 |
|
| 149 |
_wpbc.calendar__set_parameters( resource_id, {'fixed__days_num': parseInt( days_number )} ); // Number of days selection with 1 mouse click |
| 150 |
_wpbc.calendar__set_parameters( resource_id, {'fixed__week_days__start': week_days__start} ); // { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat } |
| 151 |
|
| 152 |
wpbc_cal_days_select__re_init( resource_id ); |
| 153 |
wpbc_cal__re_init( resource_id ); |
| 154 |
} |
| 155 |
|
| 156 |
// --------------------------------------------------------------------------------------------------------------------- |
| 157 |
|
| 158 |
/** |
| 159 |
* Set Range Days selection with 2 mouse clicks - after page load |
| 160 |
* |
| 161 |
* @integer resource_id - 1 -- ID of booking resource (calendar) |
| 162 |
* @integer days_min - 7 -- Min number of days to select |
| 163 |
* @integer days_max - 30 -- Max number of days to select |
| 164 |
* @array days_specific - [] | [7,14,21,28] -- Restriction for Specific number of days selection |
| 165 |
* @array week_days__start - [-1] | [ 1, 5] -- { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat } |
| 166 |
*/ |
| 167 |
function wpbc_cal_ready_days_select__range( resource_id, days_min, days_max, days_specific = [], week_days__start = [-1] ){ |
| 168 |
|
| 169 |
// Re-define selection, only after page loaded with all init vars |
| 170 |
jQuery(document).ready(function(){ |
| 171 |
|
| 172 |
// Wait 1 second, just to be sure, that all init vars defined |
| 173 |
setTimeout(function(){ |
| 174 |
|
| 175 |
wpbc_cal_days_select__range( resource_id, days_min, days_max, days_specific, week_days__start ); |
| 176 |
}, 1000); |
| 177 |
}); |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Set Range Days selection with 2 mouse clicks |
| 182 |
* Can be run at any time, when calendar defined - useful for console run. |
| 183 |
* |
| 184 |
* @integer resource_id - 1 -- ID of booking resource (calendar) |
| 185 |
* @integer days_min - 7 -- Min number of days to select |
| 186 |
* @integer days_max - 30 -- Max number of days to select |
| 187 |
* @array days_specific - [] | [7,14,21,28] -- Restriction for Specific number of days selection |
| 188 |
* @array week_days__start - [-1] | [ 1, 5] -- { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat } |
| 189 |
*/ |
| 190 |
function wpbc_cal_days_select__range( resource_id, days_min, days_max, days_specific = [], week_days__start = [-1] ){ |
| 191 |
|
| 192 |
_wpbc.calendar__set_parameters( resource_id, {'days_select_mode': 'dynamic'} ); |
| 193 |
_wpbc.calendar__set_param_value( resource_id, 'dynamic__days_min' , parseInt( days_min ) ); // Min. Number of days selection with 2 mouse clicks |
| 194 |
_wpbc.calendar__set_param_value( resource_id, 'dynamic__days_max' , parseInt( days_max ) ); // Max. Number of days selection with 2 mouse clicks |
| 195 |
_wpbc.calendar__set_param_value( resource_id, 'dynamic__days_specific' , days_specific ); // Example [5,7] |
| 196 |
_wpbc.calendar__set_param_value( resource_id, 'dynamic__week_days__start' , week_days__start ); // { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat } |
| 197 |
|
| 198 |
wpbc_cal_days_select__re_init( resource_id ); |
| 199 |
wpbc_cal__re_init( resource_id ); |
| 200 |
} |
| 201 |
|