1$(function () { 2 3 var tagsSelected = [], 4 removeIcon = '<span class="removeIcon">x</span>', 5 selectedItems = []; 6 7 $(document).on('click', '.tagsList .tag__item', function () { 8 $(this).append(removeIcon); 9 $('.tagsList__selected').prepend($(this)[0].outerHTML); 10 $(this).remove(); 11 $('.tagsList__selected__wrapper').removeClass('hidden'); 12 13 getSelectedItems(); 14 getProducts(); 15 }); 16 17 $(document).on('click', '.tagsList__selected .tag__item', function () { 18 $(this).find('.removeIcon').remove(); 19 // $('.tagsList').prepend($(this)[0].outerHTML); 20 $(this).remove(); 21 22 getSelectedItems(); 23 getProducts(); 24 25 if (!$('.tagsList__selected .tag__item').length) $('.tagsList__selected__wrapper').addClass('hidden'); 26 }); 27 28 $('.tag__item.tag__reset').click( function () { 29 $('.tagsList__selected .tag__item').each(function () { 30 $(this).find('.removeIcon').remove(); 31 $('.tagsList').prepend($(this)[0].outerHTML); 32 }); 33 $('.tagsList__selected .tag__item').remove(); 34 $('.tagsList__selected__wrapper').addClass('hidden'); 35 36 getSelectedItems(); 37 getProducts(); 38 }); 39 40 function getProducts() { 41 $.ajax({ 42 method: 'POST', 43 url: '/ajax/products', 44 data: { selectedItems: selectedItems } 45 }).done(function(data) { 46 $('.productList__wrapper').html($(data).filter('.productList__wrapper').html()); 47 $('.tagsList').html($(data).filter('.tagsList')); 48 }); 49 } 50 51 function getSelectedItems() { 52 selectedItems = [] 53 $('.tagsList__selected .tag__item').each(function () { 54 selectedItems.push($(this).data('id')); 55 }); 56 } 57 58 getCity(); 59 60 // map 61 function getCity() { 62 $.ajax({ 63 method: 'POST', 64 url: '/ajax/city', 65 dataType: 'json', 66 data: { 67 city: $('.city__selector').val(), 68 item_id: $('.productItem').data('id') 69 } 70 }).done(function(data) { 71 markersLayer.clearLayers(); 72 73 markers = []; 74 markersBranches = []; 75 76 var MarkerIcon = L.Icon.extend({ 77 options: { 78 customId: "", 79 } 80 }); 81 82 $(data.markers).each(function (el) { 83 84 85 markers[this.partner_id] = L.marker([this.lat, this.lng], { draggable: false, customId: this.partner_id }).on('click', function(e) { 86 getPatnersByMarker(this.options.customId); 87 }); 88 markers[this.partner_id].bindPopup("<a href='#partner"+this.partner_id+"'>"+this.name+"</a>").openPopup(); 89 markersLayer.addLayer(markers[this.partner_id]); 90 91 var _this = this; 92 93 if (this.hasOwnProperty('branches')) { 94 this.branches.forEach(function(value, index) { 95 markersBranches[_this.partner_id] = L.marker([value.lat, value.lng], { draggable: false, customId: _this.partner_id }).on('click', function(e) { 96 getPatnersByMarker(this.options.customId); 97 }); 98 markersBranches[_this.partner_id].bindPopup("<a href='#partner"+_this.partner_id+"'>"+_this.name+"</a>").openPopup(); 99 markersLayer.addLayer(markersBranches[_this.partner_id]); 100 }); 101 } 102 }); 103 104 map.addLayer(markersLayer); 105 106 if (data.orders) $('.partners__wrapper').html(data.orders); else { 107 $('.partners__wrapper').html(''); 108 } 109 110 map.fitBounds(markersLayer.getBounds()); 111 if (map._zoom>14) { 112 map.setZoom(14); 113 } 114 }); 115 } 116 117 function getPatnersByMarker(id) { 118 if ($('.city__selector').val() == 0) { 119 $.ajax({ 120 method: 'POST', 121 url: '/ajax/partners', 122 data: { 123 partner_id: id, 124 item_id: $('.productItem').data('id') 125 } 126 }).done(function(data) { 127 $('.partners__wrapper').html(data); 128 }); 129 } else { 130 $('.partnerItem').removeClass('partnerItem__selected'); 131 $('.partners__wrapper #partner'+id).addClass('partnerItem__selected'); 132 } 133 } 134 135 $('.city__selector').change( function () { 136 getCity(); 137 }); 138 139 // mobile 140 141 $('header .burger').click( function () { 142 $('nav').toggleClass('mobile-hide'); 143 }); 144 145});
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.