PageSourceSearch

https://zcloudme.com/templates/nuhost/js/bootstrap.offcanvas.min.js

js zcloudme.com collected 2026-10-05 09:49:49 UTC 13,098 bytes, 349 lines download raw bytes

vendor: 13,098 bytes, lines 1-349
1(function() {
2  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
3
4  (function($, window) {
5    var Offcanvas, OffcanvasDropdown, OffcanvasTouch;
6    OffcanvasDropdown = (function() {
7      function OffcanvasDropdown(element) {
8        this.element = element;
9        this._clickEvent = __bind(this._clickEvent, this);
10        this.element = $(this.element);
11        this.nav = this.element.closest(".nav");
12        this.dropdown = this.element.parent().find(".dropdown-menu");
13        this.element.on('click', this._clickEvent);
14        this.nav.closest('.navbar-offcanvas').on('click', (function(_this) {
15          return function() {
16            if (_this.dropdown.is('.shown')) {
17              return _this.dropdown.removeClass('shown').closest('.open').removeClass('open');
18            }
19          };
20        })(this));
21      }
22
23      OffcanvasDropdown.prototype._clickEvent = function(e) {
24        if (!this.dropdown.hasClass('shown')) {
25          e.preventDefault();
26        }
27        e.stopPropagation();
28        $('.dropdown-toggle').not(this.element).closest('.open').removeClass('open').find('.dropdown-menu').removeClass('shown');
29        this.dropdown.toggleClass("shown");
30        return this.element.parent().toggleClass('open');
31      };
32
33      return OffcanvasDropdown;
34
35    })();
36	
37	
38    OffcanvasTouch = (function() {
39      function OffcanvasTouch(button, element, location, offcanvas) {
40        this.button = button;
41        this.element = element;
42        this.location = location;
43        this.offcanvas = offcanvas;
44        this._getFade = __bind(this._getFade, this);
45        this._getCss = __bind(this._getCss, this);
46        this._touchEnd = __bind(this._touchEnd, this);
47        this._touchMove = __bind(this._touchMove, this);
48        this._touchStart = __bind(this._touchStart, this);
49        this.endThreshold = 130;
50        this.startThreshold = this.element.hasClass('navbar-offcanvas-right') ? $("body").outerWidth() - 60 : 20;
51        this.maxStartThreshold = this.element.hasClass('navbar-offcanvas-right') ? $("body").outerWidth() - 20 : 60;
52        this.currentX = 0;
53        this.fade = this.element.hasClass('navbar-offcanvas-fade') ? true : false;
54        $(document).on("touchstart", this._touchStart);
55        $(document).on("touchmove", this._touchMove);
56        $(document).on("touchend", this._touchEnd);
57      }
58
59      OffcanvasTouch.prototype._touchStart = function(e) {
60        this.startX = e.originalEvent.touches[0].pageX;
61        if (this.element.is('.in')) {
62          return this.element.height($(window).outerHeight());
63        }
64      };
65
66      OffcanvasTouch.prototype._touchMove = function(e) {
67        var x;
68        if ($(e.target).parents('.navbar-offcanvas').length > 0) {
69          return true;
70        }
71        if (this.startX > this.startThreshold && this.startX < this.maxStartThreshold) {
72          e.preventDefault();
73          x = e.originalEvent.touches[0].pageX - this.startX;
74          x = this.element.hasClass('navbar-offcanvas-right') ? -x : x;
75          if (Math.abs(x) < this.element.outerWidth()) {
76            this.element.css(this._getCss(x));
77            return this.element.css(this._getFade(x));
78          }
79        } else if (this.element.hasClass('in')) {
80          e.preventDefault();
81          x = e.originalEvent.touches[0].pageX + (this.currentX - this.startX);
82          x = this.element.hasClass('navbar-offcanvas-right') ? -x : x;
83          if (Math.abs(x) < this.element.outerWidth()) {
84            this.element.css(this._getCss(x));
85            return this.element.css(this._getFade(x));
86          }
87        }
88      };
89
90      OffcanvasTouch.prototype._touchEnd = function(e) {
91        var end, sendEvents, x;
92        if ($(e.target).parents('.navbar-offcanvas').length > 0) {
93          return true;
94        }
95        sendEvents = false;
96        x = e.originalEvent.changedTouches[0].pageX;
97        if (Math.abs(x) === this.startX) {
98          return;
99        }
100        end = this.element.hasClass('navbar-offcanvas-right') ? Math.abs(x) > (this.endThreshold + 50) : x < (this.endThreshold + 50);
101        if (this.element.hasClass('in') && end) {
102          this.currentX = 0;
103          this.element.removeClass('in').css(this._clearCss());
104          this.button.removeClass('is-open');
105          sendEvents = true;
106        } else if (Math.abs(x - this.startX) > this.endThreshold && this.startX > this.startThreshold && this.startX < this.maxStartThreshold) {
107          this.currentX = this.element.hasClass('navbar-offcanvas-right') ? -this.element.outerWidth() : this.element.outerWidth();
108          this.element.toggleClass('in').css(this._clearCss());
109          this.button.toggleClass('is-open');
110          sendEvents = true;
111        } else {
112          this.element.css(this._clearCss());
113        }
114        return this.offcanvas.bodyOverflow(sendEvents);
115      };
116
117      OffcanvasTouch.prototype._getCss = function(x) {
118        x = this.element.hasClass('navbar-offcanvas-right') ? -x : x;
119        return {
120          "-webkit-transform": "translate3d(" + x + "px, 0px, 0px)",
121          "-webkit-transition-duration": "0s",
122          "-moz-transform": "translate3d(" + x + "px, 0px, 0px)",
123          "-moz-transition": "0s",
124          "-o-transform": "translate3d(" + x + "px, 0px, 0px)",
125          "-o-transition": "0s",
126          "transform": "translate3d(" + x + "px, 0px, 0px)",
127          "transition": "0s"
128        };
129      };
130
131      OffcanvasTouch.prototype._getFade = function(x) {
132        if (this.fade) {
133          return {
134            "opacity": x / this.element.outerWidth()
135          };
136        } else {
137          return {};
138        }
139      };
140
141      OffcanvasTouch.prototype._clearCss = function() {
142        return {
143          "-webkit-transform": "",
144          "-webkit-transition-duration": "",
145          "-moz-transform": "",
146          "-moz-transition": "",
147          "-o-transform": "",
148          "-o-transition": "",
149          "transform": "",
150          "transition": "",
151          "opacity": ""
152        };
153      };
154
155      return OffcanvasTouch;
156
157    })();
158    window.Offcanvas = Offcanvas = (function() {
159      function Offcanvas(element) {
160        var t, target;
161        this.element = element;
162        this.bodyOverflow = __bind(this.bodyOverflow, this);
163        this._sendEventsAfter = __bind(this._sendEventsAfter, this);
164        this._sendEventsBefore = __bind(this._sendEventsBefore, this);
165        this._documentClicked = __bind(this._documentClicked, this);
166        this._close = __bind(this._close, this);
167        this._open = __bind(this._open, this);
168        this._clicked = __bind(this._clicked, this);
169        this._navbarHeight = __bind(this._navbarHeight, this);
170        target = this.element.attr('data-target') ? this.element.attr('data-target') : false;
171        if (target) {
172          this.target = $(target);
173          if (this.target.length && !this.target.hasClass('js-offcanvas-done')) {
174            this.element.addClass('js-offcanvas-has-events');
175            this.location = this.target.hasClass("navbar-offcanvas-right") ? "right" : "left";
176            this.target.addClass(this._transformSupported() ? "offcanvas-transform js-offcanvas-done" : "offcanvas-position js-offcanvas-done");
177            this.target.data('offcanvas', this);
178            this.element.on("click", this._clicked);
179            this.target.on('transitionend', (function(_this) {
180              return function() {
181                if (_this.target.is(':not(.in)')) {
182                  return _this.target.height('');
183                }
184              };
185            })(this));
186            $(document).on("click", this._documentClicked);
187            if (this.target.hasClass('navbar-offcanvas-touch')) {
188              t = new OffcanvasTouch(this.element, this.target, this.location, this);
189            }
190            this.target.find(".dropdown-toggle").each(function() {
191              var d;
192              return d = new OffcanvasDropdown(this);
193            });
194            this.target.on('offcanvas.toggle', (function(_this) {
195              return function(e) {
196                return _this._clicked(e);
197              };
198            })(this));
199            this.target.on('offcanvas.close', (function(_this) {
200              return function(e) {
201                return _this._close(e);
202              };
203            })(this));
204            this.target.on('offcanvas.open', (function(_this) {
205              return function(e) {
206                return _this._open(e);
207              };
208            })(this));
209          }
210        } else {
211          console.warn('Offcanvas: `data-target` attribute must be present.');
212        }
213      }
214
215      Offcanvas.prototype._navbarHeight = function() {
216        if (this.target.is('.in')) {
217          return this.target.height($(window).outerHeight());
218        }
219      };
220
221      Offcanvas.prototype._clicked = function(e) {
222        e.preventDefault();
223        this._sendEventsBefore();
224        $(".navbar-offcanvas").not(this.target).trigger('offcanvas.close');
225        this.target.toggleClass('in');
226        this.element.toggleClass('is-open');
227        this._navbarHeight();
228        return this.bodyOverflow();
229      };
230
231      Offcanvas.prototype._open = function(e) {
232        e.preventDefault();
233        if (this.target.is('.in')) {
234          return;
235        }
236        this._sendEventsBefore();
237        this.target.addClass('in');
238        this.element.addClass('is-open');
239        this._navbarHeight();
240        return this.bodyOverflow();
241      };
242
243      Offcanvas.prototype._close = function(e) {
244        e.preventDefault();
245        if (this.target.is(':not(.in)')) {
246          return;
247        }
248        this._sendEventsBefore();
249        this.target.removeClass('in');
250        this.element.removeClass('is-open');
251        this._navbarHeight();
252        return this.bodyOverflow();
253      };
254
255      Offcanvas.prototype._documentClicked = function(e) {
256        var clickedEl;
257        clickedEl = $(e.target);
258        if (!clickedEl.hasClass('offcanvas-toggle') && clickedEl.parents('.offcanvas-toggle').length === 0 && clickedEl.parents('.navbar-offcanvas').length === 0 && !clickedEl.hasClass('navbar-offcanvas')) {
259          if (this.target.hasClass('in')) {
260            e.preventDefault();
261            this._sendEventsBefore();
262            this.target.removeClass('in');
263            this.element.removeClass('is-open');
264            this._navbarHeight();
265            return this.bodyOverflow();
266          }
267        }
268      };
269
270      Offcanvas.prototype._sendEventsBefore = function() {
271        if (this.target.hasClass('in')) {
272          return this.target.trigger('hide.bs.offcanvas');
273        } else {
274          return this.target.trigger('show.bs.offcanvas');
275        }
276      };
277
278      Offcanvas.prototype._sendEventsAfter = function() {
279        if (this.target.hasClass('in')) {
280          return this.target.trigger('shown.bs.offcanvas');
281        } else {
282          return this.target.trigger('hidden.bs.offcanvas');
283        }
284      };
285
286      Offcanvas.prototype.bodyOverflow = function(events) {
287        if (events == null) {
288          events = true;
289        }
290        if (this.target.is('.in')) {
291          $('body').addClass('offcanvas-stop-scrolling');
292        } else {
293          $('body').removeClass('offcanvas-stop-scrolling');
294        }
295        if (events) {
296          return this._sendEventsAfter();
297        }
298      };
299
300      Offcanvas.prototype._transformSupported = function() {
301        var asSupport, el, regex, translate3D;
302        el = document.createElement('div');
303        translate3D = "translate3d(0px, 0px, 0px)";
304        regex = /translate3d\(0px, 0px, 0px\)/g;
305        el.style.cssText = "-webkit-transform: " + translate3D + "; -moz-transform: " + translate3D + "; -o-transform: " + translate3D + "; transform: " + translate3D;
306        asSupport = el.style.cssText.match(regex);
307        return asSupport.length != null;
308      };
309
310      return Offcanvas;
311
312    })();
313    $.fn.bsOffcanvas = function() {
314      return this.each(function() {
315        return new Offcanvas($(this));
316      });
317    };
318    return $(function() {
319      $('[data-toggle="offcanvas"]').each(function() {
320        return $(this).bsOffcanvas();
321      });
322      $(window).on('resize', function() {
323        $('.navbar-offcanvas.in').each(function() {
324          return $(this).height('').removeClass('in');
325        });
326        $('.offcanvas-toggle').removeClass('is-open');
327        return $('body').removeClass('offcanvas-stop-scrolling');
328      });
329      return $('.offcanvas-toggle').each(function() {
330        return $(this).on('click', function(e) {
331          var el, selector;
332          if (!$(this).hasClass('js-offcanvas-has-events')) {
333            selector = $(this).attr('data-target');
334            el = $(selector);
335            if (el) {
336              el.height('');
337              el.removeClass('in');
338              return $('body').css({
339                overflow: '',
340                position: ''
341              });
342            }
343          }
344        });
345      });
346    });
347  })(window.jQuery, window);
348
349}).call(this);

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.