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
d7982a19
Commit
d7982a19
authored
Apr 02, 2015
by
Randall Leeds
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2123 from hypothesis/2053-scroll-sidebar-to-new-annotations-2
Scroll to new annotations on creation
parents
39e85a0d
68dfc650
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
3 deletions
+42
-3
thread-test.coffee
h/static/scripts/directive/test/thread-test.coffee
+19
-0
thread.coffee
h/static/scripts/directive/thread.coffee
+21
-2
viewer.html
h/templates/client/viewer.html
+2
-1
No files found.
h/static/scripts/directive/test/thread-test.coffee
View file @
d7982a19
...
...
@@ -42,6 +42,25 @@ describe 'thread', ->
describe
'controller'
,
->
it
'returns true from isNew() for a new annotation'
,
->
createDirective
()
# When the user clicks to create a new annotation in the browser, we get
# a ThreadController with a container with a message (the annotation)
# with no id.
controller
.
container
=
{
message
:
{}}
assert
(
controller
.
isNew
())
it
'returns false from isNew() for an old annotation'
,
->
createDirective
()
# When we create a ThreadController for an old annotation, the controller
# has a container with a message (the annotation) with an id.
controller
.
container
=
{
message
:
{
id
:
123
}}
assert
(
not
controller
.
isNew
())
describe
'#toggleCollapsed'
,
->
count
=
null
...
...
h/static/scripts/directive/thread.coffee
View file @
d7982a19
uuid
=
require
(
'node-uuid'
)
###*
# @ngdoc type
# @name thread.ThreadController
...
...
@@ -136,6 +138,17 @@ ThreadController = [
return true
return @filter.check(@container)
###
*
# @ngdoc method
# @name thread.ThreadController#isNew
# @description
# Return true if this is a newly-created annotation (e.g. the user has just
# created it by clicking the new annotation button in the browser),
# false otherwise.
###
this.isNew = ->
return (this.id and not this.container?.message?.id)
this._isFilterActive = ->
if @filter
@filter.active()
...
...
@@ -148,6 +161,8 @@ ThreadController = [
else
0
this.id = uuid.v4()
this
]
...
...
@@ -174,8 +189,8 @@ isHiddenThread = (elem) ->
# Directive that instantiates {@link thread.ThreadController ThreadController}.
###
module
.
exports
=
[
'$parse'
,
'$window'
,
'pulse'
,
'render'
,
(
$parse
,
$window
,
pulse
,
render
)
->
'$parse'
,
'$window'
,
'
$location'
,
'$anchorScroll'
,
'
pulse'
,
'render'
,
(
$parse
,
$window
,
$location
,
$anchorScroll
,
pulse
,
render
)
->
linkFn
=
(
scope
,
elem
,
attrs
,
[
ctrl
,
counter
,
filter
])
->
# We would ideally use require for this, but searching parents only for a
...
...
@@ -210,6 +225,10 @@ module.exports = [
render
->
ctrl
.
container
=
thread
scope
.
$digest
()
if
ctrl
.
isNew
()
# Scroll the sidebar to show new annotations.
$location
.
hash
(
ctrl
.
id
)
$anchorScroll
()
controller
:
ThreadController
controllerAs
:
'vm'
...
...
h/templates/client/viewer.html
View file @
d7982a19
...
...
@@ -32,7 +32,8 @@
</ul>
</span>
</li>
<li
class=
"paper thread"
<li
id=
"{{vm.id}}"
class=
"paper thread"
ng-class=
"{'js-hover': hasFocus(child.message)}"
deep-count=
"count"
thread=
"child"
thread-filter
...
...
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