1(function ($, Drupal) { 2 3 Drupal.behaviors.offersSearchFormMap = { 4 attach: function (context) { 5 var $search_form = $('.base-map-search-form'); 6 var $map = $('.js-map-annuaire'); 7 var id = $search_form.find('[name="region"]').val(); 8 var $marker = $('.js-marker'); 9 10 function activeId(active) { 11 var relativeX = active.offset().left - active.closest('.js-map-wrapper').offset().left - 10; 12 var relativeY = active.offset().top - active.closest('.js-map-wrapper').offset().top - 30; 13 $marker.css({'left': relativeX, 'top': relativeY}); 14 } 15 16 function activeMap() { 17 if ($mapActive.length > 0) { 18 $marker.removeClass('d-none'); 19 activeId($mapActive); 20 21 $marker.on('click', function () { 22 // $(this).siblings().find('a.is-active').popover('toggle'); 23 $marker.toggleClass('active'); 24 }); 25 26 if ( $(window).width() < 1024 ) { 27 var $mapActiveTablet = $('.js-map-annuaire .js-map-wrapper.d-md-none a.is-active'); 28 activeId($mapActiveTablet); 29 } 30 31 $(window).resize(function() { 32 activeId($mapActive); 33 }); 34 } 35 } 36 37 function clear() { 38 $('.form-item-department input').val(''); 39 $('.is-active').removeClass('is-active'); 40 $('.js-marker').addClass('d-none'); 41 } 42 43 if (id) { 44 $map.find('a[data-id="' + id + '"]').addClass('is-active'); 45 var $mapActive = $('.js-map-annuaire a.is-active', context); 46 activeMap(); 47 } 48 49 $map.find('a').on('click', function (e) { 50 e.preventDefault(); 51 $marker.removeClass('active'); 52 $map.find('a').removeClass('is-active'); 53 // $map.find('a').not($(this)).popover('hide'); 54 $(this).addClass('is-active'); 55 // $(this).once().popover('hide'); 56 activeId($(this)); 57 id = $(this).data('id'); 58 $search_form.find('[name="region"]').val(id).trigger('change'); 59 }); 60 61 $search_form.find('.form-text').not('.js-hide').change(function (){ 62 clear(); 63 }); 64 65 $search_form.find(".SumoSelect li").bind('click.check', function(event) { 66 clear(); 67 }); 68 69 } 70 }; 71})(jQuery, Drupal);
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.