From ebdd3403ba4aaf91db5a6b97d489d1e37e652b52 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Thu, 28 Jul 2016 15:06:46 -0400 Subject: [PATCH] testing new function for centering datepicker in mobile view for off canvas booking widget --- js/app.js | 30 ++++++++++++++++++++---------- js/custom/pageSetup.js | 30 ++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/js/app.js b/js/app.js index edb9b75..43b3165 100644 --- a/js/app.js +++ b/js/app.js @@ -66,25 +66,35 @@ $(document).ready(function () { // } // } // }); + var off_canvas_arrival = $(".right-off-canvas-menu").find("#start-date"); var off_canvas_departure = $(".right-off-canvas-menu").find("#end-date"); $(off_canvas_arrival).removeClass("date-pick").removeAttr("onclick").removeAttr("value"); - $(off_canvas_departure).removeClass("date-pick").removeAttr("onclick").removeAttr("value"); - + $(off_canvas_departure).removeClass("date-pick").removeAttr("onclick").removeAttr("value"); + $(off_canvas_arrival).datepicker({ + minDate: 0, - beforeShow: function(input, inst) - { - inst.dpDiv.css({marginTop: -input.offsetHeight + 'px', marginLeft: '-20px'}); - } + beforeShow: function (input, inst) { + setTimeout(function () { + inst.dpDiv.css({ + top: 100, + left: 15 + }); + }, 0); + } }); $(off_canvas_departure).datepicker({ - beforeShow: function(input, inst) - { - inst.dpDiv.css({marginTop: '-10px', marginLeft: '-20px'}); - } + beforeShow: function (input, inst) { + setTimeout(function () { + inst.dpDiv.css({ + top: 100, + left: 15 + }); + }, 0); + } }); $(off_canvas_arrival).change( function () { diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index d3dd73c..6193d90 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -57,25 +57,35 @@ $(document).ready(function () { // } // } // }); + var off_canvas_arrival = $(".right-off-canvas-menu").find("#start-date"); var off_canvas_departure = $(".right-off-canvas-menu").find("#end-date"); $(off_canvas_arrival).removeClass("date-pick").removeAttr("onclick").removeAttr("value"); - $(off_canvas_departure).removeClass("date-pick").removeAttr("onclick").removeAttr("value"); - + $(off_canvas_departure).removeClass("date-pick").removeAttr("onclick").removeAttr("value"); + $(off_canvas_arrival).datepicker({ + minDate: 0, - beforeShow: function(input, inst) - { - inst.dpDiv.css({marginTop: -input.offsetHeight + 'px', marginLeft: '-20px'}); - } + beforeShow: function (input, inst) { + setTimeout(function () { + inst.dpDiv.css({ + top: 100, + left: 15 + }); + }, 0); + } }); $(off_canvas_departure).datepicker({ - beforeShow: function(input, inst) - { - inst.dpDiv.css({marginTop: '-10px', marginLeft: '-20px'}); - } + beforeShow: function (input, inst) { + setTimeout(function () { + inst.dpDiv.css({ + top: 100, + left: 15 + }); + }, 0); + } }); $(off_canvas_arrival).change( function () { -- 2.17.1