Advertisement
Katting

Popup Block Script

Sep 27th, 2016
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <!--------------Popup Boxes Needed Script--------------->
  2. <script>
  3. $(document).ready(function() {
  4. //
  5. $('a.poplight[href^=#]').click(function() {
  6. var popID = $(this).attr('rel'); //Get Popup Name
  7. var popURL = $(this).attr('href'); //Get Popup href to define size
  8. var query= popURL.split('?');
  9. var dim= query[1].split('&');
  10. var popWidth = dim[0].split('=')[1]; //Gets the first query string value
  11. $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://media.tumblr.com/tumblr_lngwqr5hbf1qf72le.png" class="btn_close" title="Close" alt="Close" /></a>');
  12. var popMargTop = ($('#' + popID).height() + 80) / 2;
  13. var popMargLeft = ($('#' + popID).width() + 80) / 2;
  14. //Apply Margin to Popup
  15. $('#' + popID).css({
  16. 'margin-top' : -popMargTop,
  17. 'margin-left' : -popMargLeft
  18. });
  19. $('body').append('<div id="fade"></div>');
  20. $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'})
  21. return false;
  22. });
  23. $('a.close, #fade').live('click', function() {
  24. $('#fade , .popup_block').fadeOut(function() {
  25. $('#fade, a.close').remove(); //fade them both out
  26. });
  27. return false;
  28. });
  29. });
  30. </script>
  31. <!---------------End Popup Boxes Script----------------->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement