lulushu

popup tutorial

Sep 24th, 2016
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. ADD THIS ABOVE </head>:
  2. ------------------------------
  3. <script type="text/javascript"
  4. src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
  5. <script>
  6.  
  7. $(document).ready(function() {
  8. //When you click on a link with class of poplight and the href starts with a #
  9. $('a.poplight[href^=#]').click(function() {
  10. var popID = $(this).attr('rel'); //Get Popup Name
  11. var popURL = $(this).attr('href'); //Get Popup href to define size
  12.  
  13. //Pull Query & Variables from href URL
  14. var query= popURL.split('?');
  15. var dim= query[1].split('&');
  16. var popWidth = dim[0].split('=')[1]; //Gets the first query string value
  17.  
  18. //Fade in the Popup and add close button
  19. $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="https://31.media.tumblr.com/7d91072c76c4379e9c9625a9b318cabf/tumblr_inline_n7oirdgCRB1rshr70.png" class="btn_close" title="close" alt="Close" /></a>');
  20.  
  21. //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
  22. var popMargTop = ($('#' + popID).height() + 80) / 2;
  23. var popMargLeft = ($('#' + popID).width() + 80) / 2;
  24.  
  25. //Apply Margin to Popup
  26. $('#' + popID).css({
  27. 'margin-top' : -popMargTop,
  28. 'margin-left' : -popMargLeft
  29. });
  30.  
  31. //Fade in Background
  32. $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
  33. $('#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
  34.  
  35. return false;
  36. });
  37.  
  38. //Close Popups and Fade Layer
  39. $('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
  40. $('#fade , .popup_block').fadeOut(function() {
  41. $('#fade, a.close').remove(); //fade them both out
  42. });
  43. return false;
  44. });
  45.  
  46. });
  47. </script>
  48.  
  49. ---------------------------------------------------------------------------------------------------------------------------------------
  50. ADD THIS ABOVE </style>:
  51. ---------------------------
  52. #fade {
  53. display: none;
  54. background: #000;
  55. position: fixed;
  56. left: 0;
  57. top: 0;
  58. width: 100%;
  59. height: 100%;
  60. opacity: .20;
  61. z-index: 9999;
  62. }
  63.  
  64. .popup_block{
  65. height:auto;
  66. display: none;
  67. background: {color:Box Background};
  68. font-family:{text:font};
  69. font-size:20px;
  70. padding: 20px 20px 40px 30px;
  71. float: center;
  72. position: fixed;
  73. top: 50%;
  74. left: 50%;
  75. z-index: 99999;
  76. -moz-border-radius:4px;
  77. -webkit-border-radius:4px;
  78. }
  79.  
  80. #popup_title {
  81. font-size:30px;
  82. font-family:{text:font};
  83. position:fixed;
  84. margin-top:-50px;
  85. font-style:italic;
  86. letter-spacing:3px;
  87. color: {color:link};
  88. -webkit-filter:blur(0.8px);
  89. }
  90.  
  91. img.btn_close {
  92. margin:-12px 0 0 495px;
  93. position:fixed;
  94. float: right;
  95. }
  96.  
  97. *html #fade {
  98. position: absolute;
  99. }
  100.  
  101. *html .popup_block {
  102. position: absolute;
  103. }
  104.  
  105. /** ABOUT POPUP **/
  106. #window {
  107. width:490px;
  108. height:180px;
  109. letter-spacing: 1px;
  110. float:right;
  111. margin-top:0px;
  112. font-family: {text:font};
  113. font-size: 11px;
  114. color: {color:text};
  115. padding:10px;
  116. border: 1px solid {color:Link};
  117. border-radius: 8px;
  118. }
  119.  
  120. #window img{
  121. max-width:175px;
  122. max-height:180px;
  123. float:left;
  124. border-radius: 8px;
  125. }
  126.  
  127. #cloud {
  128. float:right;
  129. width:308px;
  130. height:180px;
  131. }
  132.  
  133. #stats {
  134. float:left;
  135. font-family: {text:font};
  136. font-size: 20px;
  137. color: {color:text};
  138. background-color: {color:Posts};
  139. border: 1px solid {color:Link};
  140. margin: 0px 8px 8px 0px;
  141. padding:5px;
  142. max-width:180px;
  143. letter-spacing: 1px;
  144. border-radius: 8px;
  145. }
  146.  
  147. #bio {
  148. float:left;
  149. font-family: {text:font};
  150. font-size: 20px;
  151. color: {color:text};
  152. background-color: {color:Posts};
  153. border: 1px solid {color:Link};
  154. padding:5px;
  155. width:290px;
  156. max-height:150px;
  157. overflow:auto;
  158. font-size: 20px;
  159. letter-spacing: 1px;
  160. border-radius: 8px;
  161. }
  162.  
  163. ---------------------------------------------------------------------------------------------------------------------------------------
  164. ADD THIS SOMEWHERE IN THE BODY (PREFERABLY UNDER DESCRIPTION):
  165. ----------------------------------------------
  166. <a href="#?w=500" rel="popup" class="poplight"> TEXT </a>
  167.  
  168. <a href="#?w=500" rel="popup" class="poplight" title="{text:link title}" style="background:transparent;"><img src="{image:link button}"></a>
  169.  
  170. ---------------------------------------------------------------------------------------------------------------------------------------
  171. ADD THIS SOMEWHERE ABOVE THE THEME CREDIT (IF THERE IS ONE) OR ABOVE {block:posts}
  172. ---------------------------------------------------------------------------
  173. <div id="popup" class="popup_block">
  174. <div id="popup_title">инфо</div>
  175.  
  176. <div id="window">
  177. <img src=" IMG LINK ">
  178.  
  179. <div id="cloud">
  180. <div id="stats"> TEXT </div>
  181. <div id="stats"> YOU CAN DELETE OR ADD AS MANY OF THESE AS YOU WANT </div>
  182. <div id="stats"> dgdfgdfgdfg </div>
  183. <div id="stats"> dfdfdf </div>
  184. <div id="stats"> dfgdgdgdfgfd </div>
  185.  
  186. <div id="bio">
  187. bagkjfdgshfldshfj;dhdslhsdlffldsjldsfsfs
  188. </div>
  189.  
  190. </div>
  191. </div>
  192.  
  193. </div>
Advertisement
Add Comment
Please, Sign In to add comment