Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
subugoe
emo
TIDO
Commits
0e8eb826
Commit
0e8eb826
authored
Aug 19, 2021
by
dindigala
Browse files
refactor: update logic to hove according to the new data changes
parent
27741dcb
Pipeline
#221830
passed with stages
in 5 minutes and 58 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/components/annotations/annotations.vue
View file @
0e8eb826
...
...
@@ -308,8 +308,24 @@ export default {
const
childOtherNodes
=
[...
el
.
childNodes
].
filter
((
x
)
=>
x
.
nodeName
!==
'
#text
'
).
length
;
if
(
!
childOtherNodes
)
{
el
=
this
.
backTrackNestedAnnotations
(
el
);
const
annotationClasses
=
el
.
className
.
split
(
'
'
).
map
((
x
)
=>
annotationIds
[
x
]).
filter
((
x
)
=>
x
);
const
classNames
=
[];
el
=
this
.
backTrackNestedAnnotations
(
el
,
classNames
);
const
annotationClasses
=
[];
// checks for duplicate class names.
classNames
.
join
(
'
'
)
.
split
(
'
'
)
.
map
((
x
)
=>
annotationIds
[
x
])
.
filter
((
x
)
=>
x
)
.
reduce
((
prev
,
curr
)
=>
{
if
(
!
prev
[
curr
.
value
])
{
prev
[
curr
.
value
]
=
true
;
annotationClasses
.
push
(
curr
);
}
return
prev
;
},
{});
if
(
annotationClasses
.
length
)
{
el
.
addEventListener
(
'
mouseenter
'
,
()
=>
this
.
onMouseHover
(
el
,
annotationClasses
),
false
);
...
...
@@ -319,14 +335,15 @@ export default {
});
},
backTrackNestedAnnotations
(
el
)
{
backTrackNestedAnnotations
(
el
,
classNames
=
[]
)
{
let
current
=
el
;
while
(
current
.
parentElement
.
getAttribute
(
'
data-annotation
'
)
&&
current
.
parentElement
.
childNodes
.
length
===
1
)
{
classNames
.
push
(
current
.
className
);
current
=
current
.
parentElement
;
}
return
current
;
return
el
;
},
onContentUpdate
(
ids
)
{
...
...
@@ -356,7 +373,24 @@ export default {
},
onMouseHover
(
el
,
annotationClasses
)
{
if
(
!
el
||
(
el
&&
parseInt
(
el
.
getAttribute
(
'
data-annotation-level
'
),
10
)
<=
0
))
{
const
queue
=
[];
// this logic checks the child spans and classes.
queue
.
push
(
el
);
let
matched
=
false
;
while
(
queue
.
length
)
{
const
popped
=
queue
.
pop
();
if
(
parseInt
(
popped
.
getAttribute
(
'
data-annotation-level
'
),
10
)
>
0
)
{
matched
=
true
;
}
else
{
[...
popped
.
children
].
forEach
((
child
)
=>
{
queue
.
push
(
child
);
});
}
}
if
(
!
el
||
!
matched
)
{
return
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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