fix actionbar pre-expand-blog

This commit is contained in:
zhaospei 2023-02-04 20:14:50 +07:00
parent d59828df1c
commit 8c135a5396

View file

@ -3,129 +3,134 @@
{% block title_ruler %}{% endblock %} {% block title_ruler %}{% endblock %}
{% block media %} {% block media %}
<style> <style>
@media(min-width: 800px) { @media(min-width: 800px) {
#content { #content {
width: 98%; width: 98%;
margin-left: 0; margin-left: 0;
}
.middle-right-content {
margin-left: 13%;
display: inline-flex;
}
} }
@media(max-width: 799px) {
#content { .middle-right-content {
width: 100%; margin-left: 13%;
margin-left: 0; display: inline-flex;
}
.middle-right-content {
display: block;
}
} }
</style> }
@media(max-width: 799px) {
#content {
width: 100%;
margin-left: 0;
}
.middle-right-content {
display: block;
}
}
</style>
{% endblock %} {% endblock %}
{% block js_media %} {% block js_media %}
<script type="text/javascript"> <script type="text/javascript">
function activateBlogBoxOnClick() { function activateBlogBoxOnClick() {
$('.blog-box').on('click', function() { $('.blog-box').on('click', function () {
var $description = $(this).children('.blog-description'); var $description = $(this).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).css('cursor', 'auto');
$(this).removeClass('pre-expand-blog'); $(this).removeClass('pre-expand-blog');
} $(this).find('.actionbar').show();
})
$('.blog-box').each(function() {
if ($(this).prop('scrollHeight') > $(this).height() ) {
$(this).addClass('pre-expand-blog');
$(this).css('cursor', 'pointer');
}
});
}
function navigateTo($elem, update_sidebar=false) {
var url = $elem.attr('data-href') || $elem.attr('href');
if (url === '#') return;
if (update_sidebar) {
$('.left-sidebar-item').removeClass('active');
$elem.addClass('active');
} }
$('.middle-right-content').html(loading_page); })
$.get(url, function(data) { $('.blog-box').each(function () {
var reload_content = $(data).find('.middle-right-content'); if ($(this).prop('scrollHeight') > $(this).height()) {
$(this).addClass('pre-expand-blog');
if (reload_content.length) { $(this).css('cursor', 'pointer');
window.history.pushState("", "", url); $(this).find('.actionbar').hide();
$('.middle-right-content').html(reload_content.first().html());
$(document).prop('title', $(data).filter('title').text());
MathJax.typeset($('.middle-right-content')[0]);
onWindowReady();
activateBlogBoxOnClick();
$('.xdsoft_datetimepicker').hide();
registerNavigation();
}
else {
window.location.href = url;
}
});
}
function registerNavigation() {
const links = ['.pagination a', '.tabs li a', '.problem-feed-option a'];
for (link of links) {
$(link).on('click', function(e) {
e.preventDefault();
navigateTo($(this));
})
} }
}
$(function () {
window.addEventListener('popstate', (e) => {
window.location.href = e.currentTarget.location.href;
});
activateBlogBoxOnClick();
$('.left-sidebar-item').on('click', function() {
navigateTo($(this), true);
});
registerNavigation();
}); });
</script> }
function navigateTo($elem, update_sidebar = false) {
var url = $elem.attr('data-href') || $elem.attr('href');
if (url === '#') return;
if (update_sidebar) {
$('.left-sidebar-item').removeClass('active');
$elem.addClass('active');
}
$('.middle-right-content').html(loading_page);
$.get(url, function (data) {
var reload_content = $(data).find('.middle-right-content');
if (reload_content.length) {
window.history.pushState("", "", url);
$('.middle-right-content').html(reload_content.first().html());
$(document).prop('title', $(data).filter('title').text());
MathJax.typeset($('.middle-right-content')[0]);
onWindowReady();
activateBlogBoxOnClick();
$('.xdsoft_datetimepicker').hide();
registerNavigation();
}
else {
window.location.href = url;
}
});
}
function registerNavigation() {
const links = ['.pagination a', '.tabs li a', '.problem-feed-option a'];
for (link of links) {
$(link).on('click', function (e) {
e.preventDefault();
navigateTo($(this));
})
}
}
$(function () {
window.addEventListener('popstate', (e) => {
window.location.href = e.currentTarget.location.href;
});
activateBlogBoxOnClick();
$('.left-sidebar-item').on('click', function () {
navigateTo($(this), true);
});
registerNavigation();
});
</script>
{% endblock %} {% endblock %}
{% macro make_tab_item(name, fa, url, text) %} {% macro make_tab_item(name, fa, url, text) %}
<div class="left-sidebar-item {% if page_type == name %}active{% endif %}" data-href="{{ url }}" id="{{ name }}-tab"> <div class="left-sidebar-item {% if page_type == name %}active{% endif %}" data-href="{{ url }}" id="{{ name }}-tab">
<span class="sidebar-icon"><i class="{{ fa }}"></i></span> <span class="sidebar-icon"><i class="{{ fa }}"></i></span>
<span>{{ text }}</span> <span>{{ text }}</span>
</div> </div>
{% endmacro %} {% endmacro %}
{% block body %} {% block body %}
{% block before_posts %}{% endblock %} {% block before_posts %}{% endblock %}
<div id="three-col-container"> <div id="three-col-container">
{% block left_sidebar %}{% endblock %} {% block left_sidebar %}{% endblock %}
<div class="middle-right-content"> <div class="middle-right-content">
{% block three_col_media %}{% endblock %} {% block three_col_media %}{% endblock %}
{% block three_col_js %}{% endblock %} {% block three_col_js %}{% endblock %}
<div class="middle-content"> <div class="middle-content">
{% block middle_title %}{% endblock %} {% block middle_title %}{% endblock %}
{% block middle_content %}{% endblock %} {% block middle_content %}{% endblock %}
</div>
{% block right_sidebar %}{% endblock %}
</div> </div>
{% block right_sidebar %}{% endblock %}
</div> </div>
{% block after_posts %}{% endblock %} </div>
{% block after_posts %}{% endblock %}
{% endblock %} {% endblock %}
{% block bodyend %} {% block bodyend %}
{{ super() }} {{ super() }}
{% if REQUIRE_JAX %} {% if REQUIRE_JAX %}
{% include "mathjax-load.html" %} {% include "mathjax-load.html" %}
{% endif %} {% endif %}
{% include "comments/math.html" %} {% include "comments/math.html" %}
{% endblock %} {% endblock %}