root / snf-astakos-app / astakos / im / static / im / js / common.js @ 6ac34ab5
History | View | Annotate | Download (7.6 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 |
function tableFixedCols(table, firstColWidth ){ |
17 |
ColsNum = $('table th').size(); |
18 |
var ColWidth = parseFloat( (100 - firstColWidth)/ColsNum ).toFixed(0); |
19 |
var ColWidthPercentage = ColWidth+'%'; |
20 |
var firstColWidthPercentage = firstColWidth+'%'; |
21 |
$('table th, table td').attr('width',ColWidthPercentage ); |
22 |
$('table tr td:first-child, table tr th:first-child').attr('width',firstColWidthPercentage ); |
23 |
|
24 |
} |
25 |
|
26 |
|
27 |
//equal heights
|
28 |
|
29 |
(function($) { |
30 |
$.fn.equalHeights = function(minHeight, maxHeight) { |
31 |
tallest = (minHeight) ? minHeight : 0;
|
32 |
this.each(function() { |
33 |
if($(this).height() > tallest) { |
34 |
tallest = $(this).height(); |
35 |
} |
36 |
}); |
37 |
if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
|
38 |
return this.each(function() { |
39 |
$(this).height(tallest); |
40 |
}); |
41 |
} |
42 |
})(jQuery); |
43 |
|
44 |
|
45 |
|
46 |
// fix for iPhone - iPad orientation bug
|
47 |
var metas = document.getElementsByTagName('meta'); |
48 |
function resetViewport() { |
49 |
var i;
|
50 |
if (navigator.userAgent.match(/iPhone/i)) { |
51 |
for (i=0; i<metas.length; i++) { |
52 |
if (metas[i].name == "viewport") { |
53 |
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
|
54 |
} |
55 |
} |
56 |
} |
57 |
} |
58 |
resetViewport(); |
59 |
|
60 |
window.onorientationchange = function() { |
61 |
resetViewport(); |
62 |
}; |
63 |
|
64 |
function gestureStart() { |
65 |
for (i=0; i<metas.length; i++) { |
66 |
if (metas[i].name == "viewport") { |
67 |
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
|
68 |
} |
69 |
} |
70 |
} |
71 |
|
72 |
if (navigator.userAgent.match(/iPhone/i)) { |
73 |
document.addEventListener("gesturestart", gestureStart, false); |
74 |
} |
75 |
//end of fix
|
76 |
|
77 |
$(document).ready(function() { |
78 |
|
79 |
|
80 |
setContainerMinHeight('.container .wrapper');
|
81 |
tableFixedCols('my-projects', 25); |
82 |
|
83 |
$('.show-extra').click(function(e) { |
84 |
e.preventDefault(); |
85 |
$(this).parents('.bg-wrap').find('.extra').slideToggle(600); |
86 |
}); |
87 |
$('.hide-extra').click(function(e) { |
88 |
e.preventDefault(); |
89 |
$(this).parents('.bg-wrap').find('.extra').slideUp(600); |
90 |
}); |
91 |
|
92 |
$('.box-more p').click(function(e) { |
93 |
$(this).siblings('.clearfix').toggle('slow'); |
94 |
$(this).parents('.box-more').toggleClass('border'); |
95 |
}); |
96 |
|
97 |
var fixTopMessageHeight = function() { |
98 |
var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom')); |
99 |
$('.mainlogo').css('marginTop','-'+topMargin+'px'); |
100 |
} |
101 |
|
102 |
if ($('.mainlogo img').length > 0) { |
103 |
$('.mainlogo img').bind('load', fixTopMessageHeight) |
104 |
} else {
|
105 |
fixTopMessageHeight(); |
106 |
} |
107 |
|
108 |
$('.top-msg a.close').click(function(e) { |
109 |
e.preventDefault(); |
110 |
$('.top-msg').animate({ |
111 |
paddingTop:'0', |
112 |
paddingBottom:'0', |
113 |
height:'0' |
114 |
}, 1000, function (){ |
115 |
$('.top-msg').removeClass('active') |
116 |
}); |
117 |
$('.mainlogo').animate({ |
118 |
marginTop:'0' |
119 |
}, 1000, function (){ |
120 |
//todo
|
121 |
}); |
122 |
}); |
123 |
|
124 |
|
125 |
$('select.dropkicked').dropkick({ |
126 |
change: function (value, label) { |
127 |
$(this).parents('form').submit(); |
128 |
|
129 |
} |
130 |
}); |
131 |
|
132 |
$('.with-info select').attr('tabindex','1'); |
133 |
$('.with-info select').dropkick(); |
134 |
|
135 |
$('.top-msg .success').parents('.top-msg').addClass('success'); |
136 |
$('.top-msg .error').parents('.top-msg').addClass('error'); |
137 |
$('.top-msg .warning').parents('.top-msg').addClass('warning'); |
138 |
$('.top-msg .info').parents('.top-msg').addClass('info'); |
139 |
|
140 |
// clouds homepage animation
|
141 |
$('#animation a').hover( |
142 |
function () {
|
143 |
|
144 |
$(this).animate({ |
145 |
top: '+=-10' |
146 |
}, 600, function() { |
147 |
if ($(this).find('img').attr('src').indexOf("_top") == -1) { |
148 |
var src = $(this).find('img').attr('src').replace('.png', '_top.png') |
149 |
$(this).find('img').attr("src", src); |
150 |
} |
151 |
|
152 |
}); |
153 |
$(this).siblings('p').find('img').animate({ |
154 |
width: '60%' |
155 |
}, 600);
|
156 |
}, |
157 |
function () {
|
158 |
|
159 |
$(this).animate({top: '0'}, 600, function() { |
160 |
var src = $(this).find('img').attr('src').replace('_top.png', '.png') |
161 |
$(this).find('img').attr("src", src); |
162 |
}); |
163 |
$(this).siblings('p').find('img').animate({ |
164 |
width: '65%' |
165 |
},600);
|
166 |
} |
167 |
); |
168 |
|
169 |
|
170 |
|
171 |
|
172 |
$(function() { |
173 |
$( "#id_start_date" ).datepicker({ |
174 |
minDate: 0, |
175 |
defaultDate: "+0", |
176 |
dateFormat: "yy-mm-dd", |
177 |
onSelect: function( selectedDate ) { |
178 |
$( "#id_end_date" ).datepicker( "option", "minDate", selectedDate ); |
179 |
} |
180 |
}); |
181 |
|
182 |
$( "#id_end_date" ).datepicker({ |
183 |
defaultDate: "+3w", |
184 |
dateFormat: "yy-mm-dd", |
185 |
onSelect: function( selectedDate ) { |
186 |
$( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate ); |
187 |
} |
188 |
}); |
189 |
}); |
190 |
|
191 |
|
192 |
|
193 |
$('table .more-info').click(function(e){ |
194 |
e.preventDefault(); |
195 |
$(this).toggleClass('open'); |
196 |
if ($(this).hasClass('open')){ |
197 |
$(this).html('- less info ') |
198 |
} else {
|
199 |
$(this).html('+ more info ') |
200 |
} |
201 |
$(this).parents('tr').next('tr').toggle(); |
202 |
|
203 |
}); |
204 |
|
205 |
$('.projects .details .edit').click( function(e){ |
206 |
e.preventDefault(); |
207 |
$(this).parents('.details').children('.data').hide(); |
208 |
$(this).parents('.details').children('.editable').slideDown(500, 'linear'); |
209 |
$(this).hide(); |
210 |
}); |
211 |
|
212 |
$('.editable .form-row').each(function() { |
213 |
if ( $(this).hasClass('with-errors') ){ |
214 |
$('.editable').show(); |
215 |
$('.projects .details a.edit, .projects .details .data').hide(); |
216 |
|
217 |
} |
218 |
}); |
219 |
|
220 |
|
221 |
$("input.leave, input.join").click(function () { |
222 |
$('dialog').hide(); |
223 |
$(this).parents('.msg-wrap').find('.dialog').show(); |
224 |
return false; |
225 |
|
226 |
}); |
227 |
|
228 |
$('.msg-wrap .no').click( function(e){ |
229 |
e.preventDefault(); |
230 |
$(this).parents('.dialog').hide(); |
231 |
}) |
232 |
|
233 |
$('.msg-wrap .yes').click( function(e){ |
234 |
e.preventDefault(); |
235 |
$(this).parents('.dialog').siblings('form').submit(); |
236 |
}) |
237 |
|
238 |
$('.hidden-submit input[readonly!="True"]').focus(function () { |
239 |
$('.hidden-submit .form-row.submit').slideDown(500); |
240 |
}); |
241 |
|
242 |
|
243 |
|
244 |
$('.auth_methods').find('li>a').click(function(e){ |
245 |
e.preventDefault(); |
246 |
$(this).siblings('.wrap').toggle('slow'); |
247 |
$(this).toggleClass('up'); |
248 |
}); |
249 |
|
250 |
$('.auth_methods a.red').click(function(e){ |
251 |
e.preventDefault(); |
252 |
$(this).siblings('.dialog').show(); |
253 |
}) |
254 |
|
255 |
|
256 |
$('.auth_methods .dialog .no').click( function(e){ |
257 |
e.preventDefault(); |
258 |
console.log($(this)); |
259 |
$(this).parents('.dialog').hide(); |
260 |
}) |
261 |
|
262 |
setTimeout(function() {
|
263 |
if ($('input#id_username').val()){ |
264 |
$('input#id_username').siblings('label').css('opacity','0'); |
265 |
}; |
266 |
if ($('input#id_password').val()){ |
267 |
$('input#id_password').siblings('label').css('opacity','0'); |
268 |
} |
269 |
}, 100);
|
270 |
|
271 |
|
272 |
|
273 |
}); |
274 |
|
275 |
$(window).resize(function() { |
276 |
|
277 |
setContainerMinHeight('.container .wrapper');
|
278 |
|
279 |
|
280 |
}); |