Skip to content

Commit

Permalink
Progressive enh, inline callback fn
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrammatiko committed Jun 1, 2020
1 parent 9184643 commit 7d9a364
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions build/media_source/plg_editors_tinymce/js/tinymce.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,21 @@

editors.forEach((editor) => {
const currentEditor = editor.querySelector('textarea');
const toggleButton = editor.querySelector('.js-tiny-toggler-button');

// Setup the editor
Joomla.JoomlaTinyMCE.setupEditor(currentEditor, pluginOptions);

// Setup the toggle button
const toggleEditor = function toggleEditor() {
if (Joomla.editors.instances[currentEditor.id].instance.isHidden()) {
Joomla.editors.instances[currentEditor.id].instance.show();
} else {
Joomla.editors.instances[currentEditor.id].instance.hide();
}
};

const toggleButton = editor.querySelector('.js-tiny-toggler-button');

if (toggleButton) {
toggleButton.addEventListener('click', toggleEditor);
toggleButton.removeAttribute('disabled');
toggleButton.addEventListener('click', () => {
if (Joomla.editors.instances[currentEditor.id].instance.isHidden()) {
Joomla.editors.instances[currentEditor.id].instance.show();
} else {
Joomla.editors.instances[currentEditor.id].instance.hide();
}
});
}
});
},
Expand Down
2 changes: 1 addition & 1 deletion layouts/joomla/tinymce/togglebutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
?>
<div class="toggle-editor btn-toolbar float-right clearfix mt-3">
<div class="btn-group">
<button type="button" class="btn btn-secondary js-tiny-toggler-button">
<button type="button" disabled class="btn btn-secondary js-tiny-toggler-button">
<span class="fas fa-eye" aria-hidden="true"></span>
<?php echo Text::_('PLG_TINY_BUTTON_TOGGLE_EDITOR'); ?>
</button>
Expand Down

0 comments on commit 7d9a364

Please sign in to comment.