Moved binding to multiselect.bind() and header.bind()

This commit is contained in:
Tobias Reich 2015-03-15 21:28:07 +01:00
parent 7ed822be57
commit 9725eb707d
4 changed files with 59 additions and 44 deletions

BIN
dist/main.js vendored

Binary file not shown.

View File

@ -16,6 +16,51 @@ header.dom = function(selector) {
}
header.bind = function() {
// Event Name
var eventName = ('ontouchend' in document.documentElement) ? 'touchend' : 'click';
/* Buttons */
header.dom('#title').on(eventName, function(e) {
if (!$(this).hasClass('editable')) return false;
if (visible.photo()) contextMenu.photoTitle(album.getID(), photo.getID(), e);
else contextMenu.albumTitle(album.getID(), e);
});
header.dom('#button_share').on(eventName, function(e) {
if (photo.json.public==='1'||photo.json.public==='2') contextMenu.sharePhoto(photo.getID(), e);
else photo.setPublic(photo.getID(), e);
});
header.dom('#button_share_album').on(eventName, function(e) {
if (album.json.public==='1') contextMenu.shareAlbum(album.getID(), e);
else album.setPublic(album.getID(), true, e);
});
header.dom('#button_signin') .on(eventName, lychee.loginDialog);
header.dom('#button_settings') .on(eventName, contextMenu.settings);
header.dom('#button_info_album') .on(eventName, sidebar.toggle);
header.dom('#button_info') .on(eventName, sidebar.toggle);
header.dom('.button_add') .on(eventName, contextMenu.add);
header.dom('#button_more') .on(eventName, function(e) { contextMenu.photoMore(photo.getID(), e) });
header.dom('#button_move') .on(eventName, function(e) { contextMenu.move([photo.getID()], e) });
header.dom('#hostedwith') .on(eventName, function() { window.open(lychee.website) });
header.dom('#button_trash_album') .on(eventName, function() { album.delete([album.getID()]) });
header.dom('#button_trash') .on(eventName, function() { photo.delete([photo.getID()]) });
header.dom('#button_archive') .on(eventName, function() { album.getArchive(album.getID()) });
header.dom('#button_star') .on(eventName, function() { photo.setStar([photo.getID()]) });
header.dom('#button_back_home') .on(eventName, function() { lychee.goto('') });
header.dom('#button_back') .on(eventName, function() { lychee.goto(album.getID()) });
/* Search */
header.dom('#search').on('keyup click', function() { search.find($(this).val()) });
header.dom('#clearSearch').on(eventName, function () {
header.dom('#search').focus();
search.reset();
});
return true;
}
header.show = function() {
var newMargin = -1*($('#imageview #image').height()/2)+20;

View File

@ -9,46 +9,10 @@ $(document).ready(function() {
var eventName = ('ontouchend' in document.documentElement) ? 'touchend' : 'click';
/* Multiselect */
$('#content') .on('mousedown', function(e) { if (e.which===1) multiselect.show(e) });
$(document) .on('mouseup', function(e) { if (e.which===1) multiselect.getSelection(e) });
multiselect.bind();
/* Header */
header.dom('#title').on(eventName, function(e) {
if (!$(this).hasClass('editable')) return false;
if (visible.photo()) contextMenu.photoTitle(album.getID(), photo.getID(), e);
else contextMenu.albumTitle(album.getID(), e);
});
header.dom('#button_share').on(eventName, function(e) {
if (photo.json.public==='1'||photo.json.public==='2') contextMenu.sharePhoto(photo.getID(), e);
else photo.setPublic(photo.getID(), e);
});
header.dom('#button_share_album').on(eventName, function(e) {
if (album.json.public==='1') contextMenu.shareAlbum(album.getID(), e);
else album.setPublic(album.getID(), true, e);
});
header.dom('#button_signin') .on(eventName, lychee.loginDialog);
header.dom('#button_settings') .on(eventName, contextMenu.settings);
header.dom('#button_info_album') .on(eventName, sidebar.toggle);
header.dom('#button_info') .on(eventName, sidebar.toggle);
header.dom('.button_add') .on(eventName, contextMenu.add);
header.dom('#button_more') .on(eventName, function(e) { contextMenu.photoMore(photo.getID(), e) });
header.dom('#button_move') .on(eventName, function(e) { contextMenu.move([photo.getID()], e) });
header.dom('#hostedwith') .on(eventName, function() { window.open(lychee.website) });
header.dom('#button_trash_album') .on(eventName, function() { album.delete([album.getID()]) });
header.dom('#button_trash') .on(eventName, function() { photo.delete([photo.getID()]) });
header.dom('#button_archive') .on(eventName, function() { album.getArchive(album.getID()) });
header.dom('#button_star') .on(eventName, function() { photo.setStar([photo.getID()]) });
header.dom('#button_back_home') .on(eventName, function() { lychee.goto('') });
header.dom('#button_back') .on(eventName, function() { lychee.goto(album.getID()) });
/* Search */
header.dom('#search').on('keyup click', function() { search.find($(this).val()) });
/* Clear Search */
header.dom('#clearSearch').on(eventName, function () {
header.dom('#search').focus();
search.reset();
});
header.bind();
/* Image View */
lychee.imageview
@ -61,12 +25,9 @@ $(document).ready(function() {
.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()) {
e.preventDefault();
header.dom('#search').focus();
}
if (visible.photo()) header.dom('#button_star').click();
else if (visible.albums()) header.dom('#search').focus();
return false;
})
.bind('r', function(e) {
e.preventDefault();

View File

@ -14,6 +14,15 @@ multiselect.position = {
}
multiselect.bind = function() {
$('#content') .on('mousedown', function(e) { if (e.which===1) multiselect.show(e) });
$(document) .on('mouseup', function(e) { if (e.which===1) multiselect.getSelection(e) });
return true;
}
multiselect.show = function(e) {
if (lychee.publicMode) return false;