2015-01-31 21:29:31 +00:00
|
|
|
/**
|
|
|
|
* @description This module is used to generate HTML-Code.
|
2015-02-01 21:08:37 +00:00
|
|
|
* @copyright 2015 by Tobias Reich
|
2015-01-31 21:29:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
window.build = {}
|
|
|
|
|
2015-01-31 23:25:31 +00:00
|
|
|
build.iconic = function(icon, classes, file) {
|
2015-01-31 21:29:31 +00:00
|
|
|
|
2015-01-31 23:25:31 +00:00
|
|
|
var html = '',
|
|
|
|
path = 'src/images/';
|
2015-01-31 21:29:31 +00:00
|
|
|
|
2015-01-31 23:25:31 +00:00
|
|
|
file = file || 'iconic';
|
2015-01-31 21:29:31 +00:00
|
|
|
classes = classes || '';
|
|
|
|
|
|
|
|
html = `
|
|
|
|
<svg viewBox='0 0 8 8' class='iconic ${ classes }'>
|
2015-01-31 23:25:31 +00:00
|
|
|
<use xlink:href='${ path }${ file }.svg#${ icon }' />
|
2015-01-31 21:29:31 +00:00
|
|
|
</svg>
|
|
|
|
`
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build.divider = function(title) {
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
html = `
|
|
|
|
<div class='divider fadeIn'>
|
|
|
|
<h1>${ title }</h1>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build.editIcon = function(id) {
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
html = `<div id='${ id }' class='edit'>${ build.iconic('pencil') }</div>`
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build.multiselect = function(top, left) {
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
html = `<div id='multiselect' style='top: ${ top }px; left: ${ left }px;'></div>`
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build.album = function(data) {
|
|
|
|
|
|
|
|
if (data===null||data===undefined) return '';
|
|
|
|
|
|
|
|
var html = '',
|
|
|
|
title = data.title,
|
|
|
|
longTitle = '',
|
|
|
|
typeThumb = '';
|
|
|
|
|
|
|
|
if (title!==null&&title.length>18) {
|
|
|
|
|
|
|
|
title = data.title.substr(0, 18) + '...';
|
|
|
|
longTitle = data.title;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-03-12 11:57:48 +00:00
|
|
|
if (data.thumbs[0].split('.').pop()==='svg') typeThumb = 'nonretina';
|
2015-01-31 21:29:31 +00:00
|
|
|
|
|
|
|
html = `
|
2015-02-28 22:37:35 +00:00
|
|
|
<div class='album' data-id='${ data.id }'>
|
2015-03-12 11:57:48 +00:00
|
|
|
<img src='${ data.thumbs[2] }' width='200' height='200' alt='thumb' data-type='nonretina'>
|
|
|
|
<img src='${ data.thumbs[1] }' width='200' height='200' alt='thumb' data-type='nonretina'>
|
|
|
|
<img src='${ data.thumbs[0] }' width='200' height='200' alt='thumb' data-type='${ typeThumb }'>
|
2015-01-31 21:29:31 +00:00
|
|
|
<div class='overlay'>
|
2015-02-22 20:52:42 +00:00
|
|
|
<h1 title='${ longTitle }'>${ title }</h1>
|
|
|
|
<a>${ data.sysdate }</a>
|
2015-01-31 21:29:31 +00:00
|
|
|
</div>
|
|
|
|
`
|
|
|
|
|
|
|
|
if (lychee.publicMode===false) {
|
|
|
|
|
|
|
|
if (data.star==='1') html += `<a class='badge icn-star'>${ build.iconic('star') }</a>`;
|
|
|
|
if (data.public==='1') html += `<a class='badge icn-share'>${ build.iconic('eye') }</a>`;
|
|
|
|
if (data.unsorted==='1') html += `<a class='badge'>${ build.iconic('list') }</a>`;
|
|
|
|
if (data.recent==='1') html += `<a class='badge'>${ build.iconic('clock') }</a>`;
|
2015-02-27 20:16:22 +00:00
|
|
|
if (data.password==='1') html += `<a class='badge'>${ build.iconic('lock-locked') }</a>`;
|
2015-01-31 21:29:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
html += '</div>'
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build.photo = function(data) {
|
|
|
|
|
|
|
|
if (data===null||data===undefined) return '';
|
|
|
|
|
|
|
|
var html = '',
|
|
|
|
title = data.title,
|
|
|
|
longTitle = '';
|
|
|
|
|
|
|
|
if (title!==null&&title.length>18) {
|
|
|
|
|
|
|
|
title = data.title.substr(0, 18) + '...';
|
|
|
|
longTitle = data.title;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
html = `
|
|
|
|
<div class='photo' data-album-id='${ data.album }' data-id='${ data.id }'>
|
|
|
|
<img src='${ data.thumbUrl }' width='200' height='200' alt='thumb'>
|
|
|
|
<div class='overlay'>
|
|
|
|
<h1 title='${ longTitle }'>${ title }</h1>
|
|
|
|
`
|
|
|
|
|
2015-03-11 23:11:16 +00:00
|
|
|
if (data.cameraDate==='1') html += `<a><span title='Camera Date'>${ build.iconic('camera-slr') }</span>${ data.sysdate }</a>`;
|
2015-01-31 21:29:31 +00:00
|
|
|
else html += `<a>${ data.sysdate }</a>`;
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
2015-01-31 23:25:31 +00:00
|
|
|
if (lychee.publicMode===false) {
|
|
|
|
|
|
|
|
if (data.star==='1') html += `<a class='badge iconic-star'>${ build.iconic('star') }</a>`;
|
|
|
|
if (data.public==='1'&&album.json.public!=='1') html += `<a class='badge iconic-share'>${ build.iconic('eye') }</a>`;
|
2015-01-31 21:29:31 +00:00
|
|
|
|
2015-01-31 23:25:31 +00:00
|
|
|
}
|
2015-01-31 21:29:31 +00:00
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
return html
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build.imageview = function(data, size, visibleControls) {
|
|
|
|
|
|
|
|
if (data===null||data===undefined) return '';
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
html = `
|
|
|
|
<div class='arrow_wrapper arrow_wrapper--previous'><a id='previous'>${ build.iconic('caret-left') }</a></div>
|
|
|
|
<div class='arrow_wrapper arrow_wrapper--next'><a id='next'>${ build.iconic('caret-right') }</a></div>
|
|
|
|
`
|
|
|
|
|
|
|
|
if (size==='big') {
|
|
|
|
|
|
|
|
if (visibleControls===true)
|
|
|
|
html += `<div id='image' style='background-image: url(${ data.url })'></div>`;
|
|
|
|
else
|
|
|
|
html += `<div id='image' style='background-image: url(${ data.url });' class='full'></div>`;
|
|
|
|
|
|
|
|
} else if (size==='medium') {
|
|
|
|
|
|
|
|
if (visibleControls===true)
|
|
|
|
html += `<div id='image' style='background-image: url(${ data.medium })'></div>`;
|
|
|
|
else
|
|
|
|
html += `<div id='image' style='background-image: url(${ data.medium });' class='full'></div>`;
|
|
|
|
|
|
|
|
} else if (size==='small') {
|
|
|
|
|
|
|
|
if (visibleControls===true)
|
|
|
|
html += `<div id='image' class='small' style='background-image: url(${ data.url }); width: ${ data.width }px; height: ${ data.height }px; margin-top: -${ parseInt(data.height/2-20) }px; margin-left: -${ data.width/2 }px;'></div>`;
|
|
|
|
else
|
|
|
|
html += `<div id='image' class='small' style='background-image: url(${ data.url }); width: ${ data.width }px; height: ${ data.height }px; margin-top: -${ parseInt(data.height/2) }px; margin-left: -${ data.width/2 }px;'></div>`;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build.no_content = function(typ) {
|
|
|
|
|
|
|
|
var html;
|
|
|
|
|
|
|
|
html = `
|
|
|
|
<div class='no_content fadeIn'>
|
2015-01-31 23:25:31 +00:00
|
|
|
${ build.iconic(typ) }
|
2015-01-31 21:29:31 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
switch (typ) {
|
2015-01-31 23:25:31 +00:00
|
|
|
case 'magnifying-glass': html += '<p>No results</p>';
|
|
|
|
break;
|
|
|
|
case 'eye': html += '<p>No public albums</p>';
|
|
|
|
break;
|
|
|
|
case 'cog': html += '<p>No configuration</p>';
|
|
|
|
break;
|
2015-01-31 21:29:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build.uploadModal = function(title, files) {
|
|
|
|
|
|
|
|
var html = '',
|
|
|
|
i = 0,
|
|
|
|
file = null;
|
|
|
|
|
|
|
|
html = `
|
|
|
|
<h1>${ title }</h1>
|
|
|
|
<div class='rows'>
|
|
|
|
`
|
|
|
|
|
|
|
|
while (i<files.length) {
|
|
|
|
|
|
|
|
file = files[i];
|
|
|
|
|
|
|
|
if (file.name.length>40) file.name = file.name.substr(0, 17) + '...' + file.name.substr(file.name.length-20, 20);
|
|
|
|
|
|
|
|
html += `
|
|
|
|
<div class='row'>
|
|
|
|
<a class='name'>${ lychee.escapeHTML(file.name) }</a>
|
|
|
|
`
|
|
|
|
|
|
|
|
if (file.supported===true) html += `<a class='status'></a>`;
|
|
|
|
else html += `<a class='status error'>Not supported</a>`;
|
|
|
|
|
|
|
|
html += `
|
|
|
|
<p class='notice'></p>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-03-15 14:10:28 +00:00
|
|
|
build.tags = function(tags) {
|
2015-01-31 21:29:31 +00:00
|
|
|
|
|
|
|
var html = '',
|
|
|
|
editTagsHTML = '';
|
|
|
|
|
|
|
|
if (tags!=='') {
|
|
|
|
|
|
|
|
tags = tags.split(',');
|
|
|
|
|
|
|
|
tags.forEach(function(tag, index, array) {
|
2015-01-31 23:25:31 +00:00
|
|
|
html += `<a class='tag'>${ tag }<span data-index='${ index }'>${ build.iconic('x') }</span></a>`
|
2015-01-31 21:29:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2015-03-15 14:10:28 +00:00
|
|
|
html = `<div class='empty'>No Tags</div>`;
|
2015-01-31 21:29:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
}
|