Browse Source

New function to create the sidebar album structure

Tobias Reich 10 years ago
parent
commit
7ed822be57
5 changed files with 94 additions and 100 deletions
  1. 0 0
      dist/main.js
  2. 0 0
      dist/view.js
  3. 0 99
      src/scripts/build.js
  4. 88 0
      src/scripts/sidebar.js
  5. 6 1
      src/scripts/view.js

File diff suppressed because it is too large
+ 0 - 0
dist/main.js


File diff suppressed because it is too large
+ 0 - 0
dist/view.js


+ 0 - 99
src/scripts/build.js

@@ -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;
-
 }

+ 88 - 0
src/scripts/sidebar.js

@@ -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;

+ 6 - 1
src/scripts/view.js

@@ -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();
+
 		}
 
 	}

Some files were not shown because too many files changed in this diff