Compare commits

...

23 Commits

Author SHA1 Message Date
Trent Richardson 5eb540282f Ready for deployment 2012-02-11 17:34:50 -05:00
Trent Richardson 19fa33319a he fix by erann3 2012-02-07 11:03:50 -05:00
Trent Richardson e9ac8bf8cf Korean by Genie 2012-02-07 10:56:46 -05:00
Trent Richardson 27a426e3eb Create public $.datepicker.formatTime method 2012-02-07 10:52:19 -05:00
Trent e2faad1db2 Trim formatted time for when ampm=false and tt in format 2012-01-30 15:49:09 -05:00
Trent 547e6adde3 timeFormat tt h:mm not parsed fix by clear00 2012-01-30 15:32:35 -05:00
Trent fc2531ff86 Merge branch 'master' of github.com:trentrichardson/jQuery-Timepicker-Addon into dev 2012-01-18 07:49:32 -05:00
Trent 1b96a3f1d2 Fix more semicolons 2012-01-11 11:38:28 -05:00
Trent f1e4a47170 Fix semicolons 2012-01-11 11:34:44 -05:00
Trent 4853a89b9d Fix beforeShow to return value - by kunalkumar 2011-12-27 15:18:26 -05:00
Trent 26776afeb2 Update Russian translation by Sanek 2011-12-19 10:12:49 -05:00
Trent Richardson 1a1526287a Merge pull request #284 from RichardBradley/dev
Fix error parsing date when setting option defaultDate
2011-12-15 08:27:25 -08:00
Richard Bradley 8e456626c7 bug fix - swallowing all date parsing errors breaks the datepicker option "defaultDate" on relative values like "-18y" 2011-12-15 15:33:22 +00:00
Trent 3ac151fe8c Check for tp_inst in gotoToday 2011-12-14 08:13:01 -05:00
Trent 0ec258f82b Added Norwegian translation 2011-12-06 10:57:13 -05:00
Trent Richardson 9af6f920e8 Fix option setter 2011-12-04 11:28:14 -05:00
Trent Richardson 0a68b5c5dc Merge pull request #278 from tomaswindsor/patch-1
Fixes option setter override so it doesn't break option getter.
2011-12-04 08:24:43 -08:00
Tomáš Windsor 21bcc3c07b Fixes option setter override so it doesn't break option getter. 2011-12-04 16:02:41 +01:00
Trent Richardson dc15bf6bc5 sliderAccess tweak 2011-12-04 09:48:06 -05:00
Trent Richardson ac38588138 sliderAccess tweak 2011-12-04 09:45:23 -05:00
Trent Richardson 9963f68ad5 Create new dev version 2011-12-03 15:26:14 -05:00
Trent Richardson cc45f6a6d8 Merge branch 'master' of github.com:trentrichardson/jQuery-Timepicker-Addon 2011-12-03 15:23:22 -05:00
Trent ff6596d673 Fix localization 2011-10-03 16:50:41 -04:00
5 changed files with 135 additions and 64 deletions

View File

