new version 2.0.8

To add a class weekends xdsoft_weekend (Sunday, Saturday)
and Added options options.weekends
This commit is contained in:
Valeriy 2013-12-16 09:51:07 +06:00
parent bf8b1f5ec3
commit 887c934142
3 changed files with 172 additions and 140 deletions

View File

@ -20,7 +20,7 @@
"jquery",
"touch"
],
"version": "2.0.7",
"version": "2.0.8",
"author": {
"name": "Chupurnov Valeriy",
"email": "chupurnov@gmail.com",

View File

@ -27,6 +27,8 @@
<p>If select day is Saturday, the minimum set 11:00, otherwise 8:00</p>
<h3>onGenerate</h3>
<input type="text" id="datetimepicker8"/>
<h3>disable all weekend</h3>
<input type="text" id="datetimepicker9"/>
</body>
<script src="./jquery.js"></script>
<script src="./jquery.datetimepicker.js"></script>
@ -95,5 +97,13 @@ $('#datetimepicker8').datetimepicker({
maxDate:'+1970/01/2',
timepicker:false
});
$('#datetimepicker9').datetimepicker({
onGenerate:function( ct ){
$(this).find('.xdsoft_date.xdsoft_weekend')
.addClass('xdsoft_disabled');
},
weekends:['01.01.2014','02.01.2014','03.01.2014','04.01.2014','05.01.2014','06.01.2014'],
timepicker:false
});
</script>
</html>

View File

@ -1,5 +1,5 @@
/**
* @preserve jQuery DateTimePicker plugin v2.0.7
* @preserve jQuery DateTimePicker plugin v2.0.8
* @homepage http://xdsoft.net/jqplugins/datetimepicker/
* (c) 2013, Chupurnov Valeriy.
*/
@ -205,7 +205,8 @@
style:'',
id:'',
roundTime:'round', // ceil, floor
className:''
className:'',
weekends : []
},
options = ($.isPlainObject(opt)||!opt)?$.extend({},default_options,opt):$.extend({},default_options),
createDateTimePicker = function( input ) {
@ -617,22 +618,41 @@
minDate = _xdsoft_datetime.strtodate(options.minDate);
minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());
}
var d,y,m;
var d,y,m,classes = [];
while( i<_xdsoft_datetime.currentTime.getDaysInMonth()||start.getDay()!=options.dayOfWeekStart||_xdsoft_datetime.currentTime.getMonth()==start.getMonth() ) {
classes = [];
i++;
d = start.getDate(); y = start.getFullYear(); m = start.getMonth();
table+='<td data-date="'+d+'" data-month="'+m+'" data-year="'+y+'"'+
' class="xdsoft_date '+
(
(( maxDate!==false && start > maxDate )||
( minDate!==false && start < minDate ))
?'xdsoft_disabled ':' ')+
(_xdsoft_datetime.currentTime.getMonth()!=m?' xdsoft_other_month ':'')+
(_xdsoft_datetime.currentTime.dateFormat('d.m.Y')==start.dateFormat('d.m.Y')?' xdsoft_current ':'')+
(today.dateFormat('d.m.Y')==start.dateFormat('d.m.Y')?' xdsoft_today ':'')
+'"><div>'+d+'</div></td>';
if( start.getDay()==options.dayOfWeekStartPrev )
classes.push('xdsoft_date');
if( ( maxDate!==false && start > maxDate )||( minDate!==false && start < minDate ) ){
classes.push('xdsoft_disabled');
}
if( _xdsoft_datetime.currentTime.getMonth()!=m ) classes.push('xdsoft_other_month');
if( _xdsoft_datetime.currentTime.dateFormat('d.m.Y')==start.dateFormat('d.m.Y') ) {
classes.push('xdsoft_current');
}
if( today.dateFormat('d.m.Y')==start.dateFormat('d.m.Y') ) {
classes.push('xdsoft_today');
}
if( start.getDay()==0||start.getDay()==6||~options.weekends.indexOf(start.dateFormat('d.m.Y')) ) {
classes.push('xdsoft_weekend');
}
table+='<td data-date="'+d+'" data-month="'+m+'" data-year="'+y+'"'+' class="xdsoft_date '+ classes.join(' ')+'">'+
'<div>'+d+'</div>'+
'</td>';
if( start.getDay()==options.dayOfWeekStartPrev ) {
table+='</tr>';
}
start.setDate(d+1);
}
table+='</tbody></table>';
@ -664,6 +684,7 @@
((parseInt(today.getHours())==parseInt(h)&&parseInt(today.getMinutes())==parseInt(m))?' xdsoft_today ':'')+
'" data-hour="'+h+'" data-minute="'+m+'">'+now.dateFormat(options.formatTime)+'</div>';
};
if( !options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length ) {
for( var i=0,j=0;i<(options.hours12?12:24);i++ ) {
for( j=0;j<60;j+=options.step ) {
@ -679,6 +700,7 @@
line_time( h,m );
}
}
timebox.html(time);
var opt = '',