mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
Merge pull request #697 from xdan/revert-694-master
Revert "fix removing symbols with cmd or selecting"
This commit is contained in:
commit
3451e14ed5
20
.gitignore
vendored
20
.gitignore
vendored
@ -1,20 +0,0 @@
|
||||
lib
|
||||
node_modules
|
||||
*.log
|
||||
.idea
|
||||
.vscode/
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
package-lock.json
|
||||
/.nyc_output/
|
||||
coverage/
|
||||
/coverage/
|
@ -636,8 +636,7 @@ var datetimepickerFactory = function ($) {
|
||||
beforeShowDay: null,
|
||||
|
||||
enterLikeTab: true,
|
||||
showApplyButton: false,
|
||||
insideParent: false,
|
||||
showApplyButton: false
|
||||
};
|
||||
|
||||
var dateHelper = null,
|
||||
@ -943,8 +942,7 @@ var datetimepickerFactory = function ($) {
|
||||
KEY9 = 57,
|
||||
_KEY0 = 96,
|
||||
_KEY9 = 105,
|
||||
CTRLKEY = 17,
|
||||
CMDKEY = 91,
|
||||
CTRLKEY = 17,
|
||||
DEL = 46,
|
||||
ENTER = 13,
|
||||
ESC = 27,
|
||||
@ -960,8 +958,7 @@ var datetimepickerFactory = function ($) {
|
||||
VKEY = 86,
|
||||
ZKEY = 90,
|
||||
YKEY = 89,
|
||||
ctrlDown = false,
|
||||
cmdDown = false,
|
||||
ctrlDown = false,
|
||||
options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
|
||||
|
||||
lazyInitTimer = 0,
|
||||
@ -1356,11 +1353,8 @@ var datetimepickerFactory = function ($) {
|
||||
.append(calendar)
|
||||
.append(applyButton);
|
||||
|
||||
if (options.insideParent) {
|
||||
$(input).parent().append(datetimepicker);
|
||||
} else {
|
||||
$(options.parentID).append(datetimepicker);
|
||||
}
|
||||
$(options.parentID)
|
||||
.append(datetimepicker);
|
||||
|
||||
XDSoft_datetime = function () {
|
||||
var _this = this;
|
||||
@ -2186,7 +2180,7 @@ var datetimepickerFactory = function ($) {
|
||||
}
|
||||
});
|
||||
|
||||
if (dateInputHasFixedAncestor && !options.insideParent) {
|
||||
if (dateInputHasFixedAncestor) {
|
||||
position = 'fixed';
|
||||
|
||||
//If the picker won't fit entirely within the viewport then display it above the date input.
|
||||
@ -2226,16 +2220,12 @@ var datetimepickerFactory = function ($) {
|
||||
|
||||
datetimepickerCss = {
|
||||
position: position,
|
||||
left: options.insideParent ? dateInputElem.offsetLeft : left,
|
||||
left: left,
|
||||
top: '', //Initialize to prevent previous values interfering with new ones.
|
||||
bottom: '' //Initialize to prevent previous values interfering with new ones.
|
||||
};
|
||||
|
||||
if (options.insideParent) {
|
||||
datetimepickerCss[verticalAnchorEdge] = dateInputElem.offsetTop + dateInputElem.offsetHeight;
|
||||
} else {
|
||||
datetimepickerCss[verticalAnchorEdge] = verticalPosition;
|
||||
}
|
||||
datetimepickerCss[verticalAnchorEdge] = verticalPosition;
|
||||
|
||||
datetimepicker.css(datetimepickerCss);
|
||||
};
|
||||
@ -2463,12 +2453,8 @@ var datetimepickerFactory = function ($) {
|
||||
// hitting backspace in a selection, you can possibly go back any further - go forward
|
||||
pos += (key === BACKSPACE && !hasSel) ? -1 : 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (event.metaKey) { // cmd has been pressed
|
||||
pos = 0;
|
||||
hasSel = true;
|
||||
}
|
||||
|
||||
if (hasSel) {
|
||||
// pos might have moved so re-calc length
|
||||
@ -2590,27 +2576,16 @@ var datetimepickerFactory = function ($) {
|
||||
}
|
||||
};
|
||||
$(options.ownerDocument)
|
||||
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
||||
.off('keydown.xdsoftcmd keyup.xdsoftcmd')
|
||||
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
||||
.on('keydown.xdsoftctrl', function (e) {
|
||||
if (e.keyCode === CTRLKEY) {
|
||||
ctrlDown = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
.on('keyup.xdsoftctrl', function (e) {
|
||||
if (e.keyCode === CTRLKEY) {
|
||||
ctrlDown = false;
|
||||
}
|
||||
})
|
||||
.on('keydown.xdsoftcmd', function (e) {
|
||||
if (e.keyCode === CMDKEY) {
|
||||
cmdDown = true;
|
||||
}
|
||||
})
|
||||
.on('keyup.xdsoftcmd', function (e) {
|
||||
if (e.keyCode === CMDKEY) {
|
||||
cmdDown = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.each(function () {
|
||||
|
2
build/jquery.datetimepicker.full.min.js
vendored
2
build/jquery.datetimepicker.full.min.js
vendored
File diff suppressed because one or more lines are too long
2
build/jquery.datetimepicker.min.js
vendored
2
build/jquery.datetimepicker.min.js
vendored
File diff suppressed because one or more lines are too long
@ -627,8 +627,7 @@ var datetimepickerFactory = function ($) {
|
||||
beforeShowDay: null,
|
||||
|
||||
enterLikeTab: true,
|
||||
showApplyButton: false,
|
||||
insideParent: false,
|
||||
showApplyButton: false
|
||||
};
|
||||
|
||||
var dateHelper = null,
|
||||
@ -729,7 +728,8 @@ var datetimepickerFactory = function ($) {
|
||||
}
|
||||
|
||||
var isFormatStandard = function(format){
|
||||
return Object.values(standardFormats).indexOf(format) === -1 ? false : true;
|
||||
return $.map(standardFormats, function (val) { return val })
|
||||
.indexOf(format) === -1 ? false : true;
|
||||
}
|
||||
|
||||
$.extend($.datetimepicker, standardFormats);
|
||||
@ -934,8 +934,7 @@ var datetimepickerFactory = function ($) {
|
||||
KEY9 = 57,
|
||||
_KEY0 = 96,
|
||||
_KEY9 = 105,
|
||||
CTRLKEY = 17,
|
||||
CMDKEY = 91,
|
||||
CTRLKEY = 17,
|
||||
DEL = 46,
|
||||
ENTER = 13,
|
||||
ESC = 27,
|
||||
@ -951,8 +950,7 @@ var datetimepickerFactory = function ($) {
|
||||
VKEY = 86,
|
||||
ZKEY = 90,
|
||||
YKEY = 89,
|
||||
ctrlDown = false,
|
||||
cmdDown = false,
|
||||
ctrlDown = false,
|
||||
options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
|
||||
|
||||
lazyInitTimer = 0,
|
||||
@ -1347,11 +1345,8 @@ var datetimepickerFactory = function ($) {
|
||||
.append(calendar)
|
||||
.append(applyButton);
|
||||
|
||||
if (options.insideParent) {
|
||||
$(input).parent().append(datetimepicker);
|
||||
} else {
|
||||
$(options.parentID).append(datetimepicker);
|
||||
}
|
||||
$(options.parentID)
|
||||
.append(datetimepicker);
|
||||
|
||||
XDSoft_datetime = function () {
|
||||
var _this = this;
|
||||
@ -2177,7 +2172,7 @@ var datetimepickerFactory = function ($) {
|
||||
}
|
||||
});
|
||||
|
||||
if (dateInputHasFixedAncestor && !options.insideParent) {
|
||||
if (dateInputHasFixedAncestor) {
|
||||
position = 'fixed';
|
||||
|
||||
//If the picker won't fit entirely within the viewport then display it above the date input.
|
||||
@ -2217,16 +2212,12 @@ var datetimepickerFactory = function ($) {
|
||||
|
||||
datetimepickerCss = {
|
||||
position: position,
|
||||
left: options.insideParent ? dateInputElem.offsetLeft : left,
|
||||
left: left,
|
||||
top: '', //Initialize to prevent previous values interfering with new ones.
|
||||
bottom: '' //Initialize to prevent previous values interfering with new ones.
|
||||
};
|
||||
|
||||
if (options.insideParent) {
|
||||
datetimepickerCss[verticalAnchorEdge] = dateInputElem.offsetTop + dateInputElem.offsetHeight;
|
||||
} else {
|
||||
datetimepickerCss[verticalAnchorEdge] = verticalPosition;
|
||||
}
|
||||
datetimepickerCss[verticalAnchorEdge] = verticalPosition;
|
||||
|
||||
datetimepicker.css(datetimepickerCss);
|
||||
};
|
||||
@ -2380,7 +2371,7 @@ var datetimepickerFactory = function ($) {
|
||||
setCaretPos(input[0], 0);
|
||||
}
|
||||
|
||||
input.on('paste.xdsoft', function (event) {
|
||||
input.off('paste.xdsoft').on('paste.xdsoft', function (event) {
|
||||
// couple options here
|
||||
// 1. return false - tell them they can't paste
|
||||
// 2. insert over current characters - minimal validation
|
||||
@ -2399,6 +2390,7 @@ var datetimepickerFactory = function ($) {
|
||||
var valueAfterPaste = val.substr(pos + pastedData.length);
|
||||
|
||||
val = valueBeforeCursor + pastedData + valueAfterPaste;
|
||||
val = val.substring(0, options.mask.length)
|
||||
pos += pastedData.length;
|
||||
|
||||
if (isValidValue(options.mask, val)) {
|
||||
@ -2454,12 +2446,8 @@ var datetimepickerFactory = function ($) {
|
||||
// hitting backspace in a selection, you can possibly go back any further - go forward
|
||||
pos += (key === BACKSPACE && !hasSel) ? -1 : 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (event.metaKey) { // cmd has been pressed
|
||||
pos = 0;
|
||||
hasSel = true;
|
||||
}
|
||||
|
||||
if (hasSel) {
|
||||
// pos might have moved so re-calc length
|
||||
@ -2581,27 +2569,16 @@ var datetimepickerFactory = function ($) {
|
||||
}
|
||||
};
|
||||
$(options.ownerDocument)
|
||||
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
||||
.off('keydown.xdsoftcmd keyup.xdsoftcmd')
|
||||
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
||||
.on('keydown.xdsoftctrl', function (e) {
|
||||
if (e.keyCode === CTRLKEY) {
|
||||
ctrlDown = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
.on('keyup.xdsoftctrl', function (e) {
|
||||
if (e.keyCode === CTRLKEY) {
|
||||
ctrlDown = false;
|
||||
}
|
||||
})
|
||||
.on('keydown.xdsoftcmd', function (e) {
|
||||
if (e.keyCode === CMDKEY) {
|
||||
cmdDown = true;
|
||||
}
|
||||
})
|
||||
.on('keyup.xdsoftcmd', function (e) {
|
||||
if (e.keyCode === CMDKEY) {
|
||||
cmdDown = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.each(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user