1(function($) 2{ 3 4 bookneticHooks.addAction('booking_panel_loaded', function ( booknetic ) 5 { 6 let booking_panel_js = booknetic.panel_js; 7 8 booknetic.deleteCartItem = function (itemIndex , itemLine ) 9 { 10 itemIndex = Number.parseInt(itemIndex); 11 if( booknetic.cartArr.length == 1 && itemIndex == 0) 12 { 13 $("#booknetic_start_new_booking_btn").trigger('click' ); 14 return; 15 } 16 17 if(booknetic.cartCurrentIndex != itemIndex) 18 { 19 itemLine.remove(); 20 booknetic.cartArr.splice(itemIndex,1); 21 booknetic.cartCurrentIndex--; 22 booknetic.cartHTMLBody.splice(itemIndex,1); 23 booknetic.cartHTMLSideBar.splice(itemIndex,1); 24 $("div.booknetic-cart .booknetic-cart-col").each( function (index){ 25 $(this).attr('data-index', index); 26 }) 27 this.showCartIcon(); 28 }else 29 { 30 31 let hasPrev = booknetic.cartArr[itemIndex-1] != undefined; 32 let hasNext = booknetic.cartArr[itemIndex+1] != undefined; 33 let currentBody = booking_panel_js[0].querySelector('.booknetic_appointment_container_body .booknetic_need_copy'); 34 35 if( hasPrev ) 36 { 37 currentBody.parentNode.insertBefore( booknetic.cartHTMLBody[itemIndex-1] , currentBody); 38 39 booking_panel_js[0].querySelectorAll('.booknetic_appointment_steps_body .booknetic_appointment_step_element.need_copy').forEach((current)=>{ 40 let id = current.getAttribute('data-step-id'); 41 current.parentNode.insertBefore(booknetic.cartHTMLSideBar[itemIndex-1][id] , current); 42 current.parentNode.removeChild(current); 43 }); 44 45 booknetic.cartCurrentIndex = itemIndex-1; 46 } 47 else if( hasNext ) 48 { 49 currentBody.parentNode.insertBefore( booknetic.cartHTMLBody[itemIndex+1] , currentBody); 50 booking_panel_js[0].querySelectorAll('.booknetic_appointment_steps_body .booknetic_appointment_step_element.need_copy').forEach((current)=>{ 51 let id = current.getAttribute('data-step-id'); 52 current.parentNode.insertBefore(booknetic.cartHTMLSideBar[itemIndex+1][id] , current); 53 current.parentNode.removeChild(current); 54 }); 55 booknetic.cartCurrentIndex = itemIndex; 56 } 57 currentBody.parentNode.removeChild(currentBody); 58 booknetic.cartArr.splice( itemIndex,1); 59 booknetic.cartHTMLBody.splice( itemIndex ,1); 60 booknetic.cartHTMLSideBar.splice( itemIndex ,1); 61 62 itemLine.remove(); 63 $("div.booknetic-cart .booknetic-cart-col").each( function (index){ 64 $(this).attr('data-index', index); 65 }); 66 67 booknetic.cartPrevStep = undefined; 68 69 } 70 booknetic.stepManager.saveData(); 71 booknetic.stepManager.loadStep('cart'); 72 }; 73 74 booknetic.showCartIcon = function () 75 { 76 let cartContainer = booking_panel_js.find('.booknetic_appointment_container_header_cart'); 77 cartContainer.find('span').text(booknetic.cartArr.length); 78 79 if (booknetic.cartArr.length > 0 ) { 80 cartContainer.fadeIn(); 81 } else { 82 cartContainer.fadeOut(); 83 } 84 }; 85 86 booking_panel_js.on('click', '.booknetic-cart-item-btns',function(e) 87 { 88 e.stopPropagation(); 89 }).on('mouseenter', '.booknetic-cart-item-info' , function () 90 { 91 $(this).parents('.booknetic-cart-item-body-row').addClass('show'); 92 }).on('mouseleave', '.booknetic-cart-item-info' , function () 93 { 94 $(this).parents('.booknetic-cart-item-body-row').removeClass('show'); 95 }).on('click', '.booknetic-appointment-container-cart-btn' , function () 96 { 97 let current_step_el = booking_panel_js.find(".booknetic_appointment_step_element.booknetic_active_step"), 98 current_step_id = current_step_el.data('step-id'), 99 next_step_el = booking_panel_js.find('.booknetic_appointment_steps_body div[data-step-id="cart"]'), 100 next_step_id = 'cart'; 101 booknetic.toast( false ); 102 booknetic.stepManager.loadStep( next_step_id ); 103 // current_step_el.addClass('booknetic_selected_step'); 104 105 if( booknetic.isMobileView() ) 106 { 107 $('html,body').animate({scrollTop: parseInt(booking_panel_js.offset().top) - 100}, 1000); 108 } 109 if(current_step_id != 'cart') 110 { 111 booknetic.cartPrevStep = current_step_id; 112 } 113 }).on('hover', '.booknetic-cart-item-info', function() 114 { 115 $(this).closest('.booknetic-cart-item-body-row').toggleClass('show'); 116 }).on('click', '.booknetic-cart-item-error-close', function () 117 { 118 $(this).closest('.booknetic-cart-item-error').removeClass('show'); 119 }).on('click', '.booking-again' , function () 120 { 121 booknetic.cartCurrentIndex++; 122 booknetic.stepManager.saveData(); 123 $("#booknetic_start_new_booking_btn").trigger('click'); 124 }).on('click' ,'.booknetic-cart-item-remove' , function () 125 { 126 let itemLine = $(this).parents('div.booknetic-cart-col'); 127 let itemIndex = itemLine.attr('data-index');
128 booknetic.deleteCartItem( itemIndex , itemLine ); 129 130 }).on('click','.booknetic-cart-item-edit',function () 131 { 132 let itemLine = $(this).parents('div.booknetic-cart-col'); 133 let itemIndex = Number.parseInt(itemLine.attr('data-index')); 134 135 let currentBody = booking_panel_js[0].querySelector('.booknetic_appointment_container_body .booknetic_need_copy'); 136 137 currentBody.parentNode.insertBefore( booknetic.cartHTMLBody[itemIndex] , currentBody); 138 139 currentBody.parentNode.removeChild(currentBody); 140 141 // booknetic.cartHTMLBody[booknetic.cartCurrentIndex] = currentBody.cloneNode(true); 142 booknetic.cartHTMLBody[booknetic.cartCurrentIndex] = $(currentBody).clone(true,true).get(0); 143 144 booking_panel_js[0].querySelectorAll('.booknetic_appointment_steps_body .booknetic_appointment_step_element.need_copy').forEach((current)=> 145 { 146 let id = current.getAttribute('data-step-id'); 147 148 if(booknetic.cartHTMLSideBar[booknetic.cartCurrentIndex] == undefined) 149 { 150 booknetic.cartHTMLSideBar[booknetic.cartCurrentIndex] = {}; 151 } 152 booknetic.cartHTMLSideBar[booknetic.cartCurrentIndex][id] = $(current).clone(true,true).get(0); 153 154 current.parentNode.insertBefore(booknetic.cartHTMLSideBar[itemIndex][id] , current) 155 current.parentNode.removeChild(current); 156 }); 157 158 var start_step = booking_panel_js.find(".booknetic_appointment_step_element:not(.booknetic_menu_hidden):eq(0)"); 159 160 booknetic.cartCurrentIndex = itemIndex; 161 booknetic.stepManager.loadStep(start_step.attr('data-step-id')); 162 }); 163 164 }); 165 166 bookneticHooks.addAction('before_step_loading', function( booknetic, new_step_id, old_step_id ) 167 { 168 let booking_panel_js = booknetic.panel_js; 169 170 if( new_step_id === 'cart' ) 171 { 172 booknetic.stepManager.loadStandartSteps( new_step_id, old_step_id ); 173 } 174 175 if( new_step_id !=='cart' ) 176 { 177 booknetic.cartPrevStep = undefined; 178 } 179 180 /** 181 * CSS Height sorunu var deye bele yazilib kod, .booknetic_need_copy ichinde olan step deilse height 100% verenede css qarishir, 182 * auto verir ve bu container avtomatik 0px olur heighti, ichinde olan steplerde ise 100% verir, butun alani kaplayir; 183 * Gelecekde daha seliqeli usul dushunmek olar; 184 */ 185 if( booking_panel_js.find(`.booknetic_need_copy [data-step-id="${new_step_id}"]`).length === 0 ) 186 { 187 booking_panel_js.find('.booknetic_need_copy').css('height','auto'); 188 } 189 else 190 { 191 booking_panel_js.find('.booknetic_need_copy').css('height','100%'); 192 } 193 194 if( old_step_id === 'cart' ) 195 { 196 let cartHtmlLastIndex = booking_panel_js.find('.booknetic-cart .booknetic-cart-col').last().attr('data-index'); 197 198 if( booknetic.cartArr.length-1 > cartHtmlLastIndex ) 199 { 200 booknetic.cartArr = []; 201 booknetic.cartCurrentIndex--; 202 } 203 } 204 }); 205 206 bookneticHooks.addAction('loaded_step', function( booknetic, new_step_id, old_step_id, ajaxData ) 207 { 208 let booking_panel_js = booknetic.panel_js; 209 210 if( new_step_id === 'cart' ) 211 { 212 booking_panel_js.find('.booknetic_appointment_container_body div[data-step-id="cart"]').css('display', 'flex'); 213 booknetic.showCartIcon(); 214 } 215 216 booknetic.cartErrors.error = [] 217 }); 218 219 bookneticHooks.addAction('step_loaded_with_error', function( booknetic, new_step_id, old_step_id, ajaxData ) 220 { 221 let booking_panel_js = booknetic.panel_js; 222 223 //todo: cart needs to be added to getSelected obj 224 if( booking_panel_js.find('.booknetic_appointment_step_element[data-step-id="cart"]').hasClass('booknetic_menu_hidden') ) 225 { 226 if ( ajaxData.hasOwnProperty('errors') ) 227 { 228 booknetic.toast(ajaxData.errors[0].message); 229 } 230 else 231 { 232 booknetic.toast(ajaxData.error_msg); 233 } 234 } 235 236 if (ajaxData != undefined && typeof ajaxData['errors'] != 'undefined') 237 { 238 let errors = ajaxData['errors']; 239 errors.filter(function (value,index) 240 { 241 return typeof value['cart_item'] != 'undefined'; 242 }) 243 booknetic.cartErrors.error = errors; 244 } 245 else 246 { 247 booknetic.cartErrors.error = []; 248 } 249 }); 250 251 252 253})(jQuery);
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.