From 267abc939cb0474b6ff8376d10223db95a7835a3 Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Sun, 30 Sep 2018 22:50:06 +0200 Subject: [PATCH] fix non-exhaustive pattern for modals and remove remaining jquery integration closes #188 --- src/Handler/Utils/Templates.hs | 5 +++++ templates/adminTest.hamlet | 9 ++++----- templates/default-layout-wrapper.hamlet | 27 ------------------------- 3 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/Handler/Utils/Templates.hs b/src/Handler/Utils/Templates.hs index 2204c27f1..771e922f4 100644 --- a/src/Handler/Utils/Templates.hs +++ b/src/Handler/Utils/Templates.hs @@ -25,3 +25,8 @@ modal :: Text -> Maybe [Char] -> WidgetT site IO () modal triggerId (Just modalContent) = do modalId <- newIdent $(widgetFile "widgets/modal") +modal triggerId Nothing = do + modalId <- newIdent + let modalContent :: [Char] + modalContent = "placeholder" + $(widgetFile "widgets/modal") diff --git a/templates/adminTest.hamlet b/templates/adminTest.hamlet index ea27a3906..7638cb944 100644 --- a/templates/adminTest.hamlet +++ b/templates/adminTest.hamlet @@ -22,7 +22,6 @@
  • Kurse anlegen -

    Funktionen zum Testen @@ -33,9 +32,9 @@ ^{btnWdgt}

  • Modals: - ^{modal ".toggler1" Nothing} -
    Klick mich für Ajax-Test + ^{modal "#toggler1" Nothing} + Klick mich für Ajax-Test - ^{modal ".toggler2" (Just "Test Inhalt für Modal")} -
    Klick mich für Content-Test + ^{modal "#toggler2" (Just "Test Inhalt für Modal")} +
    Klick mich für Content-Test diff --git a/templates/default-layout-wrapper.hamlet b/templates/default-layout-wrapper.hamlet index 3eba4f9f1..014edc30f 100644 --- a/templates/default-layout-wrapper.hamlet +++ b/templates/default-layout-wrapper.hamlet @@ -7,38 +7,11 @@ $newline never - #{pageTitle pc} - <meta name="description" content=""> - <meta name="author" content=""> - <meta name="viewport" content="width=device-width,initial-scale=1"> ^{pageHead pc} - \<!--[if lt IE 9]> - \<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> - \<![endif]--> - <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.0.3/js.cookie.min.js"> - <script> - /* The `defaultCsrfMiddleware` Middleware added in Foundation.hs adds a CSRF token to the request cookies. */ - /* AJAX requests should add that token to a header to be validated by the server. */ - /* See the CSRF documentation in the Yesod.Core.Handler module of the yesod-core package for details. */ - var csrfHeaderName = "#{TE.decodeUtf8 $ CI.foldedCase defaultCsrfHeaderName}"; - - var csrfCookieName = "#{TE.decodeUtf8 defaultCsrfCookieName}"; - var csrfToken = Cookies.get(csrfCookieName); - - - if (csrfToken) { - \ $.ajaxPrefilter(function( options, originalOptions, jqXHR ) { - \ if (!options.crossDomain) { - \ jqXHR.setRequestHeader(csrfHeaderName, csrfToken); - \ } - \ }); - } - - <body .no-js .theme--#{toPathPiece currentTheme} :isAuth:.logged-in> <!-- removes no-js class from body if client supports javascript --> <script>