2016-09-18 08:33:46 +00:00
|
|
|
<!DOCTYPE html5>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
{% import "header.html" as header %}
|
2017-06-14 04:42:23 +00:00
|
|
|
{% import "tag_object.html" as tag_object %}
|
2018-04-28 03:04:01 +00:00
|
|
|
<title>{{photo.basename}} | Photos</title>
|
2016-09-18 08:33:46 +00:00
|
|
|
<meta charset="UTF-8">
|
2017-07-21 06:10:48 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
2018-02-24 20:51:36 +00:00
|
|
|
<link rel="stylesheet" href="/static/css/common.css">
|
|
|
|
<script src="/static/js/common.js"></script>
|
2018-09-23 22:52:19 +00:00
|
|
|
<script src="/static/js/api.js"></script>
|
2018-07-20 05:42:21 +00:00
|
|
|
<script src="/static/js/hotkeys.js"></script>
|
2018-09-23 22:17:31 +00:00
|
|
|
<script src="/static/js/photo_clipboard.js"></script>
|
2018-07-23 01:17:39 +00:00
|
|
|
<script src="/static/js/tag_autocomplete.js"></script>
|
2016-11-27 09:06:11 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
<style>
|
|
|
|
#content_body
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
--narrow:0;
|
2016-09-18 08:33:46 +00:00
|
|
|
flex: 1;
|
2019-01-17 03:22:21 +00:00
|
|
|
grid-template:
|
|
|
|
"left right" 1fr
|
|
|
|
/ 310px 1fr;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
|
|
|
#left
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
grid-area: left;
|
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2018-10-22 01:46:27 +00:00
|
|
|
|
|
|
|
min-height: min-content;
|
|
|
|
|
|
|
|
background-color: var(--color_site_transparency);
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
|
|
|
#right
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
grid-area: right;
|
|
|
|
|
|
|
|
display: grid;
|
|
|
|
grid-template: "viewer" 1fr / 1fr;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
|
|
|
#editor_area
|
|
|
|
{
|
2017-06-14 04:35:13 +00:00
|
|
|
padding: 8px;
|
2017-03-04 06:30:57 +00:00
|
|
|
word-wrap: break-word;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2018-10-22 01:46:27 +00:00
|
|
|
#refresh_metadata_button
|
2017-06-14 04:35:13 +00:00
|
|
|
{
|
2018-10-22 01:46:27 +00:00
|
|
|
font-size: 11px;
|
|
|
|
}
|
|
|
|
#before_after_links
|
|
|
|
{
|
|
|
|
width: max-content;
|
|
|
|
margin: auto;
|
2017-06-14 04:35:13 +00:00
|
|
|
}
|
2016-09-18 08:33:46 +00:00
|
|
|
#message_area
|
|
|
|
{
|
2018-10-22 01:46:27 +00:00
|
|
|
display: flex;
|
2017-06-14 04:35:13 +00:00
|
|
|
|
2018-10-22 01:46:27 +00:00
|
|
|
min-height: 30px;
|
2017-06-14 04:35:13 +00:00
|
|
|
max-height: none;
|
2018-10-22 01:46:27 +00:00
|
|
|
margin: 8px;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
#photo_viewer
|
2016-09-18 08:33:46 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
grid-area: viewer;
|
|
|
|
display: grid;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
.photo_viewer_audio,
|
|
|
|
.photo_viewer_video,
|
|
|
|
.photo_viewer_application,
|
|
|
|
.photo_viewer_text
|
2016-09-18 08:33:46 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
justify-items: center;
|
2016-10-30 01:46:23 +00:00
|
|
|
align-items: center;
|
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
#photo_viewer audio,
|
|
|
|
#photo_viewer video
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2017-03-31 02:34:39 +00:00
|
|
|
width: 100%;
|
2016-10-10 03:50:13 +00:00
|
|
|
max-width: 100%;
|
2019-01-17 03:22:21 +00:00
|
|
|
max-height: 100%;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
.photo_viewer_image
|
2016-09-18 08:33:46 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
display: grid;
|
|
|
|
justify-items: center;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
max-height: 100%;
|
|
|
|
background-repeat: no-repeat;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
.photo_viewer_image img
|
2016-09-18 08:33:46 +00:00
|
|
|
{
|
|
|
|
max-height: 100%;
|
2019-01-17 03:22:21 +00:00
|
|
|
max-width: 100%;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
|
2017-03-08 05:01:50 +00:00
|
|
|
@media screen and (max-width: 800px)
|
|
|
|
{
|
|
|
|
#content_body
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
--narrow:1;
|
|
|
|
grid-template:
|
|
|
|
"right" 1fr
|
|
|
|
"left" 1fr;
|
2017-03-08 05:01:50 +00:00
|
|
|
}
|
|
|
|
#left
|
|
|
|
{
|
|
|
|
/*
|
2019-01-17 03:22:21 +00:00
|
|
|
Display: none will be returned back to flex as soon as the page detects
|
|
|
|
that the screen is in narrow mode and turns off the tag box's autofocus.
|
2017-03-08 05:01:50 +00:00
|
|
|
*/
|
|
|
|
display: none;
|
|
|
|
width: initial;
|
|
|
|
max-width: none;
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
#right
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
height: calc(100vh - 40px);
|
2017-03-08 05:01:50 +00:00
|
|
|
}
|
|
|
|
#message_area
|
|
|
|
{
|
|
|
|
flex: 2;
|
|
|
|
height: initial;
|
|
|
|
max-height: 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">
|
|
|
|
<div id="left">
|
|
|
|
<div id="editor_area">
|
|
|
|
<!-- TAG INFO -->
|
|
|
|
<h4>Tags</h4>
|
|
|
|
<ul id="this_tags">
|
2017-03-08 04:20:12 +00:00
|
|
|
<li>
|
2018-07-23 01:17:39 +00:00
|
|
|
<input id="add_tag_textbox" type="text" list="tag_autocomplete_datalist" autofocus>
|
2018-07-29 08:25:53 +00:00
|
|
|
<button id="add_tag_button" class="green_button" onclick="add_photo_tag_form('{{photo.id}}');">add</button>
|
2017-03-08 04:20:12 +00:00
|
|
|
</li>
|
2018-07-20 05:42:21 +00:00
|
|
|
{% set tags = photo.get_tags()|sort_tags %}
|
2016-12-21 00:33:40 +00:00
|
|
|
{% for tag in tags %}
|
2016-09-18 08:33:46 +00:00
|
|
|
<li>
|
2018-07-20 05:42:21 +00:00
|
|
|
{{tag_object.tag_object(tag, with_alt_description=True)}}<!--
|
2017-03-04 06:30:57 +00:00
|
|
|
--><button
|
2017-12-16 22:13:02 +00:00
|
|
|
class="remove_tag_button red_button"
|
2018-07-29 08:25:53 +00:00
|
|
|
onclick="remove_photo_tag_form('{{photo.id}}', '{{tag.name}}');">
|
2017-03-04 06:30:57 +00:00
|
|
|
</button>
|
2016-09-18 08:33:46 +00:00
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!-- METADATA & DOWNLOAD -->
|
2017-03-03 01:38:15 +00:00
|
|
|
<h4>
|
|
|
|
File info
|
2018-09-23 22:52:19 +00:00
|
|
|
<button id="refresh_metadata_button" class="green_button" onclick="refresh_metadata_form('{{photo.id}}');">refresh</button>
|
2017-03-03 01:38:15 +00:00
|
|
|
</h4>
|
2016-09-18 08:33:46 +00:00
|
|
|
<ul id="metadata">
|
2018-07-20 05:42:21 +00:00
|
|
|
<li>Filename: {{photo.basename}}</li>
|
|
|
|
{% set author = photo.get_author() %}
|
|
|
|
{% if author is not none %}
|
|
|
|
<li>Author: <a href="/user/{{author.username}}">{{author.display_name}}</a></li>
|
|
|
|
{% endif %}
|
|
|
|
{% if photo.width %}
|
|
|
|
<li title="{{photo.area}} px">Dimensions: {{photo.width}}x{{photo.height}} px</li>
|
|
|
|
<li>Aspect ratio: {{photo.ratio}}</li>
|
|
|
|
{% endif %}
|
|
|
|
<li>Size: {{photo.bytes|bytestring}}</li>
|
|
|
|
{% if photo.duration %}
|
|
|
|
<li>Duration: {{photo.duration_string}}</li>
|
|
|
|
<li>Overall Bitrate: {{photo.bitrate|int}} kbps</li>
|
|
|
|
{% endif %}
|
|
|
|
<li><a href="{{photo|file_link}}?download=true&original_filename=true">Download as original filename</a></li>
|
|
|
|
<li><a href="{{photo|file_link}}?download=true">Download as {{photo.id}}.{{photo.extension}}</a></li>
|
2016-09-18 08:33:46 +00:00
|
|
|
</ul>
|
|
|
|
|
2018-07-20 05:42:21 +00:00
|
|
|
<div>
|
2018-07-23 02:43:07 +00:00
|
|
|
<label class="photo_card" data-id="{{photo.id}}"><input type="checkbox" class="photo_card_selector_checkbox" onclick="photo_clipboard.on_photo_select(event)"/>Clipboard</label>
|
2018-07-20 05:42:21 +00:00
|
|
|
</div>
|
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
<!-- CONTAINING ALBUMS -->
|
2018-02-17 07:08:44 +00:00
|
|
|
{% set albums = photo.get_containing_albums() %}
|
2016-12-21 00:33:40 +00:00
|
|
|
{% if albums %}
|
2016-09-18 08:33:46 +00:00
|
|
|
<h4>Albums containing this photo</h4>
|
|
|
|
<ul id="containing albums">
|
2016-12-21 00:33:40 +00:00
|
|
|
{% for album in albums %}
|
2017-03-11 01:08:38 +00:00
|
|
|
<li><a href="/album/{{album.id}}">{{album.display_name}}</a></li>
|
2016-09-18 08:33:46 +00:00
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
2018-01-12 00:11:38 +00:00
|
|
|
{% endif %}
|
|
|
|
|
2018-10-22 01:46:27 +00:00
|
|
|
<div id="before_after_links">
|
2018-07-20 05:42:21 +00:00
|
|
|
<a href="/search?created=-{{photo.created}}">←Before</a>
|
|
|
|
<span> | </span>
|
|
|
|
<a href="/search?created={{photo.created}}-&orderby=created-asc">After→</a>
|
|
|
|
</div>
|
2016-09-18 08:33:46 +00:00
|
|
|
</div>
|
2018-10-22 01:46:27 +00:00
|
|
|
<div id="message_area"></div>
|
2016-09-18 08:33:46 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="right">
|
2016-10-30 01:46:23 +00:00
|
|
|
<!-- THE PHOTO ITSELF -->
|
2019-01-17 03:22:21 +00:00
|
|
|
<div id="photo_viewer" class="photo_viewer_{{photo.simple_mimetype}}" {%if photo.simple_mimetype == "image"%}onclick="toggle_hoverzoom(event)"{%endif%}>
|
2017-02-28 07:39:06 +00:00
|
|
|
{% if photo.simple_mimetype == "image" %}
|
2019-01-17 03:22:21 +00:00
|
|
|
<img src="{{photo|file_link}}" alt="{{photo.basename}}" onload="this.style.opacity=0.99">
|
|
|
|
|
2017-02-28 07:39:06 +00:00
|
|
|
{% elif photo.simple_mimetype == "video" %}
|
2019-01-17 03:22:21 +00:00
|
|
|
<video
|
|
|
|
src="{{photo|file_link}}"
|
|
|
|
controls
|
|
|
|
preload=none
|
|
|
|
{%if photo.thumbnail%}poster="/thumbnail/{{photo.id}}.jpg"{%endif%}
|
|
|
|
></video>
|
|
|
|
|
2017-02-28 07:39:06 +00:00
|
|
|
{% elif photo.simple_mimetype == "audio" %}
|
2018-04-20 02:29:06 +00:00
|
|
|
<audio src="{{photo|file_link}}" controls></audio>
|
2019-01-17 03:22:21 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
{% else %}
|
2018-04-20 02:29:06 +00:00
|
|
|
<a href="{{photo|file_link}}">View {{photo.basename}}</a>
|
2019-01-17 03:22:21 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
2016-11-27 09:06:11 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
2016-10-10 03:50:13 +00:00
|
|
|
var add_tag_box = document.getElementById('add_tag_textbox');
|
|
|
|
var add_tag_button = document.getElementById('add_tag_button');
|
2018-07-23 02:12:08 +00:00
|
|
|
add_tag_box.addEventListener("keyup", common.entry_with_history_hook);
|
|
|
|
common.bind_box_to_button(add_tag_box, add_tag_button, false);
|
2016-09-18 08:33:46 +00:00
|
|
|
|
2018-07-29 08:25:53 +00:00
|
|
|
var message_area = document.getElementById('message_area');
|
2017-05-06 06:02:42 +00:00
|
|
|
|
2018-07-29 08:25:53 +00:00
|
|
|
function add_photo_tag_form(photo_id)
|
|
|
|
{
|
|
|
|
var tagname = document.getElementById("add_tag_textbox").value;
|
|
|
|
if (tagname == "")
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-09-23 22:52:19 +00:00
|
|
|
api.photos.add_tag('{{photo.id}}', tagname, receive_callback);
|
2018-07-29 08:25:53 +00:00
|
|
|
add_tag_box.value = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_photo_tag_form(photo_id, tagname)
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
2018-09-23 22:52:19 +00:00
|
|
|
api.photos.remove_tag(photo_id, tagname, receive_callback);
|
2016-12-21 05:53:59 +00:00
|
|
|
}
|
2018-07-29 08:25:53 +00:00
|
|
|
|
2016-12-21 05:53:59 +00:00
|
|
|
function receive_callback(response)
|
|
|
|
{
|
2017-03-03 01:38:15 +00:00
|
|
|
var message_text;
|
|
|
|
var message_positivity;
|
2018-02-18 02:47:17 +00:00
|
|
|
var tagname = response["data"]["tagname"];
|
|
|
|
if ("error_type" in response["data"])
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
2016-12-21 09:11:50 +00:00
|
|
|
message_positivity = "message_negative";
|
2018-02-18 02:47:17 +00:00
|
|
|
message_text = response["data"]["error_message"];
|
2016-12-21 05:53:59 +00:00
|
|
|
}
|
2017-02-26 08:33:26 +00:00
|
|
|
else
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
2017-02-26 08:33:26 +00:00
|
|
|
var action;
|
2016-12-21 09:11:50 +00:00
|
|
|
message_positivity = "message_positive";
|
2018-02-18 02:47:17 +00:00
|
|
|
if (response["meta"]["request_url"].includes("add_tag"))
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
|
|
|
message_text = "Added tag " + tagname;
|
|
|
|
}
|
2018-02-18 02:47:17 +00:00
|
|
|
else if (response["meta"]["request_url"].includes("remove_tag"))
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
|
|
|
message_text = "Removed tag " + tagname;
|
|
|
|
}
|
2017-02-26 08:33:26 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-12-21 05:53:59 +00:00
|
|
|
}
|
2018-07-23 02:12:08 +00:00
|
|
|
common.create_message_bubble(message_area, message_positivity, message_text, 8000);
|
2016-12-21 05:53:59 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:52:19 +00:00
|
|
|
function refresh_metadata_form(photo_id)
|
2017-03-03 01:38:15 +00:00
|
|
|
{
|
2018-09-23 22:52:19 +00:00
|
|
|
api.photos.refresh_metadata(photo_id, common.refresh);
|
2017-03-03 01:38:15 +00:00
|
|
|
}
|
|
|
|
|
2018-05-02 04:03:10 +00:00
|
|
|
var ZOOM_BG_URL = "url('{{photo|file_link}}')";
|
2017-05-06 06:02:42 +00:00
|
|
|
function enable_hoverzoom(event)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2017-05-06 06:02:42 +00:00
|
|
|
//console.log("enable zoom");
|
2019-01-17 03:22:21 +00:00
|
|
|
var photo_viewer = document.getElementById("photo_viewer");
|
|
|
|
var photo_img = photo_viewer.children[0];
|
2017-05-06 06:02:42 +00:00
|
|
|
if (
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_img.naturalWidth < photo_viewer.offsetWidth &&
|
|
|
|
photo_img.naturalHeight < photo_viewer.offsetHeight
|
2017-05-06 06:02:42 +00:00
|
|
|
)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-05-06 06:02:42 +00:00
|
|
|
photo_img.style.opacity = "0";
|
|
|
|
photo_img.style.display = "none";
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_viewer.style.cursor = "zoom-out";
|
|
|
|
photo_viewer.style.backgroundImage = ZOOM_BG_URL;
|
|
|
|
photo_viewer.onmousemove = move_hoverzoom;
|
2017-05-06 06:02:42 +00:00
|
|
|
move_hoverzoom(event)
|
2016-10-30 01:46:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
function disable_hoverzoom()
|
|
|
|
{
|
2017-05-06 06:02:42 +00:00
|
|
|
//console.log("disable zoom");
|
2019-01-17 03:22:21 +00:00
|
|
|
var photo_viewer = document.getElementById("photo_viewer");
|
|
|
|
var photo_img = photo_viewer.children[0];
|
2018-07-29 08:25:53 +00:00
|
|
|
|
2017-05-06 06:02:42 +00:00
|
|
|
photo_img.style.opacity = "100";
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_viewer.style.cursor = "";
|
2017-05-06 06:02:42 +00:00
|
|
|
photo_img.style.display = "";
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_viewer.style.backgroundImage = "none";
|
|
|
|
photo_viewer.onmousemove = null;
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2018-07-28 23:16:16 +00:00
|
|
|
function toggle_hoverzoom(event)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
var photo_img = document.getElementById("photo_viewer").children[0];
|
2017-05-06 06:02:42 +00:00
|
|
|
if (photo_img.style.opacity === "0")
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
|
|
|
disable_hoverzoom();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-06 06:02:42 +00:00
|
|
|
enable_hoverzoom(event);
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2018-07-29 08:25:53 +00:00
|
|
|
var content_body = document.getElementById('content_body');
|
2019-01-17 03:22:21 +00:00
|
|
|
if (getComputedStyle(content_body).getPropertyValue("--narrow") == 0)
|
2017-04-21 01:38:14 +00:00
|
|
|
{
|
|
|
|
add_tag_box.focus();
|
|
|
|
}
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2016-11-27 09:06:11 +00:00
|
|
|
|
2016-10-30 01:46:23 +00:00
|
|
|
function move_hoverzoom(event)
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
var photo_viewer = document.getElementById("photo_viewer");
|
|
|
|
var photo_img = photo_viewer.children[0];
|
2016-10-30 01:46:23 +00:00
|
|
|
var x;
|
|
|
|
var y;
|
2016-12-21 05:33:14 +00:00
|
|
|
|
2017-05-06 06:02:42 +00:00
|
|
|
/*
|
|
|
|
When clicking on the image, the event handler takes the image as the event
|
|
|
|
target even though the handler was assigned to the holder. The coordinates
|
|
|
|
for the zoom need to be based on the holder, so when this happens we need
|
|
|
|
to adjust the numbers.
|
|
|
|
I'm not sure why the offset is the holder's offsetLeft. It seems that when
|
|
|
|
the event triggers on the holder, the event X is based on its bounding box,
|
|
|
|
but when it triggers on the image it's based on the viewport.
|
|
|
|
*/
|
2016-11-27 09:06:11 +00:00
|
|
|
var mouse_x = event.offsetX;
|
2017-05-06 06:02:42 +00:00
|
|
|
var mouse_y = event.offsetY;
|
2019-01-17 03:22:21 +00:00
|
|
|
if (event.target !== photo_viewer)
|
2017-05-06 06:02:42 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_x -= photo_viewer.offsetLeft;
|
|
|
|
mouse_y -= photo_viewer.offsetTop;
|
2017-05-06 06:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Adding 5% to perceived position gives us a bit of padding around the image,
|
|
|
|
so you don't need to navigate a 1px line to see the edge.
|
|
|
|
We first subtract half of the image dimensions so that the 5% is applied
|
|
|
|
to both left and right. Otherwise 105% of 0 is still 0 which doesn't
|
|
|
|
apply padding on the left.
|
|
|
|
*/
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_x -= (photo_viewer.offsetWidth / 2);
|
2016-11-27 09:06:11 +00:00
|
|
|
mouse_x *= 1.05;
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_x += (photo_viewer.offsetWidth / 2);
|
2016-12-21 05:33:14 +00:00
|
|
|
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_y -= (photo_viewer.offsetHeight / 2);
|
2016-11-27 09:06:11 +00:00
|
|
|
mouse_y *= 1.05;
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_y += (photo_viewer.offsetHeight / 2);
|
2016-12-21 05:33:14 +00:00
|
|
|
|
2019-01-17 03:22:21 +00:00
|
|
|
if (photo_img.naturalWidth < photo_viewer.offsetWidth)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2016-12-21 05:33:14 +00:00
|
|
|
// If the image is smaller than the frame, just center it
|
2019-01-17 03:22:21 +00:00
|
|
|
x = (photo_img.naturalWidth - photo_viewer.offsetWidth) / 2;
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-21 05:33:14 +00:00
|
|
|
// Take the amount of movement necessary (frame width - image width)
|
|
|
|
// times our distance across the image as a percentage.
|
2019-01-17 03:22:21 +00:00
|
|
|
x = (photo_img.naturalWidth - photo_viewer.offsetWidth) * (mouse_x / photo_viewer.offsetWidth);
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2016-12-21 05:33:14 +00:00
|
|
|
|
2019-01-17 03:22:21 +00:00
|
|
|
if (photo_img.naturalHeight < photo_viewer.offsetHeight)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
y = (photo_img.naturalHeight - photo_viewer.offsetHeight) / 2;
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
y = (photo_img.naturalHeight - photo_viewer.offsetHeight) * (mouse_y / photo_viewer.offsetHeight);
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
|
|
|
//console.log(x);
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_viewer.style.backgroundPosition=(-x)+"px "+(-y)+"px";
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2017-02-25 06:07:59 +00:00
|
|
|
|
2018-07-23 01:17:39 +00:00
|
|
|
tag_autocomplete.init_datalist();
|
|
|
|
|
2017-02-25 06:07:59 +00:00
|
|
|
setTimeout(
|
|
|
|
/*
|
|
|
|
When the screen is in column mode, the autofocusing of the tag box snaps the
|
|
|
|
screen down to it, which is annoying. By starting the #left hidden, we have
|
|
|
|
an opportunity to unset the autofocus before showing it.
|
|
|
|
*/
|
|
|
|
function()
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
var content_body = document.getElementById("content_body");
|
|
|
|
if (getComputedStyle(content_body).getPropertyValue("--narrow") == 1)
|
2017-02-25 06:07:59 +00:00
|
|
|
{
|
|
|
|
add_tag_box.autofocus = false;
|
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
document.getElementById("left").style.display = "flex";
|
2017-02-25 06:07:59 +00:00
|
|
|
},
|
|
|
|
0
|
|
|
|
);
|
2016-11-27 09:06:11 +00:00
|
|
|
</script>
|
|
|
|
</html>
|