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
Jérome Perrin
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
Hide 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
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
View file @
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()
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