title: How can I close lean modal popup after x seconds?
body: <p>OK, so i am using a lean modal script, and i want after it processes my code to automaticaly close after 3 seconds. The lean modal script looks like this:</p>
  
  <pre><code>(function($) {
      $.fn.extend({
          leanModal: function(options) {
              var defaults = {
                  top: 100,
                  overlay: 0.5,
                  closeButton: null
              };
              var overlay = $("&lt;div id='lean_overlay'&gt;&lt;/div&gt;");
              $("body").append(overlay);
              options = $.extend(defaults, options);
              return this.each(function() {
                  var o = options;
                  $(this).click(function(e) {
                      var modal_id = $(this).attr("href");
                      $("#lean_overlay").click(function() {
                          close_modal(modal_id)
                      });
                      $(o.closeButton).click(function() {
                          close_modal(modal_id)
                      });
                      var modal_height = $(modal_id).outerHeight();
                      var modal_width = $(modal_id).outerWidth();
                      $("#lean_overlay").css({
                          "display": "block",
                          opacity: 0
                      });
                      $("#lean_overlay").fadeTo(200, o.overlay);
                      $(modal_id).css({
                          "display": "block",
                          "position": "fixed",
                          "opacity": 0,
                          "z-index": 11000,
                          "left": 50 + "%",
                          "margin-left": -(modal_width / 2) + "px",
                          "top": o.top + "px"
                      });
                      $(modal_id).fadeTo(200, 1);
                      e.preventDefault()
                  })
              });
  
              function close_modal(modal_id) {
                  $("#lean_overlay").fadeOut(200);
                  $(modal_id).css({
                      "display": "none"
                  })
              }
          }
      })
  })(jQuery);
  </code></pre>
  
  <p>The modal windows is opened on the main index page, but another php script processes a form within this modal windows. What javascript code do i need in my processing page to close this? Thanks in advance.</p>
  
  <p>tried using this to close it but will close only the low opacity thing surrounding the popup container:</p>
  
  <pre><code>setTimeout(function(){ 
  
                  $("#lean_overlay").fadeOut(200);
                  $(modal_id).css({
                      "display": "none"
                  })
                  $(".popupContainer").fadeOut(200);
                  $(modal_id).css({
                      "display": "none"
                  })
                  $(".popupBody").fadeOut(200);
                  $(modal_id).css({
                      "display": "none"
                  })
  
  
              }, 3000);
  </code></pre>