2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-11-30 20:06:40 +00:00
|
|
|
<div
|
|
|
|
v-if="$attrs.value && $attrs.value.length > 0"
|
|
|
|
:id="id"
|
|
|
|
role="region"
|
|
|
|
:class="[cx('root'), $attrs.containerClass]"
|
|
|
|
:style="$attrs.containerStyle"
|
|
|
|
:aria-label="$attrs.ariaLabel"
|
|
|
|
:aria-roledescription="$attrs.ariaRoledescription"
|
|
|
|
v-bind="{ ...$attrs.containerProps, ...getPTOptions('root') }"
|
|
|
|
>
|
2023-07-20 08:57:56 +00:00
|
|
|
<button v-if="$attrs.fullScreen" v-ripple autofocus type="button" :class="cx('closeButton')" :aria-label="closeAriaLabel" @click="$emit('mask-hide')" v-bind="getPTOptions('closeButton')">
|
|
|
|
<component :is="$attrs.templates['closeicon'] || 'TimesIcon'" :class="cx('closeIcon')" v-bind="getPTOptions('closeIcon')" />
|
2022-09-06 12:03:37 +00:00
|
|
|
</button>
|
2023-07-20 08:57:56 +00:00
|
|
|
<div v-if="$attrs.templates && $attrs.templates['header']" :class="cx('header')" v-bind="getPTOptions('header')">
|
2022-09-06 12:03:37 +00:00
|
|
|
<component :is="$attrs.templates['header']" />
|
|
|
|
</div>
|
2023-07-20 08:57:56 +00:00
|
|
|
<div :class="cx('content')" :aria-live="$attrs.autoPlay ? 'polite' : 'off'" v-bind="getPTOptions('content')">
|
2022-09-14 11:26:01 +00:00
|
|
|
<GalleriaItem
|
2022-12-08 11:04:25 +00:00
|
|
|
:id="id"
|
2022-09-14 11:26:01 +00:00
|
|
|
v-model:activeIndex="activeIndex"
|
|
|
|
v-model:slideShowActive="slideShowActive"
|
|
|
|
:value="$attrs.value"
|
|
|
|
:circular="$attrs.circular"
|
|
|
|
:templates="$attrs.templates"
|
|
|
|
:showIndicators="$attrs.showIndicators"
|
|
|
|
:changeItemOnIndicatorHover="$attrs.changeItemOnIndicatorHover"
|
|
|
|
:showItemNavigators="$attrs.showItemNavigators"
|
|
|
|
:autoPlay="$attrs.autoPlay"
|
|
|
|
@start-slideshow="startSlideShow"
|
|
|
|
@stop-slideshow="stopSlideShow"
|
2023-05-04 08:29:52 +00:00
|
|
|
:pt="pt"
|
2023-05-31 22:28:41 +00:00
|
|
|
:unstyled="unstyled"
|
2022-09-14 11:26:01 +00:00
|
|
|
/>
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2022-09-14 11:26:01 +00:00
|
|
|
<GalleriaThumbnails
|
|
|
|
v-if="$attrs.showThumbnails"
|
|
|
|
v-model:activeIndex="activeIndex"
|
|
|
|
v-model:slideShowActive="slideShowActive"
|
|
|
|
:containerId="id"
|
|
|
|
:value="$attrs.value"
|
|
|
|
:templates="$attrs.templates"
|
|
|
|
:numVisible="numVisible"
|
|
|
|
:responsiveOptions="$attrs.responsiveOptions"
|
|
|
|
:circular="$attrs.circular"
|
|
|
|
:isVertical="isVertical()"
|
|
|
|
:contentHeight="$attrs.verticalThumbnailViewPortHeight"
|
|
|
|
:showThumbnailNavigators="$attrs.showThumbnailNavigators"
|
2022-12-08 11:04:25 +00:00
|
|
|
:prevButtonProps="$attrs.prevButtonProps"
|
|
|
|
:nextButtonProps="$attrs.nextButtonProps"
|
2022-09-14 11:26:01 +00:00
|
|
|
@stop-slideshow="stopSlideShow"
|
2023-05-04 08:29:52 +00:00
|
|
|
:pt="pt"
|
2023-05-31 22:28:41 +00:00
|
|
|
:unstyled="unstyled"
|
2022-09-14 11:26:01 +00:00
|
|
|
/>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
2023-07-20 08:57:56 +00:00
|
|
|
<div v-if="$attrs.templates && $attrs.templates['footer']" :class="cx('footer')" v-bind="getPTOptions('footer')">
|
2022-09-06 12:03:37 +00:00
|
|
|
<component :is="$attrs.templates['footer']" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-04 08:29:52 +00:00
|
|
|
import BaseComponent from 'primevue/basecomponent';
|
2023-04-18 12:53:43 +00:00
|
|
|
import TimesIcon from 'primevue/icons/times';
|
2022-12-08 11:04:25 +00:00
|
|
|
import Ripple from 'primevue/ripple';
|
2022-09-14 11:26:01 +00:00
|
|
|
import { UniqueComponentId } from 'primevue/utils';
|
2022-09-06 12:03:37 +00:00
|
|
|
import GalleriaItem from './GalleriaItem.vue';
|
|
|
|
import GalleriaThumbnails from './GalleriaThumbnails.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'GalleriaContent',
|
2023-07-19 12:46:57 +00:00
|
|
|
hostName: 'Galleria',
|
2023-05-04 08:29:52 +00:00
|
|
|
extends: BaseComponent,
|
2022-09-06 12:03:37 +00:00
|
|
|
inheritAttrs: false,
|
|
|
|
interval: null,
|
|
|
|
emits: ['activeitem-change', 'mask-hide'],
|
|
|
|
data() {
|
|
|
|
return {
|
2024-03-27 02:37:32 +00:00
|
|
|
id: this.$attrs.id,
|
2022-09-06 12:03:37 +00:00
|
|
|
activeIndex: this.$attrs.activeIndex,
|
|
|
|
numVisible: this.$attrs.numVisible,
|
|
|
|
slideShowActive: false
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2024-03-27 02:37:32 +00:00
|
|
|
'$attrs.id': {
|
|
|
|
immediate: true,
|
|
|
|
handler: function (newValue) {
|
|
|
|
this.id = newValue || UniqueComponentId();
|
|
|
|
},
|
2024-02-02 15:47:25 +00:00
|
|
|
},
|
2022-09-14 11:26:01 +00:00
|
|
|
'$attrs.value': function (newVal) {
|
2022-09-06 12:03:37 +00:00
|
|
|
if (newVal && newVal.length < this.numVisible) {
|
|
|
|
this.numVisible = newVal.length;
|
|
|
|
}
|
|
|
|
},
|
2022-09-14 11:26:01 +00:00
|
|
|
'$attrs.activeIndex': function (newVal) {
|
2022-09-06 12:03:37 +00:00
|
|
|
this.activeIndex = newVal;
|
|
|
|
},
|
2022-09-14 11:26:01 +00:00
|
|
|
'$attrs.numVisible': function (newVal) {
|
2022-09-06 12:03:37 +00:00
|
|
|
this.numVisible = newVal;
|
2023-03-28 14:00:11 +00:00
|
|
|
},
|
|
|
|
'$attrs.autoPlay': function (newVal) {
|
|
|
|
newVal ? this.startSlideShow() : this.stopSlideShow();
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
updated() {
|
|
|
|
this.$emit('activeitem-change', this.activeIndex);
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
2022-09-14 11:26:01 +00:00
|
|
|
if (this.slideShowActive) {
|
|
|
|
this.stopSlideShow();
|
|
|
|
}
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
methods: {
|
2023-07-20 08:57:56 +00:00
|
|
|
getPTOptions(key) {
|
|
|
|
return this.ptm(key, {
|
|
|
|
props: {
|
|
|
|
...this.$attrs,
|
|
|
|
pt: this.pt,
|
|
|
|
unstyled: this.unstyled
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
isAutoPlayActive() {
|
|
|
|
return this.slideShowActive;
|
|
|
|
},
|
|
|
|
startSlideShow() {
|
|
|
|
this.interval = setInterval(() => {
|
2022-09-14 11:26:01 +00:00
|
|
|
let activeIndex = this.$attrs.circular && this.$attrs.value.length - 1 === this.activeIndex ? 0 : this.activeIndex + 1;
|
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
this.activeIndex = activeIndex;
|
|
|
|
}, this.$attrs.transitionInterval);
|
|
|
|
|
|
|
|
this.slideShowActive = true;
|
|
|
|
},
|
|
|
|
stopSlideShow() {
|
|
|
|
if (this.interval) {
|
|
|
|
clearInterval(this.interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.slideShowActive = false;
|
|
|
|
},
|
|
|
|
getPositionClass(preClassName, position) {
|
|
|
|
const positions = ['top', 'left', 'bottom', 'right'];
|
2022-09-14 11:26:01 +00:00
|
|
|
const pos = positions.find((item) => item === position);
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
return pos ? `${preClassName}-${pos}` : '';
|
|
|
|
},
|
|
|
|
isVertical() {
|
|
|
|
return this.$attrs.thumbnailsPosition === 'left' || this.$attrs.thumbnailsPosition === 'right';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-12-08 11:04:25 +00:00
|
|
|
closeAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.close : undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2022-09-14 11:26:01 +00:00
|
|
|
GalleriaItem: GalleriaItem,
|
2023-04-06 08:21:23 +00:00
|
|
|
GalleriaThumbnails: GalleriaThumbnails,
|
|
|
|
TimesIcon: TimesIcon
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
directives: {
|
2022-09-14 11:26:01 +00:00
|
|
|
ripple: Ripple
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|