diff --git a/ChangeLog b/ChangeLog index 577bd26024..4e1afff882 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ phpMyAdmin - ChangeLog + rfe #1479 Relations edit form for larger monitors + rfe #1475 Inline query box vertical resize + rfe #1500 [interface] Add bottom border to top menu container ++ rfe #1498 Add datepicker for 'TIME' type 4.1.7.0 (not yet released) - bug #4245 initial Browse query does not match sorting order diff --git a/js/functions.js b/js/functions.js index 1f2cdb7b00..34bc714930 100644 --- a/js/functions.js +++ b/js/functions.js @@ -194,12 +194,12 @@ function displayPasswordGenerateButton() * * @param object $this_element a jQuery object pointing to the element */ -function PMA_addDatepicker($this_element, options) -{ - var showTimeOption = false; - if ($this_element.is('.datetimefield')) { - showTimeOption = true; - } +function PMA_addDatepicker($this_element, type, options) +{ + var showTimepicker = true; + if (type=="date") { + showTimepicker = false; + } var defaultOptions = { showOn: 'button', @@ -210,7 +210,7 @@ function PMA_addDatepicker($this_element, options) showSecond: true, showMillisec: true, showMicrosec: true, - showTimepicker: showTimeOption, + showTimepicker: showTimepicker, showButtonPanel: false, dateFormat: 'yy-mm-dd', // yy means year with four digits timeFormat: 'HH:mm:ss.lc', @@ -232,10 +232,14 @@ function PMA_addDatepicker($this_element, options) $this_element.data('comes_from', ''); } }; - if (showTimeOption || (typeof(options) != 'undefined' && options.showTimepicker)) { + if (type == "datetime") { $this_element.datetimepicker($.extend(defaultOptions, options)); - } else { - $this_element.datepicker($.extend(defaultOptions, options)); + } + else if (type == "date") { + $this_element.datetimepicker($.extend(defaultOptions, options)); + } + else if (type == "time") { + $this_element.timepicker($.extend(defaultOptions, options)); } } @@ -857,21 +861,21 @@ function insertValueQuery() */ function addDateTimePicker() { if ($.timepicker !== undefined) { - $('input.datefield, input.datetimefield').each(function () { + $('input.timefield, input.datefield, input.datetimefield').each(function () { - no_decimals = $(this).parent().data('decimals'); + no_decimals = $(this).parent().attr('data-decimals'); var showMillisec = false; var showMicrosec = false; var timeFormat = 'HH:mm:ss'; // check for decimal places of seconds - if (($(this).parent().data('decimals') > 0) && ($(this).parent().data('type').indexOf('time') != -1)){ + if (($(this).parent().attr('data-decimals') > 0) && ($(this).parent().attr('data-type').indexOf('time') != -1)){ showMillisec = true; timeFormat = 'HH:mm:ss.lc'; - if ($(this).parent().data('decimals') > 3) { + if ($(this).parent().attr('data-decimals') > 3) { showMicrosec = true; } } - PMA_addDatepicker($(this), { + PMA_addDatepicker($(this), $(this).parent().attr('data-type'), { showMillisec: showMillisec, showMicrosec: showMicrosec, timeFormat: timeFormat, diff --git a/js/makegrid.js b/js/makegrid.js index fa9a90a2ae..0f9c417aaf 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -630,12 +630,12 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi : $this_field.data('value'); //remove decimal places if column type not supported - if (($this_field.data('decimals') == 0) && ( $this_field.data('type').indexOf('time') != -1)){ + if (($this_field.attr('data-decimals') == 0) && ( $this_field.attr('data-type').indexOf('time') != -1)){ new_html = new_html.substring(0, new_html.indexOf('.')); } //remove addtional decimal places - if (($this_field.data('decimals') > 0) && ( $this_field.data('type').indexOf('time') != -1)){ - new_html = new_html.substring(0, new_html.length - (6 - $this_field.data('decimals'))); + if (($this_field.attr('data-decimals') > 0) && ( $this_field.attr('data-type').indexOf('time') != -1)){ + new_html = new_html.substring(0, new_html.length - (6 - $this_field.attr('data-decimals'))); } if ($this_field.is('.truncated')) { if (new_html.length > g.maxTruncatedLen) { @@ -971,99 +971,47 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $editArea.show(); } g.isEditCellTextEditable = true; - } else if ($td.is('.datefield, .datetimefield, .timestampfield')) { + } else if ($td.is('.timefield, .datefield, .datetimefield, .timestampfield')) { var $input_field = $(g.cEdit).find('.edit_box'); // remember current datetime value in $input_field, if it is not null var is_null = $td.is('.null'); - var current_datetime_value = !is_null ? $input_field.val() : ''; - - var showTimeOption = true; - if ($td.is('.datefield')) { - showTimeOption = false; - } + var current_datetime_value = !is_null ? $input_field.val() : ''; var showMillisec = false; var showMicrosec = false; var timeFormat = 'HH:mm:ss'; // check for decimal places of seconds - if (($td.data('decimals') > 0) && ($td.data('type').indexOf('time') != -1)){ + if (($td.attr('data-decimals') > 0) && ($td.attr('data-type').indexOf('time') != -1)){ showMillisec = true; timeFormat = 'HH:mm:ss.lc'; - if ($td.data('decimals') > 3) { + if ($td.attr('data-decimals') > 3) { showMicrosec = true; } } - PMA_addDatepicker($editArea, { + // add datetime picker + PMA_addDatepicker($input_field, $td.attr('data-type'), { showMillisec: showMillisec, showMicrosec: showMicrosec, - timeFormat: timeFormat, - altField: $input_field, - showTimepicker: showTimeOption, - onSelect: function (dateText, inst) { - // remove null checkbox if it exists - $(g.cEdit).find('.null_div input[type=checkbox]').prop('checked', false); - } + timeFormat: timeFormat }); + $input_field.datepicker("show"); + + var edit_area_top = $('#ui-datepicker-div').height()+32; + $('.edit_area').css({'top' : edit_area_top+'px', 'position': 'absolute'}); + + if(is_null){ + $('.edit_area').hide(); + } + // cancel any click on the datepicker element $editArea.find('> *').click(function (e) { e.stopPropagation(); }); - // force to restore modified $input_field value after adding datepicker - // (after adding a datepicker, the input field doesn't display the time anymore, only the date) - if (is_null - || current_datetime_value == '0000-00-00' - || current_datetime_value == '0000-00-00 00:00:00.000000' - ) { - $input_field.val(current_datetime_value); - } else { - var date = new Date( - current_datetime_value.substring(0, 4), - parseInt(current_datetime_value.substring(5, 7)) - 1, - parseInt(current_datetime_value.substring(8, 10)) - ); - var no_decimals = $td.data('decimals'); - - var hour = current_datetime_value.substring(11, 13); - var min = current_datetime_value.substring(14, 16); - var sec = current_datetime_value.substring(17, 19); - if (current_datetime_value.match("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{"+ no_decimals +"}$")) { - if (no_decimals > 3){ - var milli = current_datetime_value.substring(20, 23); - var micro = current_datetime_value.substring(23); - for (var i = 0; i < 6-no_decimals ; i++) { - micro += "0"; - } - } - if (no_decimals <= 3){ - var milli = current_datetime_value.substring(20); - for (var i = 0; i < 3-no_decimals ; i++) { - milli += "0"; - } - var micro = "000"; - } - - date.setHours(hour, min, sec, milli); - date.setMicroseconds(micro); - } - if (current_datetime_value.match("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}")) { - console.log("G"); - date.setHours(hour, min, sec); - } - $editArea.datetimepicker('setDate', date); - } - $editArea.append('