themesbyhaleigh

popup javascript

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