annotate libervia/pages/photos/album/_browser/__init__.py @ 1309:9344ca3b21a6

browser (slideshow): fixed scrolling issue with comment panel: all elements present in body before slideshow is added are hidden, and comments panel is now added to slideshow itself.
author Goffi <goffi@goffi.org>
date Sat, 01 Aug 2020 16:47:21 +0200
parents 7a4a92cf5b2b
children 39a87d9099c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1300
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
1 from browser import document, window, bind, html, DOMNode
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
2 from browser import aio
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
3 from browser import timer
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from javascript import JSON
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from interpreter import Inspector
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from bridge import Bridge
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from template import Template
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
8 import dialog
1308
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
9 from slideshow import SlideShow
1300
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
10
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
11 files_service = window.files_service
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
12 files_path = window.files_path
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
13 bridge = Bridge()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
14
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
15
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
16 def on_progress(ev, photo_elt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
17 if ev.lengthComputable:
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
18 percent = int(ev.loaded/ev.total*100)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
19 update_progress(photo_elt, percent)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
20
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
21
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
22 def on_load(file_, photo_elt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
23 update_progress(photo_elt, 100)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
24 photo_elt.classList.add("progress_finished")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
25 photo_elt.classList.remove("progress_started")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
26 photo_elt.select_one('.action_delete').bind("click", on_delete)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
27 print(f"file {file_.name} uploaded correctly")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
28
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
29
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
30 def on_error(failure, file_, photo_elt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
31 # TODO: cleaner error notification
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
32 window.alert(f"can't upload {file_.name}: failure")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
33
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
34
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
35 def update_progress(photo_elt, new_value):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
36 progress_elt = photo_elt.select_one("progress")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
37 progress_elt.value = new_value
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
38 progress_elt.text = f"{new_value}%"
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
39
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
40
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
41 def on_slot_cb(file_, upload_slot, photo_elt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
42 put_url, get_url, headers = upload_slot
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
43 xhr = window.XMLHttpRequest.new()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
44 xhr.open("PUT", put_url, True)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
45 xhr.upload.bind('progress', lambda ev: on_progress(ev, photo_elt))
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
46 xhr.upload.bind('load', lambda ev: on_load(file_, photo_elt))
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
47 xhr.upload.bind('error', lambda ev: on_error(xhr.response, file_, photo_elt))
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
48 xhr.setRequestHeader('Xmpp-File-Path', window.encodeURIComponent(files_path))
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
49 xhr.setRequestHeader('Xmpp-File-No-Http', "true")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
50 xhr.send(file_)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
51
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
52
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
53 def on_slot_eb(file_, failure, photo_elt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
54 breakpoint()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
55
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
56
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
57 def upload_files(files):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
58 print(f"uploading {len(files)} files")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
59 photo_tpl = Template('photo/item.html')
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
60 album_items = document['album_items']
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
61 for file_ in files:
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
62 url = window.URL.createObjectURL(file_)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
63 photo_elt = photo_tpl.get_elt({
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
64 "file": {
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
65 "name": file_.name,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
66 # we don't want to open the file on click, it's not yet the
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
67 # uploaded URL
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
68 "url": url,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
69 # we have no thumb yet, so we use the whole image
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
70 # TODO: reduce image for preview
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
71 "thumb_url": url,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
72 },
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
73 "uploading": True,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
74 })
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
75 photo_elt.classList.add("progress_started")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
76 print(photo_elt.outerHTML)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
77 album_items <= photo_elt
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
78 # timer.set_timeout(lambda photo_elt=photo_elt: fake_finish(photo_elt), 5000)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
79
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
80 bridge.fileHTTPUploadGetSlot(
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
81 file_.name,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
82 file_.size,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
83 file_.type or '',
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
84 files_service,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
85 callback=lambda upload_slot, file_=file_, photo_elt=photo_elt:
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
86 on_slot_cb(file_, upload_slot, photo_elt),
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
87 errback=lambda failure, file_=file_, photo_elt=photo_elt:
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
88 on_slot_eb(file_, failure, photo_elt),
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
89 )
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
90
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
91
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
92 @bind("#file_drop", "drop")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
93 def on_file_select(evt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
94 evt.stopPropagation()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
95 evt.preventDefault()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
96 files = evt.dataTransfer.files
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
97 upload_files(files)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
98
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
99
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
100 @bind("#file_drop", "dragover")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
101 def on_drag_over(evt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
102 evt.stopPropagation()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
103 evt.preventDefault()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
104 evt.dataTransfer.dropEffect = 'copy'
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
105
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
106
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
107 @bind("#file_input", "change")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
108 def on_file_input_change(evt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
109 files = evt.currentTarget.files
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
110 upload_files(files)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
111
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
112
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
113 def file_delete_cb(item_elt, item):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
114 item_elt.classList.add("state_deleted")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
115 item_elt.bind("transitionend", lambda evt: item_elt.remove())
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
116 print(f"deleted {item['name']}")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
117
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
118
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
119 def file_delete_eb(failure, item_elt, item):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
120 # TODO: cleaner error notification
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
121 window.alert(f"error while deleting {item['name']}: failure")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
122
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
123
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
124 def delete_ok(evt, notif_elt, item_elt, item):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
125 file_path = f"{files_path.rstrip('/')}/{item['name']}"
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
126 bridge.fileSharingDelete(
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
127 files_service,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
128 file_path,
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
129 "",
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
130 callback=lambda : file_delete_cb(item_elt, item),
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
131 errback=lambda failure: file_delete_eb(failure, item_elt, item),
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
132 )
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
133
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
134
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
135 def delete_cancel(evt, notif_elt, item_elt, item):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
136 notif_elt.remove()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
137 item_elt.classList.remove("selected_for_deletion")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
138
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
139
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
140 def on_delete(evt):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
141 evt.stopPropagation()
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
142 target = evt.currentTarget
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
143 item_elt = DOMNode(target.elt.closest('.item'))
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
144 item_elt.classList.add("selected_for_deletion")
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
145 item = JSON.parse(item_elt.dataset.item)
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
146 dialog.Confirm(
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
147 f"{item['name']!r} will be deleted, are you sure?",
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
148 ok_label="delete",
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
149 ).show(
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
150 ok_cb=lambda evt, notif_elt: delete_ok(evt, notif_elt, item_elt, item),
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
151 cancel_cb=lambda evt, notif_elt: delete_cancel(evt, notif_elt, item_elt, item),
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
152 )
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
153
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
154
1308
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
155 @bind(".photo_thumb_click", "click")
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
156 def photo_click(evt):
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
157 evt.stopPropagation()
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
158 evt.preventDefault()
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
159 slideshow = SlideShow()
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
160 target = evt.currentTarget
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
161 clicked_item_elt = DOMNode(target.elt.closest('.item'))
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
162
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
163 select_idx = 0
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
164 slideshow.attach()
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
165 for idx, item_elt in enumerate(document.select('.item')):
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
166 item = JSON.parse(item_elt.dataset.item)
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
167 slide = html.DIV(Class="swiper-slide")
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
168 img = html.IMG(src=item['url'], Class="slide_img")
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
169 slide <= img
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
170 slide._item = item
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
171 slideshow.add_slide(slide)
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
172 if item_elt == clicked_item_elt:
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
173 slideshow.index = idx
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
174
7a4a92cf5b2b browser (album): start slideshow on photo click
Goffi <goffi@goffi.org>
parents: 1300
diff changeset
175
1300
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
176 for elt in document.select('.action_delete'):
6e110baa707f browser (photos/album): photo(s) upload and deletion
Goffi <goffi@goffi.org>
parents:
diff changeset
177 elt.bind("click", on_delete)