diff --git a/app/Http/Controllers/NewsController.php b/app/Http/Controllers/NewsController.php index 8a59d2cd..1c9174f8 100644 --- a/app/Http/Controllers/NewsController.php +++ b/app/Http/Controllers/NewsController.php @@ -16,11 +16,11 @@ class NewsController extends Controller public function show(Request $request, $id) { - parent::registerView($request, 'nieuws', $id); - $preview = ""; - if(request()->get('preview', null) != null) { - $preview = "?preview=" . request()->get('preview'); - } + parent::registerView($request, 'nieuws', $id); + $preview = ""; + if(request()->get('preview', null) != null) { + $preview = "?preview=" . request()->get('preview'); + } $apiResult = $this->API('nieuws/bericht/' . $id . $preview); $newsItem = new \Model\NewsItem($apiResult->news); @@ -29,21 +29,18 @@ class NewsController extends Controller if (!$newsItem->content) return redirect('//nhnieuws.nl/gooi'); case 2: - if(isset($apiResult->source->article)) { + if(isset($apiResult->source->article)) { $source = $apiResult->source->article; $newsItem->published = self::TimestampToDateTime($source->created); $newsItem->edited = self::TimestampToDateTime($source->updated); $newsItem->author = $source->author; $newsItem->images = null; // Images will be embedded $newsItem->video = null; // Videos will be embedded - $newsItem->content = $source->blocks; - } elseif(isset($apiResult->source->blocks)) { - $newsItem->content = $apiResult->source->blocks; - } - - - - return view('newsitem', array_merge($this->getSidebareData(), ['type' => $apiResult->type, 'news' => $newsItem, 'metadata' => $newsItem->metadata, 'searchURL' => 'nieuws/zoeken'])); + $newsItem->content = $source->blocks; + } elseif(isset($apiResult->source->blocks)) { + $newsItem->content = $apiResult->source->blocks; + } + return view('newsitem', array_merge($this->getSidebareData(), ['type' => $apiResult->type, 'news' => $newsItem, 'metadata' => $newsItem->metadata, 'searchURL' => 'nieuws/zoeken'])); } } @@ -144,6 +141,9 @@ class NewsController extends Controller $total = 5; } $page = (int)$request->get('pagina', 1); + if ($url == 'overzicht' && $request->get('dateStart', null) && $request->get('dateEnd', null)) { + $url = 'datum/' . $request->get('dateStart', null) . '/' . $request->get('dateEnd', null); + } $apiResult = $this->API('nieuws/' . $url . '?pagina=' . (int)max(1, $page) . ($total ? '&aantal=' . $total : '')); $news = []; foreach ($apiResult->news as $newsItem) { diff --git a/public/images/icons/calendar.svg b/public/images/icons/calendar.svg new file mode 100644 index 00000000..1f61388a --- /dev/null +++ b/public/images/icons/calendar.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/js/functions.js b/public/js/functions.js index 5a95c3a3..665d520c 100644 --- a/public/js/functions.js +++ b/public/js/functions.js @@ -31,14 +31,16 @@ $(document).ready(function(){ loadingElementId: '#loading', container: '', url: document.location.pathname, - nextPage: 2 + nextPage: 2, + dateStart: null, + dateEnd:null }; $.extend(options, _options); var $isLoading = $(options.loadingElementId, this); $isLoading.hide(); - this.click(function (e) { + this.unbind('click').click(function (e) { e.preventDefault(); if (!isLoading) { // Set flag and update UI @@ -48,7 +50,7 @@ $(document).ready(function(){ var $container = $(options.container) // Fire request for the next page - $.ajax({url: options.url + (options.url.indexOf('?') >= 0 ? '&' : '?') + 'pagina=' + options.nextPage}) + $.ajax({url: options.url + (options.url.indexOf('?') >= 0 ? '&' : '?') + 'pagina=' + options.nextPage + (options.dateStart ? '&dateStart=' + options.dateStart : '') + (options.dateEnd ? '&dateEnd=' + options.dateEnd : '')}) .always(function () { // Whether success or failure, update the UI again isLoading = 0; diff --git a/public/js/functions.min.js b/public/js/functions.min.js index 5b85d788..dec5baca 100644 --- a/public/js/functions.min.js +++ b/public/js/functions.min.js @@ -1,2 +1,2 @@ -/*! 2024-05-06 */ -function calculateSize(e,t){null==t&&(t=0),setTimeout(function(){(0==$("#"+e).children(":first").height()||0==$("#"+e).children(":first").width())&&t<4?calculateSize(e,t+1):($("#"+e).height($("#"+e).children(":first").height()),$("#"+e).width($("#"+e).children(":first").width()))},500),$("#"+e).css({backgroundColor:"transparent"})}$(document).ready(function(){$("#changePreferences, .cc_b_cp").click(function(){$("#title_targeting").parent("li").hide(),$("#content_targeting").hide()})}),function(a){a.fn.loadMoreNews=function(e){var t=!1,o={loadingElementId:"#loading",container:"",url:document.location.pathname,nextPage:2},s=(a.extend(o,e),a(o.loadingElementId,this));s.hide(),this.click(function(e){var n,i;e.preventDefault(),t||(t=1,s.show(),n=a(this).attr("disabled","disabled"),i=a(o.container),a.ajax({url:o.url+(0<=o.url.indexOf("?")?"&":"?")+"pagina="+o.nextPage}).always(function(){t=0,s.hide(),n.removeAttr("disabled")}).done(function(t){t?(i.each(function(){var e=this.toString();a(e).append(a("
"+t+"
").find(e).length?a("
"+t+"
").find(e).children():a(t))}),++o.nextPage):n.attr("disabled","disabled").text("Geen nieuws meer.")}))})}}(jQuery),$(function(){$("[data-loadmorenews]").each(function(){$(this).loadMoreNews($(this).data("loadmorenews"))})}),function(o){o.fn.menu=function(e){var t={menuSubmenuClass:"has_submenu"},e=(o.extend(t,e),o(this).children("."+t.menuSubmenuClass)),i=o(this);e.on("mouseenter",function(){var e=o(this),t=(o(".menu-submenu > ul.submenu").slideUp(400,function(){o(this).closest(".menu-submenu").remove()}),o(".hover",i).removeClass("hover"),e.addClass("hover"),o('
').append(e.children("ul.submenu").clone())),n=e.offset();t.addClass("menu-submenu").css({top:n.top,left:n.left}),t.on("mouseleave",function(){o(".menu-submenu > ul.submenu").slideUp(400,function(){o(this).closest(".menu-submenu").remove()}),e.removeClass("hover")}),o("body").append(t),t.children("ul.submenu").slideDown(),t.find("ul.submenu").subMenu({}),openPlayerInNewScreen()})},o.fn.subMenu=function(e){var t={menuSubmenuClass:"has_submenu"};o.extend(t,e),o(this).find("li."+t.menuSubmenuClass+" > a").click(function(e){e.preventDefault();e=o(this).closest("li");e.children("ul.submenu").slideToggle(),e.toggleClass("opened")})}}(jQuery),$(function(){$(".menu").menu({}),$(".mobile-menu").subMenu({}),$(".mobile_menu_button a").click(function(){$(".mobile_menu_container").show()}),$(".mobile_close_menu_button a").click(function(){$(".mobile_menu_container").hide()}),$(".mobile_menu_container").click(function(e){!$(e.target).closest("#mobile_menu_nav").length&&$(".mobile_menu_container").is(":visible")&&$(".mobile_menu_container").hide()})}),$(function(){$(".prettyPhoto[rel^='prettyPhoto']").prettyPhoto({show_title:!1,slideshow:3e3,overlay_gallery:!0,social_tools:""})}),$(function(){$(".scroll_top").click(function(e){e.preventDefault(),$("html, body").stop().animate({scrollTop:0},500,"swing")})}),function(o){o.fn.share=function(e){var i={type:"",types:{facebook:{url:"https://www.facebook.com/sharer/sharer.php?u=",textOption:!1},twitter_x:{url:"https://twitter.com/share?url=",textOption:"text="}},excerptClass:"excerpt"};o.extend(i,e),this.click(function(e){e.preventDefault();var t,n,e=i.types[i.type];"native"==i.type&&null!=navigator.share?(278<(n=o("."+i.excerptClass).text().trim()).length+location.href.length&&(n=n.substring(0,278-(location.href.length+3))+"..."),t={url:encodeURI(location.href),text:n,title:o(".page_title").text().trim()},navigator.share(t)):void 0!==e?(t="",e.textOption&&(278<(n=o("."+i.excerptClass).text().trim()).length+location.href.length&&(n=n.substring(0,278-(location.href.length+3))+"..."),t="&"+e.textOption+encodeURI(n)),window.open(e.url+encodeURI(location.href)+t,"pop","width=600, height=400, scrollbars=no")):console.error(i.type+" is unknown")})}}(jQuery),$(function(){$("[data-share]").each(function(){$(this).share({type:$(this).data("share")})})}),function(u){u.fn.snapTo=function(e){var t={elementClass:"post"},n=(u.extend(t,e),u(this)),i=n.find("."+t.elementClass+":visible"),o=!1,s=null,a=function(){var t;o||(o=!0,t=n.scrollLeft(),i.each(function(){var e=u(this).offset();if(e.left>-window.screen.width/2&&e.left"+t+"").find(e).length?s("
"+t+"
").find(e).children():s(t))}),++a.nextPage):n.attr("disabled","disabled").text("Geen nieuws meer.")}))})}}(jQuery),$(function(){$("[data-loadmorenews]").each(function(){$(this).loadMoreNews($(this).data("loadmorenews"))})}),function(a){a.fn.menu=function(e){var t={menuSubmenuClass:"has_submenu"},e=(a.extend(t,e),a(this).children("."+t.menuSubmenuClass)),i=a(this);e.on("mouseenter",function(){var e=a(this),t=(a(".menu-submenu > ul.submenu").slideUp(400,function(){a(this).closest(".menu-submenu").remove()}),a(".hover",i).removeClass("hover"),e.addClass("hover"),a('
').append(e.children("ul.submenu").clone())),n=e.offset();t.addClass("menu-submenu").css({top:n.top,left:n.left}),t.on("mouseleave",function(){a(".menu-submenu > ul.submenu").slideUp(400,function(){a(this).closest(".menu-submenu").remove()}),e.removeClass("hover")}),a("body").append(t),t.children("ul.submenu").slideDown(),t.find("ul.submenu").subMenu({}),openPlayerInNewScreen()})},a.fn.subMenu=function(e){var t={menuSubmenuClass:"has_submenu"};a.extend(t,e),a(this).find("li."+t.menuSubmenuClass+" > a").click(function(e){e.preventDefault();e=a(this).closest("li");e.children("ul.submenu").slideToggle(),e.toggleClass("opened")})}}(jQuery),$(function(){$(".menu").menu({}),$(".mobile-menu").subMenu({}),$(".mobile_menu_button a").click(function(){$(".mobile_menu_container").show()}),$(".mobile_close_menu_button a").click(function(){$(".mobile_menu_container").hide()}),$(".mobile_menu_container").click(function(e){!$(e.target).closest("#mobile_menu_nav").length&&$(".mobile_menu_container").is(":visible")&&$(".mobile_menu_container").hide()})}),$(function(){$(".prettyPhoto[rel^='prettyPhoto']").prettyPhoto({show_title:!1,slideshow:3e3,overlay_gallery:!0,social_tools:""})}),$(function(){$(".scroll_top").click(function(e){e.preventDefault(),$("html, body").stop().animate({scrollTop:0},500,"swing")})}),function(a){a.fn.share=function(e){var i={type:"",types:{facebook:{url:"https://www.facebook.com/sharer/sharer.php?u=",textOption:!1},twitter_x:{url:"https://twitter.com/share?url=",textOption:"text="}},excerptClass:"excerpt"};a.extend(i,e),this.click(function(e){e.preventDefault();var t,n,e=i.types[i.type];"native"==i.type&&null!=navigator.share?(278<(n=a("."+i.excerptClass).text().trim()).length+location.href.length&&(n=n.substring(0,278-(location.href.length+3))+"..."),t={url:encodeURI(location.href),text:n,title:a(".page_title").text().trim()},navigator.share(t)):void 0!==e?(t="",e.textOption&&(278<(n=a("."+i.excerptClass).text().trim()).length+location.href.length&&(n=n.substring(0,278-(location.href.length+3))+"..."),t="&"+e.textOption+encodeURI(n)),window.open(e.url+encodeURI(location.href)+t,"pop","width=600, height=400, scrollbars=no")):console.error(i.type+" is unknown")})}}(jQuery),$(function(){$("[data-share]").each(function(){$(this).share({type:$(this).data("share")})})}),function(u){u.fn.snapTo=function(e){var t={elementClass:"post"},n=(u.extend(t,e),u(this)),i=n.find("."+t.elementClass+":visible"),a=!1,o=null,s=function(){var t;a||(a=!0,t=n.scrollLeft(),i.each(function(){var e=u(this).offset();if(e.left>-window.screen.width/2&&e.left= 0 ? '&' : '?') + 'pagina=' + options.nextPage}) + $.ajax({url: options.url + (options.url.indexOf('?') >= 0 ? '&' : '?') + 'pagina=' + options.nextPage + (options.dateStart ? '&dateStart=' + options.dateStart : '') + (options.dateEnd ? '&dateEnd=' + options.dateEnd : '')}) .always(function () { // Whether success or failure, update the UI again isLoading = 0; diff --git a/resources/views/news.blade.php b/resources/views/news.blade.php index 8fdac984..342f66be 100644 --- a/resources/views/news.blade.php +++ b/resources/views/news.blade.php @@ -8,6 +8,60 @@ news @endsection +@push('scripts') + + + + + +@endpush + @section('content')
{{-- body --}} @@ -21,8 +75,16 @@
-

Meer nieuws

-
+
+

Meer nieuws

+

+
+
{!!file_get_contents(__DIR__ . '/../../../public/images/icons/calendar.svg')!!}
+ +
+

+
+
@include('partial/newslist_small', ['id' => 'items-more-news', 'news' => $news])