Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8c64e8b4
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,发现更多精彩内容 >>
未验证
提交
8c64e8b4
编写于
10月 12, 2017
作者:
M
Mike Greiling
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
convert CompareAutocomplete from class definition into simple function call, remove global export
上级
9f51a70e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
65 deletion
+56
-65
app/assets/javascripts/compare_autocomplete.js
app/assets/javascripts/compare_autocomplete.js
+54
-62
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-2
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-1
未找到文件。
app/assets/javascripts/compare_autocomplete.js
浏览文件 @
8c64e8b4
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */
window
.
CompareAutocomplete
=
(
function
()
{
function
CompareAutocomplete
()
{
this
.
initDropdown
();
}
CompareAutocomplete
.
prototype
.
initDropdown
=
function
()
{
return
$
(
'
.js-compare-dropdown
'
).
each
(
function
()
{
var
$dropdown
,
selected
;
$dropdown
=
$
(
this
);
selected
=
$dropdown
.
data
(
'
selected
'
);
const
$dropdownContainer
=
$dropdown
.
closest
(
'
.dropdown
'
);
const
$fieldInput
=
$
(
`input[name="
${
$dropdown
.
data
(
'
field-name
'
)}
"]`
,
$dropdownContainer
);
const
$filterInput
=
$
(
'
input[type="search"]
'
,
$dropdownContainer
);
$dropdown
.
glDropdown
({
data
:
function
(
term
,
callback
)
{
return
$
.
ajax
({
url
:
$dropdown
.
data
(
'
refs-url
'
),
data
:
{
ref
:
$dropdown
.
data
(
'
ref
'
),
search
:
term
,
}
}).
done
(
function
(
refs
)
{
return
callback
(
refs
);
});
},
selectable
:
true
,
filterable
:
true
,
filterRemote
:
true
,
fieldName
:
$dropdown
.
data
(
'
field-name
'
),
filterInput
:
'
input[type="search"]
'
,
renderRow
:
function
(
ref
)
{
var
link
;
if
(
ref
.
header
!=
null
)
{
return
$
(
'
<li />
'
).
addClass
(
'
dropdown-header
'
).
text
(
ref
.
header
);
}
else
{
link
=
$
(
'
<a />
'
).
attr
(
'
href
'
,
'
#
'
).
addClass
(
ref
===
selected
?
'
is-active
'
:
''
).
text
(
ref
).
attr
(
'
data-ref
'
,
escape
(
ref
));
return
$
(
'
<li />
'
).
append
(
link
);
export
default
function
initCompareAutocomplete
()
{
$
(
'
.js-compare-dropdown
'
).
each
(()
=>
{
var
$dropdown
,
selected
;
$dropdown
=
$
(
this
);
selected
=
$dropdown
.
data
(
'
selected
'
);
const
$dropdownContainer
=
$dropdown
.
closest
(
'
.dropdown
'
);
const
$fieldInput
=
$
(
`input[name="
${
$dropdown
.
data
(
'
field-name
'
)}
"]`
,
$dropdownContainer
);
const
$filterInput
=
$
(
'
input[type="search"]
'
,
$dropdownContainer
);
$dropdown
.
glDropdown
({
data
:
function
(
term
,
callback
)
{
return
$
.
ajax
({
url
:
$dropdown
.
data
(
'
refs-url
'
),
data
:
{
ref
:
$dropdown
.
data
(
'
ref
'
),
search
:
term
,
}
},
id
:
function
(
obj
,
$el
)
{
return
$el
.
attr
(
'
data-ref
'
);
},
toggleLabel
:
function
(
obj
,
$el
)
{
return
$el
.
text
().
trim
();
}
});
$filterInput
.
on
(
'
keyup
'
,
(
e
)
=>
{
const
keyCode
=
e
.
keyCode
||
e
.
which
;
if
(
keyCode
!==
13
)
return
;
const
text
=
$filterInput
.
val
();
$fieldInput
.
val
(
text
);
$
(
'
.dropdown-toggle-text
'
,
$dropdown
).
text
(
text
);
$dropdownContainer
.
removeClass
(
'
open
'
);
});
$dropdownContainer
.
on
(
'
click
'
,
'
.dropdown-content a
'
,
(
e
)
=>
{
$dropdown
.
prop
(
'
title
'
,
e
.
target
.
text
.
replace
(
/_+
?
/g
,
'
-
'
));
if
(
$dropdown
.
hasClass
(
'
has-tooltip
'
))
{
$dropdown
.
tooltip
(
'
fixTitle
'
);
}).
done
(
function
(
refs
)
{
return
callback
(
refs
);
});
},
selectable
:
true
,
filterable
:
true
,
filterRemote
:
true
,
fieldName
:
$dropdown
.
data
(
'
field-name
'
),
filterInput
:
'
input[type="search"]
'
,
renderRow
:
function
(
ref
)
{
var
link
;
if
(
ref
.
header
!=
null
)
{
return
$
(
'
<li />
'
).
addClass
(
'
dropdown-header
'
).
text
(
ref
.
header
);
}
else
{
link
=
$
(
'
<a />
'
).
attr
(
'
href
'
,
'
#
'
).
addClass
(
ref
===
selected
?
'
is-active
'
:
''
).
text
(
ref
).
attr
(
'
data-ref
'
,
escape
(
ref
));
return
$
(
'
<li />
'
).
append
(
link
);
}
});
},
id
:
function
(
obj
,
$el
)
{
return
$el
.
attr
(
'
data-ref
'
);
},
toggleLabel
:
function
(
obj
,
$el
)
{
return
$el
.
text
().
trim
();
}
});
$filterInput
.
on
(
'
keyup
'
,
(
e
)
=>
{
const
keyCode
=
e
.
keyCode
||
e
.
which
;
if
(
keyCode
!==
13
)
return
;
const
text
=
$filterInput
.
val
();
$fieldInput
.
val
(
text
);
$
(
'
.dropdown-toggle-text
'
,
$dropdown
).
text
(
text
);
$dropdownContainer
.
removeClass
(
'
open
'
);
});
};
return
CompareAutocomplete
;
})();
$dropdownContainer
.
on
(
'
click
'
,
'
.dropdown-content a
'
,
(
e
)
=>
{
$dropdown
.
prop
(
'
title
'
,
e
.
target
.
text
.
replace
(
/_+
?
/g
,
'
-
'
));
if
(
$dropdown
.
hasClass
(
'
has-tooltip
'
))
{
$dropdown
.
tooltip
(
'
fixTitle
'
);
}
});
});
}
app/assets/javascripts/dispatcher.js
浏览文件 @
8c64e8b4
...
...
@@ -23,7 +23,7 @@ import Project from './project';
import
projectAvatar
from
'
./project_avatar
'
;
/* global MergeRequest */
import
Compare
from
'
./compare
'
;
/* global CompareAutocomplete */
import
initCompareAutocomplete
from
'
./compare_autocomplete
'
;
/* global ProjectFindFile */
import
ProjectNew
from
'
./project_new
'
;
import
projectImport
from
'
./project_import
'
;
...
...
@@ -617,7 +617,7 @@ import ProjectVariables from './project_variables';
projectAvatar
();
switch
(
path
[
1
])
{
case
'
compare
'
:
new
CompareAutocomplete
();
init
CompareAutocomplete
();
break
;
case
'
edit
'
:
shortcut_handler
=
new
ShortcutsNavigation
();
...
...
app/assets/javascripts/main.js
浏览文件 @
8c64e8b4
...
...
@@ -40,7 +40,6 @@ import './admin';
import
'
./aside
'
;
import
loadAwardsHandler
from
'
./awards_handler
'
;
import
bp
from
'
./breakpoints
'
;
import
'
./compare_autocomplete
'
;
import
'
./confirm_danger_modal
'
;
import
Flash
,
{
removeFlashClickListener
}
from
'
./flash
'
;
import
'
./gl_dropdown
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录