From b4c322c657aea1db12c260e9de60ae49dbc4d039 Mon Sep 17 00:00:00 2001 From: Trent Date: Sun, 14 Nov 2010 22:41:47 -0500 Subject: [PATCH] Tested bug fixes, incremented to version 0.8 --- jquery-ui-timepicker-addon.js | 45 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 4d4f2bb..14de95e 100755 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -1,8 +1,8 @@ /* * jQuery timepicker addon * By: Trent Richardson [http://trentrichardson.com] -* Version 0.7.3 -* Last Modified: 11/9/2010 +* Version 0.8 +* Last Modified: 11/14/2010 * * Copyright 2010 Trent Richardson * Dual licensed under the MIT and GPL licenses. @@ -172,7 +172,8 @@ { var $dp = dp_inst.dpDiv; var opts = tp_inst.defaults; - + var dp_id = dp_inst.id; + // Added by Peter Medeiros: // - Figure out what the hour/minute/second max should be based on the step values. // - Example: if stepMinute is 15, then minMax is 45. @@ -181,13 +182,13 @@ var secMax = opts.secondMax - (opts.secondMax % opts.stepSecond); // Prevent displaying twice - if ($dp.find("div#ui-timepicker-div-" + dp_inst.id).length === 0){ + if ($dp.find("div#ui-timepicker-div-" + dp_id).length === 0){ var noDisplay = ' style="display:none;"'; var html = - '
' + - '
' + opts.timeText + '
' + - '
' + - '
' + opts.hourText + '
'; + '
' + + '
' + opts.timeText + '
' + + '
' + + '
' + opts.hourText + '
'; var hourGridSize = 0; var minuteGridSize = 0; var secondGridSize = 0; @@ -196,7 +197,7 @@ if (opts.showHour && opts.hourGrid > 0) { html += '
' + - '
' + + '
' + '
'; for (var h = 0; h <= hourMax; h += opts.hourGrid) @@ -235,15 +236,15 @@ } else { - html += '
'; + html += '
'; } - html += '
' + opts.minuteText + '
'; + html += '
' + opts.minuteText + '
'; if (opts.showMinute && opts.minuteGrid > 0) { html += '
' + - '
' + + '
' + '
'; for (var m = 0; m <= minMax; m += opts.minuteGrid) @@ -257,15 +258,15 @@ } else { - html += '
'; + html += '
'; } - html += '
' + opts.secondText + '
'; + html += '
' + opts.secondText + '
'; if (opts.showSecond && opts.secondGrid > 0) { html += '
' + - '
' + + '
' + '
'; for (var s = 0; s <= secMax; s += opts.secondGrid) @@ -279,7 +280,7 @@ } else { - html += '
'; + html += '
'; } html += ''; @@ -295,7 +296,7 @@ $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide(); } - tp_inst.hour_slider = $tp.find('#ui_tpicker_hour_' + dp_inst.id).slider({ + tp_inst.hour_slider = $tp.find('#ui_tpicker_hour_' + dp_id).slider({ orientation: "horizontal", value: tp_inst.hour, min: opts.hourMin, @@ -310,7 +311,7 @@ // Updated by Peter Medeiros: // - Pass in Event and UI instance into slide function - tp_inst.minute_slider = $tp.find('#ui_tpicker_minute_' + dp_inst.id).slider({ + tp_inst.minute_slider = $tp.find('#ui_tpicker_minute_' + dp_id).slider({ orientation: "horizontal", value: tp_inst.minute, min: opts.minuteMin, @@ -324,7 +325,7 @@ } }); - tp_inst.second_slider = $tp.find('#ui_tpicker_second_' + dp_inst.id).slider({ + tp_inst.second_slider = $tp.find('#ui_tpicker_second_' + dp_id).slider({ orientation: "horizontal", value: tp_inst.second, min: opts.secondMin, @@ -456,7 +457,7 @@ $dp.append($tp); } - tp_inst.$timeObj = $('#ui_tpicker_time_' + dp_inst.id); + tp_inst.$timeObj = $('#ui_tpicker_time_' + dp_id); if (dp_inst !== null) { @@ -547,6 +548,10 @@ this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg); var formattedDateTime = this.formattedDate; var timeAvailable = ((dt !== null && tp_inst.timeDefined) !== true)? false : true; + + if (dp_inst.lastVal.length > 0 && this.$input.val().length === 0) { + return; + } if(this.defaults.timeOnly === true){ formattedDateTime = this.formattedTime;