f25e69820b3bcb16012e25f0aee0e685fde15ee7
[astakos] / snf-astakos-app / astakos / im / static / im / js / common.js
1 function setContainerMinHeight( applicableDiv){\r
2         \r
3     if ( $(applicableDiv).length > 0 ) {\r
4         //var h = $('.header').height(); div.header is not found \r
5         var f = $('.footer').height();\r
6         var w = $(window).height();\r
7         var pTop = parseInt (($(applicableDiv).css('padding-top').replace("px", "")) );\r
8         var pBottom = parseInt (($(applicableDiv).css('padding-bottom').replace("px", "")));\r
9 \r
10         var c = w - ( f+pTop+pBottom+36);//36 is header's height.\r
11         $(applicableDiv).css('min-height', c);\r
12     }    \r
13 \r
14 }\r
15 \r
16 // fix for iPhone - iPad orientation bug \r
17 var metas = document.getElementsByTagName('meta');\r
18 function resetViewport() {\r
19     var i;\r
20     if (navigator.userAgent.match(/iPhone/i)) {\r
21                 for (i=0; i<metas.length; i++) {\r
22                 if (metas[i].name == "viewport") {\r
23                         metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";\r
24                 }\r
25                 }\r
26         }\r
27 }\r
28 resetViewport();\r
29     \r
30 window.onorientationchange = function() {\r
31     resetViewport();\r
32 };\r
33     \r
34 function gestureStart() {\r
35   for (i=0; i<metas.length; i++) {\r
36     if (metas[i].name == "viewport") {\r
37       metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";\r
38     }\r
39   }\r
40 }\r
41 document.addEventListener("gesturestart", gestureStart, false);\r
42 \r
43 //end of fix\r
44 \r
45 $(document).ready(function() {\r
46         \r
47          \r
48     setContainerMinHeight('.container .wrapper');\r
49     \r
50         \r
51     $('.show-extra').click(function(e) {\r
52         e.preventDefault();\r
53         $(this).parents('.bg-wrap').find('.extra').slideToggle(600);\r
54     });\r
55     $('.hide-extra').click(function(e) {\r
56         e.preventDefault();\r
57         $(this).parents('.bg-wrap').find('.extra').slideUp(600);\r
58     });\r
59     \r
60     $('.box-more p').click(function(e) {\r
61         $(this).siblings('.clearfix').toggle('slow');\r
62         $(this).parents('.box-more').toggleClass('border');\r
63     });\r
64         \r
65         var fixTopMessageHeight = function() {\r
66                 var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom'));\r
67                 $('.mainlogo').css('marginTop','-'+topMargin+'px');\r
68         }\r
69         \r
70         if ($('.mainlogo img').length > 0) {\r
71                 $('.mainlogo img').bind('load', fixTopMessageHeight)\r
72         } else {\r
73                 fixTopMessageHeight();\r
74         }\r
75         \r
76         $('.top-msg a.close').click(function(e) {\r
77                 e.preventDefault();\r
78         $('.top-msg').animate({\r
79             paddingTop:'0',\r
80             paddingBottom:'0',\r
81             height:'0'\r
82         }, 1000, function (){\r
83              $('.top-msg').removeClass('active')\r
84         });\r
85         $('.mainlogo').animate({\r
86             marginTop:'0'\r
87         }, 1000, function (){\r
88              //todo\r
89         });\r
90     }); \r
91     //$('select').dropkick();\r
92     \r
93  \r
94     \r
95     $('.top-msg .success').parents('.top-msg').css(\r
96         {\r
97                 backgroundColor: '#77C596',\r
98                 color: '#fff'\r
99         }\r
100     );\r
101     \r
102     $('.top-msg .error').parents('.top-msg').css(\r
103         {\r
104                 backgroundColor: '#EF4F54',\r
105                 color: '#fff'\r
106         }\r
107     );\r
108     \r
109     \r
110     $('.top-msg .warning').parents('.top-msg').css(\r
111         {\r
112                 backgroundColor: '#F6921E',\r
113                 color: '#fff'\r
114         }\r
115     );\r
116     \r
117     $('.top-msg .info').parents('.top-msg').css(\r
118         {\r
119                 backgroundColor: '#C3C3B9',\r
120                 color: '#fff'\r
121         }\r
122     );\r
123     \r
124     // clouds homepage animation\r
125     $('#animation a').hover(\r
126       function () {\r
127         \r
128         $(this).animate({\r
129            top: '+=-10'   \r
130            }, 600, function() {\r
131                 if ($(this).find('img').attr('src').indexOf("_top") == -1) {\r
132                         var src = $(this).find('img').attr('src').replace('.png', '_top.png')\r
133                         $(this).find('img').attr("src", src);\r
134                 }\r
135 \r
136                 });\r
137         $(this).siblings('p').find('img').animate({\r
138           width: '60%'       \r
139         });\r
140       }, \r
141       function () {\r
142 \r
143         $(this).animate({top: '0'}, 600, function() {\r
144                 var src = $(this).find('img').attr('src').replace('_top.png', '.png')\r
145                 $(this).find('img').attr("src", src);\r
146                 });\r
147         $(this).siblings('p').find('img').animate({\r
148           width: '65%'       \r
149         });\r
150       }\r
151     );\r
152     \r
153     \r
154     /*$('#animation a').hover(\r
155       function () {\r
156         var src = $(this).find('img').attr('src').replace('.png', '_top.png')\r
157         $(this).find('img').attr("src", src);\r
158         $(this).animate({\r
159            top: '+=-10'   \r
160            }, 600, function() {\r
161                         // action to do when animation is finished\r
162                 });\r
163         $(this).siblings('p').find('img').animate({\r
164           width: '60%'       \r
165         });\r
166       }, \r
167       function () {\r
168         \r
169         $(this).animate({\r
170          top: '0'   \r
171             \r
172         }, 600, function() {\r
173                 var src = $(this).find('img').attr('src').replace('_top.png', '.png')\r
174                 $(this).find('img').attr("src", src);\r
175                 });\r
176         $(this).siblings('p').find('img').animate({\r
177           width: '65%'       \r
178         });\r
179       }\r
180     );*/\r
181     \r
182     \r
183 });\r
184 \r
185 $(window).resize(function() {\r
186     \r
187    setContainerMinHeight('.container .wrapper');\r
188 \r
189 });\r