PageSourceSearch

https://ospu.ru/assets/templates/ospu/js/hs.core.js

js ospu.ru collected 2026-10-03 17:35:42 UTC 5,809 bytes, 250 lines download raw bytes

1/**
2 * HSCore -
3 *
4 * @author HtmlStream
5 * @version 1.0
6 */
7;
8(function ($) {
9
10  'use strict';
11
12  $.HSCore = {
13
14    /**
15     *
16     *
17     * @param
18     *
19     * @return
20     */
21    init: function () {
22
23      $(document).ready(function (e) {
24        // Botostrap Tootltips
25        $('[data-toggle="tooltip"]').tooltip();
26
27        // Set Background Image Dynamically
28        if ($('[data-bg-img-src]').length) $.HSCore.helpers.bgImage($('[data-bg-img-src]'));
29
30        // Extends jQuery
31        $.HSCore.helpers.extendjQuery();
32
33        // Detect Internet Explorer (IE)
34        $.HSCore.helpers.detectIE();
35
36        // Bootstrap Navigation Options
37        $.HSCore.helpers.bootstrapNavOptions.init();
38
39      });
40
41      $(window).on('load', function (e) {
42
43      });
44
45    },
46
47    /**
48     *
49     *
50     * @var
51     */
52    components: {},
53
54    /**
55     *
56     *
57     * @var
58     */
59    helpers: {
60
61        Math: {
62
63          getRandomValueFromRange: function(startPoint, endPoint, fixed) {
64
65            var fixedInner = fixed ? fixed : false;
66
67            Math.random();
68
69            return fixedInner ? (Math.random() * (endPoint - startPoint) + startPoint) : (Math.floor(Math.random() * (endPoint - startPoint + 1)) + startPoint);
70
71          }
72
73      },
74
75      /**
76       * Sets background-image dynamically.
77       *
78       * @param jQuery collection
79       *
80       * @return jQuery|undefined
81       */
82      bgImage: function (collection) {
83
84        if (!collection || !collection.length) return;
85
86        return collection.each(function (i, el) {
87
88          var $el = $(el),
89            bgImageSrc = $el.data('bg-img-src');
90
91          if (bgImageSrc) $el.css('background-image', 'url(' + bgImageSrc + ')');
92
93        });
94
95      },
96
97      /**
98       * Extends basic jQuery functionality
99       *
100       * @return undefined
101       */
102      extendjQuery: function () {
103
104        $.fn.extend({
105
106          /**
107           * Runs specified function after loading of all images.
108           *
109           * @return Deferred
110           */
111          imagesLoaded: function () {
112
113            var $imgs = this.find('img[src!=""]');
114
115            if (!$imgs.length) {
116              return $.Deferred().resolve().promise();
117            }
118
119            var dfds = [];
120
121            $imgs.each(function () {
122              var dfd = $.Deferred();
123              dfds.push(dfd);
124              var img = new Image();
125              img.onload = function () {
126                dfd.resolve();
127              };
128              img.onerror = function () {
129                dfd.resolve();
130              };
131              img.src = this.src;
132            });
133
134            return $.when.apply($, dfds);
135
136          }
137
138        });
139
140      },
141
142
143      /**
144       * Detect Internet Explorer (IE)
145       *
146       * @return version of IE or false, if browser is not Internet Explorer
147       */
148
149      detectIE: function() {
150
151          var ua = window.navigator.userAgent;
152
153          var trident = ua.indexOf('Trident/');
154          if (trident > 0) {
155              // IE 11 => return version number
156              var rv = ua.indexOf('rv:');
157              var ieV = parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
158              document.querySelector('body').className += ' IE';
159          }
160
161          var edge = ua.indexOf('Edge/');
162          if (edge > 0) {
163             // IE 12 (aka Edge) => return version number
164             var ieV = parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
165              document.querySelector('body').className += ' IE';
166          }
167
168          // other browser
169          return false;
170
171      },
172
173
174      /**
175       * Bootstrap navigation options
176       *
177       */
178      bootstrapNavOptions: {
179        init: function () {
180          this.mobileHideOnScroll();
181        },
182
183        mobileHideOnScroll: function () {
184          var $collection = $('.navbar');
185          if (!$collection.length) return;
186
187          var $w = $(window),
188            breakpointsMap = {
189              'sm': 576,
190              'md': 768,
191              'lg': 992,
192              'xl': 1200
193            };
194
195          $('body').on('click.HSMobileHideOnScroll', '.navbar-toggler', function (e) {
196            var $navbar = $(this).closest('.navbar');
197
198            if ($navbar.length) {
199              $navbar.data('mobile-menu-scroll-position', $w.scrollTop());
200            }
201            e.preventDefault();
202          });
203
204          $w.on('scroll.HSMobileHideOnScroll', function (e) {
205            $collection.each(function (i, el) {
206              var $this = $(el), $toggler, $nav, offset, $hamburgers, breakpoint;
207              if ($this.hasClass('navbar-expand-xl')) breakpoint = breakpointsMap['xl'];
208              else if ($this.hasClass('navbar-expand-lg')) breakpoint = breakpointsMap['lg'];
209              else if ($this.hasClass('navbar-expand-md')) breakpoint = breakpointsMap['md'];
210              else if ($this.hasClass('navbar-expand-xs')) breakpoint = breakpointsMap['xs'];
211
212              if ($w.width() > breakpoint) return;
213
214              $toggler = $this.find('.navbar-toggler');
215              $nav = $this.find('.navbar-collapse');
216
217              if (!$nav.data('mobile-scroll-hide')) return;
218
219              if ($nav.length) {
220                offset = $this.data('mobile-menu-scroll-position');
221
222                if (Math.abs($w.scrollTop() - offset) > 40 && $nav.hasClass('show')) {
223                  $toggler.trigger('click');
224                  $hamburgers = $toggler.find('.is-active');
225                  if ($hamburgers.length) {
226                    $hamburgers.removeClass('is-active');
227                  }
228                }
229              }
230            });
231          });
232        }
233      }
234
235    },
236
237    /**
238     *
239     *
240     * @var
241     */
242    settings: {
243      rtl: false
244    }
245
246  };
247
248  $.HSCore.init();
249
250})(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.