1jQuery(function($) { 2 /* Order Menu */ 3 4 $('#order-search').searchFilter({ targetSelector: ".order-menu .food-item", charCount: 3}); 5 6 $('.close-order').on('click', function() { 7 $('body').toggleClass('order-open'); 8 $('.order-menu-wrapper').toggleClass('active'); 9 10 if ('WebkitTransform' in document.body.style || 'MozTransform' in document.body.style || 'OTransform' in document.body.style || 'transform' in document.body.style) {} else { 11 $('.order-menu-wrapper').toggleClass('show-ie'); 12 } 13 }); 14 15 $('.mobile-close').on('click', function(e) { 16 $('.close-order').click(); 17 }); 18 19 $('.order-menu .anps_quantity button').on('click', function() { 20 var el = $(this).parent().children('.num'); 21 var parent = $(this).parent().parent().parent(); 22 var previousPrice = parseFloat($('.order-footer .price span').html().replace(',', '.')); 23 var price = parseFloat($(this).parent().parent().children('.price').clone().children().remove().end().text().replace(',', '.')); 24 var val = parseInt(el.html()); 25 var delivery_price = ""; 26 if($(".anps_delivery_fixed_price").val()!="") { 27 delivery_price = " + "+$(".anps_delivery_fixed_price").val()+" (delivery fixed price)" 28 } 29 if( $(this).hasClass('plus') ) { 30 el.html(val + 1); 31 $('.order-footer .price span, .order-review .price span').html((previousPrice + price).toFixed(2)+delivery_price); 32 } else { 33 if( val > 0 ) { 34 el.html(val - 1); 35 $('.order-footer .price span, .order-review .price span').html((previousPrice - price).toFixed(2)+delivery_price); 36 } else { 37 el.html('0'); 38 } 39 } 40 41 if( parseInt(el.html()) > 0 ) { 42 parent.addClass('active'); 43 } else { 44 parent.removeClass('active'); 45 } 46 }); 47 48 $('button[data-menu-order="review"]').on('click', function() { 49 $('.order-summary').html(''); 50 var vals = ''; 51 $('.order-menu .food-item.active').each(function(index) { 52 var el = $('.order-menu .food-item.active').eq(index); 53 if( vals != '' ) { 54 vals += ';'; 55 } 56 vals += el.attr('id') + ':' + el.find('.num').html(); 57 58 $('.order-summary').append('<li id="' + el.attr('id') + '"><h3><span class="pull-left">' + el.find('h3').html() + '</span><span class="pull-right color">Ã' + el.find('.num').html() + '</span></h3></li>'); 59 }); 60 61 $.cookie('kataleya-order', vals, { expires: 365, path: '/' }); 62 63 var notes = $('.order-menu .order-notes').val(); 64 if( notes ) { 65 $.cookie('kataleya-order-notes', notes, { expires: 365, path: '/' }); 66 $('.order-review .order-notes').val(notes); 67 } 68 69 $('.order-header, .order-menu section, .order-footer, .order-review').toggleClass('hidden'); 70 }); 71 72 $('button[data-menu-order="notes"]').on('click', function() { 73 $('.order-notes').toggleClass('hidden'); 74 }); 75 76 $('button[data-menu-order="back"]').on('click', function() { 77 $('.order-header, .order-menu section, .order-footer, .order-review').toggleClass('hidden'); 78 return false; 79 e.preventDefault(); 80 }); 81 82 if( $.cookie('kataleya-order') && $.cookie('kataleya-order') != 'null' ) { 83 var vals = $.cookie('kataleya-order').split(';'); 84 var total = 0; 85 86 $.each(vals, function(index) { 87 var eachVal = vals[index].split(':'); 88 $('.order-menu #' + eachVal[0]).addClass('active').find('.num').html(eachVal[1]); 89 90 total += parseInt(eachVal[1]) * parseFloat($('.order-menu #' + eachVal[0]).find('.price').clone().children().remove().end().text().replace(',', '.')); 91 }); 92 var delivery_price = ""; 93 if($(".anps_delivery_fixed_price").val()!="") { 94 delivery_price = " + "+$(".anps_delivery_fixed_price").val()+" (delivery fixed price)" 95 } 96 $('.order-footer .price span, .order-review .price span').html(total.toFixed(2)+delivery_price); 97 if( total > 0 ) { 98 $('.order-menu-wrapper').addClass('cookie-content'); 99 } 100 } 101 102 if( $.cookie('kataleya-order-notes') && $.cookie('kataleya-order-notes') != 'null' ) { 103 var notes = $.cookie('kataleya-order-notes'); 104 $('.order-menu .order-notes').val(notes).removeClass('hidden'); 105 } 106 107 /* Content Form */ 108 109 function setCustomer(vals) { 110 var menuOrderCustomer = $('form[data-menu-order="customer"]'); 111 var formOrderCustomer = $('form[data-menu-order="content-form"]'); 112 113 $.each(vals, function(index) { 114 var eachVal = vals[index].split(':'); 115 menuOrderCustomer.find('[name="' + eachVal[0] + '"]').val(eachVal[1]); 116 formOrderCustomer.find('[name="' + eachVal[0] + '"]').val(eachVal[1]); 117 }); 118 } 119 120 $('button[data-menu-order="content-form-submit"]').on('click', function(e) { 121 var vals = ''; 122 var menuOrderCustomer = $('form[data-menu-order="customer"]'); 123 $('form[data-menu-order="content-form"] input').each(function(index) { 124 var el = $('form[data-menu-order="content-form"] input').eq(index); 125 if( vals != '' ) { 126 vals += ';'; 127 } 128 vals += el.attr('name') + ':' + el.val(); 129 130 menuOrderCustomer.find('#order-' + el.attr('id')).val(el.val()); 131 }); 132 $('.close-order').click(); 133 $.cookie('kataleya-order-customer', vals, { expires: 365, path: '/' }); 134 setCustomer(vals.split(';')); 135 return false;
136 e.preventDefault(); 137 }); 138 139 /* Customer Cookie */ 140 141 if( $.cookie('kataleya-order-customer') ) { 142 setCustomer($.cookie('kataleya-order-customer').split(';')); 143 } 144 145 /* Reservation */ 146 147 $('form[data-form="reservation"]').on('submit', function(e) { 148 $(".contact-success").remove(); 149 $('form[data-form="reservation"] .btn').attr('disabled','disabled'); 150 //$('form[data-form="reservation"]').trigger("reset"); 151 152 var el = $(this); 153 var formData = el.serializeObject(); 154 if(checkFormRequired(el)) { 155 try { 156 $.ajax({ 157 type: "POST", 158 url: $('#anps-restaurant-plugin-url').val() + '/ajax/reservation.php', 159 data: { 160 form_data : formData, 161 } 162 }).success(function(msg) { 163 el.append('<div class="row"><div class="col-md-12"><div class="alert alert-success contact-success"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><i class="fa fa-check"></i>' + $(el).attr("data-success") + '</div></div></div>'); 164 $('.contact-success .close').on('click', function() { 165 $(this).parent().remove(); 166 $('form[data-form="reservation"] .btn').removeAttr('disabled'); 167 $('form[data-form="reservation"]').trigger("reset"); 168 }); 169 }); 170 } catch(e) { console.log(e); } 171 } 172 e.preventDefault(); 173 return false; 174 }); 175 176 /* Order form submit */ 177 178 $('form[data-menu-order="customer"]').on('submit', function(e) { 179 $(".contact-success").remove(); 180 var el = $(this); 181 var formData = el.serializeObject(); 182 var orderItems = { }; 183 184 $('.order-summary li').each(function(index) { 185 var tempEl = $('.order-summary li').eq(index); 186 orderItems[tempEl.attr('id')] = tempEl.find('.pull-right').html().replace('Ã', ''); 187 }); 188 189 orderItems['TOTAL'] = $('.order-review .price span').html(); 190 if(orderItems['TOTAL']=="0") { 191 return false; 192 } 193 if(checkFormRequired(el)) { 194 try { 195 $.ajax({ 196 type: "POST", 197 url: $('#anps-restaurant-plugin-url').val() + '/ajax/order.php', 198 data: { 199 form_data : formData, 200 order_items : orderItems 201 } 202 }).success(function(msg) { 203 el.append('<div class="row"><div class="col-md-12"><div class="alert alert-success contact-success"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><i class="fa fa-check"></i>' + $(el).attr("data-success") + '</div></div></div>'); 204 $('.contact-success .close').on('click', function() { 205 $(this).parent().remove(); 206 }); 207 $.cookie('kataleya-order', null, { path: '/' }); 208 $.cookie('kataleya-order-customer', null, { path: '/' }); 209 $.cookie('kataleya-order-notes', null, { path: '/' }); 210 $(".order-review .order-summary").remove(); 211 $(".order-review .price span").html("0"); 212 }); 213 } catch(e) { console.log(e); } 214 } 215 e.preventDefault(); 216 return false; 217 }); 218}) 219function checkElementValidation2(child) { 220 221 child.parent().find('.error-message').remove(); 222 223 if (child.val() == "" && child.attr("data-required") == "required") { 224 child.addClass("error"); 225 child.parent().append('<span class="error-message">' + child.parents("form").attr("data-required") + '</span>'); 226 child.parent().find('.error-message').css("margin-left", -child.parent().find('.error-message').innerWidth()/2); 227 return false; 228 } 229 230 child.removeClass("error"); 231 return true; 232} 233 234function checkFormRequired(el) { 235 var valid = true; 236 children = el.find('input[type="text"], input[type="email"], input[type="tel"]'); 237 children.each(function(index) { 238 var child = children.eq(index); 239 var parent = child.parents("form"); 240 241 if(!checkElementValidation2(child)) { 242 valid = false;
243 } 244 }); 245 246 return valid; 247}
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.