Removed unneeded commas breaking IE and updated to vhochstein localization contributions
This commit is contained in:
parent
c9eb9eff5a
commit
1dd304b2f9
101
jquery-ui-timepicker-addon.js
vendored
101
jquery-ui-timepicker-addon.js
vendored
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* jQuery timepicker addon
|
* jQuery timepicker addon
|
||||||
* By: Trent Richardson [http://trentrichardson.com]
|
* By: Trent Richardson [http://trentrichardson.com]
|
||||||
* Version 0.6
|
* Version 0.6
|
||||||
* Last Modified: 9/1/2010
|
* Last Modified: 9/15/2010
|
||||||
*
|
*
|
||||||
* Copyright 2010 Trent Richardson
|
* Copyright 2010 Trent Richardson
|
||||||
* Dual licensed under the MIT and GPL licenses.
|
* Dual licensed under the MIT and GPL licenses.
|
||||||
|
@ -16,7 +16,35 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
function Timepicker() { }
|
function Timepicker(singleton) {
|
||||||
|
if(typeof(singleton) === 'boolean' && singleton == true) {
|
||||||
|
this.regional = []; // Available regional settings, indexed by language code
|
||||||
|
this.regional[''] = { // Default regional settings
|
||||||
|
ampm: false,
|
||||||
|
timeFormat: 'hh:mm tt'
|
||||||
|
};
|
||||||
|
this.defaults = { // Global defaults for all the datetime picker instances
|
||||||
|
holdDatepickerOpen: true,
|
||||||
|
showButtonPanel: true,
|
||||||
|
timeOnly: false,
|
||||||
|
showHour: true,
|
||||||
|
showMinute: true,
|
||||||
|
showSecond: false,
|
||||||
|
showTime: true,
|
||||||
|
stepHour: 0.05,
|
||||||
|
stepMinute: 0.05,
|
||||||
|
stepSecond: 0.05,
|
||||||
|
hour: 0,
|
||||||
|
minute: 0,
|
||||||
|
second: 0,
|
||||||
|
alwaysSetTime: true
|
||||||
|
};
|
||||||
|
$.extend(this.defaults, this.regional['']);
|
||||||
|
} else {
|
||||||
|
this.defaults = $.extend({}, $.timepicker.defaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Timepicker.prototype = {
|
Timepicker.prototype = {
|
||||||
$input: null,
|
$input: null,
|
||||||
|
@ -33,25 +61,6 @@
|
||||||
formattedTime: '',
|
formattedTime: '',
|
||||||
formattedDateTime: '',
|
formattedDateTime: '',
|
||||||
|
|
||||||
defaults: {
|
|
||||||
holdDatepickerOpen: true,
|
|
||||||
showButtonPanel: true,
|
|
||||||
timeOnly: false,
|
|
||||||
showHour: true,
|
|
||||||
showMinute: true,
|
|
||||||
showSecond: false,
|
|
||||||
showTime: true,
|
|
||||||
stepHour: 0.05,
|
|
||||||
stepMinute: 0.05,
|
|
||||||
stepSecond: 0.05,
|
|
||||||
ampm: false,
|
|
||||||
hour: 0,
|
|
||||||
minute: 0,
|
|
||||||
second: 0,
|
|
||||||
timeFormat: 'hh:mm tt',
|
|
||||||
alwaysSetTime: true
|
|
||||||
},
|
|
||||||
|
|
||||||
//########################################################################
|
//########################################################################
|
||||||
// add our sliders to the calendar
|
// add our sliders to the calendar
|
||||||
//########################################################################
|
//########################################################################
|
||||||
|
@ -101,10 +110,14 @@
|
||||||
|
|
||||||
tp_inst.timeDefined = (treg) ? true : false;
|
tp_inst.timeDefined = (treg) ? true : false;
|
||||||
|
|
||||||
|
if (typeof(dp_inst.stay_open) !== 'boolean' || dp_inst.stay_open === false) {
|
||||||
// wait for datepicker to create itself.. 60% of the time it works every time..
|
// wait for datepicker to create itself.. 60% of the time it works every time..
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
tp_inst.injectTimePicker(dp_inst, tp_inst);
|
tp_inst.injectTimePicker(dp_inst, tp_inst);
|
||||||
}, 10);
|
}, 10);
|
||||||
|
} else {
|
||||||
|
tp_inst.injectTimePicker(dp_inst, tp_inst);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -174,7 +187,7 @@
|
||||||
slide: function(event, ui) {
|
slide: function(event, ui) {
|
||||||
tp_inst.hour_slider.slider( "option", "value", ui.value );
|
tp_inst.hour_slider.slider( "option", "value", ui.value );
|
||||||
tp_inst.onTimeChange(dp_inst, tp_inst);
|
tp_inst.onTimeChange(dp_inst, tp_inst);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Updated by Peter Medeiros:
|
// Updated by Peter Medeiros:
|
||||||
|
@ -189,7 +202,7 @@
|
||||||
// update the global minute slider instance value with the current slider value
|
// update the global minute slider instance value with the current slider value
|
||||||
tp_inst.minute_slider.slider( "option", "value", ui.value );
|
tp_inst.minute_slider.slider( "option", "value", ui.value );
|
||||||
tp_inst.onTimeChange(dp_inst, tp_inst);
|
tp_inst.onTimeChange(dp_inst, tp_inst);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tp_inst.second_slider = $tp.find('#ui_tpicker_second').slider({
|
tp_inst.second_slider = $tp.find('#ui_tpicker_second').slider({
|
||||||
|
@ -201,7 +214,7 @@
|
||||||
slide: function(event, ui) {
|
slide: function(event, ui) {
|
||||||
tp_inst.second_slider.slider( "option", "value", ui.value );
|
tp_inst.second_slider.slider( "option", "value", ui.value );
|
||||||
tp_inst.onTimeChange(dp_inst, tp_inst);
|
tp_inst.onTimeChange(dp_inst, tp_inst);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$dp.find('.ui-datepicker-calendar').after($tp);
|
$dp.find('.ui-datepicker-calendar').after($tp);
|
||||||
|
@ -299,7 +312,12 @@
|
||||||
|
|
||||||
this.formattedDateTime = formattedDateTime;
|
this.formattedDateTime = formattedDateTime;
|
||||||
this.$input.val(formattedDateTime);
|
this.$input.val(formattedDateTime);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
setDefaults: function(settings) {
|
||||||
|
extendRemove(this.defaults, settings || {});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//########################################################################
|
//########################################################################
|
||||||
|
@ -340,7 +358,7 @@
|
||||||
tp.defaults = $.extend({}, tp.defaults, opts, {
|
tp.defaults = $.extend({}, tp.defaults, opts, {
|
||||||
beforeShow: beforeShowFunc,
|
beforeShow: beforeShowFunc,
|
||||||
onChangeMonthYear: onChangeMonthYearFunc,
|
onChangeMonthYear: onChangeMonthYearFunc,
|
||||||
onClose: onCloseFunc,
|
onClose: onCloseFunc
|
||||||
});
|
});
|
||||||
|
|
||||||
$(this).datepicker(tp.defaults);
|
$(this).datepicker(tp.defaults);
|
||||||
|
@ -363,7 +381,9 @@
|
||||||
var target = $(id);
|
var target = $(id);
|
||||||
var inst = this._getInst(target[0]);
|
var inst = this._getInst(target[0]);
|
||||||
inst.inline = true;
|
inst.inline = true;
|
||||||
|
inst.stay_open = true;
|
||||||
$.datepicker._selectDateOverload(id, dateStr);
|
$.datepicker._selectDateOverload(id, dateStr);
|
||||||
|
inst.stay_open = false;
|
||||||
inst.inline = false;
|
inst.inline = false;
|
||||||
this._notifyChange(inst);
|
this._notifyChange(inst);
|
||||||
this._updateDatepicker(inst);
|
this._updateDatepicker(inst);
|
||||||
|
@ -372,18 +392,23 @@
|
||||||
$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
|
$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
|
||||||
//#############################################################################################
|
//#############################################################################################
|
||||||
// second bad hack :/ override datepicker so it triggers an event when changing the input field
|
// second bad hack :/ override datepicker so it triggers an event when changing the input field
|
||||||
|
// and does not redraw the datepicker on every selectDate event
|
||||||
//#############################################################################################
|
//#############################################################################################
|
||||||
// Generate the date picker content.
|
// Generate the date picker content.
|
||||||
$.datepicker._updateDatepicker = function(inst) {
|
$.datepicker._updateDatepicker = function(inst) {
|
||||||
this._base_updateDatepicker(inst);
|
if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
|
||||||
// Reload the time control when changing something in the input text field.
|
this._base_updateDatepicker(inst);
|
||||||
this._beforeShow(inst.input, inst);
|
// Reload the time control when changing something in the input text field.
|
||||||
|
this._beforeShow(inst.input, inst);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$.datepicker._beforeShow = function(input, inst) {
|
$.datepicker._beforeShow = function(input, inst) {
|
||||||
var beforeShow = this._get(inst, 'beforeShow');
|
var beforeShow = this._get(inst, 'beforeShow');
|
||||||
if (beforeShow) {
|
if (beforeShow) {
|
||||||
|
inst.stay_open = true;
|
||||||
beforeShow.apply((inst.input ? inst.input[0] : null), [inst.input, inst]);
|
beforeShow.apply((inst.input ? inst.input[0] : null), [inst.input, inst]);
|
||||||
|
inst.stay_open = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -401,4 +426,14 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* jQuery extend now ignores nulls! */
|
||||||
|
function extendRemove(target, props) {
|
||||||
|
$.extend(target, props);
|
||||||
|
for (var name in props)
|
||||||
|
if (props[name] == null || props[name] == undefined)
|
||||||
|
target[name] = props[name];
|
||||||
|
return target;
|
||||||
|
};
|
||||||
|
|
||||||
|
$.timepicker = new Timepicker(true); // singleton instance
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
Loading…
Reference in a new issue