Skip to content

Commit f94b2eb

Browse files
committed
Layout - Restricted content view
1 parent ce351c9 commit f94b2eb

2 files changed

Lines changed: 119 additions & 1 deletion

File tree

sites/layouts/hdn-content.html

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
layout: core
3+
js:
4+
---
5+
{%- include variable-core.liquid -%}
6+
{%- capture page-title -%}
7+
{%- if page.titleH1 -%}
8+
{{ page.titleH1 }}
9+
{%- elsif page.title -%}
10+
{{ page.title }}
11+
{%- else -%}
12+
Page untitled
13+
{%- endif -%}
14+
{%- endcapture -%}
15+
<main property="mainContentOfPage" resource="#wb-main" typeof="WebPageElement">
16+
<script>
17+
18+
/* Logic here to avoid race condition */
19+
20+
// Todo: Only show the details which contain the display action if we are internal - Like we can poke "canada-preview" server
21+
// Todo: Handle the options: Current session and fews days (ex. 3 days period and let's action it right away if enabled
22+
23+
24+
function show-hdn-content() {
25+
let hdnContent = document.querySelector( "template#show-hdn-content" );
26+
let tmpl;
27+
28+
let cloneHdnContent = document.importNode(hdnContent.content, true);
29+
30+
for (const child of cloneHdnContent.childNodes) {
31+
32+
// Take the first comment and get the real content
33+
if ( child.nodeType === 8 ) {
34+
tmpl = document.createElement('template');
35+
tmpl.innerHTML = child.data.replaceAll( "< ! - -", "<!--" ).replaceAll( "- - >", "-->" );
36+
break;
37+
}
38+
}
39+
40+
// Get the fragment
41+
const fragment = tmpl.content,
42+
parent = hdnContent.parentElement;
43+
44+
// Remove the warning content
45+
parent.removeChild( hdnContent.previousElementSibling )
46+
47+
// Add this content to the page next to the template
48+
parent.replaceChild(fragment, hdnContent );
49+
50+
// Return parent for post load action
51+
return parent;
52+
}
53+
</script>
54+
<div class="container">
55+
<section class="alert alert-warning">
56+
<h2>Warning, this page is a demo and content were intentionally hidden</h2>
57+
<p>This is a demo page for web author and developer working on Canada.ca website. If you landed here by mistake, you may want to go on our official web site at <a href="https://www.canada.ca/en.html">https://www.canada.ca/en.html</a>.</p>
58+
<p><a class="btn btn-call-to-action" href="https://www.canada.ca/en.html">Visit Canada.ca</a></p>
59+
<hr>
60+
<details>
61+
<summary>Let me view this demo for:</summary>
62+
<div class="radio">
63+
<label><input type="radio" name="viewoption" value="onetime" checked /> One time</label>
64+
</div>
65+
<div class="radio">
66+
<label><input type="radio" name="viewoption" value="session" /> Current session</label>
67+
</div>
68+
<button class="btn btn-default" type="button">Show the content</button>
69+
</details>
70+
</section>
71+
</container>
72+
<template id="show-hdn-content">
73+
<!--
74+
{{ content | replace: "<!--", "< ! - -" | replace: "-->", "- - >" }}
75+
-->
76+
</template>
77+
<script>
78+
/* Trigger here to undo what preceding and to allow smooth start */
79+
80+
let flag = sessionStorage.getItem("show-hdn-content");
81+
if ( flag && paserInt(flag) === Number.NaN ) {
82+
} else if ( flag ) {
83+
show-hdn-content()
84+
} else {
85+
fetch( "https://cdb-rdc-test.canada.ca" ).then( () => {
86+
setTimeout( function() {
87+
88+
let hdnContentWarnBox = document.querySelector( "template#show-hdn-content" ).previousElementSibling;
89+
let warnBtn = hdnContentWarnBox.querySelector( "details button" );
90+
warnBtn.addEventListener('click', btnClick);
91+
92+
function btnClick() {
93+
// Save for the whole session?
94+
if( hdnContentWarnBox.querySelector( "[name=viewoption]:checked" ) === "session" ) {
95+
sessionStorage.setItem("show-hdn-content") = Date.now();
96+
}
97+
98+
let parent = show-hdn-content();
99+
100+
// Set the focus
101+
parent.focus();
102+
103+
// Initiate WET on the parent
104+
$( parent )
105+
.find( wb.allSelectors )
106+
.addClass( "wb-init" )
107+
.filter( ":not(.wb-init .wb-init)" )
108+
.trigger( "timerpoke.wb" );
109+
110+
}
111+
112+
}, 3000);
113+
} );
114+
};
115+
</script>
116+
117+
{% include page-details/footer.html %}
118+
</main>

templates/all-services/all-services-en.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"language": "en",
55
"altLangPage": "all-services-fr.html",
66
"dateModified": "2025-08-29",
7-
"layout": "no-container",
7+
"layout": "hdn-content",
88
"css": ["https://use.fontawesome.com/releases/v5.8.1/css/all.css"]
99
}
1010
---

0 commit comments

Comments
 (0)