SimpleCarousel-omeka-module/view/common/block-layout/simple-carousel.phtml

94 lines
2.3 KiB
PHTML
Raw Permalink Normal View History

2021-05-31 20:28:57 +02:00
2021-06-27 15:51:36 +02:00
<?php
$this->headLink()->appendStylesheet($this->assetUrl('css/carousel.css', 'SimpleCarousel'));
$this->headScript()->appendFile($this->assetUrl('js/siema.min.js', 'SimpleCarousel'));
$caret = sprintf('<img class="caret" id="left" src="%s">', $this->assetUrl('caret.png', 'SimpleCarousel'));
$caret_r = sprintf('<img class="caret" id="right" src="%s">', $this->assetUrl('caret.png', 'SimpleCarousel'));
?>
<style>
/* styles placed in carousel.css */
2021-06-27 15:51:36 +02:00
</style>
2021-05-31 20:28:57 +02:00
<div class="archive-item-block archive-carousel">
2021-05-31 20:28:57 +02:00
<?php if ($renderSourceLink) { ?>
<div class="source-link">
<a href="">Source</a>
2021-05-31 20:28:57 +02:00
</div>
<?php } ?>
<div class="archive-carousel-container">
<div class="siema_<?php $carousel_id ?> siema">
<?php foreach ($images as $image) { ?>
<div class="siema-wrap" style="<?php // $wrapStyle ?>"
2021-06-27 15:51:36 +02:00
>
<img class="siema-img"
style="<?php $imgStyle ?>"
src="<?php $image['media_url'] ?>"
2021-06-27 15:51:36 +02:00
/>
</div>
<?php } ?>
</div>
<div id="siema-ui"></div>
2021-05-31 20:28:57 +02:00
</div>
<?php if ($title) { ?>
<div class="item_title">
<?php $title ?>
</div>
2021-06-27 15:51:36 +02:00
<?php } ?>
2021-05-31 20:28:57 +02:00
</div>
2021-06-27 15:51:36 +02:00
<script>
var sourceURLs = [];
<?php foreach ($images as $image) { ?>
sourceURLs.push("<?php $image['item_url'] ?>")
<?php } ?>
2021-06-27 15:51:36 +02:00
$(document).ready(function() {
let siema = new Siema({
selector: '.siema_<?php $carousel_id ?>',
2021-06-27 15:51:36 +02:00
easing: 'ease-out',
duration: <?php echo $duration ?>,
perPage: <?php echo $perPage ?>,
loop: <?php echo $loop ?>,
draggable: <?php echo $draggable ?>,
onInit: changeSourceURL,
onChange: changeSourceURL,
2021-06-27 15:51:36 +02:00
});
2021-05-31 20:28:57 +02:00
2021-06-27 15:51:36 +02:00
let caret = '<?php echo $caret;?>';
let caret_r = '<?php echo $caret_r;?>';
2021-05-31 20:28:57 +02:00
2021-06-27 15:51:36 +02:00
$('#siema-ui').append(caret);
$('#siema-ui').append(caret_r);
2021-05-31 20:28:57 +02:00
2021-06-27 15:51:36 +02:00
$('.caret#left').click(function () {siema.prev()});
$('.caret#right').click(function () {siema.next()});
2021-05-31 20:28:57 +02:00
2021-06-27 15:51:36 +02:00
<?php if ($autoSlide == true): ?>
window.setInterval(() => {
siema.next();
}, <?php echo $autoSlideInt; ?>);
<?php endif ?>
});
function changeSourceURL(){
var slide_idx = this.currentSlide
if (slide_idx < 0) {
slide_idx = sourceURLs.length -1;
}
var source_link = $(".siema_<?php $carousel_id ?>")
.closest(".archive-carousel")
.find(".source-link")
.find('a');
if (source_link.length != 0) {
$(source_link).attr("href", sourceURLs[slide_idx])
}
}
2021-06-27 15:51:36 +02:00
</script>