PageSourceSearch

https://depita.com/js/drawer.js?1650360134

js depita.com collected 2026-10-08 13:21:24 UTC 5,046 bytes, 181 lines download raw bytes

vendor: 2,021 bytes, lines 1-74
1/*!
2 * jquery-drawer v3.2.2
3 * Flexible drawer menu using jQuery, iScroll and CSS.
4 * http://git.blivesta.com/drawer
5 * License : MIT
6 * Author : blivesta <[email protected]> (http://blivesta.com/)
7 */
8
9;(function umd(factory) {
10  'use strict';
11  if (typeof define === 'function' && define.amd) {
12    define(['jquery'], factory);
13  } else if (typeof exports === 'object') {
14    module.exports = factory(require('jquery'));
15  } else {
16    factory(jQuery);
17  }
18}(function Drawer($) {
19  'use strict';
20  var namespace = 'drawer';
21  var touches = typeof document.ontouchstart != 'undefined';
22  var __ = {
23    init: function init(options) {
24      options = $.extend({
25        iscroll: {
26          mouseWheel: true,
27          preventDefault: false
28        },
29        showOverlay: true
30      }, options);
31
32      __.settings = {
33        state: false,
34        events: {
35          opened: 'drawer.opened',
36          closed: 'drawer.closed'
37        },
38        dropdownEvents: {
39          opened: 'shown.bs.dropdown',
40          closed: 'hidden.bs.dropdown'
41        }
42      };
43
44      __.settings.class = $.extend({
45        nav: 'drawer-nav',
46        toggle: 'drawer-toggle',
47        overlay: 'drawer-overlay',
48        open: 'drawer-open',
49        close: 'drawer-close',
50        dropdown: 'drawer-dropdown'
51      }, options.class);
52
53      return this.each(function instantiateDrawer() {
54        var _this = this;
55        var $this = $(this);
56        var data = $this.data(namespace);
57
58        if (!data) {
59          options = $.extend({}, options);
60          $this.data(namespace, { options: options });
61
62          __.refresh.call(_this);
63
64          if (options.showOverlay) {
65            __.addOverlay.call(_this);
66          }
67
68          $('.' + __.settings.class.toggle).on('click.' + namespace, function toggle() {
69            __.toggle.call(_this);
70            return _this.iScroll.refresh();
71          });
72
73          $(window).on('resize.' + namespace, function close() {
74            // __.close.call(_this); iOS15のSafari対応
vendor: 3,025 bytes, lines 74-181
74
75            return _this.iScroll.refresh();
76          });
77
78          $('.' + __.settings.class.dropdown)
79            .on(__.settings.dropdownEvents.opened + ' ' + __.settings.dropdownEvents.closed, function onOpenedOrClosed() {
80              return _this.iScroll.refresh();
81            });
82        }
83
84      }); // end each
85    },
86
87    refresh: function refresh() {
88      this.iScroll = new IScroll(
89        '.' + __.settings.class.nav,
90        $(this).data(namespace).options.iscroll
91      );
92    },
93
94    addOverlay: function addOverlay() {
95      var $this = $(this);
96      var $overlay = $('<div>').addClass(__.settings.class.overlay + ' ' + __.settings.class.toggle);
97
98      return $this.append($overlay);
99    },
100
101    toggle: function toggle() {
102      var _this = this;
103
104      if (__.settings.state) {
105        return __.close.call(_this);
106      } else {
107        return __.open.call(_this);
108      }
109    },
110
111    open: function open() {
112      var $this = $(this);
113
114      if (touches) {
115        $this.on('touchmove.' + namespace, function disableTouch(event) {
116          event.preventDefault();
117        });
118      }
119
120      return $this
121        .removeClass(__.settings.class.close)
122        .addClass(__.settings.class.open)
123        .drawerCallback(function triggerOpenedListeners() {
124          __.settings.state = true;
125          $this.trigger(__.settings.events.opened);
126        });
127    },
128
129    close: function close() {
130      var $this = $(this);
131
132      if (touches) $this.off('touchmove.' + namespace);
133
134      return $this
135        .removeClass(__.settings.class.open)
136        .addClass(__.settings.class.close)
137        .drawerCallback(function triggerClosedListeners() {
138          __.settings.state = false;
139          $this.trigger(__.settings.events.closed);
140        });
141    },
142
143    destroy: function destroy() {
144      return this.each(function destroyEach() {
145        var _this = this;
146        var $this = $(this);
147        $('.' + __.settings.class.toggle).off('click.' + namespace);
148        $(window).off('resize.' + namespace);
149        $('.' + __.settings.class.dropdown).off(__.settings.dropdownEvents.opened + ' ' + __.settings.dropdownEvents.closed);
150        _this.iScroll.destroy();
151        $this
152          .removeData(namespace)
153          .find('.' + __.settings.class.overlay)
154          .remove();
155      });
156    }
157
158  };
159
160  $.fn.drawerCallback = function drawerCallback(callback) {
161    var end = 'transitionend webkitTransitionEnd';
162    return this.each(function setAnimationEndHandler() {
163      var $this = $(this);
164      $this.on(end, function invokeCallbackOnAnimationEnd() {
165        $this.off(end);
166        return callback.call(this);
167      });
168    });
169  };
170
171  $.fn.drawer = function drawer(method) {
172    if (__[method]) {
173      return __[method].apply(this, Array.prototype.slice.call(arguments, 1));
174    } else if (typeof method === 'object' || !method) {
175      return __.init.apply(this, arguments);
176    } else {
177      $.error('Method ' + method + ' does not exist on jQuery.' + namespace);
178    }
179  };
180
181}));

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.