Holiday selection working

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-11-25 16:19:34 -08:00
parent 9926f8a4b1
commit 045bf530a1
2 changed files with 64 additions and 14 deletions

View File

@ -317,6 +317,11 @@
#holiday [selected] {
font-weight: bold;
}
.isNext {
margin-left: 0.5em;
opacity: 0.5;
}
</style>
<app-location route="{{route}}"></app-location>
@ -336,7 +341,7 @@
<div id="holiday" class="flex layout vertical">
<div>Holidays</div>
<template is="dom-repeat" items="[[holidays]]">
<div tabindex="0" on-tap="loadHoliday">[[item]]</div>
<div tabindex="0" holiday on-tap="loadHoliday">[[item]]</div>
</template>
</div>
<div id="time"><div>... time slider ...</div></div>
@ -405,7 +410,10 @@
<div tabindex="0" on-tap="loadPath">[[item.name]] /</div>
</template>
</div>
<div mode="holiday">[[holidayTitle]]</div>
<div mode="holiday" class="layout horizontal">
<div>[[holidayTitle]]</div>
<div class='isNext' hidden$="[[!isNextHoliday(holidayTitle, nextHoliday)]]">(next upcoming Holiday!!)</div>
</div>
<div mode="time">time</div>
<div mode="memories">Photos taken on <b on-tap="drawerToggle">[[memoryDate]]</b></div>
</iron-pages>
@ -585,9 +593,18 @@
"userChanged(user)",
"daysChanged(days)",
"baseRouteChanged(route.path, basePath)",
"pathChanged(path, route.path, basePath)",
"pathChanged(path, route.path, basePath)"
],
listeners: {
"scroll": "onScroll",
"iron-resize" : "onResize"
},
isNextHoliday: function(holiday, nextHoliday) {
return (holiday == nextHoliday);
},
pathChanged: function(path, routePath, basePath) {
if (!basePath || !routePath || !path) {
return;
@ -864,19 +881,24 @@
}
},
listeners: {
"scroll": "onScroll",
"iron-resize" : "onResize"
},
loadHoliday: function(event) {
highlightHoliday: function(holiday) {
Array.prototype.forEach.call(this.$.holiday.querySelectorAll("[selected]"), function(el) {
el.removeAttribute("selected");
});
event.currentTarget.setAttribute("selected", true);
Array.prototype.forEach.call(this.$.holiday.querySelectorAll("[holiday]"), function(el) {
if (el.textContent == holiday) {
el.setAttribute("selected", true);
}
});
},
loadHoliday: function(event) {
this.holiday = event.model.item;
this.resetPhotos();
this._loadPhotos();
this.highlightHoliday(this.holiday);
if (this.mode == "holiday") {
this.resetPhotos();
this._loadPhotos();
}
},
loadPath: function(event) {
@ -1959,7 +1981,10 @@
}
this.holiday = results.next;
this.nextHoliday = results.next;
this.holidays = results.holidays;
Polymer.dom.flush();
this.highlightHoliday(this.holiday);
}.bind(this));
},

View File

@ -52,14 +52,39 @@ function init(moment) {
//};
});
/*
const orthodoxDates = require("./pascha-dates.js");
var pascha = function(year) {
/* Date lookup table.. */
var date = orthodoxDates[year].split("-");
date[1] -= 1; /* month needs to be zero index */
date[1] -= 1; // month needs to be zero index
return moment(date);
}
*/
/**
* Calculates Easter in the Gregorian/Western (Catholic and Protestant) calendar
* based on the algorithm by Oudin (1940) from http://www.tondering.dk/claus/cal/easter.php
* @returns {array} [int month, int day]
*/
var pascha = function(year) {
var f = Math.floor,
// Golden Number - 1
G = year % 19,
C = f(year / 100),
// related to Epact
H = (C-f(C / 4) - f((8 * C + 13)/25) + 19 * G + 15) % 30,
// number of days from 21 March to the Paschal full moon
I = H - f(H/28) * (1 - f(29/(H + 1)) * f((21-G)/11)),
// weekday for the Paschal full moon
J = (year + f(year / 4) + I + 2 - C + f(C / 4)) % 7,
// number of days from 21 March to the Sunday on or before the Paschal full moon
L = I - J,
month = 3 + f((L + 40)/44),
day = L + 28 - 31 * f(month / 4);
return moment([year, (month - 1),day]);
}
moment.modifyHolidays.extendParser(function(m, date){
if (~date.indexOf('pascha')) {