Advertisement
onediewreckshun

script popup ask

Dec 28th, 2012
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. <script type="text/javascript"
  2. src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
  3.  
  4. <script>
  5.  
  6.  
  7.  
  8. $(document).ready(function() {
  9.  
  10. //
  11.  
  12.  
  13.  
  14. //When you click on a link with class of poplight and the href starts with a #
  15.  
  16. $('a.poplight[href^=#]').click(function() {
  17.  
  18. var popID = $(this).attr('rel'); //Get Popup Name
  19.  
  20. var popURL = $(this).attr('href'); //Get Popup href to define size
  21.  
  22.  
  23.  
  24. //Pull Query & Variables from href URL
  25.  
  26. var query= popURL.split('?');
  27.  
  28. var dim= query[1].split('&');
  29.  
  30. var popWidth = dim[0].split('=')[1]; //Gets the first query string value
  31.  
  32.  
  33.  
  34. //Fade in the Popup and add close button
  35.  
  36. $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://tiny.cc/closeimg" class="btn_close" title="Close Window" alt="Close" /></a>');
  37.  
  38.  
  39. //Define margin for center alignment (vertical horizontal) - we add 80px to the height/width to accomodate for the padding and border width defined in the css
  40.  
  41. var popMargTop = ($('#' + popID).height() + 80) / 2;
  42.  
  43. var popMargLeft = ($('#' + popID).width() + 80) / 2;
  44.  
  45.  
  46.  
  47. //Apply Margin to Popup
  48.  
  49. $('#' + popID).css({
  50.  
  51. 'margin-top' : -popMargTop,
  52.  
  53. 'margin-left' : -popMargLeft
  54.  
  55. });
  56.  
  57.  
  58.  
  59. //Fade in Background
  60.  
  61. $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
  62.  
  63. $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies
  64.  
  65.  
  66.  
  67. return false;
  68.  
  69. });
  70.  
  71.  
  72.  
  73. //Close Popups and Fade Layer
  74.  
  75. $('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
  76.  
  77. $('#fade , .popup_block').fadeOut(function() {
  78.  
  79. $('#fade, a.close').remove(); //fade them both out
  80.  
  81. });
  82.  
  83. return false;
  84.  
  85. });
  86.  
  87.  
  88.  
  89.  
  90.  
  91. });
  92.  
  93. </script>
  94.  
  95. <!-- DON'T TOUCH ANYTHING HERE -->
  96.  
  97. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
  98. <script src="http://static.tumblr.com/6hsqxdt/QBym35odk/jquery.masonry.js"></script>
  99. <script>
  100. $(function(){
  101. var $container = $('#container');
  102. $container.imagesLoaded(function(){
  103. $container.masonry({
  104. itemSelector: '.char',
  105. });
  106. });
  107. $container.infinitescroll({
  108. itemSelector : ".char",
  109. loadingImg : "",
  110. loadingText : "<em></em>",
  111. bufferPx : 10000,
  112. extraScrollPx: 12000,
  113. },
  114. // trigger Masonry as a callback
  115. function( newElements ) {
  116. var $newElems = $( newElements ).css({ opacity: 0 });
  117. // ensure that images load before adding to masonry layout
  118. $newElems.imagesLoaded(function(){
  119. $newElems.animate({ opacity: 1 });
  120. $container.masonry( 'appended', $newElems, true );
  121. });
  122. }
  123. );
  124. });
  125. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement