Skip to content

Commit

Permalink
Fixed author hover
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Sep 24, 2024
1 parent 319faa0 commit 9efe490
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"name": "ep_author_hover",
"description": "Adds author names to span titles (shows on hover), works as authors change their name. Hover includes author color and fast switching between author spans. Hat tip to Martyn York for the initial work on this.",
"version": "0.3.55",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "[email protected]:JohnMcLear/ep_author_hover.git"
Expand Down
27 changes: 11 additions & 16 deletions static/js/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
'use strict';

const padcookie = require('ep_etherpad-lite/static/js/pad_cookie').padcookie;
import html10n from 'ep_etherpad-lite/static/js/vendors/html10n'

let timer = 0;

const showAuthor = {
enable: (context) => {
context.ace.callWithAce((ace) => {
const doc = ace.ace_getDocument();
$(doc).find('#innerdocbody').mousemove(exports.showAuthor.hover.bind(ace));
}, 'showAuthor', true);
enable: () => {
$('iframe[name="ace_outer"]').contents().find('iframe')
.contents().find('#innerdocbody').on('mousemove',exports.showAuthor.hover);
},
disable: (context) => {
context.ace.callWithAce((ace) => {
const doc = ace.ace_getDocument();
$(doc).find('#innerdocbody').mousemove(null.bind(ace));
$(doc).find('#innerdocbody').on('mousemove',null.bind(ace));
}, 'showAuthor', true);
},
hover: (span) => {
Expand All @@ -34,7 +33,7 @@ const showAuthor = {
if (!authorId) { return; } // Default text isn't shown
showAuthor.destroy(); // Destroy existing
const authorNameAndColor =
showAuthor.authorNameAndColorFromAuthorId(authorId); // Get the authorName And Color
showAuthor.authorNameAndColorFromAuthorId(authorId); // Get the authorName And Color
showAuthor.draw(span, authorNameAndColor.name, authorNameAndColor.color);
}
},
Expand All @@ -57,7 +56,7 @@ const showAuthor = {
const myAuthorId = pad.myUserInfo.userId.substring(0, 14);
if (myAuthorId === authorId) {
return {
name: window._('ep_author_hover.me'),
name: html10n.get('ep_author_hover.me'),
color: '#fff',
};
}
Expand All @@ -68,7 +67,7 @@ const showAuthor = {
if (authorId === $(this).data('authorid').substring(0, 14)) {
$(this).find('.usertdname').each(function () {
authorObj.name = $(this).text();
if (authorObj.name === '') authorObj.name = window._('ep_author_hover.unknow_author');
if (authorObj.name === '') authorObj.name = html10n.get('ep_author_hover.unknow_author');
});
$(this).find('.usertdswatch > div').each(function () {
authorObj.color = $(this).css('background-color');
Expand All @@ -83,12 +82,12 @@ const showAuthor = {
authorObj = clientVars.collab_client_vars.historicalAuthorData[fullAuthorId];
}

return authorObj || {name: window._('ep_author_hover.unknow_author'), color: '#fff'};
return authorObj || {name: html10n.get('ep_author_hover.unknow_author'), color: '#fff'};
},
draw: (target, authorName, authorColor) => {
if (!authorName) {
const warning =
'No authorName, I have no idea why! Help me debug this by providing steps to replicate!';
'No authorName, I have no idea why! Help me debug this by providing steps to replicate!';
console.warn(warning);
return;
}
Expand Down Expand Up @@ -144,11 +143,7 @@ exports.postAceInit = (hookName, context) => {
$('#options-author-hover').attr('checked', 'checked');
}

if ($('#options-author-hover').is(':checked')) {
clientVars.plugins.plugins.ep_author_hover.enabled = true;
} else {
clientVars.plugins.plugins.ep_author_hover.enabled = false;
}
clientVars.plugins.plugins.ep_author_hover.enabled = !!$('#options-author-hover').is(':checked');

/* on click */
$('#options-author-hover').on('click', () => {
Expand Down

0 comments on commit 9efe490

Please sign in to comment.