From 426635428f2dd5e0df96525b168f9bd3047f1976 Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 18 Jul 2014 12:44:46 +0200 Subject: [PATCH] Added weeknumbers as optional feature --- jquery.datetimepicker.css | 6 ++++++ jquery.datetimepicker.js | 23 +++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/jquery.datetimepicker.css b/jquery.datetimepicker.css index baa7640..e99412a 100644 --- a/jquery.datetimepicker.css +++ b/jquery.datetimepicker.css @@ -64,6 +64,9 @@ float:left; margin-left:8px; } +.xdsoft_datetimepicker.xdsoft_showweeks .xdsoft_datepicker{ + width: 256px; +} .xdsoft_datetimepicker .xdsoft_timepicker{ width: 58px; float:left; @@ -233,6 +236,9 @@ cursor:pointer; height: 25px; } +.xdsoft_datetimepicker.xdsoft_showweeks .xdsoft_calendar td,.xdsoft_datetimepicker.xdsoft_showweeks .xdsoft_calendar th{ + width:12.5%; +} .xdsoft_datetimepicker .xdsoft_calendar th{ background: #F1F1F1; } diff --git a/jquery.datetimepicker.js b/jquery.datetimepicker.js index b5a2d4b..16ebdf6 100644 --- a/jquery.datetimepicker.js +++ b/jquery.datetimepicker.js @@ -217,6 +217,7 @@ timepicker:true, datepicker:true, + weeks:false, defaultTime:false, // use formatTime format (ex. '10:00' for formatTime: 'H:i') defaultDate:false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05') @@ -440,7 +441,7 @@ createDateTimePicker = function( input ) { - var datetimepicker = $('
'), + var datetimepicker = $('
'), xdsoft_copyright = $(''), datepicker = $('
'), mounth_picker = $('
'), @@ -939,13 +940,17 @@ //generate calendar table+=''; + if(options.weeks) { + table+=''; + } + // days for(var j = 0; j<7; j++) { table+=''; } table+=''; - table+=''; + table+=''; var maxDate = false, minDate = false; if( options.maxDate!==false ) { @@ -958,13 +963,13 @@ minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate()); } - var d,y,m,classes = [],customDateSettings; + var d,y,m,w,classes = [],customDateSettings,newRow=true; while( i<_xdsoft_datetime.currentTime.countDaysInMonth()||start.getDay()!=options.dayOfWeekStart||_xdsoft_datetime.currentTime.getMonth()==start.getMonth() ) { classes = []; i++; - d = start.getDate(); y = start.getFullYear(); m = start.getMonth(); + d = start.getDate(); y = start.getFullYear(); m = start.getMonth(); w = start.getWeekOfYear(); classes.push('xdsoft_date'); @@ -1000,12 +1005,22 @@ classes.push(options.beforeShowDay(start)) } + if(newRow) { + table+=''; + newRow = false; + + if(options.weeks) { + table+=''; + } + } + table+=''; if( start.getDay()==options.dayOfWeekStartPrev ) { table+=''; + newRow = true; } start.setDate(d+1);
'+options.i18n[options.lang].dayOfWeek[(j+options.dayOfWeekStart)>6?0:j+options.dayOfWeekStart]+'
'+w+''+ '
'+d+'
'+ '