소스 검색

Incorporated new page style for legal page

Lee Morgan 6 년 전
부모
커밋
adb4ee166e
4개의 변경된 파일83개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      views/legalPage/legal.ejs
  2. 6 0
      views/legalPage/privacy.js
  3. 6 0
      views/legalPage/terms.js
  4. 67 0
      views/shared/controller.js

+ 4 - 1
views/legalPage/legal.ejs

@@ -10,6 +10,8 @@
     <body>
         <% include ../shared/header %>
 
+        <strand-selector></strand-selector>
+
         <div id="privacyStrand" class="strand">
             <div class="content">
                 <h1>The Subline, LLC Privacy Policy</h1>
@@ -482,7 +484,8 @@
             <p>16.3 All credit card transactions are processed using secure encryption are handled via Third Party Payment Providers.</p>
         </div>
         
-        <script src="/informationPage/legal.js"></script>
+        <script src="/legalPage/privacy.js"></script>
+        <script src="/legalPage/terms.js"></script>
         <script src="/shared/controller.js"></script>
     </body>
 </html>

+ 6 - 0
views/legalPage/privacy.js

@@ -0,0 +1,6 @@
+window.privacyObj = {
+    display: function(){
+        clearScreen();
+        document.querySelector("#privacyStrand").style.display = "flex";
+    }
+}

+ 6 - 0
views/legalPage/terms.js

@@ -0,0 +1,6 @@
+window.termsObj = {
+    display: function(){
+        clearScreen();
+        document.querySelector("#termsStrand").style.display = "flex";
+    }
+}

+ 67 - 0
views/shared/controller.js

@@ -0,0 +1,67 @@
+class StrandSelector extends HTMLElement{
+    constructor(){
+        super();
+    }
+
+    connectedCallback(){
+        setTimeout(()=>{
+            let firstStrand = document.querySelector(".strand");
+            this.setAttribute("strand", firstStrand.id.slice(0, firstStrand.id.indexOf("Strand")));
+            window[`${firstStrand.id.slice(0, firstStrand.id.indexOf("Strand"))}Obj`].display();
+
+            let strands = document.querySelectorAll(".strand");
+            for(let strand of strands){
+                let selector = document.createElement("button");
+                selector.strandName = strand.id;
+                selector.innerText = strand.id.slice(0, strand.id.indexOf("Strand")).toUpperCase();
+                this.appendChild(selector);
+            }
+
+            strands[0].style.display = "flex";
+        })
+    }
+
+    static get observedAttributes(){
+        return ["strand"];
+    }
+
+    attributeChangedCallback(){
+        setTimeout(()=>{
+            let buttons = this.querySelectorAll("button");
+
+            for(let button of buttons){
+                if(button.innerText.toLowerCase() === this.getAttribute("strand").toLowerCase()){
+                    button.style.borderBottom = "3px solid black";
+                    button.style.cursor = "pointer";
+                }else{
+                    button.style.borderBottom = "none";
+                    button.style.cursor = "pointer";
+                    button.onclick = ()=>{
+                        this.setAttribute("strand", button.strandName.slice(0, button.strandName.indexOf("Strand")));
+
+                        window[`${button.strandName.slice(0, button.strandName.indexOf("Strand"))}Obj`].display();
+                    }
+                }
+            }
+        })
+    }
+}
+
+customElements.define("strand-selector", StrandSelector);
+
+let actions = document.querySelectorAll(".action");
+for(let action of actions){
+    action.display = ()=>{window[`${action.id.slice(0, action.id.indexOf("Action"))}Obj`].display();};
+}
+
+let strands = document.querySelectorAll(".strand");
+for(let strand of strands){
+    strand.display = ()=>{window[`${strand.id.slice(0, strand.id.indexOf("Strand"))}Obj`].display();};
+}
+
+window.clearScreen = ()=>{
+    let subpages = document.querySelectorAll(".strand, .action");
+    for(let subpage of subpages){
+        subpage.style.display = "none";
+    }
+}