@ -1,10 +1,10 @@
/*
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
* Version 0.9.8
* Last Modified: 12/03/2011
* Version 0.9.9
* Last Modified: 02/05/2012
*
* Copyright 2011 Trent Richardson
* Copyright 2012 Trent Richardson
* Dual licensed under the MIT and GPL licenses.
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
@ -20,7 +20,7 @@
(function($) {
$.extend($.ui, { timepicker: { version: "0.9.8" } });
$.extend($.ui, { timepicker: { version: "0.9.9" } });
/* Time picker manager.
Use the singleton instance of this class, $.timepicker, to interact with the time picker.
@ -88,7 +88,7 @@ function Timepicker() {
sliderAccessArgs: null
};
$.extend(this._defaults, this.regional['']);
}
};
$.extend(Timepicker.prototype, {
$input: null,
@ -147,7 +147,7 @@ $.extend(Timepicker.prototype, {
tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
beforeShow: function(input, dp_inst) {
if ($.isFunction(o.beforeShow))
o.beforeShow(input, dp_inst, tp_inst);
return o.beforeShow(input, dp_inst, tp_inst);
},
onChangeMonthYear: function(year, month, dp_inst) {
// Update the time as well : this prevents the time from disappearing from the $input field.
@ -247,7 +247,7 @@ $.extend(Timepicker.prototype, {
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
// escape special regex characters in the seperator
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator.replace(specials, "\\$&") + regstr;
regstr = '^.{' + dp_dateFormat.length + ',}?' + this._defaults.separator.replace(specials, "\\$&") + regstr;
}
treg = timeString.match(new RegExp(regstr, 'i'));
@ -639,20 +639,22 @@ $.extend(Timepicker.prototype, {
if (this._defaults.addSliderAccess){
var sliderAccessArgs = this._defaults.sliderAccessArgs;
setTimeout(function(){ // fix for inline mode
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
if($tp.find('.ui-slider-access').length == 0){
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
// fix any grids since sliders are shorter
var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
if(sliderAccessWidth){
$tp.find('table:visible').each(function(){
var $g = $(this),
oldWidth = $g.outerWidth(),
oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
newWidth = oldWidth - sliderAccessWidth,
newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
// fix any grids since sliders are shorter
var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
if(sliderAccessWidth){
$tp.find('table:visible').each(function(){
var $g = $(this),
oldWidth = $g.outerWidth(),
oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
newWidth = oldWidth - sliderAccessWidth,
newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
$g.css({ width: newWidth, marginLeft: newMarginLeft });
});
$g.css({ width: newWidth, marginLeft: newMarginLeft });
});
}
}
},0);
}
@ -816,7 +818,8 @@ $.extend(Timepicker.prototype, {
}
if (o.ampm) this.ampm = ampm;
this._formatTime();
//this._formatTime();
this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix);
this.timeDefined = true;
if (hasChanged) this._updateDateTime();
@ -835,41 +838,14 @@ $.extend(Timepicker.prototype, {
},
//########################################################################
// format the time all pretty...
// left for any backwards compatibility
//########################################################################
_formatTime: function(time, format, ampm) {
if (ampm == undefined) ampm = this._defaults.ampm;
_formatTime: function(time, format) {
time = time || { hour: this.hour, minute: this.minute, second: this.second, millisec: this.millisec, ampm: this.ampm, timezone: this.timezone };
var tmptime = (format || this._defaults.timeFormat).toString();
var hour = parseInt(time.hour, 10);
if (ampm) {
if (!$.inArray(time.ampm.toUpperCase(), this.amNames) !== -1)
hour = hour % 12;
if (hour === 0)
hour = 12;
}
tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
switch (match.toLowerCase()) {
case 'hh': return ('0' + hour).slice(-2);
case 'h': return hour;
case 'mm': return ('0' + time.minute).slice(-2);
case 'm': return time.minute;
case 'ss': return ('0' + time.second).slice(-2);
case 's': return time.second;
case 'l': return ('00' + time.millisec).slice(-3);
case 'z': return time.timezone;
case 't': case 'tt':
if (ampm) {
var _ampm = time.ampm;
if (match.length == 1)
_ampm = _ampm.charAt(0);
return match.charAt(0) == 'T' ? _ampm.toUpperCase() : _ampm.toLowerCase();
}
return '';
}
});
tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);
if (arguments.length) return tmptime;
else this.formattedTime = tmptime;
},
@ -953,6 +929,54 @@ $.fn.extend({
}
});
//########################################################################
// format the time all pretty...
// format = string format of the time
// time = a {}, not a Date() for timezones
// options = essentially the regional[].. amNames, pmNames, ampm
//########################################################################
$.datepicker.formatTime = function(format, time, options) {
options = options || {};
options = $.extend($.timepicker._defaults, options);
time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time);
var tmptime = format;
var ampmName = options['amNames'][0];
var hour = parseInt(time.hour, 10);
if (options.ampm) {
if (hour > 11){
ampmName = options['pmNames'][0];
if(hour > 12)
hour = hour % 12;
}
if (hour === 0)
hour = 12;
}
tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
switch (match.toLowerCase()) {
case 'hh': return ('0' + hour).slice(-2);
case 'h': return hour;
case 'mm': return ('0' + time.minute).slice(-2);
case 'm': return time.minute;
case 'ss': return ('0' + time.second).slice(-2);
case 's': return time.second;
case 'l': return ('00' + time.millisec).slice(-3);
case 'z': return time.timezone;
case 't': case 'tt':
if (options.ampm) {
if (match.length == 1)
ampmName = ampmName.charAt(0);
return match.charAt(0) == 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
}
return '';
}
});
tmptime = $.trim(tmptime);
return tmptime;
}
//########################################################################
// the bad hack :/ override datepicker so it doesnt close on select
// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
@ -1067,11 +1091,11 @@ $.datepicker._gotoToday = function(id) {
this._base_gotoToday(id);
var now = new Date();
var tp_inst = this._get(inst, 'timepicker');
if (tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
if (tp_inst && tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
var tzsign = tzoffset > 0 ? '-' : '+';
tzoffset = Math.abs(tzoffset);
var tzmin = tzoffset % 60
var tzmin = tzoffset % 60;
tzoffset = tzsign + ('0' + (tzoffset - tzmin) / 60).slice(-2) + ('0' + tzmin).slice(-2);
if (tp_inst._defaults.timezoneIso8609)
tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
@ -1205,10 +1229,15 @@ $.datepicker.parseDate = function(format, value, settings) {
try {
date = this._base_parseDate(format, value, settings);
} catch (err) {
// Hack! The error message ends with a colon, a space, and
// the "extra" characters. We rely on that instead of
// attempting to perfectly reproduce the parsing algorithm.
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
if (err.indexOf(":") >= 0) {
// Hack! The error message ends with a colon, a space, and
// the "extra" characters. We rely on that instead of
// attempting to perfectly reproduce the parsing algorithm.
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
} else {
// The underlying error was not related to the time
throw err;
}
}
return date;
};
@ -1227,7 +1256,7 @@ $.datepicker._formatDate = function(inst, day, month, year){
return tp_inst.$input.val();
}
return this._base_formatDate(inst);
}
};
//#######################################################################################
// override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
@ -1274,7 +1303,9 @@ $.datepicker._optionDatepicker = function(target, name, value) {
else if (onselect)
tp_inst._defaults.onSelect=onselect;
}
this._base_optionDatepicker(target, name, value);
if (value === undefined)
return this._base_optionDatepicker(target, name);
return this._base_optionDatepicker(target, name, value);
};
//#######################################################################################
@ -1286,10 +1317,10 @@ function extendRemove(target, props) {
if (props[name] === null || props[name] === undefined)
target[name] = props[name];
return target;
}
};
$.timepicker = new Timepicker(); // singleton instance
$.timepicker.version = "0.9.8";
$.timepicker.version = "0.9.9";
})(jQuery);

View File

@ -2,7 +2,7 @@
/* Written by Lior Lapid */
(function($) {
$.timepicker.regional["he"] = {
timeOnlyTitle: "בחרית זמן",
timeOnlyTitle: "בחירת זמן",
timeText: "שעה",
hourText: "שעות",
minuteText: "דקות",

20
localization/jquery-ui-timepicker-ko.js vendored Normal file
View File

@ -0,0 +1,20 @@
/* Korean translation for the jQuery Timepicker Addon */
/* Written by Genie */
(function($) {
$.timepicker.regional['ko'] = {
timeOnlyTitle: '시간 선택',
timeText: '시간',
hourText: '시',
minuteText: '분',
secondText: '초',
millisecText: '밀리초',
timezoneText: '표준 시간대',
currentText: '현재 시각',
closeText: '닫기',
timeFormat: 'tt h:mm',
amNames: ['오전', 'AM', 'A'],
pmNames: ['오후', 'PM', 'P'],
ampm: true
};
$.timepicker.setDefaults($.timepicker.regional['ko']);
})(jQuery);

20
localization/jquery-ui-timepicker-no.js vendored Normal file
View File

@ -0,0 +1,20 @@
/* Norwegian translation for the jQuery Timepicker Addon */
/* Written by Morten Hauan (http://hauan.me) */
(function($) {
$.timepicker.regional['no'] = {
timeOnlyTitle: 'Velg tid',
timeText: 'Tid',
hourText: 'Time',
minuteText: 'Minutt',
secondText: 'Sekund',
millisecText: 'Millisekund',
timezoneText: 'Tidssone',
currentText: 'Nå',
closeText: 'Lukk',
timeFormat: 'hh:mm',
amNames: ['am', 'AM', 'A'],
pmNames: ['pm', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['no']);
})(jQuery);

View File

@ -8,8 +8,8 @@
minuteText: 'Минуты',
secondText: 'Секунды',
millisecText: 'Миллисекунды',
timezoneText: 'Время зоны',
currentText: 'Теперь',
timezoneText: 'Часовой пояс',
currentText: 'Сейчас',
closeText: 'Закрыть',
timeFormat: 'hh:mm tt',
amNames: ['AM', 'A'],