root / cloudcms / static / cloudcms / js / common.js @ ff30ee3a
History | View | Annotate | Download (9.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 |
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 |
$('.projects table th, .projects table td').attr('width',ColWidthPercentage ); |
22 |
$('.projects table tr td:first-child,.projects table tr th:first-child').attr('width',firstColWidthPercentage ); |
23 |
|
24 |
} |
25 |
|
26 |
function addClassHover(hoverEl, applicableEl){ |
27 |
$(hoverEl).hover(
|
28 |
function () {
|
29 |
|
30 |
$(applicableEl).addClass('red-border') |
31 |
}, |
32 |
function () {
|
33 |
$(applicableEl).removeClass('red-border'); |
34 |
|
35 |
}); |
36 |
} |
37 |
//equal heights
|
38 |
|
39 |
(function($) { |
40 |
$.fn.equalHeights = function(minHeight, maxHeight) { |
41 |
tallest = (minHeight) ? minHeight : 0;
|
42 |
this.each(function() { |
43 |
if($(this).height() > tallest) { |
44 |
tallest = $(this).height(); |
45 |
} |
46 |
}); |
47 |
if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
|
48 |
return this.each(function() { |
49 |
$(this).height(tallest); |
50 |
}); |
51 |
} |
52 |
})(jQuery); |
53 |
|
54 |
|
55 |
|
56 |
// fix for iPhone - iPad orientation bug
|
57 |
var metas = document.getElementsByTagName('meta'); |
58 |
function resetViewport() { |
59 |
var i;
|
60 |
if (navigator.userAgent.match(/iPhone/i)) { |
61 |
for (i=0; i<metas.length; i++) { |
62 |
if (metas[i].name == "viewport") { |
63 |
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
|
64 |
} |
65 |
} |
66 |
} |
67 |
} |
68 |
resetViewport(); |
69 |
|
70 |
window.onorientationchange = function() { |
71 |
resetViewport(); |
72 |
}; |
73 |
|
74 |
function gestureStart() { |
75 |
for (i=0; i<metas.length; i++) { |
76 |
if (metas[i].name == "viewport") { |
77 |
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
|
78 |
} |
79 |
} |
80 |
} |
81 |
|
82 |
if (navigator.userAgent.match(/iPhone/i)) { |
83 |
document.addEventListener("gesturestart", gestureStart, false); |
84 |
} |
85 |
//end of fix
|
86 |
|
87 |
|
88 |
$(document).ready(function() { |
89 |
|
90 |
|
91 |
|
92 |
setContainerMinHeight('.container .wrapper');
|
93 |
tableFixedCols('my-projects', 25); |
94 |
|
95 |
$('.show-extra').click(function(e) { |
96 |
e.preventDefault(); |
97 |
$(this).parents('.bg-wrap').find('.extra').slideToggle(600); |
98 |
}); |
99 |
$('.hide-extra').click(function(e) { |
100 |
e.preventDefault(); |
101 |
$(this).parents('.bg-wrap').find('.extra').slideUp(600); |
102 |
}); |
103 |
|
104 |
$('.box-more p').click(function(e) { |
105 |
$(this).siblings('.clearfix').toggle('slow'); |
106 |
$(this).parents('.box-more').toggleClass('border'); |
107 |
}); |
108 |
|
109 |
var fixTopMessageHeight = function() { |
110 |
var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom')); |
111 |
$('.mainlogo').css('marginTop','-'+topMargin+'px'); |
112 |
} |
113 |
|
114 |
// Uncomment to hide logo upon top message appearance
|
115 |
|
116 |
// if ($('.mainlogo img').length > 0) {
|
117 |
// $('.mainlogo img').bind('load', fixTopMessageHeight)
|
118 |
// } else {
|
119 |
// fixTopMessageHeight();
|
120 |
// }
|
121 |
|
122 |
$('.top-msg a.close').click(function(e) { |
123 |
e.preventDefault(); |
124 |
$('.top-msg').animate({ |
125 |
paddingTop:'0', |
126 |
paddingBottom:'0', |
127 |
height:'0' |
128 |
}, 1000, function (){ |
129 |
$('.top-msg').removeClass('active') |
130 |
}); |
131 |
$('.mainlogo').animate({ |
132 |
marginTop:'0' |
133 |
}, 1000, function (){ |
134 |
//todo
|
135 |
}); |
136 |
}); |
137 |
|
138 |
|
139 |
$('select.dropkicked').dropkick({ |
140 |
change: function (value, label) { |
141 |
$(this).parents('form').submit(); |
142 |
|
143 |
} |
144 |
}); |
145 |
|
146 |
$('.with-info select').attr('tabindex','1'); |
147 |
$('.with-info select').dropkick(); |
148 |
|
149 |
$('.top-msg .success').parents('.top-msg').addClass('success'); |
150 |
$('.top-msg .error').parents('.top-msg').addClass('error'); |
151 |
$('.top-msg .warning').parents('.top-msg').addClass('warning'); |
152 |
$('.top-msg .info').parents('.top-msg').addClass('info'); |
153 |
|
154 |
// clouds homepage animation
|
155 |
$('#animation a').hover( |
156 |
function () {
|
157 |
|
158 |
$(this).animate({ |
159 |
top: '+=-3' |
160 |
}, 0, function() { |
161 |
if ($(this).find('img').attr('src').indexOf("_top") == -1) { |
162 |
var src = $(this).find('img').attr('src').replace('.png', '_top.png') |
163 |
$(this).find('img').attr("src", src); |
164 |
} |
165 |
|
166 |
}); |
167 |
$(this).siblings('p').find('img').animate({ |
168 |
width: '60%' |
169 |
}, 600);
|
170 |
}, |
171 |
function () {
|
172 |
|
173 |
$(this).animate({top: '0'}, 600, function() { |
174 |
var src = $(this).find('img').attr('src').replace('_top.png', '.png') |
175 |
$(this).find('img').attr("src", src); |
176 |
}); |
177 |
$(this).siblings('p').find('img').animate({ |
178 |
width: '65%' |
179 |
},600);
|
180 |
} |
181 |
); |
182 |
|
183 |
|
184 |
|
185 |
|
186 |
$(function() { |
187 |
$( "#id_start_date" ).datepicker({ |
188 |
minDate: 0, |
189 |
defaultDate: "+0", |
190 |
dateFormat: "yy-mm-dd", |
191 |
onSelect: function( selectedDate ) { |
192 |
$( "#id_end_date" ).datepicker( "option", "minDate", selectedDate ); |
193 |
} |
194 |
}); |
195 |
|
196 |
$( "#id_end_date" ).datepicker({ |
197 |
defaultDate: "+3w", |
198 |
dateFormat: "yy-mm-dd", |
199 |
onSelect: function( selectedDate ) { |
200 |
$( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate ); |
201 |
} |
202 |
}); |
203 |
}); |
204 |
|
205 |
|
206 |
|
207 |
$('table .more-info').click(function(e){ |
208 |
e.preventDefault(); |
209 |
$(this).toggleClass('open'); |
210 |
if ($(this).hasClass('open')){ |
211 |
$(this).html('- less info ') |
212 |
} else {
|
213 |
$(this).html('+ more info ') |
214 |
} |
215 |
$(this).parents('tr').next('tr').toggle(); |
216 |
|
217 |
}); |
218 |
|
219 |
$('.projects .details .edit').click( function(e){ |
220 |
e.preventDefault(); |
221 |
$(this).parents('.details').children('.data').hide(); |
222 |
$(this).parents('.details').children('.editable').slideDown(500, 'linear'); |
223 |
$(this).hide(); |
224 |
}); |
225 |
|
226 |
$('.editable .form-row').each(function() { |
227 |
if ( $(this).hasClass('with-errors') ){ |
228 |
$('.editable').show(); |
229 |
$('.projects .details a.edit, .projects .details .data').hide(); |
230 |
|
231 |
} |
232 |
}); |
233 |
|
234 |
|
235 |
$("input.leave, input.join").click(function () { |
236 |
$('dialog').hide(); |
237 |
$(this).parents('.msg-wrap').find('.dialog').show(); |
238 |
return false; |
239 |
|
240 |
}); |
241 |
|
242 |
$('.msg-wrap .no').click( function(e){ |
243 |
e.preventDefault(); |
244 |
$(this).parents('.dialog').hide(); |
245 |
}) |
246 |
|
247 |
$('.msg-wrap .yes').click( function(e){ |
248 |
e.preventDefault(); |
249 |
$(this).parents('.dialog').siblings('form').submit(); |
250 |
}) |
251 |
|
252 |
$('.hidden-submit input[readonly!="True"]').focus(function () { |
253 |
$('.hidden-submit .form-row.submit').slideDown(500); |
254 |
}); |
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
setTimeout(function() {
|
262 |
if ($('input#id_username').val()){ |
263 |
$('input#id_username').siblings('label').css('opacity','0'); |
264 |
}; |
265 |
if ($('input#id_password').val()){ |
266 |
$('input#id_password').siblings('label').css('opacity','0'); |
267 |
} |
268 |
}, 100);
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
$('.landing-page .cms').hover( |
274 |
function () {
|
275 |
el = $('.cloudbar ul.services li').first(); |
276 |
var offset = el.offset();
|
277 |
positionX = offset.left; |
278 |
$('#hand').css('left',positionX); |
279 |
$('#hand').show(); |
280 |
}, |
281 |
function () {
|
282 |
$('#hand').hide(); |
283 |
|
284 |
}); |
285 |
|
286 |
$('.landing-page .pithos').hover( |
287 |
function () {
|
288 |
el = $('.cloudbar ul.services li:nth-child(3)'); |
289 |
var offset = el.offset();
|
290 |
positionX = offset.left; |
291 |
left = parseInt(positionX) +20;
|
292 |
$('#hand').css('left',left+'px'); |
293 |
$('#hand').show(); |
294 |
}, |
295 |
function () {
|
296 |
$('#hand').hide(); |
297 |
|
298 |
}); |
299 |
|
300 |
$('.landing-page .cyclades').hover( |
301 |
function () {
|
302 |
el = $('.cloudbar ul.services li:nth-child(2)').first(); |
303 |
var offset = el.offset();
|
304 |
positionX = offset.left; |
305 |
left = parseInt(positionX) +20;
|
306 |
$('#hand').css('left',left+'px'); |
307 |
$('#hand').show(); |
308 |
}, |
309 |
function () {
|
310 |
$('#hand').hide(); |
311 |
|
312 |
}); |
313 |
|
314 |
|
315 |
$('.landing-page .dashboard').hover( |
316 |
function () {
|
317 |
el = $('.cloudbar .profile'); |
318 |
var offset = el.offset();
|
319 |
positionX = offset.left +50;
|
320 |
$('#hand').css('left',positionX); |
321 |
$('#hand').show(); |
322 |
}, |
323 |
function () {
|
324 |
$('#hand').hide(); |
325 |
|
326 |
}); |
327 |
|
328 |
$('.pagination a.disabled').click(function(e){ |
329 |
e.preventDefault(); |
330 |
}); |
331 |
|
332 |
// fix for recaptcha fields
|
333 |
$('#okeanos_recaptcha').parents('.form-row').find('.extra-img').hide(); |
334 |
|
335 |
fixEl = $('.details .lt'); |
336 |
if (fixEl.length){ window.fixEloffsetTop = fixEl.offset().top;}
|
337 |
|
338 |
|
339 |
$(".stats-block li em").equalHeights(); |
340 |
|
341 |
|
342 |
}); |
343 |
|
344 |
$(window).resize(function() { |
345 |
|
346 |
setContainerMinHeight('.container .wrapper');
|
347 |
|
348 |
|
349 |
}); |
350 |
|
351 |
|
352 |
/* js for fixed faq/userguide side nav */
|
353 |
$(window).scroll(function () { |
354 |
|
355 |
if ( $('.details .lt').height() < $('.details .rt').height() ) { |
356 |
if ($(window).scrollTop() > window.fixEloffsetTop){ |
357 |
fixEl.addClass('fixed');
|
358 |
} else {
|
359 |
fixEl.removeClass('fixed');
|
360 |
} |
361 |
} |
362 |
|
363 |
|
364 |
|
365 |
}); |