replace table height calculation by plain javascript

This commit is contained in:
Milan
2020-04-26 23:23:12 +02:00
parent d3fe389af3
commit 5e5e36ba22

View File

@@ -8,9 +8,6 @@ function openNewTab(url){
window.open(url, '_blank'); window.open(url, '_blank');
} }
var effect=null;
var effect_duration=null;
function selectCheckbox(selector){ function selectCheckbox(selector){
$(selector).each(function(){ $(selector).each(function(){
$(this).prop('checked', 'checked'); $(this).prop('checked', 'checked');
@@ -28,63 +25,51 @@ function isChecked(selector){
} }
function cancel_edit_event(){ function cancel_edit_event(){
$('#calendar').show(effect,null,effect_duration); $('#calendar').show();
$('#calendar_weekdays').show(effect,null,effect_duration); $('#calendar_weekdays').show();
$('#event_editor').hide(effect,null,effect_duration); $('#event_editor').hide();
resizeCalendarMenu(); resizeCalendarMenu();
return false; return false;
} }
function setupMenuHeight(){ function setupMenuHeight(){
if ($('#calendar').length>0){ if ($('#calendar').length>0){
// calendar table
console.log('setupMenuHeight')
var top=$('#calcms_nav').height(); var top=$('#calcms_nav').height();
$('#toolbar').css("top", top); $('#toolbar').css("top", top);
$('#toolbar').css("position", "absolute"); $('#toolbar').css("position", "absolute");
top+=$('#toolbar').height()+2; top+=$('#toolbar').height()+2;
var weekdays = document.querySelector("#calendar_weekdays");
$('#calendar_weekdays').css("top", top); $('#calendar_weekdays').css("top", top);
var weekday_height=30; var weekday_height=30;
$('#calendar_weekdays table td div').each( weekdays.querySelectorAll("table td div").forEach(
function(){ function(div) {
var height=$(this).height()+14; var height = div.offsetHeight + 14;
if (height>weekday_height) weekday_height=height; if (height>weekday_height) weekday_height=height;
} }
); );
top+=weekday_height+1; top+=weekday_height+1;
$('#calendar').css("top", top); $('#calendar').css("top", top);
return top; return top;
} else { } else {
var top = $('#calcms_nav').height(); var top = $('#calcms_nav').height();
$('#content').css("top", top); $('#content').css("top", top);
top = $('#calcms_nav').height();
$('#content').css("top", top);
return top; return top;
} }
} }
function hideCalendar(){
$('#calendar').css("display","none");
$('#calendar_weekdays').css("visibility","hidden");
}
function showCalendar(){
$('#calendar').show();
$('#calendar_weekdays').css("visibility","visible");
}
function resizeCalendarMenu(){ function resizeCalendarMenu(){
hideCalendar(); $('#calendar').hide();
$('#calendar_weekdays').css("visibility","hidden");
//after getting menu heigth, hide calendar again //after getting menu heigth, hide calendar again
var menuHeight=setupMenuHeight(); var menuHeight = setupMenuHeight();
var width= $(window).width()-0; var width = $(window).width()-0;
var height= $(window).height()-menuHeight; var height = $(window).height()-menuHeight;
if($('#calendar').css('display')=='none'){ if($('#calendar').css('display')=='none'){
$('body #content').css('max-width', '960'); $('body #content').css('max-width', '960');
@@ -121,7 +106,8 @@ function resizeCalendarMenu(){
var with_param='width'; var with_param='width';
var cw=cell_width.toFixed(); var cw=cell_width.toFixed();
showCalendar(); $('#calendar').show();
$('#calendar_weekdays').css("visibility","visible");
} }