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