Skip to content

Commit

Permalink
Show places list timeline, plus basic approach w/foundation slider refs
Browse files Browse the repository at this point in the history
  • Loading branch information
ut committed Mar 1, 2024
1 parent 74130a9 commit 5c73d24
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
14 changes: 14 additions & 0 deletions app/assets/javascripts/helpers/timeslider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

jQuery(function ($) {


$(document).on('changed.zf.slider', '[data-slider]', function(event) {
var $slider = $(event.currentTarget);
var $numberInput = $slider.children('input');
console.log($numberInput.val())
$('#slider-selection').html($numberInput.val())
// TODO: create list of all places with startyear and endyear data values
// hide all
// show only those existing in the selected year
});
});
2 changes: 1 addition & 1 deletion app/assets/stylesheets/foundation_and_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@include foundation-orbit;
// @include foundation-pagination;
// @include foundation-progress-bar;
// @include foundation-slider;
@include foundation-slider;
@include foundation-sticky;
@include foundation-reveal;
@include foundation-switch;
Expand Down
51 changes: 50 additions & 1 deletion app/views/places/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,55 @@
All Images of this layer
%p
 
%table
%thead
%tr
%th
- minyear = @places.minimum(:startdate).year
- maxyear = @places.maximum(:enddate).year
%b
Timeline
from
= smart_date_display(@places.minimum(:startdate),nil)
\—
= smart_date_display(@places.maximum(:enddate),nil)
- timespan = maxyear-minyear
(#{timespan} years)
%th
 
%tbody
- @places.sort_by{ |e| e.startdate.nil? ? Date.new : e.startdate }.each do |place|
%tr
%td
%p
= smart_date_display(place.startdate, place.enddate)
%em
= place.title
%td
- for i in minyear..maxyear
- if place.startdate && place.startdate.year == i
%span> ×
- elsif place.startdate && place.startdate.year < i && place.enddate && place.enddate.year > i
%span> &times;
- else
%span>‒
%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"}
%table
%thead
%tr
Expand All @@ -70,7 +119,7 @@
%tbody
- @places.sort_by{ |e| e.startdate.nil? ? Date.new : e.startdate }.each do |place|
%tr
%tr{"data-startyear":(place.startdate ? place.startdate.year : ''),"data-endyear":(place.enddate ? place.enddate.year : '')}
%td
= smart_date_display(place.startdate, place.enddate)
%p.show-for-small-only
Expand Down

0 comments on commit 5c73d24

Please sign in to comment.