Updated main.js (ES2015)
This commit is contained in:
parent
0d583ea341
commit
595e40549a
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
BIN
dist/view.js
vendored
BIN
dist/view.js
vendored
Binary file not shown.
@ -11,174 +11,174 @@ header = {
|
||||
|
||||
header.dom = function(selector) {
|
||||
|
||||
if (selector===undefined||selector===null||selector==='') return header._dom;
|
||||
return header._dom.find(selector);
|
||||
if (selector==null || selector==='') return header._dom
|
||||
return header._dom.find(selector)
|
||||
|
||||
}
|
||||
|
||||
header.bind = function() {
|
||||
|
||||
// Event Name
|
||||
var eventName = lychee.getEventName();
|
||||
let eventName = lychee.getEventName()
|
||||
|
||||
/* 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);
|
||||
});
|
||||
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);
|
||||
});
|
||||
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()) });
|
||||
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('#search').on('keyup click', function() { search.find($(this).val()) })
|
||||
header.dom('#clearSearch').on(eventName, function () {
|
||||
header.dom('#search').focus();
|
||||
search.reset();
|
||||
});
|
||||
header.dom('#search').focus()
|
||||
search.reset()
|
||||
})
|
||||
|
||||
return true;
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
header.show = function() {
|
||||
|
||||
var newMargin = -1*($('#imageview #image').height()/2)+20;
|
||||
let newMargin = (-1 * ($('#imageview #image').height()/2) + 20)
|
||||
|
||||
clearTimeout($(window).data('timeout'));
|
||||
clearTimeout($(window).data('timeout'))
|
||||
|
||||
lychee.imageview.removeClass('full');
|
||||
header.dom().removeClass('hidden');
|
||||
lychee.imageview.removeClass('full')
|
||||
header.dom().removeClass('hidden')
|
||||
|
||||
// Adjust position or size of photo
|
||||
if ($('#imageview #image.small').length>0) $('#imageview #image').css('margin-top', newMargin);
|
||||
else $('#imageview #image').removeClass('full');
|
||||
if ($('#imageview #image.small').length>0) $('#imageview #image').css('margin-top', newMargin)
|
||||
else $('#imageview #image').removeClass('full')
|
||||
|
||||
return true;
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
header.hide = function(e, delay = 500) {
|
||||
|
||||
if (visible.photo()&&!visible.sidebar()&&!visible.contextMenu()&&!visible.message()) {
|
||||
if (visible.photo() && !visible.sidebar() && !visible.contextMenu() && !visible.message()) {
|
||||
|
||||
var newMargin = -1*($('#imageview #image').height()/2);
|
||||
|
||||
clearTimeout($(window).data('timeout'));
|
||||
clearTimeout($(window).data('timeout'))
|
||||
|
||||
$(window).data('timeout', setTimeout(function() {
|
||||
|
||||
lychee.imageview.addClass('full');
|
||||
header.dom().addClass('hidden');
|
||||
let newMargin = (-1 * ($('#imageview #image').height()/2))
|
||||
|
||||
lychee.imageview.addClass('full')
|
||||
header.dom().addClass('hidden')
|
||||
|
||||
// Adjust position or size of photo
|
||||
if ($('#imageview #image.small').length>0) $('#imageview #image').css('margin-top', newMargin);
|
||||
else $('#imageview #image').addClass('full');
|
||||
if ($('#imageview #image.small').length>0) $('#imageview #image').css('margin-top', newMargin)
|
||||
else $('#imageview #image').addClass('full')
|
||||
|
||||
}, delay));
|
||||
}, delay))
|
||||
|
||||
return true;
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
header.setTitle = function(title = 'Untitled') {
|
||||
|
||||
var $title = header.dom('#title');
|
||||
let $title = header.dom('#title')
|
||||
|
||||
$title.html(title + build.iconic('caret-bottom'));
|
||||
$title.html(title + build.iconic('caret-bottom'))
|
||||
|
||||
return true;
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
header.setMode = function(mode) {
|
||||
|
||||
var albumID = album.getID();
|
||||
let albumID = album.getID()
|
||||
|
||||
switch (mode) {
|
||||
|
||||
case 'albums':
|
||||
|
||||
header.dom().removeClass('view');
|
||||
$('#tools_album, #tools_photo').hide();
|
||||
$('#tools_albums').show();
|
||||
header.dom().removeClass('view')
|
||||
$('#tools_album, #tools_photo').hide()
|
||||
$('#tools_albums').show()
|
||||
|
||||
return true;
|
||||
break;
|
||||
return true
|
||||
break
|
||||
|
||||
case 'album':
|
||||
|
||||
header.dom().removeClass('view');
|
||||
$('#tools_albums, #tools_photo').hide();
|
||||
$('#tools_album').show();
|
||||
header.dom().removeClass('view')
|
||||
$('#tools_albums, #tools_photo').hide()
|
||||
$('#tools_album').show()
|
||||
|
||||
// Hide download button when album empty
|
||||
album.json.content === false ? $('#button_archive').hide() : $('#button_archive').show();
|
||||
album.json.content === false ? $('#button_archive').hide() : $('#button_archive').show()
|
||||
|
||||
// Hide download button when not logged in and album not downloadable
|
||||
if (lychee.publicMode===true&&album.json.downloadable==='0') $('#button_archive').hide();
|
||||
if (lychee.publicMode===true && album.json.downloadable==='0') $('#button_archive').hide()
|
||||
|
||||
if (albumID==='s'||albumID==='f'||albumID==='r') {
|
||||
$('#button_info_album, #button_trash_album, #button_share_album').hide();
|
||||
if (albumID==='s' || albumID==='f' || albumID==='r') {
|
||||
$('#button_info_album, #button_trash_album, #button_share_album').hide()
|
||||
} else if (albumID==='0') {
|
||||
$('#button_info_album, #button_share_album').hide();
|
||||
$('#button_trash_album').show();
|
||||
$('#button_info_album, #button_share_album').hide()
|
||||
$('#button_trash_album').show()
|
||||
} else {
|
||||
$('#button_info_album, #button_trash_album, #button_share_album').show();
|
||||
$('#button_info_album, #button_trash_album, #button_share_album').show()
|
||||
}
|
||||
|
||||
return true;
|
||||
break;
|
||||
return true
|
||||
break
|
||||
|
||||
case 'photo':
|
||||
|
||||
header.dom().addClass('view');
|
||||
$('#tools_albums, #tools_album').hide();
|
||||
$('#tools_photo').show();
|
||||
header.dom().addClass('view')
|
||||
$('#tools_albums, #tools_album').hide()
|
||||
$('#tools_photo').show()
|
||||
|
||||
return true;
|
||||
break;
|
||||
return true
|
||||
break
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
header.setEditable = function(editable) {
|
||||
|
||||
var $title = header.dom('#title');
|
||||
let $title = header.dom('#title')
|
||||
|
||||
// Hide editable icon when not logged in
|
||||
if (lychee.publicMode===true) editable = false;
|
||||
if (lychee.publicMode===true) editable = false
|
||||
|
||||
if (editable) $title.addClass('editable');
|
||||
else $title.removeClass('editable');
|
||||
if (editable) $title.addClass('editable')
|
||||
else $title.removeClass('editable')
|
||||
|
||||
return true;
|
||||
return true
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user