mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Improvements to appearance
This commit is contained in:
@ -51,6 +51,8 @@ App.Presenters.PostListPresenter = function(
|
||||
reinit(params, function() {});
|
||||
});
|
||||
});
|
||||
|
||||
jQuery(window).on('resize', windowResized);
|
||||
}
|
||||
|
||||
function reinit(params, loaded) {
|
||||
@ -61,6 +63,7 @@ App.Presenters.PostListPresenter = function(
|
||||
|
||||
function deinit() {
|
||||
pagerPresenter.deinit();
|
||||
jQuery(window).off('resize', windowResized);
|
||||
}
|
||||
|
||||
function render() {
|
||||
@ -80,6 +83,8 @@ App.Presenters.PostListPresenter = function(
|
||||
keyboard.keyup('q', function() {
|
||||
$searchInput.eq(0).focus().select();
|
||||
});
|
||||
|
||||
windowResized();
|
||||
}
|
||||
|
||||
function softRender() {
|
||||
@ -107,6 +112,7 @@ App.Presenters.PostListPresenter = function(
|
||||
softRenderPost($post);
|
||||
$target.append($post);
|
||||
});
|
||||
windowResized();
|
||||
}
|
||||
|
||||
function renderPost(post) {
|
||||
@ -136,6 +142,24 @@ App.Presenters.PostListPresenter = function(
|
||||
$post.find('.action button').text(_.contains(classes, 'tagged') ? 'Tagged' : 'Untagged').unbind('click').click(postTagButtonClicked);
|
||||
}
|
||||
|
||||
function windowResized() {
|
||||
var $list = $el.find('ul.posts');
|
||||
var $posts = $list.find('.post-small');
|
||||
var $firstPost = $posts.eq(0);
|
||||
var $lastPost = $firstPost;
|
||||
for (var i = 1; i < $posts.length; i ++) {
|
||||
$lastPost = $posts.eq(i-1);
|
||||
if ($posts.eq(i).offset().left < $lastPost.offset().left) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($firstPost.length === 0) {
|
||||
return;
|
||||
}
|
||||
$el.find('.search').css('margin-left', $firstPost.offset().left - $list.offset().left);
|
||||
$el.find('.search').css('margin-right', $list.width() - ($lastPost.offset().left - $list.offset().left + $lastPost.width()));
|
||||
}
|
||||
|
||||
function postTagButtonClicked(e) {
|
||||
e.preventDefault();
|
||||
var $post = jQuery(e.target).parents('li');
|
||||
|
Reference in New Issue
Block a user