From 7e692945cf61cb3c489e12ed037c4d2ff7f25ba1 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 24 Feb 2015 16:56:49 +0000 Subject: [PATCH] Avoid collision between datepicker calendar dialog and date input field, try to use left or right free spaces --- etemplate/js/et2_widget_date.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/etemplate/js/et2_widget_date.js b/etemplate/js/et2_widget_date.js index 97a4eeee93..1d82175c1f 100644 --- a/etemplate/js/et2_widget_date.js +++ b/etemplate/js/et2_widget_date.js @@ -91,6 +91,28 @@ var et2_date = et2_inputWidget.extend( this.input_date.addClass("et2_time"); this.egw().time(this.input_date); } + + // Avoid collision of datepicker dialog with input field + this.input_date.datepicker('option', 'beforeShow', function(input, inst){ + var cal = inst.dpDiv; + setTimeout(function () { + var $input = jQuery(input); + var inputOffset = $input.offset(); + // position the datepicker in freespace zone + // avoid datepicker calendar collision with input field + if (cal.height() + inputOffset.top > window.innerHeight) + { + cal.position({ + my: "left center", + at: 'right bottom', + collision: 'flip fit', + of: input, + }); + } + + },0); + }); + // Update internal value when changed var self = this; this.input_date.bind('change', function(e){