New version

Add method show and hide
$('#datetimepicker4').datetimepicker('show');
$('#datetimepicker4').datetimepicker('hide');
This commit is contained in:
Valeriy 2013-11-07 10:24:58 +06:00
parent 7bb28f1ded
commit 161800fe89
2 changed files with 34 additions and 8 deletions

View File

@ -1,10 +1,16 @@
<html>
<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/>
<body>
<input type="text" value="2014/03/15 05:06" id="datetimepicker"/>
<input type="text" id="datetimepicker1"/>
<input type="text" id="datetimepicker2"/>
<input type="text" id="datetimepicker3"/>
<h3>DateTimePicker</h3>
<input type="text" value="2014/03/15 05:06" id="datetimepicker"/><br><br>
<h3>TimePicker</h3>
<input type="text" id="datetimepicker1"/><br><br>
<h3>DatePicker</h3>
<input type="text" id="datetimepicker2"/><br><br>
<h3>Inline DateTimePicker</h3>
<input type="text" id="datetimepicker3"/><br><br>
<h3>Button Trigger</h3>
<input type="text" id="datetimepicker4"/><input id="open" type="button" value="open"/><input id="close" type="button" value="close"/>
</body>
<script src="jquery.js"></script>
<script src="jquery.datetimepicker.js"></script>
@ -23,5 +29,12 @@ $('#datetimepicker2').datetimepicker({
$('#datetimepicker3').datetimepicker({
inline:true,
});
$('#datetimepicker4').datetimepicker();
$('#open').click(function(){
$('#datetimepicker4').datetimepicker('show');
});
$('#close').click(function(){
$('#datetimepicker4').datetimepicker('hide');
});
</script>
</html>

View File

@ -1,5 +1,5 @@
/**
* @preserve jQuery DateTimePicker plugin v1.0.1
* @preserve jQuery DateTimePicker plugin v1.0.3
* (c) 2013, Chupurnov Valeriy.
*/
(function( $ ){
@ -62,7 +62,7 @@
dayOfWeekStart:0,
timeHeightInTimePicker:25,
};
var options = $.extend({},default_options,opt);
var options = ($.isPlainObject(opt)||!opt)?$.extend({},default_options,opt):$.extend({},default_options);
var createDateTimePicker = function( input ){
var datetimepicker = $('<div class="xdsoft_datetimepicker"></div>'),
xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
@ -395,8 +395,21 @@
};
return this.each(function(){
if( $(this).data('xdsoft_datetimepicker') ){
$(this).data('xdsoft_datetimepicker').setOptions(options);
var datetimepicker;
if( datetimepicker = $(this).data('xdsoft_datetimepicker') ){
//$(this).data('xdsoft_datetimepicker').setOptions(options);
if( $.type(opt) === 'string' ){
switch(opt){
case 'show':
datetimepicker.open();
break;
case 'hide':
datetimepicker.close();
break;
}
}else{
$(this).data('xdsoft_datetimepicker').setOptions(options);
}
return 0;
}
createDateTimePicker($(this));