/* InfCloud - the open source CalDAV/CardDAV Web Client Copyright (C) 2011-2015 Jan Mate Andrej Lezo Matej Mihalik This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ function updateTodoFormDimensions(setHeight) { $('#CATodo').css('width',''); $('#CATodo').css('width',$('#todo_details_template').css('width')); if(setHeight) { $('#CATodo').css('height',''); $('#CATodo').css('height',$('#todo_details_template').css('height')); } } function dragOverHandler(event) { //if (window.console) { // console.log("dragOverHandler",event); //} event.preventDefault(); event.stopPropagation(); } /* Incomplete import process. The function logs to console but does not use the vcard contents. */ function dropHandler(event) { if (event) { event.preventDefault(); event.stopPropagation(); if (window.console) { console.log("dropHandler",event); } if(event.dataTransfer && event.dataTransfer && event.dataTransfer.files.length > 0) { if(window.console){console.log("files",event.dataTransfer.files);} for (let f of event.dataTransfer.files) { if(window.console){console.log("file:",f)}; let reader = new FileReader(); reader.readAsText(f); reader.onload = function(){if(window.console){console.log(reader.result)}}; reader.onerror = function(){if(window.console){console.log(reader.error)}}; } } } } function updateEventFormDimensions(setHeight) { $('#CAEvent').css('width',''); $('#CAEvent').css('width',$('#event_details_template').css('width')); if(setHeight) { $('#CAEvent').css('height',''); $('#CAEvent').css('height',$('#event_details_template').css('height')); } } function setFormPosition(jsEvent, confirmRepeat) { var position_x, position_y, dist_x, dist_y; $('#event_details_template').css('max-height',''); document.getElementById('uploadButton').addEventListener("drop", dropHandler(event)); if(jsEvent) { if(jsEvent.pageX<=($('#main').width()/2)) { position_v='left'; dist_x=jsEvent.pageX; } else { position_v='right'; dist_x=$('body').width()-jsEvent.pageX; } /*if(jsEvent.pageY<=($('#main').height()/2)) { position_h='top'; dist_y=jsEvent.pageY; } else { position_h='top'; dist_y=jsEvent.pageY-$('#event_details_template').height(); }*/ position_h='top'; dist_y=Math.max(29, jsEvent.pageY-(confirmRepeat ? $('#CAEvent').height() : $('#event_details_template').height())); } else { position_v='right'; position_h='top'; dist_x=25; dist_y=29; } $('#CAEvent').css('left',''); $('#CAEvent').css('right',''); $('#CAEvent').css('top',''); $('#CAEvent').css('bottom',''); $('#CAEvent').css(position_v, dist_x); $('#CAEvent').css(position_h, dist_y); $('#event_details_template').css('max-height', $('#main').height()-dist_y+20+'px'); $('#CAEvent').css('max-height', $('#main').height()-dist_y+20+'px'); } function setTodoPosition(jsEvent) { var dist, pointY=0; $('#todo_details_template').css('max-height',''); $('#CATodo').css('max-height',''); if(jsEvent!=undefined) { if(jsEvent.pageY!=undefined) pointY=jsEvent.pageY; else pointY=jsEvent.clientY; } if(jsEvent) { /*if((pointY)+$('#todo_details_template').height()<$(window).height()) dist=jsEvent.pageY; else dist=pointY-$('#todo_details_template').height();*/ dist=Math.max(25, jsEvent.pageY-$('#todo_details_template').height()); } else dist=25; $('#CATodo').css('left',''); $('#CATodo').css('right',''); $('#CATodo').css('top',''); $('#CATodo').css('bottom',''); $('#CATodo').css('top', dist); $('#todo_details_template').css('right', 0); $('#CATodo').css('right', 25); $('#todo_details_template').css('max-height', $('#main').height()-dist+20+'px'); $('#CATodo').css('max-height', $('#main').height()-dist+20+'px'); } function showTimezones(selTimezone, todoSelector) { if(!globalSettings.timezonesupport.value) return false; var select=$('#timezone'+todoSelector); select.empty(); var isFirst=false; for(var izone in timezoneKeys) { if(timeZonesEnabled.indexOf(timezoneKeys[izone])==-1) continue; if(!isNaN(izone)) { var tmp=null; if(!isFirst) { tmp=$('