diff --git a/src/js/plugins/lectureNote.js b/src/js/plugins/lectureNote.js index ec23750c0..20227f5d2 100644 --- a/src/js/plugins/lectureNote.js +++ b/src/js/plugins/lectureNote.js @@ -102,7 +102,17 @@ export default class LectureNote { addLectureNote () { const time = Math.round(this.player.currentTime); - if (this.hasSameTimeLectureNote(time)) { + const note = this.getSameTimeLectureNote(time); + if (note) { + + const lectureNoteContainer = getElement.call(this.player, '.lecture-note[data-id="' + note._id + '"]'); + if (lectureNoteContainer) { + const contentContianer = lectureNoteContainer.querySelector('lecture-note__content-container '); + if (contentContianer) { + const clickEvent = new Event('click'); + contentContianer.dispatchEvent(clickEvent) + } + } } else { this.disableLectureNote(); @@ -147,6 +157,15 @@ export default class LectureNote { return false; } + getSameTimeLectureNote (time) { + for (let i = 0; i < this.lectureNoteList.length; i += 1) { + if (this.lectureNoteList[i].time === time) { + return this.lectureNoteList[i]; + } + } + return null; + } + /** * @private * @return {null|*} @@ -304,6 +323,21 @@ export default class LectureNote { } }); + contentTextarea.addEventListener('blur', (e) => { + lectureNote.note = contentTextarea.value; + contentShowText.innerHTML = lectureNote.note; + toggleClass(contentContainer, 'lecture-note__content-container--edit', false); + lectureNote.showStatus = LectureNoteModel.ShowStatus.Hide; + toggleClass(lectureNoteContainer, 'hover', true); + cancelTimeout = setTimeout(() => { + toggleClass(lectureNoteContainer, 'hover', false); + }, 1000); + triggerEvent.call(this.player, this.player.media, 'lecturenoteupdate', true, { + lectureNote: lectureNote, + }); + e.preventDefault(); + }); + mark.addEventListener('mouseenter', (e) => { if (cancelTimeout) { clearTimeout(cancelTimeout);