Revision cd9cdbaf cloudcms/static/cloudcms/js/common.js
b/cloudcms/static/cloudcms/js/common.js | ||
---|---|---|
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 | 1 |
function setContainerMinHeight( applicableDiv){ |
11 |
|
|
12 | 2 |
if ( $(applicableDiv).length > 0 ) { |
13 |
//var h = $('.header').height(); div.header is not found |
|
14 | 3 |
var f = $('.footer').height(); |
15 | 4 |
var w = $(window).height(); |
16 | 5 |
var pTop = parseInt (($(applicableDiv).css('padding-top').replace("px", "")) ); |
... | ... | |
20 | 9 |
} |
21 | 10 |
} |
22 | 11 |
|
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 | 12 |
//equal heights |
43 | 13 |
(function($) { |
44 | 14 |
$.fn.equalHeights = function(minHeight, maxHeight) { |
... | ... | |
55 | 25 |
} |
56 | 26 |
})(jQuery); |
57 | 27 |
|
58 |
|
|
59 |
|
|
60 | 28 |
// fix for iPhone - iPad orientation bug |
29 |
function isIpadIphone(){ |
|
30 |
var flag = false; |
|
31 |
var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone"); |
|
32 |
var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad"); |
|
33 |
if(isiPhone > -1) { flag = true; } |
|
34 |
if(isiPad > -1) { flag = true; } |
|
35 |
return flag; |
|
36 |
} |
|
37 |
|
|
61 | 38 |
var metas = document.getElementsByTagName('meta'); |
62 | 39 |
function resetViewport() { |
63 | 40 |
var i; |
... | ... | |
88 | 65 |
} |
89 | 66 |
//end of fix |
90 | 67 |
|
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 | 68 |
$(document).ready(function() { |
104 | 69 |
|
105 | 70 |
|
106 | 71 |
setContainerMinHeight('.container .wrapper'); |
107 |
tableFixedCols('my-projects', 25); |
|
108 | 72 |
|
109 | 73 |
$('.show-extra').click(function(e) { |
110 | 74 |
e.preventDefault(); |
... | ... | |
115 | 79 |
$(this).parents('.bg-wrap').find('.extra').slideUp(600); |
116 | 80 |
}); |
117 | 81 |
|
118 |
$('.box-more p').click(function(e) { |
|
119 |
$(this).siblings('.clearfix').toggle('slow'); |
|
120 |
$(this).parents('.box-more').toggleClass('border'); |
|
121 |
}); |
|
122 |
|
|
123 | 82 |
var fixTopMessageHeight = function() { |
124 | 83 |
var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom')); |
125 | 84 |
$('.mainlogo').css('marginTop','-'+topMargin+'px'); |
... | ... | |
149 | 108 |
}); |
150 | 109 |
}); |
151 | 110 |
|
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 | 111 |
$('.top-msg .success').parents('.top-msg').addClass('success'); |
161 | 112 |
$('.top-msg .error').parents('.top-msg').addClass('error'); |
162 | 113 |
$('.top-msg .warning').parents('.top-msg').addClass('warning'); |
... | ... | |
188 | 139 |
} |
189 | 140 |
); |
190 | 141 |
|
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 | 142 |
fixEl = $('.details .lt'); |
323 | 143 |
if (fixEl.length){ window.fixEloffsetTop = fixEl.offset().top;} |
324 | 144 |
|
... | ... | |
329 | 149 |
$(window).resize(function() { |
330 | 150 |
setContainerMinHeight('.container .wrapper'); |
331 | 151 |
$(".stats-block li em").equalHeights(); |
152 |
$(window).scroll(function () { |
|
153 |
setFixedLtBar(); |
|
154 |
}); |
|
332 | 155 |
}); |
333 | 156 |
|
334 | 157 |
/* js for fixed faq/userguide side nav */ |
335 | 158 |
$(window).scroll(function () { |
336 |
setFixedLtBar(); |
|
159 |
var diff = ( $(window).height() - $('.footer').outerHeight() ) - $('.details .lt').height(); |
|
160 |
if ( $('.details .lt').height() < $('.details .rt').height() ) { |
|
161 |
if ( ($(window).scrollTop() > window.fixEloffsetTop) && diff>0 ) { |
|
162 |
fixEl.addClass('fixed'); |
|
163 |
} else { |
|
164 |
fixEl.removeClass('fixed'); |
|
165 |
} |
|
166 |
} |
|
337 | 167 |
}); |
Also available in: Unified diff