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
bed66356
Commit
bed66356
authored
Feb 13, 2015
by
csillag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cosmetic: change order of stuff
parent
82fbab54
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
28 deletions
+27
-28
texthighlights.coffee
h/static/scripts/annotator/plugin/texthighlights.coffee
+27
-28
No files found.
h/static/scripts/annotator/plugin/texthighlights.coffee
View file @
bed66356
$
=
Annotator
.
$
$
=
Annotator
.
$
# Public: Wraps the DOM Nodes within the provided range with a highlight
# element of the specified class and returns the highlight Elements.
#
# normedRange - A NormalizedRange to be highlighted.
# cssClass - A CSS class to use for the highlight (default: 'annotator-hl')
#
# Returns an array of highlight Elements.
highlightRange
=
(
normedRange
,
cssClass
=
'annotator-hl'
)
->
white
=
/^\s*$/
hl
=
$
(
"<span class='
#{
cssClass
}
'></span>"
)
# Ignore text nodes that contain only whitespace characters. This prevents
# spans being injected between elements that can only contain a restricted
# subset of nodes such as table rows and lists. This does mean that there
# may be the odd abandoned whitespace node in a paragraph that is skipped
# but better than breaking table layouts.
nodes
=
$
(
normedRange
.
textNodes
()).
filter
((
i
)
->
not
white
.
test
@
nodeValue
)
r
=
nodes
.
wrap
(
hl
).
parent
().
show
().
toArray
()
for
node
in
nodes
event
=
document
.
createEvent
"UIEvents"
event
.
initUIEvent
"domChange"
,
true
,
false
,
window
,
0
event
.
reason
=
"created hilite"
node
.
dispatchEvent
event
r
class
TextHighlight
class
TextHighlight
@
createFrom
:
(
segment
,
anchor
,
page
)
->
@
createFrom
:
(
segment
,
anchor
,
page
)
->
...
@@ -91,34 +118,6 @@ class TextHighlight
...
@@ -91,34 +118,6 @@ class TextHighlight
$
(
@
_highlights
).
scrollintoview
complete
:
->
$
(
@
_highlights
).
scrollintoview
complete
:
->
resolve
()
resolve
()
# Public: Wraps the DOM Nodes within the provided range with a highlight
# element of the specified class and returns the highlight Elements.
#
# normedRange - A NormalizedRange to be highlighted.
# cssClass - A CSS class to use for the highlight (default: 'annotator-hl')
#
# Returns an array of highlight Elements.
highlightRange
=
(
normedRange
,
cssClass
=
'annotator-hl'
)
->
white
=
/^\s*$/
hl
=
$
(
"<span class='
#{
cssClass
}
'></span>"
)
# Ignore text nodes that contain only whitespace characters. This prevents
# spans being injected between elements that can only contain a restricted
# subset of nodes such as table rows and lists. This does mean that there
# may be the odd abandoned whitespace node in a paragraph that is skipped
# but better than breaking table layouts.
nodes
=
$
(
normedRange
.
textNodes
()).
filter
((
i
)
->
not
white
.
test
@
nodeValue
)
r
=
nodes
.
wrap
(
hl
).
parent
().
show
().
toArray
()
for
node
in
nodes
event
=
document
.
createEvent
"UIEvents"
event
.
initUIEvent
"domChange"
,
true
,
false
,
window
,
0
event
.
reason
=
"created hilite"
node
.
dispatchEvent
event
r
class
Annotator
.
Plugin
.
TextHighlights
extends
Annotator
.
Plugin
class
Annotator
.
Plugin
.
TextHighlights
extends
Annotator
.
Plugin
# Plugin initialization
# Plugin initialization
...
...
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