@brandocms/jupiter 3.46.4 → 3.48.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/package.json +9 -9
- package/src/events/index.js +1 -0
- package/src/index.js +7 -7
- package/src/modules/Application/index.js +119 -80
- package/src/modules/Breakpoints/index.js +14 -17
- package/src/modules/Cookies/index.js +86 -43
- package/src/modules/CoverOverlay/index.js +6 -3
- package/src/modules/Dataloader/index.js +173 -7
- package/src/modules/Dom/index.js +26 -26
- package/src/modules/Dropdown/index.js +14 -14
- package/src/modules/EqualHeightElements/index.js +70 -0
- package/src/modules/EqualHeightImages/index.js +95 -0
- package/src/modules/FeatureTests/index.js +22 -15
- package/src/modules/FixedHeader/index.js +79 -75
- package/src/modules/Fontloader/index.js +5 -3
- package/src/modules/FooterReveal/index.js +1 -1
- package/src/modules/HeroSlider/index.js +33 -23
- package/src/modules/HeroVideo/index.js +15 -13
- package/src/modules/Lazyload/index.js +119 -65
- package/src/modules/Lightbox/index.js +40 -43
- package/src/modules/Links/index.js +8 -7
- package/src/modules/Marquee/index.js +47 -37
- package/src/modules/MobileMenu/index.js +112 -65
- package/src/modules/Moonwalk/index.js +256 -203
- package/src/modules/Parallax/index.js +24 -14
- package/src/modules/Popup/index.js +24 -21
- package/src/modules/ScrollSpy/index.js +5 -5
- package/src/modules/StackedBoxes/index.js +5 -5
- package/src/modules/StickyHeader/index.js +73 -70
- package/src/modules/Toggler/index.js +2 -2
- package/src/modules/Typography/index.js +13 -10
- package/src/utils/dispatchElementEvent.js +2 -2
- package/src/utils/imageIsLoaded.js +1 -1
- package/src/utils/imagesAreLoaded.js +3 -3
- package/src/utils/loadScript.js +9 -8
- package/src/utils/rafCallback.js +12 -10
- package/src/utils/zoom.js +11 -8
|
@@ -3,12 +3,7 @@ import * as Events from '../../events'
|
|
|
3
3
|
|
|
4
4
|
const DEFAULT_OPTIONS = {
|
|
5
5
|
runListenerOnInit: false,
|
|
6
|
-
breakpoints: [
|
|
7
|
-
'xs',
|
|
8
|
-
'sm',
|
|
9
|
-
'md',
|
|
10
|
-
'lg'
|
|
11
|
-
],
|
|
6
|
+
breakpoints: ['xs', 'sm', 'md', 'lg'],
|
|
12
7
|
|
|
13
8
|
listeners: {
|
|
14
9
|
// xs: (mq) => {
|
|
@@ -22,15 +17,17 @@ const DEFAULT_OPTIONS = {
|
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
export default class Breakpoints {
|
|
25
|
-
constructor
|
|
20
|
+
constructor(app, opts = {}) {
|
|
26
21
|
this.app = app
|
|
27
22
|
this.mediaQueries = {}
|
|
28
23
|
this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
|
|
29
24
|
window.addEventListener(Events.APPLICATION_PRELUDIUM, this.initialize.bind(this))
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
initialize
|
|
33
|
-
this.opts.breakpoints.forEach(size => {
|
|
27
|
+
initialize() {
|
|
28
|
+
this.opts.breakpoints.forEach(size => {
|
|
29
|
+
this.mediaQueries[size] = this._getVal(`--breakpoint-${size}`)
|
|
30
|
+
})
|
|
34
31
|
|
|
35
32
|
const keys = Object.keys(this.mediaQueries)
|
|
36
33
|
keys.forEach(key => {
|
|
@@ -42,7 +39,9 @@ export default class Breakpoints {
|
|
|
42
39
|
// max size
|
|
43
40
|
query = `(min-width: ${this.mediaQueries[key]})`
|
|
44
41
|
} else {
|
|
45
|
-
query = `(min-width: ${this.mediaQueries[key]}) and (max-width: ${
|
|
42
|
+
query = `(min-width: ${this.mediaQueries[key]}) and (max-width: ${
|
|
43
|
+
parseInt(this.mediaQueries[next]) - 1
|
|
44
|
+
}px)`
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
this.mediaQueries[key] = window.matchMedia(query)
|
|
@@ -63,15 +62,13 @@ export default class Breakpoints {
|
|
|
63
62
|
this.setCurrentBreakpoint()
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
getCurrentBreakpoint
|
|
67
|
-
const key = Object
|
|
68
|
-
.keys(this.mediaQueries)
|
|
69
|
-
.find(q => this.mediaQueries[q].matches)
|
|
65
|
+
getCurrentBreakpoint() {
|
|
66
|
+
const key = Object.keys(this.mediaQueries).find(q => this.mediaQueries[q].matches)
|
|
70
67
|
|
|
71
68
|
return { key, mq: this.mediaQueries[key] }
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
defaultListener
|
|
71
|
+
defaultListener(e) {
|
|
75
72
|
if (e.matches) {
|
|
76
73
|
this.setCurrentBreakpoint()
|
|
77
74
|
}
|
|
@@ -79,12 +76,12 @@ export default class Breakpoints {
|
|
|
79
76
|
window.dispatchEvent(evt)
|
|
80
77
|
}
|
|
81
78
|
|
|
82
|
-
setCurrentBreakpoint
|
|
79
|
+
setCurrentBreakpoint() {
|
|
83
80
|
const { key } = this.getCurrentBreakpoint()
|
|
84
81
|
this.app.breakpoint = key
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
_getVal
|
|
84
|
+
_getVal(key) {
|
|
88
85
|
return getComputedStyle(document.documentElement).getPropertyValue(key).trim()
|
|
89
86
|
}
|
|
90
87
|
}
|
|
@@ -24,38 +24,52 @@ const DEFAULT_OPTIONS = {
|
|
|
24
24
|
const timeline = gsap.timeline()
|
|
25
25
|
|
|
26
26
|
timeline
|
|
27
|
-
.fromTo(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
.fromTo(
|
|
28
|
+
c.cc,
|
|
29
|
+
{
|
|
30
|
+
duration: 0.5,
|
|
31
|
+
y: '120%',
|
|
32
|
+
display: 'block'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
duration: 0.5,
|
|
36
|
+
y: '0%',
|
|
37
|
+
delay: '0.5',
|
|
38
|
+
ease: 'power3.out'
|
|
39
|
+
},
|
|
40
|
+
'0.5'
|
|
41
|
+
)
|
|
42
|
+
.fromTo(
|
|
43
|
+
c.text,
|
|
44
|
+
{
|
|
45
|
+
duration: 0.7,
|
|
46
|
+
opacity: 0
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
duration: 0.7,
|
|
50
|
+
opacity: 1,
|
|
51
|
+
ease: 'power3.out'
|
|
52
|
+
},
|
|
53
|
+
'-=0.35'
|
|
54
|
+
)
|
|
55
|
+
.fromTo(
|
|
56
|
+
c.btns,
|
|
57
|
+
{
|
|
58
|
+
duration: 0.7,
|
|
59
|
+
opacity: 0
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
duration: 0.7,
|
|
63
|
+
opacity: 1,
|
|
64
|
+
ease: 'power3.out'
|
|
65
|
+
},
|
|
66
|
+
'-=0.35'
|
|
67
|
+
)
|
|
54
68
|
}
|
|
55
69
|
}
|
|
56
70
|
|
|
57
71
|
export default class Cookies {
|
|
58
|
-
constructor
|
|
72
|
+
constructor(app, opts = {}) {
|
|
59
73
|
this.app = app
|
|
60
74
|
this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
|
|
61
75
|
|
|
@@ -69,27 +83,44 @@ export default class Cookies {
|
|
|
69
83
|
return
|
|
70
84
|
}
|
|
71
85
|
|
|
72
|
-
|
|
86
|
+
this.app.registerCallback(Events.APPLICATION_REVEALED, () => {
|
|
87
|
+
this.opts.showCC(this)
|
|
88
|
+
})
|
|
73
89
|
|
|
74
90
|
this.btn.addEventListener('click', () => {
|
|
75
91
|
this.opts.onAccept(this)
|
|
76
92
|
})
|
|
77
93
|
}
|
|
78
94
|
|
|
79
|
-
getCookie
|
|
95
|
+
getCookie(sKey) {
|
|
80
96
|
if (!sKey) {
|
|
81
97
|
return null
|
|
82
98
|
}
|
|
83
|
-
return
|
|
99
|
+
return (
|
|
100
|
+
decodeURIComponent(
|
|
101
|
+
document.cookie.replace(
|
|
102
|
+
new RegExp(
|
|
103
|
+
`(?:(?:^|.*;)\\s*${encodeURIComponent(sKey).replace(
|
|
104
|
+
/[-.+*]/g,
|
|
105
|
+
'\\$&'
|
|
106
|
+
)}\\s*\\=\\s*([^;]*).*$)|^.*$`
|
|
107
|
+
),
|
|
108
|
+
'$1'
|
|
109
|
+
)
|
|
110
|
+
) || null
|
|
111
|
+
)
|
|
84
112
|
}
|
|
85
113
|
|
|
86
|
-
setCookie
|
|
87
|
-
if (!sKey || /^(?:expires|max-age|path|domain|secure)$/i.test(sKey)) {
|
|
114
|
+
setCookie(sKey, sValue, vEnd, sPath, sDomain, bSecure) {
|
|
115
|
+
if (!sKey || /^(?:expires|max-age|path|domain|secure)$/i.test(sKey)) {
|
|
116
|
+
return false
|
|
117
|
+
}
|
|
88
118
|
let sExpires = ''
|
|
89
119
|
if (vEnd) {
|
|
90
120
|
switch (vEnd.constructor) {
|
|
91
121
|
case Number:
|
|
92
|
-
sExpires =
|
|
122
|
+
sExpires =
|
|
123
|
+
vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : `; max-age=${vEnd}`
|
|
93
124
|
break
|
|
94
125
|
case String:
|
|
95
126
|
sExpires = `; expires=${vEnd}`
|
|
@@ -101,23 +132,35 @@ export default class Cookies {
|
|
|
101
132
|
break
|
|
102
133
|
}
|
|
103
134
|
}
|
|
104
|
-
document.cookie = `${encodeURIComponent(sKey)}=${encodeURIComponent(sValue)}${sExpires}${
|
|
135
|
+
document.cookie = `${encodeURIComponent(sKey)}=${encodeURIComponent(sValue)}${sExpires}${
|
|
136
|
+
sDomain ? `; domain=${sDomain}` : ''
|
|
137
|
+
}${sPath ? `; path=${sPath}` : ''}${bSecure ? '; secure' : ''}`
|
|
105
138
|
return true
|
|
106
139
|
}
|
|
107
140
|
|
|
108
|
-
removeCookie
|
|
109
|
-
if (!this.hasCookie(sKey)) {
|
|
110
|
-
|
|
141
|
+
removeCookie(sKey, sPath, sDomain) {
|
|
142
|
+
if (!this.hasCookie(sKey)) {
|
|
143
|
+
return false
|
|
144
|
+
}
|
|
145
|
+
document.cookie = `${encodeURIComponent(sKey)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT${
|
|
146
|
+
sDomain ? `; domain=${sDomain}` : ''
|
|
147
|
+
}${sPath ? `; path=${sPath}` : ''}`
|
|
111
148
|
return true
|
|
112
149
|
}
|
|
113
150
|
|
|
114
|
-
hasCookie
|
|
115
|
-
if (!sKey || /^(?:expires|max-age|path|domain|secure)$/i.test(sKey)) {
|
|
116
|
-
|
|
151
|
+
hasCookie(sKey) {
|
|
152
|
+
if (!sKey || /^(?:expires|max-age|path|domain|secure)$/i.test(sKey)) {
|
|
153
|
+
return false
|
|
154
|
+
}
|
|
155
|
+
return new RegExp(
|
|
156
|
+
`(?:^|;\\s*)${encodeURIComponent(sKey).replace(/[-.+*]/g, '\\$&')}\\s*\\=`
|
|
157
|
+
).test(document.cookie)
|
|
117
158
|
}
|
|
118
159
|
|
|
119
|
-
keys
|
|
120
|
-
const aKeys = document.cookie
|
|
160
|
+
keys() {
|
|
161
|
+
const aKeys = document.cookie
|
|
162
|
+
.replace(/((?:^|\s*;)[^=]+)(?=;|$)|^\s*|\s*(?:=[^;]*)?(?:\1|$)/g, '')
|
|
163
|
+
.split(/\s*(?:=[^;]*)?;\s*/)
|
|
121
164
|
for (let nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx += 1) {
|
|
122
165
|
aKeys[nIdx] = decodeURIComponent(aKeys[nIdx])
|
|
123
166
|
}
|
|
@@ -4,13 +4,13 @@ import _defaultsDeep from 'lodash.defaultsdeep'
|
|
|
4
4
|
const DEFAULT_OPTIONS = {}
|
|
5
5
|
|
|
6
6
|
export default class CoverOverlay {
|
|
7
|
-
constructor
|
|
7
|
+
constructor(app, opts = {}) {
|
|
8
8
|
this.app = app
|
|
9
9
|
this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
|
|
10
10
|
this.initialize()
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
initialize
|
|
13
|
+
initialize() {
|
|
14
14
|
const coveredModules = document.querySelectorAll('[data-cover-overlay]')
|
|
15
15
|
|
|
16
16
|
Array.from(coveredModules).forEach(v => {
|
|
@@ -20,7 +20,10 @@ export default class CoverOverlay {
|
|
|
20
20
|
const iframe = v.querySelector('iframe')
|
|
21
21
|
|
|
22
22
|
if (iframe) {
|
|
23
|
-
iframe.setAttribute(
|
|
23
|
+
iframe.setAttribute(
|
|
24
|
+
'allow',
|
|
25
|
+
'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'
|
|
26
|
+
)
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
if (v.hasAttribute('data-cover-overlay-vimeo-play')) {
|
|
@@ -1,8 +1,174 @@
|
|
|
1
|
+
import Dom from '../Dom'
|
|
2
|
+
import _defaultsDeep from 'lodash.defaultsdeep'
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
5
|
+
* Load data by ajax
|
|
6
|
+
*
|
|
7
|
+
* Example DOM:
|
|
8
|
+
*
|
|
9
|
+
* <div class="filter">
|
|
10
|
+
* <input type="text" data-loader-filter-for="news" placeholder="Search">
|
|
11
|
+
* </div>
|
|
12
|
+
*
|
|
13
|
+
* <div data-loader="/api/posts" data-loader-id="news">
|
|
14
|
+
* <ul>
|
|
15
|
+
* <li>
|
|
16
|
+
* <a class="noanim" href="{{ category.url }}" data-loader-param="all" data-loader-param-selected>All</a>
|
|
17
|
+
* </li>
|
|
18
|
+
* </ul>
|
|
19
|
+
* <div class="posts-grid" data-moonwalk-section data-loader-canvas>
|
|
20
|
+
* <!-- render posts here -->
|
|
21
|
+
* </div>
|
|
22
|
+
* <div class="load-more" data-moonwalk-section>
|
|
23
|
+
* <button type="button" data-loader-more data-moonwalk="u">
|
|
24
|
+
* Load more posts <span class="arrow-d">↓</span>
|
|
25
|
+
* </button>
|
|
26
|
+
* </div>
|
|
27
|
+
* </div>
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const DEFAULT_OPTIONS = {
|
|
32
|
+
page: 0,
|
|
33
|
+
loaderParam: 'all',
|
|
34
|
+
filter: '',
|
|
35
|
+
onFetch: dataloader => {
|
|
36
|
+
/**
|
|
37
|
+
* Called after fetch complete. Do your DOM manipulation here
|
|
38
|
+
*
|
|
39
|
+
* Example:
|
|
40
|
+
*
|
|
41
|
+
* const mw = new Moonwalk(dataloader.app, configureMoonwalk(dataloader.app), dataloader.$el)
|
|
42
|
+
* new Lazyload(dataloader.app, { useNativeLazyloadIfAvailable: false }, dataloader.$el)
|
|
43
|
+
* new EqualHeightImages(dataloader.app, {}, dataloader.$el)
|
|
44
|
+
* mw.ready()
|
|
45
|
+
*/
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default class Dataloader {
|
|
50
|
+
constructor(app, $el, opts = {}) {
|
|
51
|
+
this.status = 'available'
|
|
52
|
+
this.app = app
|
|
53
|
+
this.$el = $el
|
|
54
|
+
this.$canvasEl = Dom.find($el, '[data-loader-canvas]')
|
|
55
|
+
this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
|
|
56
|
+
this.initialize()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
debounce(func, delay = 650) {
|
|
60
|
+
let timerId
|
|
61
|
+
return (...args) => {
|
|
62
|
+
clearTimeout(timerId)
|
|
63
|
+
timerId = setTimeout(() => {
|
|
64
|
+
func.apply(this, args)
|
|
65
|
+
}, delay)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
initialize() {
|
|
70
|
+
this.baseURL = this.$el.dataset.loader
|
|
71
|
+
this.$paramEls = Dom.all(this.$el, '[data-loader-param]')
|
|
72
|
+
|
|
73
|
+
this.$paramEls.forEach($paramEl => {
|
|
74
|
+
$paramEl.addEventListener('click', this.onParam.bind(this))
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
this.$moreBtn = Dom.find(this.$el, '[data-loader-more]')
|
|
78
|
+
|
|
79
|
+
if (this.$moreBtn) {
|
|
80
|
+
this.$moreBtn.addEventListener('click', this.onMore.bind(this))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.$filterInput = Dom.find(this.$el, '[data-loader-filter]')
|
|
84
|
+
|
|
85
|
+
if (!this.$filterInput && this.$el.dataset.loaderId) {
|
|
86
|
+
this.id = this.$el.dataset.loaderId
|
|
87
|
+
this.$filterInput = Dom.find(`[data-loader-filter-for="${this.id}"]`)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (this.$filterInput) {
|
|
91
|
+
this.$filterInput.addEventListener('input', this.debounce(this.onFilterInput.bind(this)))
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
onFilterInput(e) {
|
|
96
|
+
e.preventDefault()
|
|
97
|
+
this.loading()
|
|
98
|
+
this.opts.page = 0
|
|
99
|
+
this.opts.filter = this.$filterInput.value
|
|
100
|
+
this.fetch(false)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
onMore(e) {
|
|
104
|
+
e.preventDefault()
|
|
105
|
+
this.loading()
|
|
106
|
+
this.opts.page += 1
|
|
107
|
+
this.fetch(true)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
onParam(e) {
|
|
111
|
+
e.preventDefault()
|
|
112
|
+
this.loading()
|
|
113
|
+
// reset page when switching param!
|
|
114
|
+
this.opts.page = 0
|
|
115
|
+
this.$paramEls.forEach($paramEl => $paramEl.removeAttribute('data-loader-param-selected'))
|
|
116
|
+
e.currentTarget.setAttribute('data-loader-param-selected', '')
|
|
117
|
+
this.opts.loaderParam = e.currentTarget.dataset.loaderParam
|
|
118
|
+
this.fetch()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
fetch(addEntries = false) {
|
|
122
|
+
const param = this.opts.loaderParam
|
|
123
|
+
const filter = this.opts.filter
|
|
124
|
+
|
|
125
|
+
fetch(`${this.baseURL}/${param}/${this.opts.page}?` + new URLSearchParams({ filter }))
|
|
126
|
+
.then(res => {
|
|
127
|
+
this.status = res.headers.get('jpt-dataloader') || 'available'
|
|
128
|
+
this.updateButton()
|
|
129
|
+
return res.text()
|
|
130
|
+
})
|
|
131
|
+
.then(html => {
|
|
132
|
+
if (addEntries) {
|
|
133
|
+
this.$canvasEl.innerHTML += html
|
|
134
|
+
} else {
|
|
135
|
+
this.$canvasEl.innerHTML = html
|
|
136
|
+
}
|
|
137
|
+
this.opts.onFetch(this)
|
|
138
|
+
this.complete()
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Set [data-loader-loading] on main el
|
|
144
|
+
*/
|
|
145
|
+
loading() {
|
|
146
|
+
document.documentElement.setAttribute('data-loading', '')
|
|
147
|
+
this.$el.setAttribute('data-loader-loading', '')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Remove [data-loader-loading] on main el
|
|
152
|
+
*/
|
|
153
|
+
complete() {
|
|
154
|
+
this.$el.removeAttribute('data-loader-loading')
|
|
155
|
+
document.documentElement.removeAttribute('data-loading')
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Update the MORE button
|
|
160
|
+
*
|
|
161
|
+
* Sets [data-loader-starved] attribute if there is no more to fetch
|
|
162
|
+
*/
|
|
163
|
+
updateButton() {
|
|
164
|
+
if (!this.$moreBtn) {
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (this.status === 'starved') {
|
|
169
|
+
this.$moreBtn.setAttribute('data-loader-starved', '')
|
|
170
|
+
} else {
|
|
171
|
+
this.$moreBtn.removeAttribute('data-loader-starved')
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
package/src/modules/Dom/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
class DOM {
|
|
2
|
-
constructor
|
|
2
|
+
constructor() {
|
|
3
3
|
this.body = document.body
|
|
4
4
|
this.html = document.documentElement
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
new
|
|
7
|
+
new(arg) {
|
|
8
8
|
const doc = new DOMParser().parseFromString(arg.trim(), 'text/html')
|
|
9
9
|
return Array.from(doc.body.childNodes)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
find
|
|
12
|
+
find(arg1, arg2) {
|
|
13
13
|
if (typeof arg1 === 'string' && typeof arg2 === 'object') {
|
|
14
14
|
throw new Error('Dom.find: Wrong syntax, use -> Dom.find(node, selector)')
|
|
15
15
|
}
|
|
@@ -25,7 +25,7 @@ class DOM {
|
|
|
25
25
|
return null
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
all
|
|
28
|
+
all(arg1, arg2) {
|
|
29
29
|
if (typeof arg1 === 'string') {
|
|
30
30
|
return Array.from(document.querySelectorAll(arg1))
|
|
31
31
|
}
|
|
@@ -37,47 +37,47 @@ class DOM {
|
|
|
37
37
|
return []
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
create
|
|
40
|
+
create(element, ...classes) {
|
|
41
41
|
const el = document.createElement(element)
|
|
42
42
|
this.addClass(el, ...classes)
|
|
43
43
|
return el
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
append
|
|
46
|
+
append(element) {
|
|
47
47
|
document.body.appendChild(element)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
remove
|
|
50
|
+
remove(element) {
|
|
51
51
|
element.remove()
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
addClass
|
|
54
|
+
addClass(element, ...classes) {
|
|
55
55
|
classes.forEach(className => {
|
|
56
56
|
element.classList.add(className)
|
|
57
57
|
})
|
|
58
58
|
return element
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
removeClass
|
|
61
|
+
removeClass(element, ...classes) {
|
|
62
62
|
classes.forEach(className => {
|
|
63
63
|
element.classList.remove(className)
|
|
64
64
|
})
|
|
65
65
|
return element
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
hasClass
|
|
68
|
+
hasClass(element, className) {
|
|
69
69
|
return element.classList.contains(className)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
toggleClass
|
|
72
|
+
toggleClass(element, ...classes) {
|
|
73
73
|
return classes.map(className => element.classList.toggle(className))
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
hasAttribute
|
|
76
|
+
hasAttribute(element, attributeName) {
|
|
77
77
|
return element.hasAttribute(attributeName)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
overlapsVertically
|
|
80
|
+
overlapsVertically($div1, $div2) {
|
|
81
81
|
// Div 1 data
|
|
82
82
|
const d1Offset = $div1.getBoundingClientRect()
|
|
83
83
|
const d1Height = this.outerHeight($div1)
|
|
@@ -99,7 +99,7 @@ class DOM {
|
|
|
99
99
|
return 0
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
outerHeight
|
|
102
|
+
outerHeight(el) {
|
|
103
103
|
let height = el.offsetHeight
|
|
104
104
|
const style = getComputedStyle(el)
|
|
105
105
|
|
|
@@ -107,7 +107,7 @@ class DOM {
|
|
|
107
107
|
return height
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
outerWidth
|
|
110
|
+
outerWidth(el) {
|
|
111
111
|
let width = el.offsetWidth
|
|
112
112
|
const style = getComputedStyle(el)
|
|
113
113
|
|
|
@@ -115,23 +115,23 @@ class DOM {
|
|
|
115
115
|
return width
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
getCSSVar
|
|
118
|
+
getCSSVar(key) {
|
|
119
119
|
return getComputedStyle(document.documentElement).getPropertyValue(key).trim()
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
setCSSVar
|
|
122
|
+
setCSSVar(key, val) {
|
|
123
123
|
document.documentElement.style.setProperty(`--${key}`, val)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
offset
|
|
127
|
-
const rect = el.getBoundingClientRect()
|
|
126
|
+
offset(el) {
|
|
127
|
+
const rect = el.getBoundingClientRect()
|
|
128
128
|
return {
|
|
129
129
|
top: rect.top + window.pageYOffset,
|
|
130
130
|
left: rect.left + window.pageXOffset
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
position
|
|
134
|
+
position(el) {
|
|
135
135
|
return {
|
|
136
136
|
top: el.offsetTop,
|
|
137
137
|
left: el.offsetLeft
|
|
@@ -143,15 +143,15 @@ class DOM {
|
|
|
143
143
|
*
|
|
144
144
|
* @param {*} el
|
|
145
145
|
*/
|
|
146
|
-
inViewport
|
|
146
|
+
inViewport(el) {
|
|
147
147
|
const rect = el.getBoundingClientRect()
|
|
148
|
-
const windowHeight =
|
|
149
|
-
const windowWidth =
|
|
148
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight
|
|
149
|
+
const windowWidth = window.innerWidth || document.documentElement.clientWidth
|
|
150
150
|
|
|
151
|
-
const vertInView =
|
|
152
|
-
const horInView =
|
|
151
|
+
const vertInView = rect.top <= windowHeight && rect.top + rect.height >= 0
|
|
152
|
+
const horInView = rect.left <= windowWidth && rect.left + rect.width >= 0
|
|
153
153
|
|
|
154
|
-
return
|
|
154
|
+
return vertInView && horInView
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
@@ -29,7 +29,7 @@ const DEFAULT_OPTIONS = {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export default class Dropdown {
|
|
32
|
-
constructor
|
|
32
|
+
constructor(app, opts = {}) {
|
|
33
33
|
this.app = app
|
|
34
34
|
this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
|
|
35
35
|
this.elements = {}
|
|
@@ -42,24 +42,24 @@ export default class Dropdown {
|
|
|
42
42
|
this.initialize()
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
initialize
|
|
45
|
+
initialize() {
|
|
46
46
|
this.timeline.from(
|
|
47
|
-
this.elements.menu,
|
|
47
|
+
this.elements.menu,
|
|
48
|
+
{
|
|
48
49
|
duration: 0.3,
|
|
49
50
|
className: `${this.elements.menu.className} zero-height`
|
|
50
|
-
},
|
|
51
|
+
},
|
|
52
|
+
'open'
|
|
51
53
|
)
|
|
52
54
|
this.timeline.to(
|
|
53
|
-
this.elements.menu,
|
|
55
|
+
this.elements.menu,
|
|
56
|
+
{
|
|
54
57
|
height: 'auto'
|
|
55
|
-
},
|
|
58
|
+
},
|
|
59
|
+
'open'
|
|
56
60
|
)
|
|
57
61
|
|
|
58
|
-
this.timeline.from(
|
|
59
|
-
this.elements.menuItems,
|
|
60
|
-
this.opts.tweens.items,
|
|
61
|
-
'open+=.1'
|
|
62
|
-
)
|
|
62
|
+
this.timeline.from(this.elements.menuItems, this.opts.tweens.items, 'open+=.1')
|
|
63
63
|
|
|
64
64
|
if (!this.elements.trigger) {
|
|
65
65
|
return
|
|
@@ -67,7 +67,7 @@ export default class Dropdown {
|
|
|
67
67
|
this.elements.trigger.addEventListener('click', this.onClick.bind(this))
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
onClick
|
|
70
|
+
onClick(event) {
|
|
71
71
|
event.preventDefault()
|
|
72
72
|
event.stopPropagation()
|
|
73
73
|
|
|
@@ -80,7 +80,7 @@ export default class Dropdown {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
openMenu
|
|
83
|
+
openMenu() {
|
|
84
84
|
if (!this.opts.multipleActive) {
|
|
85
85
|
if (this.app.currentMenu) {
|
|
86
86
|
this.app.currentMenu.closeMenu()
|
|
@@ -96,7 +96,7 @@ export default class Dropdown {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
closeMenu
|
|
99
|
+
closeMenu() {
|
|
100
100
|
this.app.currentMenu = null
|
|
101
101
|
this.open = false
|
|
102
102
|
|