root / snf-astakos-app / astakos / im / static / im / js / common.js @ bde71886
History | View | Annotate | Download (6.8 kB)
1 |
function setContainerMinHeight( applicableDiv){ |
---|---|
2 |
|
3 |
if ( $(applicableDiv).length > 0 ) { |
4 |
//var h = $('.header').height(); div.header is not found
|
5 |
var f = $('.footer').height(); |
6 |
var w = $(window).height(); |
7 |
var pTop = parseInt (($(applicableDiv).css('padding-top').replace("px", "")) ); |
8 |
var pBottom = parseInt (($(applicableDiv).css('padding-bottom').replace("px", ""))); |
9 |
|
10 |
var c = w - ( f+pTop+pBottom+36);//36 is header's height. |
11 |
$(applicableDiv).css('min-height', c); |
12 |
} |
13 |
|
14 |
} |
15 |
|
16 |
|
17 |
//equal heights
|
18 |
|
19 |
(function($) { |
20 |
$.fn.equalHeights = function(minHeight, maxHeight) { |
21 |
tallest = (minHeight) ? minHeight : 0;
|
22 |
this.each(function() { |
23 |
if($(this).height() > tallest) { |
24 |
tallest = $(this).height(); |
25 |
} |
26 |
}); |
27 |
if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
|
28 |
return this.each(function() { |
29 |
$(this).height(tallest); |
30 |
}); |
31 |
} |
32 |
})(jQuery); |
33 |
|
34 |
|
35 |
|
36 |
// fix for iPhone - iPad orientation bug
|
37 |
var metas = document.getElementsByTagName('meta'); |
38 |
function resetViewport() { |
39 |
var i;
|
40 |
if (navigator.userAgent.match(/iPhone/i)) { |
41 |
for (i=0; i<metas.length; i++) { |
42 |
if (metas[i].name == "viewport") { |
43 |
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
|
44 |
} |
45 |
} |
46 |
} |
47 |
} |
48 |
resetViewport(); |
49 |
|
50 |
window.onorientationchange = function() { |
51 |
resetViewport(); |
52 |
}; |
53 |
|
54 |
function gestureStart() { |
55 |
for (i=0; i<metas.length; i++) { |
56 |
if (metas[i].name == "viewport") { |
57 |
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
|
58 |
} |
59 |
} |
60 |
} |
61 |
|
62 |
if (navigator.userAgent.match(/iPhone/i)) { |
63 |
document.addEventListener("gesturestart", gestureStart, false); |
64 |
} |
65 |
//end of fix
|
66 |
|
67 |
$(document).ready(function() { |
68 |
|
69 |
|
70 |
setContainerMinHeight('.container .wrapper');
|
71 |
|
72 |
|
73 |
$('.show-extra').click(function(e) { |
74 |
e.preventDefault(); |
75 |
$(this).parents('.bg-wrap').find('.extra').slideToggle(600); |
76 |
}); |
77 |
$('.hide-extra').click(function(e) { |
78 |
e.preventDefault(); |
79 |
$(this).parents('.bg-wrap').find('.extra').slideUp(600); |
80 |
}); |
81 |
|
82 |
$('.box-more p').click(function(e) { |
83 |
$(this).siblings('.clearfix').toggle('slow'); |
84 |
$(this).parents('.box-more').toggleClass('border'); |
85 |
}); |
86 |
|
87 |
var fixTopMessageHeight = function() { |
88 |
var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom')); |
89 |
$('.mainlogo').css('marginTop','-'+topMargin+'px'); |
90 |
} |
91 |
|
92 |
if ($('.mainlogo img').length > 0) { |
93 |
$('.mainlogo img').bind('load', fixTopMessageHeight) |
94 |
} else {
|
95 |
fixTopMessageHeight(); |
96 |
} |
97 |
|
98 |
$('.top-msg a.close').click(function(e) { |
99 |
e.preventDefault(); |
100 |
$('.top-msg').animate({ |
101 |
paddingTop:'0', |
102 |
paddingBottom:'0', |
103 |
height:'0' |
104 |
}, 1000, function (){ |
105 |
$('.top-msg').removeClass('active') |
106 |
}); |
107 |
$('.mainlogo').animate({ |
108 |
marginTop:'0' |
109 |
}, 1000, function (){ |
110 |
//todo
|
111 |
}); |
112 |
}); |
113 |
|
114 |
|
115 |
|
116 |
//$('select').dropkick();
|
117 |
|
118 |
|
119 |
$('.top-msg .success').parents('.top-msg').addClass('success'); |
120 |
$('.top-msg .error').parents('.top-msg').addClass('error'); |
121 |
$('.top-msg .warning').parents('.top-msg').addClass('warning'); |
122 |
$('.top-msg .info').parents('.top-msg').addClass('info'); |
123 |
|
124 |
// clouds homepage animation
|
125 |
$('#animation a').hover( |
126 |
function () {
|
127 |
|
128 |
$(this).animate({ |
129 |
top: '+=-10' |
130 |
}, 600, function() { |
131 |
if ($(this).find('img').attr('src').indexOf("_top") == -1) { |
132 |
var src = $(this).find('img').attr('src').replace('.png', '_top.png') |
133 |
$(this).find('img').attr("src", src); |
134 |
} |
135 |
|
136 |
}); |
137 |
$(this).siblings('p').find('img').animate({ |
138 |
width: '60%' |
139 |
}, 600);
|
140 |
}, |
141 |
function () {
|
142 |
|
143 |
$(this).animate({top: '0'}, 600, function() { |
144 |
var src = $(this).find('img').attr('src').replace('_top.png', '.png') |
145 |
$(this).find('img').attr("src", src); |
146 |
}); |
147 |
$(this).siblings('p').find('img').animate({ |
148 |
width: '65%' |
149 |
},600);
|
150 |
} |
151 |
); |
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
if ($('.widjets'.length > 0)) { |
158 |
$('.widjets li div').equalHeights(); |
159 |
} |
160 |
|
161 |
$(function() { |
162 |
if($("#id_issue_date").length > 0 ){ |
163 |
$( "#id_issue_date" ).datepicker({ |
164 |
defaultDate: "+0", |
165 |
dateFormat: "yy-mm-dd", |
166 |
onSelect: function( selectedDate ) { |
167 |
$( "#id_expiration_date" ).datepicker( "option", "minDate", selectedDate ); |
168 |
} |
169 |
}); |
170 |
$( "#id_expiration_date" ).datepicker({ |
171 |
defaultDate: "+1w", |
172 |
dateFormat: "yy-mm-dd", |
173 |
onSelect: function( selectedDate ) { |
174 |
$( "#id_issue_date" ).datepicker( "option", "maxDate", selectedDate ); |
175 |
} |
176 |
}); |
177 |
} |
178 |
|
179 |
if($("#id_issue_date_demo").length > 0 ){ |
180 |
$( "#id_issue_date_demo" ).datepicker({ |
181 |
defaultDate: "+0", |
182 |
dateFormat: "yy-mm-dd", |
183 |
onSelect: function( selectedDate ) { |
184 |
$( "#id_expiration_date_demo" ).datepicker( "option", "minDate", selectedDate ); |
185 |
} |
186 |
}); |
187 |
$( "#id_expiration_date_demo" ).datepicker({ |
188 |
defaultDate: "+1w", |
189 |
dateFormat: "yy-mm-dd", |
190 |
onSelect: function( selectedDate ) { |
191 |
$( "#id_issue_date_demo" ).datepicker( "option", "maxDate", selectedDate ); |
192 |
} |
193 |
}); |
194 |
} |
195 |
}); |
196 |
|
197 |
|
198 |
$(".table_sorting").tablesorter(); |
199 |
|
200 |
$('table .more-info').click(function(e){ |
201 |
e.preventDefault(); |
202 |
$(this).toggleClass('open'); |
203 |
$(this).parents('tr').next('tr').toggle(); |
204 |
|
205 |
}); |
206 |
|
207 |
$('.projects .details .edit').click( function(e){ |
208 |
e.preventDefault(); |
209 |
$(this).parents('.details').children('.data').hide(); |
210 |
$(this).parents('.details').children('.editable').show(); |
211 |
$(this).hide(); |
212 |
}) |
213 |
|
214 |
|
215 |
$('.widjet-x').click(function(e){ |
216 |
e.preventDefault(); |
217 |
$(this).siblings('ul').hide('slow'); |
218 |
$(this).hide(); |
219 |
}) |
220 |
|
221 |
// quota form actions
|
222 |
|
223 |
$('.quotas-form ul li a').click(function(e){ |
224 |
e.preventDefault(); |
225 |
$(this).addClass('selected'); |
226 |
var id = $(this).attr('id'); |
227 |
$('.quotas-form fieldset').each(function() { |
228 |
if($(this).hasClass(id)) { |
229 |
$(this).show('slow'); |
230 |
} |
231 |
}); |
232 |
|
233 |
}); |
234 |
|
235 |
$('.quotas-form fieldset .delete').click(function(e){ |
236 |
e.preventDefault(); |
237 |
$(this).parents('fieldset').find('input').val(''); |
238 |
$(this).parents('fieldset').hide('slow'); |
239 |
fieldsetClass = $(this).parents('fieldset').attr('class').replace('quota ', ''); |
240 |
$('.quotas-form ul li a').each(function() { |
241 |
if($(this).attr('id')==fieldsetClass) { |
242 |
$(this).removeClass('selected'); |
243 |
} |
244 |
}); |
245 |
|
246 |
|
247 |
}) |
248 |
|
249 |
|
250 |
|
251 |
}); |
252 |
|
253 |
$(window).resize(function() { |
254 |
|
255 |
setContainerMinHeight('.container .wrapper');
|
256 |
if ($('.widjets').length > 0) { |
257 |
$('.widjets li div').equalHeights(); |
258 |
} |
259 |
|
260 |
}); |