Allow default alignment changes
Change-Id: I0815983f974c0a3d6919e973c65310ac30e93480
diff --git a/Changes b/Changes
index b94ec89..7cc30b2 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.60 2025-07-04
+0.60 2025-09-19
- Tour stops gracefully if there are no results (closes #189; hebasta)
- Create top navbar and modify sidebar. (uyen-nhu)
- Improve appearance of title-addon on logo. (uyen-nhu)
@@ -18,6 +18,7 @@
- Support non-indexed annotations in match tables (diewald)
- Improve explanation of timed-out match counts (diewald)
- Support response pipes (preliminary; diewald)
+ - Support default alignment changes (diewald)
0.59 2025-03-28
- Docker only release (diewald)
diff --git a/dev/js/src/panel/result.js b/dev/js/src/panel/result.js
index 7d771ad..c9aa44d 100644
--- a/dev/js/src/panel/result.js
+++ b/dev/js/src/panel/result.js
@@ -91,9 +91,17 @@
/**
* Toggle the alignment (left <=> right)
*/
- this.actions().add(loc.TOGGLE_ALIGN, {'cls':['align','right','button-icon']}, function (e) {
- var olCl = d.querySelector('#search > ol').classList;
+ let olCl = d.querySelector('#search > ol').classList;
+ let buttonInit = "right";
+ aRoll.find(function(align, i) {
+ if (olCl.contains('align-' + align)) {
+ buttonInit = aRoll[i >= 2 ? 0 : i+1];
+ return true;
+ };
+ });
+
+ this.actions().add(loc.TOGGLE_ALIGN, {'cls':['align',buttonInit,'button-icon']}, function (e) {
aRoll.find(function(align, i) {
if (olCl.contains('align-' + align)) {
const n = i >= 2 ? 0 : i+1;
diff --git a/kalamar.conf b/kalamar.conf
index 56a6358..f5bed8e 100644
--- a/kalamar.conf
+++ b/kalamar.conf
@@ -69,7 +69,8 @@
## Adjust defaults
# defaults => {
# items_per_page => 20,
- # context => '20-t,20-t'
+ # context => '20-t,20-t',
+ # alignment => 'left' # or 'right' or 'center'
# }
}
}
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index cd23dbf..462e9ba 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -328,12 +328,14 @@
$self->defaults(
items_per_page => 25,
context => '40-t,40-t', # Before: 'base/s:p'/'paragraph'
+ alignment => 'left'
);
if (exists $conf->{defaults}) {
my $def = $conf->{defaults};
- $self->defaults(items_per_page => $def->{items_per_page}) if $def->{items_per_page};
- $self->defaults(context => $def->{context}) if $def->{context};
+ foreach (qw!items_per_page context alignment!) {
+ $self->defaults($_ => $def->{$_}) if $def->{$_};
+ };
};
# Configure documentation navigation
diff --git a/t/query.t b/t/query.t
index 9b51aab..2ac2ac6 100644
--- a/t/query.t
+++ b/t/query.t
@@ -197,6 +197,10 @@
->content_like(qr!${q}startIndex${q}:0!)
->content_like(qr!${q}itemsPerPage${q}:2!)
+ # Alignment
+ ->element_exists('#search ol.align-left')
+ ->element_exists_not('#search ol.align-right')
+
# No caching
->header_isnt('X-Kalamar-Cache', 'true')
@@ -353,7 +357,6 @@
;
is(defined $err ? $err->text : '', '');
-
my $base_fixtures = path(Mojo::File->new(__FILE__)->dirname, 'fixtures');
my $text_info = $base_fixtures->child('response_textinfo_goe_agi_00000.json')->slurp;
my $fields = decode_json($text_info)->{json}->{document}->{fields};
@@ -382,6 +385,5 @@
is($f->{corpusSigle}, 'GOE');
is($f->{corpusEditor}, 'Trunz, Erich');
-
done_testing;
__END__
diff --git a/templates/search.html.ep b/templates/search.html.ep
index d912abe..7fb540d 100644
--- a/templates/search.html.ep
+++ b/templates/search.html.ep
@@ -27,7 +27,7 @@
<div id="search">
% if (stash('results')->size && stash('total_results') != 0) {
- <ol class="align-left">
+ <ol class="align-<%= stash 'alignment' %>">
%= search_results begin
%= include 'match', match => $_
% end