mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
Merge pull request #693 from bmalpham8/master
fix onClose call multiple times
This commit is contained in:
commit
af7dbc036b
@ -690,7 +690,7 @@ var datetimepickerFactory = function ($) {
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// for locale settings
|
||||
$.datetimepicker = {
|
||||
@ -725,12 +725,12 @@ var datetimepickerFactory = function ($) {
|
||||
RFC_1123: 'D, d M Y H:i:s O',
|
||||
RSS: 'D, d M Y H:i:s O',
|
||||
W3C: 'Y-m-d\TH:i:sP'
|
||||
}
|
||||
};
|
||||
|
||||
var isFormatStandard = function(format) {
|
||||
return $.map(standardFormats, function (val) { return val })
|
||||
.indexOf(format) === -1 ? false : true;
|
||||
}
|
||||
};
|
||||
|
||||
$.extend($.datetimepicker, standardFormats);
|
||||
|
||||
@ -951,6 +951,7 @@ var datetimepickerFactory = function ($) {
|
||||
ZKEY = 90,
|
||||
YKEY = 89,
|
||||
ctrlDown = false,
|
||||
isClosed = false,
|
||||
options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
|
||||
|
||||
lazyInitTimer = 0,
|
||||
@ -1067,7 +1068,7 @@ var datetimepickerFactory = function ($) {
|
||||
if(distance > options.touchMovedThreshold) {
|
||||
this.touchMoved = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
month_picker
|
||||
.find('.xdsoft_select')
|
||||
@ -2225,6 +2226,7 @@ var datetimepickerFactory = function ($) {
|
||||
datetimepicker
|
||||
.on('open.xdsoft', function (event) {
|
||||
var onShow = true;
|
||||
isClosed = false;
|
||||
if (options.onShow && $.isFunction(options.onShow)) {
|
||||
onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
|
||||
}
|
||||
@ -2245,6 +2247,12 @@ var datetimepickerFactory = function ($) {
|
||||
})
|
||||
.on('close.xdsoft', function (event) {
|
||||
var onClose = true;
|
||||
event.stopPropagation();
|
||||
|
||||
if (isClosed) {
|
||||
return;
|
||||
}
|
||||
|
||||
month_picker
|
||||
.find('.xdsoft_month,.xdsoft_year')
|
||||
.find('.xdsoft_select')
|
||||
@ -2255,7 +2263,7 @@ var datetimepickerFactory = function ($) {
|
||||
if (onClose !== false && !options.opened && !options.inline) {
|
||||
datetimepicker.hide();
|
||||
}
|
||||
event.stopPropagation();
|
||||
isClosed = true;
|
||||
})
|
||||
.on('toggle.xdsoft', function () {
|
||||
if (datetimepicker.is(':visible')) {
|
||||
@ -2384,13 +2392,13 @@ var datetimepickerFactory = function ($) {
|
||||
var clipboardData = event.clipboardData || event.originalEvent.clipboardData || window.clipboardData,
|
||||
pastedData = clipboardData.getData('text'),
|
||||
val = this.value,
|
||||
pos = this.selectionStart
|
||||
pos = this.selectionStart;
|
||||
|
||||
var valueBeforeCursor = val.substr(0, pos);
|
||||
var valueAfterPaste = val.substr(pos + pastedData.length);
|
||||
|
||||
val = valueBeforeCursor + pastedData + valueAfterPaste;
|
||||
val = val.substring(0, options.mask.length)
|
||||
val = val.substring(0, options.mask.length);
|
||||
pos += pastedData.length;
|
||||
|
||||
if (isValidValue(options.mask, val)) {
|
||||
@ -2648,7 +2656,7 @@ var datetimepickerFactory = function ($) {
|
||||
define(['jquery', 'jquery-mousewheel'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS style for Browserify
|
||||
module.exports = factory(require('jquery'));;
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
|
Loading…
Reference in New Issue
Block a user