Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
71b70feb
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
71b70feb
编写于
12月 06, 2017
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Greatly improve sidebar when width < 700px
上级
9c49f401
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
70 addition
and
5 deletion
+70
-5
src/librustdoc/html/layout.rs
src/librustdoc/html/layout.rs
+1
-0
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+7
-0
src/librustdoc/html/static/main.js
src/librustdoc/html/static/main.js
+37
-1
src/librustdoc/html/static/rustdoc.css
src/librustdoc/html/static/rustdoc.css
+25
-4
未找到文件。
src/librustdoc/html/layout.rs
浏览文件 @
71b70feb
...
...
@@ -65,6 +65,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
{before_content}
<nav class="sidebar">
<div class="sidebar-menu">☰</div>
{logo}
{sidebar}
</nav>
...
...
src/librustdoc/html/render.rs
浏览文件 @
71b70feb
...
...
@@ -3542,6 +3542,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let
cx
=
self
.cx
;
let
it
=
self
.item
;
let
parentlen
=
cx
.current
.len
()
-
if
it
.is_mod
()
{
1
}
else
{
0
};
let
mut
should_close
=
false
;
if
it
.is_struct
()
||
it
.is_trait
()
||
it
.is_primitive
()
||
it
.is_union
()
||
it
.is_enum
()
||
it
.is_mod
()
||
it
.is_typedef
()
...
...
@@ -3575,6 +3576,8 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
}
}
write!
(
fmt
,
"<div class=
\"
sidebar-elems
\"
>"
)
?
;
should_close
=
true
;
match
it
.inner
{
clean
::
StructItem
(
ref
s
)
=>
sidebar_struct
(
fmt
,
it
,
s
)
?
,
clean
::
TraitItem
(
ref
t
)
=>
sidebar_trait
(
fmt
,
it
,
t
)
?
,
...
...
@@ -3625,6 +3628,10 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!
(
fmt
,
"<script defer src=
\"
{path}sidebar-items.js
\"
></script>"
,
path
=
relpath
)
?
;
}
if
should_close
{
// Closes sidebar-elems div.
write!
(
fmt
,
"</div>"
)
?
;
}
Ok
(())
}
...
...
src/librustdoc/html/static/main.js
浏览文件 @
71b70feb
...
...
@@ -106,6 +106,24 @@
return
(
elem
.
offsetParent
===
null
)
}
function
showSidebar
()
{
document
.
getElementsByClassName
(
"
sidebar-elems
"
)[
0
].
style
.
display
=
"
block
"
;
var
sidebar
=
document
.
getElementsByClassName
(
'
sidebar
'
)[
0
];
sidebar
.
style
.
position
=
'
fixed
'
;
sidebar
.
style
.
width
=
'
100%
'
;
sidebar
.
style
.
marginLeft
=
'
0
'
;
document
.
getElementsByTagName
(
"
body
"
)[
0
].
style
.
marginTop
=
'
45px
'
;
}
function
hideSidebar
()
{
document
.
getElementsByClassName
(
"
sidebar-elems
"
)[
0
].
style
.
display
=
""
;
var
sidebar
=
document
.
getElementsByClassName
(
'
sidebar
'
)[
0
];
sidebar
.
style
.
position
=
''
;
sidebar
.
style
.
width
=
''
;
sidebar
.
style
.
marginLeft
=
''
;
document
.
getElementsByTagName
(
"
body
"
)[
0
].
style
.
marginTop
=
''
;
}
// used for special search precedence
var
TY_PRIMITIVE
=
itemTypes
.
indexOf
(
"
primitive
"
);
...
...
@@ -130,6 +148,8 @@
}
function
highlightSourceLines
(
ev
)
{
// If we're in mobile mode, we should add the sidebar in any case.
hideSidebar
();
var
search
=
document
.
getElementById
(
"
search
"
);
var
i
,
from
,
to
,
match
=
window
.
location
.
hash
.
match
(
/^#
?(\d
+
)(?:
-
(\d
+
))?
$/
);
if
(
match
)
{
...
...
@@ -1459,7 +1479,7 @@
// delayed sidebar rendering.
function
initSidebarItems
(
items
)
{
var
sidebar
=
document
.
getElementsByClassName
(
'
sidebar
'
)[
0
];
var
sidebar
=
document
.
getElementsByClassName
(
'
sidebar
-elems
'
)[
0
];
var
current
=
window
.
sidebarCurrent
;
function
block
(
shortty
,
longty
)
{
...
...
@@ -1829,6 +1849,22 @@
removeClass
(
search
,
"
hidden
"
);
search
.
innerHTML
=
'
<h3 style="text-align: center;">Loading search results...</h3>
'
;
}
var
sidebar_menu
=
document
.
getElementsByClassName
(
"
sidebar-menu
"
)[
0
];
if
(
sidebar_menu
)
{
sidebar_menu
.
onclick
=
function
()
{
var
sidebar
=
document
.
getElementsByClassName
(
'
sidebar
'
)[
0
];
if
(
sidebar
.
style
.
position
===
"
fixed
"
)
{
hideSidebar
();
}
else
{
showSidebar
();
}
};
}
window
.
onresize
=
function
()
{
hideSidebar
();
};
}());
// Sets the focus on the search bar at the top of the page
...
...
src/librustdoc/html/static/rustdoc.css
浏览文件 @
71b70feb
...
...
@@ -263,6 +263,10 @@ nav.sub {
width
:
100%
;
}
.sidebar-menu
{
display
:
none
;
}
.content
{
padding
:
15px
0
;
}
...
...
@@ -823,7 +827,7 @@ span.since {
position
:
static
;
}
.sidebar
.location
{
.sidebar
>
.location
{
float
:
right
;
margin
:
0px
;
margin-top
:
2px
;
...
...
@@ -843,16 +847,33 @@ span.since {
margin-top
:
5px
;
margin-bottom
:
5px
;
float
:
left
;
margin-left
:
50px
;
}
nav
.sub
{
margin
:
0
auto
;
.sidebar-menu
{
position
:
absolute
;
font-size
:
2rem
;
cursor
:
pointer
;
margin-top
:
2px
;
display
:
block
;
}
.sidebar
.block
{
.sidebar-elems
{
background-color
:
#F1F1F1
;
position
:
fixed
;
z-index
:
1
;
left
:
0
;
top
:
45px
;
bottom
:
0
;
overflow-y
:
auto
;
border-right
:
1px
solid
#000
;
display
:
none
;
}
nav
.sub
{
margin
:
0
auto
;
}
.content
{
margin-left
:
0px
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录