| 1 |
/** |
| 2 |
* @version 1.0 |
| 3 |
* @package Booking Calendar |
| 4 |
* @subpackage Getenberg integration |
| 5 |
* @category inserting into posts |
| 6 |
* |
| 7 |
* @author wpdevelop |
| 8 |
* @link https://wpbookingcalendar.com/ |
| 9 |
* @email info@wpbookingcalendar.com |
| 10 |
* |
| 11 |
* @modified 2018-08-23Probably you updated your paid version of Booking Calendar |
| 12 |
*/ |
| 13 |
|
| 14 |
// FixIn: 8.3.3.99. |
| 15 |
|
| 16 |
/* |
| 17 |
window.wp.blocks, |
| 18 |
window.wp.components, |
| 19 |
window.wp.element |
| 20 |
|
| 21 |
*/ |
| 22 |
//( function( blocks, components, element ) { |
| 23 |
|
| 24 |
( function( wp ) { |
| 25 |
/** |
| 26 |
* Registers a new block provided a unique name and an object defining its behavior. |
| 27 |
* @see https://github.com/WordPress/gutenberg/tree/master/blocks#api |
| 28 |
*/ |
| 29 |
var registerBlockType = wp.blocks.registerBlockType; |
| 30 |
|
| 31 |
/** |
| 32 |
* Returns a new element of given type. Element is an abstraction layer atop React. |
| 33 |
* @see https://github.com/WordPress/gutenberg/tree/master/packages/element#element |
| 34 |
*/ |
| 35 |
var el = wp.element.createElement; |
| 36 |
|
| 37 |
/** |
| 38 |
* Retrieves the translation of text. |
| 39 |
* @see https://github.com/WordPress/gutenberg/tree/master/i18n#api |
| 40 |
*/ |
| 41 |
var __ = wp.i18n.__; |
| 42 |
|
| 43 |
// FixIn: 8.4.3.1. |
| 44 |
/* |
| 45 |
var source = wp.blocks.source, |
| 46 |
RichText = wp.editor.RichText, |
| 47 |
BlockControls = wp.editor.BlockControls, |
| 48 |
AlignmentToolbar = wp.editor.AlignmentToolbar;*/ |
| 49 |
|
| 50 |
/** |
| 51 |
* Custom SVG path for Booking Calendar icon |
| 52 |
*/ |
| 53 |
var wpbc_icon = el('svg', { width: 16, height: 16, fill: "currentColor", className: "bi bi-calendar3-range", viewBox: "-2 -1 20 20" }, |
| 54 |
el('path', { d: "M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z" } ), |
| 55 |
el('path', { d: "M7 10a1 1 0 0 0 0-2H1v2h6zm2-3h6V5H9a1 1 0 0 0 0 2z" } ) |
| 56 |
); |
| 57 |
|
| 58 |
registerBlockType( 'booking/booking', { |
| 59 |
|
| 60 |
title: 'Booking Calendar', |
| 61 |
|
| 62 |
description: __( 'Show a booking form, availability calendar or other elements from Booking Calendar plugin.' ), |
| 63 |
|
| 64 |
icon: wpbc_icon, // FixIn: 9.5.2.1. |
| 65 |
|
| 66 |
// icon: { |
| 67 |
// // Specifying a background color to appear with the icon e.g.: in the inserter. |
| 68 |
// background: 'rgb(129, 142, 160)', |
| 69 |
// // Specifying a color for the icon (optional: if not set, a readable color will be automatically defined) |
| 70 |
// foreground: '#fff', |
| 71 |
// // Specifying a dashicon for the block |
| 72 |
// src: 'calendar-alt' |
| 73 |
// }, |
| 74 |
|
| 75 |
category: 'common', // common | formatting | layout | widgets | embed |
| 76 |
|
| 77 |
/* |
| 78 |
// Use the block just once per post // its possible to use several Booking Calendar forms for different booking resources |
| 79 |
multiple: false, |
| 80 |
*/ |
| 81 |
|
| 82 |
// // Add the support for block's alignment (left, center, right, wide, full). |
| 83 |
// align: true, |
| 84 |
// |
| 85 |
// // Pick which alignment options to display. |
| 86 |
// align: [ 'left', 'right', 'full' ], |
| 87 |
|
| 88 |
keywords: [ 'wpbc' , 'oplugins', 'form' ], |
| 89 |
|
| 90 |
// // Specifying my block attributes |
| 91 |
attributes: { |
| 92 |
/*content: { |
| 93 |
type: 'string', |
| 94 |
source: 'children', |
| 95 |
selector: 'p', |
| 96 |
},*/ |
| 97 |
|
| 98 |
wpbc_shortcode: { |
| 99 |
type: 'string', |
| 100 |
default: '' |
| 101 |
} |
| 102 |
}, |
| 103 |
|
| 104 |
|
| 105 |
edit: function( props ) { |
| 106 |
|
| 107 |
//console.log( 'WPBC-Gb :: Edit :', props ); |
| 108 |
|
| 109 |
jQuery( '.wpbc-gutenberg-update-view').remove(); |
| 110 |
|
| 111 |
var children = [], |
| 112 |
cid = props.clientId; // its reference to unique 'data-block' attribute in section: <div class="editor-block-list__block-edit" data-block="8a1b713a-6981-43d3-a1f5-ce98b0e611d4"> ... |
| 113 |
|
| 114 |
var btnClassName = 'button wpbc-gutenberg-open-btn'; |
| 115 |
|
| 116 |
|
| 117 |
//////////////////////////////////////////////////////////////////////////////////////////////////// |
| 118 |
//////////////////////////////////////////////////////////////////////////////////////////////////// |
| 119 |
|
| 120 |
// Old value from attribute |
| 121 |
var _val = props.attributes.wpbc_shortcode; |
| 122 |
|
| 123 |
// Possibly new value, set to the text field programmatically from popup |
| 124 |
var _valNew = jQuery( 'div[data-block="' + cid + '"] .wpbc_gb_text_shortcode' ).val(); |
| 125 |
|
| 126 |
//console.log( '%cWPBC-Gb :: E d i t >>> _valNew , _val , cid, obj', 'color: green; font-weight: bold;', _valNew , _val , cid , jQuery( 'div[data-block="' + cid + '"] .wpbc_gb_text_shortcode' ) ); |
| 127 |
|
| 128 |
// Default value here |
| 129 |
if ( typeof _val == typeof undefined ) { |
| 130 |
_val = ''; |
| 131 |
} |
| 132 |
if ( ( typeof _valNew != typeof undefined ) && ( _val !== _valNew ) ) { |
| 133 |
_val = _valNew; |
| 134 |
props.setAttributes( { wpbc_shortcode: _val } ); |
| 135 |
} |
| 136 |
|
| 137 |
//////////////////////////////////////////////////////////////////////////////////////////////////// |
| 138 |
//////////////////////////////////////////////////////////////////////////////////////////////////// |
| 139 |
|
| 140 |
|
| 141 |
children.push( |
| 142 |
el( 'a', |
| 143 |
{ |
| 144 |
className : btnClassName, |
| 145 |
// href : 'javascript:void(0)', //FixIn: 8.7.3.17 href: '#!' |
| 146 |
href : '#!', |
| 147 |
data_block_id: cid, |
| 148 |
popup_tab_index: 0 // Will be index for active tab in popup dialog |
| 149 |
, key: 'configure_' + cid // FixIn: 8.7.3.18. |
| 150 |
}, |
| 151 |
__( 'Configure Booking Calendar Block' ) |
| 152 |
) |
| 153 |
); |
| 154 |
|
| 155 |
// Visual Preview of Block |
| 156 |
children = wpbc_gt_parse_shortcode( props.attributes.wpbc_shortcode, children , cid ); // FixIn: 8.7.3.18. |
| 157 |
|
| 158 |
//console.log( 'WPBC children', children) ; |
| 159 |
|
| 160 |
children.push( |
| 161 |
|
| 162 |
el( |
| 163 |
'input', |
| 164 |
{ |
| 165 |
key: 'onchangewpbcinput_' + cid, // FixIn: 8.7.3.18. |
| 166 |
value : _val, //props.attributes.wpbc_shortcode, |
| 167 |
onChange : function ( event ) { |
| 168 |
props.setAttributes( {wpbc_shortcode: event.target.value } ); |
| 169 |
//console.log( '%cWPBC-Gb :: o n C h a n g e !!!! Y E S !!! event for onChangeWPBCinputShortcode', 'color: orange; font-weight: bold;', event ); |
| 170 |
}, |
| 171 |
onClick: function (event) { // FixIn: 8.8.2.10. |
| 172 |
props.setAttributes( {wpbc_shortcode: event.target.value } ); |
| 173 |
}, |
| 174 |
className: 'wpbc_gb_text_shortcode', |
| 175 |
type : 'text', |
| 176 |
//readOnly : 'readonly', // FixIn: 8.8.2.10. |
| 177 |
//disabled : 'disabled', // FixIn: 8.8.2.10. |
| 178 |
// onFocus : function ( event ){ |
| 179 |
// event.target.select(); |
| 180 |
// } |
| 181 |
} |
| 182 |
) |
| 183 |
|
| 184 |
); |
| 185 |
|
| 186 |
|
| 187 |
// Show Hided Block (after configuration) -- React update Block preview |
| 188 |
jQuery( '.wpbc_gb_div_block' ).parent().removeClass( 'hidden' ); |
| 189 |
|
| 190 |
|
| 191 |
var wpbc_gb_div_block_css = 'wpbc_gb_div_block'; |
| 192 |
if ( '' == props.attributes.wpbc_shortcode ) { |
| 193 |
// If no shortcode at all, then do not hide configure button |
| 194 |
wpbc_gb_div_block_css += ' wpbc_gb_div_block_no_shortcode'; |
| 195 |
} |
| 196 |
|
| 197 |
return el( 'div', { className: wpbc_gb_div_block_css }, children ); |
| 198 |
}, |
| 199 |
|
| 200 |
|
| 201 |
save: function( props ) { |
| 202 |
|
| 203 |
//console.log( 'WPBC-Gb :: Saving ', props ); |
| 204 |
|
| 205 |
return el( 'div', null, props.attributes.wpbc_shortcode ); |
| 206 |
} |
| 207 |
|
| 208 |
|
| 209 |
} ); |
| 210 |
|
| 211 |
|
| 212 |
} )( |
| 213 |
window.wp |
| 214 |
); |
| 215 |
|
| 216 |
|
| 217 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 218 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 219 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 220 |
|
| 221 |
|
| 222 |
( function( $ ) { |
| 223 |
|
| 224 |
$( document ).on( 'click', '.wpbc_gb_block_preview_inner_title_edit', function( e ) { |
| 225 |
//jQuery( '.wpbc-gutenberg-open-btn' ).hide(); |
| 226 |
$( this ).closest( '.wpbc_gb_div_block' ).find( '.wpbc-gutenberg-open-btn' ).trigger( 'click' ); // FixIn: 8.7.11.12. |
| 227 |
|
| 228 |
}); |
| 229 |
|
| 230 |
/** |
| 231 |
* Open popup window for configuration Booking Calendar shortcode |
| 232 |
*/ |
| 233 |
$( document ).on( 'click', '.wpbc-gutenberg-open-btn', function( e ) { |
| 234 |
|
| 235 |
e.preventDefault(); |
| 236 |
|
| 237 |
// Set ID of currently edited section in post (just in case if we will have several sections |
| 238 |
var _id = $( this ).attr( 'data_block_id' ); |
| 239 |
|
| 240 |
|
| 241 |
// Remove CSS class 'is-selected' (remove blue focus) in main DIV (after popup opened), because of that hide via CSS BIG blue button: "Configure Booking Calendar Block" |
| 242 |
jQuery( 'div[data-block="' + _id + '"]' ).removeClass( 'is-selected' ); // FixIn: 8.8.2.10. |
| 243 |
|
| 244 |
// Get num. of popup active tab to set |
| 245 |
var popup_tab_index = $( this ).attr( 'popup_tab_index' ); |
| 246 |
|
| 247 |
var wpbc_tag = ''; |
| 248 |
|
| 249 |
wpbc_tiny_btn_click( wpbc_tag ); |
| 250 |
|
| 251 |
jQuery( "#wpbc_text_gettenberg_section_id" ).val( _id ); |
| 252 |
|
| 253 |
// Select specific TAB in poup dialog |
| 254 |
jQuery( "#wpbc_tiny_modal .wpdvlp-top-tabs a.nav-tab" ).eq( popup_tab_index ).trigger( 'click' ); // FixIn: 8.7.11.12. |
| 255 |
|
| 256 |
|
| 257 |
//console.log( 'WPBC-Gb :: Popup window for configuration Booking Calendar shortcode. Section #', _id ); |
| 258 |
|
| 259 |
}); |
| 260 |
|
| 261 |
|
| 262 |
/** |
| 263 |
* Remove Update view button after clicking on it. |
| 264 |
*/ |
| 265 |
$( document ).on( 'click', '.wpbc-gutenberg-update-preview-btn', function( e ) { |
| 266 |
|
| 267 |
e.preventDefault(); |
| 268 |
|
| 269 |
jQuery( '.wpbc-gutenberg-update-view').remove(); |
| 270 |
|
| 271 |
//console.log( 'WPBC-Gb :: Preview button clicked. Section #' ); |
| 272 |
|
| 273 |
}); |
| 274 |
|
| 275 |
|
| 276 |
} ) ( jQuery ); |
| 277 |
|
| 278 |
|
| 279 |
/** |
| 280 |
* Send shortcode from popup dialog into the gutenberg sections. |
| 281 |
* |
| 282 |
* @param shortcode_text |
| 283 |
* @returns {boolean} |
| 284 |
*/ |
| 285 |
function wpbc_send_text_to_gutenberg( shortcode_text ){ |
| 286 |
|
| 287 |
// Get ID of section, where to insert shortcode configuraiton |
| 288 |
var block_section_id = jQuery( "#wpbc_text_gettenberg_section_id" ).val(); |
| 289 |
|
| 290 |
//console.log( 'WPBC-Gb :: wpbc_send_text_to_gutenberg' , shortcode_text, block_section_id ); |
| 291 |
|
| 292 |
if ( '' == block_section_id ) { |
| 293 |
|
| 294 |
return false; // if no such block then just return false, its means tha inserting in Classic block - TinyMCE |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
// Code to insert into Gutenberg section in our text field |
| 299 |
jQuery( 'div[data-block="' + block_section_id + '"] .wpbc_gb_text_shortcode' ).val( shortcode_text ); |
| 300 |
|
| 301 |
//Its does not work for automatic generating "Edit" event :((( , so we make some workarround in Edit block event |
| 302 |
jQuery( 'div[data-block="' + block_section_id + '"] .wpbc_gb_text_shortcode' ).trigger( 'focus' ).trigger('mousedown').trigger( 'click' ).trigger('mouseup').trigger('change'); |
| 303 |
|
| 304 |
// FixIn: 8.4.2.10. |
| 305 |
//FixIn: 8.7.3.17 href: '#!' |
| 306 |
//FixIn: 8.7.3.19 - chnaged <a href="#!" to '<div href="#!" - its make update of block after clicking on DIV (and not A) element |
| 307 |
|
| 308 |
//FixIn: 8.8.2.10 - commenting these 2 blocks |
| 309 |
// jQuery( 'div[data-block="' + block_section_id + '"]' ).parent().parent().before( |
| 310 |
// '<div class="editor-block-list__block wpbc-gutenberg-update-view" style="cursor: pointer;text-align: center;">' + |
| 311 |
// '<div href="#!" class="button wpbc-gutenberg-update-preview-btn" ' + |
| 312 |
// '>' + wp.i18n.__( 'Click to Preview Block' ) + '</div></div>' |
| 313 |
// ); |
| 314 |
// // FixIn: 8.7.6.11. |
| 315 |
// jQuery( 'div[data-block="' + block_section_id + '"]' ).before( |
| 316 |
// '<div class="editor-block-list__block wpbc-gutenberg-update-view" style="cursor: pointer;text-align: center;">' + |
| 317 |
// '<div href="#!" class="button wpbc-gutenberg-update-preview-btn" ' + |
| 318 |
// '>' + wp.i18n.__( 'Click to Preview Block' ) + '</div></div>' |
| 319 |
// ); |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
// Hide entire Block -- until React does not update Block preview |
| 324 |
//jQuery( 'div[data-block="' + block_section_id + '"]' ).addClass( 'hidden' ); //FixIn: 8.8.2.10 - commenting |
| 325 |
|
| 326 |
// Neet to return true, to prevent insertion into some other TinyMCE block, if exist, because we have inserted it into Gutenberg |
| 327 |
return true; |
| 328 |
} |
| 329 |
|
| 330 |
|
| 331 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 332 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 333 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 338 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 339 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 340 |
|
| 341 |
/** |
| 342 |
* Parse shortcode in text field and show Visual Preview of element |
| 343 |
* |
| 344 |
* @param shortcode_in_text - shortcode from text field |
| 345 |
* @param children - array of el for gnerating preview |
| 346 |
* @returns - array of el |
| 347 |
*/ |
| 348 |
function wpbc_gt_parse_shortcode( shortcode_in_text, children, cid ){ // FixIn: 8.7.3.18. |
| 349 |
|
| 350 |
//console.log( 'wpbc_gt_parse_shortcode cid', cid ); |
| 351 |
|
| 352 |
var wpbc_shortcode_type |
| 353 |
, shortcode_obj |
| 354 |
, block_preview_el = '' |
| 355 |
, el = wp.element.createElement; |
| 356 |
|
| 357 |
var block_header_txt, block_text_txt; |
| 358 |
|
| 359 |
var wpbc_shortcode_type_arr = [ 'booking' |
| 360 |
, 'bookingcalendar' |
| 361 |
, 'bookingtimeline' |
| 362 |
, 'bookingselect' |
| 363 |
, 'bookingform' |
| 364 |
, 'bookingsearch' |
| 365 |
, 'bookingsearchresults' |
| 366 |
, 'bookingedit' |
| 367 |
, 'bookingcustomerlisting' |
| 368 |
, 'bookingresource' |
| 369 |
, 'booking_confirm' |
| 370 |
, 'booking-manager-import' |
| 371 |
, 'booking-manager-listing' |
| 372 |
]; |
| 373 |
var wpbc_shortcode_type_arr_length = wpbc_shortcode_type_arr.length; |
| 374 |
|
| 375 |
for ( var i = 0; i < wpbc_shortcode_type_arr_length ; i++ ){ |
| 376 |
|
| 377 |
wpbc_shortcode_type = wpbc_shortcode_type_arr[ i ]; |
| 378 |
|
| 379 |
shortcode_obj = wp.shortcode.next( wpbc_shortcode_type, shortcode_in_text, 0 ); // Parse shortcode |
| 380 |
|
| 381 |
if ( undefined != shortcode_obj ){ |
| 382 |
|
| 383 |
block_preview_el = ''; |
| 384 |
//console.log( 'wpbc_shortcode_type' , wpbc_shortcode_type); |
| 385 |
// Get Preview |
| 386 |
switch ( wpbc_shortcode_type ){ |
| 387 |
|
| 388 |
case 'booking': |
| 389 |
block_preview_el = wpbc_gt_get_visual_block_for_booking( shortcode_obj.shortcode, { |
| 390 |
'shortcode_in_text': shortcode_in_text |
| 391 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid // FixIn: 8.7.3.18. |
| 392 |
} ); |
| 393 |
children[ (children.length - 1) ].props.popup_tab_index = 0; // Set index of Active tab in popup dialog |
| 394 |
break; |
| 395 |
|
| 396 |
case 'bookingcalendar': |
| 397 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingcalendar( shortcode_obj.shortcode, { |
| 398 |
'shortcode_in_text': shortcode_in_text |
| 399 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 400 |
} ); |
| 401 |
children[ (children.length - 1) ].props.popup_tab_index = 2; // Set index of Active tab in popup dialog |
| 402 |
break; |
| 403 |
|
| 404 |
case 'bookingtimeline': |
| 405 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingtimeline( shortcode_obj.shortcode, { |
| 406 |
'shortcode_in_text': shortcode_in_text |
| 407 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 408 |
} ); |
| 409 |
children[ (children.length - 1) ].props.popup_tab_index = 1; // Set index of Active tab in popup dialog |
| 410 |
break; |
| 411 |
|
| 412 |
case 'bookingselect': |
| 413 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingselect( shortcode_obj.shortcode, { |
| 414 |
'shortcode_in_text': shortcode_in_text |
| 415 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 416 |
} ); |
| 417 |
children[ (children.length - 1) ].props.popup_tab_index = 3; // Set index of Active tab in popup dialog |
| 418 |
break; |
| 419 |
|
| 420 |
case 'bookingform': |
| 421 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingform( shortcode_obj.shortcode, { |
| 422 |
'shortcode_in_text': shortcode_in_text |
| 423 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 424 |
} ); |
| 425 |
children[ (children.length - 1) ].props.popup_tab_index = 5; // Set index of Active tab in popup dialog |
| 426 |
break; |
| 427 |
|
| 428 |
case 'bookingsearch': |
| 429 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingsearch( shortcode_obj.shortcode, { |
| 430 |
'shortcode_in_text': shortcode_in_text |
| 431 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 432 |
} ); |
| 433 |
children[ (children.length - 1) ].props.popup_tab_index = 4; // Set index of Active tab in popup dialog |
| 434 |
break; |
| 435 |
|
| 436 |
case 'bookingsearchresults': |
| 437 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingsearchresults( shortcode_obj.shortcode, { |
| 438 |
'shortcode_in_text': shortcode_in_text |
| 439 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 440 |
} ); |
| 441 |
children[ (children.length - 1) ].props.popup_tab_index = 4; // Set index of Active tab in popup dialog |
| 442 |
break; |
| 443 |
|
| 444 |
case 'bookingedit': |
| 445 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingedit( shortcode_obj.shortcode, { |
| 446 |
'shortcode_in_text': shortcode_in_text |
| 447 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 448 |
} ); |
| 449 |
children[ (children.length - 1) ].props.popup_tab_index = -1; // Set index of Active tab in popup dialog |
| 450 |
break; |
| 451 |
|
| 452 |
case 'bookingcustomerlisting': |
| 453 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingcustomerlisting( shortcode_obj.shortcode, { |
| 454 |
'shortcode_in_text': shortcode_in_text |
| 455 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 456 |
} ); |
| 457 |
children[ (children.length - 1) ].props.popup_tab_index = -1; // Set index of Active tab in popup dialog |
| 458 |
break; |
| 459 |
|
| 460 |
case 'bookingresource': |
| 461 |
block_preview_el = wpbc_gt_get_visual_block_for_bookingresource( shortcode_obj.shortcode, { |
| 462 |
'shortcode_in_text': shortcode_in_text |
| 463 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 464 |
} ); |
| 465 |
children[ (children.length - 1) ].props.popup_tab_index = -1; // Set index of Active tab in popup dialog |
| 466 |
break; |
| 467 |
|
| 468 |
case 'booking_confirm': |
| 469 |
block_preview_el = wpbc_gt_get_visual_block_for_booking_confirm( shortcode_obj.shortcode, { |
| 470 |
'shortcode_in_text': shortcode_in_text |
| 471 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 472 |
} ); |
| 473 |
children[ (children.length - 1) ].props.popup_tab_index = -1; // Set index of Active tab in popup dialog |
| 474 |
break; |
| 475 |
|
| 476 |
case 'booking-manager-import': |
| 477 |
block_preview_el = wpbc_gt_get_visual_block_for_booking_manager_import( shortcode_obj.shortcode, { |
| 478 |
'shortcode_in_text': shortcode_in_text |
| 479 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 480 |
} ); |
| 481 |
//block_preview_el = el( 'div', { className: 'test' }, 'Test Import 1' ); |
| 482 |
children[ (children.length - 1) ].props.popup_tab_index = -1; // Set index of Active tab in popup dialog |
| 483 |
break; |
| 484 |
|
| 485 |
case 'booking-manager-listing': |
| 486 |
block_preview_el = wpbc_gt_get_visual_block_for_booking_manager_listing( shortcode_obj.shortcode, { |
| 487 |
'shortcode_in_text': shortcode_in_text |
| 488 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 489 |
} ); |
| 490 |
//block_preview_el = el( 'div', { className: 'test' }, 'Test 2' ); |
| 491 |
children[ (children.length - 1) ].props.popup_tab_index = -1; // Set index of Active tab in popup dialog |
| 492 |
break; |
| 493 |
|
| 494 |
default: |
| 495 |
block_preview_el = wpbc_gt_get_visual_block_for_default( shortcode_obj.shortcode |
| 496 |
, { |
| 497 |
'shortcode_in_text': shortcode_in_text, |
| 498 |
'block_header' : block_header_txt, |
| 499 |
'block_text' : block_text_txt |
| 500 |
, 'cid_key': wpbc_shortcode_type+ '_' + cid |
| 501 |
} |
| 502 |
); |
| 503 |
|
| 504 |
} |
| 505 |
|
| 506 |
//console.log( 'WPBC-Gb :: block_preview_el', block_preview_el); |
| 507 |
|
| 508 |
if ( '' != block_preview_el ){ |
| 509 |
children.push( block_preview_el ); |
| 510 |
} |
| 511 |
} |
| 512 |
|
| 513 |
} |
| 514 |
|
| 515 |
return children; |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 520 |
|
| 521 |
|
| 522 |
/** |
| 523 |
* Generate Visual Preview Block - just general Shortcode |
| 524 |
* |
| 525 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 526 |
* @returns |
| 527 |
*/ |
| 528 |
function wpbc_gt_get_visual_block_for_default( shortcode_obj, params ){ |
| 529 |
|
| 530 |
// Booking Form Parameters // FixIn: 10.0.0.16. |
| 531 |
var shortcode_defaults = { |
| 532 |
type : 1, |
| 533 |
resource_id : 1, |
| 534 |
nummonths : 1, |
| 535 |
form_type : 'standard', |
| 536 |
aggregate : null, |
| 537 |
startmonth: null, |
| 538 |
options : null |
| 539 |
}; |
| 540 |
|
| 541 |
// // Calendar Parameters |
| 542 |
// var shortcode_defaults = { |
| 543 |
// type : 1, |
| 544 |
// resource_id : 1, |
| 545 |
// nummonths : 1, |
| 546 |
// aggregate : null, |
| 547 |
// startmonth: null, |
| 548 |
// options : null |
| 549 |
// }; |
| 550 |
|
| 551 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 552 |
|
| 553 |
var el = wp.element.createElement; |
| 554 |
|
| 555 |
//FixIn: 8.7.3.18 Start |
| 556 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 557 |
, wpbc_gb_tpl_header( { header: params[ 'block_header' ], cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 558 |
); |
| 559 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 560 |
, wpbc_gb_tpl_shortcode_parameters( |
| 561 |
[ |
| 562 |
{ block_text: params[ 'block_text' ] } |
| 563 |
, { name: 'Booking form', value: 'super-booking-admin'} |
| 564 |
, { name: 'Number of months to show', value: '2'} |
| 565 |
] |
| 566 |
, { cid_key: 'body_' + params[ 'cid_key' ] } |
| 567 |
) |
| 568 |
); |
| 569 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 570 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 571 |
); |
| 572 |
|
| 573 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_default' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 574 |
|
| 575 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 576 |
, [ inner_header, inner_body ] |
| 577 |
) |
| 578 |
, inner_footer |
| 579 |
); |
| 580 |
//FixIn: 8.7.3.18 End |
| 581 |
} |
| 582 |
|
| 583 |
|
| 584 |
/** |
| 585 |
* Generate Visual Preview Block of Booking form |
| 586 |
* |
| 587 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 588 |
* @returns |
| 589 |
*/ |
| 590 |
function wpbc_gt_get_visual_block_for_booking( shortcode_obj, params ){ |
| 591 |
|
| 592 |
// Booking Form Parameters // FixIn: 10.0.0.16. |
| 593 |
var shortcode_defaults = { |
| 594 |
type : 1, |
| 595 |
resource_id : 1, |
| 596 |
nummonths : 1, |
| 597 |
form_type : 'standard', |
| 598 |
aggregate : null, |
| 599 |
startmonth: null, |
| 600 |
options : null |
| 601 |
}; |
| 602 |
|
| 603 |
|
| 604 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 605 |
|
| 606 |
var el = wp.element.createElement; |
| 607 |
|
| 608 |
var inner_header = el( 'div', { |
| 609 |
className: 'wpbc_gb_block_preview_inner_header' |
| 610 |
, key: 'header_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 611 |
} |
| 612 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Booking Form' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 613 |
); |
| 614 |
var inner_body = el( 'div', { |
| 615 |
className: 'wpbc_gb_block_preview_inner_body' |
| 616 |
, key: 'body_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 617 |
} |
| 618 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_booking( props ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 619 |
); |
| 620 |
var inner_footer = el( 'div', { |
| 621 |
className: 'wpbc_gb_block_preview_inner_footer' |
| 622 |
, key: 'footer_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 623 |
} |
| 624 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 625 |
); |
| 626 |
|
| 627 |
|
| 628 |
return el( 'div', { |
| 629 |
className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_booking' |
| 630 |
, key: 'preview_wrapper_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 631 |
} |
| 632 |
, el( 'div', { |
| 633 |
className: 'wpbc_gb_block_shortcode_preview_content' |
| 634 |
, key: 'preview_content_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 635 |
} |
| 636 |
, [ inner_header, inner_body ] |
| 637 |
) |
| 638 |
, inner_footer |
| 639 |
); |
| 640 |
} |
| 641 |
|
| 642 |
|
| 643 |
/** |
| 644 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 645 |
* |
| 646 |
* @param props |
| 647 |
*/ |
| 648 |
function wpbc_parse_params_into_rows_arr_for_booking( props ){ |
| 649 |
//console.log( 'WPBC::props', props, props[ 'type' ], props[ 'resource_id' ]); |
| 650 |
// Parameters Description ///////////////////////////////// |
| 651 |
var rows_in_content = []; |
| 652 |
if ( (undefined != props[ 'type' ]) && ( 1 != props[ 'type' ]) ){ |
| 653 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource' ), value: 'ID = ' + props[ 'type' ]} ); |
| 654 |
} |
| 655 |
// FixIn: 10.0.0.16. |
| 656 |
if ( (undefined != props[ 'resource_id' ]) && ( 1 != props[ 'resource_id' ]) ){ |
| 657 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource' ), value: 'ID = ' + props[ 'resource_id' ]} ); |
| 658 |
} |
| 659 |
if ( undefined != props[ 'nummonths' ] ){ |
| 660 |
rows_in_content.push( {name: wp.i18n.__( 'Visible months number' ), value: props[ 'nummonths' ]} ); |
| 661 |
} |
| 662 |
if ( undefined != props[ 'startmonth' ] ) { |
| 663 |
rows_in_content.push( { name: wp.i18n.__( 'Start month' ), value: props[ 'startmonth' ] } ); |
| 664 |
} |
| 665 |
if ( ( undefined != props[ 'form_type' ] ) && ( 'standard' != props[ 'form_type' ] ) ){ |
| 666 |
rows_in_content.push( { name: wp.i18n.__( 'Custom booking form' ), value: props[ 'form_type' ] } ); |
| 667 |
} |
| 668 |
if ( undefined != props[ 'aggregate' ] ) { |
| 669 |
rows_in_content.push( { name: wp.i18n.__( 'Unavailable dates from other booking resources' ), value: 'ID = ' + props[ 'aggregate' ] } ); |
| 670 |
} |
| 671 |
if ( undefined != props[ 'options' ] ) { |
| 672 |
rows_in_content.push( { name: wp.i18n.__( 'Options' ), value: props[ 'options' ] } ); |
| 673 |
} |
| 674 |
|
| 675 |
return rows_in_content; |
| 676 |
} |
| 677 |
|
| 678 |
|
| 679 |
/** |
| 680 |
* Generate Visual Preview Block of Booking form |
| 681 |
* |
| 682 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 683 |
* @returns |
| 684 |
*/ |
| 685 |
function wpbc_gt_get_visual_block_for_bookingcalendar( shortcode_obj, params ){ |
| 686 |
|
| 687 |
// Booking Form Parameters // FixIn: 10.0.0.16. |
| 688 |
var shortcode_defaults = { |
| 689 |
type : 1, |
| 690 |
resource_id : 1, |
| 691 |
nummonths : 1, |
| 692 |
aggregate : null, |
| 693 |
startmonth: null, |
| 694 |
options : null |
| 695 |
}; |
| 696 |
|
| 697 |
|
| 698 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 699 |
|
| 700 |
var el = wp.element.createElement; |
| 701 |
|
| 702 |
var inner_header = el( 'div', { |
| 703 |
className: 'wpbc_gb_block_preview_inner_header' |
| 704 |
, key: 'header_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 705 |
} |
| 706 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Availability Calendar' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 707 |
); |
| 708 |
var inner_body = el( 'div', { |
| 709 |
className: 'wpbc_gb_block_preview_inner_body' |
| 710 |
, key: 'body_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 711 |
} |
| 712 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingcalendar( props ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 713 |
); |
| 714 |
var inner_footer = el( 'div', { |
| 715 |
className: 'wpbc_gb_block_preview_inner_footer' |
| 716 |
, key: 'footer_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 717 |
} |
| 718 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 719 |
); |
| 720 |
|
| 721 |
|
| 722 |
return el( 'div', { |
| 723 |
className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingcalendar' |
| 724 |
, key: 'preview_wrapper_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 725 |
} |
| 726 |
|
| 727 |
, el( 'div', { |
| 728 |
className: 'wpbc_gb_block_shortcode_preview_content' |
| 729 |
, key: 'preview_content_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 730 |
} |
| 731 |
, [ inner_header, inner_body ] |
| 732 |
) |
| 733 |
, inner_footer |
| 734 |
); |
| 735 |
} |
| 736 |
|
| 737 |
|
| 738 |
/** |
| 739 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 740 |
* |
| 741 |
* @param props |
| 742 |
*/ |
| 743 |
function wpbc_parse_params_into_rows_arr_for_bookingcalendar( props ){ |
| 744 |
|
| 745 |
// Parameters Description ///////////////////////////////// |
| 746 |
var rows_in_content = []; |
| 747 |
if ( (undefined != props[ 'type' ]) && ( 1 != props[ 'type' ]) ){ |
| 748 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource' ), value: 'ID = ' + props[ 'type' ]} ); |
| 749 |
} |
| 750 |
// FixIn: 10.0.0.16. |
| 751 |
if ( (undefined != props[ 'resource_id' ]) && ( 1 != props[ 'resource_id' ]) ){ |
| 752 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource' ), value: 'ID = ' + props[ 'resource_id' ]} ); |
| 753 |
} |
| 754 |
if ( undefined != props[ 'nummonths' ] ){ |
| 755 |
rows_in_content.push( {name: wp.i18n.__( 'Visible months number' ), value: props[ 'nummonths' ]} ); |
| 756 |
} |
| 757 |
if ( undefined != props[ 'startmonth' ] ) { |
| 758 |
rows_in_content.push( { name: wp.i18n.__( 'Start month' ), value: props[ 'startmonth' ] } ); |
| 759 |
} |
| 760 |
if ( undefined != props[ 'aggregate' ] ) { |
| 761 |
rows_in_content.push( { name: wp.i18n.__( 'Unavailable dates from other booking resources' ), value: 'ID = ' + props[ 'aggregate' ] } ); |
| 762 |
} |
| 763 |
if ( undefined != props[ 'options' ] ) { |
| 764 |
rows_in_content.push( { name: wp.i18n.__( 'Options' ), value: props[ 'options' ] } ); |
| 765 |
} |
| 766 |
|
| 767 |
return rows_in_content; |
| 768 |
} |
| 769 |
|
| 770 |
|
| 771 |
/** |
| 772 |
* Generate Visual Preview Block of TimeLine |
| 773 |
* |
| 774 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 775 |
* @returns |
| 776 |
*/ |
| 777 |
function wpbc_gt_get_visual_block_for_bookingtimeline( shortcode_obj, params ){ |
| 778 |
|
| 779 |
// Booking Form Parameters |
| 780 |
var shortcode_defaults = { |
| 781 |
type : 'Default', // 1, |
| 782 |
view_days_num : 30, // 30, |
| 783 |
|
| 784 |
scroll_start_date : null, // '', |
| 785 |
scroll_day : null, // 0, |
| 786 |
scroll_month : null, // 0, |
| 787 |
header_title : null, // '', |
| 788 |
limit_hours : null, // '0,24' |
| 789 |
}; |
| 790 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 791 |
|
| 792 |
var el = wp.element.createElement; |
| 793 |
|
| 794 |
|
| 795 |
var inner_header = el( 'div', { |
| 796 |
className: 'wpbc_gb_block_preview_inner_header' |
| 797 |
, key: 'header_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 798 |
} |
| 799 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Timeline' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 800 |
); |
| 801 |
var inner_body = el( 'div', { |
| 802 |
className: 'wpbc_gb_block_preview_inner_body' |
| 803 |
, key: 'body_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 804 |
} |
| 805 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingtimeline( props ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 806 |
); |
| 807 |
var inner_footer = el( 'div', { |
| 808 |
className: 'wpbc_gb_block_preview_inner_footer' |
| 809 |
, key: 'footer_' + params[ 'cid_key' ] // FixIn: 8.7.3.18. |
| 810 |
} |
| 811 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 812 |
); |
| 813 |
|
| 814 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingtimeline' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 815 |
|
| 816 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 817 |
, [ inner_header, inner_body ] |
| 818 |
) |
| 819 |
, inner_footer |
| 820 |
); |
| 821 |
} |
| 822 |
|
| 823 |
|
| 824 |
/** |
| 825 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 826 |
* |
| 827 |
* @param props |
| 828 |
*/ |
| 829 |
function wpbc_parse_params_into_rows_arr_for_bookingtimeline( props ){ |
| 830 |
|
| 831 |
// Parameters Description ///////////////////////////////// |
| 832 |
var rows_in_content = []; |
| 833 |
if ( undefined != props[ 'type' ] ){ |
| 834 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource(s)' ), value: 'ID = ' + props[ 'type' ]} ); |
| 835 |
} |
| 836 |
if ( undefined != props[ 'view_days_num' ] ){ |
| 837 |
|
| 838 |
if ( '1' == props[ 'view_days_num' ] ) { |
| 839 |
props[ 'view_days_num' ] = 'Day'; |
| 840 |
} |
| 841 |
if ( '7' == props[ 'view_days_num' ] ) { |
| 842 |
props[ 'view_days_num' ] = 'Week'; |
| 843 |
} |
| 844 |
if ( '30' == props[ 'view_days_num' ] ) { |
| 845 |
props[ 'view_days_num' ] = 'Month'; |
| 846 |
} |
| 847 |
if ( '60' == props[ 'view_days_num' ] ) { |
| 848 |
props[ 'view_days_num' ] = '2 Months'; |
| 849 |
} |
| 850 |
if ( '90' == props[ 'view_days_num' ] ) { |
| 851 |
props[ 'view_days_num' ] = '3 Months'; |
| 852 |
} |
| 853 |
if ( '365' == props[ 'view_days_num' ] ){ |
| 854 |
props[ 'view_days_num' ] = 'Year'; |
| 855 |
} |
| 856 |
rows_in_content.push( {name: wp.i18n.__( 'View mode' ), value: props[ 'view_days_num' ]} ); |
| 857 |
} |
| 858 |
if ( undefined != props[ 'header_title' ] ) { |
| 859 |
rows_in_content.push( { name: wp.i18n.__( 'Title' ), value: props[ 'header_title' ] } ); |
| 860 |
} |
| 861 |
if ( undefined != props[ 'scroll_day' ] ) { |
| 862 |
rows_in_content.push( { name: wp.i18n.__( 'Number of days to scroll' ), value: props[ 'scroll_day' ] } ); |
| 863 |
} |
| 864 |
if ( undefined != props[ 'scroll_month' ] ) { |
| 865 |
rows_in_content.push( { name: wp.i18n.__( 'Number of months to scroll' ), value: props[ 'scroll_month' ] } ); |
| 866 |
} |
| 867 |
if ( undefined != props[ 'scroll_start_date' ] ) { |
| 868 |
rows_in_content.push( { name: wp.i18n.__( 'Start Date' ), value: props[ 'scroll_start_date' ] } ); |
| 869 |
} |
| 870 |
if ( undefined != props[ 'limit_hours' ] ) { |
| 871 |
rows_in_content.push( { name: wp.i18n.__( 'Show from/to' ), value: props[ 'limit_hours' ] } ); |
| 872 |
} |
| 873 |
|
| 874 |
return rows_in_content; |
| 875 |
} |
| 876 |
|
| 877 |
|
| 878 |
/** |
| 879 |
* Generate Visual Preview Block of Booking form |
| 880 |
* |
| 881 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 882 |
* @returns |
| 883 |
*/ |
| 884 |
function wpbc_gt_get_visual_block_for_bookingselect( shortcode_obj, params ){ |
| 885 |
|
| 886 |
// Booking Form Parameters |
| 887 |
var shortcode_defaults = { |
| 888 |
type : wp.i18n.__( 'All booking resources' ), |
| 889 |
nummonths : 1, |
| 890 |
form_type : null, // : 'standard', |
| 891 |
selected_type : null, // : '', |
| 892 |
label : null, // : '', |
| 893 |
first_option_title: wp.i18n.__( 'Please Select' ), |
| 894 |
startmonth : null, |
| 895 |
options : null |
| 896 |
}; |
| 897 |
|
| 898 |
|
| 899 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 900 |
|
| 901 |
var el = wp.element.createElement; |
| 902 |
|
| 903 |
//FixIn: 8.7.3.18 Start |
| 904 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 905 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Selection of Resources' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 906 |
); |
| 907 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 908 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingselect( props ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 909 |
); |
| 910 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 911 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 912 |
); |
| 913 |
|
| 914 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingselect' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 915 |
|
| 916 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 917 |
, [ inner_header, inner_body ] |
| 918 |
) |
| 919 |
, inner_footer |
| 920 |
); |
| 921 |
//FixIn: 8.7.3.18 End |
| 922 |
|
| 923 |
} |
| 924 |
|
| 925 |
|
| 926 |
/** |
| 927 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 928 |
* |
| 929 |
* @param props |
| 930 |
*/ |
| 931 |
function wpbc_parse_params_into_rows_arr_for_bookingselect( props ){ |
| 932 |
|
| 933 |
// Parameters Description ///////////////////////////////// |
| 934 |
var rows_in_content = []; |
| 935 |
if ( undefined != props[ 'type' ] ){ |
| 936 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource(s)' ), value: props[ 'type' ]} ); |
| 937 |
} |
| 938 |
if ( undefined != props[ 'label' ] ) { |
| 939 |
rows_in_content.push( { name: wp.i18n.__( 'Label' ), value: props[ 'label' ] } ); |
| 940 |
} |
| 941 |
if ( undefined != props[ 'selected_type' ] ) { |
| 942 |
rows_in_content.push( { name: wp.i18n.__( 'Selected booking resource (by default)' ), value: 'ID = ' + props[ 'selected_type' ] } ); |
| 943 |
} |
| 944 |
if ( undefined != props[ 'first_option_title' ] ) { |
| 945 |
rows_in_content.push( { name: wp.i18n.__( 'Title of first option in list' ), value: props[ 'first_option_title' ] } ); |
| 946 |
} |
| 947 |
if ( undefined != props[ 'nummonths' ] ){ |
| 948 |
rows_in_content.push( {name: wp.i18n.__( 'Visible months number' ), value: props[ 'nummonths' ]} ); |
| 949 |
} |
| 950 |
if ( undefined != props[ 'startmonth' ] ) { |
| 951 |
rows_in_content.push( { name: wp.i18n.__( 'Start month' ), value: props[ 'startmonth' ] } ); |
| 952 |
} |
| 953 |
if ( ( undefined != props[ 'form_type' ] ) && ( 'standard' != props[ 'form_type' ] ) ){ |
| 954 |
rows_in_content.push( { name: wp.i18n.__( 'Custom booking form for all booking resources' ), value: props[ 'form_type' ] } ); |
| 955 |
} |
| 956 |
if ( undefined != props[ 'aggregate' ] ) { |
| 957 |
rows_in_content.push( { name: wp.i18n.__( 'Unavailable dates from other booking resources' ), value: 'ID = ' + props[ 'aggregate' ] } ); |
| 958 |
} |
| 959 |
if ( undefined != props[ 'options' ] ) { |
| 960 |
rows_in_content.push( { name: wp.i18n.__( 'Options' ), value: props[ 'options' ] } ); |
| 961 |
} |
| 962 |
|
| 963 |
return rows_in_content; |
| 964 |
} |
| 965 |
|
| 966 |
|
| 967 |
/** |
| 968 |
* Generate Visual Preview Block of Booking form |
| 969 |
* |
| 970 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 971 |
* @returns |
| 972 |
*/ |
| 973 |
function wpbc_gt_get_visual_block_for_bookingform( shortcode_obj, params ){ |
| 974 |
|
| 975 |
// Booking Form Parameters // FixIn: 10.0.0.16. |
| 976 |
var shortcode_defaults = { |
| 977 |
type : 1, |
| 978 |
resource_id : 1, |
| 979 |
selected_dates : null, |
| 980 |
form_type : 'standard' |
| 981 |
}; |
| 982 |
|
| 983 |
|
| 984 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 985 |
|
| 986 |
var el = wp.element.createElement; |
| 987 |
|
| 988 |
//FixIn: 8.7.3.18 Start |
| 989 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 990 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Booking Form (without calendar)' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 991 |
); |
| 992 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 993 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingform( props ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 994 |
); |
| 995 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 996 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 997 |
); |
| 998 |
|
| 999 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingform' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1000 |
|
| 1001 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1002 |
, [ inner_header, inner_body ] |
| 1003 |
) |
| 1004 |
, inner_footer |
| 1005 |
); |
| 1006 |
//FixIn: 8.7.3.18 End |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
/** |
| 1011 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 1012 |
* |
| 1013 |
* @param props |
| 1014 |
*/ |
| 1015 |
function wpbc_parse_params_into_rows_arr_for_bookingform( props ){ |
| 1016 |
|
| 1017 |
// Parameters Description ///////////////////////////////// |
| 1018 |
var rows_in_content = []; |
| 1019 |
if ( (undefined != props[ 'type' ]) && ( 1 != props[ 'type' ]) ){ |
| 1020 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource' ), value: 'ID = ' + props[ 'type' ]} ); |
| 1021 |
} |
| 1022 |
// FixIn: 10.0.0.16. |
| 1023 |
if ( (undefined != props[ 'resource_id' ]) && ( 1 != props[ 'resource_id' ]) ){ |
| 1024 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource' ), value: 'ID = ' + props[ 'resource_id' ]} ); |
| 1025 |
} |
| 1026 |
|
| 1027 |
if ( undefined != props[ 'selected_dates' ] ){ |
| 1028 |
rows_in_content.push( {name: wp.i18n.__( 'Date for submit booking' ), value: props[ 'selected_dates' ]} ); |
| 1029 |
} |
| 1030 |
if ( ( undefined != props[ 'form_type' ] ) && ( 'standard' != props[ 'form_type' ] ) ){ |
| 1031 |
rows_in_content.push( { name: wp.i18n.__( 'Custom booking form' ), value: props[ 'form_type' ] } ); |
| 1032 |
} |
| 1033 |
|
| 1034 |
return rows_in_content; |
| 1035 |
} |
| 1036 |
|
| 1037 |
|
| 1038 |
/** |
| 1039 |
* Generate Visual Preview Block of Search Availability Form |
| 1040 |
* |
| 1041 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 1042 |
* @returns |
| 1043 |
*/ |
| 1044 |
function wpbc_gt_get_visual_block_for_bookingsearch( shortcode_obj, params ){ |
| 1045 |
|
| 1046 |
// Booking Form Parameters |
| 1047 |
var shortcode_defaults = { |
| 1048 |
searchresultstitle : '', // searchresultstitle='{searchresults} Result(s) Found' |
| 1049 |
noresultstitle : '', // noresultstitle='Nothing Found' |
| 1050 |
users : null, // users='3,55' |
| 1051 |
searchresults : null // searchresults='http://test.com/search-results' |
| 1052 |
}; |
| 1053 |
|
| 1054 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 1055 |
|
| 1056 |
var el = wp.element.createElement; |
| 1057 |
|
| 1058 |
//FixIn: 8.7.3.18 Start |
| 1059 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 1060 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Search Availability form' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 1061 |
); |
| 1062 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 1063 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingsearch( props ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 1064 |
); |
| 1065 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 1066 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 1067 |
); |
| 1068 |
|
| 1069 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingsearch' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1070 |
|
| 1071 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1072 |
, [ inner_header, inner_body ] |
| 1073 |
) |
| 1074 |
, inner_footer |
| 1075 |
); |
| 1076 |
//FixIn: 8.7.3.18 End |
| 1077 |
|
| 1078 |
} |
| 1079 |
|
| 1080 |
|
| 1081 |
/** |
| 1082 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 1083 |
* |
| 1084 |
* @param props |
| 1085 |
*/ |
| 1086 |
function wpbc_parse_params_into_rows_arr_for_bookingsearch( props ){ |
| 1087 |
|
| 1088 |
// Parameters Description ///////////////////////////////// |
| 1089 |
var rows_in_content = []; |
| 1090 |
if ( undefined != props[ 'searchresults' ] ){ |
| 1091 |
rows_in_content.push( { name: wp.i18n.__( 'Show search results on other page' ) |
| 1092 |
, value: wp.element.createElement( 'a', { href: props[ 'searchresults' ] }, props[ 'searchresults' ] ) |
| 1093 |
} ); |
| 1094 |
rows_in_content.push( {name: wp.i18n.__( 'Note' ), value: wp.i18n.__( 'Search results page must have this shortcode' ) + ' [bookingsearchresults]' } ); |
| 1095 |
rows_in_content.push( { block_text: '---' } ); |
| 1096 |
} else { |
| 1097 |
rows_in_content.push( { block_text: wp.i18n.__( 'Show search results in the same page' ) } ); |
| 1098 |
} |
| 1099 |
if ( undefined != props[ 'searchresultstitle' ] ){ |
| 1100 |
//rows_in_content.push( {name: wp.i18n.__( 'Search Results Title' ), value: props[ 'searchresultstitle' ]} ); |
| 1101 |
} |
| 1102 |
if ( undefined != props[ 'noresultstitle' ] ){ |
| 1103 |
//rows_in_content.push( {name: wp.i18n.__( 'Title, if no search results' ), value: props[ 'noresultstitle' ]} ); |
| 1104 |
} |
| 1105 |
if ( undefined != props[ 'users' ] ){ |
| 1106 |
rows_in_content.push( {name: wp.i18n.__( 'Search in booking resources of WP users' ), value: 'ID = ' + props[ 'users' ]} ); |
| 1107 |
} |
| 1108 |
|
| 1109 |
return rows_in_content; |
| 1110 |
} |
| 1111 |
|
| 1112 |
|
| 1113 |
/** |
| 1114 |
* Generate Visual Preview Block of Search Results |
| 1115 |
* |
| 1116 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 1117 |
* @returns |
| 1118 |
*/ |
| 1119 |
function wpbc_gt_get_visual_block_for_bookingsearchresults( shortcode_obj, params ){ |
| 1120 |
|
| 1121 |
// Booking Form Parameters |
| 1122 |
var shortcode_defaults = { |
| 1123 |
}; |
| 1124 |
|
| 1125 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 1126 |
|
| 1127 |
var el = wp.element.createElement; |
| 1128 |
|
| 1129 |
//FixIn: 8.7.3.18 Start |
| 1130 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 1131 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Search Results' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 1132 |
); |
| 1133 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 1134 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingsearchresults( props ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 1135 |
); |
| 1136 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 1137 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 1138 |
); |
| 1139 |
|
| 1140 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingsearch' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1141 |
|
| 1142 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1143 |
, [ inner_header, inner_body ] |
| 1144 |
) |
| 1145 |
, inner_footer |
| 1146 |
); |
| 1147 |
//FixIn: 8.7.3.18 End |
| 1148 |
} |
| 1149 |
|
| 1150 |
|
| 1151 |
/** |
| 1152 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 1153 |
* |
| 1154 |
* @param props |
| 1155 |
*/ |
| 1156 |
function wpbc_parse_params_into_rows_arr_for_bookingsearchresults( props ){ |
| 1157 |
|
| 1158 |
// Parameters Description ///////////////////////////////// |
| 1159 |
var rows_in_content = []; |
| 1160 |
rows_in_content.push( { block_text: wp.i18n.__( 'Show search results on this page, after redirection from search form at other page.' ) } ); |
| 1161 |
|
| 1162 |
return rows_in_content; |
| 1163 |
} |
| 1164 |
|
| 1165 |
|
| 1166 |
/** |
| 1167 |
* Generate Visual Preview Block of Booking Confirm - system shortcode |
| 1168 |
* |
| 1169 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 1170 |
* @returns |
| 1171 |
*/ |
| 1172 |
function wpbc_gt_get_visual_block_for_booking_confirm( shortcode_obj, params ){ |
| 1173 |
|
| 1174 |
// Booking Form Parameters |
| 1175 |
var shortcode_defaults = { |
| 1176 |
}; |
| 1177 |
|
| 1178 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 1179 |
|
| 1180 |
var el = wp.element.createElement; |
| 1181 |
|
| 1182 |
//FixIn: 8.7.3.18 Start |
| 1183 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 1184 |
, wpbc_gb_tpl_header( { header: 'WP Booking Calendar - ' + wp.i18n.__( 'System Block' ) , cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 1185 |
); |
| 1186 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 1187 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_booking_confirm( props ,'body_' + params[ 'cid_key' ] ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 1188 |
); |
| 1189 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 1190 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 1191 |
); |
| 1192 |
|
| 1193 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_booking_confirm' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1194 |
|
| 1195 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1196 |
, [ inner_header, inner_body ] |
| 1197 |
) |
| 1198 |
, inner_footer |
| 1199 |
); |
| 1200 |
//FixIn: 8.7.3.18 End |
| 1201 |
} |
| 1202 |
|
| 1203 |
|
| 1204 |
/** |
| 1205 |
* Generate Visual Preview Block of "Booking Manager" == Import == |
| 1206 |
* |
| 1207 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 1208 |
* @returns |
| 1209 |
*/ |
| 1210 |
function wpbc_gt_get_visual_block_for_booking_manager_import( shortcode_obj, params ){ |
| 1211 |
|
| 1212 |
// Booking Form Parameters |
| 1213 |
var shortcode_defaults = {}; |
| 1214 |
|
| 1215 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 1216 |
|
| 1217 |
var el = wp.element.createElement; |
| 1218 |
|
| 1219 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 1220 |
, wpbc_gb_tpl_header( { header: 'Booking Manager - ' + wp.i18n.__( 'Import Events from .ics feed into WP Booking Calendar - Block' ) , cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 1221 |
); |
| 1222 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 1223 |
, wpbc_gb_tpl_shortcode_parameters( |
| 1224 |
[ |
| 1225 |
{ block_text: wp.i18n.__( 'This shortcode [ booking-manager-import ] is used for import bookings from .ics feed URL into the WP Booking Calendar plugin' ) } |
| 1226 |
] |
| 1227 |
, { cid_key: 'body_' + params[ 'cid_key' ] } |
| 1228 |
) |
| 1229 |
); |
| 1230 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 1231 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 1232 |
); |
| 1233 |
|
| 1234 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_booking_import' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1235 |
|
| 1236 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1237 |
, [ inner_header, inner_body ] |
| 1238 |
) |
| 1239 |
, inner_footer |
| 1240 |
); |
| 1241 |
} |
| 1242 |
|
| 1243 |
|
| 1244 |
/** |
| 1245 |
* Generate Visual Preview Block of "Booking Manager" == Import == |
| 1246 |
* |
| 1247 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 1248 |
* @returns |
| 1249 |
*/ |
| 1250 |
function wpbc_gt_get_visual_block_for_booking_manager_listing( shortcode_obj, params ){ |
| 1251 |
|
| 1252 |
// Booking Form Parameters |
| 1253 |
var shortcode_defaults = {}; |
| 1254 |
|
| 1255 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 1256 |
|
| 1257 |
var el = wp.element.createElement; |
| 1258 |
|
| 1259 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 1260 |
, wpbc_gb_tpl_header( { header: 'Booking Manager - ' + wp.i18n.__( 'Show Events Listing from .ics feed - Block' ) , cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 1261 |
); |
| 1262 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 1263 |
, wpbc_gb_tpl_shortcode_parameters( |
| 1264 |
[ |
| 1265 |
{ block_text: wp.i18n.__( 'This shortcode [ booking-manager-listing ] used for show events listing from .ics feed URL.' ) } |
| 1266 |
] |
| 1267 |
, { cid_key: 'body_' + params[ 'cid_key' ] } |
| 1268 |
) |
| 1269 |
); |
| 1270 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 1271 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 1272 |
); |
| 1273 |
|
| 1274 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_booking_import' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1275 |
|
| 1276 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1277 |
, [ inner_header, inner_body ] |
| 1278 |
) |
| 1279 |
, inner_footer |
| 1280 |
); |
| 1281 |
} |
| 1282 |
|
| 1283 |
|
| 1284 |
/** |
| 1285 |
* Generate Visual Preview Block of Booking Edit - system shortcode |
| 1286 |
* |
| 1287 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 1288 |
* @returns |
| 1289 |
*/ |
| 1290 |
function wpbc_gt_get_visual_block_for_bookingedit( shortcode_obj, params ){ |
| 1291 |
|
| 1292 |
// Booking Form Parameters |
| 1293 |
var shortcode_defaults = { |
| 1294 |
}; |
| 1295 |
|
| 1296 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 1297 |
|
| 1298 |
var el = wp.element.createElement; |
| 1299 |
|
| 1300 |
//FixIn: 8.7.3.18 Start |
| 1301 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 1302 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'System Block' ) + ' (' + wp.i18n.__( 'Booking Calendar Editing' ) + ')', cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 1303 |
); |
| 1304 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 1305 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingedit( props ,'body_' + params[ 'cid_key' ] ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 1306 |
); |
| 1307 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 1308 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 1309 |
); |
| 1310 |
|
| 1311 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingedit' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1312 |
|
| 1313 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1314 |
, [ inner_header, inner_body ] |
| 1315 |
) |
| 1316 |
, inner_footer |
| 1317 |
); |
| 1318 |
//FixIn: 8.7.3.18 End |
| 1319 |
} |
| 1320 |
|
| 1321 |
|
| 1322 |
/** |
| 1323 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 1324 |
* |
| 1325 |
* @param props |
| 1326 |
*/ |
| 1327 |
function wpbc_parse_params_into_rows_arr_for_booking_confirm( props , cid_key){ |
| 1328 |
|
| 1329 |
// Parameters Description ///////////////////////////////// |
| 1330 |
var rows_in_content = []; |
| 1331 |
rows_in_content.push( { block_text: wp.i18n.__( 'This shortcode [booking_confirm] is used on a confirmation booking page to display booking details and confirmation after a successful booking.' ) } ); |
| 1332 |
|
| 1333 |
return rows_in_content; |
| 1334 |
} |
| 1335 |
|
| 1336 |
|
| 1337 |
/** |
| 1338 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 1339 |
* |
| 1340 |
* @param props |
| 1341 |
*/ |
| 1342 |
function wpbc_parse_params_into_rows_arr_for_bookingedit( props, cid_key ){ |
| 1343 |
|
| 1344 |
var el = wp.element.createElement; |
| 1345 |
|
| 1346 |
// Parameters Description ///////////////////////////////// |
| 1347 |
var rows_in_content = []; |
| 1348 |
rows_in_content.push( { block_text: wp.i18n.__( 'This block required for ability to edit, cancel the booking by visitor, who made the booking, or for ability to show payment form, after sending payment request.' ) } ); |
| 1349 |
|
| 1350 |
rows_in_content.push( { block_text: |
| 1351 |
|
| 1352 |
el( 'div', { key: 'wpbc_be1_' + cid_key } |
| 1353 |
, el( 'span', { key: 'wpbc_be2_' + cid_key }, wp.i18n.__( 'Link to this page must be defined' ) ) |
| 1354 |
, ' ' |
| 1355 |
, el( 'a', { href: 'admin.php?page=wpbc-settings#wpbc_general_settings_advanced_metabox', key: 'wpbc_be3_' + cid_key }, 'on this page' ) |
| 1356 |
, ', ' |
| 1357 |
, el( 'span', { key: 'wpbc_be4_' + cid_key }, wp.i18n.__( 'at this option' ) ) |
| 1358 |
, ': "' |
| 1359 |
, el( 'strong', { key: 'wpbc_be5_' + cid_key }, wp.i18n.__( 'URL to edit bookings' ) ) |
| 1360 |
, '".' |
| 1361 |
) |
| 1362 |
} ); |
| 1363 |
rows_in_content.push( { block_text: |
| 1364 |
el( 'div', { style: { marginTop: '20px' }, key: 'wpbc_be6_' + cid_key } |
| 1365 |
, el( 'strong', { key: 'wpbc_be7_' + cid_key }, wp.i18n.__( 'Important!' ) ) |
| 1366 |
, ' ' |
| 1367 |
, el( 'span', { key: 'wpbc_be8_' + cid_key }, wp.i18n.__( 'You can not open this page directly. Please, use links in ' ) ) |
| 1368 |
, ' ' |
| 1369 |
, el( 'a', { href: 'admin.php?page=wpbc-settings&tab=email' , key: 'wpbc_be9_' + cid_key }, 'email' ) |
| 1370 |
, '.' |
| 1371 |
) |
| 1372 |
} ); |
| 1373 |
rows_in_content.push( { block_text: |
| 1374 |
el( 'div', { key: 'wpbc_be10_' + cid_key } |
| 1375 |
, el( 'span', { key: 'wpbc_be11_' + cid_key }, wp.i18n.__( 'If you open this page directly, then you will see this error' ) ) |
| 1376 |
, ': "' |
| 1377 |
, el( 'strong', { key: 'wpbc_be12_' + cid_key }, wp.i18n.__( 'You do not set any parameters for booking editing' ) ) |
| 1378 |
, '".' |
| 1379 |
) |
| 1380 |
} ); |
| 1381 |
return rows_in_content; |
| 1382 |
} |
| 1383 |
|
| 1384 |
|
| 1385 |
/** |
| 1386 |
* Generate Visual Preview Block of Customer Bookings Listing - system shortcode |
| 1387 |
* |
| 1388 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 1389 |
* @returns |
| 1390 |
*/ |
| 1391 |
function wpbc_gt_get_visual_block_for_bookingcustomerlisting( shortcode_obj, params ){ |
| 1392 |
|
| 1393 |
// Booking Form Parameters |
| 1394 |
var shortcode_defaults = { |
| 1395 |
}; |
| 1396 |
|
| 1397 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 1398 |
|
| 1399 |
var el = wp.element.createElement; |
| 1400 |
|
| 1401 |
//FixIn: 8.7.3.18 Start |
| 1402 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 1403 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Customer Bookings Listing' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 1404 |
); |
| 1405 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 1406 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingcustomerlisting( props, 'body_' + params[ 'cid_key' ] ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 1407 |
); |
| 1408 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 1409 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 1410 |
); |
| 1411 |
|
| 1412 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingcustomerlisting' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1413 |
|
| 1414 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1415 |
, [ inner_header, inner_body ] |
| 1416 |
) |
| 1417 |
, inner_footer |
| 1418 |
); |
| 1419 |
//FixIn: 8.7.3.18 End |
| 1420 |
} |
| 1421 |
|
| 1422 |
|
| 1423 |
/** |
| 1424 |
* Parse parameters into array of rows objects for showing in conetnt of block |
| 1425 |
* |
| 1426 |
* @param props |
| 1427 |
*/ |
| 1428 |
function wpbc_parse_params_into_rows_arr_for_bookingcustomerlisting( props, cid_key ){ |
| 1429 |
|
| 1430 |
var el = wp.element.createElement; |
| 1431 |
|
| 1432 |
// Parameters Description ///////////////////////////////// |
| 1433 |
var rows_in_content = []; |
| 1434 |
rows_in_content.push( { block_text: wp.i18n.__( 'Visitors of your website, can view previous (own) bookings, by clicking on secret link in email, which is sending after booking created.' ) } ); |
| 1435 |
|
| 1436 |
rows_in_content.push( { block_text: |
| 1437 |
|
| 1438 |
el( 'div', { key: 'wpbc_bcl1_' + cid_key } |
| 1439 |
, el( 'span', { key: 'wpbc_bcl2_' + cid_key }, wp.i18n.__( 'Link to this page must be defined' ) ) |
| 1440 |
, ' ' |
| 1441 |
, el( 'a', { href: 'admin.php?page=wpbc-settings#wpbc_general_settings_advanced_metabox' , key: 'wpbc_bcl2_2_' + cid_key }, 'on this page' ) |
| 1442 |
, ', ' |
| 1443 |
, el( 'span', { key: 'wpbc_bcl3_' + cid_key }, wp.i18n.__( 'at this option' ) ) |
| 1444 |
, ': "' |
| 1445 |
, el( 'strong', { key: 'wpbc_bcl4_' + cid_key }, wp.i18n.__( 'URL of page for customer bookings listing' ) ) |
| 1446 |
, '".' |
| 1447 |
) |
| 1448 |
} ); |
| 1449 |
rows_in_content.push( { block_text: |
| 1450 |
el( 'div', { style: { marginTop: '20px' }, key: 'wpbc_bcl5_' + cid_key } |
| 1451 |
, el( 'strong', { key: 'wpbc_bcl6_' + cid_key }, wp.i18n.__( 'Important!' ) ) |
| 1452 |
, ' ' |
| 1453 |
, el( 'span', { key: 'wpbc_bcl7_' + cid_key }, wp.i18n.__( 'You can not open this page directly. Please, use links in ' ) ) |
| 1454 |
, ' ' |
| 1455 |
, el( 'a', { href: 'admin.php?page=wpbc-settings&tab=email' , key: 'wpbc_bcl8_' + cid_key }, 'email' ) |
| 1456 |
, '.' |
| 1457 |
) |
| 1458 |
} ); |
| 1459 |
rows_in_content.push( { block_text: |
| 1460 |
el( 'div', { key: 'wpbc_bcl9_' + cid_key } |
| 1461 |
, el( 'span', { key: 'wpbc_bcl10_' + cid_key }, wp.i18n.__( 'If you open this page directly, then you will see this error' ) ) |
| 1462 |
, ': "' |
| 1463 |
, el( 'strong', { key: 'wpbc_bcl11_' + cid_key }, wp.i18n.__( 'You do not set any parameters for booking editing' ) ) |
| 1464 |
, '".' |
| 1465 |
) |
| 1466 |
} ); |
| 1467 |
return rows_in_content; |
| 1468 |
} |
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
/** |
| 1474 |
* Generate Visual Preview Block of Showing booking resource Info |
| 1475 |
* |
| 1476 |
* @param shortcode_obj - shortcode JavaScript obj. |
| 1477 |
* @returns |
| 1478 |
*/ |
| 1479 |
function wpbc_gt_get_visual_block_for_bookingresource( shortcode_obj, params ){ |
| 1480 |
|
| 1481 |
// Booking Form Parameters // FixIn: 10.0.0.16. |
| 1482 |
var shortcode_defaults = { |
| 1483 |
type : 1, |
| 1484 |
resource_id : 1, |
| 1485 |
show : 'title' |
| 1486 |
}; |
| 1487 |
|
| 1488 |
|
| 1489 |
var props = _.defaults( shortcode_obj.attrs.named, shortcode_defaults ); |
| 1490 |
|
| 1491 |
var el = wp.element.createElement; |
| 1492 |
|
| 1493 |
//FixIn: 8.7.3.18 Start |
| 1494 |
var inner_header = el( 'div', {className: 'wpbc_gb_block_preview_inner_header', key: 'header_' + params[ 'cid_key' ]} |
| 1495 |
, wpbc_gb_tpl_header( { header: wp.i18n.__( 'Show Info of Booking Resource' ), cid_key: 'header_' + params[ 'cid_key' ] } ) |
| 1496 |
); |
| 1497 |
var inner_body = el( 'div', {className: 'wpbc_gb_block_preview_inner_body', key: 'body_' + params[ 'cid_key' ] } |
| 1498 |
, wpbc_gb_tpl_shortcode_parameters( wpbc_parse_params_into_rows_arr_for_bookingresource( props ), { cid_key: 'body_' + params[ 'cid_key' ] } ) |
| 1499 |
); |
| 1500 |
var inner_footer = el( 'div', {className: 'wpbc_gb_block_preview_inner_footer' , key: 'footer_' + params[ 'cid_key' ] } |
| 1501 |
, wpbc_gb_tpl_footer( { shortcode_in_text: params[ 'shortcode_in_text' ], cid_key: 'footer_' + params[ 'cid_key' ] } ) |
| 1502 |
); |
| 1503 |
|
| 1504 |
return el( 'div', { className: 'wpbc_gb_block_shortcode_preview_wrapper wpbc_gb_block_preview_bookingresource' , key: 'preview_wrapper_' + params[ 'cid_key' ] } |
| 1505 |
|
| 1506 |
, el( 'div', { className: 'wpbc_gb_block_shortcode_preview_content' , key: 'preview_content_' + params[ 'cid_key' ] } |
| 1507 |
, [ inner_header, inner_body ] |
| 1508 |
) |
| 1509 |
, inner_footer |
| 1510 |
); |
| 1511 |
//FixIn: 8.7.3.18 End |
| 1512 |
} |
| 1513 |
|
| 1514 |
|
| 1515 |
/** |
| 1516 |
* Parse parameters into array of rows objects for showing in content of block |
| 1517 |
* |
| 1518 |
* @param props |
| 1519 |
*/ |
| 1520 |
function wpbc_parse_params_into_rows_arr_for_bookingresource( props ){ |
| 1521 |
|
| 1522 |
// Parameters Description ///////////////////////////////// |
| 1523 |
var rows_in_content = []; |
| 1524 |
if ( (undefined != props[ 'type' ]) && ( 1 != props[ 'type' ]) ){ |
| 1525 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource' ), value: 'ID = ' + props[ 'type' ]} ); |
| 1526 |
} |
| 1527 |
// FixIn: 10.0.0.16. |
| 1528 |
if ( (undefined != props[ 'resource_id' ]) && ( 1 != props[ 'resource_id' ]) ){ |
| 1529 |
rows_in_content.push( {name: wp.i18n.__( 'Booking resource' ), value: 'ID = ' + props[ 'resource_id' ]} ); |
| 1530 |
} |
| 1531 |
|
| 1532 |
if ( undefined != props[ 'show' ] ) { |
| 1533 |
rows_in_content.push( { name: wp.i18n.__( 'Show' ), value: props[ 'show' ] } ); |
| 1534 |
/* |
| 1535 |
if ( 'title' == props[ 'show' ] ) { |
| 1536 |
rows_in_content.push( { name: wp.i18n.__( 'Show' ), value: props[ 'show' ] } ); |
| 1537 |
} |
| 1538 |
if ( 'cost' == props[ 'show' ] ) { |
| 1539 |
rows_in_content.push( { name: wp.i18n.__( 'Show' ), value: props[ 'show' ] } ); |
| 1540 |
} |
| 1541 |
if ( 'capacity' == props[ 'show' ] ) { |
| 1542 |
rows_in_content.push( { name: wp.i18n.__( 'Show' ), value: props[ 'show' ] } ); |
| 1543 |
} |
| 1544 |
*/ |
| 1545 |
} |
| 1546 |
return rows_in_content; |
| 1547 |
} |
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
// Templates /////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1552 |
|
| 1553 |
/** |
| 1554 |
* Header template for Block Preview |
| 1555 |
* |
| 1556 |
* @param props - object of parameters |
| 1557 |
* @returns array of createElements - react elements |
| 1558 |
*/ |
| 1559 |
function wpbc_gb_tpl_header( props ){ |
| 1560 |
|
| 1561 |
var el = wp.element.createElement; |
| 1562 |
// FixIn: 8.7.3.18. |
| 1563 |
return [ |
| 1564 |
el( 'h3', {className: 'wpbc_gb_block_preview_inner_title_text', key: 'h3header_' + props[ 'cid_key' ] }, props.header ), |
| 1565 |
|
| 1566 |
el( 'a', {className: 'wpbc_gb_block_preview_inner_title_edit', key: 'a_clickedit_' + props[ 'cid_key' ] }, wp.i18n.__( 'Click to edit' ) ), |
| 1567 |
|
| 1568 |
el( 'div', {className: 'wpbc_gb_block_preview_inner_title_desc', key: 'div_notreal_' + props[ 'cid_key' ] }, wp.i18n.__( 'This is not real preview. Its configuration block of "Booking Calendar".' ) ) |
| 1569 |
]; |
| 1570 |
} |
| 1571 |
|
| 1572 |
|
| 1573 |
/** |
| 1574 |
* Parameters template for shortcode params in Body of Block Preview |
| 1575 |
* |
| 1576 |
* @param props - array of objects of parameters [ {name: 'title', value: 'data'}, ... ] |
| 1577 |
* @returns array of createElements - react elements |
| 1578 |
*/ |
| 1579 |
function wpbc_gb_tpl_shortcode_parameters( props , params ){ // FixIn: 8.7.3.18. |
| 1580 |
|
| 1581 |
var el = wp.element.createElement; |
| 1582 |
|
| 1583 |
var shortcode_parameters_arr = []; |
| 1584 |
|
| 1585 |
var propsLength = props.length; |
| 1586 |
|
| 1587 |
var cid_key = params[ 'cid_key' ]; // FixIn: 8.7.3.18. |
| 1588 |
for ( var i = 0; i < propsLength; i++ ){ |
| 1589 |
|
| 1590 |
cid_key = 'internal' + i + params[ 'cid_key' ]; |
| 1591 |
|
| 1592 |
if ( undefined != props[i]['block_text'] ) { |
| 1593 |
|
| 1594 |
shortcode_parameters_arr.push( |
| 1595 |
el( 'div', {className: 'wpbc_gb_block_preview_inner_params_row', key: 'div_text' + cid_key } |
| 1596 |
, el( 'span', { key: 'inner_params_row_span' + cid_key }, props[ i ]['block_text'] ) |
| 1597 |
) |
| 1598 |
); |
| 1599 |
|
| 1600 |
} |
| 1601 |
|
| 1602 |
if ( ( undefined != props[i]['name'] ) && ( undefined != props[i]['value'] ) ) { |
| 1603 |
|
| 1604 |
shortcode_parameters_arr.push( |
| 1605 |
el( 'div', {className: 'wpbc_gb_block_preview_inner_params_row', key: 'div_name' + cid_key } |
| 1606 |
, el( 'strong', { key: 'strong_name' + cid_key }, props[ i ].name ) |
| 1607 |
, el( 'span', { key: 'span_name' + cid_key }, ': ' ) |
| 1608 |
, el( 'em', { key: 'em_value' + cid_key }, props[ i ].value ) |
| 1609 |
) |
| 1610 |
); |
| 1611 |
} |
| 1612 |
} |
| 1613 |
|
| 1614 |
return shortcode_parameters_arr; |
| 1615 |
} |
| 1616 |
|
| 1617 |
|
| 1618 |
/** |
| 1619 |
* Header template for Block Preview |
| 1620 |
* |
| 1621 |
* @param props - object of parameters |
| 1622 |
* @returns array of createElements - react elements |
| 1623 |
*/ |
| 1624 |
function wpbc_gb_tpl_footer( props ){ |
| 1625 |
|
| 1626 |
var el = wp.element.createElement; |
| 1627 |
// FixIn: 8.7.3.18. |
| 1628 |
return [ |
| 1629 |
el( 'div', { className: 'wpbc_gb_block_preview_inner_shortcode', key: 'div_foot_' + props[ 'cid_key' ] }, props.shortcode_in_text ) |
| 1630 |
]; |
| 1631 |
} |