@unlk/keymaster 1.2.2 → 1.2.4
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/CHANGELOG.md +10 -0
- package/dist/css/keymaster.css +14 -0
- package/dist/css/keymaster.css.map +1 -1
- package/dist/css/keymaster.min.css +1 -1
- package/dist/css/keymaster.min.css.map +1 -1
- package/dist/js/keymaster.js +43 -16
- package/dist/js/keymaster.js.map +1 -1
- package/dist/js/keymaster.min.js +6 -6
- package/dist/js/keymaster.min.js.map +1 -1
- package/js/video-modal.js +41 -18
- package/package.json +1 -1
- package/scss/theme/_modal.scss +16 -0
package/dist/js/keymaster.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Unlock Keymaster [object Object] v1.2.
|
|
2
|
+
* Unlock Keymaster [object Object] v1.2.4 (https://unlock-com.github.io/keymaster)
|
|
3
3
|
* Copyright 2022-2025 Unlk Developers
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -7660,7 +7660,7 @@
|
|
|
7660
7660
|
defineJQueryPlugin(CarouselCaption);
|
|
7661
7661
|
|
|
7662
7662
|
const NAME = 'videoModal';
|
|
7663
|
-
const
|
|
7663
|
+
const EVENT_SHOWN = 'shown.bs.modal';
|
|
7664
7664
|
const EVENT_HIDDEN = 'hidden.bs.modal';
|
|
7665
7665
|
const SELECTOR_DIALOG = '.modal-dialog-media';
|
|
7666
7666
|
const SELECTOR_RATIO = '.ratio';
|
|
@@ -7700,36 +7700,58 @@
|
|
|
7700
7700
|
this._vimeoUrl = this._container.getAttribute('data-vimeo-url');
|
|
7701
7701
|
this._youtubePlayer = null;
|
|
7702
7702
|
this._vimeoPlayer = null;
|
|
7703
|
-
EventHandler.on(this._element,
|
|
7703
|
+
EventHandler.on(this._element, EVENT_SHOWN, () => this._onShown());
|
|
7704
7704
|
EventHandler.on(this._element, EVENT_HIDDEN, () => this._onHide());
|
|
7705
7705
|
}
|
|
7706
7706
|
dispose() {
|
|
7707
7707
|
this._onHide();
|
|
7708
7708
|
super.dispose();
|
|
7709
7709
|
}
|
|
7710
|
-
async
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
} = this._element;
|
|
7714
|
-
const playerClass = `${id}-youtube-player`;
|
|
7710
|
+
async _onShown() {
|
|
7711
|
+
// Reset container each time
|
|
7712
|
+
this._container.innerHTML = '';
|
|
7715
7713
|
if (this._vimeoUrl) {
|
|
7716
7714
|
await vimeoAPIInitPromise;
|
|
7717
7715
|
const vimeoId = this._getVimeoId(this._vimeoUrl);
|
|
7716
|
+
if (!vimeoId) return;
|
|
7718
7717
|
this._vimeoPlayer = new window.Vimeo.Player(this._container, {
|
|
7719
7718
|
id: vimeoId,
|
|
7720
|
-
autoplay: true
|
|
7719
|
+
autoplay: true,
|
|
7720
|
+
muted: true,
|
|
7721
|
+
playsinline: true,
|
|
7722
|
+
dnt: true
|
|
7721
7723
|
});
|
|
7724
|
+
this._vimeoPlayer.play?.().catch(() => {});
|
|
7722
7725
|
}
|
|
7723
7726
|
if (this._youtubeSrc) {
|
|
7724
7727
|
await youTubeAPIInitPromise;
|
|
7725
7728
|
const youtubeId = this._getYouTubeId(this._youtubeSrc);
|
|
7726
|
-
|
|
7727
|
-
|
|
7729
|
+
if (!youtubeId) {
|
|
7730
|
+
console.warn('[VideoModal] No YouTube ID parsed from', this._youtubeSrc);
|
|
7731
|
+
return;
|
|
7732
|
+
}
|
|
7733
|
+
const playerDiv = document.createElement('div');
|
|
7734
|
+
playerDiv.className = 'w-100 h-100';
|
|
7735
|
+
this._container.appendChild(playerDiv);
|
|
7728
7736
|
this._youtubePlayer = new window.YT.Player(playerDiv, {
|
|
7729
7737
|
videoId: youtubeId,
|
|
7738
|
+
host: 'https://www.youtube-nocookie.com',
|
|
7730
7739
|
playerVars: {
|
|
7731
7740
|
autoplay: 1,
|
|
7732
|
-
rel: 0
|
|
7741
|
+
rel: 0,
|
|
7742
|
+
playsinline: 1,
|
|
7743
|
+
origin: window.location.origin
|
|
7744
|
+
},
|
|
7745
|
+
events: {
|
|
7746
|
+
onReady: e => {
|
|
7747
|
+
try {
|
|
7748
|
+
e.target.mute();
|
|
7749
|
+
} catch {}
|
|
7750
|
+
try {
|
|
7751
|
+
e.target.playVideo();
|
|
7752
|
+
} catch {}
|
|
7753
|
+
},
|
|
7754
|
+
onError: e => console.warn('[VideoModal] YT error', e?.data)
|
|
7733
7755
|
}
|
|
7734
7756
|
});
|
|
7735
7757
|
}
|
|
@@ -7740,16 +7762,21 @@
|
|
|
7740
7762
|
this._vimeoPlayer = null;
|
|
7741
7763
|
}
|
|
7742
7764
|
if (this._youtubePlayer) {
|
|
7743
|
-
|
|
7765
|
+
try {
|
|
7766
|
+
this._youtubePlayer.destroy();
|
|
7767
|
+
} catch {}
|
|
7744
7768
|
this._youtubePlayer = null;
|
|
7745
7769
|
}
|
|
7770
|
+
this._container.innerHTML = '';
|
|
7746
7771
|
}
|
|
7747
7772
|
_getYouTubeId(url) {
|
|
7748
|
-
|
|
7749
|
-
|
|
7773
|
+
if (!url) return '';
|
|
7774
|
+
// robust: supports v=, youtu.be/, embed/, shorts/
|
|
7775
|
+
const m = String(url).match(/(?:v=|youtu\.be\/|embed\/|shorts\/)([\w-]{11})/);
|
|
7776
|
+
return m ? m[1] : '';
|
|
7750
7777
|
}
|
|
7751
7778
|
_getVimeoId(url) {
|
|
7752
|
-
const match = url.match(/vimeo\.com\/(\d+)/);
|
|
7779
|
+
const match = String(url).match(/vimeo\.com\/(\d+)/);
|
|
7753
7780
|
return match ? match[1] : '';
|
|
7754
7781
|
}
|
|
7755
7782
|
static get NAME() {
|