Commit 8aae447f authored by Ubbo Veentjer's avatar Ubbo Veentjer
Browse files

Merge branch 'release/3.1.3' into main

parents db928454 5b38791a
Pipeline #141257 passed with stages
in 7 minutes and 32 seconds
export function setupSearchResultsPage() {
var filters = [];
// get the filters from the left sidebar to append them to the search form
$('.tgrep.sidebar_item.-filter').each((id, elem) => {
filters.push(elem.dataset.filter);
});
$('#search-filters-active').change(function() {
if($('#search-filters-active').is(':checked')){
addFiltersToSearchForm(filters);
} else {
removeFiltersFromSearchForm();
}
});
addFiltersToSearchForm(filters);
}
function addFiltersToSearchForm(filters) {
$(filters).each(function(id, filter) {
$('form.search').append($('<input type="hidden" class="hiddenFilterInput" name="filter" value="'+filter+'" />'));
});
}
function removeFiltersFromSearchForm() {
$('.hiddenFilterInput').remove();
}
/* functions for interacting with the shelf */
/* show number of items on shelf */
export function setShelfCount(num) {
$('.topbox_shelf-count').each((id, elem) => {
elem.textContent = num;
})
}
export function setupShelfButtons(isShelf) {
const removeLabel = document.querySelector('#i18n-remove-from-shelf-label').dataset.value;
const addLabel = document.querySelector('#i18n-add-to-shelf-label').dataset.value;
$(document).on('click', '.-remove-from-shelf', function(e) {
var $this = $(this);
var tgObjectUri = $this.attr('data-textgrid-targeturi');
$.ajax({
url: '/service/shelf/remove' ,
type: 'POST',
dataType:'json',
data: {
uri: tgObjectUri
},
success: function(data) {
if(isShelf) {
// if this remove button is on the shelf, the whole item is removed
$this.closest('li.tgrep.result').remove();
$this.closest('li.tgrep.gallery-item').remove();
$('.tgrep.header_count').html(data);
removeFromAggregatorItemString(tgObjectUri)
} else {
$this.removeClass('-remove-from-shelf');
$this.addClass('-add-to-shelf');
$this.html(addLabel);
}
setShelfCount(data);
}
});
});
// the shelf has no add buttons
if(!isShelf) {
$(document).on('click', '.-add-to-shelf', function(e) {
var $this = $(this);
$.ajax({
url: "/service/shelf/add" ,
type: 'POST',
dataType:'json',
data: {
uri: $this.attr('data-textgrid-targeturi')
},
success: function(data) {
$this.removeClass('-add-to-shelf');
$this.addClass('-remove-from-shelf');
$this.html(removeLabel);
setShelfCount(data);
}
});
});
}
}
export function setupShelf() {
setupShelfButtons(true);
$(document).on('click', '.tgrep.header_button.-clear', function(e) {
$.ajax({
url: '/service/shelf/clear' ,
type: 'POST',
dataType:'json',
data: {
empty: 'empty'
},
success: function(data) {
$('.tgrep.results_list').empty();
$('.tgrep.results_gallery').empty();
$('.tgrep.header_count').html(0);
setShelfCount(data);
removeUselessActionsFromEmptyShelf();
}
});
});
shelfItemString = document.querySelector('#shelfItemString').dataset.value;
}
//set by jsp
var shelfItemString;
// removes the tguri from aggregatorUrl
function removeFromAggregatorItemString(tgObjectUri) {
var shelfItemStringOld = shelfItemString;
var itemArr = shelfItemString.split(',');
itemArr.splice(itemArr.indexOf(tgObjectUri),1);
// are there any objects left on the shelf?
if(itemArr.length > 0) {
shelfItemString = itemArr.join(',');
$('.aggregator-items').each((id, elem) => {
elem.href = elem.href.replace(shelfItemStringOld, shelfItemString);
});
} else {
removeUselessActionsFromEmptyShelf();
}
}
// disable download and voyant links if shelf is empty
function removeUselessActionsFromEmptyShelf() {
$('.remove_on_shelf_empty').each((id, elem) => {
elem.remove();
});
}
/* localstorage */
export function hasLocalStorage() {
const item = "tgrep"
try {
window.localStorage.setItem(item, item);
window.localStorage.removeItem(item);
return true;
} catch(e) {
return false;
}
}
// Set default animation duration to 300 ms
$.fx.speeds._default = 300
$( function() {
export function setupTheme() {
// Set default animation duration to 300 ms
$.fx.speeds._default = 300
// Drowdown handlers
$('.tg.dropdown_menu a').attr('tabindex', -1)
......@@ -79,7 +80,7 @@ $( function() {
})
$('.tgrep.advanced-search_button.-select').click( function() {
checked = $(this).hasClass('-all')
const checked = $(this).hasClass('-all')
$( '#' + $(this).data('target') ).find(':checkbox').prop('checked', checked)
})
......@@ -87,8 +88,8 @@ $( function() {
$('.tgrep.advanced-search_button.-item').click( function() {
var $container = $(this).closest('.tgrep.advanced-search_grow-group')
if ( $(this).hasClass('-add') ) {
$template = $(this).closest('.tgrep.advanced-search_grow-item')
$clone = $template.clone(true)
let $template = $(this).closest('.tgrep.advanced-search_grow-item')
let $clone = $template.clone(true)
$clone.find(':input').val('')
$clone.find('select').each( function() {
$(this).val( $(this).find('option:first').val() )
......@@ -115,106 +116,5 @@ $( function() {
return false
})
})
/* for the basket */
/* retrieve number of basket items on page load to set number display */
document.addEventListener("DOMContentLoaded", event => {
fetch("/service/shelf/count")
.then(response => response.text())
.then(cnt => setBasketCount(cnt));
});
/* show number of items in basket */
function setBasketCount(num) {
document.querySelectorAll('.topbox_shelf-count').forEach( elem => {
elem.textContent = num;
})
}
/* the javascript for the shelf buttons, needed on browse and search-result and shelf pages */
document.addEventListener("DOMContentLoaded", function(event) {
const removeLabel = document.querySelector('#i18n-remove-from-shelf-label').dataset.value;
const addLabel = document.querySelector('#i18n-add-to-shelf-label').dataset.value;
/* the buttons */
$(document).on('click', '.-add-to-shelf', function(e) {
var $this = $(this);
$.ajax({
url: "/service/shelf/add" ,
type: 'POST',
dataType:'json',
data: {
uri: $this.attr('data-textgrid-targeturi')
},
success: function(data) {
$this.removeClass('-add-to-shelf');
$this.addClass('-remove-from-shelf');
$this.html(removeLabel);
setBasketCount(data);
}
});
});
$(document).on('click', '.-remove-from-shelf', function(e) {
var $this = $(this);
$.ajax({
url: "/service/shelf/remove" ,
type: 'POST',
dataType:'json',
data: {
uri: $this.attr('data-textgrid-targeturi')
},
success: function(data) {
$this.removeClass('-remove-from-shelf');
$this.addClass('-add-to-shelf');
$this.html(addLabel);
setBasketCount(data);
}
});
});
});
/* the browse.jsp has an iframe when showing html directly loaded from tgcrud */
document.addEventListener("DOMContentLoaded", function(event) {
$("#htmlIframe").contents().find("body").attr("style","margin-left: 0");
});
/* add/remove filters in search jsp */
document.addEventListener("DOMContentLoaded", function(event) {
var filters = [];
// get the filters from the left sidebar to append them to the search form
document.querySelectorAll('.tgrep.sidebar_item.-filter').forEach( elem => {
filters.push(elem.dataset.filter);
});
function addFiltersToSearchForm(filters) {
filters.forEach(function(filter) {
$('form.search').append($('<input type="hidden" class="hiddenFilterInput" name="filter" value="'+filter+'" />'));
});
}
function removeFiltersFromSearchForm() {
$('.hiddenFilterInput').remove();
}
addFiltersToSearchForm(filters);
//$('form.search').append($('<input type="hidden" name="order" value="${order}" />'));
//$('form.search').append($('<input type="hidden" name="limit" value="${limit}" />'));
$('#search-filters-active').change(function() {
if($('#search-filters-active').is(':checked')){
addFiltersToSearchForm(filters);
} else {
removeFiltersFromSearchForm();
}
});
});
......@@ -8,6 +8,7 @@ server.servlet.session.cookie.secure: ${tgrep.ssl}
# textgrid defaults
textgrid.host: https://textgridlab.org
tgsearch.url: ${textgrid.host}/1.0/tgsearch-public
handle.host: https://hdl.handle.net
# tool defaults
......@@ -21,4 +22,6 @@ lang.available: en, de
lang.default: en
tgsearch.query.facetlimit = 10000
#tgsearch.query.facetlimit = 10
\ No newline at end of file
#tgsearch.query.facetlimit = 10
sentry.enabled = false
\ No newline at end of file
......@@ -14,6 +14,7 @@ collapse-all=Alles einklappen
download-all=Alles herunterladen
change-result-display=Anzeige anpassen
nothing-found=Leider keine Ergebnisse für die Anfrage:
download-text-only-zip=ZIP / nur Text
# facet-group names
edition.agent.value=Autor
......@@ -60,7 +61,7 @@ filter=Filter
active-filters=Aktive Filter
remove-filter=Diesen Filter entfernen
# basket.jsp, shares some strings with singleResult.jsp
# shelf.jsp, shares some strings with singleResult.jsp
show-sidebar=Seitenleiste anzeigen
hide-sidebar=Seitenleiste verbergen
expand=Alle anzeigen
......@@ -86,6 +87,10 @@ collection-citation-heading=Zitationsvorschlag für diese Kollektion
aggregation-citation-heading=Zitationsvorschlag für diese Aggregation
work-citation-heading=Zitationsvorschlag für dieses Werk
item-citation-heading=Zitationsvorschlag für dieses Objekt
revisions=Revisionen
higher-revision-available=Höhere Revision vorhanden
higher-rev-msg-pt1=Aktuell wird Revision
higher-rev-msg-pt2=des Dokumentes angezeigt. Eine höhere Revision des Dokumentes wurde publiziert:
#usersettings.jsp
usersettings=Persönliche Einstellungen
......
......@@ -14,6 +14,7 @@ collapse-all=Collapse all
download-all=Download all
change-result-display=Change display
nothing-found=Unfortunately nothing was found for query:
download-text-only-zip=ZIP / text only
# facet-group names
edition.agent.value=Author
......@@ -60,7 +61,7 @@ filter=Filter
active-filters=Active filters
remove-filter=Remove this filter
# basket.jsp, shares some strings with singleResult.jsp
# shelf.jsp, shares some strings with singleResult.jsp
show-sidebar=Show sidebar
hide-sidebar=Hide sidebar
expand=Show all
......@@ -86,6 +87,10 @@ collection-citation-heading=Citation Suggestion for this Collection
aggregation-citation-heading=Citation Suggestion for this Aggregation
work-citation-heading=Citation Suggestion for this Work
item-citation-heading=Citation Suggestion for this Object
revisions=Revisions
higher-revision-available=Higher revision available
higher-rev-msg-pt1=You are viewing revision
higher-rev-msg-pt2=of this document. A higher revision of this document has been published:
#usersettings.jsp
usersettings=Personal Settings
......
This diff is collapsed.
document.addEventListener("DOMContentLoaded", function(event) {
$('form.advanced-search').submit(function(e) {
e.preventDefault();
var query = "";
/**
* serialize form for accessing fulltext, contentType and wordDistance params
*/
var formArray = $("form.advanced-search").serializeArray();
var fulltext;
var ctypeArr = [];
var wordDistance;
var wordDistanceActive = false;
var mdSearchActive = false;
var contentSearchActive = false;
formArray.forEach(function(val) {
if(val.name === 'fulltext') {
fulltext = val.value;
}
if(val.name === 'contenttype') {
contentSearchActive = true;
ctypeArr.push(val.value);
}
if(val.name === 'wordDistanceSel') {
wordDistanceActive = val.value === 'true';
}
if(val.name === 'wordDistance') {
wordDistance = val.value;
}
if(val.name === 'metadata-term') {
if (val.value.length > 0 ) {
mdSearchActive = true;
}
}
});
/**
* handle metadata query
*/
if(mdSearchActive) {
$.each($('.metadata-searchgroup'), function(id, val) {
var field = $(val).find('[name="metadata-field"]').val();
query += '(';
$.each($(val).find('[name="metadata-term"]'), function(termIndex, termInput) {
var term = $(termInput).val();
if(term !== '' && term !== true) {
query += field + ':"' + term + '" OR ';
}
});
/* cut the last "OR" */
query = query.substring(0, query.length-4);
query += ')';
query += ' AND ';
});
/* cut the last "AND" */
query = query.substring(0, query.length-5);
}
/**
* handle content type query
*/
if(ctypeArr.length > 0) {
if(query !== "") query += ' AND ';
if(ctypeArr.length > 1) {
query += '(';
}
$.each(ctypeArr, function() {
query += 'format:"'+this+'" OR ';
});
/* cut the last "OR" */
query = query.substring(0, query.length-4);
if(ctypeArr.length > 1) {
query += ")";
}
}
/**
* fulltext
*/
if(fulltext !== "") {
if(! $.isEmptyObject(fulltext)) {
if(query !== "") {
query += ' AND ';
}
if( wordDistanceActive ) {
query += '"'+fulltext+'"~'+wordDistance;
} else {
query += fulltext;
}
}
}
location.href="/search?query="+query;
});
});
\ No newline at end of file
document.addEventListener("DOMContentLoaded", function(event) {
// TODO: does this overload the binding from theme.js?
$(document).on('click', '.-remove-from-shelf', function(e) {
var $this = $(this);
var tgObjectUri = $this.attr('data-textgrid-targeturi');
$.ajax({
url: '/service/shelf/remove' ,
type: 'POST',
dataType:'json',
data: {
uri: tgObjectUri
},
success: function(data) {
$this.closest('li.tgrep.result').remove();
$this.closest('li.tgrep.gallery-item').remove();
$('.tgrep.header_count').html(data);
setBasketCount(data);
removeFromAggregatorItemString(tgObjectUri)
}
});
});
$(document).on('click', '.tgrep.header_button.-clear', function(e) {
$.ajax({
url: '/service/shelf/clear' ,
type: 'POST',
dataType:'json',
data: {
empty: 'empty'
},
success: function(data) {
$('.tgrep.results_list').empty();
$('.tgrep.results_gallery').empty();
$('.tgrep.header_count').html(0);
setBasketCount(data);
removeUselessActionsFromEmptyShelf();
}
});
});
basketItemString = document.querySelector('#basketItemString').dataset.value;
});
// set by jsp
var basketItemString;
// removes the tguri from aggregatorUrl
function removeFromAggregatorItemString(tgObjectUri) {
var basketItemStringOld = basketItemString;
var itemArr = basketItemString.split(',');
itemArr.splice(itemArr.indexOf(tgObjectUri),1);
// are there any objects left on the shelf?
if(itemArr.length > 0) {
basketItemString = itemArr.join(',');
document.querySelectorAll('.aggregator-items').forEach( elem => {
elem.href = elem.href.replace(basketItemStringOld, basketItemString);
});
} else {
removeUselessActionsFromEmptyShelf();
}
}
// disable download and voyant links if shelf is empty
function removeUselessActionsFromEmptyShelf() {
document.querySelectorAll('.remove_on_shelf_empty').forEach( elem => {
elem.remove();
});
}
\ No newline at end of file
Sentry.init({ dsn: 'https://0e2560ec0cda414897840b800e9c03e7@dev2.discuss-data.net/4' });
# Theme for textgridrep.org
Originating from the [Liferay 6 Theme for textgrid.de](https://projects.gwdg.de/projects/liferay-textgrid)
Note: the Sass was formerly built with gulp and made use of globbing. This
is not supported by sass-dart, so we now have an _index.sass in every subdir.
## Extending the theme (aka adding styles)
Styles are written in Sass (indented syntax), using a variant of the
[BEM](https://en.bem.info/method/) naming scheme for class names. In BEM -
meaning block, element, modifier - all styles belong to one of these types:
- `.block` represents the higher level of an abstraction or component
- `.block_element`, divided by `_`, represents a descendent of .block. Use only
one level of descendency, it does not have to correspond with the actual DOM.
- `.-modifier`, prepended by `-` (think command-line switch), represents a
different state of a .block or .block_element and can only be used
alongside those.
In Sass, this looks like `.namespace.block-name_element-name &.-modifier-name.`
Namespace is added to improve specifity and thus override default styles. This
corresponds to
`<element class="namespace block-name_element-name -modifier-name"`> in
HTML/Velocity. Up to two class-less child elements are fine if otherwise extra
overrides would be necessary. Use !important only for base theme overrides
as a last resort.
// Link styles for Liferay web content and RSS portlet
.journal-content-article,
.portlet-rss,