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
c7512d0b
Commit
c7512d0b
authored
Mar 31, 2014
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lift view and sort to App controller
Fix #1123
parent
5deb4440
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
56 deletions
+58
-56
controllers.coffee
h/js/controllers.coffee
+58
-56
No files found.
h/js/controllers.coffee
View file @
c7512d0b
...
...
@@ -6,6 +6,19 @@ class App
collapsed
:
true
tab
:
null
ongoingHighlightSwitch
:
false
sorts
:
[
'Newest'
'Oldest'
'Location'
]
views
:
[
'Screen'
'Document'
'Comments'
]
viewState
:
sort
:
'Newest'
view
:
'Screen'
this
.
$inject
=
[
'$element'
,
'$filter'
,
'$http'
,
'$location'
,
'$rootScope'
,
'$scope'
,
'$timeout'
,
...
...
@@ -148,7 +161,47 @@ class App
$scope
.
$broadcast
'$reset'
$rootScope
.
view
=
'Screen'
# "View" -- which annotations are shown
$scope
.
applyView
=
(
view
)
->
$scope
.
viewState
.
view
=
view
switch
view
when
'Screen'
# Go over all providers, and switch them to dynamic mode
# They will, in turn, call back updateView
# with the right set of annotations
for
p
in
providers
p
.
channel
.
notify
method
:
'setDynamicBucketMode'
,
params
:
true
break
when
'Document'
for
p
in
providers
p
.
channel
.
notify
method
:
'showAll'
break
when
'Comments'
for
p
in
providers
p
.
channel
.
notify
method
:
'setDynamicBucketMode'
,
params
:
false
annotations
=
annotator
.
plugins
.
Store
.
annotations
comments
=
annotations
.
filter
(
a
)
->
annotator
.
isComment
(
a
)
$rootScope
.
annotations
=
comments
break
else
throw
new
Error
"Unknown view requested: "
+
view
# "Sort" -- order annotations are shown
$scope
.
applySort
=
(
sort
)
->
$scope
.
viewState
.
sort
=
sort
if
sort
==
'Newest'
$scope
.
predicate
=
'updated'
$scope
.
reverse
=
true
if
sort
==
'Oldest'
$scope
.
predicate
=
'updated'
$scope
.
reverse
=
false
if
sort
==
'Location'
$scope
.
predicate
=
'target[0].selector[2].start'
$scope
.
reverse
=
false
# Clean up the searchbar
$scope
.
leaveSearch
=
=>
...
...
@@ -496,11 +549,11 @@ class Annotation
switch
$scope
.
action
when
'create'
if
annotator
.
isComment
(
annotation
)
if
$
rootScop
e
.
view
isnt
"Comments"
$
rootScope
.
applyView
"Comments"
if
$
scope
.
$parent
.
viewStat
e
.
view
isnt
"Comments"
$
scope
.
$parent
.
applyView
"Comments"
else
if
not
annotator
.
isReply
(
annotation
)
and
$
rootScop
e
.
view
in
[
"Comments"
,
"Selection"
]
$
rootScope
.
applyView
"Screen"
$
scope
.
$parent
.
viewStat
e
.
view
in
[
"Comments"
,
"Selection"
]
$
scope
.
$parent
.
applyView
"Screen"
annotator
.
publish
'annotationCreated'
,
annotation
when
'delete'
root
=
$scope
.
$root
.
annotations
...
...
@@ -690,19 +743,6 @@ class Viewer
annotator
)
->
{
providers
,
threading
}
=
annotator
$scope
.
sort
=
'Newest'
$scope
.
views
=
[
{
view
:
'Screen'
}
{
view
:
'Document'
}
{
view
:
"Comments"
}
]
$scope
.
sorts
=
[
{
sort
:
'Newest'
}
{
sort
:
'Oldest'
}
{
sort
:
'Location'
}]
$scope
.
predicate
=
'updated'
$scope
.
reverse
=
true
$scope
.
focus
=
(
annotation
)
->
if
angular
.
isArray
annotation
...
...
@@ -722,44 +762,6 @@ class Viewer
method
:
'scrollTo'
params
:
annotation
.
$
$tag
$rootScope
.
applyView
=
(
view
)
->
switch
view
when
'Screen'
# Go over all providers, and switch them to dynamic mode
# They will, in turn, call back updateView
# with the right set of annotations
for
p
in
providers
p
.
channel
.
notify
method
:
'setDynamicBucketMode'
,
params
:
true
break
when
'Document'
for
p
in
providers
p
.
channel
.
notify
method
:
'showAll'
break
when
'Comments'
for
p
in
providers
p
.
channel
.
notify
method
:
'setDynamicBucketMode'
,
params
:
false
annotations
=
annotator
.
plugins
.
Store
.
annotations
comments
=
annotations
.
filter
(
a
)
->
annotator
.
isComment
(
a
)
$rootScope
.
annotations
=
comments
break
else
throw
new
Error
"Unknown view requested: "
+
view
$scope
.
applySort
=
(
sort
)
->
$scope
.
sort
=
sort
if
$scope
.
sort
==
'Newest'
$scope
.
predicate
=
'updated'
$scope
.
reverse
=
true
if
$scope
.
sort
==
'Oldest'
$scope
.
predicate
=
'updated'
$scope
.
reverse
=
false
if
$scope
.
sort
==
'Location'
$scope
.
predicate
=
'target[0].selector[2].start'
$scope
.
reverse
=
false
class
Search
this
.
$inject
=
[
'$filter'
,
'$location'
,
'$rootScope'
,
'$routeParams'
,
'$sce'
,
'$scope'
,
'annotator'
]
...
...
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