{"id":6257,"date":"2022-04-07T16:18:22","date_gmt":"2022-04-07T15:18:22","guid":{"rendered":"http:\/\/mom.deptford.red\/?p=6257"},"modified":"2023-03-23T23:13:52","modified_gmt":"2023-03-23T23:13:52","slug":"modals","status":"publish","type":"post","link":"https:\/\/davelevy.info\/prototype\/2022\/04\/07\/modals\/","title":{"rendered":"Modals"},"content":{"rendered":"\n<style>\n.modal {\n    display: none; \/* Hidden by default *\/\n    position: fixed; \/* Stay in place *\/\n    z-index: 1; \/* Sit on top *\/\n    padding-top: 100px; \/* Location of the box *\/\n    \/* left: 0; *\/ \n    top: 0;\n    width: 70%; \/* Full width *\/\n    height: 100%; \/* Full height *\/\n    overflow: auto; \/* Enable scroll if needed *\/\n    background-color: rgb(0,0,0); \/* Fallback color *\/\n    background-color: rgba(0,0,0,0.4); \/* Black w\/ opacity *\/\n}\n        \n\/* Modal Content *\/\n.modal-content { background-color: #fefefe; \n    margin: 5px; font-size: 80%; padding: 5px; \n    width: 80%;\n    border: 1px solid #888; }\n        \n\/* The Close Button *\/\n.close { color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; }    \n.close:hover, .close:focus { color: #000; text-decoration: none; cursor: pointer; }\n    \n.modal-content2 {\n    display: none; \/* Hidden by default *\/\n    background-color: #fefefe;\n    margin: auto; padding: 20px;\n    border: 1px solid #888;\n    width: 80%;\n}\n.close2 { color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; }\n.close2:hover, .close2:focus { color: #000; text-decoration: none;cursor: pointer; }\n\n.scroll-box {\n      width: 650px; \/* maximum width of the box, feel free to change this! *\/\n      overflow-x: scroll; white-space: nowrap;     }\n<\/style>\n<h3>This is a two modal test with event listeners<\/h3>\n\n<p>Test 5: event listener with arguments, on both buttons; the &#8220;close object&#8221; needs to be uniquely named .<!--more--><\/p>\n\n<p>The 2nd Button, strangely<\/p>\n<!-- Trigger\/Open The Modal -->\n<button id=\"myBtn2\">More Latin<\/button><br><br>\n\n<!-- The Modal -->\n<div id=\"myModal2\" class=\"modal\"><!-- Modal content -->\n    <div class=\"modal-content\" style=\"width: 80%;\"> \n        <span class=\"close2\">x<\/span>\n        <p style=\"font-size: 120%;\">A 2nd example modal<\/p>\n        <p style=\"font-size: 102%;\">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.<\/p>\n<\/div>\n<\/div>\n\n<hr>\n\n<p>And no 1<\/p>\n<!-- Trigger\/Open The Modal -->\n<button id=\"myBtn\">Click Me<\/button><br><br>\n<!-- The Modal -->\n<div id=\"myModal\" class=\"modal\">\n\n<!-- Modal content -->\n<div class=\"modal-content\">\n    <span class=\"close\">x<\/span>\n    <p style=\"font-size: 120%;\">An example modal<\/p>\n    <p style=\"font-size: 102%;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<\/p>\n<\/div>\n<\/div>\n\n<p>HTML End<\/p>\n\n<script>\n\/\/ Get the modal  \nfunction showmodal (id,bid, cid) {\n\n    var modal = document.querySelector(id);\n    var btn = document.querySelector(bid);\n    var span = document.querySelector(cid);\n\n    btn.addEventListener(\"click\", function () {\n        modal.style.display = \"block\";\n    });\n\n    span.onclick = function () { modal.style.display = \"none\"; }\n    \/\/ When the user clicks anywhere outside of the modal, close it\n    window.addEventListener(\"click\", function (event) {\n        \/\/console.log(event.target);\n        if (event.target == modal) {\n            modal.style.display = \"none\";\n        }\n    });\n}\n<\/script>\n<script>\nshowmodal(\"#myModal\",\"#myBtn\",\".close\"); \nshowmodal(\"#myModal2\",\"#myBtn2\",\".close2\");\n<\/script>\n<p>End Script<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a two modal test with event listeners and represent the output of Test 5: event listener with arguments, on both buttons; the &#8220;close object&#8221; needs to be uniquely named .<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_share_on_mastodon":"0"},"categories":[9,27,34],"tags":[733,1513,1697],"class_list":["post-6257","post","type-post","status-publish","format-standard","hentry","category-news","category-technology","category-wordpress-technology","tag-html","tag-technology","tag-wordpress"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/posts\/6257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/comments?post=6257"}],"version-history":[{"count":10,"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/posts\/6257\/revisions"}],"predecessor-version":[{"id":6268,"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/posts\/6257\/revisions\/6268"}],"wp:attachment":[{"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/media?parent=6257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/categories?post=6257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davelevy.info\/prototype\/wp-json\/wp\/v2\/tags?post=6257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}