PageSourceSearch

https://www.institutimagine.org/themes/custom/ecedi/js/helpers.js?tm2jnl

js institutimagine.org collected 2026-10-02 08:04:04 UTC 1,522 bytes, 53 lines download raw bytes

1/**
2 * @file Global Helpers object
3 * @see JS module pattern explained :
4 *     http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
5 * @example
6 * Helpers.demoHelper(...);
7 */
8
9'use strict';
10
11var Helpers = (function (helpers, $) {
12  /**
13   * @function Helpers.demoHelper
14   * Demo helper
15   * @param {string} demoArg - Whatever text you want
16   */
17  helpers.demoHelper = function (demoArg) {
18    console.log('Ceci est un helper de démo "' + demoArg + '" !');
19  };
20
21  /**
22   * A11y animated scroll to.
23   *
24   * @param {object} $target - A jquery element to scroll to.
25   * @param {string} hash - The location hash used to works similarly to the
26   *     native anchor navigation (optional).
27   * @param {int} offset - Positive or negative offset (optional).
28   */
29  helpers.scrollTo = function ($target, hash, offset) {
30    var _offset = offset || 0;
31    return $('html, body').animate({
32      scrollTop: $target.offset().top - _offset
33    }, 500, function () {
34      // after the animation, focus on the target
35      $target.focus();
36
37      // if the target doesn't get the focus by itself (= it isn't an
38      // interactive element), force it with a tabindex -1
39      if (!$target.is(':focus')) {
40        $target.attr('tabindex', '-1');
41        $target.focus();
42      }
43
44      // change the URL with the new hash so it works similarly to the native
45      // anchor navigation
46      if (hash) {
47        location.hash = hash;
48      }
49    }).promise();
50  }
51
52  return helpers;
53}(Helpers || {}, jQuery));

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.