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
e2fd7152
Commit
e2fd7152
authored
Nov 27, 2012
by
Randall Leeds
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '181-alert-for-unsaved-dialog-in-detail-view' into develop
Conflicts: h/js/src/controllers.coffee
parents
b4b36648
3e87c7cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
8 deletions
+44
-8
controllers.coffee
h/js/src/controllers.coffee
+44
-8
No files found.
h/js/src/controllers.coffee
View file @
e2fd7152
...
@@ -8,11 +8,12 @@ class Hypothesis extends Annotator
...
@@ -8,11 +8,12 @@ class Hypothesis extends Annotator
userString
:
(
user
)
->
user
.
replace
(
/^acct:(.+)@(.+)$/
,
'$1 on $2'
)
userString
:
(
user
)
->
user
.
replace
(
/^acct:(.+)@(.+)$/
,
'$1 on $2'
)
# Internal state
# Internal state
bucket
:
-
1
# * The index of the bucket shown in the summary view
bucket
:
-
1
# * The index of the bucket shown in the summary view
detail
:
false
# * Whether the viewer shows a summary or detail listing
detail
:
false
# * Whether the viewer shows a summary or detail listing
hash
:
-
1
# * cheap UUID :cake:
hash
:
-
1
# * cheap UUID :cake:
cache
:
{}
# * object cache
cache
:
{}
# * object cache
visible
:
false
# * Whether the sidebar is visible
visible
:
false
# * Whether the sidebar is visible
unsaved_drafts
:
[]
# * Unsaved drafts currenty open
this
.
$inject
=
[
'$rootElement'
,
'$scope'
,
'$compile'
,
'$http'
]
this
.
$inject
=
[
'$rootElement'
,
'$scope'
,
'$compile'
,
'$http'
]
constructor
:
(
@
element
,
@
scope
,
@
compile
,
@
http
)
->
constructor
:
(
@
element
,
@
scope
,
@
compile
,
@
http
)
->
...
@@ -49,6 +50,7 @@ class Hypothesis extends Annotator
...
@@ -49,6 +50,7 @@ class Hypothesis extends Annotator
this
.
show
()
this
.
show
()
null
null
showEditor
:
(
stub
)
=>
showEditor
:
(
stub
)
=>
return
unless
this
.
_canCloseUnsaved
()
h
=
stub
.
hash
h
=
stub
.
hash
annotation
=
$
.
extend
@
cache
[
h
],
stub
,
annotation
=
$
.
extend
@
cache
[
h
],
stub
,
hash
:
hash
:
...
@@ -326,8 +328,13 @@ class Hypothesis extends Annotator
...
@@ -326,8 +328,13 @@ class Hypothesis extends Annotator
# Returns itself for chaining.
# Returns itself for chaining.
_setupEditor
:
->
_setupEditor
:
->
@
editor
=
this
.
_createEditor
()
@
editor
=
this
.
_createEditor
()
.
on
(
'hide'
,
=>
@
provider
.
onEditorHide
())
.
on
'hide'
,
=>
.
on
(
'save'
,
=>
@
provider
.
onEditorSubmit
())
@
provider
.
onEditorHide
()
.
on
'save'
,
=>
@
provider
.
onEditorSubmit
()
.
on
'hide save'
,
=>
if
@
unsaved_drafts
.
indexOf
(
@
editor
)
>
-
1
@
unsaved_drafts
.
splice
(
@
unsaved_drafts
.
indexOf
(
@
editor
),
1
)
this
this
_createEditor
:
->
_createEditor
:
->
...
@@ -341,6 +348,7 @@ class Hypothesis extends Annotator
...
@@ -341,6 +348,7 @@ class Hypothesis extends Annotator
annotation
.
text
=
$
(
field
).
find
(
'textarea'
).
val
()
annotation
.
text
=
$
(
field
).
find
(
'textarea'
).
val
()
}]
}]
@
unsaved_drafts
.
push
editor
editor
editor
_fillDynamicBucket
:
->
_fillDynamicBucket
:
->
...
@@ -390,6 +398,9 @@ class Hypothesis extends Annotator
...
@@ -390,6 +398,9 @@ class Hypothesis extends Annotator
@
provider
.
setupAnnotation
stub
@
provider
.
setupAnnotation
stub
showViewer
:
(
annotations
=
[],
detail
=
false
)
=>
showViewer
:
(
annotations
=
[],
detail
=
false
)
=>
if
(
@
visible
and
not
detail
)
or
@
unsaved_drafts
.
indexOf
(
@
editor
)
>
-
1
if
not
this
.
_canCloseUnsaved
()
then
return
# Thread the messages using JWZ
# Thread the messages using JWZ
messages
=
mail
.
messageThread
().
thread
annotations
.
map
(
a
)
->
messages
=
mail
.
messageThread
().
thread
annotations
.
map
(
a
)
->
m
=
mail
.
message
(
null
,
a
.
id
,
a
.
thread
?
.
split
(
'/'
)
or
[])
m
=
mail
.
message
(
null
,
a
.
id
,
a
.
thread
?
.
split
(
'/'
)
or
[])
...
@@ -469,7 +480,6 @@ class Hypothesis extends Annotator
...
@@ -469,7 +480,6 @@ class Hypothesis extends Annotator
else
else
d3
.
select
(
this
).
html
(
quote
)
d3
.
select
(
this
).
html
(
quote
)
highlights
=
[]
highlights
=
[]
excerpts
.
each
(
d
)
=>
excerpts
.
each
(
d
)
=>
h
=
d
.
message
.
annotation
.
hash
h
=
d
.
message
.
annotation
.
hash
...
@@ -566,6 +576,10 @@ class Hypothesis extends Annotator
...
@@ -566,6 +576,10 @@ class Hypothesis extends Annotator
editor
.
element
.
appendTo
(
item
.
node
())
editor
.
element
.
appendTo
(
item
.
node
())
editor
.
on
(
'hide'
,
=>
item
.
remove
())
editor
.
on
(
'hide'
,
=>
item
.
remove
())
editor
.
on
'hide save'
,
=>
@
unsaved_drafts
.
splice
(
@
unsaved_drafts
.
indexOf
(
editor
),
1
)
editor
.
element
.
find
(
":input:first"
).
focus
()
editor
.
element
.
find
(
":input:first"
).
focus
()
context
=
items
.
select
'.thread'
context
=
items
.
select
'.thread'
...
@@ -601,6 +615,8 @@ class Hypothesis extends Annotator
...
@@ -601,6 +615,8 @@ class Hypothesis extends Annotator
.
append
(
item
)
.
append
(
item
)
.
find
(
":input:first"
).
focus
()
.
find
(
":input:first"
).
focus
()
@
unsaved_drafts
.
push
@
editor
d3
.
select
(
@
viewer
.
element
[
0
]).
datum
(
null
)
d3
.
select
(
@
viewer
.
element
[
0
]).
datum
(
null
)
this
.
show
()
this
.
show
()
...
@@ -625,6 +641,26 @@ class Hypothesis extends Annotator
...
@@ -625,6 +641,26 @@ class Hypothesis extends Annotator
@
element
.
find
(
'#toolbar'
).
removeClass
(
'shown'
)
@
element
.
find
(
'#toolbar'
).
removeClass
(
'shown'
)
.
find
(
'.tri'
).
attr
(
'draggable'
,
false
)
.
find
(
'.tri'
).
attr
(
'draggable'
,
false
)
_canCloseUnsaved
:
->
# See if there's an unsaved/uncancelled reply
can_close
=
true
open_editors
=
0
for
editor
in
@
unsaved_drafts
unsaved_text
=
editor
.
element
.
find
(
':input:first'
).
attr
'value'
if
unsaved_text
?
and
unsaved_text
.
toString
().
length
>
0
open_editors
+=
1
if
open_editors
>
0
if
open_editors
>
1
ctext
=
"You have
#{
open_editors
}
unsaved replies."
else
ctext
=
"You have an unsaved reply."
ctext
=
ctext
+
" Do you really want to close the view?"
can_close
=
confirm
ctext
if
can_close
then
@
unsaved_drafts
=
[]
can_close
threadId
:
(
annotation
)
->
threadId
:
(
annotation
)
->
if
annotation
?
.
thread
?
if
annotation
?
.
thread
?
annotation
.
thread
+
'/'
+
annotation
.
id
annotation
.
thread
+
'/'
+
annotation
.
id
...
...
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