aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl/cover_photo_widget.tpl
diff options
context:
space:
mode:
Diffstat (limited to 'view/tpl/cover_photo_widget.tpl')
-rwxr-xr-xview/tpl/cover_photo_widget.tpl79
1 files changed, 53 insertions, 26 deletions
diff --git a/view/tpl/cover_photo_widget.tpl b/view/tpl/cover_photo_widget.tpl
index 3aaad5ae5..7739d24b8 100755
--- a/view/tpl/cover_photo_widget.tpl
+++ b/view/tpl/cover_photo_widget.tpl
@@ -2,54 +2,59 @@
var aside_padding_top;
var section_padding_top;
var coverSlid = false;
+ var hide_cover = Boolean({{$hide_cover}});
+ var cover_height;
$(document).ready(function() {
+ if(! $('#cover-photo').length)
+ return;
+
+ if($(window).width() < 755) {
+ $('#cover-photo').remove();
+ coverSlid = true;
+ return;
+ }
- aside_padding_top = parseInt($('aside').css('padding-top'));
- section_padding_top = parseInt($('section').css('padding-top'));
+ $('#cover-photo').removeClass('d-none');
+ cover_height = Math.ceil($(window).width()/2.75862069);
+ $('#cover-photo').css('height', cover_height + 'px');
+ datasrc2src('#cover-photo > img');
$(document).on('click mouseup keyup', slideUpCover);
- if($('#cover-photo').length && $(window).width() > 755) {
- if($(window).scrollTop() < $('#cover-photo').height()) {
- $('.navbar').removeClass('fixed-top');
- $('main').css('margin-top', - $('nav').outerHeight(true) + 'px');
- $('main').css('opacity', 0);
- }
+ if(hide_cover) {
+ hideCover();
}
- else {
- $('#cover-photo').remove();
- coverSlid = true;
+ else if(!hide_cover && !coverSlid) {
+ coverVisibleActions();
}
});
$(window).scroll(function () {
- if($('#cover-photo').length && $(window).width() > 755 && $(window).scrollTop() >= $('#cover-photo').height()) {
- $('.navbar').addClass('fixed-top');
- $('main').css('margin-top', '');
- $('main').css('opacity', 1);
+ if($(window).scrollTop() >= cover_height) {
+ coverHiddenActions();
coverSlid = true;
}
- else if ($('#cover-photo').length && $(window).width() > 755 && $(window).scrollTop() < $('#cover-photo').height()){
+ else if ($(window).scrollTop() < cover_height){
if(coverSlid) {
- $(window).scrollTop(Math.ceil($('#cover-photo').height()));
+ $(window).scrollTop(cover_height);
setTimeout(function(){ coverSlid = false; }, 1000);
}
else {
- if($(window).scrollTop() < $('#cover-photo').height()) {
- $('.navbar').removeClass('fixed-top');
- $('main').css('margin-top', - $('nav').outerHeight(true) + 'px');
- $('main').css('opacity', 0);
+ if($(window).scrollTop() < cover_height) {
+ coverVisibleActions();
}
}
}
- if($('#cover-photo').length && $('main').css('opacity') < 1) {
- $('main').css('opacity', ($(window).scrollTop()/$('#cover-photo').height()).toFixed(1));
+ if($('main').css('opacity') < 1) {
+ $('main').css('opacity', ($(window).scrollTop()/cover_height).toFixed(1));
}
});
$(window).resize(function () {
- if($('#cover-photo').length && $(window).width() < 755) {
+ cover_height = Math.ceil($(window).width()/2.75862069);
+ $('#cover-photo').css('height', cover_height + 'px');
+ if($(window).width() < 755) {
$('#cover-photo').remove();
$('.navbar').addClass('fixed-top');
$('main').css('opacity', 1);
@@ -62,12 +67,34 @@
if(coverSlid) {
return;
}
- $('html, body').animate({scrollTop: Math.ceil($('#cover-photo').height()) + 'px' }, 'fast');
+ $('html, body').animate({scrollTop: cover_height + 'px'}, 'fast');
return;
}
+
+ function hideCover() {
+ if(coverSlid) {
+ return;
+ }
+ window.scrollTo(0, cover_height);
+ return;
+ }
+
+ function coverVisibleActions() {
+ $('body').css('cursor', 'n-resize');
+ $('.navbar').removeClass('fixed-top');
+ $('main').css('margin-top', - $('nav').outerHeight(true) + 'px');
+ $('main').css('opacity', 0);
+ }
+
+ function coverHiddenActions() {
+ $('body').css('cursor', '');
+ $('.navbar').addClass('fixed-top');
+ $('main').css('margin-top', '');
+ $('main').css('opacity', 1);
+ }
</script>
-<div id="cover-photo" title="{{$hovertitle}}">
+<div class="d-none" id="cover-photo" title="{{$hovertitle}}">
{{$photo_html}}
<div id="cover-photo-caption">
<h1>{{$title}}</h1>