Skip to content

Commit

Permalink
List at places > index: Slider removed, timeline coverage set to hidd…
Browse files Browse the repository at this point in the history
…en and add toggle function (refs #350)
  • Loading branch information
ut committed Nov 2, 2024
1 parent 6d26e4d commit 881a0ce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 42 deletions.
8 changes: 8 additions & 0 deletions app/assets/javascripts/application.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ jQuery(function ($) {
}
});

// places > index: toggle timeline-list
$('#timeline-list-info').hide();
$('#timeline-list-body').hide();
$('#timeline-list-header').click(function(e){
e.preventDefault();
$('#timeline-list-info').toggle();
$('#timeline-list-body').toggle();
});

// places > form: toggle layer dropdown
$('#move_to_layer').click(function(e){
Expand Down
28 changes: 6 additions & 22 deletions app/assets/javascripts/helpers/timeslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,28 +274,12 @@ $(document).on('changed.zf.slider', '[data-slider]', function(event) {
$('#slider-selection').html($numberInput.val())
const selectedYear = $numberInput.val();

if ( $('body').attr('id') === 'places' ) {
// maps > layers > places > index
const placeDivs = document.querySelectorAll(".place");
placeDivs.forEach(function(div) {
div.classList.add("hidden");
if ( div.dataset.endyear === undefined || div.dataset.endyear === "" ) {
div.dataset.endyear = div.dataset.startyear;
}
console.log("Place",div.dataset,div.dataset.startyear,div.dataset.endyear);

if ( (div.dataset.startyear <= selectedYear && div.dataset.endyear >= selectedYear)
|| ( div.dataset.startyear === undefined || div.dataset.startyear === "" ) ) {
div.classList.remove("hidden");
}
});
} else {
// maps > index
let el = document.getElementById('year'+selectedYear);
var selectedYearPlaces = el.getAttribute('data-places');
$('#selection').data('map-selected-year',selectedYear);
console.log("Slider: changed.zf.slider",selectedYear,selectedYearPlaces)
filterMarkers(selectedYear,selectedYearPlaces);
}
// maps > index
let el = document.getElementById('year'+selectedYear);
var selectedYearPlaces = el.getAttribute('data-places');
$('#selection').data('map-selected-year',selectedYear);
console.log("Slider: changed.zf.slider",selectedYear,selectedYearPlaces)
filterMarkers(selectedYear,selectedYearPlaces);

});
28 changes: 8 additions & 20 deletions app/views/places/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,27 @@
%table#timeline-list
%thead
%tr
%th
%th#timeline-list-header{colspan:2}
%p
- minyear = @places.reject { |place| place.startdate.nil? }.min_by { |place| place.startdate.year }&.startdate&.year || Date.today.year
- maxyear = @places.reject { |place| place.enddate.nil? }.max_by { |place| place.enddate.year }&.enddate&.year || Date.today.year
%b
Timeline
Timeline coverage
from
= minyear
- if minyear != maxyear
\—
= maxyear
- timespan = maxyear-minyear+1
(#{timespan} #{timespan > 1 ? 'years' : 'year'})
>>
%tr
%th#timeline-list-info{colspan:2}
%p
%label.small
Dates in brackets are the new fuzzy dates with qualifiers (this will replace the old date format!)
Displays the "coverage" of all start/enddates in this layer. Dates in brackets are the new fuzzy dates with qualifiers (this replaces the fixed date format)
%i.fi.fi-info{"data-tooltip"=>true, :title=>"This is a new feature to allow to define fuzzy dates, where either the start or end is not exactly known. You have to set a qualifier in the edit form of each place to use this feature."}
%th
&nbsp;
%tbody
%tbody#timeline-list-body
- @places.sort_by{ |e| e.startdate.nil? ? Date.new : e.startdate }.each do |place|
%tr
%td
Expand All @@ -121,20 +122,7 @@
%span.time.time-on>‒
- else
%span.time.time-off>‒
- if @map.enable_time_slider && timespan > 1
%table
%thead
%tr
%th{colspan:2}
Slider
%p.float-right#slider-selection
%strong
= minyear
.slider.radius{"data-slider":true,"data-initial-start":minyear,"data-start":minyear,"data-end":maxyear,"data-step":1}
.slider-handle{"data-slider-handle":true,"role":"slider","tabindex":1}
.slider-fill{"data-slider-fill":true}
%input{"type":"hidden"}
%p.text-right.small
Expand Down

0 comments on commit 881a0ce

Please sign in to comment.