Skip to content

Commit

Permalink
pager changes
Browse files Browse the repository at this point in the history
nczirjak-acdh committed Apr 15, 2020
1 parent 0851e1f commit 88e2ea9
Showing 3 changed files with 107 additions and 9 deletions.
21 changes: 20 additions & 1 deletion js/acdh_repo_gui.js
Original file line number Diff line number Diff line change
@@ -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'));
}
});




});
41 changes: 40 additions & 1 deletion js/acdh_repo_gui_detail_view.js
Original file line number Diff line number Diff line change
@@ -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();
});
}
});

});

54 changes: 47 additions & 7 deletions js/acdh_repo_gui_pager.js
Original file line number Diff line number Diff line change
@@ -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('<a class="dropdown-item" data-value="lastnameasc" href="#">Last Name (ASC)</a>');
$('#sortByDropdown').append('<a class="dropdown-item" data-value="lastnamedesc" href="#">Last Name (DESC)</a>');
$('.sortByDropdownBottom').append('<a class="dropdown-item" data-value="lastnameasc" href="#">Last Name (ASC)</a>');
$('.sortByDropdownBottom').append('<a class="dropdown-item" data-value="lastnamedesc" href="#">Last Name (DESC)</a>');
}
//extend the collection with
if (currentURL.indexOf("type=Collection/") >= 0 || currentURL.indexOf("type=Collection&") >= 0) {
$('#sortByDropdown').append('<a class="dropdown-item" data-value="dateasc" href="#">Date (ASC)</a>');
$('#sortByDropdown').append('<a class="dropdown-item" data-value="datedesc" href="#">Date (DESC)</a>');
$('.sortByDropdownBottom').append('<a class="dropdown-item" data-value="dateasc" href="#">Date (ASC)</a>');
$('.sortByDropdownBottom').append('<a class="dropdown-item" data-value="datedesc" href="#">Date (DESC)</a>');
}

if (currentURL.indexOf("discover/root") >= 0) {
$('#sortByDropdown').append('<a class="dropdown-item" data-value="dateasc" href="#">Date (ASC)</a>');
$('#sortByDropdown').append('<a class="dropdown-item" data-value="datedesc" href="#">Date (DESC)</a>');
$('.sortByDropdownBottom').append('<a class="dropdown-item" data-value="dateasc" href="#">Date (ASC)</a>');
$('.sortByDropdownBottom').append('<a class="dropdown-item" data-value="datedesc" href="#">Date (DESC)</a>');
}
}

function getUrlParams(actionPage = 'detail_view'){
var urlPage;
var urlLimit;
@@ -76,18 +99,36 @@ 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);
var obj = {urlPage: urlPage, urlLimit: urlLimit, urlOrder: urlOrder, searchStr: searchStr};
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;

0 comments on commit 88e2ea9

Please sign in to comment.