Advertisement
Guest User

cookie popup

a guest
Oct 18th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.88 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>yensdesign.com - How to create a stuning and smooth popup in jQuery</title>
  6. <link rel="stylesheet" href="http://www.mywebsite.com/templates/it_theshop/popup/general.css" type="text/css" media="screen" />
  7. <script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript"></script>
  8. <script type="text/javascript">
  9. //SETTING UP OUR POPUP
  10. //0 means disabled; 1 means enabled;
  11. var popupStatus = 0;
  12.  
  13. //loading popup with jQuery magic!
  14. function loadPopup(){
  15. //loads popup only if it is disabled
  16. if(popupStatus==0){
  17. $("#backgroundPopup").css({
  18. "opacity": "0.7"
  19. });
  20. $("#backgroundPopup").fadeIn("slow");
  21. $("#popupContact").fadeIn("slow");
  22. popupStatus = 1;
  23. }
  24. }
  25.  
  26. //disabling popup with jQuery magic!
  27. function disablePopup(){
  28. //disables popup only if it is enabled
  29. if(popupStatus==1){
  30. $("#backgroundPopup").fadeOut("slow");
  31. $("#popupContact").fadeOut("slow");
  32. popupStatus = 0;
  33. }
  34. }
  35.  
  36. //centering popup
  37. function centerPopup(){
  38. //request data for centering
  39. var windowWidth = document.documentElement.clientWidth;
  40. var windowHeight = document.documentElement.clientHeight;
  41. var popupHeight = $("#popupContact").height();
  42. var popupWidth = $("#popupContact").width();
  43. //centering
  44. $("#popupContact").css({
  45. "position": "absolute",
  46. "top": windowHeight/2-popupHeight/2,
  47. "left": windowWidth/2-popupWidth/2
  48. });
  49. //only need force for IE6
  50.  
  51. $("#backgroundPopup").css({
  52. "height": windowHeight
  53. });
  54.  
  55. }
  56. //---------------cookies-------------------//
  57.  
  58. function getCookie(c_name)
  59. {
  60. var i,x,y,ARRcookies=document.cookie.split(";");
  61. for (i=0;i<ARRcookies.length;i++)
  62. {
  63. x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  64. y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  65. x=x.replace(/^\s+|\s+$/g,"");
  66. if (x==c_name)
  67. {
  68. return unescape(y);
  69. }
  70. }
  71. }
  72.  
  73. function setCookie(c_name,value,exdays)
  74. {
  75. var exdate=new Date();
  76. exdate.setDate(exdate.getDate() + exdays);
  77. var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  78. //alert(c_value);
  79. document.cookie=c_name + "=" + c_value;
  80. }
  81.  
  82. function checkCookie()
  83. {
  84. var username=getCookie("shoppingKatalog");
  85. if (username!=null && username!="")
  86. {
  87. //
  88. }
  89. else
  90. {
  91. //centering with css
  92. centerPopup();
  93. //load popup
  94. loadPopup();
  95. setCookie("shoppingKatalog","istekuva-za-eden-den",321);
  96. }
  97. }
  98.  
  99. //--------------end cookies---------------//
  100.  
  101.  
  102. //CONTROLLING EVENTS IN jQuery
  103. $(document).ready(function(){
  104.  
  105. checkCookie();
  106. //LOADING POPUP
  107. //Click the button event!
  108. $("#button").click(function(){
  109. //centering with css
  110. centerPopup();
  111. //load popup
  112. loadPopup();
  113. });
  114.  
  115. //CLOSING POPUP
  116. //Click the x event!
  117. $("#popupContactClose").click(function(){
  118. disablePopup();
  119. });
  120. //Click out event!
  121. $("#backgroundPopup").click(function(){
  122. disablePopup();
  123. });
  124. //Press Escape event!
  125. $(document).keypress(function(e){
  126. if(e.keyCode==27 && popupStatus==1){
  127. disablePopup();
  128. }
  129. });
  130.  
  131. });
  132.  
  133. </script>
  134. <script type="text/javascript">
  135. </script>
  136. </head>
  137. <body>
  138.  
  139. <center>
  140. <a href="http://www.yensdesign.com"><img src="logo.jpg" alt="Go to yensdesign.com"/></a>
  141. </center>
  142. <div id="popupContact">
  143. <div id="popup_wrap" style="background-image:url('http://www.mywebsite.com/templates/it_theshop/images/popup/shopping-popup1.jpg');height:380px;width:800px;">
  144. <div style="float:left;width:490px;padding:5px;">
  145. <h1 style="margin:0px;">??????? ?? <span style="color:#981A32;">90%</span></h1>
  146. <h2 style="margin:0px;">?????? ?? ????????????? - <span style="color:#981A32;">????!</span></h2>
  147. <p style="margin:0px;">?????? ???? ???? ?? ?????? ??????? ?????? ?? ?????, ??????, ?????, ?????????, ????????? ?? ????, ??????, ????????... ?? ??? ??? ?? ?????? ?? ????????????? ?????.</p>
  148. <h4 style="margin:0px;">?????? Newsletter ? ?????????!</h4>
  149. <form method="post">
  150.  
  151. <table class="acymailing_form">
  152. <p style="color:#981A32;margin:0px;">???????? ?? ????? ?? ??????????? ??? ?????? ?? ?? ????????:</p>
  153. <tr>
  154. <td align="left"><input type="checkbox" class="acymailing_checkbox" name="subscription[]" checked="checked" value="1" /><b style="color:#981A32;">???? ??????? ? ?????????</b></td>
  155. </tr>
  156. <tr>
  157. <td align="left"><input type="checkbox" class="acymailing_checkbox" name="subscription[]" value="2" />
  158. <b style="color:#981A32;">???? ???? ?????????</b></td>
  159. </tr>
  160. <tr>
  161. <td align="left"><input type="checkbox" class="acymailing_checkbox" name="subscription[]" value="4" /><b style="color:#981A32;">???? ???????</b></td>
  162. </tr>
  163. <tr style="color:#981A32;">
  164. <td><label for="user_name">???</label><input id="user_name" type="text" name="user[name]" value="" /></td>
  165. </tr>
  166. <tr>
  167. <td style="color:#981A32;"><label for="user_email">E-????</label><input id="user_email" type="text" name="user[email]" value="" /></td>
  168. </tr>
  169. <tr>
  170. <td><div style="display:none;"><label for="user_html">???????</label></div></td>
  171. <td><div style="display:none;"><input type="radio" name="user[html]" value="0" id="user_html_0" /><label for="user_html_0">Text</label></div><div style="display:none;"><input type="radio" name="user[html]" value="1" id="user_html_1" checked="checked" /><label for="user_html_1">HTML</label></div></td>
  172. </tr>
  173.  
  174. <tr>
  175. <td colspan="2">
  176. <div style="display:none;">
  177. <input type="radio" name="task" value="optin" checked="checked" id="optin" /><label for="optin">Subscribe</label>
  178. <input type="radio" name="task" value="optout" id="opftout" /><label for="optout">Unsubscribe</label> </div>
  179. <input class="button" type="submit" value="??????? ?? ?????????!" name="Submit" style="color: white;background-color: orange;border: 0;border-radius: 5px;height: 30px;font-weight: bold;margin-top:5px;" onclick="setCookie('mywebsite','istekuva-za-godina',364);" /></td>
  180. </tr>
  181. </table>
  182. <input type="hidden" name="gtask" value="sub" style="color:#981A32;" />
  183. <input type="hidden" name="redirect" value="http://www.mywebsite.com" />
  184. <input type="hidden" name="option" value="com_acymailing" />
  185. <input type="hidden" name="visiblelists" value="1,2,4" />
  186. <input type="hidden" name="hiddenlists" value="YOUR_LISTS" />
  187. </form>
  188. </div>
  189. <img src="http://www.mywebsite.com/templates/it_theshop/images/popup/popust.png" style="float:right;padding-right:-10px;position: absolute;margin-left: 260px;" />
  190. </div>
  191. </div>
  192. <div id="backgroundPopup" style="display : none;">Amti Kriplani</div>
  193. </body>
  194. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement