Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
85a3f8a0
Commit
85a3f8a0
authored
Sep 20, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] annotations: repair free selection events
parent
7718b763
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
28 deletions
+32
-28
app.css
annotations/static/annotations/app.css
+6
-3
highlight.js
annotations/static/annotations/highlight.js
+26
-25
No files found.
annotations/static/annotations/app.css
View file @
85a3f8a0
...
...
@@ -151,12 +151,15 @@
transition
:
all
0.25s
linear
;
}
.selection
{
/* this was used for the p or div that *contained* a selection */
/*.selection {
color: #aaa;
}
}*/
/* this is used for the selected text itself */
::selection
{
color
:
black
;
background-color
:
rgba
(
0
,
0
,
0
,
0.4
)
;
background-color
:
#aaa
;
}
.noselection
{
...
...
annotations/static/annotations/highlight.js
View file @
85a3f8a0
...
...
@@ -50,6 +50,9 @@
/*
* Universal text selection
*
* "universal" <=> (Chrome, Firefox, IE, Safari, Opera...)
* cf. quirksmode.org/dom/range_intro.html
*/
function
getSelected
()
{
if
(
window
.
getSelection
)
{
...
...
@@ -68,18 +71,20 @@
return
false
;
}
// we only need one singleton at a time
// (<=> is only called once per doc, but value of annotation changes)
var
selection
=
getSelected
();
/*
* When mouse selection
is started, we highlight it
* When mouse selection
was started, this used to grey out the text panel
*/
function
toggleSelectionHighlight
(
text
)
{
if
(
text
.
trim
()
!==
""
&&
!
$element
.
hasClass
(
'menu-is-opened'
))
{
$
(
".text-panel"
).
addClass
(
"selection"
);
}
else
{
$
(
".text-panel"
).
removeClass
(
"selection"
);
}
}
// function toggleSelectionChangePanelClass(text) {
// // if (text.trim() !== "" && !$element.hasClass('menu-is-opened')) {
// if (text.trim() !== "" && !$element.hasClass('menu-is-opened')) {
// $(".text-panel").addClass("selection");
// } else {
// $(".text-panel").removeClass("selection");
// }
// }
/*
* Dynamically construct the selection menu scope
...
...
@@ -107,10 +112,11 @@
$scope
.
selection_text
=
angular
.
copy
(
annotation
);
// debug
// console.log("toggleMenu with context:", context) ;
// console.log("toggleMenu with annotation: '" + JSON.stringify(annotation) +"'") ;
// console.log("toggleMenu with \$scope.selection_text: '" + JSON.stringify($scope.selection_text) +"'") ;
if
(
angular
.
isObject
(
annotation
)
&&
!
$element
.
hasClass
(
'menu-is-opened'
))
{
// existing ngram
var
ngramId
=
annotation
.
uuid
var
mainformId
=
annotation
.
group
...
...
@@ -210,7 +216,7 @@
}
// "add" actions for non-existing ngram
else
if
(
annotation
.
trim
()
!==
""
&&
!
$element
.
hasClass
(
'menu-is-opened'
)
)
{
else
if
(
annotation
.
trim
()
!==
""
&&
!
context
)
{
var
newNgramText
=
annotation
.
trim
()
// new ngram (first call creates then like previous case for list)
$scope
.
menuItems
.
push
({
...
...
@@ -252,12 +258,16 @@
// show the menu
$element
.
fadeIn
(
50
);
$element
.
addClass
(
'menu-is-opened'
);
// console.warn("FADE IN menu", $element)
}
else
{
console
.
warn
(
"=> else"
)
// close the menu
$scope
.
menuItems
=
[];
$element
.
fadeOut
(
50
);
$element
.
removeClass
(
'menu-is-opened'
);
// console.warn("FADE OUT menu", $element)
}
});
});
...
...
@@ -283,25 +293,14 @@
});
/*
*
Finish positioning the menu then display the menu
*
Toggle the menu when clicking on an existing ngram keyword
*/
$
(
".text-container"
).
mouseup
(
function
(
e
){
$
(
".text-container"
).
unbind
(
"mousemove"
,
positionMenu
);
$rootScope
.
$emit
(
"positionAnnotationMenu"
,
e
.
pageX
,
e
.
pageY
);
toggleSelectionHighlight
(
selection
.
toString
().
trim
());
toggleMenu
(
null
,
selection
.
toString
().
trim
());
});
/*
* Toggle the menu when clicking on an existing ngram keyword
*
* £TODO test: apparently this is never used ?
* (superseded by TextSelectionController.onClick)
*/
$
(
".text-container"
).
delegate
(
':not("#selection")'
,
"click"
,
function
(
e
)
{
// if ($(e.target).hasClass("keyword-inline")) return;
positionMenu
(
e
);
toggleSelectionHighlight
(
selection
.
toString
().
trim
());
// console.warn("calling toggleMenu from *mouseup*")
toggleMenu
(
null
,
selection
.
toString
().
trim
());
});
...
...
@@ -322,9 +321,11 @@
$rootScope
.
makeChainedCalls
(
0
,
todoCrudCalls
,
$rootScope
.
refresh
)
// syntax: (step_to_run_first, list_of_steps, lastCallback)
// hide the highlighted text and the menu element
$
(
".text-panel"
).
removeClass
(
"selection"
);
// hide the menu element
$element
.
fadeOut
(
100
);
// the highlighted text hides itself when deselected
// (thx to browser and css ::selection)
};
}
]);
...
...
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