show actionbar pre-expand-blog

This commit is contained in:
zhaospei 2023-02-05 20:13:12 +07:00
parent d2405de7dd
commit 38d5c2cab1
4 changed files with 89 additions and 78 deletions

View file

@ -222,20 +222,26 @@
padding-bottom: 0; padding-bottom: 0;
} }
.pre-expand-blog::before { .show-more {
color: var(--color-accent-dark);
font-style: italic;
font-size: 16px;
font-weight: 700;
padding: 0px 12px;
margin-top: 5px;
position: absolute; position: absolute;
z-index: 1; inset: 50% 0px 60px;
top: 0; background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 1%, #f3f3f3 95%, #f3f3f3 100%);
left: 0; display: flex;
width: 100%; -webkit-box-pack: end;
height: 100%; justify-content: flex-end;
content: ""; align-items: flex-end;
background-image: -webkit-linear-gradient(bottom, gray, lightgray 3%, transparent 8%, transparent 100%); cursor: pointer;
border-radius: 8px; padding: 16px 16px;
} }
.pre-expand-blog:hover { .actionbar-box {
background-color: #f3f3f3; margin: 8px 16px;
} }
.post-full { .post-full {
@ -349,4 +355,4 @@
font-size: 2.5em; font-size: 2.5em;
} }
} }
} }

View file

@ -1,51 +1,54 @@
{% set logged_in = request.user.is_authenticated %} {% set logged_in = request.user.is_authenticated %}
{% set profile = request.profile if logged_in else None %} {% set profile = request.profile if logged_in else None %}
{% if logged_in %} {% if logged_in %}
{% if include_hr %}<hr>{% endif %} {% if include_hr %}
<div class="page-vote actionbar"> <hr>{% endif %}
<span class="actionbar-block" style="justify-content: flex-start;"> <div class="page-vote actionbar">
<span id="like-button-{{pagevote.id}}" <span class="actionbar-block" style="justify-content: flex-start;">
class="like-button actionbar-button {% if pagevote.vote_score(request.profile) == 1 %}voted{% endif %}" <span id="like-button-{{pagevote.id}}"
onclick="javascript:pagevote_upvote({{ pagevote.id }})" class="like-button actionbar-button {% if pagevote.vote_score(request.profile) == 1 %}voted{% endif %}"
> onclick="javascript:pagevote_upvote({{ pagevote.id }})">
<span class="pagevote-score" id="pagevote-score-{{pagevote.id}}">{{ pagevote.score }}</span> <span class="pagevote-score" id="pagevote-score-{{pagevote.id}}">{{ pagevote.score }}</span>
<i class="fa fa-thumbs-o-up" style="font-size: large;"></i> <i class="fa fa-thumbs-o-up" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Like")}}</span> <span class="actionbar-text">{{_("Like")}}</span>
</span>
<span id="dislike-button-{{pagevote.id}}" class="dislike-button actionbar-button {% if pagevote.vote_score(request.profile) == -1 %}voted{% endif %}" onclick="javascript:pagevote_downvote({{ pagevote.id }})">
<i class="fa fa-thumbs-o-down" style="font-size: large;"></i>
</span>
</span> </span>
{% if not hide_actionbar_comment %} <span id="dislike-button-{{pagevote.id}}"
<span class="actionbar-block"> class="dislike-button actionbar-button {% if pagevote.vote_score(request.profile) == -1 %}voted{% endif %}"
<span class="actionbar-button actionbar-comment"> onclick="javascript:pagevote_downvote({{ pagevote.id }})">
<i class="fa fa-comment-o" style="font-size: large;"></i> <i class="fa fa-thumbs-o-down" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Comment")}} {% if comment_list.count() %} ({{comment_list.count()}}) {% endif %}</span>
</span>
</span>
{% endif %}
<span class="actionbar-block">
<span id="bookmark-button-{{bookmark.id}}"
class="bookmark-button actionbar-button {% if bookmark.get_bookmark(request.profile) == True %} bookmarked {% endif %}"
onclick="javascript:bookmark({{ bookmark.id }})"
>
<i class="fa fa-bookmark-o" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Bookmark")}}</span>
</span>
</span> </span>
<span class="actionbar-block" > </span>
<span class="actionbar-button actionbar-share" style="position: relative" {{"share-url=" + share_url if share_url else ""}}> {% if not hide_actionbar_comment %}
<i class="fa fa-share" style="font-size: large;"></i> <span class="actionbar-block">
<span class="actionbar-text">{{_("Share")}}</span> <span class="actionbar-button actionbar-comment">
</span> <i class="fa fa-comment-o" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Comment")}} {% if comment_list.count() %} ({{comment_list.count()}}) {% endif
%}</span>
</span> </span>
{% if actionbar_report_url %} </span>
<span class="actionbar-block"> {% endif %}
<a class="actionbar-button black" href="{{actionbar_report_url}}"> <span class="actionbar-block">
<i class="fa fa-flag-o" style="font-size: large;"></i> <span id="bookmark-button-{{bookmark.id}}"
<span class="actionbar-text">{{_("Report")}}</span> class="bookmark-button actionbar-button {% if bookmark.get_bookmark(request.profile) == True %} bookmarked {% endif %}"
</a> onclick="javascript:bookmark({{ bookmark.id }})">
</span> <i class="fa fa-bookmark-o" style="font-size: large;"></i>
{% endif %} <span class="actionbar-text">{{_("Bookmark")}}</span>
</div> </span>
</span>
<span class="actionbar-block" style="justify-content: flex-end;">
<span class="actionbar-button actionbar-share" style="position: relative"
{{"share-url=" + share_url if share_url else ""}}>
<i class=" fa fa-share" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Share")}}</span>
</span>
</span>
{% if actionbar_report_url %}
<span class="actionbar-block">
<a class="actionbar-button black" href="{{actionbar_report_url}}">
<i class="fa fa-flag-o" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Report")}}</span>
</a>
</span>
{% endif %}
</div>
{% endif %} {% endif %}

