Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6085b6a7
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,发现更多精彩内容 >>
提交
6085b6a7
编写于
8月 11, 2014
作者:
R
Robert Schilling
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move label coffeescript from view to class
上级
0b5e0e4c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
24 deletion
+23
-24
app/assets/javascripts/labels.js.coffee
app/assets/javascripts/labels.js.coffee
+23
-8
app/views/projects/labels/_form.html.haml
app/views/projects/labels/_form.html.haml
+0
-16
未找到文件。
app/assets/javascripts/labels.js.coffee
浏览文件 @
6085b6a7
class
Labels
constructor
:
->
# find the form
form
=
$
(
'.label-form'
)
@
setupLabelForm
(
form
)
@
cleanBinding
()
@
addBinding
()
@
updateColorPreview
###
General note form setup.
addBinding
:
->
$
(
document
).
on
'click'
,
'.suggest-colors a'
,
@
setSuggestedColor
$
(
document
).
on
'input'
,
'input#label_color'
,
@
updateColorPreview
deactivates the submit button when text is empty
hides the preview button when text is empty
setup GFM auto complete
show the form
#
##
cleanBinding
:
->
$
(
document
).
off
'click'
,
'.suggest-colors a'
$
(
document
).
off
'input'
,
'input#label_color'
#
Initializes the form to disable the save button if no color or title is entered
setupLabelForm
:
(
form
)
->
disableButtonIfEmptyField
form
,
'.form-control'
,
form
.
find
(
'.js-save-button'
)
# Updates the the preview color with the hex-color input
updateColorPreview
:
=>
previewColor
=
$
(
'input#label_color'
).
val
()
$
(
'div.label-color-preview'
).
css
(
'background-color'
,
previewColor
)
# Updates the preview color with a click on a suggested color
setSuggestedColor
:
(
e
)
=>
color
=
$
(
e
.
currentTarget
).
data
(
'color'
)
$
(
'input#label_color'
).
val
(
color
)
@
updateColorPreview
()
e
.
preventDefault
()
@
Labels
=
Labels
app/views/projects/labels/_form.html.haml
浏览文件 @
6085b6a7
...
...
@@ -31,19 +31,3 @@
=
f
.
submit
'Save'
,
class:
'btn btn-save js-save-button'
=
link_to
"Cancel"
,
project_labels_path
(
@project
),
class:
'btn btn-cancel'
:coffeescript
updateColorPreview = ->
previewColor = $('input#label_color').val()
$('div.label-color-preview').css('background-color', previewColor)
$('.suggest-colors a').on 'click', (e) ->
color = $(this).data("color")
$('input#label_color').val(color)
updateColorPreview()
e.preventDefault()
$('input#label_color').on 'input', ->
updateColorPreview()
updateColorPreview()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录