Improved post sizing, added [F]ullscreen hotkey

This commit is contained in:
Marcin Kurczewski 2015-03-13 09:29:26 +01:00
parent 65bc6705d3
commit eb3b02c28d
5 changed files with 72 additions and 32 deletions

View file

@ -1,24 +1,34 @@
.post-type-video video { .post-type-image .object-wrapper {
max-width: 100%;
}
.post-type-image .image-wrapper {
max-width: 100%; max-width: 100%;
position: relative; position: relative;
} }
.post-type-image .image-wrapper img { .post-type-image .object-wrapper img {
position: absolute; position: absolute;
top: 0;
left: 0;
width: 100%; width: 100%;
height: 100%;
} }
.post-type-youtube iframe { .post-type-youtube .object-wrapper {
width: 800px; max-width: 800px;
height: 600px; position: relative;
}
.post-type-youtube .object-wrapper .padding-fix {
padding-bottom: 75%;
}
.post-type-youtube .object-wrapper iframe {
position: absolute;
width: 100%;
height: 100%;
border: 0; border: 0;
} }
.post-type-video .object-wrapper {
max-width: 100%;
}
.post-type-video .object-wrapper video {
width: 100%;
}
#post-current-search-wrapper { #post-current-search-wrapper {
text-align: center; text-align: center;
} }

View file

@ -45,8 +45,8 @@ App.Presenters.PostContentPresenter = function(
} }
function updatePostNotesSize() { function updatePostNotesSize() {
$target.find('.post-notes-target').width($target.find('.image-wrapper').outerWidth()); $target.find('.post-notes-target').width($target.find('.object-wrapper').outerWidth());
$target.find('.post-notes-target').height($target.find('.image-wrapper').outerHeight()); $target.find('.post-notes-target').height($target.find('.object-wrapper').outerHeight());
} }
function addNewPostNote() { function addNewPostNote() {
@ -57,6 +57,7 @@ App.Presenters.PostContentPresenter = function(
init: init, init: init,
render: render, render: render,
addNewPostNote: addNewPostNote, addNewPostNote: addNewPostNote,
updatePostNotesSize: updatePostNotesSize,
}; };
}; };

View file

@ -134,6 +134,18 @@ App.Presenters.PostPresenter = function(
editButtonClicked(null); editButtonClicked(null);
}); });
keyboard.keyup('f', function() {
var $wrapper = $el.find('.object-wrapper');
if ($wrapper.data('full')) {
$wrapper.css({maxWidth: $wrapper.attr('data-width') + 'px', width: 'auto'});
$wrapper.data('full', false);
} else {
$wrapper.css({maxWidth: null, width: $wrapper.attr('data-width')});
$wrapper.data('full', true);
}
postContentPresenter.updatePostNotesSize();
});
attachSidebarEvents(); attachSidebarEvents();
attachLinksToPostsAround(); attachLinksToPostsAround();

View file

@ -64,6 +64,11 @@
<td>Go to newer/older page or post</td> <td>Go to newer/older page or post</td>
</tr> </tr>
<tr>
<td><code>[F]</code></td>
<td>Toggle full post size</td>
</tr>
<tr> <tr>
<td><code>[E]</code></td> <td><code>[E]</code></td>
<td>Edit post</td> <td>Edit post</td>

View file

@ -6,17 +6,25 @@
<% if (post.contentType === 'image') { %> <% if (post.contentType === 'image') { %>
<div class="image-wrapper" style="width: <%= post.imageWidth %>px"> <div
class="object-wrapper"
data-width="<%= post.imageWidth %>"
data-height="<%= post.imageWidth %>"
style="max-width: <%= post.imageWidth %>px">
<img alt="<%= post.name %>" src="<%= postContentUrl %>"/> <img alt="<%= post.name %>" src="<%= postContentUrl %>"/>
<div style="padding-top: calc(100% * <%= post.imageHeight %> / <%= post.imageWidth %>)"></div> <div class="padding-fix" style="padding-bottom: calc(100% * <%= post.imageHeight %> / <%= post.imageWidth %>)"></div>
</div> </div>
<% } else if (post.contentType === 'youtube') { %> <% } else if (post.contentType === 'youtube') { %>
<div class="object-wrapper">
<iframe src="//www.youtube.com/embed/<%= post.contentChecksum %>?wmode=opaque" allowfullscreen></iframe> <iframe src="//www.youtube.com/embed/<%= post.contentChecksum %>?wmode=opaque" allowfullscreen></iframe>
<div class="padding-fix"></div>
</div>
<% } else if (post.contentType === 'flash') { %> <% } else if (post.contentType === 'flash') { %>
<div class="object-wrapper">
<object <object
type="<%= post.contentMimeType %>" type="<%= post.contentMimeType %>"
width="<%= post.imageWidth %>" width="<%= post.imageWidth %>"
@ -25,8 +33,11 @@
<param name="wmode" value="opaque"/> <param name="wmode" value="opaque"/>
<param name="movie" value="<%= postContentUrl %>"/> <param name="movie" value="<%= postContentUrl %>"/>
</object> </object>
</div>
<% } else if (post.contentType === 'video') { %> <% } else if (post.contentType === 'video') { %>
<div class="object-wrapper">
<% if (post.flags.loop) { %> <% if (post.flags.loop) { %>
<video id="video" controls loop="loop"> <video id="video" controls loop="loop">
<% } else { %> <% } else { %>
@ -37,6 +48,7 @@
Your browser doesn't support HTML5 videos. Your browser doesn't support HTML5 videos.
</video> </video>
</div>
<% } else { console.log(new Error('Unknown post type')) } %> <% } else { console.log(new Error('Unknown post type')) } %>