New function to create the sidebar album structure

pull/331/head
Tobias Reich 9 years ago
parent 5c71fc3727
commit 7ed822be57

12
dist/main.js vendored

File diff suppressed because one or more lines are too long

6
dist/view.js vendored

File diff suppressed because one or more lines are too long

@ -265,103 +265,4 @@ build.tags = function(tags) {
return html;
}
build.sidebarAlbum = function(data, forView = false) {
var html = '',
visible = '',
password = '',
downloadable = '',
editTitleHTML = '',
editDescriptionHTML = '',
infos = [];
switch (data.public) {
case '0': visible = 'No';
break;
case '1': visible = 'Yes';
break;
default: visible = '-';
break;
}
switch (data.password) {
case '0': password = 'No';
break;
case '1': password = 'Yes';
break;
default: password = '-';
break;
}
switch (data.downloadable) {
case '0': downloadable = 'No';
break;
case '1': downloadable = 'Yes';
break;
default: downloadable = '-';
break;
}
if (forView===false&&lychee.publicMode===false) {
editTitleHTML = ' ' + build.editIcon('edit_title');
editDescriptionHTML = ' ' + build.editIcon('edit_description');
}
infos = [
['', 'Basics'],
['Title', data.title + editTitleHTML],
['Description', data.description + editDescriptionHTML],
['', 'Album'],
['Created', data.sysdate],
['Images', data.num],
['', 'Share'],
['Public', visible],
['Downloadable', downloadable],
['Password', password]
]
infos.forEach(function(info, i, items) {
// Set default for empty values
if (info[1]===''||info[1]===null||info[1]===undefined) info[1] = '-';
if (info[0]==='') {
// Divider
html += `
</table>
<div class='divider'>
<h1>${ info[1] }</h1>
</div>
<table id='infos'>
`
} else {
// Item
html += `
<tr>
<td>${ info[0] }</td>
<td class='attr_${ info[0].toLowerCase() }'>${ info[1] }</td>
</tr>
`
}
});
html += `
</table>
`
return html;
}

@ -212,6 +212,94 @@ sidebar.createStructure.photo = function(data) {
}
sidebar.createStructure.album = function(data) {
if (data===undefined||data===null||data==='') return false;
var editable = false,
structure = {},
visible = '',
password = '',
downloadable = '';
// Enable editable when user logged in
if (lychee.publicMode===false) editable = true;
// Set value for public
switch (data.public) {
case '0': visible = 'No';
break;
case '1': visible = 'Yes';
break;
default: visible = '-';
break;
}
// Set value for password
switch (data.password) {
case '0': password = 'No';
break;
case '1': password = 'Yes';
break;
default: password = '-';
break;
}
// Set value for downloadable
switch (data.downloadable) {
case '0': downloadable = 'No';
break;
case '1': downloadable = 'Yes';
break;
default: downloadable = '-';
break;
}
structure.basics = {
title: 'Basics',
type: sidebar.types.DEFAULT,
rows: [
{ title: 'Title', value: data.title, editable },
{ title: 'Description', value: data.description, editable }
]
}
structure.album = {
title: 'Album',
type: sidebar.types.DEFAULT,
rows: [
{ title: 'Created', value: data.sysdate },
{ title: 'Images', value: data.num }
]
}
structure.share = {
title: 'Share',
type: sidebar.types.DEFAULT,
rows: [
{ title: 'Public', value: visible },
{ title: 'Downloadable', value: downloadable },
{ title: 'Password', value: password }
]
}
// Construct all parts of the structure
structure = [
structure.basics,
structure.album,
structure.share
]
return structure;
}
sidebar.render = function(structure) {
if (structure===undefined||structure===null||structure==='') return false;

@ -266,8 +266,13 @@ view.album = {
sidebar: function() {
if ((visible.album()||!album.json.init)&&!visible.photo()) {
sidebar.dom('.wrapper').html(build.sidebarAlbum(album.json));
let structure = sidebar.createStructure.album(album.json),
html = sidebar.render(structure);
sidebar.dom('.wrapper').html(html);
sidebar.bind();
}
}

Loading…
Cancel
Save