Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
enterprise:demos:lightbox [2021/10/23 19:07] admin |
enterprise:demos:lightbox [2021/10/24 23:37] (current) admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~Title: | ||
+ | |||
+ | ====== Demo : Lightbox ====== | ||
+ | ===== Overview ===== | ||
+ | This is a lightbox sample. | ||
+ | Lightbox is a popup window that displays medias by filling the screen, and dimming out the rest of the web page. | ||
+ | |||
+ | ===== Running ===== | ||
+ | |||
< | < | ||
- | <div>Lightbox media gallery</ | + | <div>Click any of the thumbnail images below to pop up a lightbox.</ |
<div id=" | <div id=" | ||
- | <a href="/ | + | <a href="/ |
- | <a href="/ | + | <a href="/ |
- | <a href="/ | + | <a href="/ |
- | <a href="/ | + | <a href="/ |
- | <a href="/ | + | <a href="/ |
- | <a href="/ | + | <a href="/ |
- | <a href="/ | + | <a href="/ |
</ | </ | ||
Line 23: | Line 32: | ||
</ | </ | ||
<script > | <script > | ||
- | | + | |
- | var $ = domx.query; | + | var $ = domx.query; |
- | | + | |
- | " | + | " |
- | ], | + | ], |
- | 'use strict' | + | 'use strict' |
+ | | ||
+ | // Get the container id from the data-gallery attribute: | ||
+ | var id = $(this).data(' | ||
+ | $lightbox = $("# | ||
+ | |||
+ | var callbacks = { | ||
+ | onopen: function () { | ||
+ | container.data(' | ||
+ | }, | ||
+ | onopened: function () { | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onslide: function () { | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onslideend: function () { | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onslidecomplete: | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onclose: function () { | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onclosed: function () { | ||
+ | container.trigger(' | ||
+ | } | ||
+ | }; | ||
+ | // Select all links with the same data-gallery attribute: | ||
+ | var links = $(this) | ||
+ | .closest(' | ||
+ | .find(' | ||
- | $(document).on(' | + | domx.eventer.stop(event); |
- | // Get the container id from the data-gallery attribute: | + | |
- | var id = $(this).data(' | + | var players = []; |
- | | + | var playingPlayer; |
- | | + | |
- | var callbacks | + | if (playingPlayer) { |
- | | + | |
- | | + | } |
- | }, | + | |
- | | + | players[e.toIndex].resize(); |
- | | + | } |
- | }, | + | |
- | | + | function renderMediaItem(item, callback) { |
- | | + | |
- | }, | + | |
- | | + | |
- | | + | let playerElement |
- | }, | + | |
- | | + | |
- | | + | autoplay : false, |
- | }, | + | fileOptions |
- | | + | type : item.type, |
- | | + | url : item.href |
- | }, | + | |
- | | + | poster : item.poster, |
- | | + | |
+ | }); | ||
+ | |||
+ | player.on(" | ||
+ | | ||
+ | | ||
+ | |||
+ | player.on(" | ||
+ | | ||
+ | }); | ||
+ | |||
+ | players.push(player); | ||
+ | | ||
+ | | ||
+ | |||
+ | var items = links.map(function(index,link){ | ||
+ | let $img = $(link).find('img'); | ||
+ | return { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | | ||
+ | }); | ||
+ | |||
+ | |||
+ | var carsouselOptions = Object.assign( | ||
+ | { | ||
+ | data : { | ||
+ | items : items | ||
+ | }, | ||
+ | |||
+ | item : { | ||
+ | | ||
+ | }, | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | "<% if (title) { %>" + | ||
+ | " | ||
+ | "< | ||
+ | "< | ||
+ | " | ||
+ | "<% } %>" | ||
+ | "/>" | ||
} | } | ||
- | | + | }, |
- | // Select all links with the same data-gallery attribute: | + | |
- | var links = $(this) | + | |
- | .closest(' | + | |
- | .find(' | + | |
- | //if (viewOptions.filter) { | + | |
- | // links = links.filter(viewOptions.filter); | + | |
- | //} | + | |
- | domx.eventer.stop(event); | + | start: $(' |
+ | onjumped : onSlide | ||
+ | }, | ||
+ | callbacks | ||
+ | | ||
- | var players | + | let carsousel |
- | var playingPlayer; | + | |
- | function onSlide(e) { | + | |
- | if (playingPlayer) { | + | |
- | playingPlayer.stop(); | + | |
- | /// | + | |
- | } | + | |
- | players[e.toIndex].resize(); | + | $lightbox.find(".close" |
- | } | + | |
+ | | ||
+ | $lightbox.show(); | ||
+ | }); | ||
+ | }); | ||
+ | } | ||
+ | </ | ||
+ | <link type=" | ||
- | function renderMediaItem(item, callback) { | + | < |
- | item.altText = item.altText || item.title; | + | # |
+ | position: fixed; | ||
+ | z-index: 999999; | ||
+ | overflow: hidden; | ||
+ | background: #000; | ||
+ | background: rgba(0, 0, 0, 0.9); | ||
+ | | ||
+ | direction: ltr; | ||
+ | top: 0; | ||
+ | right: 0; | ||
+ | bottom: 0; | ||
+ | left: 0; | ||
+ | } | ||
+ | # | ||
+ | position: absolute; | ||
+ | left: 0; | ||
+ | margin: auto; | ||
+ | top: 0; | ||
+ | bottom: 0; | ||
+ | right: 0; | ||
+ | } | ||
- | let playerElement = $("< | + | .links img { |
- | player = new oneplayer.Player(playerElement, | + | width: 300px; |
- | | + | |
- | | + | |
- | | + | |
- | | + | } |
- | url : item.href | + | |
- | | + | |
- | poster : item.poster, | + | |
- | }); | + | .lark-carousel |
+ | position: absolute; | ||
+ | top: 15px; | ||
+ | left: auto; | ||
+ | margin: -15px; | ||
+ | font-size: 30px; | ||
+ | line-height: | ||
+ | color: #fff; | ||
+ | text-shadow: | ||
+ | text-decoration: | ||
+ | opacity: 0.8; | ||
- | // player.src({ | + | padding: 15px; |
- | // | + | right: 15px; |
- | // | + | |
- | // }); | + | } |
+ | </style> | ||
+ | </ | ||
- | player.on(" | + | ===== Code ===== |
- | playingPlayer | + | < |
- | }); | + | < |
- | player.on("play", | + | <div id=" |
- | | + | <a href="/ |
- | }); | + | <a href="/ |
+ | <a href="/ | ||
+ | <a href="/ | ||
+ | <a href="/ | ||
+ | <a href="/ | ||
+ | <a href="/ | ||
+ | |||
+ | </ | ||
+ | <!-- The Gallery as lightbox dialog, should be a child element of the document body --> | ||
+ | <div id=" | ||
+ | <div class=" | ||
+ | <h3 class=" | ||
+ | <a class=" | ||
+ | <a class=" | ||
+ | <a class=" | ||
+ | <a class=" | ||
+ | <ol class=" | ||
+ | </ | ||
+ | <script > | ||
+ | | ||
+ | var $ = domx.query; | ||
- | players.push(player); | + | require([ |
- | | + | " |
+ | ], | ||
+ | 'use strict' | ||
+ | | ||
+ | // Get the container id from the data-gallery attribute: | ||
+ | var id = $(this).data(' | ||
+ | | ||
+ | |||
+ | var callbacks = { | ||
+ | onopen: function () { | ||
+ | container.data(' | ||
+ | }, | ||
+ | onopened: function () { | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onslide: function () { | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onslideend: function () { | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onslidecomplete: | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onclose: function () { | ||
+ | container.trigger(' | ||
+ | }, | ||
+ | onclosed: function () { | ||
+ | container.trigger(' | ||
} | } | ||
+ | }; | ||
+ | // Select all links with the same data-gallery attribute: | ||
+ | var links = $(this) | ||
+ | .closest(' | ||
+ | .find(' | ||
- | var items = links.map(function(index, | + | domx.eventer.stop(event); |
- | let $img = $(link).find(' | + | |
- | | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }; | + | |
- | }); | + | |
+ | var players = []; | ||
+ | var playingPlayer; | ||
+ | function onSlide(e) { | ||
+ | if (playingPlayer) { | ||
+ | playingPlayer.stop(); | ||
+ | } | ||
- | var carsouselOptions = Object.assign( | + | players[e.toIndex].resize(); |
- | { | + | } |
- | data : { | + | |
- | items : items | + | |
- | }, | + | |
- | item : { | + | function renderMediaItem(item, callback) |
- | template : renderMediaItem | + | |
- | }, | + | |
- | | ||
- | indicator : { | ||
- | template : "< | ||
- | "<% if (title) { %>" + | ||
- | "title = \"< | ||
- | "<% } %>" + | ||
- | "<% if (thumbnail) { %>" + | ||
- | " style = \" | ||
- | "<% } %>" | ||
- | "/>" | ||
- | } | ||
- | }, | ||
- | start: | + | let playerElement = $("< |
- | | + | player = new oneplayer.Player(playerElement,{ |
- | }, | + | |
- | | + | |
- | ); | + | |
+ | type : item.type, | ||
+ | url : item.href | ||
+ | }, | ||
+ | poster : item.poster, | ||
- | | + | |
- | $lightbox.find(".close").click(function(){ | + | player.on("pause",function(){ |
- | | + | |
- | }) | + | |
- | $lightbox.show(); | + | |
}); | }); | ||
+ | player.on(" | ||
+ | playingPlayer = player; | ||
+ | }); | ||
+ | |||
+ | players.push(player); | ||
+ | return playerElement; | ||
+ | } | ||
+ | |||
+ | var items = links.map(function(index, | ||
+ | let $img = $(link).find(' | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }; | ||
}); | }); | ||
- | | + | |
+ | |||
+ | var carsouselOptions = Object.assign( | ||
+ | { | ||
+ | data : { | ||
+ | items : items | ||
+ | }, | ||
+ | |||
+ | item : { | ||
+ | | ||
+ | }, | ||
+ | |||
+ | | ||
+ | indicator : { | ||
+ | template : "< | ||
+ | "<% if (title) { %>" + | ||
+ | "title = \"< | ||
+ | "<% } %>" + | ||
+ | "<% if (thumbnail) { %>" + | ||
+ | " style = \" | ||
+ | "<% } %>" | ||
+ | "/>" | ||
+ | } | ||
+ | }, | ||
+ | |||
+ | start: $(' | ||
+ | onjumped : onSlide | ||
+ | }, | ||
+ | callbacks | ||
+ | ); | ||
+ | |||
+ | let carsousel = new carousels.Carousel($lightbox[0], | ||
+ | |||
+ | $lightbox.find(" | ||
+ | $lightbox.hide(); | ||
+ | }) | ||
+ | $lightbox.show(); | ||
+ | }); | ||
+ | }); | ||
+ | | ||
</ | </ | ||
Line 217: | Line 422: | ||
} | } | ||
</ | </ | ||
+ | </ | ||
+ | |||
- | </ |