Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
tiblu committed Feb 20, 2020
1 parent 26d86a9 commit d619168
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 0.0.4
* BUG: Authors list is not visible when toolbar is on multiple lines. Also fixed resize handling. - https://github.com/tiblu/ep_authorship_toggle/issues/1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ I also wanted the list of authors to be shown when the colors are enabled, like

## Credits

* [CitizenOS](https://citizenos.com) for funding the development
* [Citizen OS](https://citizenos.com) for funding the development

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ep_authorship_toggle",
"version": "0.0.3",
"version": "0.0.4",
"description": "Toggle authorship colors on and off.",
"author": {
"name": "Tiblu"
Expand Down
16 changes: 14 additions & 2 deletions static/js/clientHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,34 @@
exports.postToolbarInit = function (hook_name, args) {
var editbar = args.toolbar; // toolbar is actually editbar - http://etherpad.org/doc/v1.5.7/#index_editbar

var $window = $(window);
var $inner = $('iframe[name=ace_outer]').contents().find('iframe[name=ace_inner]').contents();
var $docBody = $inner.find('#innerdocbody');
var $editorcontainer = $('#editorcontainer');
var $editbar = $('#editbar');

var $epAuthorshipToggleAuthorList = $('#epAuthorshipToggleAuthorList');
var $epAuthorList = $epAuthorshipToggleAuthorList.find('#authorsList');

var resizeHandler = function() {
console.log('epAuthorshipToggle', 'resize handler!');

$epAuthorshipToggleAuthorList.css('top', $editbar.outerHeight() + 'px');
$editorcontainer.css('top', $epAuthorshipToggleAuthorList.offset().top + $epAuthorshipToggleAuthorList.outerHeight());
};

editbar.registerCommand('epAuthorshipToggle', function () {
var isVisibleAuthor = $epAuthorshipToggleAuthorList.is(':visible');

$docBody.toggleClass('authorColors');

if (isVisibleAuthor) { // Is visible so it's gonna be hidden
$editorcontainer.css('top', $editorcontainer.offset().top - $epAuthorshipToggleAuthorList.outerHeight());
$window.off('resize', resizeHandler);

$epAuthorshipToggleAuthorList.toggle();
} else {
$window.on('resize', resizeHandler);

// Clear previous authors and build a new author list
$epAuthorList.empty();

Expand All @@ -50,7 +62,7 @@ exports.postToolbarInit = function (hook_name, args) {

if (Object.keys(authors).length) {
$epAuthorshipToggleAuthorList.toggle(); // Show before to get height
$editorcontainer.css('top', $editorcontainer.offset().top + $epAuthorshipToggleAuthorList.outerHeight());
resizeHandler();
}
}
});
Expand Down

0 comments on commit d619168

Please sign in to comment.