Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table popup hide on click on page and everything except table button … #800

Merged
15 changes: 14 additions & 1 deletion dist/PublicLab.Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -23392,8 +23392,10 @@ module.exports = function initTables(_module, wysiwyg) {
$('.woofmark-command-table').attr('data-placement', 'top');

$('.woofmark-command-table').popover({html: true});

let popoverIsOpen = false;
$('.wk-commands .woofmark-command-table').click(function() {
popoverIsOpen = !popoverIsOpen;

$('.ple-table-size').click(function() {
wysiwyg.runCommand(function(chunks, mode) {
var table = createTable(
Expand All @@ -23410,6 +23412,17 @@ module.exports = function initTables(_module, wysiwyg) {
$('.woofmark-command-table').popover('toggle');
});
});

$(':not(".woofmark-command-table")').click((e) => {
// check to see that the clicked element isn't fa-table icon, else when you click on the fa-table icon, the popover will close
if (popoverIsOpen && $('.woofmark-command-table').children()[0] != e.target) {
const popoverContainer = document.querySelector('.popover');
const isChildElement = popoverContainer.contains(e.target);
if (popoverIsOpen && !e.target.classList.contains("woofmark-command-table") && !isChildElement) {
$('.woofmark-command-table').click();
}
}
});
});
};

Expand Down
15 changes: 14 additions & 1 deletion src/modules/PublicLab.RichTextModule.Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ module.exports = function initTables(_module, wysiwyg) {
$('.woofmark-command-table').attr('data-placement', 'top');

$('.woofmark-command-table').popover({html: true});

let popoverIsOpen = false;
$('.wk-commands .woofmark-command-table').click(function() {
popoverIsOpen = !popoverIsOpen;

$('.ple-table-size').click(function() {
wysiwyg.runCommand(function(chunks, mode) {
var table = createTable(
Expand All @@ -95,5 +97,16 @@ module.exports = function initTables(_module, wysiwyg) {
$('.woofmark-command-table').popover('toggle');
});
});

$(':not(".woofmark-command-table")').click((e) => {
// check to see that the clicked element isn't fa-table icon, else when you click on the fa-table icon, the popover will close
if (popoverIsOpen && $('.woofmark-command-table').children()[0] != e.target) {
const popoverContainer = document.querySelector('.popover');
const isChildElement = popoverContainer.contains(e.target);
if (popoverIsOpen && !e.target.classList.contains("woofmark-command-table") && !isChildElement) {
$('.woofmark-command-table').click();
}
}
});
TildaDares marked this conversation as resolved.
Show resolved Hide resolved
});
};