@brandocms/jupiter 3.50.0 → 3.50.1
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
CHANGED
|
@@ -8,6 +8,7 @@ const DEFAULT_OPTIONS = {
|
|
|
8
8
|
triggerEvents: true,
|
|
9
9
|
scrollDuration: 0.8,
|
|
10
10
|
mobileMenuDelay: 800,
|
|
11
|
+
openExternalInWindow: true,
|
|
11
12
|
linkQuery: 'a:not([href^="#"]):not([target="_blank"]):not([data-lightbox]):not(.noanim)',
|
|
12
13
|
anchorQuery: 'a[href^="#"]:not(.noanim)',
|
|
13
14
|
|
|
@@ -139,9 +140,14 @@ export default class Links {
|
|
|
139
140
|
|
|
140
141
|
bindLinks(links) {
|
|
141
142
|
Array.from(links).forEach(link => {
|
|
143
|
+
const href = link.getAttribute('href')
|
|
144
|
+
const internalLink = href.indexOf(document.location.hostname) > -1 || href.startsWith('/')
|
|
145
|
+
if (this.opts.openExternalInWindow && !internalLink) {
|
|
146
|
+
link.setAttribute('target', '_blank')
|
|
147
|
+
}
|
|
148
|
+
|
|
142
149
|
link.addEventListener('click', e => {
|
|
143
150
|
const loadingContainer = document.querySelector('.loading-container')
|
|
144
|
-
const href = link.getAttribute('href')
|
|
145
151
|
|
|
146
152
|
if (e.shiftKey || e.metaKey || e.ctrlKey) {
|
|
147
153
|
return
|
|
@@ -151,7 +157,7 @@ export default class Links {
|
|
|
151
157
|
loadingContainer.style.display = 'none'
|
|
152
158
|
}
|
|
153
159
|
|
|
154
|
-
if (
|
|
160
|
+
if (internalLink) {
|
|
155
161
|
e.preventDefault()
|
|
156
162
|
this.opts.onTransition(href, this.app)
|
|
157
163
|
}
|