Widget:MapLegend

RLQ.push(['jquery', function {  console.log('mw.loader and jQuery are available now', $);  var id = '';  function setVisibility(type, on) {    if (on) {      $('#map-' + id).removeClass('hide-' + type);    } else {      $('#map-' + id).addClass('hide-' + type);    }  }  $('#map-legend-' + id).on('change', 'input.toggle-one', function  { setVisibility(this.value, this.checked); }); $('#map-toggle-all-' + id).on('click', function  { $('#map-legend-' + id).find('input.toggle-one').prop('checked', this.checked).each(function {      setVisibility(this.value, this.checked);    }); }); $('#map-toggle-cave-' + id).on('click', function  { setVisibility('cave', this.checked); });

// shows coords near cursor var tooltipCoords = $(' ').css({   textAlign: 'center',    backgroundColor: 'rgba(255, 255, 255, 0.7)',    textShadow: '1px 1px white',    color: 'black',    padding: '3px',    minWidth: '60px',    position: 'fixed',    display: 'none',    whiteSpace: 'nowrap',    border: '1px solid black'  }).appendTo('#content');

$('.map-container'). each(function {      var $this = $(this),        widthCoords = parseFloat($this.data('borderleft')) - parseFloat($this.data('borderright')),        heightCoords = parseFloat($this.data('borderbottom')) - parseFloat($this.data('bordertop')),        borderT = parseFloat($this.data('bordertop')),        borderR = parseFloat($this.data('borderright'));

$this. mousemove(function (e) {         var pos = $this.offset,            top = pos.top,            right = pos.left + $this.width,            lon = ((right - e.clientX - $(document).scrollLeft) * widthCoords / $this.width + borderR).toFixed(1),            lat = ((e.clientY + $(document).scrollTop - top) * heightCoords / $this.height + borderT).toFixed(1);

$(tooltipCoords).text(lon + 'W ' + lat + 'S').css({           left: e.clientX + 20,            top: e.clientY          }).show; }).       mouseleave(function  { $(tooltipCoords).hide; });   }); }]);