Code to hide popup when clicked anywhere
-
So I needed to be able to hide the popup when clicked anywhere on the screen. This was requested a few times here before without any replies, so I tried it myself.
I did it using jQuery code and some workarounds. Hopefully the plugin owner can implement it too ??
This code is changed in anything-popup.php. Line 162, change from
$pop = $pop . '<div style="display: none;" id="AnythingPopup_BoxContainer'.$pop_content_id.'">';
to
$pop = $pop . '<div style="display: none;" class="AnythingPopupBox" id="AnythingPopup_BoxContainer'.$pop_content_id.'">';
And line 169, change from
$pop = $pop . '<div style="display: none;" id="AnythingPopup_BoxContainerFooter'.$pop_content_id.'"></div>';
to
$pop = $pop . '<div style="display: none;" class="AnythingPopupBoxContainer" id="AnythingPopup_BoxContainerFooter'.$pop_content_id.'"></div>';
This code is added in anything-popup.js, anywhere, but outside of the existing functions:
jQuery(document).ready(function (e) { jQuery(".AnythingPopupBoxContainer").click(function(){ jQuery(".AnythingPopupBox:visible").hide(); jQuery(".AnythingPopupBoxContainer:visible").hide(); }); });
The downside about this method is that it will close all open popups.
- The topic ‘Code to hide popup when clicked anywhere’ is closed to new replies.