Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
1b14908d
Commit
1b14908d
authored
Jul 30, 2014
by
Aron Carroll
Committed by
Randall Leeds
Aug 01, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use camel case for angular event names
parent
8d06a91c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
status-button.coffee
h/static/scripts/directives/status-button.coffee
+2
-2
status-button-test.coffee
tests/js/directives/status-button-test.coffee
+3
-3
No files found.
h/static/scripts/directives/status-button.coffee
View file @
1b14908d
# Augments a button to provide loading/status flags for asynchronous actions.
# Augments a button to provide loading/status flags for asynchronous actions.
#
#
# Requires that the attribute provide a "target" form name. It will then listen
# Requires that the attribute provide a "target" form name. It will then listen
# to "form
-s
tate" events on the scope. These events are expected to provide a
# to "form
S
tate" events on the scope. These events are expected to provide a
# the form name and a status.
# the form name and a status.
#
#
# Example
# Example
...
@@ -33,7 +33,7 @@ statusButton = ->
...
@@ -33,7 +33,7 @@ statusButton = ->
wrapper
.
insertBefore
(
elem
)
wrapper
.
insertBefore
(
elem
)
wrapper
.
append
(
elem
)
wrapper
.
append
(
elem
)
scope
.
$on
'form
-s
tate'
,
(
event
,
formName
,
formState
)
->
scope
.
$on
'form
S
tate'
,
(
event
,
formName
,
formState
)
->
return
unless
formName
==
targetForm
return
unless
formName
==
targetForm
unless
formState
in
[
STATE_LOADING
,
STATE_SUCCESS
]
unless
formState
in
[
STATE_LOADING
,
STATE_SUCCESS
]
formState
=
''
formState
=
''
...
...
tests/js/directives/status-button-test.coffee
View file @
1b14908d
...
@@ -27,15 +27,15 @@ describe 'h.directives.statusButton', ->
...
@@ -27,15 +27,15 @@ describe 'h.directives.statusButton', ->
it
'sets the status-button-state attribute when a loading event is triggered'
,
->
it
'sets the status-button-state attribute when a loading event is triggered'
,
->
parent
=
$element
.
parent
()
parent
=
$element
.
parent
()
$scope
.
$emit
(
'form
-s
tate'
,
'test'
,
'loading'
)
$scope
.
$emit
(
'form
S
tate'
,
'test'
,
'loading'
)
assert
.
equal
(
parent
.
attr
(
'status-button-state'
),
'loading'
)
assert
.
equal
(
parent
.
attr
(
'status-button-state'
),
'loading'
)
it
'sets the status-button-state attribute when a success event is triggered'
,
->
it
'sets the status-button-state attribute when a success event is triggered'
,
->
parent
=
$element
.
parent
()
parent
=
$element
.
parent
()
$scope
.
$emit
(
'form
-s
tate'
,
'test'
,
'success'
)
$scope
.
$emit
(
'form
S
tate'
,
'test'
,
'success'
)
assert
.
equal
(
parent
.
attr
(
'status-button-state'
),
'success'
)
assert
.
equal
(
parent
.
attr
(
'status-button-state'
),
'success'
)
it
'unsets the status-button-state attribute when another event is triggered'
,
->
it
'unsets the status-button-state attribute when another event is triggered'
,
->
parent
=
$element
.
parent
()
parent
=
$element
.
parent
()
$scope
.
$emit
(
'form
-s
tate'
,
'test'
,
'reset'
)
$scope
.
$emit
(
'form
S
tate'
,
'test'
,
'reset'
)
assert
.
equal
(
parent
.
attr
(
'status-button-state'
),
''
)
assert
.
equal
(
parent
.
attr
(
'status-button-state'
),
''
)
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