Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
67d96b0f
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,发现更多精彩内容 >>
提交
67d96b0f
编写于
8月 27, 2014
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7611 from yglukhov/sticky-diff-headers
Diff headers made sticky.
上级
f089fd5f
6eb85b1a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
173 addition
and
1 deletion
+173
-1
app/assets/javascripts/application.js.coffee
app/assets/javascripts/application.js.coffee
+1
-0
app/assets/javascripts/diff.js.coffee
app/assets/javascripts/diff.js.coffee
+2
-1
vendor/assets/javascripts/jquery.sticky.js
vendor/assets/javascripts/jquery.sticky.js
+170
-0
未找到文件。
app/assets/javascripts/application.js.coffee
浏览文件 @
67d96b0f
...
...
@@ -15,6 +15,7 @@
#= require jquery.atwho
#= require jquery.scrollTo
#= require jquery.blockUI
#= require jquery.sticky
#= require turbolinks
#= require jquery.turbolinks
#= require bootstrap
...
...
app/assets/javascripts/diff.js.coffee
浏览文件 @
67d96b0f
...
...
@@ -34,7 +34,8 @@ class Diff
$
.
get
(
link
,
params
,
(
response
)
=>
target
.
parent
().
replaceWith
(
response
)
)
)
).
ready
=>
$
(
".diff-header"
).
sticky
{
responsiveWidth
:
true
,
getWidthFrom
:
".diff-file"
}
lineNumbers
:
(
line
)
->
return
([
0
,
0
])
unless
line
.
children
().
length
...
...
vendor/assets/javascripts/jquery.sticky.js
0 → 100755
浏览文件 @
67d96b0f
// Sticky Plugin v1.0.0 for jQuery
// =============
// Author: Anthony Garand
// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
// Improvements by Leonardo C. Daronco (daronco)
// Created: 2/14/2011
// Date: 2/12/2012
// Website: http://labs.anthonygarand.com/sticky
// Description: Makes an element on the page stick on the screen as you scroll
// It will only set the 'top' and 'position' of your element, you
// might need to adjust the width in some cases.
(
function
(
$
)
{
var
defaults
=
{
topSpacing
:
0
,
bottomSpacing
:
0
,
className
:
'
is-sticky
'
,
wrapperClassName
:
'
sticky-wrapper
'
,
center
:
false
,
getWidthFrom
:
''
,
responsiveWidth
:
false
},
$window
=
$
(
window
),
$document
=
$
(
document
),
sticked
=
[],
windowHeight
=
$window
.
height
(),
scroller
=
function
()
{
var
scrollTop
=
$window
.
scrollTop
(),
documentHeight
=
$document
.
height
(),
dwh
=
documentHeight
-
windowHeight
,
extra
=
(
scrollTop
>
dwh
)
?
dwh
-
scrollTop
:
0
;
for
(
var
i
=
0
;
i
<
sticked
.
length
;
i
++
)
{
var
s
=
sticked
[
i
],
elementTop
=
s
.
stickyWrapper
.
offset
().
top
,
etse
=
elementTop
-
s
.
topSpacing
-
extra
;
if
(
scrollTop
<=
etse
)
{
if
(
s
.
currentTop
!==
null
)
{
s
.
stickyElement
.
css
(
'
position
'
,
''
)
.
css
(
'
top
'
,
''
);
s
.
stickyElement
.
trigger
(
'
sticky-end
'
,
[
s
]).
parent
().
removeClass
(
s
.
className
);
s
.
currentTop
=
null
;
}
}
else
{
var
newTop
=
documentHeight
-
s
.
stickyElement
.
outerHeight
()
-
s
.
topSpacing
-
s
.
bottomSpacing
-
scrollTop
-
extra
;
if
(
newTop
<
0
)
{
newTop
=
newTop
+
s
.
topSpacing
;
}
else
{
newTop
=
s
.
topSpacing
;
}
if
(
s
.
currentTop
!=
newTop
)
{
s
.
stickyElement
.
css
(
'
position
'
,
'
fixed
'
)
.
css
(
'
top
'
,
newTop
);
if
(
typeof
s
.
getWidthFrom
!==
'
undefined
'
)
{
s
.
stickyElement
.
css
(
'
width
'
,
$
(
s
.
getWidthFrom
).
width
());
}
s
.
stickyElement
.
trigger
(
'
sticky-start
'
,
[
s
]).
parent
().
addClass
(
s
.
className
);
s
.
currentTop
=
newTop
;
}
}
}
},
resizer
=
function
()
{
windowHeight
=
$window
.
height
();
for
(
var
i
=
0
;
i
<
sticked
.
length
;
i
++
)
{
var
s
=
sticked
[
i
];
if
(
typeof
s
.
getWidthFrom
!==
'
undefined
'
&&
s
.
responsiveWidth
===
true
)
{
s
.
stickyElement
.
css
(
'
width
'
,
$
(
s
.
getWidthFrom
).
width
());
}
}
},
methods
=
{
init
:
function
(
options
)
{
var
o
=
$
.
extend
({},
defaults
,
options
);
return
this
.
each
(
function
()
{
var
stickyElement
=
$
(
this
);
var
stickyId
=
stickyElement
.
attr
(
'
id
'
);
var
wrapperId
=
stickyId
?
stickyId
+
'
-
'
+
defaults
.
wrapperClassName
:
defaults
.
wrapperClassName
var
wrapper
=
$
(
'
<div></div>
'
)
.
attr
(
'
id
'
,
stickyId
+
'
-sticky-wrapper
'
)
.
addClass
(
o
.
wrapperClassName
);
stickyElement
.
wrapAll
(
wrapper
);
if
(
o
.
center
)
{
stickyElement
.
parent
().
css
({
width
:
stickyElement
.
outerWidth
(),
marginLeft
:
"
auto
"
,
marginRight
:
"
auto
"
});
}
if
(
stickyElement
.
css
(
"
float
"
)
==
"
right
"
)
{
stickyElement
.
css
({
"
float
"
:
"
none
"
}).
parent
().
css
({
"
float
"
:
"
right
"
});
}
var
stickyWrapper
=
stickyElement
.
parent
();
stickyWrapper
.
css
(
'
height
'
,
stickyElement
.
outerHeight
());
sticked
.
push
({
topSpacing
:
o
.
topSpacing
,
bottomSpacing
:
o
.
bottomSpacing
,
stickyElement
:
stickyElement
,
currentTop
:
null
,
stickyWrapper
:
stickyWrapper
,
className
:
o
.
className
,
getWidthFrom
:
o
.
getWidthFrom
,
responsiveWidth
:
o
.
responsiveWidth
});
});
},
update
:
scroller
,
unstick
:
function
(
options
)
{
return
this
.
each
(
function
()
{
var
unstickyElement
=
$
(
this
);
var
removeIdx
=
-
1
;
for
(
var
i
=
0
;
i
<
sticked
.
length
;
i
++
)
{
if
(
sticked
[
i
].
stickyElement
.
get
(
0
)
==
unstickyElement
.
get
(
0
))
{
removeIdx
=
i
;
}
}
if
(
removeIdx
!=
-
1
)
{
sticked
.
splice
(
removeIdx
,
1
);
unstickyElement
.
unwrap
();
unstickyElement
.
removeAttr
(
'
style
'
);
}
});
}
};
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
if
(
window
.
addEventListener
)
{
window
.
addEventListener
(
'
scroll
'
,
scroller
,
false
);
window
.
addEventListener
(
'
resize
'
,
resizer
,
false
);
}
else
if
(
window
.
attachEvent
)
{
window
.
attachEvent
(
'
onscroll
'
,
scroller
);
window
.
attachEvent
(
'
onresize
'
,
resizer
);
}
$
.
fn
.
sticky
=
function
(
method
)
{
if
(
methods
[
method
])
{
return
methods
[
method
].
apply
(
this
,
Array
.
prototype
.
slice
.
call
(
arguments
,
1
));
}
else
if
(
typeof
method
===
'
object
'
||
!
method
)
{
return
methods
.
init
.
apply
(
this
,
arguments
);
}
else
{
$
.
error
(
'
Method
'
+
method
+
'
does not exist on jQuery.sticky
'
);
}
};
$
.
fn
.
unstick
=
function
(
method
)
{
if
(
methods
[
method
])
{
return
methods
[
method
].
apply
(
this
,
Array
.
prototype
.
slice
.
call
(
arguments
,
1
));
}
else
if
(
typeof
method
===
'
object
'
||
!
method
)
{
return
methods
.
unstick
.
apply
(
this
,
arguments
);
}
else
{
$
.
error
(
'
Method
'
+
method
+
'
does not exist on jQuery.sticky
'
);
}
};
$
(
function
()
{
setTimeout
(
scroller
,
0
);
});
})(
jQuery
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录