Viewing 30 posts - 1 through 30 (of 31 total)
  • Author
    Posts
  • #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!

    #1361687

    can 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 toggles

    #1361701

    Hi,
    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,
    Mike

    #1361720

    Thanks, 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.

    #1361725

    you 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-hide

    see 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.

    #1361730

    Hi,

    @sky19er
    @Guenni007’s solution at https://enfold.webers-webdesign.de/sky19er/ seems to work good.
    Please clear your browser cache and check.

    Best regards,
    Mike

    #1361757

    Thanks, 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?

    #1361769

    Comming soon …
    I just wanted to ask before investing time in a solution again and then not producing what you wanted to have after all.

    #1361786

    yes 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.

    #1361787

    PS : 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.

    #1361796

    Hi,
    Very nice, thanks for sharing @Guenni007

    Best regards,
    Mike

    #1361801

    it is probably not necessary to mention that the Gallery option is prevented by setting it to false.

    #1361825

    by 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 css

    #1361877

    Epic — 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!

    #1361878

    Ooh, 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.

    #1361900

    for 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/

    #1361903

    Just 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 that

    don’t know why this makes the difference ;)

    see all code and example page on : https://enfold.webers-webdesign.de/sky19er/

    #1361928

    Hi,

    @Guenni007
    thanks for the css recommendation, I have added it to the team member solution :)

    Best regards,
    Mike

    #1362020

    Epic, @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!!

    #1362022

    Hi,
    Glad Guenni007 could help, thank you Guenni007, we will leave this open for any closing comments from Guenni007.

    Best regards,
    Mike

    #1362039

    the 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.

    #1362114

    Ah, 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?

    #1362126

    Hi,
    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,
    Mike

    #1362138

    Thanks, 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?

    • This reply was modified 2 years ago by sky19er.
    • This reply was modified 2 years ago by sky19er.
    #1362141

    Hi,
    Thanks for your feedback, let’s wait for Guenni007’s insight on this.

    Best regards,
    Mike

    #1362153

    just 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.: people

    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: '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;
    }
    #1362323

    Awesome — thanks so much, again, Guenni — I think I can leave you alone on this one, now ;)

    #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!

    #1365693

    Hi,
    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:
    2022-09-20_001.jpg
    note the class: bio-link
    2022-09-20_002.jpg
    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,
    Mike

    #1365729

    yes – 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;
    }
Viewing 30 posts - 1 through 30 (of 31 total)
  • The topic ‘text in popup’ is closed to new replies.