Updated several files (ES2015)
This commit is contained in:
parent
d4470341ff
commit
1326524ade
BIN
dist/main.js
vendored
Executable file → Normal file
BIN
dist/main.js
vendored
Executable file → Normal file
Binary file not shown.
BIN
dist/view.js
vendored
BIN
dist/view.js
vendored
Binary file not shown.
@ -1,12 +1,12 @@
|
|||||||
function gup(b) {
|
function gup(b) {
|
||||||
|
|
||||||
b = b.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
b = b.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]")
|
||||||
|
|
||||||
var a = "[\\?&]" + b + "=([^&#]*)",
|
let a = "[\\?&]" + b + "=([^&#]*)",
|
||||||
d = new RegExp(a),
|
d = new RegExp(a),
|
||||||
c = d.exec(window.location.href);
|
c = d.exec(window.location.href)
|
||||||
|
|
||||||
if (c === null) return '';
|
if (c === null) return ''
|
||||||
else return c[1];
|
else return c[1]
|
||||||
|
|
||||||
};
|
}
|
@ -1,74 +1,74 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
var Swipe = function(el) {
|
var Swipe = function(el) {
|
||||||
var self = this;
|
var self = this
|
||||||
|
|
||||||
this.el = $(el);
|
this.el = $(el)
|
||||||
this.pos = { start: { x: 0, y: 0 }, end: { x: 0, y: 0 } };
|
this.pos = { start: { x: 0, y: 0 }, end: { x: 0, y: 0 } }
|
||||||
this.startTime;
|
this.startTime
|
||||||
|
|
||||||
el.on('touchstart', function(e) { self.touchStart(e); });
|
el.on('touchstart', function(e) { self.touchStart(e) })
|
||||||
el.on('touchmove', function(e) { self.touchMove(e); });
|
el.on('touchmove', function(e) { self.touchMove(e) })
|
||||||
el.on('touchend', function(e) { self.swipeEnd(); });
|
el.on('touchend', function(e) { self.swipeEnd() })
|
||||||
el.on('mousedown', function(e) { self.mouseDown(e); });
|
el.on('mousedown', function(e) { self.mouseDown(e) })
|
||||||
};
|
}
|
||||||
|
|
||||||
Swipe.prototype = {
|
Swipe.prototype = {
|
||||||
touchStart: function(e) {
|
touchStart: function(e) {
|
||||||
var touch = e.originalEvent.touches[0];
|
var touch = e.originalEvent.touches[0]
|
||||||
|
|
||||||
this.swipeStart(e, touch.pageX, touch.pageY);
|
this.swipeStart(e, touch.pageX, touch.pageY)
|
||||||
},
|
},
|
||||||
|
|
||||||
touchMove: function(e) {
|
touchMove: function(e) {
|
||||||
var touch = e.originalEvent.touches[0];
|
var touch = e.originalEvent.touches[0]
|
||||||
|
|
||||||
this.swipeMove(e, touch.pageX, touch.pageY);
|
this.swipeMove(e, touch.pageX, touch.pageY)
|
||||||
},
|
},
|
||||||
|
|
||||||
mouseDown: function(e) {
|
mouseDown: function(e) {
|
||||||
var self = this;
|
var self = this
|
||||||
|
|
||||||
this.swipeStart(e, e.pageX, e.pageY);
|
this.swipeStart(e, e.pageX, e.pageY)
|
||||||
|
|
||||||
this.el.on('mousemove', function(e) { self.mouseMove(e); });
|
this.el.on('mousemove', function(e) { self.mouseMove(e) })
|
||||||
this.el.on('mouseup', function() { self.mouseUp(); });
|
this.el.on('mouseup', function() { self.mouseUp() })
|
||||||
},
|
},
|
||||||
|
|
||||||
mouseMove: function(e) {
|
mouseMove: function(e) {
|
||||||
this.swipeMove(e, e.pageX, e.pageY);
|
this.swipeMove(e, e.pageX, e.pageY)
|
||||||
},
|
},
|
||||||
|
|
||||||
mouseUp: function(e) {
|
mouseUp: function(e) {
|
||||||
this.swipeEnd(e);
|
this.swipeEnd(e)
|
||||||
|
|
||||||
this.el.off('mousemove');
|
this.el.off('mousemove')
|
||||||
this.el.off('mouseup');
|
this.el.off('mouseup')
|
||||||
},
|
},
|
||||||
|
|
||||||
swipeStart: function(e, x, y) {
|
swipeStart: function(e, x, y) {
|
||||||
this.pos.start.x = x;
|
this.pos.start.x = x
|
||||||
this.pos.start.y = y;
|
this.pos.start.y = y
|
||||||
this.pos.end.x = x;
|
this.pos.end.x = x
|
||||||
this.pos.end.y = y;
|
this.pos.end.y = y
|
||||||
|
|
||||||
this.startTime = new Date().getTime();
|
this.startTime = new Date().getTime()
|
||||||
|
|
||||||
this.trigger('swipeStart', e);
|
this.trigger('swipeStart', e)
|
||||||
},
|
},
|
||||||
|
|
||||||
swipeMove: function(e, x, y) {
|
swipeMove: function(e, x, y) {
|
||||||
this.pos.end.x = x;
|
this.pos.end.x = x
|
||||||
this.pos.end.y = y;
|
this.pos.end.y = y
|
||||||
|
|
||||||
this.trigger('swipeMove', e);
|
this.trigger('swipeMove', e)
|
||||||
},
|
},
|
||||||
|
|
||||||
swipeEnd: function(e) {
|
swipeEnd: function(e) {
|
||||||
this.trigger('swipeEnd', e);
|
this.trigger('swipeEnd', e)
|
||||||
},
|
},
|
||||||
|
|
||||||
trigger: function(e, originalEvent) {
|
trigger: function(e, originalEvent) {
|
||||||
var self = this;
|
var self = this
|
||||||
|
|
||||||
var
|
var
|
||||||
event = $.Event(e),
|
event = $.Event(e),
|
||||||
@ -78,31 +78,31 @@
|
|||||||
direction = 'up',
|
direction = 'up',
|
||||||
distance = Math.round(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))),
|
distance = Math.round(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))),
|
||||||
angle = Math.round(radians * 180 / Math.PI),
|
angle = Math.round(radians * 180 / Math.PI),
|
||||||
speed = Math.round(distance / ( new Date().getTime() - self.startTime ) * 1000);
|
speed = Math.round(distance / ( new Date().getTime() - self.startTime ) * 1000)
|
||||||
|
|
||||||
if ( angle < 0 ) {
|
if ( angle < 0 ) {
|
||||||
angle = 360 - Math.abs(angle);
|
angle = 360 - Math.abs(angle)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( angle <= 45 && angle >= 0 ) || ( angle <= 360 && angle >= 315 ) ) {
|
if ( ( angle <= 45 && angle >= 0 ) || ( angle <= 360 && angle >= 315 ) ) {
|
||||||
direction = 'left';
|
direction = 'left'
|
||||||
} else if ( angle >= 135 && angle <= 225 ) {
|
} else if ( angle >= 135 && angle <= 225 ) {
|
||||||
direction = 'right';
|
direction = 'right'
|
||||||
} else if ( angle > 45 && angle < 135 ) {
|
} else if ( angle > 45 && angle < 135 ) {
|
||||||
direction = 'down';
|
direction = 'down'
|
||||||
}
|
}
|
||||||
|
|
||||||
event.originalEvent = originalEvent;
|
event.originalEvent = originalEvent
|
||||||
|
|
||||||
event.swipe = { x: x, y: y, direction: direction, distance: distance, angle: angle, speed: speed };
|
event.swipe = { x: x, y: y, direction: direction, distance: distance, angle: angle, speed: speed }
|
||||||
|
|
||||||
$(self.el).trigger(event);
|
$(self.el).trigger(event)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.swipe = function() {
|
$.fn.swipe = function() {
|
||||||
var swipe = new Swipe(this);
|
var swipe = new Swipe(this)
|
||||||
|
|
||||||
return this;
|
return this
|
||||||
};
|
}
|
||||||
})(jQuery);
|
})(jQuery)
|
@ -9,14 +9,14 @@ view.albums = {
|
|||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
|
||||||
view.albums.title();
|
view.albums.title()
|
||||||
view.albums.content.init();
|
view.albums.content.init()
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
title: function() {
|
title: function() {
|
||||||
|
|
||||||
lychee.setTitle('Albums', false);
|
lychee.setTitle('Albums', false)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -26,68 +26,67 @@ view.albums = {
|
|||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
|
||||||
var smartData = '',
|
let smartData = '',
|
||||||
albumsData = '';
|
albumsData = ''
|
||||||
|
|
||||||
/* Smart Albums */
|
// Smart Albums
|
||||||
if (lychee.publicMode===false) {
|
if (lychee.publicMode===false) {
|
||||||
|
|
||||||
albums.parse(albums.json.smartalbums.unsorted);
|
albums.parse(albums.json.smartalbums.unsorted)
|
||||||
albums.parse(albums.json.smartalbums.public);
|
albums.parse(albums.json.smartalbums.public)
|
||||||
albums.parse(albums.json.smartalbums.starred);
|
albums.parse(albums.json.smartalbums.starred)
|
||||||
albums.parse(albums.json.smartalbums.recent);
|
albums.parse(albums.json.smartalbums.recent)
|
||||||
|
|
||||||
smartData = build.divider('Smart Albums') + build.album(albums.json.smartalbums.unsorted) + build.album(albums.json.smartalbums.public) + build.album(albums.json.smartalbums.starred) + build.album(albums.json.smartalbums.recent);
|
smartData = build.divider('Smart Albums') + build.album(albums.json.smartalbums.unsorted) + build.album(albums.json.smartalbums.public) + build.album(albums.json.smartalbums.starred) + build.album(albums.json.smartalbums.recent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Albums */
|
// Albums
|
||||||
if (albums.json.albums&&albums.json.num!==0) {
|
if (albums.json.albums && albums.json.num!==0) {
|
||||||
|
|
||||||
$.each(albums.json.albums, function() {
|
$.each(albums.json.albums, function() {
|
||||||
albums.parse(this);
|
albums.parse(this)
|
||||||
albumsData += build.album(this);
|
albumsData += build.album(this)
|
||||||
});
|
})
|
||||||
|
|
||||||
// Add divider
|
// Add divider
|
||||||
if (lychee.publicMode===false) albumsData = build.divider('Albums') + albumsData;
|
if (lychee.publicMode===false) albumsData = build.divider('Albums') + albumsData
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smartData===''&&albumsData==='') {
|
if (smartData==='' && albumsData==='') {
|
||||||
lychee.content.html('');
|
lychee.content.html('')
|
||||||
$('body').append(build.no_content('eye'));
|
$('body').append(build.no_content('eye'))
|
||||||
} else {
|
} else {
|
||||||
lychee.content.html(smartData + albumsData);
|
lychee.content.html(smartData + albumsData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore scroll position
|
// Restore scroll position
|
||||||
if (view.albums.content.scrollPosition!==null&&
|
if (view.albums.content.scrollPosition!==null && view.albums.content.scrollPosition!==0) {
|
||||||
view.albums.content.scrollPosition!==0) {
|
$(document).scrollTop(view.albums.content.scrollPosition)
|
||||||
$(document).scrollTop(view.albums.content.scrollPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
title: function(albumID) {
|
title: function(albumID) {
|
||||||
|
|
||||||
var title = albums.getByID(albumID).title;
|
let title = albums.getByID(albumID).title
|
||||||
|
|
||||||
$('.album[data-id="' + albumID + '"] .overlay h1')
|
$('.album[data-id="' + albumID + '"] .overlay h1')
|
||||||
.html(title)
|
.html(title)
|
||||||
.attr('title', title);
|
.attr('title', title)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
delete: function(albumID) {
|
delete: function(albumID) {
|
||||||
|
|
||||||
$('.album[data-id="' + albumID + '"]').css('opacity', 0).animate({
|
$('.album[data-id="' + albumID + '"]').css('opacity', 0).animate({
|
||||||
width: 0,
|
width : 0,
|
||||||
marginLeft: 0
|
marginLeft : 0
|
||||||
}, 300, function() {
|
}, 300, function() {
|
||||||
$(this).remove();
|
$(this).remove()
|
||||||
if (albums.json.num<=0) lychee.content.find('.divider:last-child').remove();
|
if (albums.json.num<=0) lychee.content.find('.divider:last-child').remove()
|
||||||
});
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,38 +98,38 @@ view.album = {
|
|||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
|
||||||
album.parse();
|
album.parse()
|
||||||
|
|
||||||
view.album.sidebar();
|
view.album.sidebar()
|
||||||
view.album.title();
|
view.album.title()
|
||||||
view.album.public();
|
view.album.public()
|
||||||
view.album.content.init();
|
view.album.content.init()
|
||||||
|
|
||||||
album.json.init = 1;
|
album.json.init = 1
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
title: function() {
|
title: function() {
|
||||||
|
|
||||||
if ((visible.album()||!album.json.init)&&!visible.photo()) {
|
if ((visible.album() || !album.json.init) && !visible.photo()) {
|
||||||
|
|
||||||
switch (album.getID()) {
|
switch (album.getID()) {
|
||||||
case 'f':
|
case 'f':
|
||||||
lychee.setTitle('Starred', false);
|
lychee.setTitle('Starred', false)
|
||||||
break;
|
break
|
||||||
case 's':
|
case 's':
|
||||||
lychee.setTitle('Public', false);
|
lychee.setTitle('Public', false)
|
||||||
break;
|
break
|
||||||
case 'r':
|
case 'r':
|
||||||
lychee.setTitle('Recent', false);
|
lychee.setTitle('Recent', false)
|
||||||
break;
|
break
|
||||||
case '0':
|
case '0':
|
||||||
lychee.setTitle('Unsorted', false);
|
lychee.setTitle('Unsorted', false)
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
if (album.json.init) sidebar.changeAttr('title', album.json.title);
|
if (album.json.init) sidebar.changeAttr('title', album.json.title)
|
||||||
lychee.setTitle(album.json.title, true);
|
lychee.setTitle(album.json.title, true)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -141,64 +140,64 @@ view.album = {
|
|||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
|
||||||
var photosData = '';
|
let photosData = ''
|
||||||
|
|
||||||
if (album.json.content&&album.json.content!==false) {
|
if (album.json.content && album.json.content!==false) {
|
||||||
|
|
||||||
// Build photos
|
// Build photos
|
||||||
$.each(album.json.content, function() {
|
$.each(album.json.content, function() {
|
||||||
photosData += build.photo(this);
|
photosData += build.photo(this)
|
||||||
});
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save and reset scroll position
|
// Save and reset scroll position
|
||||||
view.albums.content.scrollPosition = $(document).scrollTop();
|
view.albums.content.scrollPosition = $(document).scrollTop()
|
||||||
requestAnimationFrame(() => $(document).scrollTop(0));
|
requestAnimationFrame(() => $(document).scrollTop(0))
|
||||||
|
|
||||||
// Add photos to view
|
// Add photos to view
|
||||||
lychee.content.html(photosData);
|
lychee.content.html(photosData)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
title: function(photoID) {
|
title: function(photoID) {
|
||||||
|
|
||||||
var title = album.json.content[photoID].title;
|
let title = album.json.content[photoID].title
|
||||||
|
|
||||||
$('.photo[data-id="' + photoID + '"] .overlay h1')
|
$('.photo[data-id="' + photoID + '"] .overlay h1')
|
||||||
.html(title)
|
.html(title)
|
||||||
.attr('title', title);
|
.attr('title', title)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
star: function(photoID) {
|
star: function(photoID) {
|
||||||
|
|
||||||
$('.photo[data-id="' + photoID + '"] .iconic-star').remove();
|
$('.photo[data-id="' + photoID + '"] .iconic-star').remove()
|
||||||
if (album.json.content[photoID].star==='1') $('.photo[data-id="' + photoID + '"]').append("<a class='badge iconic-star'>" + build.iconic('star') + "</a>");
|
if (album.json.content[photoID].star==='1') $('.photo[data-id="' + photoID + '"]').append("<a class='badge iconic-star'>" + build.iconic('star') + "</a>")
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
public: function(photoID) {
|
public: function(photoID) {
|
||||||
|
|
||||||
$('.photo[data-id="' + photoID + '"] .iconic-share').remove();
|
$('.photo[data-id="' + photoID + '"] .iconic-share').remove()
|
||||||
if (album.json.content[photoID].public==='1') $('.photo[data-id="' + photoID + '"]').append("<a class='badge iconic-share'>" + build.iconic('eye') + "</a>");
|
if (album.json.content[photoID].public==='1') $('.photo[data-id="' + photoID + '"]').append("<a class='badge iconic-share'>" + build.iconic('eye') + "</a>")
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
delete: function(photoID) {
|
delete: function(photoID) {
|
||||||
|
|
||||||
$('.photo[data-id="' + photoID + '"]').css('opacity', 0).animate({
|
$('.photo[data-id="' + photoID + '"]').css('opacity', 0).animate({
|
||||||
width: 0,
|
width : 0,
|
||||||
marginLeft: 0
|
marginLeft : 0
|
||||||
}, 300, function() {
|
}, 300, function() {
|
||||||
$(this).remove();
|
$(this).remove()
|
||||||
// Only when search is not active
|
// Only when search is not active
|
||||||
if (!visible.albums()) {
|
if (!visible.albums()) {
|
||||||
album.json.num--;
|
album.json.num--
|
||||||
view.album.num();
|
view.album.num()
|
||||||
view.album.title();
|
view.album.title()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,13 +205,13 @@ view.album = {
|
|||||||
|
|
||||||
description: function() {
|
description: function() {
|
||||||
|
|
||||||
sidebar.changeAttr('description', album.json.description);
|
sidebar.changeAttr('description', album.json.description)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
num: function() {
|
num: function() {
|
||||||
|
|
||||||
sidebar.changeAttr('images', album.json.num);
|
sidebar.changeAttr('images', album.json.num)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -222,53 +221,54 @@ view.album = {
|
|||||||
|
|
||||||
$('#button_share_album')
|
$('#button_share_album')
|
||||||
.addClass('active')
|
.addClass('active')
|
||||||
.attr('title', 'Share Album');
|
.attr('title', 'Share Album')
|
||||||
|
|
||||||
$('.photo .iconic-share').remove();
|
$('.photo .iconic-share').remove()
|
||||||
|
|
||||||
if (album.json.init) sidebar.changeAttr('public', 'Yes');
|
if (album.json.init) sidebar.changeAttr('public', 'Yes')
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$('#button_share_album')
|
$('#button_share_album')
|
||||||
.removeClass('active')
|
.removeClass('active')
|
||||||
.attr('title', 'Make Public');
|
.attr('title', 'Make Public')
|
||||||
|
|
||||||
|
if (album.json.init) sidebar.changeAttr('public', 'No')
|
||||||
|
|
||||||
if (album.json.init) sidebar.changeAttr('public', 'No');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
visible: function() {
|
visible: function() {
|
||||||
|
|
||||||
if (album.json.visible==='1') sidebar.changeAttr('visible', 'Yes');
|
if (album.json.visible==='1') sidebar.changeAttr('visible', 'Yes')
|
||||||
else sidebar.changeAttr('visible', 'No');
|
else sidebar.changeAttr('visible', 'No')
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
downloadable: function() {
|
downloadable: function() {
|
||||||
|
|
||||||
if (album.json.downloadable==='1') sidebar.changeAttr('downloadable', 'Yes');
|
if (album.json.downloadable==='1') sidebar.changeAttr('downloadable', 'Yes')
|
||||||
else sidebar.changeAttr('downloadable', 'No');
|
else sidebar.changeAttr('downloadable', 'No')
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
password: function() {
|
password: function() {
|
||||||
|
|
||||||
if (album.json.password==='1') sidebar.changeAttr('password', 'Yes');
|
if (album.json.password==='1') sidebar.changeAttr('password', 'Yes')
|
||||||
else sidebar.changeAttr('password', 'No');
|
else sidebar.changeAttr('password', 'No')
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
sidebar: function() {
|
sidebar: function() {
|
||||||
|
|
||||||
if ((visible.album()||!album.json.init)&&!visible.photo()) {
|
if ((visible.album() || !album.json.init) && !visible.photo()) {
|
||||||
|
|
||||||
let structure = sidebar.createStructure.album(album.json),
|
let structure = sidebar.createStructure.album(album.json),
|
||||||
html = sidebar.render(structure);
|
html = sidebar.render(structure)
|
||||||
|
|
||||||
sidebar.dom('.wrapper').html(html);
|
sidebar.dom('.wrapper').html(html)
|
||||||
sidebar.bind();
|
sidebar.bind()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,151 +280,161 @@ view.photo = {
|
|||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
|
||||||
photo.parse();
|
photo.parse()
|
||||||
|
|
||||||
view.photo.sidebar();
|
view.photo.sidebar()
|
||||||
view.photo.title();
|
view.photo.title()
|
||||||
view.photo.star();
|
view.photo.star()
|
||||||
view.photo.public();
|
view.photo.public()
|
||||||
view.photo.photo();
|
view.photo.photo()
|
||||||
|
|
||||||
photo.json.init = 1;
|
photo.json.init = 1
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function() {
|
show: function() {
|
||||||
|
|
||||||
// Change header
|
// Change header
|
||||||
lychee.content.addClass('view');
|
lychee.content.addClass('view')
|
||||||
header.setMode('photo');
|
header.setMode('photo')
|
||||||
|
|
||||||
// Make body not scrollable
|
// Make body not scrollable
|
||||||
$('body').css('overflow', 'hidden');
|
$('body').css('overflow', 'hidden')
|
||||||
|
|
||||||
// Fullscreen
|
// Fullscreen
|
||||||
$(document)
|
$(document)
|
||||||
.bind('mouseenter', header.show)
|
.bind('mouseenter', header.show)
|
||||||
.bind('mouseleave', header.hide);
|
.bind('mouseleave', header.hide)
|
||||||
|
|
||||||
lychee.animate(lychee.imageview, 'fadeIn');
|
lychee.animate(lychee.imageview, 'fadeIn')
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
hide: function() {
|
hide: function() {
|
||||||
|
|
||||||
header.show();
|
header.show()
|
||||||
|
|
||||||
lychee.content.removeClass('view');
|
lychee.content.removeClass('view')
|
||||||
header.setMode('album');
|
header.setMode('album')
|
||||||
|
|
||||||
// Make body scrollable
|
// Make body scrollable
|
||||||
$('body').css('overflow', 'auto');
|
$('body').css('overflow', 'auto')
|
||||||
|
|
||||||
// Disable Fullscreen
|
// Disable Fullscreen
|
||||||
$(document)
|
$(document)
|
||||||
.unbind('mouseenter')
|
.unbind('mouseenter')
|
||||||
.unbind('mouseleave');
|
.unbind('mouseleave')
|
||||||
|
|
||||||
// Hide Photo
|
// Hide Photo
|
||||||
lychee.animate(lychee.imageview, 'fadeOut');
|
lychee.animate(lychee.imageview, 'fadeOut')
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
lychee.imageview.hide();
|
lychee.imageview.hide()
|
||||||
view.album.sidebar();
|
view.album.sidebar()
|
||||||
}, 300);
|
}, 300)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
title: function() {
|
title: function() {
|
||||||
|
|
||||||
if (photo.json.init) sidebar.changeAttr('title', photo.json.title);
|
if (photo.json.init) sidebar.changeAttr('title', photo.json.title)
|
||||||
lychee.setTitle(photo.json.title, true);
|
lychee.setTitle(photo.json.title, true)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
description: function() {
|
description: function() {
|
||||||
|
|
||||||
if (photo.json.init) sidebar.changeAttr('description', photo.json.description);
|
if (photo.json.init) sidebar.changeAttr('description', photo.json.description)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
star: function() {
|
star: function() {
|
||||||
|
|
||||||
if (photo.json.star==1) {
|
if (photo.json.star==='1') {
|
||||||
|
|
||||||
// Starred
|
// Starred
|
||||||
$('#button_star')
|
$('#button_star')
|
||||||
.addClass('active')
|
.addClass('active')
|
||||||
.attr('title', 'Unstar Photo');
|
.attr('title', 'Unstar Photo')
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Unstarred
|
// Unstarred
|
||||||
$('#button_star').removeClass('active');
|
$('#button_star').removeClass('active')
|
||||||
$('#button_star').attr('title', 'Star Photo');
|
$('#button_star').attr('title', 'Star Photo')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
public: function() {
|
public: function() {
|
||||||
|
|
||||||
if (photo.json.public==='1'||photo.json.public==='2') {
|
if (photo.json.public==='1' || photo.json.public==='2') {
|
||||||
|
|
||||||
// Photo public
|
// Photo public
|
||||||
$('#button_share')
|
$('#button_share')
|
||||||
.addClass('active')
|
.addClass('active')
|
||||||
.attr('title', 'Share Photo');
|
.attr('title', 'Share Photo')
|
||||||
if (photo.json.init) sidebar.changeAttr('public', 'Yes');
|
|
||||||
|
if (photo.json.init) sidebar.changeAttr('public', 'Yes')
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Photo private
|
// Photo private
|
||||||
$('#button_share')
|
$('#button_share')
|
||||||
.removeClass('active')
|
.removeClass('active')
|
||||||
.attr('title', 'Make Public');
|
.attr('title', 'Make Public')
|
||||||
if (photo.json.init) sidebar.changeAttr('public', 'No');
|
|
||||||
|
if (photo.json.init) sidebar.changeAttr('public', 'No')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
tags: function() {
|
tags: function() {
|
||||||
|
|
||||||
sidebar.changeAttr('tags', build.tags(photo.json.tags));
|
sidebar.changeAttr('tags', build.tags(photo.json.tags))
|
||||||
sidebar.bind();
|
sidebar.bind()
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
photo: function() {
|
photo: function() {
|
||||||
|
|
||||||
lychee.imageview.html(build.imageview(photo.json, photo.getSize(), visible.header()));
|
lychee.imageview.html(build.imageview(photo.json, photo.getSize(), visible.header()))
|
||||||
|
|
||||||
var $nextArrow = lychee.imageview.find('a#next'),
|
let $nextArrow = lychee.imageview.find('a#next'),
|
||||||
$previousArrow = lychee.imageview.find('a#previous'),
|
$previousArrow = lychee.imageview.find('a#previous'),
|
||||||
hasNext = album.json&&album.json.content&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].nextPhoto==='',
|
hasNext = album.json && album.json.content && album.json.content[photo.getID()] && album.json.content[photo.getID()].nextPhoto==='',
|
||||||
hasPrevious = album.json&&album.json.content&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].previousPhoto==='';
|
hasPrevious = album.json && album.json.content && album.json.content[photo.getID()] && album.json.content[photo.getID()].previousPhoto===''
|
||||||
|
|
||||||
if (hasNext||lychee.viewMode) { $nextArrow.hide(); }
|
if (hasNext || lychee.viewMode) { $nextArrow.hide() }
|
||||||
else {
|
else {
|
||||||
|
|
||||||
var nextPhotoID = album.json.content[photo.getID()].nextPhoto,
|
let nextPhotoID = album.json.content[photo.getID()].nextPhoto,
|
||||||
nextPhoto = album.json.content[nextPhotoID];
|
nextPhoto = album.json.content[nextPhotoID]
|
||||||
|
|
||||||
$nextArrow.css('background-image', 'linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("' + nextPhoto.thumbUrl + '")');
|
$nextArrow.css('background-image', `linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("${ nextPhoto.thumbUrl }")`)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasPrevious||lychee.viewMode) { $previousArrow.hide(); }
|
if (hasPrevious || lychee.viewMode) { $previousArrow.hide() }
|
||||||
else {
|
else {
|
||||||
|
|
||||||
var previousPhotoID = album.json.content[photo.getID()].previousPhoto,
|
let previousPhotoID = album.json.content[photo.getID()].previousPhoto,
|
||||||
previousPhoto = album.json.content[previousPhotoID];
|
previousPhoto = album.json.content[previousPhotoID]
|
||||||
|
|
||||||
$previousArrow.css('background-image', 'linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("' + previousPhoto.thumbUrl + '")');
|
$previousArrow.css('background-image', `linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("${ previousPhoto.thumbUrl }")`)
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
sidebar: function() {
|
sidebar: function() {
|
||||||
|
|
||||||
var structure = sidebar.createStructure.photo(photo.json),
|
let structure = sidebar.createStructure.photo(photo.json),
|
||||||
html = sidebar.render(structure);
|
html = sidebar.render(structure)
|
||||||
|
|
||||||
sidebar.dom('.wrapper').html(html);
|
sidebar.dom('.wrapper').html(html)
|
||||||
sidebar.bind();
|
sidebar.bind()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,77 +3,73 @@
|
|||||||
* @copyright 2015 by Tobias Reich
|
* @copyright 2015 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var lychee = { content: $('#content') },
|
let lychee = { content: $('#content') },
|
||||||
loadingBar = { show() {}, hide() {} }
|
loadingBar = { show() {}, hide() {} }
|
||||||
imageview = $('#imageview');
|
imageview = $('#imageview')
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
// Event Name
|
// Event Name
|
||||||
var touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement),
|
let touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement),
|
||||||
eventName = (touchendSupport===true ? 'touchend' : 'click');
|
eventName = (touchendSupport===true ? 'touchend' : 'click')
|
||||||
|
|
||||||
// Set API error handler
|
// Set API error handler
|
||||||
api.onError = error;
|
api.onError = error
|
||||||
|
|
||||||
// Infobox
|
// Infobox
|
||||||
header.dom('#button_info').on(eventName, sidebar.toggle);
|
header.dom('#button_info').on(eventName, sidebar.toggle)
|
||||||
|
|
||||||
// Direct Link
|
// Direct Link
|
||||||
header.dom('#button_direct').on(eventName, function() {
|
header.dom('#button_direct').on(eventName, function() {
|
||||||
|
|
||||||
var link = $('#imageview #image').css('background-image').replace(/"/g,'').replace(/url\(|\)$/ig, '');
|
let link = $('#imageview #image').css('background-image').replace(/"/g,'').replace(/url\(|\)$/ig, '')
|
||||||
window.open(link, '_newtab');
|
window.open(link, '_newtab')
|
||||||
|
|
||||||
});
|
})
|
||||||
|
|
||||||
loadPhotoInfo(gup('p'));
|
loadPhotoInfo(gup('p'))
|
||||||
|
|
||||||
});
|
})
|
||||||
|
|
||||||
getPhotoSize = function(photo) {
|
const getPhotoSize = function(photo) {
|
||||||
|
|
||||||
// Size can be 'big', 'medium' or 'small'
|
// Size can be 'big', 'medium' or 'small'
|
||||||
// Default is big
|
// Default is big
|
||||||
// Small is centered in the middle of the screen
|
// Small is centered in the middle of the screen
|
||||||
var size = 'big',
|
let size = 'big',
|
||||||
scaled = false,
|
scaled = false,
|
||||||
hasMedium = photo.medium!=='',
|
hasMedium = photo.medium!=='',
|
||||||
pixelRatio = window.devicePixelRatio,
|
pixelRatio = window.devicePixelRatio,
|
||||||
view = {
|
view = {
|
||||||
width: $(window).width()-60,
|
width: $(window).width() - 60,
|
||||||
height: $(window).height()-100
|
height: $(window).height() - 100
|
||||||
};
|
}
|
||||||
|
|
||||||
// Detect if the photo will be shown scaled,
|
// Detect if the photo will be shown scaled,
|
||||||
// because the screen size is smaller than the photo
|
// because the screen size is smaller than the photo
|
||||||
if (photo.width>view.width||
|
if (photo.json.width>view.width || photo.json.height>view.height) scaled = true
|
||||||
photo.width>view.height) scaled = true;
|
|
||||||
|
|
||||||
// Calculate pixel ratio of screen
|
// Calculate pixel ratio of screen
|
||||||
if (pixelRatio!==undefined&&pixelRatio>1) {
|
if (pixelRatio!==undefined && pixelRatio>1) {
|
||||||
view.width = view.width * pixelRatio;
|
view.width = view.width * pixelRatio
|
||||||
view.height = view.height * pixelRatio;
|
view.height = view.height * pixelRatio
|
||||||
}
|
}
|
||||||
|
|
||||||
// Medium available and
|
// Medium available and
|
||||||
// Medium still bigger than screen
|
// Medium still bigger than screen
|
||||||
if (hasMedium===true&&
|
if (hasMedium===true && (1920>view.width && 1080>view.height)) size = 'medium'
|
||||||
(1920>view.width&&1080>view.height)) size = 'medium';
|
|
||||||
|
|
||||||
// Photo not scaled
|
// Photo not scaled
|
||||||
// Photo smaller then screen
|
// Photo smaller then screen
|
||||||
if (scaled===false&&
|
if (scaled===false && (photo.json.width<view.width&& photo.json.width<view.height)) size = 'small'
|
||||||
(photo.width<view.width&&
|
|
||||||
photo.width<view.height)) size = 'small';
|
|
||||||
|
|
||||||
return size;
|
return size
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPhotoInfo = function(photoID) {
|
const loadPhotoInfo = function(photoID) {
|
||||||
|
|
||||||
var params = {
|
let params = {
|
||||||
photoID,
|
photoID,
|
||||||
albumID: 0,
|
albumID: 0,
|
||||||
password: ''
|
password: ''
|
||||||
@ -81,50 +77,46 @@ loadPhotoInfo = function(photoID) {
|
|||||||
|
|
||||||
api.post('Photo::get', params, function(data) {
|
api.post('Photo::get', params, function(data) {
|
||||||
|
|
||||||
if (data==='Warning: Photo private!'||
|
if (data==='Warning: Photo private!' || data==='Warning: Wrong password!') {
|
||||||
data==='Warning: Wrong password!') {
|
|
||||||
|
|
||||||
$('body').append(build.no_content('question-mark'));
|
$('body').append(build.no_content('question-mark'))
|
||||||
$('body').removeClass('view');
|
$('body').removeClass('view')
|
||||||
header.dom().remove();
|
header.dom().remove()
|
||||||
return false;
|
return false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set title */
|
// Set title
|
||||||
|
if (!data.title) data.title = 'Untitled'
|
||||||
|
document.title = 'Lychee - ' + data.title
|
||||||
|
header.dom('#title').html(data.title)
|
||||||
|
|
||||||
if (!data.title) data.title = 'Untitled';
|
let size = getPhotoSize(data)
|
||||||
document.title = 'Lychee - ' + data.title;
|
|
||||||
header.dom('#title').html(data.title);
|
|
||||||
|
|
||||||
/* Render HTML */
|
// Render HTML
|
||||||
|
imageview.html(build.imageview(data, size, true))
|
||||||
|
imageview.find('.arrow_wrapper').remove()
|
||||||
|
imageview.addClass('fadeIn').show()
|
||||||
|
|
||||||
var size = getPhotoSize(data);
|
// Render Sidebar
|
||||||
|
let structure = sidebar.createStructure.photo(data),
|
||||||
|
html = sidebar.render(structure)
|
||||||
|
|
||||||
imageview.html(build.imageview(data, size, true));
|
sidebar.dom('.wrapper').html(html)
|
||||||
imageview.find('.arrow_wrapper').remove();
|
sidebar.bind()
|
||||||
imageview.addClass('fadeIn').show();
|
|
||||||
|
|
||||||
/* Render Sidebar */
|
})
|
||||||
|
|
||||||
var structure = sidebar.createStructure.photo(data),
|
|
||||||
html = sidebar.render(structure);
|
|
||||||
|
|
||||||
sidebar.dom('.wrapper').html(html);
|
|
||||||
sidebar.bind();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error = function(errorThrown, params, data) {
|
const error = function(errorThrown, params, data) {
|
||||||
|
|
||||||
console.error({
|
console.error({
|
||||||
description: errorThrown,
|
description : errorThrown,
|
||||||
params: params,
|
params : params,
|
||||||
response: data
|
response : data
|
||||||
});
|
})
|
||||||
|
|
||||||
loadingBar.show('error', errorThrown);
|
loadingBar.show('error', errorThrown)
|
||||||
|
|
||||||
}
|
}
|
@ -6,12 +6,12 @@
|
|||||||
visible = {}
|
visible = {}
|
||||||
|
|
||||||
visible.albums = function() {
|
visible.albums = function() {
|
||||||
if ($('#tools_albums').css('display')==='block') return true
|
if (header.dom('#tools_albums').css('display')==='block') return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
visible.album = function() {
|
visible.album = function() {
|
||||||
if ($('#tools_album').css('display')==='block') return true
|
if (header.dom('#tools_album').css('display')==='block') return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,6 @@ visible.sidebar = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
visible.sidebarbutton = function() {
|
visible.sidebarbutton = function() {
|
||||||
if (visible.albums()) return false
|
|
||||||
if (visible.photo()) return true
|
if (visible.photo()) return true
|
||||||
if (visible.album() && $('#button_info_album:visible').length>0) return true
|
if (visible.album() && $('#button_info_album:visible').length>0) return true
|
||||||
return false
|
return false
|
||||||
@ -43,13 +42,7 @@ visible.header = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
visible.message = function() {
|
visible.message = function() {
|
||||||
if ($('.message').length>0) return true
|
return basicModal.visible()
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
visible.signin = function() {
|
|
||||||
if ($('.message .sign_in').length>0) return true
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
visible.contextMenu = function() {
|
visible.contextMenu = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user