1 2/** 3 * Get elemnt ID of Conditional section, relative to specific day or false 4 * 5 * @param string td_class - day in format: td_class = 11-23-2015 6 * @param string bk_type - ID of booking resources 7 * @returns bool | string 8 */ 9function wpbc_get_conditional_section_id_for_weekday( td_class, bk_type ){ //FixIn: 5.4.5.2 10 11 var date_sections = td_class.split("-"); 12 var check_date = new Date; 13 check_date.setFullYear( parseInt(date_sections[2]-0) ,parseInt(date_sections[0]-1), parseInt(date_sections[1]-0) ); 14 15 16 var garbage_divs = jQuery( '#booking_form_garbage' + bk_type + ' div' ); // Check for the W E E K D A Y S conditions 17 var index; 18 var garbage_element = false; 19 20 for (index = 0; index < garbage_divs.length; ++index) { 21 22 if ( '' !== garbage_divs[ index ].id ){ 23 garbage_element = jQuery( '#' + garbage_divs[ index ].id ); // Get Garbage DIV as jQuery element 24 25 if ( garbage_element.hasClass( 'wpdevbk_weekday_' + check_date.getDay() ) ){ // Found our filter element of this date in garbage 26 27 return '#' + garbage_divs[ index ].id; // ID of garbage_element 28 } 29 } 30 } 31 32 // Check in booking form - its required for situation, when we selected date, and some conditional section already in booking form. 33 var booking_form_element = jQuery( '#booking_form_div' + bk_type + ' .wpdevbk_optional_condition'); // .conditional_section_element_weekday-condition.wpdevbk_optional_condition 34 35 if ( booking_form_element.hasClass( 'wpdevbk_weekday_' + check_date.getDay() ) ) { // Found our filter element of this date in garbage 36 37 return '#booking_form_div' + bk_type + ' .wpdevbk_optional_condition' ; 38 } 39 40 return false; 41} 42 43 44 45// // Show / hide Fields in the booking form, 46// depend on from week day or season filter 47function check_condition_sections_in_bkform(date, bk_type){ 48 49 // Reseting 50 moveOptionalElementsToGarbage( bk_type ); 51 moveDefaultElementsToForm( bk_type ); 52 53 if (date == '') return; // If no days selections so then skip all. 54 55 date = get_first_day_of_selection(date); // Get the 10.06.2013 from different dates selection Varibale : 11.06.2013, 12.06.2013, 13.06.2013, 10.06.2013 || 10.06.2013 || 10.06.2013 - 18.06.2013 56 57 var date_sections = date.split("."); 58 var selceted_first_day = new Date; 59 selceted_first_day.setFullYear( parseInt(date_sections[2]-0) ,parseInt(date_sections[1]-1), parseInt(date_sections[0]-0) ); 60 61 62 var class_day = (selceted_first_day.getMonth()+1) + '-' + selceted_first_day.getDate() + '-' + selceted_first_day.getFullYear(); 63 if (jQuery('#calendar_booking'+bk_type+' .datepick-days-cell.cal4date-'+class_day).length <= 0) return; // We are chnaged the month (hided previos with first selected date), so this date cell is not exist now, we are need to exist 64 var calendarDateClassList =jQuery('#calendar_booking'+bk_type+' .datepick-days-cell.cal4date-'+class_day).attr('class').split(/\s+/); 65 66 var formElementClassName = ''; 67 var garbageElement = false; 68 69 jQuery.each( calendarDateClassList, function(index, singleClassCSS){ 70 71 // S E A S O N F I L T E R C O N D I T I O N S - checking 72 if ( singleClassCSS.indexOf("wpdevbk_season_") >= 0 ) { 73 74 // 1.Get this element from the garbage - <div class="conditional_section_element_times wpdevbk_optional_condition wpdevbk_season_high_season"> [...] </div> 75 76 jQuery.each( jQuery('#booking_form_garbage'+bk_type + ' div') , function(index, conditionGarbageDIV){ // LOOP in the Garbage 77 78 if ( '' !== conditionGarbageDIV.id ){ //FixIn: 9.7.3.6 79 80 garbageElement = jQuery( '#' + conditionGarbageDIV.id ); // Get Garbage DIV as jQuery element 81 82 if ( garbageElement.hasClass( singleClassCSS ) ){ // We found our season filter element in garbage with CSS class of that SEASON 83 84 // Get the ALL CSS classes of the DIV garbage element. Example: conditional_section_element_times wpdevbk_optional_condition wpdevbk_season_high_
84season 85 var garbageElementClassList = garbageElement.attr( 'class' ).split( /\s+/ ); 86 87 jQuery.each( garbageElementClassList, function ( index, garbageElementClassName ){ 88 89 //Get the name of CSS, like this: conditional_section_element_times 90 if ( garbageElementClassName.indexOf( "conditional_section_element_" ) >= 0 ){ 91 92 // 2.Get the class name in this element of the DIV section in the form 93 formElementClassName = garbageElementClassName.replace( '_element', '' ); 94 95 // 3.Remove all elements from the form in that DIV into the Garbage 96 jQuery( '#booking_form_div' + bk_type + ' div.' + formElementClassName + ' div' ).appendTo( '#booking_form_garbage' + bk_type ); 97 98 // 4.Insert this element into the form 99 garbageElement.appendTo( '#booking_form_div' + bk_type + ' div.' + formElementClassName ); 100 } 101 } ); 102 } 103 } 104 105 }); 106 } 107 108 }); 109 110 111 112 // Check for the W E E K D A Y S conditions ////////////////////////////////////////////////////////////////////////////////////// 113 jQuery.each( jQuery('#booking_form_garbage'+bk_type + ' div') , function(index, conditionGarbageDIV){ // LOOP in the Garbage 114 115 if ( '' !== conditionGarbageDIV.id ){ 116 garbageElement = jQuery('#'+conditionGarbageDIV.id); // Get Garbage DIV as jQuery element 117 118 if ( garbageElement.hasClass( 'wpdevbk_weekday_' + selceted_first_day.getDay() ) ) { // We found our filter element od this date in garbage with CSS class of that SEASON 119 120 121 // Get the ALL CSS classes of the DIV garbage element. Example: conditional_section_element_times wpdevbk_optional_condition wpdevbk_season_high_season 122 var garbageElementClassList = garbageElement.attr('class').split(/\s+/); 123 124 jQuery.each( garbageElementClassList, function(index, garbageElementClassName ){ 125 126 //Get the name of CSS, like this: conditional_section_element_times 127 if ( garbageElementClassName.indexOf("conditional_section_element_") >= 0 ) { 128 129 // 2.Get the class name in this element of the DIV section in the form 130 formElementClassName = garbageElementClassName.replace('_element', ''); 131 132 // 3.Remove all elements from the form in that DIV into the Garbage 133 jQuery('#booking_form_div' + bk_type + ' div.' + formElementClassName + ' div').appendTo( '#booking_form_garbage' + bk_type ); 134 135 // 4.Insert this element into the form 136 garbageElement.appendTo( '#booking_form_div' + bk_type + ' div.' + formElementClassName ); 137 } 138 }); 139 140 } 141 } 142 }); 143 144 // Select first available option (timeslot) in the dropdown list, that showing based on days conditions , after selection of date in calendar. //FixIn: 8.7.11.3 145 var is_skip; 146 if ( '' !== formElementClassName ){ 147 jQuery.each( jQuery( '#booking_form_div' + bk_type + ' div.' + formElementClassName ).find( 'select' ), function ( index, select_el_in_form ){ 148 149 is_skip = false; 150 jQuery.each( jQuery( select_el_in_form ).find( 'option' ), function ( index, option_in_select ){ 151 152 if ( (!is_skip) && (false === jQuery( option_in_select ).is( ':disabled' )) ){ 153 // jQuery( option_in_select ).prop( "selected", true ); //FixIn: 8.9.1.1 Fix issue of not ability to auto select correct saved value for select boxes in conditional sections, while editing the bookings. 154 is_skip = true; 155 } 156 } ); 157 } ); 158 } 159} 160 161 162// Optionals: Form -> Garbage 163function moveOptionalElementsToGarbage( bk_type ){ 164 jQuery('#booking_form_div' + bk_type + ' .wpdevbk_optional_condition').appendTo( '#booking_form_garbage'+bk_type ); 165 jQuery('#booking_form_garbage' + bk_type + ' .wpdevbk_optional_condition').show(); // We are need to show this elements, because by default they are hided 166} 167 168 169// Defaults: Garbage -> Form 170function moveDefaultElementsToForm( bk_type ){ 171 172 var formElementClassName = ''; 173 var garbageElement = false;
174 175 jQuery.each( jQuery('#booking_form_garbage'+bk_type + ' div') , function(index, conditionGarbageDIV){ // LOOP in the Garbage 176 177 if ( '' !== conditionGarbageDIV.id ){ 178 179 garbageElement = jQuery('#'+conditionGarbageDIV.id); // Get Garbage DIV as jQuery element 180 181 if ( garbageElement.hasClass( 'wpdevbk_default_condition' ) ) { // We found our Default Element 182 183 // Get the ALL CSS classes of this DIV garbage element. 184 var garbageElementClassList = garbageElement.attr('class').split(/\s+/); 185 186 jQuery.each( garbageElementClassList, function(index, garbageElementClassName ){ 187 188 //Get the name of CSS, like this: conditional_section_element_times 189 if ( garbageElementClassName.indexOf("conditional_section_element_") >= 0 ) { 190 191 //Get the CSS class of the DIV section in the form 192 formElementClassName = garbageElementClassName.replace('_element', ''); 193 194 // Move this Default Garbage Element -> Form 195 garbageElement.appendTo( '#booking_form_div' + bk_type + ' div.' + formElementClassName ); 196 } 197 }); 198 199 } 200 } 201 202 }); 203}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.