kmaterialize 2.0.0 → 2.3.3-1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +55 -91
- package/components/appbar/_navbar.old.scss +223 -0
- package/components/appbar/appbar.css +235 -0
- package/components/appbar/appbar.mjs +54 -0
- package/components/appbar/appbar.test.mjs +9 -0
- package/components/atomic/atomic.mjs +19 -0
- package/components/atomic/component.mjs +67 -0
- package/components/badge/_badges.scss +75 -0
- package/components/badge/badge.mjs +11 -0
- package/components/breadcrumb/_breadcrumb.scss +27 -0
- package/components/button/_buttons.scss +352 -0
- package/components/button/button.mjs +11 -0
- package/components/button/buttons.stories.ts +150 -0
- package/components/button/buttons.ts +282 -0
- package/components/button/examples.iso.js +18 -0
- package/components/button/fabSpec.js +65 -0
- package/components/button/test-button.mjs +16 -0
- package/components/card/_cards.scss +229 -0
- package/components/card/card.mjs +10 -0
- package/components/card/cards.ts +185 -0
- package/components/card/cardsSpec.js +269 -0
- package/components/carousel/_carousel.scss +93 -0
- package/components/carousel/_slider.scss +119 -0
- package/components/carousel/carousel.ts +693 -0
- package/components/carousel/carouselSpec.js +61 -0
- package/components/carousel/slider.ts +431 -0
- package/components/carousel/sliderSpec.js +99 -0
- package/components/checkbox/_checkboxes.scss +281 -0
- package/components/checkbox/checkbox.mdx +24 -0
- package/components/checkbox/checkbox.stories.ts +120 -0
- package/components/chip/chip.mjs +37 -0
- package/components/chip/chip.test.mjs +10 -0
- package/components/chip/chips.css +126 -0
- package/components/chip/chips.mdx +33 -0
- package/components/chip/chips.ts +440 -0
- package/components/chip/chipsSpec.js +165 -0
- package/components/chip/readme.md +323 -0
- package/components/collapsible/_collapsible.scss +82 -0
- package/components/collapsible/collapsible.ts +230 -0
- package/components/collapsible/collapsibleSpec.js +240 -0
- package/components/datepicker/_datepicker.scss +268 -0
- package/components/datepicker/datepicker.ts +1450 -0
- package/components/datepicker/datepickerSpec.js +162 -0
- package/components/dialog/_materialbox.scss +42 -0
- package/components/dialog/_modal.scss +79 -0
- package/components/dialog/materialbox.ts +446 -0
- package/components/dialog/materialboxSpec.js +37 -0
- package/components/dialog/modal.ts +111 -0
- package/components/dialog/modalSpec.js +83 -0
- package/components/dialog/readme.md +5 -0
- package/components/divider/readme.md +15 -0
- package/components/dropdown/_dropdown.scss +83 -0
- package/components/dropdown/dropdown.ts +653 -0
- package/components/dropdown/dropdownSpec.js +108 -0
- package/components/list/_collection.scss +114 -0
- package/components/list/_list.scss +6 -0
- package/components/list/list.mjs +58 -0
- package/components/list/list.test.mjs +16 -0
- package/components/loading/loading.mjs +26 -0
- package/components/loading/loading.test.mjs +10 -0
- package/components/navigation-bar/_old +582 -0
- package/components/navigation-bar/navigation-bar.mdx +20 -0
- package/components/navigation-bar/navigation-bar.stories.ts +39 -0
- package/components/navigation-drawer/_sidenav.scss +247 -0
- package/components/navigation-drawer/sidenav.ts +546 -0
- package/components/navigation-drawer/sidenavSpec.js +124 -0
- package/components/pagination/_pagination.scss +47 -0
- package/components/progress/_preloader.scss +416 -0
- package/components/radio-button/_radio-buttons.scss +112 -0
- package/components/radio-button/radio-buttons.mdx +28 -0
- package/components/radio-button/radio-buttons.stories.ts +51 -0
- package/components/search/autocomplete.ts +620 -0
- package/components/search/autocompleteSpec.js +321 -0
- package/components/slider/_range.scss +157 -0
- package/components/slider/range.ts +216 -0
- package/components/snackbar/_toast.scss +68 -0
- package/components/snackbar/toastSpec.js +132 -0
- package/components/snackbar/toasts.ts +312 -0
- package/components/switch/_switches.scss +121 -0
- package/components/tabs/_tabs.scss +171 -0
- package/components/tabs/tabs.mjs +31 -0
- package/components/tabs/tabs.ts +358 -0
- package/components/tabs/tabsSpec.js +180 -0
- package/components/textfield/_file-input.scss +41 -0
- package/components/textfield/_input-fields.scss +368 -0
- package/components/textfield/_select.scss +104 -0
- package/components/textfield/formfields.css +311 -0
- package/components/textfield/forms.ts +182 -0
- package/components/textfield/formsSpec.js +142 -0
- package/components/textfield/select.ts +472 -0
- package/components/textfield/selectSpec.js +390 -0
- package/components/textfield/textfield.mjs +29 -0
- package/components/textfield/textfield.test.mjs +10 -0
- package/components/timepicker/_timepicker.scss +362 -0
- package/components/timepicker/timepicker.ts +905 -0
- package/components/tooltip/_tooltip.scss +40 -0
- package/components/tooltip/tooltip.ts +380 -0
- package/components/tooltip/tooltipSpec.js +145 -0
- package/dist/css/materialize.colors.min.css +6 -0
- package/dist/css/materialize.css +7578 -6326
- package/dist/css/materialize.min.css +6 -13
- package/dist/css/materialize.min.css.map +1 -0
- package/dist/js/materialize.cjs.js +8410 -0
- package/dist/js/materialize.d.ts +2625 -0
- package/dist/js/materialize.js +8415 -12374
- package/dist/js/materialize.min.js +6 -6
- package/dist/js/materialize.mjs +8382 -0
- package/package.json +82 -47
- package/sass/_colors.scss +417 -0
- package/sass/_global.scss +490 -0
- package/sass/_grid.scss +172 -0
- package/sass/_table_of_contents.scss +28 -0
- package/sass/_tapTarget.scss +102 -0
- package/sass/_typography.scss +58 -0
- package/sass/_variables.scss +56 -0
- package/sass/materialize.scss +51 -0
- package/sass/mixins.module.scss +168 -0
- package/extras/noUiSlider/nouislider.css +0 -406
- package/extras/noUiSlider/nouislider.js +0 -2147
- package/extras/noUiSlider/nouislider.min.js +0 -1
- package/js/anime.min.js +0 -34
- package/js/autocomplete.js +0 -448
- package/js/buttons.js +0 -354
- package/js/cards.js +0 -40
- package/js/carousel.js +0 -717
- package/js/cash.js +0 -960
- package/js/characterCounter.js +0 -136
- package/js/chips.js +0 -481
- package/js/collapsible.js +0 -275
- package/js/component.js +0 -44
- package/js/datepicker.js +0 -975
- package/js/dropdown.js +0 -635
- package/js/forms.js +0 -275
- package/js/global.js +0 -444
- package/js/materialbox.js +0 -453
- package/js/modal.js +0 -382
- package/js/parallax.js +0 -138
- package/js/pushpin.js +0 -148
- package/js/range.js +0 -263
- package/js/scrollspy.js +0 -295
- package/js/select.js +0 -450
- package/js/sidenav.js +0 -580
- package/js/slider.js +0 -359
- package/js/tabs.js +0 -402
- package/js/tapTarget.js +0 -314
- package/js/timepicker.js +0 -647
- package/js/toasts.js +0 -310
- package/js/tooltip.js +0 -303
- package/js/waves.js +0 -335
package/js/range.js
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
(function($, anim) {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
let _defaults = {};
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @class
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
class Range extends Component {
|
|
11
|
-
/**
|
|
12
|
-
* Construct Range instance
|
|
13
|
-
* @constructor
|
|
14
|
-
* @param {Element} el
|
|
15
|
-
* @param {Object} options
|
|
16
|
-
*/
|
|
17
|
-
constructor(el, options) {
|
|
18
|
-
super(Range, el, options);
|
|
19
|
-
|
|
20
|
-
this.el.M_Range = this;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Options for the range
|
|
24
|
-
* @member Range#options
|
|
25
|
-
*/
|
|
26
|
-
this.options = $.extend({}, Range.defaults, options);
|
|
27
|
-
|
|
28
|
-
this._mousedown = false;
|
|
29
|
-
|
|
30
|
-
// Setup
|
|
31
|
-
this._setupThumb();
|
|
32
|
-
|
|
33
|
-
this._setupEventHandlers();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static get defaults() {
|
|
37
|
-
return _defaults;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static init(els, options) {
|
|
41
|
-
return super.init(this, els, options);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get Instance
|
|
46
|
-
*/
|
|
47
|
-
static getInstance(el) {
|
|
48
|
-
let domElem = !!el.jquery ? el[0] : el;
|
|
49
|
-
return domElem.M_Range;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Teardown component
|
|
54
|
-
*/
|
|
55
|
-
destroy() {
|
|
56
|
-
this._removeEventHandlers();
|
|
57
|
-
this._removeThumb();
|
|
58
|
-
this.el.M_Range = undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Setup Event Handlers
|
|
63
|
-
*/
|
|
64
|
-
_setupEventHandlers() {
|
|
65
|
-
this._handleRangeChangeBound = this._handleRangeChange.bind(this);
|
|
66
|
-
this._handleRangeMousedownTouchstartBound = this._handleRangeMousedownTouchstart.bind(this);
|
|
67
|
-
this._handleRangeInputMousemoveTouchmoveBound = this._handleRangeInputMousemoveTouchmove.bind(
|
|
68
|
-
this
|
|
69
|
-
);
|
|
70
|
-
this._handleRangeMouseupTouchendBound = this._handleRangeMouseupTouchend.bind(this);
|
|
71
|
-
this._handleRangeBlurMouseoutTouchleaveBound = this._handleRangeBlurMouseoutTouchleave.bind(
|
|
72
|
-
this
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
this.el.addEventListener('change', this._handleRangeChangeBound);
|
|
76
|
-
|
|
77
|
-
this.el.addEventListener('mousedown', this._handleRangeMousedownTouchstartBound);
|
|
78
|
-
this.el.addEventListener('touchstart', this._handleRangeMousedownTouchstartBound);
|
|
79
|
-
|
|
80
|
-
this.el.addEventListener('input', this._handleRangeInputMousemoveTouchmoveBound);
|
|
81
|
-
this.el.addEventListener('mousemove', this._handleRangeInputMousemoveTouchmoveBound);
|
|
82
|
-
this.el.addEventListener('touchmove', this._handleRangeInputMousemoveTouchmoveBound);
|
|
83
|
-
|
|
84
|
-
this.el.addEventListener('mouseup', this._handleRangeMouseupTouchendBound);
|
|
85
|
-
this.el.addEventListener('touchend', this._handleRangeMouseupTouchendBound);
|
|
86
|
-
|
|
87
|
-
this.el.addEventListener('blur', this._handleRangeBlurMouseoutTouchleaveBound);
|
|
88
|
-
this.el.addEventListener('mouseout', this._handleRangeBlurMouseoutTouchleaveBound);
|
|
89
|
-
this.el.addEventListener('touchleave', this._handleRangeBlurMouseoutTouchleaveBound);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Remove Event Handlers
|
|
94
|
-
*/
|
|
95
|
-
_removeEventHandlers() {
|
|
96
|
-
this.el.removeEventListener('change', this._handleRangeChangeBound);
|
|
97
|
-
|
|
98
|
-
this.el.removeEventListener('mousedown', this._handleRangeMousedownTouchstartBound);
|
|
99
|
-
this.el.removeEventListener('touchstart', this._handleRangeMousedownTouchstartBound);
|
|
100
|
-
|
|
101
|
-
this.el.removeEventListener('input', this._handleRangeInputMousemoveTouchmoveBound);
|
|
102
|
-
this.el.removeEventListener('mousemove', this._handleRangeInputMousemoveTouchmoveBound);
|
|
103
|
-
this.el.removeEventListener('touchmove', this._handleRangeInputMousemoveTouchmoveBound);
|
|
104
|
-
|
|
105
|
-
this.el.removeEventListener('mouseup', this._handleRangeMouseupTouchendBound);
|
|
106
|
-
this.el.removeEventListener('touchend', this._handleRangeMouseupTouchendBound);
|
|
107
|
-
|
|
108
|
-
this.el.removeEventListener('blur', this._handleRangeBlurMouseoutTouchleaveBound);
|
|
109
|
-
this.el.removeEventListener('mouseout', this._handleRangeBlurMouseoutTouchleaveBound);
|
|
110
|
-
this.el.removeEventListener('touchleave', this._handleRangeBlurMouseoutTouchleaveBound);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Handle Range Change
|
|
115
|
-
* @param {Event} e
|
|
116
|
-
*/
|
|
117
|
-
_handleRangeChange() {
|
|
118
|
-
$(this.value).html(this.$el.val());
|
|
119
|
-
|
|
120
|
-
if (!$(this.thumb).hasClass('active')) {
|
|
121
|
-
this._showRangeBubble();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
let offsetLeft = this._calcRangeOffset();
|
|
125
|
-
$(this.thumb)
|
|
126
|
-
.addClass('active')
|
|
127
|
-
.css('left', offsetLeft + 'px');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Handle Range Mousedown and Touchstart
|
|
132
|
-
* @param {Event} e
|
|
133
|
-
*/
|
|
134
|
-
_handleRangeMousedownTouchstart(e) {
|
|
135
|
-
// Set indicator value
|
|
136
|
-
$(this.value).html(this.$el.val());
|
|
137
|
-
|
|
138
|
-
this._mousedown = true;
|
|
139
|
-
this.$el.addClass('active');
|
|
140
|
-
|
|
141
|
-
if (!$(this.thumb).hasClass('active')) {
|
|
142
|
-
this._showRangeBubble();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (e.type !== 'input') {
|
|
146
|
-
let offsetLeft = this._calcRangeOffset();
|
|
147
|
-
$(this.thumb)
|
|
148
|
-
.addClass('active')
|
|
149
|
-
.css('left', offsetLeft + 'px');
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Handle Range Input, Mousemove and Touchmove
|
|
155
|
-
*/
|
|
156
|
-
_handleRangeInputMousemoveTouchmove() {
|
|
157
|
-
if (this._mousedown) {
|
|
158
|
-
if (!$(this.thumb).hasClass('active')) {
|
|
159
|
-
this._showRangeBubble();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
let offsetLeft = this._calcRangeOffset();
|
|
163
|
-
$(this.thumb)
|
|
164
|
-
.addClass('active')
|
|
165
|
-
.css('left', offsetLeft + 'px');
|
|
166
|
-
$(this.value).html(this.$el.val());
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Handle Range Mouseup and Touchend
|
|
172
|
-
*/
|
|
173
|
-
_handleRangeMouseupTouchend() {
|
|
174
|
-
this._mousedown = false;
|
|
175
|
-
this.$el.removeClass('active');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Handle Range Blur, Mouseout and Touchleave
|
|
180
|
-
*/
|
|
181
|
-
_handleRangeBlurMouseoutTouchleave() {
|
|
182
|
-
if (!this._mousedown) {
|
|
183
|
-
let paddingLeft = parseInt(this.$el.css('padding-left'));
|
|
184
|
-
let marginLeft = 7 + paddingLeft + 'px';
|
|
185
|
-
|
|
186
|
-
if ($(this.thumb).hasClass('active')) {
|
|
187
|
-
anim.remove(this.thumb);
|
|
188
|
-
anim({
|
|
189
|
-
targets: this.thumb,
|
|
190
|
-
height: 0,
|
|
191
|
-
width: 0,
|
|
192
|
-
top: 10,
|
|
193
|
-
easing: 'easeOutQuad',
|
|
194
|
-
marginLeft: marginLeft,
|
|
195
|
-
duration: 100
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
$(this.thumb).removeClass('active');
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Setup dropdown
|
|
204
|
-
*/
|
|
205
|
-
_setupThumb() {
|
|
206
|
-
this.thumb = document.createElement('span');
|
|
207
|
-
this.value = document.createElement('span');
|
|
208
|
-
$(this.thumb).addClass('thumb');
|
|
209
|
-
$(this.value).addClass('value');
|
|
210
|
-
$(this.thumb).append(this.value);
|
|
211
|
-
this.$el.after(this.thumb);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Remove dropdown
|
|
216
|
-
*/
|
|
217
|
-
_removeThumb() {
|
|
218
|
-
$(this.thumb).remove();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* morph thumb into bubble
|
|
223
|
-
*/
|
|
224
|
-
_showRangeBubble() {
|
|
225
|
-
let paddingLeft = parseInt(
|
|
226
|
-
$(this.thumb)
|
|
227
|
-
.parent()
|
|
228
|
-
.css('padding-left')
|
|
229
|
-
);
|
|
230
|
-
let marginLeft = -7 + paddingLeft + 'px'; // TODO: fix magic number?
|
|
231
|
-
anim.remove(this.thumb);
|
|
232
|
-
anim({
|
|
233
|
-
targets: this.thumb,
|
|
234
|
-
height: 30,
|
|
235
|
-
width: 30,
|
|
236
|
-
top: -30,
|
|
237
|
-
marginLeft: marginLeft,
|
|
238
|
-
duration: 300,
|
|
239
|
-
easing: 'easeOutQuint'
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Calculate the offset of the thumb
|
|
245
|
-
* @return {Number} offset in pixels
|
|
246
|
-
*/
|
|
247
|
-
_calcRangeOffset() {
|
|
248
|
-
let width = this.$el.width() - 15;
|
|
249
|
-
let max = parseFloat(this.$el.attr('max')) || 100; // Range default max
|
|
250
|
-
let min = parseFloat(this.$el.attr('min')) || 0; // Range default min
|
|
251
|
-
let percent = (parseFloat(this.$el.val()) - min) / (max - min);
|
|
252
|
-
return percent * width;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
M.Range = Range;
|
|
257
|
-
|
|
258
|
-
if (M.jQueryLoaded) {
|
|
259
|
-
M.initializeJqueryWrapper(Range, 'range', 'M_Range');
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
Range.init($('input[type=range]'));
|
|
263
|
-
})(cash, M.anime);
|
package/js/scrollspy.js
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
(function($, anim) {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
let _defaults = {
|
|
5
|
-
throttle: 100,
|
|
6
|
-
scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll
|
|
7
|
-
activeClass: 'active',
|
|
8
|
-
getActiveElement: function(id) {
|
|
9
|
-
return 'a[href="#' + id + '"]';
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @class
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
class ScrollSpy extends Component {
|
|
18
|
-
/**
|
|
19
|
-
* Construct ScrollSpy instance
|
|
20
|
-
* @constructor
|
|
21
|
-
* @param {Element} el
|
|
22
|
-
* @param {Object} options
|
|
23
|
-
*/
|
|
24
|
-
constructor(el, options) {
|
|
25
|
-
super(ScrollSpy, el, options);
|
|
26
|
-
|
|
27
|
-
this.el.M_ScrollSpy = this;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Options for the modal
|
|
31
|
-
* @member Modal#options
|
|
32
|
-
* @prop {Number} [throttle=100] - Throttle of scroll handler
|
|
33
|
-
* @prop {Number} [scrollOffset=200] - Offset for centering element when scrolled to
|
|
34
|
-
* @prop {String} [activeClass='active'] - Class applied to active elements
|
|
35
|
-
* @prop {Function} [getActiveElement] - Used to find active element
|
|
36
|
-
*/
|
|
37
|
-
this.options = $.extend({}, ScrollSpy.defaults, options);
|
|
38
|
-
|
|
39
|
-
// setup
|
|
40
|
-
ScrollSpy._elements.push(this);
|
|
41
|
-
ScrollSpy._count++;
|
|
42
|
-
ScrollSpy._increment++;
|
|
43
|
-
this.tickId = -1;
|
|
44
|
-
this.id = ScrollSpy._increment;
|
|
45
|
-
this._setupEventHandlers();
|
|
46
|
-
this._handleWindowScroll();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static get defaults() {
|
|
50
|
-
return _defaults;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static init(els, options) {
|
|
54
|
-
return super.init(this, els, options);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get Instance
|
|
59
|
-
*/
|
|
60
|
-
static getInstance(el) {
|
|
61
|
-
let domElem = !!el.jquery ? el[0] : el;
|
|
62
|
-
return domElem.M_ScrollSpy;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Teardown component
|
|
67
|
-
*/
|
|
68
|
-
destroy() {
|
|
69
|
-
ScrollSpy._elements.splice(ScrollSpy._elements.indexOf(this), 1);
|
|
70
|
-
ScrollSpy._elementsInView.splice(ScrollSpy._elementsInView.indexOf(this), 1);
|
|
71
|
-
ScrollSpy._visibleElements.splice(ScrollSpy._visibleElements.indexOf(this.$el), 1);
|
|
72
|
-
ScrollSpy._count--;
|
|
73
|
-
this._removeEventHandlers();
|
|
74
|
-
$(this.options.getActiveElement(this.$el.attr('id'))).removeClass(this.options.activeClass);
|
|
75
|
-
this.el.M_ScrollSpy = undefined;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Setup Event Handlers
|
|
80
|
-
*/
|
|
81
|
-
_setupEventHandlers() {
|
|
82
|
-
let throttledResize = M.throttle(this._handleWindowScroll, 200);
|
|
83
|
-
this._handleThrottledResizeBound = throttledResize.bind(this);
|
|
84
|
-
this._handleWindowScrollBound = this._handleWindowScroll.bind(this);
|
|
85
|
-
if (ScrollSpy._count === 1) {
|
|
86
|
-
window.addEventListener('scroll', this._handleWindowScrollBound);
|
|
87
|
-
window.addEventListener('resize', this._handleThrottledResizeBound);
|
|
88
|
-
document.body.addEventListener('click', this._handleTriggerClick);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Remove Event Handlers
|
|
94
|
-
*/
|
|
95
|
-
_removeEventHandlers() {
|
|
96
|
-
if (ScrollSpy._count === 0) {
|
|
97
|
-
window.removeEventListener('scroll', this._handleWindowScrollBound);
|
|
98
|
-
window.removeEventListener('resize', this._handleThrottledResizeBound);
|
|
99
|
-
document.body.removeEventListener('click', this._handleTriggerClick);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Handle Trigger Click
|
|
105
|
-
* @param {Event} e
|
|
106
|
-
*/
|
|
107
|
-
_handleTriggerClick(e) {
|
|
108
|
-
let $trigger = $(e.target);
|
|
109
|
-
for (let i = ScrollSpy._elements.length - 1; i >= 0; i--) {
|
|
110
|
-
let scrollspy = ScrollSpy._elements[i];
|
|
111
|
-
if ($trigger.is('a[href="#' + scrollspy.$el.attr('id') + '"]')) {
|
|
112
|
-
e.preventDefault();
|
|
113
|
-
let offset = scrollspy.$el.offset().top + 1;
|
|
114
|
-
|
|
115
|
-
anim({
|
|
116
|
-
targets: [document.documentElement, document.body],
|
|
117
|
-
scrollTop: offset - scrollspy.options.scrollOffset,
|
|
118
|
-
duration: 400,
|
|
119
|
-
easing: 'easeOutCubic'
|
|
120
|
-
});
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Handle Window Scroll
|
|
128
|
-
*/
|
|
129
|
-
_handleWindowScroll() {
|
|
130
|
-
// unique tick id
|
|
131
|
-
ScrollSpy._ticks++;
|
|
132
|
-
|
|
133
|
-
// viewport rectangle
|
|
134
|
-
let top = M.getDocumentScrollTop(),
|
|
135
|
-
left = M.getDocumentScrollLeft(),
|
|
136
|
-
right = left + window.innerWidth,
|
|
137
|
-
bottom = top + window.innerHeight;
|
|
138
|
-
|
|
139
|
-
// determine which elements are in view
|
|
140
|
-
let intersections = ScrollSpy._findElements(top, right, bottom, left);
|
|
141
|
-
for (let i = 0; i < intersections.length; i++) {
|
|
142
|
-
let scrollspy = intersections[i];
|
|
143
|
-
let lastTick = scrollspy.tickId;
|
|
144
|
-
if (lastTick < 0) {
|
|
145
|
-
// entered into view
|
|
146
|
-
scrollspy._enter();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// update tick id
|
|
150
|
-
scrollspy.tickId = ScrollSpy._ticks;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
for (let i = 0; i < ScrollSpy._elementsInView.length; i++) {
|
|
154
|
-
let scrollspy = ScrollSpy._elementsInView[i];
|
|
155
|
-
let lastTick = scrollspy.tickId;
|
|
156
|
-
if (lastTick >= 0 && lastTick !== ScrollSpy._ticks) {
|
|
157
|
-
// exited from view
|
|
158
|
-
scrollspy._exit();
|
|
159
|
-
scrollspy.tickId = -1;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// remember elements in view for next tick
|
|
164
|
-
ScrollSpy._elementsInView = intersections;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Find elements that are within the boundary
|
|
169
|
-
* @param {number} top
|
|
170
|
-
* @param {number} right
|
|
171
|
-
* @param {number} bottom
|
|
172
|
-
* @param {number} left
|
|
173
|
-
* @return {Array.<ScrollSpy>} A collection of elements
|
|
174
|
-
*/
|
|
175
|
-
static _findElements(top, right, bottom, left) {
|
|
176
|
-
let hits = [];
|
|
177
|
-
for (let i = 0; i < ScrollSpy._elements.length; i++) {
|
|
178
|
-
let scrollspy = ScrollSpy._elements[i];
|
|
179
|
-
let currTop = top + scrollspy.options.scrollOffset || 200;
|
|
180
|
-
|
|
181
|
-
if (scrollspy.$el.height() > 0) {
|
|
182
|
-
let elTop = scrollspy.$el.offset().top,
|
|
183
|
-
elLeft = scrollspy.$el.offset().left,
|
|
184
|
-
elRight = elLeft + scrollspy.$el.width(),
|
|
185
|
-
elBottom = elTop + scrollspy.$el.height();
|
|
186
|
-
|
|
187
|
-
let isIntersect = !(
|
|
188
|
-
elLeft > right ||
|
|
189
|
-
elRight < left ||
|
|
190
|
-
elTop > bottom ||
|
|
191
|
-
elBottom < currTop
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
if (isIntersect) {
|
|
195
|
-
hits.push(scrollspy);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return hits;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
_enter() {
|
|
203
|
-
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(function(value) {
|
|
204
|
-
return value.height() != 0;
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
if (ScrollSpy._visibleElements[0]) {
|
|
208
|
-
$(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).removeClass(
|
|
209
|
-
this.options.activeClass
|
|
210
|
-
);
|
|
211
|
-
if (
|
|
212
|
-
ScrollSpy._visibleElements[0][0].M_ScrollSpy &&
|
|
213
|
-
this.id < ScrollSpy._visibleElements[0][0].M_ScrollSpy.id
|
|
214
|
-
) {
|
|
215
|
-
ScrollSpy._visibleElements.unshift(this.$el);
|
|
216
|
-
} else {
|
|
217
|
-
ScrollSpy._visibleElements.push(this.$el);
|
|
218
|
-
}
|
|
219
|
-
} else {
|
|
220
|
-
ScrollSpy._visibleElements.push(this.$el);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
$(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).addClass(
|
|
224
|
-
this.options.activeClass
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
_exit() {
|
|
229
|
-
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(function(value) {
|
|
230
|
-
return value.height() != 0;
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
if (ScrollSpy._visibleElements[0]) {
|
|
234
|
-
$(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).removeClass(
|
|
235
|
-
this.options.activeClass
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter((el) => {
|
|
239
|
-
return el.attr('id') != this.$el.attr('id');
|
|
240
|
-
});
|
|
241
|
-
if (ScrollSpy._visibleElements[0]) {
|
|
242
|
-
// Check if empty
|
|
243
|
-
$(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).addClass(
|
|
244
|
-
this.options.activeClass
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* @static
|
|
253
|
-
* @memberof ScrollSpy
|
|
254
|
-
* @type {Array.<ScrollSpy>}
|
|
255
|
-
*/
|
|
256
|
-
ScrollSpy._elements = [];
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* @static
|
|
260
|
-
* @memberof ScrollSpy
|
|
261
|
-
* @type {Array.<ScrollSpy>}
|
|
262
|
-
*/
|
|
263
|
-
ScrollSpy._elementsInView = [];
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* @static
|
|
267
|
-
* @memberof ScrollSpy
|
|
268
|
-
* @type {Array.<cash>}
|
|
269
|
-
*/
|
|
270
|
-
ScrollSpy._visibleElements = [];
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* @static
|
|
274
|
-
* @memberof ScrollSpy
|
|
275
|
-
*/
|
|
276
|
-
ScrollSpy._count = 0;
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* @static
|
|
280
|
-
* @memberof ScrollSpy
|
|
281
|
-
*/
|
|
282
|
-
ScrollSpy._increment = 0;
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* @static
|
|
286
|
-
* @memberof ScrollSpy
|
|
287
|
-
*/
|
|
288
|
-
ScrollSpy._ticks = 0;
|
|
289
|
-
|
|
290
|
-
M.ScrollSpy = ScrollSpy;
|
|
291
|
-
|
|
292
|
-
if (M.jQueryLoaded) {
|
|
293
|
-
M.initializeJqueryWrapper(ScrollSpy, 'scrollSpy', 'M_ScrollSpy');
|
|
294
|
-
}
|
|
295
|
-
})(cash, M.anime);
|