-
AuthorPosts
-
August 15, 2022 at 8:44 am #1361682
Hi, I’m wondering what your latest recommendation is for creating a link or button triggering a popup box containing text. My client would like their team bios on https://abodedev.wpengine.com/about/our-people/ to open in popup boxes instead of toggles. I see this post, but it’s from 2014 — https://kriesi.at/support/topic/contact-form-in-pop-up-prettyphoto-issue/#post-304173 — is that still the best way to handle it? Thanks so much, as always, and lmk if you have any questions!
August 15, 2022 at 10:57 am #1361687can you try this in your child-theme functions.php:
function inline_popup_for_toggles() { ?> <script type="text/javascript"> (function($){ $(window).on('load', function(){ $('#people .toggler').off('click'); $('#people .single_toggle').each(function() { $(this).magnificPopup({ type:'inline', midClick: true, items: { src: $(this).find('.toggle_content').addClass('white-popup'), } }); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'inline_popup_for_toggles');
and this in quick css:
.mfp-content .white-popup { position: relative; background: #FFF; padding: 40px; width: auto; max-width: 800px; margin: 50px auto; }
you see that selector – it is only for your ID set by yourself: #people
so if you like to have that on different places you had to adjust that selector –
PS: the .off(‘click’) removes the initial event on the togglesAugust 15, 2022 at 2:09 pm #1361701Hi,
Another option might be to see this solution for using the team member element and open it in a lightbox. I see on your page you are not using a team member element, but images with toggles below them so perhaps give this a try.Best regards,
MikeAugust 15, 2022 at 8:26 pm #1361720Thanks, Guenni007, but I’m not trying to make the toggle trigger a popup — I’d like to trigger the popup from a link or button, instead of using toggles for the bios.
And thanks, Mike — that does seem like a viable option — I think I will try that; thank you!
I would still be interested to hear if anyone has a current solution for just using a link or button to trigger a simple popup with content in it…?
Thanks again, everyone.
August 15, 2022 at 9:26 pm #1361725you want to have both functions ? toggle works and a button to open bios?
Or do you only want to have a button instead ( for the toggle container ) just put under your text-block a button. ( button link just #)
under that button put a text-block with the bio and give a custom-class to that text-block : mfp-hidesee here: https://enfold.webers-webdesign.de/sky19er/
If this is what you like to have?PS: or use the image – or the h3 Name as lightbox trigger.
August 16, 2022 at 12:05 am #1361730Hi,
@sky19er @Guenni007’s solution at https://enfold.webers-webdesign.de/sky19er/ seems to work good.
Please clear your browser cache and check.Best regards,
MikeAugust 16, 2022 at 7:59 am #1361757Thanks, Mike — and wow, Guenni007, that’s amazing — exactly what I’m looking for — just the buttons, no toggles. So, sorry, did you already post the code for that solution?
August 16, 2022 at 10:00 am #1361769Comming soon …
I just wanted to ask before investing time in a solution again and then not producing what you wanted to have after all.August 16, 2022 at 11:24 am #1361786yes the first Bio works this way:
function button_for_biography(){ ?> <script> window.addEventListener("DOMContentLoaded", function () { (function($) { $('#people').each(function(){ var that = this; $(this).find('.flex_column').each(function(i){ $(this).find('.avia-button').attr('href','#bio-'+(i+1)); $(this).find('.mfp-hide').attr('id','bio-'+(i+1)).addClass('white-popup'); }); }); $('#people .flex_column').find('.avia-button, .avia_image').magnificPopup({ type:'inline', midClick: true, gallery: { enabled:true, }, }); })(jQuery); }); </script> <?php } add_action( 'wp_footer', 'button_for_biography');
and :
.mfp-content .white-popup { position: relative; background: #FFF; padding: 40px; width: auto; max-width: 800px; margin: 50px auto; }
you see in the first part, that the function will replace that link # with a unique link : #bio-1, #bio-2 etc.
and the hidden textblock will get that unique ID –
the index method eliminates the need to manually set this link – ID correlation.August 16, 2022 at 11:31 am #1361787PS : that part:
/**** // re-appends controls inside the main container callbacks: { buildControls: function() { this.arrowLeft.appendTo(this.contentContainer); this.arrowRight.appendTo(this.contentContainer); }, }, ****/
if you like to have that – just get rid of those two lines with those asterisks
you can completely remove. This is only to have the left and right arrows inside the mfp-content container.
PPS:
if you are loading your jQuery in the footer do not forget to set a priority for that function in the last line:
add_action( 'wp_footer', 'button_for_biography', 999 );
and to have the image of your team-member inside the lightbox – just place the image into your text-block ( that with the mfp-hide class ) – on my test it is a float left setting.August 16, 2022 at 1:33 pm #1361796Hi,
Very nice, thanks for sharing @Guenni007Best regards,
MikeAugust 16, 2022 at 2:05 pm #1361801it is probably not necessary to mention that the Gallery option is prevented by setting it to false.
August 16, 2022 at 4:31 pm #1361825by the way @Mike – for your team-member ALB solution – i tried to find a gallery enabled solution – but did not find yet.
And for that page of the participant – i recommend an additonal cssAugust 16, 2022 at 8:49 pm #1361877Epic — thanks so much, Guenni007!! One last request, if you feel like it (feel free to shut me down on this ;), but I’m wondering if you might know how to add a little fade-in to the popup, just to take the edge off the popup a little. You know what I mean? So the popup doesn’t immediately snap over the screen — so there’s a slightly softer transition? Regardless, thanks again so much!
August 16, 2022 at 8:55 pm #1361878Ooh, and another thing — would it be too hard to also trigger the popups when clicking on the photos? So if the user clicked on either the photo or the button, the popup would be triggered? Again, this is “extra credit” — feel free to shut me down on these extra requests ;). Thanks again.
August 17, 2022 at 9:14 am #1361900for that fading you have to insert that mainClass:
Edit: see next posting
( PS : you can try here like Mike did in the other topic with native eventListener DOMContentLoaded – but window on load will work too )
and in additon to quick css:
.mfp-fade.mfp-bg { opacity: 0; -webkit-transition: all 0.3s ease-out; transition: all 0.3s ease-out; } .mfp-fade.mfp-bg.mfp-ready { opacity: 0.8; } .mfp-fade.mfp-bg.mfp-removing { opacity: 0; } .mfp-fade.mfp-wrap .mfp-content { opacity: 0; -webkit-transition: all 0.3s ease-out; transition: all 0.3s ease-out; } .mfp-fade.mfp-wrap.mfp-ready .mfp-content { opacity: 1; } .mfp-fade.mfp-wrap.mfp-removing .mfp-content { opacity: 0; }
and if you like to have between the items on gallery mode a fading – replace white-popup rule with :
.mfp-content .white-popup { position: relative; background: #FFF; padding: 40px; width: auto; max-width: 800px; margin: 50px auto; -webkit-animation: .3s fadeIn both; animation: .3s fadeIn both; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
You don’t have the need to insert links to the images – the code above will do – but to see that there is a link on the image:
#people .avia_image[href^="#"] { cursor: pointer; } #people .avia_image[href^="#"]:hover { box-shadow: 0 0 10px -3px #333; -webkit-transform: scale(1.05); transform: scale(1.05); }
see again: https://enfold.webers-webdesign.de/sky19er/
August 17, 2022 at 9:48 am #1361903Just a moment – i see that the gallery will show by this code each lightbox twice
so i had to thing about that a while … and because maybe not all images on the page got hidden bios – i inserted if clauses:function button_for_biography(){ ?> <script> window.addEventListener("DOMContentLoaded", function () { (function($) { $('#people').each(function(){ var that = this; $('.flex_column', this).each(function(i){ if($(this).find('.mfp-hide').length){ $(this).find('.avia-button').attr('href','#bio-'+(i+1)).addClass('no-scroll'); $(this).find('.avia_image').attr('href','#bio-'+(i+1)).addClass('no-scroll'); $(this).find('.mfp-hide').attr('id','bio-'+(i+1)).addClass('white-popup'); } }); }); $('#people .flex_column').find('.avia-button[href^="#bio-"]').magnificPopup({ type:'inline', midClick: true, removalDelay: 500, mainClass: 'mfp-fade', gallery: { enabled:true, }, }); $('#people .flex_column').find('.avia_image[href^="#bio-"]').magnificPopup({ type:'inline', midClick: true, removalDelay: 500, mainClass: 'mfp-fade', gallery: { enabled:true, }, }); })(jQuery); }); </script> <?php } add_action( 'wp_footer', 'button_for_biography');
PS: i see on your developer page that on click the lightbox opens and the background scrolls a bit.
so i inserted on those links the class: no-scroll to hamper thatdon’t know why this makes the difference ;)
see all code and example page on : https://enfold.webers-webdesign.de/sky19er/
August 17, 2022 at 12:40 pm #1361928Hi,
@Guenni007 thanks for the css recommendation, I have added it to the team member solution :)Best regards,
MikeAugust 18, 2022 at 3:34 am #1362020Epic, @guenni007 — you’re the BOMB! FYI, I added a bit of css to pull those arrows a smidge away from the content, on the phone:
.mfp-arrow-left { left: -7px; } .mfp-arrow-right { right: -7px; }
and some css I often use to unfloat images on the phone:
@media only screen and (max-width: 479px) { body .alignright, .entry-content-wrapper a:hover .alignright { margin: 5px 0px 10px 0px; float: none; } }
So it’s looking pretty good on the phone, now, I think (screenshot https://prnt.sc/Y11GDbpX-DZN)
Thanks again so much!!
August 18, 2022 at 3:40 am #1362022Hi,
Glad Guenni007 could help, thank you Guenni007, we will leave this open for any closing comments from Guenni007.Best regards,
MikeAugust 18, 2022 at 9:56 am #1362039the first Bio is there twice : do not give a link to the image – it will be done by the code itself!
The button must have that # but the images you could leave as they are.August 18, 2022 at 7:59 pm #1362114Ah, got it — thanks again. Oh, I meant to ask, is that magnificPopup code being used by some other element in Enfold? Like, when I tweak the position of the arrows in the phone view, am I potentially screwing up the formatting of some other element in Enfold?
August 18, 2022 at 9:12 pm #1362126Hi,
The magnificPopup (lightbox) is used by many elements, it is the theme’s default lightbox. I would recommend at least wrapping your code in a media query for mobile only, like you did to unfloat the images above. On Guenni007’s test page above he has added the class “people”, which if you have the same you could add to your css to target this element, like this:@media only screen and (max-width: 479px) { .mfp-wrap.people .mfp-arrow-left { left: -7px; } .mfp-wrap.people .mfp-arrow-right { right: -7px; } }
I don’t see a link to your page to check and I don’t see this class added in Guenni007’s solution above so I’m not sure, but you could add a custom class in Guenni007’s solution above if you need to.
Best regards,
MikeAugust 19, 2022 at 12:24 am #1362138Thanks, Mike. It looks like anything I add to the page itself ends up way below the code for the popups. I could use the page ID, since that’s in the body, but I’m not sure how @Guenni007 got that class added above the popup code. The page I’m working on is https://abodedev.wpengine.com/about/our-people/. Also, no offense to Guenni, of course, but I do prefer the arrows in the default enfold lightbox — for example, in the lightbox gallery for https://abodedev.wpengine.com/portfolio-item/adams-terrace/ — no one on the Enfold team has put out a way of repurposing this in the way Guenni has?
August 19, 2022 at 12:52 am #1362141Hi,
Thanks for your feedback, let’s wait for Guenni007’s insight on this.Best regards,
MikeAugust 19, 2022 at 8:03 am #1362153just put in the mainClass the enfold class: avia-popup
(mainClass: 'avia-popup mfp-fade',
) and to better select that popup maybe we put in an additonal class f.e.: peoplefunction button_for_biography(){ ?> <script> window.addEventListener("DOMContentLoaded", function () { (function($) { $('#people').each(function(){ var that = this; $('.flex_column', this).each(function(i){ if($(this).find('.mfp-hide').length){ $(this).find('.avia-button').attr('href','#bio-'+(i+1)).addClass('no-scroll'); $(this).find('.avia_image').attr('href','#bio-'+(i+1)).addClass('no-scroll'); $(this).find('.mfp-hide').attr('id','bio-'+(i+1)).addClass('white-popup'); } }); }); $('#people .flex_column').find('.avia-button[href^="#bio-"]').magnificPopup({ type:'inline', midClick: true, removalDelay: 500, mainClass: 'avia-popup mfp-fade people', gallery: { enabled:true, }, }); $('#people .flex_column').find('.avia_image[href^="#bio-"]').magnificPopup({ type:'inline', midClick: true, removalDelay: 500, mainClass: 'avia-popup mfp-fade people', gallery: { enabled:true, }, }); })(jQuery); }); </script> <?php } add_action( 'wp_footer', 'button_for_biography');
now we can influence that close button “X” only for that popup (people) by:
div.avia-popup.people .mfp-close { right: -5px; top: -45px; color: #fff; }
August 21, 2022 at 8:49 am #1362323Awesome — thanks so much, again, Guenni — I think I can leave you alone on this one, now ;)
September 19, 2022 at 3:03 am #1365469@Guenni007, I hate to ask, but would it be too much to ask for a version of this that uses text links instead of the buttons? My client prefers simple text links, like on Gio Aliano, on https://abodedev.wpengine.com/about/our-people — again, feel free to deny my request, here — I could always just style the buttons to look more like links. Thanks!
September 20, 2022 at 12:51 pm #1365693Hi,
Thanks for your question, I created a test page based on @Guenni007’s instructions and replaced the button element with a text block element with a text link:
note the class: bio-link
then I changed the script to look for the text link instead of the button:function link_for_biography(){ ?> <script> window.addEventListener("DOMContentLoaded", function () { (function($) { $('#people').each(function(){ var that = this; $('.flex_column', this).each(function(i){ if($(this).find('.mfp-hide').length){ $(this).find('.bio-link').attr('href','#bio-'+(i+1)).addClass('no-scroll'); $(this).find('.avia_image').attr('href','#bio-'+(i+1)).addClass('no-scroll'); $(this).find('.mfp-hide').attr('id','bio-'+(i+1)).addClass('white-popup'); } }); }); $('#people .flex_column').find('a[href^="#bio-"]').magnificPopup({ type:'inline', midClick: true, removalDelay: 500, mainClass: 'avia-popup mfp-fade people', gallery: { enabled:true, }, }); $('#people .flex_column').find('.avia_image[href^="#bio-"]').magnificPopup({ type:'inline', midClick: true, removalDelay: 500, mainClass: 'avia-popup mfp-fade people', gallery: { enabled:true, }, }); })(jQuery); }); </script> <?php } add_action( 'wp_footer', 'link_for_biography');
Please give this a try
Best regards,
MikeSeptember 20, 2022 at 4:15 pm #1365729yes – you can do that – or leave all as it is with buttons – and just remove the button styling on that:
body #people .avia-button { color: #000 !important; background-color: transparent; border-radius: none; padding: 0; font-size: 16px; border-bottom: none; text-align: left; background-color: transparent; } body #people .avia-button:before { content:"+ " } body #people .avia-button:active { outline: none; border: none; }
-
AuthorPosts
- The topic ‘text in popup’ is closed to new replies.