aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--module/html/view/calendar.scm20
-rw-r--r--module/html/view/calendar/month.scm12
-rw-r--r--module/html/view/calendar/week.scm11
-rw-r--r--static/script.js12
4 files changed, 44 insertions, 11 deletions
diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm
index 76d1e79f..a0de3551 100644
--- a/module/html/view/calendar.scm
+++ b/module/html/view/calendar.scm
@@ -30,7 +30,9 @@
:select (get-git-version))
)
-;; date should be start of month
+;; Small calendar similar to the one below.
+;; TODO highlight days depending on which events they contain
+;; TODO run this standalone, for embedding in other websites.
;; @example
;; må ti on to fr lö sö
;; 1 2 3 4 5 6 7
@@ -39,7 +41,7 @@
;; 22 23 24 25 26 27 28
;; 29 30
;; @end example
-;; date - a date in the month to display
+;; date - The start date of the month to display
(define* (cal-table key: start-date end-date next-start prev-start)
(define (td date)
@@ -99,8 +101,13 @@
;;; and the html-generate procedure also filters, but instead to find earlier eventns.
;;; All this filtering is probably slow, and should be looked into.
+;; TODO place this somewhere proper
(define repo-url (make-parameter "https://git.hornquist.se"))
+
+;; TODO document what @var{render-calendar} is supposed to take and return.
+;; Can at least note that @var{render-calendar} is strongly encouraged to include
+;; (script "const VIEW='??';"), where ?? is replaced by the name of the view.
(define*-public (html-generate
key:
(intervaltype 'all) ; 'week | 'month | 'all
@@ -183,10 +190,11 @@
next-start: next-start
prev-start: prev-start
)
-
- ,@(for event in (stream->list
- (events-between pre-start post-end events))
- (popup event (string-append "popup" (html-id event)))))
+ ;; Popups used to be here, but was moved into render-calendar so each
+ ;; sub-view can itself decide where to put them. This is important
+ ;; since they need to be placed as children to the scrolling
+ ;; component, if one such component exists.
+ )
;; Page footer
(footer
diff --git a/module/html/view/calendar/month.scm b/module/html/view/calendar/month.scm
index 9288fd1a..99640a22 100644
--- a/module/html/view/calendar/month.scm
+++ b/module/html/view/calendar/month.scm
@@ -35,7 +35,8 @@
(events-between s e (list->stream long-events)))))
(date-range pre-start post-end (date day: 7))))
- `((header (@ (class "table-head"))
+ `((script "const VIEW='month';")
+ (header (@ (class "table-head"))
,(string-titlecase (date->string start-date "~B ~Y")))
(div (@ (class "caltable")
(style "grid-template-rows: 2em"
@@ -74,7 +75,14 @@
,@(map make-small-block (stream->list events)))))
short-event-groups
(repeating-naturals 1 7)
- )))))
+ )))
+
+ ;; These popups are relative the document root. Can thus be placed anywhere in the DOM.
+ ,@(for event in (stream->list
+ (events-between start-date end-date events))
+ ((@ (html vcomponent) popup) event
+ (string-append "popup" ((@ (html util) html-id) event))))
+ ))
diff --git a/module/html/view/calendar/week.scm b/module/html/view/calendar/week.scm
index 7da186e1..34e8eeb4 100644
--- a/module/html/view/calendar/week.scm
+++ b/module/html/view/calendar/week.scm
@@ -22,7 +22,8 @@
(define*-public (render-calendar key: events start-date end-date #:allow-other-keys)
(let* ((long-events short-events (partition long-event? (stream->list (events-between start-date end-date events))))
(range (date-range start-date end-date)))
- `((div (@ (class "calendar"))
+ `((script "const VIEW='week';")
+ (div (@ (class "calendar"))
(div (@ (class "days"))
,@(time-marker-div)
(div (@ (class "longevents event-container")
@@ -41,7 +42,13 @@
(stream-map
lay-out-day
(get-groups-between (group-stream (list->stream short-events))
- start-date end-date))))))))
+ start-date end-date)))
+
+ ,@(for event in (stream->list
+ (events-between start-date end-date events))
+ ((@ (html vcomponent ) popup) event (string-append "popup" (html-id event))))
+
+ )))))
diff --git a/static/script.js b/static/script.js
index 785ff23c..7303d1c6 100644
--- a/static/script.js
+++ b/static/script.js
@@ -686,7 +686,17 @@ function close_popup(popup) {
function open_popup(popup) {
popup.classList.add("visible");
let element = document.getElementById(popup.id.substr(5))
- let root = document.body;
+ // let root = document.body;
+ let root;
+ switch (VIEW) {
+ case 'week':
+ root = document.getElementsByClassName("days")[0];
+ break;
+ case 'month':
+ default:
+ root = document.body;
+ break;
+ }
/* start <X, Y> sets offset between top left corner
of event in calendar and popup. 10, 10 soo old
event is still visible */