issues/27: cabinet owl.carousel Stimulus fix

This commit is contained in:
Valery Petrov
2026-05-30 02:15:14 +03:00
committed by Valeriy Petrov
parent 0460846dac
commit 2ed344e503
4 changed files with 3390 additions and 31 deletions
+1 -1
View File
@@ -25,6 +25,6 @@ yarn-error.log
###< symfony/webpack-encore-bundle ### ###< symfony/webpack-encore-bundle ###
/*.md /*.md
/*.lock /*.lock
!/yarn.lock
/symfony.lock /symfony.lock
/yarn.lock
/service.sh /service.sh
+10 -8
View File
@@ -1,16 +1,13 @@
import { Controller } from 'stimulus'; import { Controller } from 'stimulus';
import 'owl.carousel2/dist/assets/owl.carousel.css'; import 'owl.carousel2/dist/assets/owl.carousel.css';
import 'owl.carousel2/dist/assets/owl.theme.default.css'; import 'owl.carousel2/dist/assets/owl.theme.default.css';
import 'owl.carousel2';
/* /*
* This is an example Stimulus controller! * owl.carousel2 is a legacy jQuery plugin that reads `window.jQuery` at module
* * evaluation time. When statically imported it lands in the eager shared chunk,
* Any element with a data-controller="hello" attribute will cause * and depending on webpack chunk ordering it can evaluate before jQuery is ready,
* this controller to be executed. The name "hello" comes from the filename: * throwing and breaking the whole Stimulus bootstrap. Load it lazily inside
* hello_controller.js -> "hello" * connect() so it can never break unrelated controllers (e.g. registration).
*
* Delete this file or adapt it for your use!
*/ */
export default class extends Controller { export default class extends Controller {
static targets = ["showid"]; static targets = ["showid"];
@@ -18,6 +15,7 @@ export default class extends Controller {
connect() { connect() {
var slideshow = this.element; var slideshow = this.element;
import('owl.carousel2').then(function() {
$(slideshow).owlCarousel({ $(slideshow).owlCarousel({
nav: true, nav: true,
margin: 15, margin: 15,
@@ -42,6 +40,10 @@ export default class extends Controller {
}); });
slideshow.classList.remove('hide'); slideshow.classList.remove('hide');
}).catch(function(e) {
console.warn('owl.carousel failed to load', e);
slideshow.classList.remove('hide');
});
slideshow.querySelectorAll('.show-msg').forEach(function (el) { slideshow.querySelectorAll('.show-msg').forEach(function (el) {
el.addEventListener('click', function (evn) { el.addEventListener('click', function (evn) {
+1
View File
@@ -21,6 +21,7 @@
}, },
"license": "UNLICENSED", "license": "UNLICENSED",
"private": true, "private": true,
"packageManager": "yarn@1.22.22",
"scripts": { "scripts": {
"dev-server": "encore dev-server", "dev-server": "encore dev-server",
"dev": "encore dev", "dev": "encore dev",
+3356
View File
File diff suppressed because it is too large Load Diff