2016-09-18 08:33:46 +00:00
|
|
|
<!DOCTYPE html5>
|
|
|
|
<html>
|
|
|
|
<head>
|
2016-11-07 02:00:30 +00:00
|
|
|
{% import "photo_card.html" as photo_card %}
|
2016-09-18 08:33:46 +00:00
|
|
|
{% import "header.html" as header %}
|
2017-03-11 01:08:38 +00:00
|
|
|
<title>Album {{album.display_name}}</title>
|
2016-09-18 08:33:46 +00:00
|
|
|
<meta charset="UTF-8">
|
|
|
|
<link rel="stylesheet" href="/static/common.css">
|
2017-04-23 04:38:23 +00:00
|
|
|
<script src="/static/common.js"></script>
|
2016-11-27 09:06:11 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
<style>
|
2016-12-14 21:26:42 +00:00
|
|
|
p
|
|
|
|
{
|
|
|
|
word-break: break-word;
|
|
|
|
}
|
2016-09-18 08:33:46 +00:00
|
|
|
#content_body
|
|
|
|
{
|
|
|
|
/* overriding common.css here */
|
|
|
|
display: block;
|
|
|
|
}
|
2017-04-23 04:38:23 +00:00
|
|
|
#title_editor,
|
|
|
|
#description_editor
|
|
|
|
{
|
|
|
|
width: 100%;
|
|
|
|
max-width: 800px;
|
|
|
|
}
|
2017-05-13 22:26:34 +00:00
|
|
|
#description_text
|
2017-04-23 04:38:23 +00:00
|
|
|
{
|
2017-05-13 22:26:34 +00:00
|
|
|
padding: 8px;
|
|
|
|
background-color: rgba(0, 0, 0, 0.1);
|
2017-04-23 04:38:23 +00:00
|
|
|
}
|
2017-05-13 22:26:34 +00:00
|
|
|
#description_editor textarea
|
2017-04-23 04:38:23 +00:00
|
|
|
{
|
2017-05-13 22:26:34 +00:00
|
|
|
width: 100%;
|
2017-04-23 04:38:23 +00:00
|
|
|
}
|
|
|
|
.hidden
|
|
|
|
{
|
|
|
|
display: none;
|
|
|
|
}
|
2016-09-18 08:33:46 +00:00
|
|
|
</style>
|
2016-11-27 09:06:11 +00:00
|
|
|
</head>
|
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
|
|
|
|
<body>
|
2016-12-18 13:12:14 +00:00
|
|
|
{{header.make_header(session=session)}}
|
2016-09-18 08:33:46 +00:00
|
|
|
<div id="content_body">
|
2017-04-23 04:38:23 +00:00
|
|
|
<h2>
|
|
|
|
{% if album.title %}
|
|
|
|
<span id="title_text">{{album.title}}</span>
|
|
|
|
{% else %}
|
|
|
|
<span id="title_text">Album {{album.id}}</span>
|
|
|
|
{% endif %}
|
|
|
|
<input id="title_editor" class="hidden" type="text" value="{{album.title}}" placeholder="title">
|
|
|
|
</h2>
|
|
|
|
|
2017-05-13 22:26:34 +00:00
|
|
|
<p id="description_text" {% if album.description == "" %}class="hidden"{% endif %}>{{album.description}}</p>
|
2017-04-23 04:38:23 +00:00
|
|
|
|
|
|
|
<div id="description_editor" class="hidden">
|
2017-05-13 22:26:34 +00:00
|
|
|
<textarea id="description_editor_box" rows="6" placeholder="description">{{album.description}}</textarea>
|
|
|
|
<div>
|
2017-05-06 04:17:13 +00:00
|
|
|
<button id="save_button" class="green_button" onclick="finish_editing(true)">Save</button>
|
|
|
|
<button id="cancel_button" class="red_button" onclick="finish_editing(false)">Cancel</button>
|
2017-05-13 22:26:34 +00:00
|
|
|
</div>
|
2017-05-06 04:17:13 +00:00
|
|
|
<span id="edit_submitting_spinner">Submitting...</span>
|
2017-04-23 04:38:23 +00:00
|
|
|
</div>
|
2017-05-13 22:26:34 +00:00
|
|
|
<button id="edit_button" class="green_button" onclick="start_editing()">edit</button>
|
2017-04-23 04:38:23 +00:00
|
|
|
|
2017-04-01 04:48:27 +00:00
|
|
|
{% set viewparam = "?view=list" if view == "list" else "" %}
|
2017-04-23 04:38:23 +00:00
|
|
|
{% set parent = album.parent() %}
|
2016-09-18 08:33:46 +00:00
|
|
|
{% if parent %}
|
2017-04-01 04:48:27 +00:00
|
|
|
<h3>Parent: <a href="/album/{{parent.id}}{{viewparam}}">{{parent.display_name}}</a></h3>
|
2016-11-06 00:58:37 +00:00
|
|
|
{% else %}
|
|
|
|
<h3>Parent: <a href="/albums">Albums</a></h3>
|
2016-09-18 08:33:46 +00:00
|
|
|
{% endif %}
|
2017-04-23 04:38:23 +00:00
|
|
|
|
2016-12-21 00:33:40 +00:00
|
|
|
{% set sub_albums = album.children() %}
|
|
|
|
{% if sub_albums %}
|
2016-09-18 08:33:46 +00:00
|
|
|
<h3>Sub-albums</h3>
|
|
|
|
<ul>
|
2017-02-05 02:30:02 +00:00
|
|
|
{% for sub_album in sub_albums|sort(attribute='title') %}
|
2017-04-01 04:48:27 +00:00
|
|
|
<li><a href="/album/{{sub_album.id}}{{viewparam}}">{{sub_album.display_name}}</a>
|
2016-09-18 08:33:46 +00:00
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
2017-04-23 04:38:23 +00:00
|
|
|
|
2016-12-24 03:49:51 +00:00
|
|
|
{% set photos = album.photos() %}
|
2017-04-23 04:38:23 +00:00
|
|
|
{% if photos or sub_albums %}
|
|
|
|
{% endif %}
|
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
{% if photos %}
|
2017-03-31 01:56:27 +00:00
|
|
|
<h3>Photos</h3>
|
|
|
|
{% if view != "list" %}
|
|
|
|
<a href="?view=list">List view</a>
|
|
|
|
{% else %}
|
|
|
|
<a href="?view=grid">Grid view</a>
|
|
|
|
{% endif %}
|
|
|
|
<ul>
|
2016-09-18 08:33:46 +00:00
|
|
|
{% for photo in photos %}
|
2017-03-31 01:56:27 +00:00
|
|
|
{{photo_card.create_photo_card(photo, view=view)}}
|
2016-09-18 08:33:46 +00:00
|
|
|
{% endfor %}
|
2017-03-31 01:56:27 +00:00
|
|
|
</ul>
|
2016-09-18 08:33:46 +00:00
|
|
|
{% endif %}
|
2017-05-13 22:25:31 +00:00
|
|
|
<p>
|
|
|
|
{% if photos or sub_albums %}
|
|
|
|
Download:
|
|
|
|
{% if photos %}
|
|
|
|
<a href="/album/{{album.id}}.zip?recursive=no">
|
|
|
|
These files ({{album.sum_bytes(recurse=False, string=True)}})
|
|
|
|
</a>
|
|
|
|
{% endif %}
|
|
|
|
{% if photos and sub_albums %}—{% endif %}
|
|
|
|
{% if sub_albums %}
|
|
|
|
<a href="/album/{{album.id}}.zip?recursive=yes">
|
|
|
|
Include children ({{album.sum_bytes(recurse=True, string=True)}})
|
|
|
|
</a>
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
</p>
|
2016-09-18 08:33:46 +00:00
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2017-04-23 04:38:23 +00:00
|
|
|
var edit_button = document.getElementById("edit_button");
|
|
|
|
var save_button = document.getElementById("save_button");
|
|
|
|
var cancel_button = document.getElementById("cancel_button");
|
|
|
|
|
|
|
|
var title_text = document.getElementById("title_text");
|
|
|
|
var title_editor = document.getElementById("title_editor");
|
|
|
|
var description_text = document.getElementById("description_text");
|
|
|
|
var description_editor = document.getElementById("description_editor");
|
|
|
|
var description_editor_box = document.getElementById("description_editor_box");
|
2017-05-06 04:17:13 +00:00
|
|
|
var edit_submitting_spinner = document.getElementById("edit_submitting_spinner");
|
2017-04-23 04:38:23 +00:00
|
|
|
|
|
|
|
bind_box_to_button(title_editor, save_button);
|
2017-05-13 22:26:34 +00:00
|
|
|
var ctrl_enter = true;
|
|
|
|
bind_box_to_button(description_editor_box, save_button, ctrl_enter);
|
2017-04-23 04:38:23 +00:00
|
|
|
|
2017-05-06 04:17:13 +00:00
|
|
|
var title_is_blank = {{ (album.title == '')|int }};
|
2017-04-23 04:38:23 +00:00
|
|
|
var blank_title_text = "Album {{album.id}}";
|
|
|
|
|
2016-10-21 03:15:24 +00:00
|
|
|
function submit_tag(callback)
|
|
|
|
{
|
2016-12-21 00:33:40 +00:00
|
|
|
add_photo_tag('{{album.id}}', add_tag_box.value, callback);
|
2016-10-21 03:15:24 +00:00
|
|
|
add_tag_box.value = "";
|
|
|
|
}
|
2017-04-23 04:38:23 +00:00
|
|
|
|
2017-05-06 04:17:13 +00:00
|
|
|
function show_editor()
|
2017-04-23 04:38:23 +00:00
|
|
|
{
|
|
|
|
edit_button.classList.add("hidden");
|
2017-05-06 04:17:13 +00:00
|
|
|
edit_submitting_spinner.classList.add("hidden");
|
|
|
|
|
2017-04-23 04:38:23 +00:00
|
|
|
title_text.classList.add("hidden");
|
|
|
|
title_editor.classList.remove("hidden");
|
2017-05-06 04:17:13 +00:00
|
|
|
|
2017-04-23 04:38:23 +00:00
|
|
|
description_text.classList.add("hidden");
|
|
|
|
description_editor.classList.remove("hidden");
|
2017-05-06 04:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_spinner()
|
|
|
|
{
|
|
|
|
edit_submitting_spinner.classList.remove("hidden");
|
|
|
|
}
|
|
|
|
|
|
|
|
function hide_editor()
|
|
|
|
{
|
|
|
|
edit_button.classList.remove("hidden");
|
|
|
|
edit_submitting_spinner.classList.add("hidden");
|
2017-04-23 04:38:23 +00:00
|
|
|
|
2017-05-06 04:17:13 +00:00
|
|
|
title_text.classList.remove("hidden");
|
|
|
|
title_editor.classList.add("hidden");
|
|
|
|
|
2017-05-13 22:26:34 +00:00
|
|
|
if (description_text.innerText !== "")
|
|
|
|
{
|
|
|
|
description_text.classList.remove("hidden");
|
|
|
|
}
|
2017-05-06 04:17:13 +00:00
|
|
|
description_editor.classList.add("hidden");
|
|
|
|
}
|
|
|
|
|
|
|
|
function start_editing()
|
|
|
|
{
|
2017-04-23 04:38:23 +00:00
|
|
|
if (title_is_blank)
|
|
|
|
{
|
|
|
|
title_editor.value = "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
title_editor.value = title_text.innerText;
|
|
|
|
}
|
2017-05-06 04:17:13 +00:00
|
|
|
show_editor();
|
2017-04-23 04:38:23 +00:00
|
|
|
title_editor.focus();
|
|
|
|
description_editor_box.value = description_text.innerText;
|
|
|
|
}
|
|
|
|
|
|
|
|
function finish_editing(do_save)
|
|
|
|
{
|
|
|
|
if (do_save === true)
|
|
|
|
{
|
|
|
|
var title = title_editor.value;
|
|
|
|
var description = description_editor_box.value;
|
2017-05-06 04:17:13 +00:00
|
|
|
|
|
|
|
var url = "/album/{{album.id}}/edit";
|
|
|
|
var data = new FormData();
|
|
|
|
data.append("title", title);
|
|
|
|
data.append("description", description);
|
|
|
|
|
|
|
|
show_spinner();
|
|
|
|
post(url, data, callback_edit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-06 06:04:33 +00:00
|
|
|
hide_editor();
|
2017-05-06 04:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function callback_edit(response)
|
|
|
|
{
|
|
|
|
console.log(response);
|
|
|
|
if (response["_status"] == 200)
|
|
|
|
{
|
|
|
|
if (response["title"] === "")
|
2017-04-23 04:38:23 +00:00
|
|
|
{
|
|
|
|
document.title = "Album {{album.id}}";
|
|
|
|
title_text.innerText = blank_title_text;
|
|
|
|
title_is_blank = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-06 04:17:13 +00:00
|
|
|
document.title = "Album " + response["title"];
|
|
|
|
title_text.innerText = response["title"];
|
2017-04-23 04:38:23 +00:00
|
|
|
title_is_blank = false;
|
|
|
|
}
|
2017-05-06 04:17:13 +00:00
|
|
|
description_text.innerText = response["description"];
|
|
|
|
hide_editor();
|
2017-04-23 04:38:23 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-27 09:06:11 +00:00
|
|
|
</script>
|
2017-04-23 04:38:23 +00:00
|
|
|
</html>
|