Skip to content

Commit

Permalink
Merge pull request #11 from hailaz/master
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Jan 11, 2020
2 parents 7f73cdf + e6cd5ee commit 4e977c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 62 deletions.
27 changes: 3 additions & 24 deletions public/resource/css/document/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ blockquote {
#main-markdown-404 {
text-align: center;
}
#main-markdown-content {
#main-markdown-content, main-markdown-toc {
display:none;
}
#menu-icon {
Expand All @@ -33,39 +33,20 @@ blockquote {
top: 22px;
}

#main-markdown-toc {
display: none;
width: 240px;
padding-top: 20px;
}
#main-markdown-toc ul {
margin:0 !important;
}

#menu-icon, #menu-icon:visited {
color: #666;
}

#help-icon {
position: fixed;
right: 270px;
right: 50px;
top: 22px;
}

#help-icon, #help-icon:visited {
color: #666;
}

#toc-icon {
position: fixed;
right: 273px;
top: 62px;
}

#toc-icon, #toc-icon:visited {
color: #666;
}

#totop-icon, #totop-icon:visited {
color: #666;
}
Expand Down Expand Up @@ -298,7 +279,6 @@ li.active {
margin: 10px;
}


#toc-icon {
position: fixed;
right: 52px;
Expand All @@ -311,5 +291,4 @@ li.active {

#toc-icon, #toc-icon:visited, #toc-icon-close {
color: #666;
}

}
43 changes: 6 additions & 37 deletions public/resource/js/document/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ function tocOn() {
}
});
}

// 插入代码
function isEleExist(id) {
if($("#"+id).length <= 0) {
Expand Down Expand Up @@ -225,7 +224,7 @@ function reloadMainMarkdown() {
//用于检测代码块是否有纵向滚动条
$(".check-scroll").each(function(){
var ua=navigator.userAgent;
if(hasScrolled(this ,'vertical') && ua.search("Mobile") == -1){
if(hasScrolled(this ,'vertical') && ua.search("Mobile")==-1){
if(ua.search("Windows NT")!=-1){
$(this).prev().find("span").css("padding","2px 22px");
}else{
Expand All @@ -240,40 +239,19 @@ function reloadMainMarkdown() {
'class' : 'toc',
'targetId': 'main-markdown-toc'
} );
if ($('#main-markdown-toc .toc').html() == "undefined") {
$('#main-markdown-toc').html("");
hideToc()
} else {
showToc()
}
// 首页不展示TOC
if (window.location.pathname == "/index") {
hideToc()
if ($('#main-markdown-toc').html().length > 0) {
var html = $("#main-markdown-view").html().replace("<p>[TOC]</p>", $('#main-markdown-toc').html());
html += $("#powered").html();
$("#main-markdown-view").html(html)
}
var html = $("#main-markdown-view").html().replace("<p>[TOC]</p>", "");
html += $("#powered").html();
$("#main-markdown-view").html(html);

copyBtnOn();
tocOn();
}
replaceHrefAndSrc();
updateHelpUrl(window.location.pathname);
}

// 显示TOC
function showToc() {
$("#help-icon").css("right", "270px");
$("#toc-icon").css("right", "273px");
$("#main-markdown-toc").show();
}

// 隐藏TOC
function hideToc() {
$("#help-icon").css("right", "20px");
$("#toc-icon").css("right", "23px");
$("#main-markdown-toc").hide();
}

// 更新文档markdown链接地址
function updateHelpUrl(uri) {
$("#help-icon").attr("href", "https://github.com/gogf/gf-doc/tree/master" + uri + ".md");
Expand Down Expand Up @@ -400,15 +378,6 @@ $(function() {
}
});

// TOC关闭隐藏
$("#toc-icon").click(function () {
if ($("#main-markdown-toc").css("display") == "none") {
showToc()
} else {
hideToc()
}
});

// 搜索按钮
$("#search-input button").click(function () {
var key = $("#search-key").val();
Expand Down
2 changes: 1 addition & 1 deletion template/document/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{{include "document/include/404.html" .}}
{{end}}
</div>
<div id="main-markdown-toc"></div>
<div id="main-markdown-toc" style="display:none;"></div>
<div id="powered" style="display:none;">
<div id="powered-bottom">Powered by <a href="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/gogf/gf" target="_blank">GoFrame {{.GF.version}}</a></div>
</div>
Expand Down

0 comments on commit 4e977c2

Please sign in to comment.