ulvis.paste.net

Paste Search Dynamic
Recent pastes
popup.js
  1. /***************************/
  2. //@Author: Adrian "yEnS" Mato Gondelle
  3. //@website: www.yensdesign.com
  4. //@license: Feel free to use it, but keep this credits please!                    
  5. /***************************/
  6.  
  7. //SETTING UP OUR POPUP
  8. //0 means disabled; 1 means enabled;
  9. var popupStatus = 0;
  10.  
  11. //loading popup with jQuery magic!
  12. function loadPopup(){
  13.     //loads popup only if it is disabled
  14.     if(popupStatus==0){
  15.         $("#backgroundPopup").css({
  16.             "opacity": "0.95"
  17.         });
  18.         $("#backgroundPopup").fadeIn("slow");
  19.         $("#popupContact").fadeIn("slow");
  20.         popupStatus = 1;
  21.     }
  22. }
  23.  
  24. function age_ok()
  25. {
  26. document.cookie='age_ok=1; expires=Thu, 2 Aug 2020 20:00:00 UTC; path=/';
  27. }
  28.  
  29. //disabling popup with jQuery magic!
  30. function disablePopup(){
  31.     //disables popup only if it is enabled
  32.     if(popupStatus==1) {
  33.         age_ok();
  34.         $("#backgroundPopup").fadeOut("slow");
  35.         $("#popupContact").fadeOut("slow");
  36.         popupStatus = 0;
  37.     }
  38. }
  39.  
  40. //centering popup
  41. function centerPopup(){
  42.     //request data for centering
  43.     var windowWidth = document.documentElement.clientWidth;
  44.     var windowHeight = document.documentElement.clientHeight;
  45.     var popupHeight = $("#popupContact").height();
  46.     var popupWidth = $("#popupContact").width();
  47.     //centering
  48.     $("#popupContact").css({
  49.         "position": "absolute",
  50.         "top": windowHeight/2-popupHeight/2,
  51.         "left": windowWidth/2-popupWidth/2
  52.     });
  53.     //only need force for IE6
  54.    
  55.     $("#backgroundPopup").css({
  56.         "height": windowHeight
  57.     });
  58.    
  59. }
  60.  
  61.  
  62. //CONTROLLING EVENTS IN jQuery
  63. $(document).ready(function(){
  64.    
  65.    
  66.     //LOADING POPUP
  67.     //Click the button event!
  68. $(document).ready(function() {
  69.         //centering with css
  70.         centerPopup();
  71.         //load popup
  72.         loadPopup();
  73.     });
  74.            
  75.     //CLOSING POPUP
  76.     //Click the x event!
  77.     $("#popupContactClose").click(function(){
  78.         disablePopup();
  79.     });
  80.     //Click out event!
  81.     $("#backgroundPopup").click(function(){
  82. //        disablePopup();
  83.     });
  84.     //Press Escape event!
  85.     $(document).keypress(function(e){
  86.         if(e.keyCode==27 && popupStatus==1){
  87. //            disablePopup();
  88.         }
  89.     });
  90.  
  91. });
Parsed in 0.012 seconds