Skip to content

Instantly share code, notes, and snippets.

@hssktm
Created September 10, 2024 22:22
Show Gist options
  • Save hssktm/c9f3fdc31a8f07cdc9419be7a47cb133 to your computer and use it in GitHub Desktop.
Save hssktm/c9f3fdc31a8f07cdc9419be7a47cb133 to your computer and use it in GitHub Desktop.
Oxygen Builder Temporary Cookies Modal JSON
{"component":{"id":141,"name":"ct_div_block","options":{"ct_id":141,"ct_parent":100004,"selector":"div_block-141-109","original":{"width":"100","width-unit":"%"},"nicename":"Temporary Cookies Modal"},"depth":5,"children":[{"id":5,"name":"ct_code_block","options":{"ct_id":5,"ct_parent":141,"selector":"code_block-5-109","original":{"code-js":"document.addEventListener('DOMContentLoaded', function() {\n var cookieName = \"oxyModalCokkies\";\n var modals = document.querySelectorAll('.oxy-modal-cokkie');\n var closeButtons = [];\n\n if (localStorage.getItem(cookieName) && !sessionStorage.getItem(cookieName)) {\n document.cookie = cookieName + \"=; path=/; max-age=0\";\n localStorage.removeItem(cookieName);\n }\n\n if (document.cookie.split(';').some((item) => item.trim().startsWith(cookieName + '='))) {\n modals.forEach(modal => {\n if (modal && modal.parentElement) {\n modal.parentElement.remove();\n }\n });\n }\n\n modals.forEach(modal => {\n if (modal) {\n closeButtons = modal.querySelectorAll('.oxy-close-modal');\n\n closeButtons.forEach(button => {\n button.addEventListener('click', () => setCookie(modal));\n button.addEventListener('touchstart', () => setCookie(modal));\n });\n\n if (modal.parentElement && modal.parentElement.getAttribute('data-close_on_esc') === 'on') {\n document.addEventListener('keydown', function(event) {\n if (event.key === 'Escape') {\n setCookie(modal);\n }\n });\n }\n\n if (modal.parentElement && !modal.parentElement.classList.contains('oxy-not-closable')) {\n modal.parentElement.addEventListener('click', function(event) {\n if (!modal.contains(event.target)) {\n setCookie(modal);\n }\n });\n }\n\n var parentElement = modal.parentElement;\n var closeAfterTime = parentElement.getAttribute('data-close-after-time');\n var closeAutomatically = parentElement.getAttribute('data-close-automatically');\n \n if (closeAutomatically === 'yes' && closeAfterTime) {\n var timeInSeconds = parseInt(closeAfterTime, 10);\n if (!isNaN(timeInSeconds)) {\n setTimeout(() => {\n setCookie(modal);\n }, timeInSeconds * 1000);\n }\n }\n }\n });\n\n function setCookie(modal) {\n try {\n document.cookie = cookieName + \"=Si; path=/;\";\n localStorage.setItem(cookieName, \"true\");\n sessionStorage.setItem(cookieName, \"true\");\n \n if (modal && modal.parentElement) {\n modal.parentElement.remove();\n }\n } catch (error) {\n ///\n }\n }\n});\n","code-php":"<!---->"},"nicename":"Code Temporary Cookies Modal","activeselector":false},"depth":6},{"id":107,"name":"ct_modal","options":{"ct_id":107,"ct_parent":141,"selector":"modal-107-109","original":{"padding-top":"25","padding-right":"25","padding-bottom":"25","padding-left":"25","trigger_time":"0","custom-js":"","custom-attributes":[{"name":"data-modal-id","value":"cokkies-2"}],"modal_position":"bottom_right","selector-locked":"false","width":"100","max-width":"280","margin-right":"20","margin-bottom":"20","display":"flex","aos-enable":"true","aos-type":"fade-down","background-color":"#ffffff","behavior":"1","trigger":"user_clicks_element","close_on_esc":"off","close_automatically":"no","close_modal_on_backdrop_click":"no","trigger_selector":"#text_block-127-109","close_after_time":"2"},"nicename":"Modal (#107)","activeselector":false,"classes":["oxy-modal-cokkie"]},"depth":6,"children":[{"id":112,"name":"ct_div_block","options":{"ct_id":112,"ct_parent":107,"selector":"div_block-112-109","original":{"width":"100","width-unit":"%","text-align":"center","align-items":"center","gap":"20"},"nicename":"Div (#112)"},"depth":7,"children":[{"id":110,"name":"ct_fancy_icon","options":{"ct_id":110,"ct_parent":112,"selector":"fancy_icon-110-109","original":{"icon-id":"Iconsicon-pie-chart","icon-color":"#e0e0e0","icon-size":"100"},"nicename":"Icon (#110)","activeselector":false},"depth":8},{"id":113,"name":"ct_headline","options":{"ct_id":113,"ct_parent":112,"selector":"headline-113-109","original":{"tag":"h2"},"nicename":"Heading (#113)","ct_content":"Cookies!<br>","activeselector":false},"depth":8},{"id":114,"name":"ct_text_block","options":{"ct_id":114,"ct_parent":112,"selector":"text_block-114-109","original":{},"nicename":"Text (#114)","ct_content":"Cookies help us deliver the best experience on our website. By using our website, you agree to the use of cookies. <span id=\"ct-placeholder-117\"></span>"},"depth":8,"children":[{"id":117,"name":"ct_span","options":{"ct_id":117,"ct_parent":114,"selector":"span-117-109","original":{"text-decoration":"underline"},"nicename":"Span (#117)","ct_content":"Find out how we use cookies."},"depth":9}]},{"id":120,"name":"ct_text_block","options":{"ct_id":120,"ct_parent":112,"selector":"text_block-120-109","original":{"width":"100","width-unit":"%","padding-top":"10","padding-right":"10","padding-bottom":"10","padding-left":"10","border-top-width":"2","border-right-width":"2","border-bottom-width":"2","border-left-width":"2","border-all-width":"2","border-top-style":"solid","border-right-style":"solid","border-bottom-style":"solid","border-left-style":"solid","border-all-style":"solid","border-top-color":"#292930","border-right-color":"#292930","border-bottom-color":"#292930","border-left-color":"#292930","border-all-color":"#292930","font-weight":"600","useCustomTag":"true"},"nicename":"Text (#120)","ct_content":"ACCEPT","activeselector":"oxy-close-modal","classes":["oxy-close-modal"]},"depth":8}]}]}]},"classes":{"oxy-modal-cokkie":{"original":{"selector-locked":"true"},"key":"oxy-modal-cokkie"},"oxy-close-modal":{"key":"oxy-close-modal","original":{"selector-locked":"false","custom-css":"cursor: pointer;"}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment