Allow to select photos/albums individually (fixes #339).

This commit adds support for selecting photos and albums individually
via ctrl+click. For that, the event handlers in init.js call to
multiselect now, which collects the photo/album ids and calls the
appropriate method of contextMenu in the end.
pull/594/head
Nils Asmussen 8 years ago
parent 96bd6b240b
commit 0746acda79

@ -96,12 +96,12 @@ $(document).ready(function() {
$(document)
// Navigation
.on('click', '.album', function() { lychee.goto($(this).attr('data-id')) })
.on('click', '.photo', function() { lychee.goto(album.getID() + '/' + $(this).attr('data-id')) })
.on('click', '.album', function(e) { multiselect.albumClick(e, $(this)) })
.on('click', '.photo', function(e) { multiselect.photoClick(e, $(this)) })
// Context Menu
.on('contextmenu', '.photo', function(e) { contextMenu.photo(photo.getID(), e) })
.on('contextmenu', '.album', function(e) { contextMenu.album(album.getID(), e) })
.on('contextmenu', '.photo', function(e) { multiselect.photoContextMenu(e, $(this)) })
.on('contextmenu', '.album', function(e) { multiselect.albumContextMenu(e, $(this)) })
// Upload
.on('change', '#upload_files', function() { basicModal.close(); upload.start.local(this.files) })

@ -3,7 +3,11 @@
* @copyright 2015 by Tobias Reich
*/
multiselect = {}
multiselect = {
ids : []
}
multiselect.position = {
@ -22,6 +26,72 @@ multiselect.bind = function() {
}
multiselect.toggleItem = function(object, id) {
if (album.isSmartID(id)) return
let pos = $.inArray(id, multiselect.ids)
if (pos!=-1) {
multiselect.ids.splice(pos, 1)
multiselect.deselect(object)
}
else {
multiselect.ids.push(id)
multiselect.select(object)
}
}
multiselect.albumClick = function(e, albumObj) {
let id = albumObj.attr('data-id')
if (e.ctrlKey) multiselect.toggleItem(albumObj, id)
else lychee.goto(id)
}
multiselect.photoClick = function(e, photoObj) {
let id = photoObj.attr('data-id')
if (e.ctrlKey) multiselect.toggleItem(photoObj, id)
else lychee.goto(album.getID() + '/' + id)
}
multiselect.albumContextMenu = function(e, albumObj) {
let id = albumObj.attr('data-id')
if ($.inArray(id, multiselect.ids)!=-1) {
contextMenu.albumMulti(multiselect.ids, e)
}
else {
multiselect.deselect('.photo.active, .album.active')
contextMenu.album(album.getID(), e)
}
multiselect.ids = []
}
multiselect.photoContextMenu = function(e, photoObj) {
let id = photoObj.attr('data-id')
if ($.inArray(id, multiselect.ids)!=-1) {
contextMenu.photoMulti(multiselect.ids, e)
}
else {
multiselect.deselect('.photo.active, .album.active')
contextMenu.photo(photo.getID(), e)
}
multiselect.ids = []
}
multiselect.show = function(e) {
if (lychee.publicMode) return false
@ -234,6 +304,9 @@ multiselect.deselect = function(id) {
multiselect.close = function() {
multiselect.deselect('.photo.active, .album.active')
multiselect.ids = []
sidebar.setSelectable(true)
multiselect.stopResize()

Loading…
Cancel
Save