Merge remote-tracking branch 'origin/pull/12666' into QA_4_6

This commit is contained in:
Michal Čihař 2016-11-08 14:48:16 +01:00
commit 9df6c8258c
4 changed files with 51 additions and 4 deletions

View File

@ -188,9 +188,12 @@ function addDateTimePicker() {
timeFormat: timeFormat
});
// Add a tip regarding entering MySQL allowed-values for TIME data-type
// Add a tip regarding entering MySQL allowed-values
// for TIME and DATE data-type
if ($(this).hasClass('timefield')) {
PMA_tooltip($(this), 'input', PMA_messages.strMysqlAllowedValuesTip);
PMA_tooltip($(this), 'input', PMA_messages.strMysqlAllowedValuesTipTime);
} else if ($(this).hasClass('datefield')) {
PMA_tooltip($(this), 'input', PMA_messages.strMysqlAllowedValuesTipDate);
}
});
}
@ -4939,6 +4942,30 @@ function PMA_ignorePhpErrors(clearPrevErrors){
$pmaErrors.remove();
}
/**
* Toggle the Datetimepicker UI if the date value entered
* by the user in the 'text box' is not going to be accepted
* by the Datetimepicker plugin (but is accepted by MySQL)
*/
function toggleDatepickerIfInvalid($td, $input_field) {
// Regex allowed by the Datetimepicker UI
var dtexpDate = new RegExp(['^([0-9]{4})',
'-(((01|03|05|07|08|10|12)-((0[1-9])|([1-2][0-9])|(3[0-1])))|((02|04|06|09|11)',
'-((0[1-9])|([1-2][0-9])|30)))$'].join(''));
var dtexpTime = new RegExp(['^(([0-1][0-9])|(2[0-3]))',
':((0[0-9])|([1-5][0-9]))',
':((0[0-9])|([1-5][0-9]))(\.[0-9]{1,6}){0,1}$'].join(''));
// If key-ed in Time or Date values are unsupported by the UI, close it
if ($td.attr('data-type') === 'date' && ! dtexpDate.test($input_field.val())) {
$input_field.datepicker('hide');
} else if ($td.attr('data-type') === 'time' && ! dtexpTime.test($input_field.val())) {
$input_field.datepicker('hide');
} else {
$input_field.datepicker('show');
}
}
/**
* Unbind all event handlers before tearing down a page
*/

View File

@ -1051,7 +1051,21 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
timeFormat: timeFormat
});
$input_field.on('keyup', function (e) {
if (e.which == 13) {
// post on pressing "Enter"
e.preventDefault();
e.stopPropagation();
g.saveOrPostEditedCell();
} else if (e.which == 27) {
} else {
toggleDatepickerIfInvalid($td, $input_field);
}
});
$input_field.datepicker("show");
toggleDatepickerIfInvalid($td, $input_field);
// unbind the mousedown event to prevent the problem of
// datepicker getting closed, needs to be checked for any
// change in names when updating

View File

@ -518,11 +518,17 @@ $js_messages['strCopyEncryptionKey'] = __('Do you want to copy encryption key?')
$js_messages['strEncryptionKey'] = __('Encryption key');
/* For Tip to be shown on Time field */
$js_messages['strMysqlAllowedValuesTip'] = __(
$js_messages['strMysqlAllowedValuesTipTime'] = __(
'MySQL accepts additional values not selectable by the slider;'
. ' key in those values directly if desired'
);
/* For Tip to be shown on Date field */
$js_messages['strMysqlAllowedValuesTipDate'] = __(
'MySQL accepts additional values not selectable by the datepicker;'
. ' key in those values directly if desired'
);
/* For Lock symbol Tooltip */
$js_messages['strLockToolTip'] = __(
'Indicates that you have made changes to this page;'

View File

@ -100,7 +100,7 @@ function isDate(val, tmstmp)
}
val = arrayVal.join("-");
var pos = 2;
var dtexp = new RegExp(/^([0-9]{4})-(((01|03|05|07|08|10|12)-((0[1-9])|([1-2][0-9])|(3[0-1])))|((02|04|06|09|11)-((0[1-9])|([1-2][0-9])|30)))$/);
var dtexp = new RegExp(/^([0-9]{4})-(((01|03|05|07|08|10|12)-((0[0-9])|([1-2][0-9])|(3[0-1])))|((02|04|06|09|11)-((0[0-9])|([1-2][0-9])|30))|((00)-(00)))$/);
if (val.length == 8) {
pos = 0;
}