PageSourceSearch

http://www.reggiewhitefoundation.org/data/sites/7/skins/skin-01/assets/js/components/hs.go-to.js

js reggiewhitefoundation.org collected 2026-09-25 07:16:36 UTC 4,341 bytes, 157 lines download raw bytes

1/**
2 * Go To wrapper.
3 *
4 * @author Htmlstream
5 * @version 1.0
6 *
7 */
8;(function ($) {
9  'use strict';
10  $.HSCore.components.HSGoTo = {
11    /**
12     *
13     *
14     * @var Object _baseConfig
15     */
16    _baseConfig: {},
17
18    /**
19     *
20     *
21     * @var jQuery pageCollection
22     */
23    pageCollection: $(),
24
25    /**
26     * Initialization of Go To wrapper.
27     *
28     * @param String selector (optional)
29     * @param Object config (optional)
30     *
31     * @return jQuery pageCollection - collection of initialized items.
32     */
33
34    init: function (selector, config) {
35      this.collection = selector && $(selector).length ? $(selector) : $();
36      if (!$(selector).length) return;
37
38      this.config = config && $.isPlainObject(config) ?
39        $.extend({}, this._baseConfig, config) : this._baseConfig;
40
41      this.config.itemSelector = selector;
42
43      this.initGoTo();
44
45      return this.pageCollection;
46    },
47
48    initGoTo: function () {
49      //Variables
50      var $self = this,
51        collection = $self.pageCollection;
52
53      //Actions
54      this.collection.each(function (i, el) {
55        //Variables
56        var $this = $(el),
57          $target = $this.data('target'),
58          type = $this.data('type'),
59          showEffect = $this.data('show-effect'),
60          hideEffect = $this.data('hide-effect'),
61          position = JSON.parse(el.getAttribute('data-position')),
62          compensation = $($this.data('compensation')).outerHeight(),
63          offsetTop = $this.data('offset-top'),
64          targetOffsetTop = function () {
65            if (compensation) {
66              return $target ? $($target).offset().top - compensation : 0;
67            } else {
68              return $target ? $($target).offset().top : 0;
69            }
70          };
71
72        if (type == 'static') {
73          $this.css({
74            'display': 'inline-block'
75          });
76        } else {
77          $this.addClass('animated').css({
78            'display': 'inline-block',
79            'position': type,
80            'opacity': 0
81          });
82        }
83
84        if (type == 'fixed' || type == 'absolute') {
85          $this.css(position);
86        }
87
88        $this.on('click', function (e) {
89          e.preventDefault();
90
91          $('html, body').stop().animate({
92            'scrollTop': targetOffsetTop()
93          }, 800);
94        });
95
96        if (!$this.data('offset-top') && !$this.hasClass('js-animation-was-fired') && type != 'static') {
97          if ($this.offset().top <= $(window).height()) {
98            $this.show();
99
100            setTimeout(function () {
101              $this.addClass('js-animation-was-fired ' + showEffect).css({
102                'opacity': ''
103              });
104            });
105          }
106        }
107
108        if (type != 'static') {
109          $(window).on('scroll', function () {
110            if ($this.data('offset-top')) {
111              if ($(window).scrollTop() >= offsetTop && !$this.hasClass('js-animation-was-fired')) {
112                $this.show();
113
114                setTimeout(function () {
115                  $this.addClass('js-animation-was-fired ' + showEffect).css({
116                    'opacity': ''
117                  });
118                });
119              } else if ($(window).scrollTop() <= offsetTop && $this.hasClass('js-animation-was-fired')) {
120                $this.removeClass('js-animation-was-fired ' + showEffect);
121
122                setTimeout(function () {
123                  $this.addClass(hideEffect).css({
124                    'opacity': 0
125                  });
126                }, 100);
127
128                setTimeout(function () {
129                  $this.removeClass(hideEffect).hide();
130                }, 400);
131              }
132            } else {
133              var thisOffsetTop = $this.offset().top;
134
135              if (!$this.hasClass('js-animation-was-fired')) {
136                if ($(window).scrollTop() >= thisOffsetTop - $(window).height()) {
137                  $this.show();
138
139                  setTimeout(function () {
140                    $this.addClass('js-animation-was-fired ' + showEffect).css({
141                      'opacity': ''
142                    });
143                  });
144                }
145              }
146            }
147          });
148
149          $(window).trigger('scroll');
150        }
151
152        //Actions
153        collection = collection.add($this);
154      });
155    }
156  };
157})(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.