bfocht

Domain Search Modal JavaScript

Dec 16th, 2017
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($) {
  2.     // build popup on body
  3.     $('body').append($('<div/>').attr("id", "popResults").addClass(""));
  4.     $('body').append($('<div/>').attr("id", "blackout").addClass(""));
  5.     $('#popResults').append($('<div/>').attr("id", "closePop").addClass("").html("X"));
  6.  
  7.     function showModal() {
  8.         $('#blackout').fadeIn();
  9.         $('#popResults').fadeIn();
  10.         $('.result-content').fadeIn();
  11.         $('#popResults').append($('.result-content'));
  12.     }
  13.  
  14.     //move domain search results on click
  15.     $('.rstore-domain-search').on('click', '.rstore-domain-search-button', showModal);
  16.  
  17.     //remove search results and add the results div back to the search bar
  18.     $('body').on('click', '#closePop, #blackout', function() {
  19.         $('#popResults').fadeOut();
  20.         $('#blackout').fadeOut();
  21.         $('.result-content').hide();
  22.         $('.search-box').append($('.result-content'));
  23.     });
  24.  
  25.     //check for query string param domainToCheck and display modal
  26.     (/[?&]domainToCheck=./.test(location.search)) && showModal();
  27.  
  28. });
Advertisement
Add Comment
Please, Sign In to add comment