root / snf-astakos-app / astakos / im / static / im / js / common.js @ ed2f0452
History | View | Annotate | Download (6.5 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').dropkick();
|
116 |
|
117 |
$('.top-msg .success').parents('.top-msg').addClass('success'); |
118 |
$('.top-msg .error').parents('.top-msg').addClass('error'); |
119 |
$('.top-msg .warning').parents('.top-msg').addClass('warning'); |
120 |
$('.top-msg .info').parents('.top-msg').addClass('info'); |
121 |
|
122 |
// clouds homepage animation
|
123 |
$('#animation a').hover( |
124 |
function () {
|
125 |
|
126 |
$(this).animate({ |
127 |
top: '+=-10' |
128 |
}, 600, function() { |
129 |
if ($(this).find('img').attr('src').indexOf("_top") == -1) { |
130 |
var src = $(this).find('img').attr('src').replace('.png', '_top.png') |
131 |
$(this).find('img').attr("src", src); |
132 |
} |
133 |
|
134 |
}); |
135 |
$(this).siblings('p').find('img').animate({ |
136 |
width: '60%' |
137 |
}, 600);
|
138 |
}, |
139 |
function () {
|
140 |
|
141 |
$(this).animate({top: '0'}, 600, function() { |
142 |
var src = $(this).find('img').attr('src').replace('_top.png', '.png') |
143 |
$(this).find('img').attr("src", src); |
144 |
}); |
145 |
$(this).siblings('p').find('img').animate({ |
146 |
width: '65%' |
147 |
},600);
|
148 |
} |
149 |
); |
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
if ($('.widjets'.length > 0)) { |
156 |
$('.widjets li div').equalHeights(); |
157 |
} |
158 |
|
159 |
$(function() { |
160 |
if($("#id_issue_date").length > 0 ){ |
161 |
$( "#id_issue_date" ).datepicker({ |
162 |
defaultDate: "+0", |
163 |
dateFormat: "yy-mm-dd", |
164 |
onSelect: function( selectedDate ) { |
165 |
$( "#id_expiration_date" ).datepicker( "option", "minDate", selectedDate ); |
166 |
} |
167 |
}); |
168 |
$( "#id_expiration_date" ).datepicker({ |
169 |
defaultDate: "+1w", |
170 |
dateFormat: "yy-mm-dd", |
171 |
onSelect: function( selectedDate ) { |
172 |
$( "#id_issue_date" ).datepicker( "option", "maxDate", selectedDate ); |
173 |
} |
174 |
}); |
175 |
} |
176 |
|
177 |
if($("#id_issue_date_demo").length > 0 ){ |
178 |
$( "#id_issue_date_demo" ).datepicker({ |
179 |
defaultDate: "+0", |
180 |
dateFormat: "yy-mm-dd", |
181 |
onSelect: function( selectedDate ) { |
182 |
$( "#id_expiration_date_demo" ).datepicker( "option", "minDate", selectedDate ); |
183 |
} |
184 |
}); |
185 |
$( "#id_expiration_date_demo" ).datepicker({ |
186 |
defaultDate: "+1w", |
187 |
dateFormat: "yy-mm-dd", |
188 |
onSelect: function( selectedDate ) { |
189 |
$( "#id_issue_date_demo" ).datepicker( "option", "maxDate", selectedDate ); |
190 |
} |
191 |
}); |
192 |
} |
193 |
$( "#id_start_date" ).datepicker({ |
194 |
dateFormat: "yy-mm-dd", |
195 |
onSelect: function( selectedDate ) { |
196 |
$( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate ); |
197 |
} |
198 |
}); |
199 |
|
200 |
$( "#id_end_date" ).datepicker({ |
201 |
dateFormat: "yy-mm-dd", |
202 |
onSelect: function( selectedDate ) { |
203 |
$( "#id_end_date" ).datepicker( "option", "maxDate", selectedDate ); |
204 |
} |
205 |
}); |
206 |
}); |
207 |
|
208 |
|
209 |
$(".table_sorting").tablesorter(); |
210 |
|
211 |
$('table .more-info').click(function(e){ |
212 |
e.preventDefault(); |
213 |
$(this).toggleClass('open'); |
214 |
$(this).parents('tr').next('tr').toggle(); |
215 |
|
216 |
}); |
217 |
|
218 |
$('.projects .details .edit').click( function(e){ |
219 |
e.preventDefault(); |
220 |
$(this).parents('.details').children('.data').hide(); |
221 |
$(this).parents('.details').children('.editable').show(); |
222 |
$(this).hide(); |
223 |
}) |
224 |
|
225 |
|
226 |
$('.widjet-x').click(function(e){ |
227 |
e.preventDefault(); |
228 |
$(this).siblings('ul').hide('slow'); |
229 |
$(this).hide(); |
230 |
}) |
231 |
|
232 |
|
233 |
|
234 |
|
235 |
}); |
236 |
|
237 |
$(window).resize(function() { |
238 |
|
239 |
setContainerMinHeight('.container .wrapper');
|
240 |
if ($('.widjets').length > 0) { |
241 |
$('.widjets li div').equalHeights(); |
242 |
} |
243 |
|
244 |
}); |