View file

@ -2,26 +2,26 @@
<div style="margin-bottom: 0.5em"> <div style="margin-bottom: 0.5em">
<span class="time"> <span class="time">
{% with authors=post.authors.all() %} {% with authors=post.authors.all() %}
{%- if authors -%} {%- if authors -%}
<img src="{{gravatar(authors[0])}}" style="width: 1.5em; border-radius: 50%; margin-bottom: -0.3em"> <img src="{{gravatar(authors[0])}}" style="width: 1.5em; border-radius: 50%; margin-bottom: -0.3em">
<span class="post-authors">{{ link_users(authors) }}</span> <span class="post-authors">{{ link_users(authors) }}</span>
{%- endif -%} {%- endif -%}
{% endwith %} {% endwith %}
&#8226; &#8226;
{{ relative_time(post.publish_on, abs=_('on {time}'), rel=_('{time}')) -}} {{ relative_time(post.publish_on, abs=_('on {time}'), rel=_('{time}')) -}}
{%- if post.sticky %} &#8226; {%- if post.sticky %} &#8226;
<i title="Sticky" class="fa fa-star fa-fw"></i>{% endif -%} <i title="Sticky" class="fa fa-star fa-fw"></i>{% endif -%}
{% if post.is_organization_private and show_organization_private_icon %} {% if post.is_organization_private and show_organization_private_icon %}
&#8226; &#8226;
<span> <span>
{% for org in post.organizations.all() %} {% for org in post.organizations.all() %}
<span class="organization-tag" style="display: inherit;"> <span class="organization-tag" style="display: inherit;">
<a href="{{ org.get_absolute_url() }}"> <a href="{{ org.get_absolute_url() }}">
<i class="fa fa-lock"></i> {{ org.name }} <i class="fa fa-lock"></i> {{ org.name }}
</a> </a>
</span>
{% endfor %}
</span> </span>
{% endfor %}
</span>
{% endif %} {% endif %}
</span> </span>
<span style="float: right"> <span style="float: right">
@ -39,9 +39,12 @@
<div class="blog-description"> <div class="blog-description">
<div class="summary content-description"> <div class="summary content-description">
{% cache 86400 'post_summary' post.id %} {% cache 86400 'post_summary' post.id %}
{{ post.summary|default(post.content, true)|markdown(lazy_load=True)|reference|str|safe }} {{ post.summary|default(post.content, true)|markdown(lazy_load=True)|reference|str|safe }}
{% endcache %} {% endcache %}
</div> </div>
</div>
<div class="show-more"> {{_("...Xem thêm")}} </div>
<div class="actionbar-box">
{% set pagevote = post.pagevote %} {% set pagevote = post.pagevote %}
{% set bookmark = post.bookmark %} {% set bookmark = post.bookmark %}
{% set hide_actionbar_comment = True %} {% set hide_actionbar_comment = True %}

View file

@ -32,21 +32,20 @@
{% block js_media %} {% block js_media %}
<script type="text/javascript"> <script type="text/javascript">
function activateBlogBoxOnClick() { function activateBlogBoxOnClick() {
$('.blog-box').on('click', function () { $('.show-more').on('click', function () {
var $description = $(this).children('.blog-description'); var $description = $(this).parent().children('.blog-description');
var max_height = $description.css('max-height'); var max_height = $description.css('max-height');
if (max_height !== 'fit-content') { if (max_height !== 'fit-content') {
$description.css('max-height', 'fit-content'); $description.css('max-height', 'fit-content');
$(this).css('cursor', 'auto'); $(this).parent().css('cursor', 'auto');
$(this).removeClass('pre-expand-blog'); $(this).parent().removeClass('pre-expand-blog');
$(this).find('.actionbar').show(); console.log($(this).parent());
$(this).hide();
} }
}) })
$('.blog-box').each(function () { $('.blog-box').each(function () {
if ($(this).prop('scrollHeight') > $(this).height()) { if ($(this).prop('scrollHeight') > $(this).height()) {
$(this).addClass('pre-expand-blog'); $(this).addClass('pre-expand-blog');
$(this).css('cursor', 'pointer');
$(this).find('.actionbar').hide();
} }
}); });
} }