diff options
author | amazingrise <8315221+AmazingRise@users.noreply.github.com> | 2021-05-14 05:48:02 +0300 |
---|---|---|
committer | amazingrise <8315221+AmazingRise@users.noreply.github.com> | 2021-05-14 05:48:02 +0300 |
commit | 368250ef26613ab014bb78a2bbdea0f45cc8c4b7 (patch) | |
tree | 265685c350314c625a183fde9b26decf3cd8984a | |
parent | 3673a16986c4f71d8e7465d6c7fa512cae64173a (diff) |
Remove components and some of jQuery codes.
-rw-r--r-- | layouts/partials/journal.html | 12 | ||||
-rw-r--r-- | layouts/partials/mobile-header.html | 9 | ||||
-rw-r--r-- | layouts/partials/sidebar.html | 11 | ||||
-rw-r--r-- | static/js/journal.js | 28 | ||||
-rw-r--r-- | static/js/toc-collapse.js | 4 | ||||
-rw-r--r-- | static/js/toc.js | 90 |
6 files changed, 70 insertions, 84 deletions
diff --git a/layouts/partials/journal.html b/layouts/partials/journal.html index 0667cb7..95cdfe5 100644 --- a/layouts/partials/journal.html +++ b/layouts/partials/journal.html @@ -116,12 +116,20 @@ app = new Vue({ region: {{.Site.Params.twikooRegion}}, }); {{ end }} + + document.querySelectorAll("table").forEach(function(elem){ + elem.classList.add("table-striped"); + elem.classList.add("table"); + elem.classList.add("table-responsive"); + elem.classList.add("table-hover"); + }) }, destroyed() { window.removeEventListener('scroll', this.handleScroll); window.removeEventListener('resize', this.handleResize); } }); -</script> -<script src="{{"/js/journal.js" | relURL}}"></script> +new SmoothScroll('a#globalBackToTop'); + +</script>
\ No newline at end of file diff --git a/layouts/partials/mobile-header.html b/layouts/partials/mobile-header.html index 2276cc9..028b73c 100644 --- a/layouts/partials/mobile-header.html +++ b/layouts/partials/mobile-header.html @@ -14,11 +14,14 @@ {{$actived = "active"}} {{end}} {{ if .HasChildren }} - <parent name="{{ .Name }}" type="drawer-menu-item {{$actived}}"> - {{ range .Children }} + <div class="a-block" class="drawer-menu-item {{$actived}}" v-on:click="isHidden = !isHidden"> + {{ .Name }} + <div class="nav-link-subitem" v-if="!isHidden"> + {{ range .Children }} <li><a href="{{ .URL }}"> {{ .Name }}</a></li> {{ end }} - </parent> + </div> + </div> {{ else }} <!--<a class="a-block nav-link-item {{$actived}}" href="{{ .URL }}">--> <a class="a-block drawer-menu-item {{ $actived }}" href="{{ .URL }}"> diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 459965f..897d951 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -23,11 +23,14 @@ {{$actived = "active"}} {{end}} {{ if .HasChildren }} - <parent name="{{ .Name }}" type="nav-link-item {{$actived}}"> - {{ range .Children }} + <div class="a-block" class="nav-link-item {{$actived}}" v-on:click="isHidden = !isHidden"> + {{ .Name }} + <div class="nav-link-subitem" v-if="!isHidden"> + {{ range .Children }} <li><a href="{{ .URL }}"> {{ .Name }}</a></li> - {{ end }} - </parent> + {{ end }} + </div> + </div> {{ else }} <!--<a class="a-block nav-link-item {{$actived}}" href="{{ .URL }}">--> <a class="a-block nav-link-item {{ $actived }}" href="{{ .URL }}"> diff --git a/static/js/journal.js b/static/js/journal.js index fe6d4fe..e69de29 100644 --- a/static/js/journal.js +++ b/static/js/journal.js @@ -1,28 +0,0 @@ -new SmoothScroll('a#globalBackToTop'); - -Vue.component('parent',{ - props:['name','type'], - data: function () { - return { - isHidden: true - } - }, - template: ` - <div class="a-block" :class="type" v-on:click="isHidden = !isHidden"> - {{ name }} - <div class="nav-link-subitem" v-if="!isHidden"> - <slot></slot> - </div> - </div> - ` -}); - -$().ready(function(){ - var elems = $("table"); - elems.each(function(idx){ - $(this).addClass('table-striped'); - $(this).addClass('table'); - $(this).addClass('table-responsive'); - $(this).addClass('table-hover'); - }); -});
\ No newline at end of file diff --git a/static/js/toc-collapse.js b/static/js/toc-collapse.js index fa51778..25212a4 100644 --- a/static/js/toc-collapse.js +++ b/static/js/toc-collapse.js @@ -35,7 +35,7 @@ var onNavClick = function (name) { var elems = $(":header"); elems.each(function (idx) { var id = $(this).attr('id'); - if (name == '#' + id + '-nav'){ + if (name == '#' + id + '-nav') { collapseOthers(idx); return; } @@ -52,7 +52,7 @@ var collapseOthers = function (currentIndex) { var elems = $(":header"); //console.log(currentIndex); currentId = "#" + elems[currentIndex].id + "-nav"; - + $(currentId).parents(".collapse").each(function (idx) { $(this).collapse("show"); }); diff --git a/static/js/toc.js b/static/js/toc.js index 61fdc93..accf88d 100644 --- a/static/js/toc.js +++ b/static/js/toc.js @@ -1,55 +1,55 @@ var spy = function () { - var elems = $(":header"); - if (elems.length == 0) { - return; - } - var currentTop = $(window).scrollTop(); - var currentBottom = $(window).scrollTop() + $(window).height(); - var pageBottom = $('#EOF').offset().top; + var elems = $(":header"); + if (elems.length == 0) { + return; + } + var currentTop = $(window).scrollTop(); + var currentBottom = $(window).scrollTop() + $(window).height(); + var pageBottom = $('#EOF').offset().top; - var meetUnread = false - var currentIndex = -1 - elems.each(function (idx) { - var elemTop = $(this).offset().top; - var id = $(this).attr('id'); - var navElem = $('#' + id + '-nav'); - if (currentTop + $(this).height() >= elemTop || currentBottom >= pageBottom) { - navElem.addClass('toc-active'); - } else { - if (meetUnread == false) { - meetUnread = true - currentIndex = idx - 1 - } - navElem.removeClass('toc-active'); - } - }) + var meetUnread = false + var currentIndex = -1 + elems.each(function (idx) { + var elemTop = $(this).offset().top; + var id = $(this).attr('id'); + var navElem = $('#' + id + '-nav'); + if (currentTop + $(this).height() >= elemTop || currentBottom >= pageBottom) { + navElem.addClass('toc-active'); + } else { + if (meetUnread == false) { + meetUnread = true + currentIndex = idx - 1 + } + navElem.removeClass('toc-active'); + } + }) } $().ready(function () { - $(".collapse").each(function (idx) { - $(this).collapse("show"); - }); - spy(); - $(window).bind('scroll', throttle(spy)); + $(".collapse").each(function (idx) { + $(this).collapse("show"); + }); + spy(); + $(window).bind('scroll', throttle(spy)); }); function throttle(func, timeout = 250) { - let last; - let timer; - - return function () { - const context = this; - const args = arguments; - const now = +new Date(); - - if (last && now < last + timeout) { - clearTimeout(timer) - timer = setTimeout(function () { - last = now - func.apply(context, args) - }, timeout) - } else { + let last; + let timer; + + return function () { + const context = this; + const args = arguments; + const now = +new Date(); + + if (last && now < last + timeout) { + clearTimeout(timer) + timer = setTimeout(function () { last = now func.apply(context, args) - } + }, timeout) + } else { + last = now + func.apply(context, args) } - }
\ No newline at end of file + } +}
\ No newline at end of file |