Skip to content

Fixed errors when call public methods from input without datepicker instance #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions jquery-ui-timepicker-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,19 +1107,23 @@ $.datepicker._gotoToday = function(id) {
//#######################################################################################
// Disable & enable the Time in the datetimepicker
//#######################################################################################
$.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
$.datepicker._disableTimepickerDatepicker = function(target) {
var inst = this._getInst(target);
if (!inst) return;

var tp_inst = this._get(inst, 'timepicker');
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
if (tp_inst) {
tp_inst._defaults.showTimepicker = false;
tp_inst._updateDateTime(inst);
}
};

$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
$.datepicker._enableTimepickerDatepicker = function(target) {
var inst = this._getInst(target)
if (!inst) return;

var tp_inst = this._get(inst, 'timepicker');
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
if (tp_inst) {
tp_inst._defaults.showTimepicker = true;
Expand Down Expand Up @@ -1168,9 +1172,11 @@ $.datepicker._setTime = function(inst, date) {
// Create new public method to set only time, callable as $().datepicker('setTime', date)
//#######################################################################################
$.datepicker._setTimeDatepicker = function(target, date, withDate) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');

var inst = this._getInst(target);
if (!inst) return;

var tp_inst = this._get(inst, 'timepicker');

if (tp_inst) {
this._setDateFromField(inst);
var tp_date;
Expand All @@ -1193,8 +1199,10 @@ $.datepicker._setTimeDatepicker = function(target, date, withDate) {
//#######################################################################################
$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
$.datepicker._setDateDatepicker = function(target, date) {
var inst = this._getInst(target),
tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
var inst = this._getInst(target);
if (!inst) return;

var tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;

this._updateDatepicker(inst);
this._base_setDateDatepicker.apply(this, arguments);
Expand All @@ -1206,8 +1214,10 @@ $.datepicker._setDateDatepicker = function(target, date) {
//#######################################################################################
$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
$.datepicker._getDateDatepicker = function(target, noDefault) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
var inst = this._getInst(target);
if (!inst) return;

var tp_inst = this._get(inst, 'timepicker');

if (tp_inst) {
this._setDateFromField(inst, noDefault);
Expand Down Expand Up @@ -1259,8 +1269,10 @@ $.datepicker._formatDate = function(inst, day, month, year){
//#######################################################################################
$.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
$.datepicker._optionDatepicker = function(target, name, value) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
var inst = this._getInst(target);
if (!inst) return null;

var tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
var min = null, max = null, onselect = null;
if (typeof name == 'string') { // if min/max was set with the string
Expand Down