Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
75054174
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75054174
编写于
7月 19, 2017
作者:
P
Phil Hughes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moved JS & only run when new_nav cookie exists
上级
ad633afd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
78 addition
and
27 deletion
+78
-27
app/assets/javascripts/fly_out_nav.js
app/assets/javascripts/fly_out_nav.js
+35
-0
app/assets/javascripts/layout_nav.js
app/assets/javascripts/layout_nav.js
+6
-0
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-27
spec/javascripts/fly_out_nav_spec.js
spec/javascripts/fly_out_nav_spec.js
+37
-0
未找到文件。
app/assets/javascripts/fly_out_nav.js
0 → 100644
浏览文件 @
75054174
export
const
calculateTop
=
(
boundingRect
,
outerHeight
)
=>
{
const
windowHeight
=
window
.
innerHeight
;
const
bottomOverflow
=
windowHeight
-
(
boundingRect
.
top
+
outerHeight
);
return
bottomOverflow
<
0
?
boundingRect
.
top
-
Math
.
abs
(
bottomOverflow
)
:
boundingRect
.
top
;
};
export
const
createArrowStyles
=
(
boundingRect
,
top
)
=>
`.sidebar-sub-level-items::before { transform: translate3d(0,
${
boundingRect
.
top
-
top
}
px, 0); }`
;
export
default
()
=>
{
const
style
=
document
.
createElement
(
'
style
'
);
document
.
head
.
appendChild
(
style
);
$
(
'
.sidebar-top-level-items > li:not(.active)
'
).
on
(
'
mouseover
'
,
(
e
)
=>
{
const
$this
=
e
.
currentTarget
;
const
$subitems
=
$
(
'
.sidebar-sub-level-items
'
,
$this
).
show
();
if
(
$subitems
.
length
)
{
const
boundingRect
=
$this
.
getBoundingClientRect
();
const
top
=
calculateTop
(
boundingRect
,
$subitems
.
outerHeight
());
$subitems
.
css
({
transform
:
`translate3d(0,
${
top
}
px, 0)`
,
});
style
.
sheet
.
insertRule
(
createArrowStyles
(
boundingRect
,
top
),
0
);
}
}).
on
(
'
mouseout
'
,
(
e
)
=>
{
$
(
'
.sidebar-sub-level-items
'
,
e
.
currentTarget
).
hide
();
if
(
style
.
sheet
.
rules
.
length
)
{
style
.
sheet
.
deleteRule
(
0
);
}
});
};
app/assets/javascripts/layout_nav.js
浏览文件 @
75054174
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, no-unused-vars, one-var, one-var-declaration-per-line, vars-on-top, max-len */
import
Cookies
from
'
js-cookie
'
;
import
_
from
'
underscore
'
;
import
initFlyOutNav
from
'
./fly_out_nav
'
;
(
function
()
{
var
hideEndFade
;
...
...
@@ -54,5 +56,9 @@ import _ from 'underscore';
$
(()
=>
{
$
(
window
).
on
(
'
scroll
'
,
_
.
throttle
(
applyScrollNavClass
,
100
));
if
(
Cookies
.
get
(
'
new_nav
'
)
===
'
true
'
)
{
initFlyOutNav
();
}
});
}).
call
(
window
);
app/assets/javascripts/main.js
浏览文件 @
75054174
...
...
@@ -347,31 +347,4 @@ $(function () {
gl
.
utils
.
renderTimeago
();
$
(
document
).
trigger
(
'
init.scrolling-tabs
'
);
const
style
=
document
.
createElement
(
"
style
"
);
document
.
head
.
appendChild
(
style
);
$
(
'
.sidebar-top-level-items > li:not(.active)
'
).
on
(
'
mouseover
'
,
(
e
)
=>
{
const
windowHeight
=
window
.
innerHeight
;
const
$this
=
e
.
currentTarget
;
const
$subitems
=
$
(
'
.sidebar-sub-level-items
'
,
$this
).
show
();
if
(
$subitems
.
length
)
{
const
boundingRect
=
$this
.
getBoundingClientRect
();
const
bottomOverflow
=
windowHeight
-
(
boundingRect
.
top
+
$subitems
.
outerHeight
());
const
top
=
bottomOverflow
<
0
?
boundingRect
.
top
-
Math
.
abs
(
bottomOverflow
)
:
boundingRect
.
top
;
$subitems
.
css
({
transform
:
`translate3d(0,
${
top
}
px, 0)`
,
});
style
.
sheet
.
insertRule
(
`.sidebar-sub-level-items::before { transform: translate3d(0,
${
boundingRect
.
top
-
top
}
px, 0); }`
,
0
);
}
}).
on
(
'
mouseout
'
,
(
e
)
=>
{
$
(
'
.sidebar-sub-level-items
'
,
e
.
currentTarget
).
hide
();
if
(
style
.
sheet
.
rules
.
length
)
{
style
.
sheet
.
deleteRule
(
0
);
}
});
});
spec/javascripts/fly_out_nav_spec.js
0 → 100644
浏览文件 @
75054174
import
{
calculateTop
,
createArrowStyles
}
from
'
~/fly_out_nav
'
;
describe
(
'
Fly out sidebar navigation
'
,
()
=>
{
describe
(
'
calculateTop
'
,
()
=>
{
it
(
'
returns boundingRect top
'
,
()
=>
{
const
boundingRect
=
{
top
:
100
,
};
expect
(
calculateTop
(
boundingRect
,
100
),
).
toBe
(
100
);
});
it
(
'
returns boundingRect - bottomOverflow
'
,
()
=>
{
const
boundingRect
=
{
top
:
window
.
innerHeight
,
};
expect
(
calculateTop
(
boundingRect
,
100
),
).
toBe
(
window
.
innerHeight
-
100
);
});
});
describe
(
'
createArrowStyles
'
,
()
=>
{
it
(
'
returns translate3d styles
'
,
()
=>
{
const
boundingRect
=
{
top
:
100
,
};
expect
(
createArrowStyles
(
boundingRect
,
50
),
).
toContain
(
'
translate3d(0, 50px, 0)
'
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录