Advertisement
itskrystalized

popup lightbox 04# >> javascript

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