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