Jump to content

cloecloa

Member
  • Posts

    10
  • Joined

  • Last visited

Posts posted by cloecloa

  1. Thanks so much this is showing now! 

    Do you know how to get it to show on mobile as well?

    I also noticed, when you actually submit your email into the form it closes instantly without the thank you message showing. Is there a way for that message to show and for the pop-up to have an close X in the top right?

     

     

     

  2. Hi @tuanphan

    This is exactly what I need, I tried to install this on my website and it hasn't worked. The form has disappeared from the page but no pop-up appears. 

    I have tried setting the squarespace built-in pop-up to show on this page and not to show on this page but the pop-up doesn't appear either way. 

    Would really appreciate your help:

    URL and Code below: 

    https://www.howaboutnope.com/np-shop

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
    <script>
    $(document).ready(function() {
      function handlePopUp() {
        var popup = $('.form-block');
        var isHidePopup = getCookie('coookieIsHidePopup');
        if('true'!==isHidePopup){
          popup.css('display', 'block');
        }
        // Hide popup when clicking outsite
        $(document).click(function (e){
          if('block' == popup.css('display')) {
            if (!popup.is(e.target) && popup.has(e.target).length === 0){
              hidePopupAndSetCookie( popup, 1 );
            }
          }
        });
        // Hide popup when close or submit
        $('#close-popup, .newsletter-form-button, header.newsletter-form-header').click(function() {
          hidePopupAndSetCookie( popup, 1 );
        });
      }
      function hidePopupAndSetCookie(popup, time) {
        popup.hide();
        setCookie('coookieIsHidePopup', 'true', 1);
      }
      function setCookie(cname, cvalue, exdays) {
        var now = new Date();
        //d.setTime(d.getTime() + (exdays*24*60*60*1000));
        //var expires = "expires="+ d.toUTCString();
        //window.document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
        now.setTime(now.getTime() + 24 * 3600 * 1000);
        document.cookie = "name=value; expires=" + now.toUTCString() + "; path=/";
      }
      function getCookie(cname) {
        var name = cname + "=";
        var decodedCookie = decodeURIComponent(window.document.cookie);
        var ca = decodedCookie.split(';');
        for(var i = 0; i <ca.length; i++) {
          var c = ca[i];
          while (c.charAt(0) == ' ') {
            c = c.substring(1);
          }
          if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
          }
        }
        
        return "";
      }
      handlePopUp();
    });
    </script>
    <style>
    #block-yui_3_17_2_1_1667994634958_6508 {
      position: fixed;
      width: 340px;
      background-color: green; /* newsletter background */
      top: 100px;
      left: 0;
      right: 0;
      margin: 0 auto;
      z-index: 999;
      display: none;
    }
    /* Close icon */
    #block-yui_3_17_2_1_1667994634958_6508.newsletter-form-header:before {
        content: "\e01a";
        font-family: 'squarespace-ui-font';
        color: white;
        border: 1px solid white;
        position: absolute;
        right: -30px;
        top: 0;
        padding: 5px;
        line-height: 15px;
      z-index: 20000;
      cursor: pointer;
    }
    </style>

     

     

  3. Hi Tuanphan, 

    Thank you so so much for your help! That sorted the bulk buy sections and I can swap out the block-yui code for all other sections. 

    I did try it for the "single bars" section and it doesn't work, from what I see it only has a block- Id. I attached a screenshot because not sure if it is possible in accordion or if I need a different id number?

    1115676328_Screenshot2022-09-06at17_36_43.thumb.png.34cfa31e219f8f13de6fe3072e73d525.png

  4. Hi all, 

    Thanks so much for posting this, it has been really helpful and fixed my problem also. I have noticed, however that it doesn't work on all the product blocks on the site. I had previously thought it was because some product blocks were in an accordion but I have removed them from this and it is still not working. 

    It works on the top section of product blocks but when these lower down blocks are separated by heading text it stops working. Are you able to help?

    Thanks,

    Chloe

    Screenshot 2022-09-04 at 12.19.31.png

    Screenshot 2022-09-04 at 12.19.24.png

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.