PageSourceSearch

https://harvardfcu.org/wp-content/themes/huecu2020/assets/js/bodyScrollLock.min.js

js harvardfcu.org collected 2026-09-26 05:48:14 UTC 8,351 bytes, 196 lines download raw bytes

vendor: 8,351 bytes, lines 1-196
1/*!
2 * Scroll Lock v3.1.3
3 * https://github.com/MohammadYounes/jquery-scrollLock
4 *
5 * Copyright (c) 2017 Mohammad Younes
6 * Licensed under GPL 3.
7 */
8;(function (factory) {
9    if (typeof define === 'function' && define.amd) {
10      // AMD. Register as an anonymous module.
11      define(['jquery'], factory)
12    } else {
13      // Browser globals
14      factory(jQuery)
15    }
16  }(function ($) {
17    'use strict'
18    var keys = { space: 32, pageup: 33, pagedown: 34, end: 35, home: 36,  up: 38, down: 40 }
19    var processScrollEvent = function (event, $element) {
20      var scrollTop = $element.scrollTop(),
21        scrollHeight = $element.prop('scrollHeight'),
22        clientHeight = $element.prop('clientHeight'),
23        delta = event.originalEvent.wheelDelta || (-1 * event.originalEvent.detail) || (-1 * event.originalEvent.deltaY),
24        deltaY = 0
25      if (event.type === 'wheel') {
26        var ratio = $element.height() / $(window).height()
27        deltaY = event.originalEvent.deltaY * ratio
28      } else if (this.options.touch && event.type === 'touchmove') {
29        delta = event.originalEvent.changedTouches[0].clientY - this.startClientY
30      }
31      var top, prevent
32      prevent = (top = delta > 0 && scrollTop + deltaY <= 0) || delta < 0 && scrollTop + deltaY >= scrollHeight - clientHeight
33      return {prevent: prevent, top: top, scrollTop: scrollTop, deltaY: deltaY }
34    }
35    var processKeyboardEvent = function (event, $element) {
36      var scrollTop = $element.scrollTop(),
37        result = {top: false, bottom: false}
38      result.top = scrollTop === 0 && (event.keyCode === keys.pageup || event.keyCode === keys.home || event.keyCode === keys.up)
39      if (!result.top) {
40        var scrollHeight = $element.prop('scrollHeight'),
41          clientHeight = $element.prop('clientHeight')
42        result.bottom = scrollHeight === scrollTop + clientHeight && (event.keyCode === keys.space || event.keyCode === keys.pagedown || event.keyCode === keys.end || event.keyCode === keys.down)
43      }
44      return result
45    }
46    var ScrollLock = function ($element, options) {
47      this.$element = $element
48      this.options = $.extend({}, ScrollLock.DEFAULTS, this.$element.data(), options)
49      this.enabled = true
50      this.startClientY = 0
51      if (this.options.unblock) {
52        this.$element.on(ScrollLock.CORE.wheelEventName + ScrollLock.NAMESPACE, this.options.unblock, $.proxy(ScrollLock.CORE.unblockHandler, this))
53      }
54      this.$element.on(ScrollLock.CORE.wheelEventName + ScrollLock.NAMESPACE, this.options.selector, $.proxy(ScrollLock.CORE.handler, this))
55      if (this.options.touch) {
56        this.$element.on('touchstart' + ScrollLock.NAMESPACE, this.options.selector, $.proxy(ScrollLock.CORE.touchHandler, this))
57        this.$element.on('touchmove' + ScrollLock.NAMESPACE, this.options.selector, $.proxy(ScrollLock.CORE.handler, this))
58        
59        if (this.options.unblock) {
60          this.$element.on('touchmove' + ScrollLock.NAMESPACE, this.options.unblock, $.proxy(ScrollLock.CORE.unblockHandler, this))
61        }
62      }
63      if (this.options.keyboard) {
64        this.$element.attr('tabindex', this.options.keyboard.tabindex || 0)
65        this.$element.on('keydown' + ScrollLock.NAMESPACE, this.options.selector, $.proxy(ScrollLock.CORE.keyboardHandler, this))
66  
67        if (this.options.unblock) {
68          this.$element.on('keydown' + ScrollLock.NAMESPACE, this.options.unblock, $.proxy(ScrollLock.CORE.unblockHandler, this))
69        }
70      }
71    }
72    ScrollLock.NAME = 'ScrollLock'
73    ScrollLock.VERSION = '3.1.2'
74    ScrollLock.NAMESPACE = '.scrollLock'
75    ScrollLock.ANIMATION_NAMESPACE = ScrollLock.NAMESPACE + '.effect'
76    ScrollLock.DEFAULTS = {
77      strict: false,
78      strictFn: function ($element) {
79        return $element.prop('scrollHeight') > $element.prop('clientHeight')
80      },
81      selector: false,
82      animation: false,
83      touch: 'ontouchstart' in window,
84      keyboard: false,
85      unblock: false
86    }
87    ScrollLock.CORE = {
88      wheelEventName: 'onwheel' in document.createElement('div') ? 'wheel' : // Modern browsers support "wheel"
89        document.onmousewheel !== undefined ? 'mousewheel' : // Webkit and IE support at least "mousewheel"
90          'DOMMouseScroll', // let's assume that remaining browsers are older Firefox,
91      animationEventName: [
92          'webkitAnimationEnd',
93          'mozAnimationEnd',
94          'MSAnimationEnd',
95          'oanimationend',
96          'animationend'
97        ].join(ScrollLock.ANIMATION_NAMESPACE + ' ') + ScrollLock.ANIMATION_NAMESPACE,
98      unblockHandler: function (event) {
99        event.__currentTarget = event.currentTarget
100      },
101      handler: function (event) {
102        // allow zooming
103        if (this.enabled && !event.ctrlKey) {
104          var $this = $(event.currentTarget)
105          if (this.options.strict !== true || this.options.strictFn($this)) {
106            // Support for nested scrollable blocks (see https://github.com/MohammadYounes/jquery-scrollLock/issues/4)
107            event.stopPropagation()
108            var result = $.proxy(processScrollEvent, this)(event, $this)
109            if (event.__currentTarget)
110              result.prevent &= $.proxy(processScrollEvent, this)(event, $(event.__currentTarget)).prevent
111            if (result.prevent) {
112              event.preventDefault()
113              if (result.deltaY) {
114                $this.scrollTop(result.scrollTop + result.deltaY)
115              }
116              var key = result.top ? 'top' : 'bottom'
117              if (this.options.animation) {
118                setTimeout(ScrollLock.CORE.animationHandler.bind(this, $this, key), 0)
119              }
120              $this.trigger($.Event(key + ScrollLock.NAMESPACE))
121            }
122          }
123        }
124      },
125      touchHandler: function (event) {
126        this.startClientY = event.originalEvent.touches[0].clientY
127      },
128      animationHandler: function ($element, key) {
129        var css = this.options.animation[key],
130          all = this.options.animation.top + ' ' + this.options.animation.bottom
131        $element.off(ScrollLock.ANIMATION_NAMESPACE)
132          .removeClass(all)
133          .addClass(css)
134          .one(ScrollLock.CORE.animationEventName,
135            function () {
136              $element.removeClass(css)
137            })
138      },
139      keyboardHandler: function (event) {
140        var $this = $(event.currentTarget),
141          scrollTop = $this.scrollTop(),
142          result = processKeyboardEvent(event, $this)
143        if (event.__currentTarget) {
144          var result2 = processKeyboardEvent(event, $(event.__currentTarget))
145          result.top &= result2.top
146          result.bottom &= result2.bottom
147        }
148        if (result.top) {
149          $this.trigger($.Event('top' + ScrollLock.NAMESPACE))
150          if (this.options.animation) {
151            setTimeout(ScrollLock.CORE.animationHandler.bind(this, $this, 'top'), 0)
152          }
153          return false
154        } else if (result.bottom) {
155          $this.trigger($.Event('bottom' + ScrollLock.NAMESPACE))
156          if (this.options.animation) {
157            setTimeout(ScrollLock.CORE.animationHandler.bind(this, $this, 'bottom'), 0)
158          }
159          return false
160        }
161      }
162    }
163    ScrollLock.prototype.toggleStrict = function () {
164      this.options.strict = !this.options.strict
165    }
166    ScrollLock.prototype.enable = function () {
167      this.enabled = true
168    }
169    ScrollLock.prototype.disable = function () {
170      this.enabled = false
171    }
172    ScrollLock.prototype.destroy = function () {
173      this.disable()
174      this.$element.off(ScrollLock.NAMESPACE)
175      this.$element = null
176      this.options = null
177    }
178    // plugin defintion.
179    var old = $.fn.scrollLock
180    $.fn.scrollLock = function (option) {
181      return this.each(function () {
182        var $this = $(this)
183        var options = typeof option == 'object' && option
184        var data = $this.data(ScrollLock.NAME)
185        if (!data && 'destroy' === option) return
186        if (!data) $this.data(ScrollLock.NAME, (data = new ScrollLock($this, options)))
187        if (typeof option == 'string') data[option]()
188      })
189    }
190    $.fn.scrollLock.defaults = ScrollLock.DEFAULTS
191    // no conflict
192    $.fn.scrollLock.noConflict = function () {
193      $.fn.scrollLock = old
194      return this
195    }
196  }));

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.