From a821682c8c165077947781bca2064922884f6e7d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 5 Sep 2018 12:17:32 +0200 Subject: instead of not displaying the cover-photo at all after first page load, load the page with the cover slided up. change pointer to n-resize if cover is not slid. --- view/tpl/cover_photo_widget.tpl | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'view/tpl/cover_photo_widget.tpl') diff --git a/view/tpl/cover_photo_widget.tpl b/view/tpl/cover_photo_widget.tpl index 3aaad5ae5..ed708ffb5 100755 --- a/view/tpl/cover_photo_widget.tpl +++ b/view/tpl/cover_photo_widget.tpl @@ -2,16 +2,27 @@ var aside_padding_top; var section_padding_top; var coverSlid = false; + var hide_cover = Boolean({{$hide_cover}}); $(document).ready(function() { + if(! $('#cover-photo').length) + return; aside_padding_top = parseInt($('aside').css('padding-top')); section_padding_top = parseInt($('section').css('padding-top')); $(document).on('click mouseup keyup', slideUpCover); - if($('#cover-photo').length && $(window).width() > 755) { + if($(window).width() > 755) { + datasrc2src('#cover-photo > img'); + + if(hide_cover) { + hideCover(); + coverSlid = true; + } + if($(window).scrollTop() < $('#cover-photo').height()) { + $('body').css('cursor', 'n-resize'); $('.navbar').removeClass('fixed-top'); $('main').css('margin-top', - $('nav').outerHeight(true) + 'px'); $('main').css('opacity', 0); @@ -24,32 +35,34 @@ }); $(window).scroll(function () { - if($('#cover-photo').length && $(window).width() > 755 && $(window).scrollTop() >= $('#cover-photo').height()) { + if($(window).width() > 755 && $(window).scrollTop() >= $('#cover-photo').height()) { + $('body').css('cursor', ''); $('.navbar').addClass('fixed-top'); $('main').css('margin-top', ''); $('main').css('opacity', 1); coverSlid = true; } - else if ($('#cover-photo').length && $(window).width() > 755 && $(window).scrollTop() < $('#cover-photo').height()){ + else if ($(window).width() > 755 && $(window).scrollTop() < $('#cover-photo').height()){ if(coverSlid) { $(window).scrollTop(Math.ceil($('#cover-photo').height())); setTimeout(function(){ coverSlid = false; }, 1000); } else { if($(window).scrollTop() < $('#cover-photo').height()) { + $('body').css('cursor', 'n-resize'); $('.navbar').removeClass('fixed-top'); $('main').css('margin-top', - $('nav').outerHeight(true) + 'px'); $('main').css('opacity', 0); } } } - if($('#cover-photo').length && $('main').css('opacity') < 1) { + if($('main').css('opacity') < 1) { $('main').css('opacity', ($(window).scrollTop()/$('#cover-photo').height()).toFixed(1)); } }); $(window).resize(function () { - if($('#cover-photo').length && $(window).width() < 755) { + if($(window).width() < 755) { $('#cover-photo').remove(); $('.navbar').addClass('fixed-top'); $('main').css('opacity', 1); @@ -65,6 +78,13 @@ $('html, body').animate({scrollTop: Math.ceil($('#cover-photo').height()) + 'px' }, 'fast'); return; } + + function hideCover() { + if(coverSlid) { + return; + } + window.scrollTo(0, Math.ceil($('#cover-photo').height())); + }
-- cgit v1.2.3 From 4f82428a207d426a5cace7c3749655b391e6c156 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 5 Sep 2018 14:31:34 +0200 Subject: hide cover photo by default and show it only if conditions are met --- view/tpl/cover_photo_widget.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'view/tpl/cover_photo_widget.tpl') diff --git a/view/tpl/cover_photo_widget.tpl b/view/tpl/cover_photo_widget.tpl index ed708ffb5..2de3c74be 100755 --- a/view/tpl/cover_photo_widget.tpl +++ b/view/tpl/cover_photo_widget.tpl @@ -14,6 +14,7 @@ $(document).on('click mouseup keyup', slideUpCover); if($(window).width() > 755) { + $('#cover-photo').removeClass('d-none'); datasrc2src('#cover-photo > img'); if(hide_cover) { @@ -87,7 +88,7 @@ } -
+
{{$photo_html}}

{{$title}}

-- cgit v1.2.3 From 5135f236c2ff57a7002a2b1e27b7b61e8bf3d1f7 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 6 Sep 2018 11:30:50 +0200 Subject: improve cover-photo handling --- view/tpl/cover_photo_widget.tpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'view/tpl/cover_photo_widget.tpl') diff --git a/view/tpl/cover_photo_widget.tpl b/view/tpl/cover_photo_widget.tpl index 2de3c74be..7972b8e81 100755 --- a/view/tpl/cover_photo_widget.tpl +++ b/view/tpl/cover_photo_widget.tpl @@ -19,7 +19,6 @@ if(hide_cover) { hideCover(); - coverSlid = true; } if($(window).scrollTop() < $('#cover-photo').height()) { @@ -36,7 +35,7 @@ }); $(window).scroll(function () { - if($(window).width() > 755 && $(window).scrollTop() >= $('#cover-photo').height()) { + if($(window).width() > 755 && $(window).scrollTop() > ($('#cover-photo').height() - 1)) { $('body').css('cursor', ''); $('.navbar').addClass('fixed-top'); $('main').css('margin-top', ''); -- cgit v1.2.3 From 6a338e28b281e30bfa5be788957e86e0de0060f1 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 6 Sep 2018 14:27:56 +0200 Subject: -1 has issues in some browsers --- view/tpl/cover_photo_widget.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/tpl/cover_photo_widget.tpl') diff --git a/view/tpl/cover_photo_widget.tpl b/view/tpl/cover_photo_widget.tpl index 7972b8e81..e8af6f6dc 100755 --- a/view/tpl/cover_photo_widget.tpl +++ b/view/tpl/cover_photo_widget.tpl @@ -35,7 +35,7 @@ }); $(window).scroll(function () { - if($(window).width() > 755 && $(window).scrollTop() > ($('#cover-photo').height() - 1)) { + if($(window).width() > 755 && $(window).scrollTop() > $('#cover-photo').height()) { $('body').css('cursor', ''); $('.navbar').addClass('fixed-top'); $('main').css('margin-top', ''); -- cgit v1.2.3 From 4cc413cdaf8a2ce1245fcfbfaae08977e3b836b9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 10 Sep 2018 11:12:15 +0200 Subject: cover photo: some code cleanup and fix height issue when photo was not cached --- view/tpl/cover_photo_widget.tpl | 69 +++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 30 deletions(-) (limited to 'view/tpl/cover_photo_widget.tpl') diff --git a/view/tpl/cover_photo_widget.tpl b/view/tpl/cover_photo_widget.tpl index e8af6f6dc..a7d4e52ea 100755 --- a/view/tpl/cover_photo_widget.tpl +++ b/view/tpl/cover_photo_widget.tpl @@ -3,52 +3,45 @@ var section_padding_top; var coverSlid = false; var hide_cover = Boolean({{$hide_cover}}); + var cover_height; $(document).ready(function() { if(! $('#cover-photo').length) return; - aside_padding_top = parseInt($('aside').css('padding-top')); - section_padding_top = parseInt($('section').css('padding-top')); - - $(document).on('click mouseup keyup', slideUpCover); + if($(window).width() < 755) { + $('#cover-photo').remove(); + coverSlid = true; + return; + } - if($(window).width() > 755) { - $('#cover-photo').removeClass('d-none'); - datasrc2src('#cover-photo > img'); + $('#cover-photo').removeClass('d-none'); + cover_height = Math.ceil($(window).width()/2.75862069); + $('#cover-photo').css('height', cover_height + 'px'); + datasrc2src('#cover-photo > img'); - if(hide_cover) { - hideCover(); - } + $(document).on('click mouseup keyup', slideUpCover); - if($(window).scrollTop() < $('#cover-photo').height()) { - $('body').css('cursor', 'n-resize'); - $('.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($(window).width() > 755 && $(window).scrollTop() > $('#cover-photo').height()) { - $('body').css('cursor', ''); - $('.navbar').addClass('fixed-top'); - $('main').css('margin-top', ''); - $('main').css('opacity', 1); + if($(window).scrollTop() > cover_height) { + coverHiddenActions(); coverSlid = true; } - else if ($(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()) { + if($(window).scrollTop() < cover_height) { $('body').css('cursor', 'n-resize'); $('.navbar').removeClass('fixed-top'); $('main').css('margin-top', - $('nav').outerHeight(true) + 'px'); @@ -57,11 +50,13 @@ } } if($('main').css('opacity') < 1) { - $('main').css('opacity', ($(window).scrollTop()/$('#cover-photo').height()).toFixed(1)); + $('main').css('opacity', ($(window).scrollTop()/cover_height).toFixed(1)); } }); $(window).resize(function () { + 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'); @@ -75,7 +70,7 @@ if(coverSlid) { return; } - $('html, body').animate({scrollTop: Math.ceil($('#cover-photo').height()) + 'px' }, 'fast'); + $('html, body').animate({scrollTop: cover_height + 'px'}, 'fast'); return; } @@ -83,7 +78,21 @@ if(coverSlid) { return; } - window.scrollTo(0, Math.ceil($('#cover-photo').height())); + window.scrollTo(0, cover_height); + } + + 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); } -- cgit v1.2.3 From 4bb16b18edd15cdeace1ebc4ac31ea7a8432d3cc Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 10 Sep 2018 12:12:05 +0200 Subject: cover photo: mior issue and more cleanup --- view/tpl/cover_photo_widget.tpl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'view/tpl/cover_photo_widget.tpl') diff --git a/view/tpl/cover_photo_widget.tpl b/view/tpl/cover_photo_widget.tpl index a7d4e52ea..7739d24b8 100755 --- a/view/tpl/cover_photo_widget.tpl +++ b/view/tpl/cover_photo_widget.tpl @@ -31,7 +31,7 @@ }); $(window).scroll(function () { - if($(window).scrollTop() > cover_height) { + if($(window).scrollTop() >= cover_height) { coverHiddenActions(); coverSlid = true; } @@ -42,10 +42,7 @@ } else { if($(window).scrollTop() < cover_height) { - $('body').css('cursor', 'n-resize'); - $('.navbar').removeClass('fixed-top'); - $('main').css('margin-top', - $('nav').outerHeight(true) + 'px'); - $('main').css('opacity', 0); + coverVisibleActions(); } } } @@ -79,6 +76,7 @@ return; } window.scrollTo(0, cover_height); + return; } function coverVisibleActions() { -- cgit v1.2.3