mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
new version 1.0.7
1) Add destroy method 2) $('#datetimepicker6').datetimepicker('destroy'); also fixed bug with resize window 3) fixed bug when datetimepicker overflow window
This commit is contained in:
parent
641110cde0
commit
efec312e79
@ -11,7 +11,7 @@
|
||||
"timepicker",
|
||||
"datetimepicker"
|
||||
],
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.8",
|
||||
"author": {
|
||||
"name": "Chupurnov Valeriy",
|
||||
"url": "http://xdsoft.net/contacts.html"
|
||||
|
12
index.html
12
index.html
@ -13,6 +13,8 @@
|
||||
<input type="text" id="datetimepicker4"/><input id="open" type="button" value="open"/><input id="close" type="button" value="close"/>
|
||||
<h3>TimePicker allows time</h3>
|
||||
<input type="text" id="datetimepicker5"/><br><br>
|
||||
<h3>Destroy DateTimePicker</h3>
|
||||
<input type="text" id="datetimepicker6"/><input id="destroy" type="button" value="destroy"/>
|
||||
</body>
|
||||
<script src="jquery.js"></script>
|
||||
<script src="jquery.datetimepicker.js"></script>
|
||||
@ -43,5 +45,15 @@ $('#datetimepicker5').datetimepicker({
|
||||
datepicker:false,
|
||||
allowTimes:['12:00','13:00','15:00','17:00','17:05','17:20','19:00','20:00'],
|
||||
});
|
||||
$('#datetimepicker6').datetimepicker();
|
||||
$('#destroy').click(function(){
|
||||
if( $('#datetimepicker6').data('xdsoft_datetimepicker') ){
|
||||
$('#datetimepicker6').datetimepicker('destroy');
|
||||
this.value = 'create';
|
||||
}else{
|
||||
$('#datetimepicker6').datetimepicker();
|
||||
this.value = 'destroy';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/**
|
||||
* @preserve jQuery DateTimePicker plugin v1.0.6
|
||||
* @preserve jQuery DateTimePicker plugin v1.0.7
|
||||
* @homepage http://xdsoft.net/jqplugins/datetimepicker/
|
||||
* (c) 2013, Chupurnov Valeriy.
|
||||
*/
|
||||
(function( $ ){
|
||||
@ -59,7 +60,7 @@
|
||||
onSelectDate:function(){},
|
||||
onSelectTime:function(){},
|
||||
onChangeMonth:function(){},
|
||||
onChangeTime:function(){},
|
||||
onChangeDateTime:function(){},
|
||||
onShow:function(){},
|
||||
onClose:function(){},
|
||||
withoutCopyright:true,
|
||||
@ -276,7 +277,7 @@
|
||||
timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px')
|
||||
}
|
||||
datetimepicker.trigger('scroll.timebox',[Math.abs(parseInt(timebox.css('marginTop')))]);
|
||||
options.onChangeTime&&options.onChangeTime.call&&options.onChangeTime.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
|
||||
//options.onChangeDateTime&&options.onChangeDateTime.call&&options.onChangeDateTime.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
|
||||
period= ( period>10 )?10:period-10;
|
||||
!stop&&(timer = setTimeout(arguments.callee,v?v:period));
|
||||
})(500);
|
||||
@ -379,6 +380,7 @@
|
||||
datetimepicker.close();
|
||||
options.onSelectDate&&options.onSelectDate.call&&options.onSelectDate.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
|
||||
datetimepicker.trigger('change.xdsoft');
|
||||
datetimepicker.trigger('changedatetime.xdsoft');
|
||||
});
|
||||
timebox.on( 'mousedown','div',function(){
|
||||
if($(this).hasClass('xdsoft_disabled'))
|
||||
@ -391,6 +393,7 @@
|
||||
!options.inline&&datetimepicker.close();
|
||||
options.onSelectTime&&options.onSelectTime.call&&options.onSelectTime.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
|
||||
datetimepicker.trigger('change.xdsoft');
|
||||
datetimepicker.trigger('changedatetime.xdsoft');
|
||||
});
|
||||
datetimepicker.mousewheel&&datepicker.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
if( !options.scrollMonth )
|
||||
@ -416,9 +419,11 @@
|
||||
fl = false;
|
||||
}
|
||||
datetimepicker.trigger('scroll.timebox',[Math.abs(parseInt(timebox.css('marginTop')))]);
|
||||
options.onChangeTime&&options.onChangeTime.call&&options.onChangeTime.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
|
||||
return fl;
|
||||
});
|
||||
datetimepicker.on('changedatetime.xdsoft',function(){
|
||||
options.onChangeDateTime&&options.onChangeDateTime.call&&options.onChangeDateTime.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
|
||||
});
|
||||
var current_time_index = 0;
|
||||
input.mousewheel&&input.mousewheel(function( event, delta, deltaX, deltaY ){
|
||||
if( !options.scrollInput )
|
||||
@ -432,6 +437,7 @@
|
||||
}else if( options.datepicker && !options.timepicker ){
|
||||
datepicker.trigger( event, [delta, deltaX, deltaY]);
|
||||
input.val&&input.val( datetimepicker.data('xdsoft_datetime').str() );
|
||||
datetimepicker.trigger('changedatetime.xdsoft');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -439,13 +445,21 @@
|
||||
var onShow = true;
|
||||
options.onShow&&options.onShow.call&&(onShow=options.onShow.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input')));
|
||||
if( onShow!==false ){
|
||||
var offset = datetimepicker.data('input').offset();
|
||||
datetimepicker.css({
|
||||
left:offset.left,
|
||||
top:offset.top+datetimepicker.data('input')[0].offsetHeight,
|
||||
}).show();
|
||||
var setPos = function(){
|
||||
var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight;
|
||||
if( top+datetimepicker[0].offsetHeight>$('body').height() )
|
||||
top = offset.top-datetimepicker[0].offsetHeight;
|
||||
datetimepicker.css({
|
||||
left:offset.left,
|
||||
top:top,
|
||||
});
|
||||
};
|
||||
datetimepicker.show();
|
||||
setPos();
|
||||
$(window).on('resize.xdsoft',setPos);
|
||||
|
||||
if( options.closeOnWithoutClick ){
|
||||
$(window).on('mousedown keydown',function(){
|
||||
$(window).on('mousedown.xdsoft keydown.xdsoft',function(){
|
||||
datetimepicker.close();
|
||||
$(this).off('mousedown',arguments.callee);
|
||||
});
|
||||
@ -467,7 +481,7 @@
|
||||
datetimepicker.setOptions(options);
|
||||
_xdsoft_datetime.setCurrentTime( options.value?options.value:(input&&input.val&&input.val())?input.val():new Date );
|
||||
input.data( 'xdsoft_datetimepicker',datetimepicker )
|
||||
.on('enter keyup mousedown open.xdsoft',function(event){
|
||||
.on('enter.xdsoft keyup.xdsoft mousedown.xdsoft open.xdsoft',function(event){
|
||||
if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible') )
|
||||
return;
|
||||
clearTimeout(timer);
|
||||
@ -481,6 +495,21 @@
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
var destroyDateTimePicker = function(input){
|
||||
var datetimepicker = input.data('xdsoft_datetimepicker');
|
||||
if( datetimepicker ){
|
||||
var _xdsoft_datetime = datetimepicker.data('xdsoft_datetime');
|
||||
delete _xdsoft_datetime;
|
||||
datetimepicker.remove();
|
||||
delete datetimepicker;
|
||||
input.data( 'xdsoft_datetimepicker',null );
|
||||
input.off( 'enter.xdsoft keyup.xdsoft mousedown.xdsoft open.xdsoft' );
|
||||
$(window).off('resize.xdsoft');
|
||||
$(window).off('mousedown.xdsoft keydown.xdsoft');
|
||||
input.unmousewheel&&input.unmousewheel();
|
||||
delete options;
|
||||
}
|
||||
};
|
||||
return this.each(function(){
|
||||
var datetimepicker;
|
||||
@ -494,13 +523,16 @@
|
||||
case 'hide':
|
||||
datetimepicker.close();
|
||||
break;
|
||||
case 'destroy':
|
||||
destroyDateTimePicker($(this));
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
$(this).data('xdsoft_datetimepicker').setOptions(options);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
createDateTimePicker($(this));
|
||||
}else
|
||||
($.type(opt) !== 'string')&&createDateTimePicker($(this));
|
||||
});
|
||||
};
|
||||
})( jQuery );
|
||||
|
BIN
screen/3.1.png
Normal file
BIN
screen/3.1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
screen/3.png
BIN
screen/3.png
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in New Issue
Block a user