|
@@ -1,134 +1,128 @@
|
|
/**
|
|
/**
|
|
- * @description This module is used for bindings.
|
|
|
|
- * @copyright 2015 by Tobias Reich
|
|
|
|
|
|
+ * @description This module is used for bindings.
|
|
|
|
+ * @copyright 2015 by Tobias Reich
|
|
*/
|
|
*/
|
|
|
|
|
|
$(document).ready(function() {
|
|
$(document).ready(function() {
|
|
|
|
|
|
- /* Event Name */
|
|
|
|
- var eventName = lychee.getEventName();
|
|
|
|
|
|
+ // Event Name
|
|
|
|
+ let eventName = lychee.getEventName()
|
|
|
|
|
|
- /* Set API error handler */
|
|
|
|
- api.onError = lychee.error;
|
|
|
|
|
|
+ // Set API error handler
|
|
|
|
+ api.onError = lychee.error
|
|
|
|
|
|
- /* Multiselect */
|
|
|
|
- multiselect.bind();
|
|
|
|
|
|
+ // Multiselect
|
|
|
|
+ multiselect.bind()
|
|
|
|
|
|
- /* Header */
|
|
|
|
- header.bind();
|
|
|
|
|
|
+ // Header
|
|
|
|
+ header.bind()
|
|
|
|
|
|
- /* Image View */
|
|
|
|
|
|
+ // Image View
|
|
lychee.imageview
|
|
lychee.imageview
|
|
- .on(eventName, '.arrow_wrapper--previous', photo.previous)
|
|
|
|
- .on(eventName, '.arrow_wrapper--next', photo.next);
|
|
|
|
|
|
+ .on(eventName, '.arrow_wrapper--previous', photo.previous)
|
|
|
|
+ .on(eventName, '.arrow_wrapper--next', photo.next)
|
|
|
|
|
|
- /* Keyboard */
|
|
|
|
|
|
+ // Keyboard
|
|
Mousetrap
|
|
Mousetrap
|
|
- .bind('left', function() { if (visible.photo()) $('#imageview a#previous').click() })
|
|
|
|
- .bind('right', function() { if (visible.photo()) $('#imageview a#next').click() })
|
|
|
|
- .bind('u', function() { $('#upload_files').click() })
|
|
|
|
- .bind(['s', 'f'], function(e) {
|
|
|
|
- if (visible.photo()) header.dom('#button_star').click();
|
|
|
|
- else if (visible.albums()) header.dom('#search').focus();
|
|
|
|
- return false;
|
|
|
|
|
|
+ .bind('left', function() {
|
|
|
|
+ if (visible.photo()) { $('#imageview a#previous').click(); return false }
|
|
})
|
|
})
|
|
- .bind('r', function(e) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- if (visible.album()) album.setTitle(album.getID());
|
|
|
|
- else if (visible.photo()) photo.setTitle([photo.getID()]);
|
|
|
|
|
|
+ .bind('right', function() {
|
|
|
|
+ if (visible.photo()) { $('#imageview a#next').click(); return false }
|
|
})
|
|
})
|
|
- .bind('d', function(e) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- if (visible.photo()) photo.setDescription(photo.getID());
|
|
|
|
- else if (visible.album()) album.setDescription(album.getID());
|
|
|
|
|
|
+ .bind('u', function() {
|
|
|
|
+ if (!visible.photo()) { $('#upload_files').click(); return false }
|
|
})
|
|
})
|
|
- .bind('t', function(e) {
|
|
|
|
- if (visible.photo()) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- photo.editTags([photo.getID()]);
|
|
|
|
- }
|
|
|
|
|
|
+ .bind(['s', 'f'], function() {
|
|
|
|
+ if (visible.photo()) { header.dom('#button_star').click(); return false }
|
|
|
|
+ else if (visible.albums()) { header.dom('#search').focus(); return false }
|
|
|
|
+ })
|
|
|
|
+ .bind('r', function() {
|
|
|
|
+ if (visible.album()) { album.setTitle(album.getID()); return false }
|
|
|
|
+ else if (visible.photo()) { photo.setTitle([photo.getID()]); return false }
|
|
|
|
+ })
|
|
|
|
+ .bind('d', function() {
|
|
|
|
+ if (visible.photo()) { photo.setDescription(photo.getID()); return false }
|
|
|
|
+ else if (visible.album()) { album.setDescription(album.getID()); return false }
|
|
|
|
+ })
|
|
|
|
+ .bind('t', function() {
|
|
|
|
+ if (visible.photo()) { photo.editTags([photo.getID()]); return false }
|
|
})
|
|
})
|
|
.bind('i', function() {
|
|
.bind('i', function() {
|
|
- if (visible.multiselect()) return false;
|
|
|
|
- else sidebar.toggle();
|
|
|
|
|
|
+ if (!visible.multiselect()) { sidebar.toggle(); return false }
|
|
})
|
|
})
|
|
.bind(['command+backspace', 'ctrl+backspace'], function() {
|
|
.bind(['command+backspace', 'ctrl+backspace'], function() {
|
|
- if (visible.photo()&&!visible.message()) photo.delete([photo.getID()]);
|
|
|
|
- else if (visible.album()&&!visible.message()) album.delete([album.getID()]);
|
|
|
|
|
|
+ if (visible.photo() && !visible.message()) { photo.delete([photo.getID()]); return false }
|
|
|
|
+ else if (visible.album() && !visible.message()) { album.delete([album.getID()]); return false }
|
|
})
|
|
})
|
|
.bind(['command+a', 'ctrl+a'], function() {
|
|
.bind(['command+a', 'ctrl+a'], function() {
|
|
- if (visible.album()&&!visible.message()) multiselect.selectAll();
|
|
|
|
- else if (visible.albums()&&!visible.message()) multiselect.selectAll();
|
|
|
|
- });
|
|
|
|
|
|
+ if (visible.album() && !visible.message()) { multiselect.selectAll(); return false }
|
|
|
|
+ else if (visible.albums() && !visible.message()) { multiselect.selectAll(); return false }
|
|
|
|
+ })
|
|
|
|
|
|
Mousetrap.bindGlobal('enter', function() {
|
|
Mousetrap.bindGlobal('enter', function() {
|
|
- if (basicModal.visible()===true) basicModal.action();
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- Mousetrap.bindGlobal(['esc', 'command+up'], function(e) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- if (basicModal.visible()===true) basicModal.cancel();
|
|
|
|
- else if (visible.contextMenu()) contextMenu.close();
|
|
|
|
- else if (visible.photo()) lychee.goto(album.getID());
|
|
|
|
- else if (visible.album()) lychee.goto('');
|
|
|
|
- else if (visible.albums()&&$('#search').val().length!==0) search.reset();
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
|
|
+ if (basicModal.visible()===true) basicModal.action()
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ Mousetrap.bindGlobal(['esc', 'command+up'], function() {
|
|
|
|
+ if (basicModal.visible()===true) basicModal.cancel()
|
|
|
|
+ else if (visible.contextMenu()) contextMenu.close()
|
|
|
|
+ else if (visible.photo()) lychee.goto(album.getID())
|
|
|
|
+ else if (visible.album()) lychee.goto('')
|
|
|
|
+ else if (visible.albums() && $('#search').val().length!==0) search.reset()
|
|
|
|
+ return false
|
|
|
|
+ })
|
|
|
|
|
|
if (eventName==='touchend') {
|
|
if (eventName==='touchend') {
|
|
|
|
|
|
$(document)
|
|
$(document)
|
|
|
|
|
|
- /* Fullscreen on mobile */
|
|
|
|
|
|
+ // Fullscreen on mobile
|
|
.on('touchend', '#image', function(e) {
|
|
.on('touchend', '#image', function(e) {
|
|
- if (swipe.obj==null||(swipe.offset>=-5&&swipe.offset<=5)) {
|
|
|
|
- if (visible.header()) header.hide(e, 0);
|
|
|
|
- else header.show();
|
|
|
|
|
|
+ if (swipe.obj==null || (swipe.offset>=-5&&swipe.offset<=5)) {
|
|
|
|
+ if (visible.header()) header.hide(e, 0)
|
|
|
|
+ else header.show()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
- /* Swipe on mobile */
|
|
|
|
- .swipe().on('swipeStart', function() { if (visible.photo()) swipe.start($('#image')) })
|
|
|
|
- .swipe().on('swipeMove', function(e) { if (visible.photo()) swipe.move(e.swipe) })
|
|
|
|
- .swipe().on('swipeEnd', function(e) { if (visible.photo()) swipe.stop(e.swipe, photo.previous, photo.next) });
|
|
|
|
|
|
+ // Swipe on mobile
|
|
|
|
+ .swipe().on('swipeStart', function() { if (visible.photo()) swipe.start($('#image')) })
|
|
|
|
+ .swipe().on('swipeMove', function(e) { if (visible.photo()) swipe.move(e.swipe) })
|
|
|
|
+ .swipe().on('swipeEnd', function(e) { if (visible.photo()) swipe.stop(e.swipe, photo.previous, photo.next) })
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- /* Document */
|
|
|
|
|
|
+ // Document
|
|
$(document)
|
|
$(document)
|
|
|
|
|
|
- /* Login */
|
|
|
|
- .on('keyup', '#password', function() { if ($(this).val().length>0) $(this).removeClass('error') })
|
|
|
|
-
|
|
|
|
- /* Navigation */
|
|
|
|
|
|
+ // Navigation
|
|
.on('click', '.album', function() { lychee.goto($(this).attr('data-id')) })
|
|
.on('click', '.album', function() { lychee.goto($(this).attr('data-id')) })
|
|
.on('click', '.photo', function() { lychee.goto(album.getID() + '/' + $(this).attr('data-id')) })
|
|
.on('click', '.photo', function() { lychee.goto(album.getID() + '/' + $(this).attr('data-id')) })
|
|
|
|
|
|
- /* Context Menu */
|
|
|
|
|
|
+ // Context Menu
|
|
.on('contextmenu', '.photo', function(e) { contextMenu.photo(photo.getID(), e) })
|
|
.on('contextmenu', '.photo', function(e) { contextMenu.photo(photo.getID(), e) })
|
|
.on('contextmenu', '.album', function(e) { contextMenu.album(album.getID(), e) })
|
|
.on('contextmenu', '.album', function(e) { contextMenu.album(album.getID(), e) })
|
|
|
|
|
|
- /* Upload */
|
|
|
|
- .on('change', '#upload_files', function() { basicModal.close(); upload.start.local(this.files) })
|
|
|
|
- .on('dragover', function(e) { e.preventDefault(); }, false)
|
|
|
|
- .on('drop', function(e) {
|
|
|
|
|
|
+ // Upload
|
|
|
|
+ .on('change', '#upload_files', function() { basicModal.close(); upload.start.local(this.files) })
|
|
|
|
|
|
- e.stopPropagation();
|
|
|
|
- e.preventDefault();
|
|
|
|
|
|
+ // Drag and Drop upload
|
|
|
|
+ .on('dragover', function() { return false }, false)
|
|
|
|
+ .on('drop', function(e) {
|
|
|
|
|
|
// Close open overlays or views which are correlating with the upload
|
|
// Close open overlays or views which are correlating with the upload
|
|
- if (visible.photo()) lychee.goto(album.getID());
|
|
|
|
- if (visible.contextMenu()) contextMenu.close();
|
|
|
|
|
|
+ if (visible.photo()) lychee.goto(album.getID())
|
|
|
|
+ if (visible.contextMenu()) contextMenu.close()
|
|
|
|
|
|
// Detect if dropped item is a file or a link
|
|
// Detect if dropped item is a file or a link
|
|
- if (e.originalEvent.dataTransfer.files.length>0) upload.start.local(e.originalEvent.dataTransfer.files);
|
|
|
|
- else if (e.originalEvent.dataTransfer.getData('Text').length>3) upload.start.url(e.originalEvent.dataTransfer.getData('Text'));
|
|
|
|
|
|
+ if (e.originalEvent.dataTransfer.files.length>0) upload.start.local(e.originalEvent.dataTransfer.files)
|
|
|
|
+ else if (e.originalEvent.dataTransfer.getData('Text').length>3) upload.start.url(e.originalEvent.dataTransfer.getData('Text'))
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
+ return false
|
|
|
|
|
|
- });
|
|
|
|
|
|
+ })
|
|
|
|
|
|
- /* Init */
|
|
|
|
- lychee.init();
|
|
|
|
|
|
+ // Init
|
|
|
|
+ lychee.init()
|
|
|
|
|
|
-});
|
|
|
|
|
|
+})
|