Skip to content
Snippets Groups Projects
Commit 25627e9a authored by Sven Kästle's avatar Sven Kästle
Browse files

refactor: Switch from passing element to id of annotation

parent e90511d6
No related branches found
No related tags found
No related merge requests found
...@@ -283,6 +283,7 @@ function displayAnnotation(annotation) { ...@@ -283,6 +283,7 @@ function displayAnnotation(annotation) {
.append( .append(
// annotation card // annotation card
$('<div>').attr('class', 'annotation-card') $('<div>').attr('class', 'annotation-card')
.attr('id', annotation.id)
.mouseenter(function () { .mouseenter(function () {
$(this).children('.annotation-header').css('background-color', getDarkUserColor(annotation.userToken)); $(this).children('.annotation-header').css('background-color', getDarkUserColor(annotation.userToken));
}) })
...@@ -321,7 +322,7 @@ function displayAnnotation(annotation) { ...@@ -321,7 +322,7 @@ function displayAnnotation(annotation) {
// unfold button // unfold button
$('<div>').attr('class', 'annotation-header-toggle') $('<div>').attr('class', 'annotation-header-toggle')
.click(function () { .click(function () {
toggleButtonHandler($(this)); toggleButtonHandler(annotation.id);
}) })
.append( .append(
$('<i>').attr('class', 'fas fa-chevron-down') $('<i>').attr('class', 'fas fa-chevron-down')
...@@ -347,8 +348,7 @@ function displayAnnotation(annotation) { ...@@ -347,8 +348,7 @@ function displayAnnotation(annotation) {
$('<i>').attr('class', editIcon) $('<i>').attr('class', editIcon)
) )
.click(function () { .click(function () {
// deleteAnnotationHandler($(this).closest('li'), annotation.id) editAnnotationHandler(annotation.id)
editAnnotationHandler($(this).closest('.annotation-card'))
}) })
} }
} }
...@@ -541,13 +541,15 @@ function isTimestampToday(timestamp) { ...@@ -541,13 +541,15 @@ function isTimestampToday(timestamp) {
/** /**
* Toggle between the toggle button status * Toggle between the toggle button status
* *
* @param element The given toggle button * @param id The id of the clicked annotation
*/ */
function toggleButtonHandler(element) { function toggleButtonHandler(id) {
// the clicked annotation card
var card = $('#' + id);
// open and close annotation text // open and close annotation text
element.parent().siblings(".annotation-body").children("p").toggleClass("overflow-hidden"); card.find(".annotation-body").children("p").toggleClass("overflow-hidden");
// toggle between up and down button // toggle between up and down button
element.children("i").toggleClass("fa-chevron-down fa-chevron-up") card.find('.annotation-header-toggle').children("i").toggleClass("fa-chevron-down fa-chevron-up")
} }
/** /**
...@@ -583,9 +585,11 @@ function saveNewAnnotation(title, comment, startCharacter, endCharacter) { ...@@ -583,9 +585,11 @@ function saveNewAnnotation(title, comment, startCharacter, endCharacter) {
/** /**
* Open edit modal with title and comment from given card * Open edit modal with title and comment from given card
* *
* @param card The clicked annotation card * @param id The id of the clicked annotation
*/ */
function editAnnotationHandler(card) { function editAnnotationHandler(id) {
// the clicked annotation card
var card = $('#' + id);
// get title and comment // get title and comment
var title = card.find('.annotation-header-data-title').text(); var title = card.find('.annotation-header-data-title').text();
var comment = card.find('.annotation-body-text').text(); var comment = card.find('.annotation-body-text').text();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment