From 9607a7f1b647544eecc1c4f29cd9da1d8f061ff1 Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Sat, 1 Jun 2024 10:31:10 -0600 Subject: gallery image modal --- .../clojurescript/woodriverlessons/src/core.cljs | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/webapps/woodriverlessons/clojurescript/woodriverlessons/src/core.cljs b/lisp/webapps/woodriverlessons/clojurescript/woodriverlessons/src/core.cljs index 6066008..737b20c 100644 --- a/lisp/webapps/woodriverlessons/clojurescript/woodriverlessons/src/core.cljs +++ b/lisp/webapps/woodriverlessons/clojurescript/woodriverlessons/src/core.cljs @@ -71,6 +71,8 @@ (declare render-about-us-modify-submit) (declare render-gallery) (declare template-gallery-view) +(declare template-gallery-image-fullscreen) +(declare on-gallery-image-clicked ) (declare handler-gallery-view) (declare render-gallery-view) (declare on-gallery-add-clicked) @@ -560,9 +562,28 @@ (hiccups/defhtml template-gallery [jsonobj] [:h1 {:style "text-align: center"} "Gallery"] [:div {:id "content"}] - [:div {:id "modify" + [:div {:id "image" :class "modal fade" :role "dialog"} + [:div {:class "modal-dialog modal-lg"} + [:div {:class "modal-content"} + [:div {:class "modal-header"} + [:button {:type "button" + :class "close" + :data-dismiss "modal"} + "×"]] + [:div {:id "image-body" + :class "modal-body" + :style "height: 83vh"}] + [:div {:class "modal-footer"} + [:button {:type "submit" + :class "btn btn-danger btn-default" + :data-dismiss "modal"} + [:span {:class "glyphicon glyphicon-remove"}] + "Close"]]]]] + [:div {:id "modify" + :class "modal fade" + :role "dialog"} [:div {:class "modal-dialog modal-lg"} [:div {:class "modal-content"} [:div {:class "modal-header"} @@ -616,8 +637,10 @@ :referrerpolicy "strict-origin-when-cross-origin" :allowfullscreen "allowfullscreen"}] :else - [:img {:height "405" - :src (str "/gallery/file/view?id=" (get rec "id"))}])] + (let [img-src (str "/gallery/file/view?id=" (get rec "id"))] + [:img {:height "405" + :src img-src + :onclick (str (namespace ::x) ".on_gallery_image_clicked('" img-src "')")}]))] (when (get jsonobj "adminP") [:td {:style "text-align:right; vertical-align:top"} [:img {:src "/static/images/edit.png" @@ -632,6 +655,14 @@ [:tr [:td " "]]]])))) +(hiccups/defhtml template-gallery-image-fullscreen [src] + [:img {:src src + :style "height: 80vh"}]) + +(defn on-gallery-image-clicked [src] + (dommy/set-html! (dommy/sel1 :#image-body) (template-gallery-image-fullscreen src)) + (.modal (jquery "#image"))) + (defn handler-gallery-view [response] (let [jsonobj (js->clj (js/JSON.parse response))] (auth-notifications jsonobj) -- cgit v1.3