Welcome to mirror list, hosted at ThFree Co, Russian Federation.

toggleTheme.html « partials « layouts - github.com/darshanbaral/aafu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eb437c2434252322c243b44573558f80e35a3b1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{{ if .Site.Params.theme.allowToggle }}
<div class="toggleSwitchContainer" style="width: 45px; height: 45px;">
  <i
    class="fas fa-toggle-on zoomlink"
    id="toggle"
    title="Toggle Theme"
    onclick="toggleTheme(this)"
  ></i>
</div>

<script>
  //const mainTheme =
  //  "{{ print (`/css/aafu_` | relURL) .Site.Params.theme.mainTheme `.css` }}";
  //const altTheme =
  //  "{{ print (`/css/aafu_` | relURL) .Site.Params.theme.altTheme `.css` }}";
  const currentCSS = document.querySelector("#color-CSS");
  function toggleTheme(elem) {
    //console.log("." + mainTheme);
    //console.log(altTheme);
    elem.classList.toggle("fa-toggle-off");
    elem.classList.toggle("fa-toggle-on");
    currentTheme = currentTheme === mainTheme ? altTheme : mainTheme;
    foo(currentTheme);
  }

  function changeThemeColor() {
    themeColor.content = getComputedStyle(document.body)["background-color"];
  }
  const thisBody = document.body;
  thisBody.addEventListener("webkitTransitionEnd", changeThemeColor);
  thisBody.addEventListener("transitionend", changeThemeColor);
</script>
{{ end }}