From 88e2ea97b3c4198b8d7cca6c6a0470f83819d53f Mon Sep 17 00:00:00 2001 From: Norbert Czirjak Date: Wed, 15 Apr 2020 13:55:03 +0200 Subject: [PATCH] pager changes --- js/acdh_repo_gui.js | 21 ++++++++++++- js/acdh_repo_gui_detail_view.js | 41 ++++++++++++++++++++++++- js/acdh_repo_gui_pager.js | 54 ++++++++++++++++++++++++++++----- 3 files changed, 107 insertions(+), 9 deletions(-) diff --git a/js/acdh_repo_gui.js b/js/acdh_repo_gui.js index 24a223d..b707c93 100644 --- a/js/acdh_repo_gui.js +++ b/js/acdh_repo_gui.js @@ -1,5 +1,24 @@ jQuery(function($) { - "use strict"; + + + $(document ).delegate( ".res-act-button-expertview", "click", function(e) { +//$('.res-act-button-expertview').click(function() { + if ($(this).hasClass('basic')) { + $('.single-res-overview-basic').hide(); + $('.single-res-overview-expert').fadeIn(200); + $(this).removeClass('basic'); + $(this).addClass('expert'); + $(this).children('span').text(Drupal.t('Switch to Basic-View')); + } else { + $('.single-res-overview-expert').hide(); + $('.single-res-overview-basic').fadeIn(200); + $(this).removeClass('expert'); + $(this).addClass('basic'); + $(this).children('span').text(Drupal.t('Switch to Expert-View')); + } +}); + + }); diff --git a/js/acdh_repo_gui_detail_view.js b/js/acdh_repo_gui_detail_view.js index 9d02660..cfe9095 100644 --- a/js/acdh_repo_gui_detail_view.js +++ b/js/acdh_repo_gui_detail_view.js @@ -147,7 +147,46 @@ } - + + $(document).ready(function() { + + + /** + * If we are inside the oeaw_detail view, then we will just update the mainpagecontent div + */ + if(window.location.href.indexOf("browser/oeaw_detail/") >= 0 ){ + //block-mainpagecontent + $(document ).delegate( "a", "click", function(e) { + //$('a').click(function(e){ + $("#loader-div").show(); + var url = $(this).attr('href'); + if(url && url.indexOf("/browser/oeaw_detail/") >= 0 || url && url.indexOf("/browser//oeaw_detail/") >= 0 ) { + $('html, body').animate({scrollTop: '0px'}, 0); + url = url.substring(url.indexOf("/browser/")); + $(".loader-div").show(); + var id = url; + id = id.replace("/browser/oeaw_detail/", ""); + id = id.replace("/browser//oeaw_detail/", ""); + url = url+"&ajax=1"; + $.ajax({ + url: url, + type: "POST", + success: function(data, status) { + //change url + createNewUrl(id); + $('#block-mainpagecontent').html(data); + }, + error: function(message) { + $('#block-mainpagecontent').html("Resource does not exists!"); + } + }); + $("#loader-div").hide(); + e.preventDefault(); + } + $("#loader-div").hide(); + }); + } + }); }); diff --git a/js/acdh_repo_gui_pager.js b/js/acdh_repo_gui_pager.js index 67f1cd3..96b2e4c 100644 --- a/js/acdh_repo_gui_pager.js +++ b/js/acdh_repo_gui_pager.js @@ -1,10 +1,7 @@ jQuery(function($) { "use strict"; var actionPage = ''; - let orderTexts = { - titleasc: 'Title (ASC)', titledesc: 'Title (DESC)', - dateasc: 'Date (ASC)', datedesc: 'Date (DESC)' - }; + if(window.location.href.indexOf("/oeaw_detail/") > -1) { actionPage = 'detail_view'; @@ -26,8 +23,34 @@ jQuery(function($) { $(document).ready(function() { + addExtraSortingForViews(); }); + function addExtraSortingForViews() { + var currentURL = window.location.toString(); + //extend the search dropdown for the persons + if (currentURL.indexOf("type=Person/") >= 0 || currentURL.indexOf("type=Person&") >= 0) { + $('#sortByDropdown').append('Last Name (ASC)'); + $('#sortByDropdown').append('Last Name (DESC)'); + $('.sortByDropdownBottom').append('Last Name (ASC)'); + $('.sortByDropdownBottom').append('Last Name (DESC)'); + } + //extend the collection with + if (currentURL.indexOf("type=Collection/") >= 0 || currentURL.indexOf("type=Collection&") >= 0) { + $('#sortByDropdown').append('Date (ASC)'); + $('#sortByDropdown').append('Date (DESC)'); + $('.sortByDropdownBottom').append('Date (ASC)'); + $('.sortByDropdownBottom').append('Date (DESC)'); + } + + if (currentURL.indexOf("discover/root") >= 0) { + $('#sortByDropdown').append('Date (ASC)'); + $('#sortByDropdown').append('Date (DESC)'); + $('.sortByDropdownBottom').append('Date (ASC)'); + $('.sortByDropdownBottom').append('Date (DESC)'); + } + } + function getUrlParams(actionPage = 'detail_view'){ var urlPage; var urlLimit; @@ -76,11 +99,25 @@ jQuery(function($) { } } else { + //detail view child paging let searchParams = new URLSearchParams(window.location.href); urlPage = searchParams.get('page'); urlLimit= searchParams.get('limit'); urlOrder= searchParams.get('order'); } + + urlOrder = urlOrder.replace('#',''); + urlLimit = urlLimit.replace('#',''); + urlPage = urlPage.replace('#',''); + + let orderTexts = { + titleasc: 'Title (ASC)', titledesc: 'Title (DESC)', + dateasc: 'Date (ASC)', datedesc: 'Date (DESC)' + }; + + console.log(urlOrder); + console.log(orderTexts[urlOrder]); + console.log(urlLimit); //change the gui values $('#sortByButton').html(orderTexts[urlOrder]); $('#resPerPageButton').html(urlLimit); @@ -88,6 +125,10 @@ jQuery(function($) { return obj; } + function changePagerGui() { + + } + $(document ).delegate( "#prev-btn", "click", function(e) { let newPageNumber = $(this).data('pagination'); createNewUrl(newPageNumber, params.urlLimit, params.urlOrder, actionPage, params.searchStr); @@ -123,7 +164,8 @@ jQuery(function($) { newurl = window.location.protocol + "//" + window.location.host + '/browser/discover/root/' + orderBy + '/' + limit + '/' + page; } else if(actionPage == 'search') { newurl = window.location.protocol + "//" + window.location.host + '/browser/discover/'+ searchStr +'/' + orderBy + '/' + limit + '/' + page; - }else { + } else { + var path = window.location.pathname; var newUrlLimit = "&limit="+limit; var newUrlPage = "&page="+page; @@ -135,8 +177,6 @@ jQuery(function($) { cleanPath = path; } newurl = window.location.protocol + "//" + window.location.host + cleanPath + newUrlPage + newUrlLimit + newUrlOrder; - window.history.pushState({path:newurl},'',newurl); - window.location = newurl; } window.history.pushState({path:newurl},'',newurl); window.location = newurl;