mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
fix removing symbols with cmd or selecting
This commit is contained in:
parent
97be78e40a
commit
cf89d330df
@ -728,8 +728,7 @@ var datetimepickerFactory = function ($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var isFormatStandard = function(format){
|
var isFormatStandard = function(format){
|
||||||
return $.map(standardFormats, function (val) { return val })
|
return Object.values(standardFormats).indexOf(format) === -1 ? false : true;
|
||||||
.indexOf(format) === -1 ? false : true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$.extend($.datetimepicker, standardFormats);
|
$.extend($.datetimepicker, standardFormats);
|
||||||
@ -935,6 +934,7 @@ var datetimepickerFactory = function ($) {
|
|||||||
_KEY0 = 96,
|
_KEY0 = 96,
|
||||||
_KEY9 = 105,
|
_KEY9 = 105,
|
||||||
CTRLKEY = 17,
|
CTRLKEY = 17,
|
||||||
|
CMDKEY = 91,
|
||||||
DEL = 46,
|
DEL = 46,
|
||||||
ENTER = 13,
|
ENTER = 13,
|
||||||
ESC = 27,
|
ESC = 27,
|
||||||
@ -951,6 +951,7 @@ var datetimepickerFactory = function ($) {
|
|||||||
ZKEY = 90,
|
ZKEY = 90,
|
||||||
YKEY = 89,
|
YKEY = 89,
|
||||||
ctrlDown = false,
|
ctrlDown = false,
|
||||||
|
cmdDown = false,
|
||||||
options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
|
options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
|
||||||
|
|
||||||
lazyInitTimer = 0,
|
lazyInitTimer = 0,
|
||||||
@ -2371,7 +2372,7 @@ var datetimepickerFactory = function ($) {
|
|||||||
setCaretPos(input[0], 0);
|
setCaretPos(input[0], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
input.off('paste.xdsoft').on('paste.xdsoft', function (event) {
|
input.on('paste.xdsoft', function (event) {
|
||||||
// couple options here
|
// couple options here
|
||||||
// 1. return false - tell them they can't paste
|
// 1. return false - tell them they can't paste
|
||||||
// 2. insert over current characters - minimal validation
|
// 2. insert over current characters - minimal validation
|
||||||
@ -2390,7 +2391,6 @@ var datetimepickerFactory = function ($) {
|
|||||||
var valueAfterPaste = val.substr(pos + pastedData.length);
|
var valueAfterPaste = val.substr(pos + pastedData.length);
|
||||||
|
|
||||||
val = valueBeforeCursor + pastedData + valueAfterPaste;
|
val = valueBeforeCursor + pastedData + valueAfterPaste;
|
||||||
val = val.substring(0, options.mask.length)
|
|
||||||
pos += pastedData.length;
|
pos += pastedData.length;
|
||||||
|
|
||||||
if (isValidValue(options.mask, val)) {
|
if (isValidValue(options.mask, val)) {
|
||||||
@ -2448,6 +2448,10 @@ var datetimepickerFactory = function ($) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.metaKey) { // cmd has been pressed
|
||||||
|
pos = 0;
|
||||||
|
hasSel = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasSel) {
|
if (hasSel) {
|
||||||
// pos might have moved so re-calc length
|
// pos might have moved so re-calc length
|
||||||
@ -2570,6 +2574,7 @@ var datetimepickerFactory = function ($) {
|
|||||||
};
|
};
|
||||||
$(options.ownerDocument)
|
$(options.ownerDocument)
|
||||||
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
||||||
|
.off('keydown.xdsoftcmd keyup.xdsoftcmd')
|
||||||
.on('keydown.xdsoftctrl', function (e) {
|
.on('keydown.xdsoftctrl', function (e) {
|
||||||
if (e.keyCode === CTRLKEY) {
|
if (e.keyCode === CTRLKEY) {
|
||||||
ctrlDown = true;
|
ctrlDown = true;
|
||||||
@ -2578,6 +2583,16 @@ var datetimepickerFactory = function ($) {
|
|||||||
.on('keyup.xdsoftctrl', function (e) {
|
.on('keyup.xdsoftctrl', function (e) {
|
||||||
if (e.keyCode === CTRLKEY) {
|
if (e.keyCode === CTRLKEY) {
|
||||||
ctrlDown = false;
|
ctrlDown = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('keydown.xdsoftcmd', function (e) {
|
||||||
|
if (e.keyCode === CMDKEY) {
|
||||||
|
cmdDown = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('keyup.xdsoftcmd', function (e) {
|
||||||
|
if (e.keyCode === CMDKEY) {
|
||||||
|
cmdDown = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user