Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
enterprise:demos:slider [2021/10/24 23:54] admin |
enterprise:demos:slider [2021/10/25 00:00] (current) admin |
||
|---|---|---|---|
| Line 7: | Line 7: | ||
| ===== Running ===== | ===== Running ===== | ||
| - | |||
| < | < | ||
| <!-- The Gallery as inline carousel, can be positioned anywhere on the page --> | <!-- The Gallery as inline carousel, can be positioned anywhere on the page --> | ||
| Line 167: | Line 166: | ||
| </ | </ | ||
| </ | </ | ||
| + | ===== Code ===== | ||
| + | < | ||
| + | <!-- The Gallery as inline carousel, can be positioned anywhere on the page --> | ||
| + | <div id=" | ||
| + | <div class=" | ||
| + | <h3 class=" | ||
| + | <a class=" | ||
| + | <a class=" | ||
| + | <ol class=" | ||
| + | </ | ||
| + | <br> | ||
| + | < | ||
| + | function initPage(langx, | ||
| + | var $ = domx.query; | ||
| + | |||
| + | require([ | ||
| + | " | ||
| + | ], | ||
| + | 'use strict' | ||
| + | |||
| + | // Initialize the Gallery as video carousel: | ||
| + | |||
| + | var medias = [ | ||
| + | { | ||
| + | title: ' | ||
| + | href: '/ | ||
| + | type: ' | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | title: ' | ||
| + | href: '/ | ||
| + | type: ' | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | title: ' | ||
| + | href: '/ | ||
| + | type: ' | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | title: ' | ||
| + | href: '/ | ||
| + | type: ' | ||
| + | | ||
| + | }, | ||
| + | { | ||
| + | title: ' | ||
| + | href: '/ | ||
| + | type: ' | ||
| + | | ||
| + | } | ||
| + | | ||
| + | ]; | ||
| + | |||
| + | var players = []; | ||
| + | var playingPlayer; | ||
| + | function onSlide(e) { | ||
| + | if (playingPlayer) { | ||
| + | playingPlayer.stop(); | ||
| + | /// | ||
| + | } | ||
| + | |||
| + | players[e.toIndex].resize(); | ||
| + | } | ||
| + | |||
| + | function renderMediaItem(item, | ||
| + | item.altText = item.altText || item.title; | ||
| + | |||
| + | let playerElement = $("< | ||
| + | player = new oneplayer.Player(playerElement, | ||
| + | picker : false, | ||
| + | autoplay : false, | ||
| + | fileOptions :{ | ||
| + | type : item.type, | ||
| + | url : item.href | ||
| + | }, | ||
| + | poster : item.poster, | ||
| + | |||
| + | }); | ||
| + | |||
| + | player.on(" | ||
| + | playingPlayer = null; | ||
| + | }); | ||
| + | |||
| + | player.on(" | ||
| + | playingPlayer = player; | ||
| + | }); | ||
| + | |||
| + | players.push(player); | ||
| + | return playerElement; | ||
| + | } | ||
| + | |||
| + | |||
| + | $('# | ||
| + | cycle : { | ||
| + | interval:0 | ||
| + | }, | ||
| + | data : { | ||
| + | items: medias | ||
| + | }, | ||
| + | mode : " | ||
| + | start : 0, | ||
| + | onjumped : onSlide, | ||
| + | |||
| + | item : { | ||
| + | template : renderMediaItem | ||
| + | }, | ||
| + | | ||
| + | indicator : { | ||
| + | template : "< | ||
| + | "<% if (title) { %>" + | ||
| + | "title = \"< | ||
| + | "<% } %>" + | ||
| + | "<% if (poster) { %>" + | ||
| + | " style = \" | ||
| + | "<% } %>" | ||
| + | "/>" | ||
| + | } | ||
| + | } | ||
| + | }); | ||
| + | }); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | <link type=" | ||
| + | |||
| + | < | ||
| + | .lark-carousel.slide { | ||
| + | width: | ||
| + | height: | ||
| + | margin:1em auto; | ||
| + | max-width: 100%; | ||
| + | | ||
| + | } | ||
| + | .lark-carousel.slide .indicators { | ||
| + | z-index: 100; | ||
| + | bottom: 30px; | ||
| + | background: #00000080; | ||
| + | margin: 0; | ||
| + | padding: 0; | ||
| + | right: 0; | ||
| + | left: 0; | ||
| + | height: 80px; | ||
| + | } | ||
| + | |||
| + | | ||
| + | background-size: | ||
| + | } | ||
| + | |||
| + | .lark-carousel.slide > .indicators > li { | ||
| + | width : 60px; | ||
| + | height: 60px; | ||
| + | background-size: | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | </ | ||