| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPBC BFB Pack: Start Time (single time points). |
| 4 |
* |
| 5 |
* - Adds a "starttime" field that renders dropdown options like: |
| 6 |
* [selectbox starttime "08:00" "09:00" ... ] |
| 7 |
* - Labels can be AM/PM or 24h; values are always strict "HH:MM" (24h). |
| 8 |
* - Inspector: |
| 9 |
* - AM/PM </> 24H switch (radio) |
| 10 |
* - Generator: From/To + Duration (step) -> builds single time points |
| 11 |
* - Options editor with rows that mirror the chosen format |
| 12 |
* - Respects global "Show as time picker" toggle used by time-based fields. |
| 13 |
* - Requires iMask.js (already loaded on the Builder page) for 24h masking. |
| 14 |
* |
| 15 |
* @package Booking Calendar |
| 16 |
* @author wpdevelop |
| 17 |
* @since 11.0.0 |
| 18 |
* @modified 31.10.2025 16:45 |
| 19 |
* @version 1.0.0 |
| 20 |
*/ |
| 21 |
|
| 22 |
if ( ! defined( 'ABSPATH' ) ) { |
| 23 |
exit; |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* Register the "starttime" field pack (AM/PM labels by default). |
| 29 |
* |
| 30 |
* @param array $packs Packs map. |
| 31 |
* @return array |
| 32 |
*/ |
| 33 |
function wpbc_bfb_register_field_packs__field_starttime_wptpl( $packs ) { |
| 34 |
$packs['starttime'] = array( |
| 35 |
'kind' => 'field', |
| 36 |
'type' => 'starttime', |
| 37 |
'label' => __( 'Start time', 'booking' ), |
| 38 |
'icon' => 'wpbc-bi-clock', |
| 39 |
'usage_key' => 'starttime', |
| 40 |
|
| 41 |
'schema' => array( |
| 42 |
'props' => array( |
| 43 |
'label' => array( 'type' => 'string', 'default' => __( 'Start time', 'booking' ) ), |
| 44 |
'name' => array( 'type' => 'string', 'default' => 'starttime' ), |
| 45 |
'html_id' => array( 'type' => 'string', 'default' => '' ), |
| 46 |
'required' => array( 'type' => 'boolean', 'default' => true ), |
| 47 |
'multiple' => array( 'type' => 'boolean', 'default' => false ), |
| 48 |
'size' => array( 'type' => 'number', 'default' => null, 'min' => 2, 'max' => 20 ), |
| 49 |
'cssclass' => array( 'type' => 'string', 'default' => '' ), |
| 50 |
'help' => array( 'type' => 'string', 'default' => '' ), |
| 51 |
'default_value' => array( 'type' => 'string', 'default' => '' ), |
| 52 |
'placeholder' => array( 'type' => 'string', 'default' => '--- ' . __( 'Select time', 'booking' ) . ' ---' ), |
| 53 |
'value_differs' => array( 'type' => 'boolean', 'default' => true ), |
| 54 |
|
| 55 |
// AM/PM labels, 24h values. |
| 56 |
'options' => array( |
| 57 |
'type' => 'array', |
| 58 |
'default' => array( |
| 59 |
array( 'label' => '08:00 AM', 'value' => '08:00', 'selected' => false ), |
| 60 |
array( 'label' => '09:00 AM', 'value' => '09:00', 'selected' => false ), |
| 61 |
array( 'label' => '10:00 AM', 'value' => '10:00', 'selected' => false ), |
| 62 |
array( 'label' => '11:00 AM', 'value' => '11:00', 'selected' => false ), |
| 63 |
array( 'label' => '12:00 PM', 'value' => '12:00', 'selected' => false ), |
| 64 |
array( 'label' => '01:00 PM', 'value' => '13:00', 'selected' => false ), |
| 65 |
array( 'label' => '02:00 PM', 'value' => '14:00', 'selected' => false ), |
| 66 |
array( 'label' => '03:00 PM', 'value' => '15:00', 'selected' => false ), |
| 67 |
array( 'label' => '04:00 PM', 'value' => '16:00', 'selected' => false ), |
| 68 |
array( 'label' => '05:00 PM', 'value' => '17:00', 'selected' => false ), |
| 69 |
array( 'label' => '06:00 PM', 'value' => '18:00', 'selected' => false ), |
| 70 |
array( 'label' => '07:00 PM', 'value' => '19:00', 'selected' => false ), |
| 71 |
array( 'label' => '08:00 PM', 'value' => '20:00', 'selected' => false ), |
| 72 |
array( 'label' => '09:00 PM', 'value' => '21:00', 'selected' => false ), |
| 73 |
array( 'label' => '10:00 PM', 'value' => '22:00', 'selected' => false ), |
| 74 |
), |
| 75 |
), |
| 76 |
|
| 77 |
// Generator defaults -> AM/PM initially. |
| 78 |
'gen_label_fmt' => array( 'type' => 'string', 'default' => 'ampm' ), // 'ampm' | '24h' |
| 79 |
'gen_start_24h' => array( 'type' => 'string', 'default' => '08:00' ), |
| 80 |
'gen_end_24h' => array( 'type' => 'string', 'default' => '22:00' ), |
| 81 |
'gen_start_ampm_t' => array( 'type' => 'string', 'default' => '08:00' ), |
| 82 |
'gen_end_ampm_t' => array( 'type' => 'string', 'default' => '22:00' ), |
| 83 |
'gen_step_h' => array( 'type' => 'number', 'default' => 1, 'min' => 0, 'max' => 12 ), |
| 84 |
'gen_step_m' => array( 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 59 ), |
| 85 |
|
| 86 |
'min_width' => array( 'type' => 'string', 'default' => '180px' ), |
| 87 |
), |
| 88 |
), |
| 89 |
|
| 90 |
'templates_printer' => 'wpbc_bfb_field_starttime_wptpl_print_templates', |
| 91 |
); |
| 92 |
|
| 93 |
return $packs; |
| 94 |
} |
| 95 |
add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__field_starttime_wptpl' ); |
| 96 |
|
| 97 |
/** |
| 98 |
* Palette item defaults — AM/PM labels, 24h values. |
| 99 |
* |
| 100 |
* @param string $group Group key. |
| 101 |
* @param string $position Position key. |
| 102 |
* @return void |
| 103 |
*/ |
| 104 |
function wpbc_bfb_palette_register_items__starttime_wptpl( $group, $position ) { |
| 105 |
if ( 'times' !== $group || 'bottom' !== $position ) { |
| 106 |
return; |
| 107 |
} |
| 108 |
|
| 109 |
$default_options = array( |
| 110 |
array( 'label' => '08:00 AM', 'value' => '08:00', 'selected' => false ), |
| 111 |
array( 'label' => '09:00 AM', 'value' => '09:00', 'selected' => false ), |
| 112 |
array( 'label' => '10:00 AM', 'value' => '10:00', 'selected' => false ), |
| 113 |
array( 'label' => '11:00 AM', 'value' => '11:00', 'selected' => false ), |
| 114 |
array( 'label' => '12:00 PM', 'value' => '12:00', 'selected' => false ), |
| 115 |
array( 'label' => '01:00 PM', 'value' => '13:00', 'selected' => false ), |
| 116 |
array( 'label' => '02:00 PM', 'value' => '14:00', 'selected' => false ), |
| 117 |
array( 'label' => '03:00 PM', 'value' => '15:00', 'selected' => false ), |
| 118 |
array( 'label' => '04:00 PM', 'value' => '16:00', 'selected' => false ), |
| 119 |
array( 'label' => '05:00 PM', 'value' => '17:00', 'selected' => false ), |
| 120 |
array( 'label' => '06:00 PM', 'value' => '18:00', 'selected' => false ), |
| 121 |
array( 'label' => '07:00 PM', 'value' => '19:00', 'selected' => false ), |
| 122 |
array( 'label' => '08:00 PM', 'value' => '20:00', 'selected' => false ), |
| 123 |
array( 'label' => '09:00 PM', 'value' => '21:00', 'selected' => false ), |
| 124 |
array( 'label' => '10:00 PM', 'value' => '22:00', 'selected' => false ), |
| 125 |
); |
| 126 |
?> |
| 127 |
<li class="wpbc_bfb__field" |
| 128 |
data-id="starttime" |
| 129 |
data-type="starttime" |
| 130 |
data-usage_key="starttime" |
| 131 |
data-usagenumber="1" |
| 132 |
data-min_width="180px" |
| 133 |
data-label="<?php echo esc_attr( __( 'Start time', 'booking' ) ); ?>" |
| 134 |
data-name="starttime" |
| 135 |
data-required="true" |
| 136 |
data-autoname="0" |
| 137 |
data-fresh="0" |
| 138 |
data-name_user_touched="1" |
| 139 |
data-options="<?php echo esc_attr( wp_json_encode( $default_options ) ); ?>"> |
| 140 |
<i class="menu_icon icon-1x wpbc_icn_restore"></i> |
| 141 |
<span class="wpbc_bfb__field-label"><?php echo esc_html( __( 'Start time', 'booking' ) ); ?></span> |
| 142 |
<span class="wpbc_bfb__field-type">starttime</span> |
| 143 |
</li> |
| 144 |
<?php |
| 145 |
} |
| 146 |
add_action( 'wpbc_bfb_palette_register_items', 'wpbc_bfb_palette_register_items__starttime_wptpl', 10, 2 ); |
| 147 |
|
| 148 |
|
| 149 |
/** |
| 150 |
* Enqueue the Start Time pack JS. |
| 151 |
* |
| 152 |
* @param string $page Current admin page slug. |
| 153 |
* @return void |
| 154 |
*/ |
| 155 |
function wpbc_bfb_enqueue__field_starttime_wptpl_js( $page ) { |
| 156 |
// iMask.js is already enqueued on this page. |
| 157 |
wp_enqueue_script( |
| 158 |
'wpbc-bfb_field_starttime_wptpl', |
| 159 |
wpbc_plugin_url( '/includes/page-form-builder/field-packs/time-start/_out/field-starttime-wptpl.js' ), |
| 160 |
array( 'wp-util', 'wpbc-bfb', 'wpbc-bfb-time-utils' ), |
| 161 |
WP_BK_VERSION_NUM, |
| 162 |
true |
| 163 |
); |
| 164 |
} |
| 165 |
add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__field_starttime_wptpl_js', 10, 1 ); |
| 166 |
|
| 167 |
|
| 168 |
/** |
| 169 |
* Print wp.template() blocks (Preview + Inspector) for Start Time. |
| 170 |
* |
| 171 |
* @param string $page Builder page slug. |
| 172 |
* @return void |
| 173 |
*/ |
| 174 |
function wpbc_bfb_field_starttime_wptpl_print_templates( $page ) { |
| 175 |
|
| 176 |
if ( WPBC_BFB_BUILDER_PAGE_SLUG !== $page ) { |
| 177 |
return; |
| 178 |
} |
| 179 |
|
| 180 |
?> |
| 181 |
<script type="text/html" id="tmpl-wpbc-bfb-field-starttime"> |
| 182 |
<span class="wpbc_bfb__noaction wpbc_bfb__no-drag-zone" inert="" style="min-width: {{ data.min_width || '180px' }}"> |
| 183 |
<# var is_req = ( true === data.required || 'true' === data.required || 1 === data.required || '1' === data.required ); #> |
| 184 |
|
| 185 |
<# if ( data.label && data.label !== '' ) { #> |
| 186 |
<label class="wpbc_bfb__field-label" <# if ( data.html_id ) { #> for="{{ data.html_id }}" <# } #>> |
| 187 |
{{ data.label }} <# if ( is_req ) { #><span aria-hidden="true">*</span><# } #> |
| 188 |
</label> |
| 189 |
<# } #> |
| 190 |
|
| 191 |
<span class="wpbc_wrap_text wpdev-form-control-wrap"> |
| 192 |
<select |
| 193 |
class="wpbc_bfb__preview-input wpbc_bfb__preview-select wpbc_bfb__preview-starttime wpbc_bfb__preview-timepicker {{ data.cssclass || '' }}" |
| 194 |
name="{{ (data.name || data.id || 'starttime') }}" |
| 195 |
tabindex="-1" aria-disabled="true" |
| 196 |
<# if ( data.html_id ) { #> id="{{ data.html_id }}" <# } #> |
| 197 |
<# if ( is_req ) { #> required aria-required="true" <# } #> |
| 198 |
> |
| 199 |
<# |
| 200 |
var has_marked = Array.isArray( data.options ) && data.options.some( function(o){ |
| 201 |
return !! o && ( true === o.selected || 'true' === o.selected || 1 === o.selected || '1' === o.selected ); |
| 202 |
} ); |
| 203 |
var has_text_default = ( (data.default_value != null) && String( data.default_value ).trim() !== '' ); |
| 204 |
var has_any_default = has_marked || has_text_default; |
| 205 |
|
| 206 |
var selected_set = {}; |
| 207 |
if ( has_marked ) { |
| 208 |
( data.options || [] ).forEach( function(o){ |
| 209 |
if ( o && ( true === o.selected || 'true' === o.selected || 1 === o.selected || '1' === o.selected ) ) { |
| 210 |
selected_set[ String( o.value || '' ) ] = true; |
| 211 |
} |
| 212 |
} ); |
| 213 |
} else if ( has_text_default ) { |
| 214 |
selected_set[ String( data.default_value ) ] = true; |
| 215 |
} |
| 216 |
#> |
| 217 |
|
| 218 |
<# if ( data.placeholder && ! has_any_default ) { #> |
| 219 |
<option value="" selected="selected" disabled="disabled">{{ data.placeholder }}</option> |
| 220 |
<# } #> |
| 221 |
|
| 222 |
<# |
| 223 |
var _opts = Array.isArray( data.options ) ? data.options |
| 224 |
: ( function(o){ var a=[],k; for ( k in (o||{}) ){ if ( Object.prototype.hasOwnProperty.call(o,k) ){ a.push( o[k] ); } } return a; } )( data.options ); |
| 225 |
_opts.forEach( function( opt ){ |
| 226 |
if ( ! opt ) { return; } |
| 227 |
var _val = String( opt.value || '' ); |
| 228 |
var _lbl = String( opt.label || '' ); |
| 229 |
var _sel = !! selected_set[ _val ]; |
| 230 |
#> |
| 231 |
<option value="{{ _val }}" <# if ( _sel ) { #> selected <# } #> >{{ _lbl }}</option> |
| 232 |
<# }); #> |
| 233 |
</select> |
| 234 |
</span> |
| 235 |
|
| 236 |
<# if ( data.help ) { #> |
| 237 |
<div class="wpbc_bfb__help">{{ data.help }}</div> |
| 238 |
<# } #> |
| 239 |
</span> |
| 240 |
</script> |
| 241 |
|
| 242 |
<script type="text/html" id="tmpl-wpbc-bfb-inspector-starttime"> |
| 243 |
<style type="text/css"> |
| 244 |
.wpbc_admin .wpbc_ui_el__vert_right_bar__wrapper:has(.wpbc_bfb__inspector_timepicker) { |
| 245 |
--wpbc_ui_left_vert_nav__width_max: Min(580px, 100%); |
| 246 |
} |
| 247 |
</style> |
| 248 |
<div class="wpbc_bfb__inspector_starttime wpbc_bfb__inspector_timepicker" data-type="starttime" |
| 249 |
data-i18n-add="<?php echo esc_attr__( 'Add New', 'booking' ); ?>" |
| 250 |
data-i18n-duplicate="<?php echo esc_attr__( 'Duplicate', 'booking' ); ?>" |
| 251 |
data-i18n-remove="<?php echo esc_attr__( 'Remove', 'booking' ); ?>" |
| 252 |
data-i18n-default="<?php echo esc_attr__( 'Default', 'booking' ); ?>" |
| 253 |
data-i18n-reorder="<?php echo esc_attr__( 'Drag to reorder', 'booking' ); ?>" |
| 254 |
data-i18n-rowlabel="<?php echo esc_attr__( 'Label (e.g. 10:00 AM)', 'booking' ); ?>" |
| 255 |
> |
| 256 |
<div class="wpbc_bfb__inspector__head"> |
| 257 |
<div class="header_container"> |
| 258 |
<div class="header_title_content"> |
| 259 |
<h3 class="title"><?php echo esc_html__( 'Start time', 'booking' ); ?></h3> |
| 260 |
<div class="desc"><?php echo esc_html__( 'Use the generator to quickly create time points.', 'booking' ); ?></div> |
| 261 |
</div> |
| 262 |
<div class="actions wpbc_ajx_toolbar wpbc_no_borders"> |
| 263 |
<div class="ui_container ui_container_small"> |
| 264 |
<div class="ui_group"> |
| 265 |
<div class="ui_element"> |
| 266 |
<button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button" data-action="deselect" aria-label="<?php echo esc_attr__( 'Deselect', 'booking' ); ?>"> |
| 267 |
<i class="menu_icon icon-1x wpbc_icn_remove_done"></i> |
| 268 |
</button> |
| 269 |
<button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button" data-action="scrollto" aria-label="<?php echo esc_attr__( 'Scroll to field', 'booking' ); ?>"> |
| 270 |
<i class="menu_icon icon-1x wpbc_icn_ads_click filter_center_focus"></i> |
| 271 |
</button> |
| 272 |
</div> |
| 273 |
<div class="ui_element"> |
| 274 |
<button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button" data-action="move-up" aria-label="<?php echo esc_attr__( 'Move up', 'booking' ); ?>"> |
| 275 |
<i class="menu_icon icon-1x wpbc_icn_arrow_upward"></i> |
| 276 |
</button> |
| 277 |
<button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button" data-action="move-down" aria-label="<?php echo esc_attr__( 'Move down', 'booking' ); ?>"> |
| 278 |
<i class="menu_icon icon-1x wpbc_icn_arrow_downward"></i> |
| 279 |
</button> |
| 280 |
</div> |
| 281 |
<div class="ui_element"> |
| 282 |
<button data-action="delete" aria-label="<?php echo esc_attr__( 'Delete', 'booking' ); ?>" type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button wpbc_ui_button_danger button-link-delete"> |
| 283 |
<span class="in-button-text"><?php echo esc_html__( 'Delete', 'booking' ); ?></span> <i class="menu_icon icon-1x wpbc_icn_delete_outline"></i> |
| 284 |
</button> |
| 285 |
</div> |
| 286 |
</div><!-- .ui_group --> |
| 287 |
</div><!-- .ui_container --> |
| 288 |
</div><!-- .actions --> |
| 289 |
|
| 290 |
<?php if ( ! function_exists( 'wpbc_is_mu_user_can_be_here' ) || wpbc_is_mu_user_can_be_here( 'only_super_admin' ) ) { ?> |
| 291 |
<div class="wpbc_ui__collapsible_group" style="width: 99%;"> |
| 292 |
<div class="inspector__row row__bordered" style="background:#f8f8f8;border:0;justify-content: space-between;"> |
| 293 |
<label class="inspector__label"><?php echo esc_html__( 'Show as time picker', 'booking' ); ?></label> |
| 294 |
<div class="inspector__control" style="flex: 0 1 auto;"> |
| 295 |
<input type="checkbox" class="inspector__checkbox js-toggle-timeslot-picker"> |
| 296 |
<p class="wpbc_bfb__help" style="margin-top:6px;"> |
| 297 |
<?php echo esc_html__( 'Toggle between selectbox and clickable time slots.', 'booking' ); ?> |
| 298 |
</p> |
| 299 |
</div> |
| 300 |
<?php |
| 301 |
$opt_name = 'booking_timeslot_picker'; |
| 302 |
$nonce_action = 'wpbc_nonce_' . $opt_name; |
| 303 |
?> |
| 304 |
<a href="javascript:void(0);" |
| 305 |
class="button button-secondary" |
| 306 |
onclick="wpbc_save_option_from_element(this);" |
| 307 |
data-wpbc-u-save-name="<?php echo esc_attr( $opt_name ); ?>" |
| 308 |
data-wpbc-u-save-nonce="<?php echo esc_attr( wp_create_nonce( $nonce_action ) ); ?>" |
| 309 |
data-wpbc-u-save-action="<?php echo esc_attr( $nonce_action ); ?>" |
| 310 |
data-wpbc-u-save-value-from=".wpbc_bfb__inspector_timepicker .js-toggle-timeslot-picker" |
| 311 |
data-wpbc-u-autosave-on-form-save="1" |
| 312 |
data-wpbc-u-busy-text="<?php esc_attr_e( 'Saving', 'booking' ); ?>..."> |
| 313 |
<?php esc_html_e( 'Save Toggle', 'booking' ); ?> |
| 314 |
</a> |
| 315 |
</div> |
| 316 |
</div> |
| 317 |
<?php } ?> |
| 318 |
|
| 319 |
</div><!-- .header_container --> |
| 320 |
</div><!-- .wpbc_bfb__inspector__head --> |
| 321 |
|
| 322 |
<div class="wpbc_bfb__inspector__body"> |
| 323 |
|
| 324 |
<section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="basic"> |
| 325 |
<button type="button" class="group__header"> |
| 326 |
<h3><?php echo esc_html__( 'Basic', 'booking' ); ?></h3> |
| 327 |
<i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i> |
| 328 |
</button> |
| 329 |
<div class="group__fields"> |
| 330 |
<div class="inspector__row"> |
| 331 |
<label class="inspector__label"><?php echo esc_html__( 'Label', 'booking' ); ?></label> |
| 332 |
<div class="inspector__control"> |
| 333 |
<input type="text" class="inspector__input" data-inspector-key="label" value="{{ data.label || '<?php echo esc_js( __( 'Start time', 'booking' ) ); ?>' }}"> |
| 334 |
</div> |
| 335 |
</div> |
| 336 |
|
| 337 |
<div class="inspector__row"> |
| 338 |
<label class="inspector__label"><?php echo esc_html__( 'Name', 'booking' ); ?></label> |
| 339 |
<div class="inspector__control"> |
| 340 |
<input type="text" class="inspector__input" value="{{ (data.name && data.name !== '' ? data.name : 'starttime') }}" disabled="disabled" aria-disabled="true"> |
| 341 |
<input type="hidden" class="inspector__input js-locked-name" data-inspector-key="name" data-locked="1" value="{{ (data.name && data.name !== '' ? data.name : 'starttime') }}"> |
| 342 |
<p class="wpbc_bfb__help" style="margin-top:6px;"><?php echo esc_html__( 'This field name is fixed for compatibility.', 'booking' ); ?></p> |
| 343 |
</div> |
| 344 |
</div> |
| 345 |
|
| 346 |
<div class="inspector__row"> |
| 347 |
<div class="inspector__control "> |
| 348 |
<span class="wpbc_ui__toggle"> |
| 349 |
<# var input_id = window.WPBC_BFB_Core.UI.WPBC_BFB_Toggle_Normalizer.generate_unique_id( 'wpbc_ins_auto_' + 'toggle_required' + '_' ); #> |
| 350 |
<input type="checkbox" id="{{input_id}}" class="inspector__checkbox js-required-visible" checked disabled aria-disabled="true" data-wpbc-ui-no-toggle="1"> |
| 351 |
<label class="wpbc_ui__toggle_icon" for="{{input_id}}"></label> |
| 352 |
<label class="wpbc_ui__toggle_label" for="{{input_id}}"><?php echo esc_html__( 'Required', 'booking' ); ?></label> |
| 353 |
</span> |
| 354 |
<input type="checkbox" class="inspector__checkbox js-required-proxy" data-inspector-key="required" data-locked="1" checked data-wpbc-ui-no-toggle="1" style="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;"> |
| 355 |
<p class="wpbc_bfb__help" style="margin-inline-start:1em;display: inline-block;"><?php echo esc_html__( 'This field is always required.', 'booking' ); ?></p> |
| 356 |
</div> |
| 357 |
</div> |
| 358 |
|
| 359 |
<div class="inspector__row"> |
| 360 |
<label class="inspector__label"><?php echo esc_html__( 'Help text', 'booking' ); ?></label> |
| 361 |
<div class="inspector__control"> |
| 362 |
<textarea class="inspector__textarea" rows="3" data-inspector-key="help">{{ data.help || '' }}</textarea> |
| 363 |
</div> |
| 364 |
</div> |
| 365 |
</div> |
| 366 |
</section> |
| 367 |
|
| 368 |
<section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group is-open" data-group="options"> |
| 369 |
<button type="button" class="group__header"> |
| 370 |
<h3><?php echo esc_html__( 'Time options', 'booking' ); ?></h3> |
| 371 |
<i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i> |
| 372 |
</button> |
| 373 |
|
| 374 |
<div class="group__fields inspector__group__fields__times"> |
| 375 |
|
| 376 |
<?php /* ===== Generator ===== */ ?> |
| 377 |
<div class="inspector__row"> |
| 378 |
<div class="inspector__control inspector__control__generator_times"> |
| 379 |
|
| 380 |
<# var __fmt_name = 'st_label_fmt_' + ( data.html_id ? data.html_id : ( 'id_' + String( Math.random() ).slice(2) ) ); #> |
| 381 |
<h2><?php echo esc_html__( 'Generate times', 'booking' ); ?></h2> |
| 382 |
<div class="wpbc_bfb__st_gen_format wpbc_inline_inputs" role="radiogroup" aria-label="<?php echo esc_attr__( 'Time format', 'booking' ); ?>"> |
| 383 |
<label class="inspector__label inspector__w_30"><?php echo esc_html__( 'Time format', 'booking' ); ?>:</label> |
| 384 |
<div class="wpbc_inline_inputs inspector__w_70"> |
| 385 |
|
| 386 |
<input type="hidden" class="inspector__input js-st-label-fmt-value" data-inspector-key="gen_label_fmt" value="{{ data.gen_label_fmt || 'ampm' }}"> |
| 387 |
|
| 388 |
<label> |
| 389 |
<input type="radio" name="{{ __fmt_name }}" class="js-st-label-fmt" value="ampm" <# if ( (data.gen_label_fmt||'ampm') === 'ampm' ) { #> checked <# } #> > |
| 390 |
<?php echo esc_html__( 'AM/PM', 'booking' ); ?> |
| 391 |
</label> |
| 392 |
|
| 393 |
<label> |
| 394 |
<input type="radio" name="{{ __fmt_name }}" class="js-st-label-fmt" value="24h" <# if ( (data.gen_label_fmt||'ampm') === '24h' ) { #> checked <# } #> > |
| 395 |
<?php echo esc_html__( '24H', 'booking' ); ?> |
| 396 |
</label> |
| 397 |
</div> |
| 398 |
</div> |
| 399 |
|
| 400 |
<div class="wpbc_bfb__st_gen_times" style="margin-top:8px;"> |
| 401 |
<!-- 24H group (masked text inputs) --> |
| 402 |
<div class="js-st-24h wpbc_inline_inputs" <# if ( (data.gen_label_fmt||'24h') !== '24h' ) { #> style="display:none" hidden aria-hidden="true" <# } #>> |
| 403 |
<label class="inspector__label inspector__w_30"><?php echo esc_html__( 'From / To', 'booking' ); ?>:</label> |
| 404 |
<div class="wpbc_inline_inputs inspector__w_70"> |
| 405 |
<div class="inspector__control inspector__w_45"> |
| 406 |
<input type="text" class="inspector__input inspector__w_25 js-st-mask js-gen-start-24h" data-mask-kind="24h" placeholder="HH:MM" data-inspector-key="gen_start_24h" value="{{ data.gen_start_24h || '08:00' }}"> |
| 407 |
</div> |
| 408 |
<div class="inspector__control inspector__w_10" style="text-align: center;font-size: 18px;line-height: 2;font-weight: 700;">–</div> |
| 409 |
<div class="inspector__control inspector__w_45"> |
| 410 |
<input type="text" class="inspector__input inspector__w_25 js-st-mask js-gen-end-24h" data-mask-kind="24h" placeholder="HH:MM" data-inspector-key="gen_end_24h" value="{{ data.gen_end_24h || '22:00' }}"> |
| 411 |
</div> |
| 412 |
</div> |
| 413 |
</div> |
| 414 |
|
| 415 |
<!-- AM/PM group (native time inputs) --> |
| 416 |
<div class="js-st-ampm wpbc_inline_inputs" <# if ( (data.gen_label_fmt||'24h') === '24h' ) { #> style="display:none" hidden aria-hidden="true" <# } #>> |
| 417 |
<label class="inspector__label inspector__w_30"><?php echo esc_html__( 'From / To', 'booking' ); ?>:</label> |
| 418 |
<div class="wpbc_inline_inputs inspector__w_70"> |
| 419 |
<div class="inspector__control inspector__w_45"> |
| 420 |
<input type="time" class="inspector__input inspector__w_25 js-gen-start-ampm-time" step="300" data-inspector-key="gen_start_ampm_t" value="{{ data.gen_start_ampm_t || '08:00' }}"> |
| 421 |
</div> |
| 422 |
<div class="inspector__control inspector__w_10" style="text-align: center;font-size: 18px;line-height: 2;font-weight: 700;">–</div> |
| 423 |
<div class="inspector__control inspector__w_45"> |
| 424 |
<input type="time" class="inspector__input inspector__w_25 js-gen-end-ampm-time" step="300" data-inspector-key="gen_end_ampm_t" value="{{ data.gen_end_ampm_t || '22:00' }}"> |
| 425 |
</div> |
| 426 |
</div> |
| 427 |
</div> |
| 428 |
</div> |
| 429 |
|
| 430 |
<div class="wpbc_bfb__st_gen_step wpbc_inline_inputs"> |
| 431 |
<label class="inspector__label inspector__w_30"><?php echo esc_html__( 'Step', 'booking' ); ?></label> |
| 432 |
<div class="wpbc_len_group wpbc_inline_inputs inspector__w_70" data-len-group="st-step-hours"> |
| 433 |
<div class="inspector__control inspector__w_10"><?php echo esc_html__( 'hours', 'booking' ); ?>:</div> |
| 434 |
<input data-len-range type="range" class="inspector__input js-gen-step-h-range" min="0" max="12" step="1" value="{{ data.gen_step_h || 1 }}"> |
| 435 |
<input data-len-value type="number" class="inspector__input inspector__w_30 js-gen-step-h" data-inspector-key="gen_step_h" min="0" max="12" step="1" value="{{ data.gen_step_h || 1 }}"> |
| 436 |
</div> |
| 437 |
</div> |
| 438 |
|
| 439 |
<div class="wpbc_bfb__st_gen_step wpbc_inline_inputs"> |
| 440 |
<label class="inspector__label inspector__w_30"></label> |
| 441 |
<div class="wpbc_len_group wpbc_inline_inputs inspector__w_70" data-len-group="st-step-minutes"> |
| 442 |
<div class="inspector__control inspector__w_10"><?php echo esc_html__( 'minutes', 'booking' ); ?>:</div> |
| 443 |
<input data-len-range type="range" class="inspector__input js-gen-step-m-range" min="0" max="59" step="5" value="{{ data.gen_step_m || 0 }}"> |
| 444 |
<input data-len-value type="number" class="inspector__input inspector__w_30 js-gen-step-m" data-inspector-key="gen_step_m" min="0" max="59" step="5" value="{{ data.gen_step_m || 0 }}"> |
| 445 |
</div> |
| 446 |
</div> |
| 447 |
|
| 448 |
<div class="wpbc_bfb__options_toolbar wpbc_inline_inputs"> |
| 449 |
<div class="inspector__control inspector__w_100" style="text-align: center;"> |
| 450 |
<button type="button" class="button button-primary js-st-generate"><?php echo esc_html__( 'Generate times', 'booking' ); ?> <i class="menu_icon icon-1x wpbc_icn_arrow_downward" aria-hidden="true"></i></button> |
| 451 |
</div> |
| 452 |
</div> |
| 453 |
|
| 454 |
</div> |
| 455 |
</div> |
| 456 |
|
| 457 |
<?php /* ===== Options editor ===== */ ?> |
| 458 |
<div class="inspector__row wpbc_bfb__options_editor"> |
| 459 |
<div class="wpbc_bfb__options_list__header"> |
| 460 |
<div class="wpbc_bfb__header_col__drag-handle"></div> |
| 461 |
<div class="wpbc_bfb__header_col__label"><?php echo esc_html__( 'Label', 'booking' ) . ' (' . esc_html__( 'any text', 'booking' ) . ')'; ?></div> |
| 462 |
<div class="wpbc_bfb__header_col__value"><?php echo esc_html__( 'Time', 'booking' ); ?></div> |
| 463 |
<div class="wpbc_bfb__header_col__action"></div> |
| 464 |
</div> |
| 465 |
<div class="wpbc_bfb__options_list"> |
| 466 |
<# |
| 467 |
var _opts2 = Array.isArray( data.options ) ? data.options |
| 468 |
: ( function(o){ var a=[],k; for ( k in (o || {}) ) { if ( Object.prototype.hasOwnProperty.call( o, k ) ) { a.push( o[ k ] ); } } return a; } )( data.options ); |
| 469 |
#> |
| 470 |
|
| 471 |
<# _opts2.forEach( function( opt, idx ){ |
| 472 |
var _val = String( opt && opt.value || '' ); |
| 473 |
var __uid = 'wpbc_ins_st_' + Math.random().toString(36).slice(2,10); |
| 474 |
var __sel = !!( opt && ( true === opt.selected || 'true' === opt.selected || 1 === opt.selected || '1' === opt.selected ) ); |
| 475 |
#> |
| 476 |
<div class="wpbc_bfb__options_row" data-index="{{ idx }}"> |
| 477 |
<span class="wpbc_bfb__drag-handle" title="<?php echo esc_attr__( 'Drag to reorder', 'booking' ); ?>"><span class="wpbc_icn_drag_indicator"></span></span> |
| 478 |
|
| 479 |
<input type="text" class="wpbc_bfb__opt-label" placeholder="<?php echo esc_attr__( 'Label (e.g. 10:00 AM)', 'booking' ); ?>" value="{{ opt && opt.label || '' }}"> |
| 480 |
|
| 481 |
<# if ( (data.gen_label_fmt||'24h') === '24h' ) { #> |
| 482 |
<input type="text" class="wpbc_bfb__opt-time js-st-mask" data-mask-kind="24h" placeholder="HH:MM" value="{{ _val }}"> |
| 483 |
<# } else { #> |
| 484 |
<input type="time" class="wpbc_bfb__opt-time js-st-time" step="300" value="{{ _val }}"> |
| 485 |
<# } #> |
| 486 |
|
| 487 |
<input type="text" class="wpbc_bfb__opt-value" value="{{ _val }}" hidden> |
| 488 |
|
| 489 |
<div class="wpbc_bfb__opt-selected"> |
| 490 |
<div class="inspector__control wpbc_ui__toggle"> |
| 491 |
<input type="checkbox" class="wpbc_bfb__opt-selected-chk inspector__input" id="{{ __uid }}" role="switch" aria-checked="{{ __sel ? 'true' : 'false' }}" <# if ( __sel ) { #> checked <# } #> > |
| 492 |
<label class="wpbc_ui__toggle_icon_radio" for="{{ __uid }}"></label> |
| 493 |
<label class="wpbc_ui__toggle_label" for="{{ __uid ?>"><?php echo esc_js( __( 'Default', 'booking' ) ); ?></label> |
| 494 |
</div> |
| 495 |
</div> |
| 496 |
|
| 497 |
<div class="wpbc_ui_el wpbc_ui_el_container wpbc_ui_el__dropdown"> |
| 498 |
<a href="javascript:void(0)" data-toggle="wpbc_dropdown" aria-expanded="false" class="ul_dropdown_menu_toggle"> |
| 499 |
<i class="menu_icon icon-1x wpbc_icn_more_vert"></i> |
| 500 |
</a> |
| 501 |
<ul class="ul_dropdown_menu" role="menu" style="right:0px; left:auto;"> |
| 502 |
<li><a class="ul_dropdown_menu_li_action st_dropdown_action" data-st-action="add_after" href="javascript:void(0)"><?php echo esc_html__( 'Add New', 'booking' ); ?><i class="menu_icon icon-1x wpbc_icn_add_circle"></i></a></li> |
| 503 |
<li><a class="ul_dropdown_menu_li_action st_dropdown_action" data-st-action="duplicate" href="javascript:void(0)"><?php echo esc_html__( 'Duplicate', 'booking' ); ?><i class="menu_icon icon-1x wpbc_icn_content_copy"></i></a></li> |
| 504 |
<li class="divider"></li> |
| 505 |
<li><a class="ul_dropdown_menu_li_action st_dropdown_action" data-st-action="remove" href="javascript:void(0)"><?php echo esc_html__( 'Remove', 'booking' ); ?><i class="menu_icon icon-1x wpbc_icn_delete_outline"></i></a></li> |
| 506 |
</ul> |
| 507 |
</div> |
| 508 |
</div> |
| 509 |
<# }); #> |
| 510 |
</div> |
| 511 |
|
| 512 |
<div class="wpbc_bfb__options_toolbar "> |
| 513 |
<small class="desc"><?php echo esc_html__( 'Drag by handle to reorder. Only one “Default” can be checked.', 'booking' ); ?></small> |
| 514 |
<div class="wpbc_bfb__options_toolbar wpbc_inline_inputs"> |
| 515 |
<div class="inspector__control inspector__w_15"> |
| 516 |
<button type="button" class="button js-st-clear"><?php echo esc_html__( 'Clear all', 'booking' ); ?></button> |
| 517 |
</div> |
| 518 |
<div class="inspector__control inspector__w_85"> |
| 519 |
<button type="button" class="button button-secondary js-st-add-option"> |
| 520 |
<i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x wpbc_icn_add_circle" aria-hidden="true"></i> |
| 521 |
<?php echo esc_html__( 'Add time', 'booking' ); ?> |
| 522 |
</button> |
| 523 |
</div> |
| 524 |
</div> |
| 525 |
</div> |
| 526 |
|
| 527 |
<# |
| 528 |
var __json = JSON.stringify(_opts2 || []); |
| 529 |
__json = __json.replace(/<\/textarea/gi, '<\\/textarea'); |
| 530 |
#> |
| 531 |
<textarea class="wpbc_bfb__options_state inspector__input" data-inspector-key="options" hidden>{{ __json }}</textarea> |
| 532 |
</div> |
| 533 |
|
| 534 |
<div class="inspector__row js-placeholder-row"> |
| 535 |
<label class="inspector__label"><?php echo esc_html__( 'Placeholder', 'booking' ); ?></label> |
| 536 |
<div class="inspector__control"> |
| 537 |
<input type="text" class="inspector__input js-placeholder" data-inspector-key="placeholder" value="{{ data.placeholder || '<?php echo '--- ' . esc_js( __( 'Select time', 'booking' ) ) . ' ---'; ?>' }}"> |
| 538 |
<p class="wpbc_bfb__help js-placeholder-note" style="margin-top:6px;"><?php echo esc_html__( 'Placeholder is used when no default is set.', 'booking' ); ?></p> |
| 539 |
</div> |
| 540 |
</div> |
| 541 |
|
| 542 |
</div> |
| 543 |
</section> |
| 544 |
|
| 545 |
<section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="appearance"> |
| 546 |
<button type="button" class="group__header"> |
| 547 |
<h3><?php echo esc_html__( 'Appearance', 'booking' ); ?></h3> |
| 548 |
<i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i> |
| 549 |
</button> |
| 550 |
<div class="group__fields"> |
| 551 |
|
| 552 |
<div class="inspector__row"> |
| 553 |
<label class="inspector__label"><?php echo esc_html__( 'CSS class', 'booking' ); ?></label> |
| 554 |
<div class="inspector__control"> |
| 555 |
<input type="text" class="inspector__input" data-inspector-key="cssclass" value="{{ data.cssclass || '' }}"> |
| 556 |
</div> |
| 557 |
</div> |
| 558 |
|
| 559 |
<div class="inspector__row"> |
| 560 |
<label class="inspector__label"><?php echo esc_html__( 'HTML ID', 'booking' ); ?></label> |
| 561 |
<div class="inspector__control"> |
| 562 |
<input type="text" class="inspector__input" data-inspector-key="html_id" value="{{ data.html_id || '' }}"> |
| 563 |
</div> |
| 564 |
</div> |
| 565 |
|
| 566 |
<div class="inspector__row"> |
| 567 |
<label class="inspector__label"><?php echo esc_html__( 'Min width', 'booking' ); ?></label> |
| 568 |
<div class="inspector__control"> |
| 569 |
<input type="text" class="inspector__input" data-inspector-key="min_width" placeholder="180px" value="{{ data.min_width || '180px' }}"> |
| 570 |
</div> |
| 571 |
</div> |
| 572 |
</div> |
| 573 |
</section> |
| 574 |
|
| 575 |
</div><!-- .wpbc_bfb__inspector__body --> |
| 576 |
</div><!-- .wpbc_bfb__inspector_starttime --> |
| 577 |
</script> |
| 578 |
<?php |
| 579 |
} |
| 580 |
|