root / snf-astakos-app / astakos / im / static / im / js / common.js @ 5ebebb20
History | View | Annotate | Download (7.9 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 |
$('select.dropkicked').dropkick({ |
116 |
change: function (value, label) { |
117 |
$(this).parents('form').submit(); |
118 |
|
119 |
} |
120 |
}); |
121 |
|
122 |
$('.top-msg .success').parents('.top-msg').addClass('success'); |
123 |
$('.top-msg .error').parents('.top-msg').addClass('error'); |
124 |
$('.top-msg .warning').parents('.top-msg').addClass('warning'); |
125 |
$('.top-msg .info').parents('.top-msg').addClass('info'); |
126 |
|
127 |
// clouds homepage animation
|
128 |
$('#animation a').hover( |
129 |
function () {
|
130 |
|
131 |
$(this).animate({ |
132 |
top: '+=-10' |
133 |
}, 600, function() { |
134 |
if ($(this).find('img').attr('src').indexOf("_top") == -1) { |
135 |
var src = $(this).find('img').attr('src').replace('.png', '_top.png') |
136 |
$(this).find('img').attr("src", src); |
137 |
} |
138 |
|
139 |
}); |
140 |
$(this).siblings('p').find('img').animate({ |
141 |
width: '60%' |
142 |
}, 600);
|
143 |
}, |
144 |
function () {
|
145 |
|
146 |
$(this).animate({top: '0'}, 600, function() { |
147 |
var src = $(this).find('img').attr('src').replace('_top.png', '.png') |
148 |
$(this).find('img').attr("src", src); |
149 |
}); |
150 |
$(this).siblings('p').find('img').animate({ |
151 |
width: '65%' |
152 |
},600);
|
153 |
} |
154 |
); |
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
///if ($('.widjets'.length > 0)) {
|
161 |
///$('.widjets li div .txt').equalHeights();
|
162 |
///}
|
163 |
|
164 |
$(function() { |
165 |
if($("#id_issue_date").length > 0 ){ |
166 |
$( "#id_issue_date" ).datepicker({ |
167 |
defaultDate: "+0", |
168 |
dateFormat: "yy-mm-dd", |
169 |
onSelect: function( selectedDate ) { |
170 |
$( "#id_expiration_date" ).datepicker( "option", "minDate", selectedDate ); |
171 |
} |
172 |
}); |
173 |
$( "#id_expiration_date" ).datepicker({ |
174 |
defaultDate: "+1w", |
175 |
dateFormat: "yy-mm-dd", |
176 |
onSelect: function( selectedDate ) { |
177 |
$( "#id_issue_date" ).datepicker( "option", "maxDate", selectedDate ); |
178 |
} |
179 |
}); |
180 |
} |
181 |
|
182 |
if($("#id_issue_date_demo").length > 0 ){ |
183 |
$( "#id_issue_date_demo" ).datepicker({ |
184 |
defaultDate: "+0", |
185 |
dateFormat: "yy-mm-dd", |
186 |
onSelect: function( selectedDate ) { |
187 |
$( "#id_expiration_date_demo" ).datepicker( "option", "minDate", selectedDate ); |
188 |
} |
189 |
}); |
190 |
$( "#id_expiration_date_demo" ).datepicker({ |
191 |
defaultDate: "+1w", |
192 |
dateFormat: "yy-mm-dd", |
193 |
onSelect: function( selectedDate ) { |
194 |
$( "#id_issue_date_demo" ).datepicker( "option", "maxDate", selectedDate ); |
195 |
} |
196 |
}); |
197 |
} |
198 |
$( "#id_start_date" ).datepicker({ |
199 |
dateFormat: "yy-mm-dd", |
200 |
onSelect: function( selectedDate ) { |
201 |
$( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate ); |
202 |
} |
203 |
}); |
204 |
|
205 |
$( "#id_end_date" ).datepicker({ |
206 |
dateFormat: "yy-mm-dd", |
207 |
onSelect: function( selectedDate ) { |
208 |
$( "#id_end_date" ).datepicker( "option", "maxDate", selectedDate ); |
209 |
} |
210 |
}); |
211 |
}); |
212 |
|
213 |
|
214 |
$(".table_sorting").tablesorter(); |
215 |
|
216 |
$('table .more-info').click(function(e){ |
217 |
e.preventDefault(); |
218 |
$(this).toggleClass('open'); |
219 |
if ($(this).hasClass('open')){ |
220 |
$(this).html('- less info ') |
221 |
} else {
|
222 |
$(this).html('+ more info ') |
223 |
} |
224 |
$(this).parents('tr').next('tr').toggle(); |
225 |
|
226 |
}); |
227 |
|
228 |
$('.projects .details .edit').click( function(e){ |
229 |
e.preventDefault(); |
230 |
$(this).parents('.details').children('.data').hide(); |
231 |
$(this).parents('.details').children('.editable').slideDown(500, 'linear'); |
232 |
$(this).hide(); |
233 |
}); |
234 |
|
235 |
$('.editable .form-row').each(function() { |
236 |
if ( $(this).hasClass('with-errors') ){ |
237 |
$('.editable').show(); |
238 |
$('.projects .details a.edit, .projects .details .data').hide(); |
239 |
|
240 |
} |
241 |
}); |
242 |
|
243 |
$('.widjet-x').click(function(e){ |
244 |
e.preventDefault(); |
245 |
$(this).siblings('ul').hide('slow'); |
246 |
$(this).hide(); |
247 |
}) |
248 |
|
249 |
// todo den doulevei
|
250 |
$('#group_create_form').submit(function(){ |
251 |
if ($('.quotas-form .group .form-row.with-errors').length>0 ){ |
252 |
return false; |
253 |
} |
254 |
var flag = 0; |
255 |
$('.quotas-form .group input[type="text"]').each(function() { |
256 |
// get value from input
|
257 |
var value = $(this).val(); |
258 |
if (value){
|
259 |
flag =1;
|
260 |
} |
261 |
}); |
262 |
if (flag =='0') { |
263 |
$('#icons span.info').addClass('error-msg'); |
264 |
return false; |
265 |
|
266 |
} |
267 |
}); |
268 |
|
269 |
|
270 |
|
271 |
$("input.leave, input.join").click(function () { |
272 |
$(this).parents('.msg-wrap').find('.dialog').show(); |
273 |
return false; |
274 |
|
275 |
}); |
276 |
|
277 |
$('.msg-wrap .no').click( function(e){ |
278 |
e.preventDefault(); |
279 |
$(this).parents('.dialog').hide(); |
280 |
}) |
281 |
|
282 |
$('.msg-wrap .yes').click( function(e){ |
283 |
e.preventDefault(); |
284 |
$(this).parents('.dialog').siblings('form').submit(); |
285 |
}) |
286 |
|
287 |
$('.hidden-submit input[readonly!="True"]').focus(function () { |
288 |
$('.hidden-submit .form-row.submit').show(500); |
289 |
}); |
290 |
|
291 |
}); |
292 |
|
293 |
$(window).resize(function() { |
294 |
|
295 |
setContainerMinHeight('.container .wrapper');
|
296 |
|
297 |
|
298 |
}); |