JavaScript Page /Include/popup.js (VB.NET)
1: //SETTING UP OUR POPUP
2: //0 means disabled; 1 means enabled;
3: var popupStatus = 0;
4: //loading popup with jQuery magic!
5: function loadPopup(){
6:     //loads popup only if it is disabled
7:     if(popupStatus==0){
8:         $("#backgroundPopup").css({
9:             "opacity": "0.7"
10:         });
11:         $("#backgroundPopup").fadeIn("slow");
12:         $("#popupContact").fadeIn("slow");
13:         popupStatus = 1;
14:     }
15: }
16:
17: //disabling popup with jQuery magic!
18: function disablePopup(){
19:     //disables popup only if it is enabled
20:     if(popupStatus==1){
21:         $("#backgroundPopup").fadeOut("slow");
22:         $("#popupContact").fadeOut("slow");
23:         popupStatus = 0;
24:     }
25: }
26:
27: //centering popup
28: function centerPopup(){
29:     //request data for centering
30:     var windowWidth = document.documentElement.clientWidth;
31:     var windowHeight = document.documentElement.clientHeight;
32:     var popupHeight = $("#popupContact").height();
33:     var popupWidth = $("#popupContact").width();
34:     //centering
35:     $("#popupContact").css({
36:         "position": "absolute",
37:         "top": windowHeight/2-popupHeight/2,
38:         "left": windowWidth/2-popupWidth/2
39:     });
40:     //only need force for IE6
41:     
42:     $("#backgroundPopup").css({
43:         "height": windowHeight
44:     });
45:     
46: }
47:
48:
49: //CONTROLLING EVENTS IN jQuery
50: $(document).ready(function () {
51:     //LOADING POPUP
52:     //Click the button event!
53:     $("#button").click(function(){
54:         //centering with css
55:         centerPopup();
56:         //load popup
57:         loadPopup();
58:     });
59:                 
60:     //CLOSING POPUP
61:     //Click the x event!
62:     $("#popupContactClose").click(function(){
63:         disablePopup();
64:     });
65:     //Click out event!
66:     $("#backgroundPopup").click(function(){
67:         disablePopup();
68:     });
69:     //Press Escape event!
70:     $(document).keypress(function(e){
71:         if(e.keyCode==27 && popupStatus==1){
72:             disablePopup();
73:         }
74:     });
75:
76: });

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.