diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html
index c1aa428..c652f00 100755
--- a/frontend/src/ketr-photos/ketr-photos.html
+++ b/frontend/src/ketr-photos/ketr-photos.html
@@ -317,6 +317,11 @@
#holiday [selected] {
font-weight: bold;
}
+
+ .isNext {
+ margin-left: 0.5em;
+ opacity: 0.5;
+ }
@@ -336,7 +341,7 @@
Holidays
- [[item]]
+ [[item]]
@@ -405,7 +410,10 @@
[[item.name]] /
- [[holidayTitle]]
+
+
[[holidayTitle]]
+
(next upcoming Holiday!!)
+
time
Photos taken on [[memoryDate]]
@@ -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));
},
diff --git a/server/lib/pascha.js b/server/lib/pascha.js
index 4ded784..4a01f9f 100644
--- a/server/lib/pascha.js
+++ b/server/lib/pascha.js
@@ -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')) {