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
24334ac8
Commit
24334ac8
authored
Mar 05, 2015
by
Nick Stenning
Committed by
Randall Leeds
Mar 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow toggleCollapsed to take a forced value
parent
7f32e044
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
thread-test.coffee
h/static/scripts/directives/test/thread-test.coffee
+16
-5
thread.coffee
h/static/scripts/directives/thread.coffee
+6
-3
No files found.
h/static/scripts/directives/test/thread-test.coffee
View file @
24334ac8
...
...
@@ -24,13 +24,24 @@ describe 'h:directives.thread', ->
controller
describe
'#toggleCollapsed'
,
->
it
'
sets the collapsed property
'
,
->
it
'
toggles whether or not the thread is collapsed
'
,
->
controller
=
createController
()
before
=
controller
.
collapsed
controller
.
toggleCollapsed
()
after
=
controller
.
collapsed
assert
.
equal
(
before
,
!
after
)
it
'can accept an argument to force a particular state'
,
->
controller
=
createController
()
controller
.
toggleCollapsed
(
true
)
assert
.
isTrue
(
controller
.
collapsed
)
controller
.
toggleCollapsed
(
true
)
assert
.
isTrue
(
controller
.
collapsed
)
controller
.
toggleCollapsed
(
false
)
assert
.
isFalse
(
controller
.
collapsed
)
controller
.
toggleCollapsed
(
false
)
assert
.
isFalse
(
controller
.
collapsed
)
describe
'#shouldShowReply'
,
->
count
=
null
controller
=
null
...
...
@@ -53,12 +64,12 @@ describe 'h:directives.thread', ->
it
'shows the reply if the thread is collapsed and has children'
,
->
count
.
withArgs
(
'message'
).
returns
(
1
)
controller
.
collapsed
=
true
controller
.
toggleCollapsed
(
true
)
assert
.
isTrue
(
controller
.
shouldShowReply
(
count
,
false
))
it
'does not show the reply if the thread is collapsed and has no children'
,
->
count
.
withArgs
(
'message'
).
returns
(
0
)
controller
.
collapsed
=
true
controller
.
toggleCollapsed
(
true
)
assert
.
isFalse
(
controller
.
shouldShowReply
(
count
,
false
))
describe
'and when filtered with children'
,
->
...
...
@@ -86,12 +97,12 @@ describe 'h:directives.thread', ->
it
'does not show the reply if the thread is collapsed and has children'
,
->
count
.
withArgs
(
'message'
).
returns
(
1
)
controller
.
collapsed
=
true
controller
.
toggleCollapsed
(
true
)
assert
.
isFalse
(
controller
.
shouldShowReply
(
count
,
false
))
it
'does not show the reply if the thread is collapsed and has no children'
,
->
count
.
withArgs
(
'message'
).
returns
(
0
)
controller
.
collapsed
=
true
controller
.
toggleCollapsed
(
true
)
assert
.
isFalse
(
controller
.
shouldShowReply
(
count
,
false
))
describe
'and when filtered with children'
,
->
...
...
h/static/scripts/directives/thread.coffee
View file @
24334ac8
...
...
@@ -26,8 +26,11 @@ ThreadController = [
# @description
# Toggle the collapsed property.
###
this.toggleCollapsed = ->
@collapsed = not @collapsed
this.toggleCollapsed = (value) ->
@collapsed = if value?
!!value
else
not @collapsed
###
*
# @ngdoc method
...
...
@@ -160,7 +163,7 @@ thread = [
# Watch the thread-collapsed attribute.
if
attrs
.
threadCollapsed
scope
.
$watch
$parse
(
attrs
.
threadCollapsed
),
(
collapsed
)
->
ctrl
.
toggleCollapsed
(
)
if
!!
collapsed
!=
ctrl
.
collapsed
ctrl
.
toggleCollapsed
(
collapsed
)
controller
:
'ThreadController'
controllerAs
:
'vm'
...
...
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