changeset 1308:7a4a92cf5b2b

browser (album): start slideshow on photo click
author Goffi <goffi@goffi.org>
date Thu, 16 Jul 2020 09:08:50 +0200 (2020-07-16)
parents 0a6698714557
children 9344ca3b21a6
files libervia/pages/photos/album/_browser/__init__.py
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/pages/photos/album/_browser/__init__.py	Thu Jul 16 09:08:50 2020 +0200
+++ b/libervia/pages/photos/album/_browser/__init__.py	Thu Jul 16 09:08:50 2020 +0200
@@ -6,6 +6,7 @@
 from bridge import Bridge
 from template import Template
 import dialog
+from slideshow import SlideShow
 
 files_service = window.files_service
 files_path = window.files_path
@@ -151,5 +152,26 @@
     )
 
 
+@bind(".photo_thumb_click", "click")
+def photo_click(evt):
+    evt.stopPropagation()
+    evt.preventDefault()
+    slideshow = SlideShow()
+    target = evt.currentTarget
+    clicked_item_elt = DOMNode(target.elt.closest('.item'))
+
+    select_idx = 0
+    slideshow.attach()
+    for idx, item_elt in enumerate(document.select('.item')):
+        item = JSON.parse(item_elt.dataset.item)
+        slide = html.DIV(Class="swiper-slide")
+        img = html.IMG(src=item['url'], Class="slide_img")
+        slide <= img
+        slide._item = item
+        slideshow.add_slide(slide)
+        if item_elt == clicked_item_elt:
+            slideshow.index = idx
+
+
 for elt in document.select('.action_delete'):
     elt.bind("click", on_delete)