Commit 66cf7ee9 authored by Elias's avatar Elias

Annotations Fix : selection menu position and toggling

parent 750e7a46
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
* When mouse selection is started, we highlight it * When mouse selection is started, we highlight it
*/ */
function toggleSelectionHighlight(text) { function toggleSelectionHighlight(text) {
if (text.trim() !== "") { if (text.trim() !== "" && !$element.hasClass('menu-is-opened')) {
$(".text-panel").addClass("selection"); $(".text-panel").addClass("selection");
} else { } else {
$(".text-panel").removeClass("selection"); $(".text-panel").removeClass("selection");
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
// variable used in onClick // variable used in onClick
$scope.selection_text = angular.copy(annotation); $scope.selection_text = angular.copy(annotation);
if (angular.isObject(annotation)) { if (angular.isObject(annotation) && !$element.hasClass('menu-is-opened')) {
// existing ngram // existing ngram
// Delete from the current list // Delete from the current list
$scope.menuItems = [ $scope.menuItems = [
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
$scope.menuItems.push({ $scope.menuItems.push({
'action': 'post', 'action': 'post',
'listId': stoplist_id, 'listId': stoplist_id,
'verb': 'Add to', 'verb': 'Move to',
'listName': $rootScope.lists[stoplist_id] 'listName': $rootScope.lists[stoplist_id]
}); });
} else if ($rootScope.lists[annotation.list_id] == "StopList") { } else if ($rootScope.lists[annotation.list_id] == "StopList") {
...@@ -100,13 +100,14 @@ ...@@ -100,13 +100,14 @@
$scope.menuItems.push({ $scope.menuItems.push({
'action': 'post', 'action': 'post',
'listId': miamlist_id, 'listId': miamlist_id,
'verb': 'Add to', 'verb': 'Move to',
'listName': $rootScope.lists[miamlist_id] 'listName': $rootScope.lists[miamlist_id]
}); });
} }
// show the menu // show the menu
$element.fadeIn(100); $element.fadeIn(100);
} else if (annotation.trim() !== "") { $element.addClass('menu-is-opened');
} else if (annotation.trim() !== "" && !$element.hasClass('menu-is-opened')) {
// new ngram // new ngram
$scope.menuItems = [ $scope.menuItems = [
{ {
...@@ -118,10 +119,12 @@ ...@@ -118,10 +119,12 @@
]; ];
// show the menu // show the menu
$element.fadeIn(100); $element.fadeIn(100);
$element.addClass('menu-is-opened');
} else { } else {
$scope.menuItems = []; $scope.menuItems = [];
// close the menu // close the menu
$element.fadeOut(100); $element.fadeOut(100);
$element.removeClass('menu-is-opened');
} }
}); });
}); });
...@@ -159,7 +162,7 @@ ...@@ -159,7 +162,7 @@
* Toggle the menu when clicking on an existing ngram keyword * Toggle the menu when clicking on an existing ngram keyword
*/ */
$(".text-container").delegate(':not("#selection")', "click", function(e) { $(".text-container").delegate(':not("#selection")', "click", function(e) {
if ($(e.target).hasClass("keyword-inline")) return; // if ($(e.target).hasClass("keyword-inline")) return;
positionMenu(e); positionMenu(e);
toggleSelectionHighlight(selection.toString().trim()); toggleSelectionHighlight(selection.toString().trim());
toggleMenu(null, selection.toString().trim()); toggleMenu(null, selection.toString().trim());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment