From 2ed0c5478fd9855283818a0647bd114d37066992 Mon Sep 17 00:00:00 2001 From: Valeriy Date: Tue, 26 Nov 2013 13:28:31 +0600 Subject: [PATCH] New Version 1.0.9 minDate and maxDate can now be specified as -1970/01/02 and 1970/01/02 respectively --- datetimepicker.jquery.json | 4 ++-- index.html | 4 +++- jquery.datetimepicker.js | 13 ++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/datetimepicker.jquery.json b/datetimepicker.jquery.json index f0605da..8a66cfe 100644 --- a/datetimepicker.jquery.json +++ b/datetimepicker.jquery.json @@ -11,7 +11,7 @@ "timepicker", "datetimepicker" ], - "version": "1.0.8", + "version": "1.0.9", "author": { "name": "Chupurnov Valeriy", "url": "http://xdsoft.net/contacts.html" @@ -27,6 +27,6 @@ "docs": "http://xdsoft.net/jqplugins/datetimepicker/", "download": "https://github.com/xdan/datetimepicker/archive/master.zip", "dependencies": { - "jquery": ">=1.5" + "jquery": ">=1.7" } } \ No newline at end of file diff --git a/index.html b/index.html index 4480e37..7394912 100644 --- a/index.html +++ b/index.html @@ -29,7 +29,9 @@ $('#datetimepicker1').datetimepicker({ $('#datetimepicker2').datetimepicker({ timepicker:false, format:'d/m/Y', - minDate:0, + formatDate:'Y/m/d', + minDate:'-1970/01/02', // yesterday is minimum date + maxDate:'+1970/01/02', // and tommorow is maximum date calendar }); $('#datetimepicker3').datetimepicker({ inline:true, diff --git a/jquery.datetimepicker.js b/jquery.datetimepicker.js index 85e864f..8e8c4f5 100644 --- a/jquery.datetimepicker.js +++ b/jquery.datetimepicker.js @@ -1,5 +1,5 @@ /** - * @preserve jQuery DateTimePicker plugin v1.0.8 + * @preserve jQuery DateTimePicker plugin v1.0.9 * @homepage http://xdsoft.net/jqplugins/datetimepicker/ * (c) 2013, Chupurnov Valeriy. */ @@ -114,6 +114,13 @@ options.dayOfWeekStart = parseInt(options.dayOfWeekStart); if( !options.timepickerScrollbar ) scrollbar.hide(); + var tmpDate = []; + if( options.minDate && ( tmpDate = /^-(.*)$/.exec(options.minDate) ) && (tmpDate=Date.parseDate(tmpDate[1], options.formatDate)) ){ + options.minDate = new Date((new Date).getTime()-tmpDate.getTime()).dateFormat( options.formatDate ); + } + if( options.maxDate && ( tmpDate = /^\+(.*)$/.exec(options.maxDate) ) && (tmpDate=Date.parseDate(tmpDate[1], options.formatDate)) ){ + options.maxDate = new Date((new Date).getTime()+tmpDate.getTime()).dateFormat( options.formatDate ); + } options.dayOfWeekStartPrev = (options.dayOfWeekStart==0)?6:options.dayOfWeekStart-1; }; datetimepicker.data('options',options); @@ -446,9 +453,9 @@ options.onShow&&options.onShow.call&&(onShow=options.onShow.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'))); if( onShow!==false ){ var setPos = function(){ - var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight; + var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight-1; if( top+datetimepicker[0].offsetHeight>$('body').height() ) - top = offset.top-datetimepicker[0].offsetHeight; + top = offset.top-datetimepicker[0].offsetHeight+1; datetimepicker.css({ left:offset.left, top:top,