提交 d6925c26 编写于 作者: E edisonxiang

docs navigate correctly

上级 7aef7778
<nav>
<!-- {{ partial "docs/search" . }} -->
{{ partial "docs/search" . }}
{{ partial "docs/inject/menu-before" . }}
{{ if .Site.Params.BookMenuBundle }}
......
{{ if default true .Site.Params.BookSearch }}
<div class="book-search">
<div class="book-search" style="display: none;">
<input type="text" placeholder="Search" id="book-search-input" maxlength="64" readonly />
<div class="book-search-spinner spinner hidden"></div>
<ul id="book-search-results"></ul>
......
......@@ -22,12 +22,71 @@
<script type="text/javascript">
$(document).ready(function () {
function getRelativePath() {
var url = location.href;
var arrURL = url.split("//");
return arrURL[1].substring(arrURL[1].indexOf("/"));
}
function getCurrentID(wholeData, relativeURL) {
for (var j in wholeData) {
var href = wholeData[j].a_attr.href;
var text = wholeData[j].text;
//debugger;
if ((href == relativeURL) || (text.indexOf(relativeURL) >= 0)) {
//console.log(wholeData[j].id);
return wholeData[j].id;
} else {
if (wholeData[j].children.length > 0) {
var v = getCurrentID(wholeData[j].children, relativeURL);
if (v != "") {
return v;
}
}
}
}
return "";
}
if ($('#docstreeview').length) {
$('#docstreeview').jstree();
$('#docstreeview').jstree().hide_dots();
$('#docstreeview').jstree().hide_icons();
$('#docstreeview').on("changed.jstree", function (e, data) {
location.href = data.node.a_attr.href;
if (data.node) {
var link = data.node.a_attr.href;
if (link == "" || link == "#") {
var aElementID = "#" + data.node.id + "_anchor";
var aElement = $(aElementID).find("a");
if (aElement.length) {
link = aElement.attr("href");
}
}
console.log(link);
var relativeURL = getRelativePath();
console.log(relativeURL);
if (link != relativeURL) {
location.href = link;
}
}
});
/* select the node by the relative url
var currentAElement = $('#docstreeview').find("a[href='" + getRelativePath() + "']");
if (currentAElement.length) {
console.log("click");
currentAElement.trigger("click");
}*/
$("#docstreeview").on("ready.jstree", function (e, data) {
$("#docstreeview").fadeIn("slow")
var relativeURL = getRelativePath();
var wholeData = $("#docstreeview").jstree().get_json();
var currentID = getCurrentID(wholeData, relativeURL);
console.log(currentID);
$("#docstreeview").jstree()._open_to(currentID);
$('#docstreeview').jstree().select_node(currentID);
});
}
function showNav() {
......@@ -41,7 +100,7 @@
}).attr("onoff", "off");
}
$("#slideNav").bind('click' ,function(){
$("#slideNav").bind('click', function () {
if ($('#menu').attr("onoff") == "on") {
hideNav();
} else {
......
......@@ -449,8 +449,26 @@ footer .notice span {
margin-bottom: 148px;
}
.jstree-default .jstree-anchor {
height: 35px !important;
.book-menu .jstree-default .jstree-anchor {
height: 36px;
text-decoration: none;
color: inherit;
padding: 6px 0px;
}
.book-menu .jstree-default .jstree-anchor a {
text-decoration: none;
color: inherit;
}
.book-menu .jstree-default .jstree-anchor.jstree-hovered,
.book-menu .jstree-default .jstree-anchor.jstree-clicked {
color: #ffffff;
background-color: #467fbf;
}
.book-menu .jstree-default .jstree-icon.jstree-ocl {
margin-top:6px;
}
.table-bordered.table-striped td {
......@@ -469,8 +487,6 @@ footer .notice span {
line-height: 25px;
}
.divmail ul li a {
margin-left: 10px;
}
......@@ -491,6 +507,10 @@ footer .notice span {
text-decoration: none !important;
}
#docstreeview {
display: none;
}
/*html {
min-width: 1280px;
max-width: 1920px;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册