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
04ad197b
Commit
04ad197b
authored
Aug 13, 2014
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trigger an update of save button if user pressed a preview color
parent
b9519c83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
app/assets/javascripts/application.js.coffee
app/assets/javascripts/application.js.coffee
+3
-3
app/assets/javascripts/labels.js.coffee
app/assets/javascripts/labels.js.coffee
+3
-1
No files found.
app/assets/javascripts/application.js.coffee
View file @
04ad197b
...
@@ -59,18 +59,18 @@ window.rstrip = (val) ->
...
@@ -59,18 +59,18 @@ window.rstrip = (val) ->
# Disable button if text field is empty
# Disable button if text field is empty
window
.
disableButtonIfEmptyField
=
(
field_selector
,
button_selector
)
->
window
.
disableButtonIfEmptyField
=
(
field_selector
,
button_selector
)
->
field
=
$
(
field_selector
)
field
=
$
(
field_selector
)
closest_submit
=
field
.
closest
(
"form"
).
find
(
button_selector
)
closest_submit
=
field
.
closest
(
'form'
).
find
(
button_selector
)
closest_submit
.
disable
()
if
rstrip
(
field
.
val
())
is
""
closest_submit
.
disable
()
if
rstrip
(
field
.
val
())
is
""
field
.
on
"input"
,
->
field
.
on
'input'
,
->
if
rstrip
(
$
(
@
).
val
())
is
""
if
rstrip
(
$
(
@
).
val
())
is
""
closest_submit
.
disable
()
closest_submit
.
disable
()
else
else
closest_submit
.
enable
()
closest_submit
.
enable
()
# Disable button if any input field with given selector is empty
# Disable button if any input field with given selector is empty
window
.
disableButtonIfEmptyField
=
(
form
,
form_selector
,
button_selector
)
->
window
.
disableButtonIf
Any
EmptyField
=
(
form
,
form_selector
,
button_selector
)
->
closest_submit
=
form
.
find
(
button_selector
)
closest_submit
=
form
.
find
(
button_selector
)
empty
=
false
empty
=
false
form
.
find
(
'input'
).
filter
(
form_selector
).
each
->
form
.
find
(
'input'
).
filter
(
form_selector
).
each
->
...
...
app/assets/javascripts/labels.js.coffee
View file @
04ad197b
...
@@ -16,7 +16,7 @@ class Labels
...
@@ -16,7 +16,7 @@ class Labels
# Initializes the form to disable the save button if no color or title is entered
# 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'
)
disableButtonIf
Any
EmptyField
form
,
'.form-control'
,
form
.
find
(
'.js-save-button'
)
# Updates the the preview color with the hex-color input
# Updates the the preview color with the hex-color input
updateColorPreview
:
=>
updateColorPreview
:
=>
...
@@ -28,6 +28,8 @@ class Labels
...
@@ -28,6 +28,8 @@ class Labels
color
=
$
(
e
.
currentTarget
).
data
(
'color'
)
color
=
$
(
e
.
currentTarget
).
data
(
'color'
)
$
(
'input#label_color'
).
val
(
color
)
$
(
'input#label_color'
).
val
(
color
)
@
updateColorPreview
()
@
updateColorPreview
()
# Notify the form, that color has changed
$
(
'.label-form'
).
trigger
(
'keyup'
)
e
.
preventDefault
()
e
.
preventDefault
()
@
Labels
=
Labels
@
Labels
=
Labels
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