Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
6085b6a7
Commit
6085b6a7
authored
Aug 11, 2014
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move label coffeescript from view to class
parent
0b5e0e4c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
24 deletions
+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
No files found.
app/assets/javascripts/labels.js.coffee
View file @
6085b6a7
class
Labels
class
Labels
constructor
:
->
constructor
:
->
# find the form
form
=
$
(
'.label-form'
)
form
=
$
(
'.label-form'
)
@
setupLabelForm
(
form
)
@
setupLabelForm
(
form
)
@
cleanBinding
()
@
addBinding
()
@
updateColorPreview
###
addBinding
:
->
General note form setup.
$
(
document
).
on
'click'
,
'.suggest-colors a'
,
@
setSuggestedColor
$
(
document
).
on
'input'
,
'input#label_color'
,
@
updateColorPreview
deactivates the submit button when text is empty
cleanBinding
:
->
hides the preview button when text is empty
$
(
document
).
off
'click'
,
'.suggest-colors a'
setup GFM auto complete
$
(
document
).
off
'input'
,
'input#label_color'
show the form
#
##
#
Initializes the form to disable the save button if no color or title is entered
setupLabelForm
:
(
form
)
->
setupLabelForm
:
(
form
)
->
disableButtonIfEmptyField
form
,
'.form-control'
,
form
.
find
(
'.js-save-button'
)
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
@
Labels
=
Labels
app/views/projects/labels/_form.html.haml
View file @
6085b6a7
...
@@ -31,19 +31,3 @@
...
@@ -31,19 +31,3 @@
=
f
.
submit
'Save'
,
class:
'btn btn-save js-save-button'
=
f
.
submit
'Save'
,
class:
'btn btn-save js-save-button'
=
link_to
"Cancel"
,
project_labels_path
(
@project
),
class:
'btn btn-cancel'
=
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()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment