diff --git a/dist/main.js b/dist/main.js index 87a2c9d..db6f1fe 100644 Binary files a/dist/main.js and b/dist/main.js differ diff --git a/src/scripts/header.js b/src/scripts/header.js index f970761..2dbea07 100644 --- a/src/scripts/header.js +++ b/src/scripts/header.js @@ -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; diff --git a/src/scripts/init.js b/src/scripts/init.js index 5847149..d68e721 100755 --- a/src/scripts/init.js +++ b/src/scripts/init.js @@ -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(); diff --git a/src/scripts/multiselect.js b/src/scripts/multiselect.js index 364414a..30afe41 100644 --- a/src/scripts/multiselect.js +++ b/src/scripts/multiselect.js @@ -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;