Skip to content

Commit 83975d3

Browse files
committed
Integrate bugfixes.
1 parent 6558637 commit 83975d3

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

ui/jquery.ui.datetimepicker.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
/*!
2-
* jQuery UI Timepicker 0.2.1
2+
* jQuery UI DateTimepicker @VERSION
3+
*
4+
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5+
* Dual licensed under the MIT or GPL Version 2 licenses.
6+
* http://jquery.org/license
37
*
48
* Copyright (c) 2009 Martin Milesich (http://milesich.com/)
59
* http://addyosmani.com/blog/the-missing-date-time-selector-for-jquery-ui/
610
*
7-
* Copyright (c) 2010 Gábor Czigola (http://gablog.eu)
8-
*
11+
* Copyright (c) 2010 Gábor Czigola
912
*
10-
* $Id: timepicker.js 28 2009-08-11 20:31:23Z majlo $
13+
* http://docs.jquery.com/UI/Timepicker
1114
*
1215
* Depends:
1316
* ui.core.js
@@ -92,6 +95,8 @@ $.datepicker._checkExternalClick = function (event) {
9295
if (!$.datepicker._curInst) return;
9396
var $target = $(event.target);
9497

98+
$.datepicker._curInst.closeButtonClicked = $target.parents('.ui-datepicker-buttonpane').length;
99+
95100
if (($target.parents('#' + $.timepicker._mainDivId).length == 0)) {
96101
$.datepicker._checkExternalClickOverride(event);
97102
}
@@ -108,18 +113,28 @@ $.datepicker._hideDatepicker = function(input, duration) {
108113

109114
if (!inst || (input && inst != $.data(input, PROP_NAME))) return;
110115

116+
// Change the field only when Done button clicked or sliders changed.
117+
var saveOnHide = $.timepicker._modified;
118+
try {
119+
saveOnHide |= inst.closeButtonClicked;
120+
}
121+
catch (err) {}
122+
111123
// Get the value of showTime property
112124
var showTime = this._get(inst, 'showTime');
113125

114-
if (input === undefined && showTime) {
126+
if (saveOnHide && input === undefined && showTime) {
115127
if (inst.input) {
116128
inst.input.val(this._formatDate(inst));
117-
inst.input.trigger('change'); // fire the change event
118129
}
119130

120131
this._updateAlternate(inst);
121132

122133
if (showTime) $.timepicker.update(this._formatDate(inst));
134+
135+
if (inst.input) {
136+
inst.input.trigger('change'); // fire the change event
137+
}
123138
}
124139

125140
// Hide datepicker
@@ -129,6 +144,8 @@ $.datepicker._hideDatepicker = function(input, duration) {
129144
if (showTime) {
130145
$.timepicker.hide();
131146
}
147+
148+
$.timepicker._modified = false;
132149
};
133150

134151
/**
@@ -186,6 +203,7 @@ Timepicker.prototype = {
186203
this._orgMinute = null;
187204
this._colonPos = -1;
188205
this._visible = false;
206+
this._modified = false;
189207
this.tpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible" style="z-index: 16; width: 100px; display: none; position: absolute;"></div>');
190208
this._generateHtml();
191209
},
@@ -302,9 +320,11 @@ Timepicker.prototype = {
302320
max: 23,
303321
step: 1,
304322
slide: function(event, ui) {
323+
self._modified = true;
305324
self._writeTime('hour', ui.value);
306325
},
307326
stop: function(event, ui) {
327+
self._modified = true;
308328
$('#' + self._inputId).focus();
309329
}
310330
});
@@ -405,7 +425,7 @@ Timepicker.prototype = {
405425
}
406426

407427
this._writeTime(type, value);
408-
}
428+
}
409429
};
410430

411431
$.timepicker = new Timepicker();

0 commit comments

Comments
 (0)