From ba4bd7d03ea1927e3c9de26ce0696cd7a50c26c1 Mon Sep 17 00:00:00 2001 From: Justineo Date: Thu, 9 Nov 2017 14:05:38 +0800 Subject: [PATCH 1/2] fix header link --- themes/vue/source/css/_settings.styl | 4 ++-- themes/vue/source/css/page.styl | 6 ++++-- themes/vue/source/js/common.js | 15 ++++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/themes/vue/source/css/_settings.styl b/themes/vue/source/css/_settings.styl index e6f8a59770..9d0e95343c 100644 --- a/themes/vue/source/css/_settings.styl +++ b/themes/vue/source/css/_settings.styl @@ -23,7 +23,7 @@ $header-inner-height = 41px $heading-padding-vertical = 10px $header-height = $header-inner-height + $heading-padding-vertical * 2 $mobile-header-height = 40px -$heading-link-padding-top = $content-padding-top -$mobile-heading-link-padding-top = $content-padding-top +$heading-link-padding-top = $header-height + $content-padding-top +$mobile-heading-link-padding-top = $mobile-header-height + $content-padding-top $h2-margin-top = 45px $h3-margin-top = 52px diff --git a/themes/vue/source/css/page.styl b/themes/vue/source/css/page.styl index 8866789b34..ac1737e582 100644 --- a/themes/vue/source/css/page.styl +++ b/themes/vue/source/css/page.styl @@ -51,6 +51,10 @@ h1 margin: 0 0 1em h2, h3 + pointer-events: none + a + pointer-events: auto + color: $dark &:before content: "" display: block @@ -61,11 +65,9 @@ margin: $h2-margin-top 0 .8em padding-bottom: .7em border-bottom: 1px solid $border - z-index: -1 h3 margin: $h3-margin-top 0 1.2em position: relative - z-index: -1 &:after content: "#" color: $green diff --git a/themes/vue/source/js/common.js b/themes/vue/source/js/common.js index 8474236a99..ce57507aac 100644 --- a/themes/vue/source/js/common.js +++ b/themes/vue/source/js/common.js @@ -1,5 +1,4 @@ (function () { - initMobileMenu() if (PAGE_TYPE) { initVersionSelect() @@ -26,7 +25,7 @@ }) } - function createSourceSearchPath(query) { + function createSourceSearchPath (query) { query = query .replace(/\([^\)]*?\)/g, '') .replace(/(Vue\.)(\w+)/g, '$1$2" OR "$2') @@ -251,7 +250,7 @@ } } if (last) - setActive(last.id, !hoveredOverSidebar) + setActive(last.id, !hoveredOverSidebar) } function makeLink (h) { @@ -337,8 +336,14 @@ function makeHeaderClickable (link) { var wrapper = link.querySelector('a') wrapper.setAttribute('data-scroll', '') - link.parentNode.insertBefore(wrapper, link) - wrapper.appendChild(link) + + var nodes = link.childNodes + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i] + if (node !== wrapper) { + wrapper.appendChild(node) + } + } } } })() From 3051502ae645fae70482c6246f43529f2caf2e95 Mon Sep 17 00:00:00 2001 From: Justineo Date: Fri, 10 Nov 2017 00:37:21 +0800 Subject: [PATCH 2/2] fix cr --- themes/vue/source/css/_settings.styl | 3 +++ themes/vue/source/js/common.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/themes/vue/source/css/_settings.styl b/themes/vue/source/css/_settings.styl index 9d0e95343c..700bf1e974 100644 --- a/themes/vue/source/css/_settings.styl +++ b/themes/vue/source/css/_settings.styl @@ -19,10 +19,13 @@ $info = #1C90F3 $radius = 2px $content-padding-top = 30px + +// header settings $header-inner-height = 41px $heading-padding-vertical = 10px $header-height = $header-inner-height + $heading-padding-vertical * 2 $mobile-header-height = 40px +// prevent headers from being covered by the top nav upon navigation $heading-link-padding-top = $header-height + $content-padding-top $mobile-heading-link-padding-top = $mobile-header-height + $content-padding-top $h2-margin-top = 45px diff --git a/themes/vue/source/js/common.js b/themes/vue/source/js/common.js index ce57507aac..d4b13ced98 100644 --- a/themes/vue/source/js/common.js +++ b/themes/vue/source/js/common.js @@ -337,6 +337,9 @@ var wrapper = link.querySelector('a') wrapper.setAttribute('data-scroll', '') + // transform DOM structure from + // `

Header` to

Header

` + // to make the link clickable var nodes = link.childNodes for (var i = 0; i < nodes.length; i++) { var node = nodes[i]