PageSourceSearch

https://kungsbacka.se/download/18.51f49f9317c1158e1c26903d/1740035508202/clickable-area.js

js kungsbacka.se collected 2026-10-02 04:34:40 UTC 2,088 bytes, 59 lines download raw bytes

1// Makes an area clickable, usable for blurbs and stuff like that. On click the
2// user is redirected to the location of the first link inside the clickable area.
3//
4// Documentation available at https://github.com/Limepark/common/tree/master/clickable-area.
5//
6// Copyright (C) 2013 Limepark AB
7/* globals lp */
8(function($, utils) {
9  if (utils.isOnlineMode()) {
10    var isMac = navigator.platform.toLowerCase().indexOf('mac') === 0;
11
12    $('html').on('click', '.lp-clickable-area', function (event) {
13      var linkClicked = event.target.tagName.match(/^a$/i) || $(event.target).parents('a').length > 0;
14      var interactiveElementClicked = event.target.tagName.match(/^(button|input|textarea)$/i);
15      var isTextSelected = window.getSelection().toString();
16
17      if (!linkClicked && !interactiveElementClicked && !isTextSelected) {
18        var newTab = (isMac && event.metaKey) || (!isMac && event.ctrlKey) || event.shiftKey;
19        var firstLink = $('a', this)[0];
20
21        if (firstLink) {
22          event.preventDefault();
23
24          if (newTab) {
25            window.open(firstLink.href, '_blank');
26          } else {
27            firstLink.click();
28          }
29        }
30      }
31    });
32
33    $('head').append('<style type="text/css">.lp-clickable-area { cursor: pointer; }</style>');
34  }
35
36  $.fn.clickableArea = function (options) {
37    var opts = $.extend({}, $.fn.clickableArea.defaults, options);
38
39    return this.each(function () {
40      var $el = $(this);
41      if (!opts.requireLink || $el.has('a[href]').length > 0) {
42        $el.addClass('lp-clickable-area');
43      }
44    });
45  };
46
47  $.fn.clickableArea.defaults = {
48    requireLink: false, // require a link in the element for the clickable area to be applied.
49  };
50
51  /**
52   * Init code
53   */
54  $(function () {
55    $('.sv-archive-portlet li, .lp-boxes > div, :not(.lp-box-menu__item--additional-box) > .lp-box-menu__content, .sv-newslist__gallery-item, .lp-related-page, .lp-card, .lp-basetool-event-list__item, .lp-app-blurbs-list__item').clickableArea({ requireLink: true });
56  });
57
58
59})($svjq || jQuery, lp.utils);

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.