Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="wrapper">
  <main>
    <div class="container">
      <div class="row">
        <div class="col-md-3">
          <!-- Sidebar Content -->
          <p>First Sidebar Ad</p>
          <p>
            <a class="open-riser" href="#" data-title="First Marketo Form" data-mktoformid="1534">
              <img src="http://placehold.it/260x150">
            </a>
          </p>
          <p>Second Sidebar Ad</p>
          <p>
            <a class="open-riser" href="#" data-title="Second Marketo Form" data-mktoformid="1551">
              <img src="http://placehold.it/260x150">
            </a>
          </p>
        </div>
        <!--/.col-md-3-->
        <div class="col-md-9">
          <!-- Main Content Area -->
          <h1>Marketo Double Click Demo</h1>
          <h4 style="color:red;">Quicly click the sidebar ads on the left multiple times to see the bug.</h4>
          <p>Each sidebar ad has a data-attribute <code>data-mktoformid="XXXX"</code> that contains the form id for the marketo form we want to load into the riser.</p>
          <hr />
          <p>Lorem ipsum dolor sit amet, sed mollis nullam, dolor aenean adipiscing dolor sapien dapibus. Tortor justo duis. Congue vitae diam. Imperdiet suspendisse justo class nonummy sit. Lacus odio fermentum ac eget, velit sociosqu semper maecenas sodales
            natoque, sem integer lobortis, vehicula pellentesque mi, et vestibulum nullam.</p>
          <p>Lorem ipsum dolor sit amet, sed mollis nullam, dolor aenean adipiscing dolor sapien dapibus. Tortor justo duis. Congue vitae diam. Imperdiet suspendisse justo class nonummy sit. Lacus odio fermentum ac eget, velit sociosqu semper maecenas sodales
            natoque, sem integer lobortis, vehicula pellentesque mi, et vestibulum nullam.</p>
        </div>
        <!--/.col-md-9 -->
      </div>
      <!--/.row-->
    </div>
    <!--/.container-->
  </main>
  <!-- The overlay that blocks out the page behind the riser from being clicked -->
  <div id="PageOverlay" class=""></div>
  <!-- Form Riser -->
  <div id="FormRiser">
    <button id="closeRiser" class="close"><span aria-hidden="true">&times;</span></button>
    <div class="container">
      <h1 class="riser-title"></h1>
      <div class="form-container">
        <!-- this is where the <form> element gets rendered -->
      </div>
    </div>
  </div>
  <!--/Form Riser -->
</div>
<!--/.wrapper-->

              
            
!

CSS

              
                html,
body{
  width: 100%;
  height: 100%;
}

.wrapper{
  position: relative;
  width: 100%;
  height: 100%;

}

#PageOverlay {
    position: fixed;
    display: none;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    background: rgba(42,45,51,.7);
    visibility: hidden;
    z-index: 9998;
    -webkit-transition: all .3s ease;
    -moz-transition: all .3s ease;
    -o-transition: all .3s ease;
    transition: all .3s ease;
}

#FormRiser{
  background:orange;
  position:fixed;
  min-height:300px;
  height:auto;
  padding:60px 0;
  bottom:0;
  left:0;
  width:100%;
  z-index: 9999;
  -webkit-transform: translateY(100%);
  transform: translateY(100%);
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
}
#FormRiser .close{
  position:absolute;
  top: 20px;
  right: 20px;
  font-size:36px;
}

/*add .riser-open class to body to trigger riser css*/
body.riser-open #PageOverlay{
  display: block;
  visibility: visible;
  opacity: 1;
}
body.riser-open #PageOverlay:hover{
  cursor: pointer;
}
body.riser-open #FormRiser{
  -webkit-transform: translateY(0);
  transform: translateY(0);
}

              
            
!

JS

              
                var MarketoRiser = (function($, window, undefined) {
  "use strict";
  /* Marketo Account */
  var MktoAccount = {
    baseUrl: "//app-ab17.marketo.com",
    munchkinId: "361-IGT-147"
  };
  /* Riser Variables*/
  var body = $("body"),
    formContainer = $(".form-container"),
    riserTitle = $(".riser-title"),
    _isOpen = false;

  //when the form has been loaded and ready...
  MktoForms2.whenReady(function(form) {
    var formEl = form.getFormElem()[0];
    formEl.id = "";

    console.log("MktoForms2 is ready");
    form.onSuccess(function(values, followUpUrl) {
      riserTitle.text("Thank You!"); //set riser title to "thank you"
      // form.getFormElem().hide();  // Get the form's jQuery element and hide it
      deleteFormEl(); //delete form element
      return false; // Prevent the submission handler from taking the lead to the follow up url
    });
  });

  /**
   *  Private Methods
   */
  function getMktoForm(formid, title) {
    //set the title in the riser
    riserTitle.text(title);

    //delete any previous forms inside riser
    deleteFormEl();

    //create form element dynamically, since we cannot have a <form> tag inside a web form
    var formEl = document.createElement("form"); //create form element
    formEl.setAttribute("id", "mktoForm_" + formid); //set the form id so Marketo knows where to render the form
    formContainer.append(formEl); //add form element inside riser container
    console.log("form element created");

    //now that the <form> has been created, we need to load the MarketoForm
    MktoForms2.loadForm(MktoAccount.baseUrl, MktoAccount.munchkinId, formid);
  }


  function deleteFormEl() {
    console.log(document.querySelectorAll(".form-container form"));
    if ($(".form-container form").length > 0) {
      $(".form-container form").remove();
      console.log("form element deleted");
    }
  }

  /**
   *  Public Methods
   */
  function OpenRiser(data) {
    /* if the riser is closed */
    if (!_isOpen) {
      _isOpen = true; //set flag to true
      console.log("OpenRiser(), _isOpen:true");
      body.addClass("riser-open");
      //pass the form id and title from the clicked element to the renderForm method
      getMktoForm(data.mktoformid, data.title);
    }
  }

  function CloseRiser() {
    /* if the riser is open */
    if (_isOpen) {
      body.removeClass("riser-open");
      deleteFormEl();
      _isOpen = false; //set flag to true
      console.log("CloseRiser(), _isOpen:false");
    }
  }

  //return public methods
  return {
    OpenRiser: OpenRiser,
    CloseRiser: CloseRiser
  };
})(jQuery, window);

/*normally the code below is placed on page or 
  from within another js file, but putting it in
  here for readability*/
$(document).ready(function() {
  //when a sidebar ad with open-riser class is clicked
  $(".open-riser").on("click", function(evt) {
    evt.preventDefault();
    var elData = $(this).data(); //get the data from the data-attributes
    MarketoRiser.OpenRiser(elData) //pass the data to the OpenRiser method
  });

  //when a riser is open we can close it by clicking the close X in the riser,
  //or by clicking on the page overlay
  $("#closeRiser, #PageOverlay").on("click", function() {
    MarketoRiser.CloseRiser();
  });
});

              
            
!
999px

Console