diff --git a/js/functions.js b/js/functions.js
index 5498f930c..6559b34e9 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -55,6 +55,37 @@ function displayPasswordGenerateButton() {
$('#div_element_before_generate_password').parent().append('
');
}
+/*
+ * Adds a date/time picker to an element
+ *
+ * @param object $this_element a jQuery object pointing to the element
+ */
+function PMA_addDatepicker($this_element) {
+ var showTimeOption = false;
+ if ($this_element.is('.datetimefield')) {
+ showTimeOption = true;
+ }
+
+ $this_element
+ .datepicker({
+ showOn: 'button',
+ buttonImage: themeCalendarImage, // defined in js/messages.php
+ buttonImageOnly: true,
+ duration: '',
+ time24h: true,
+ stepMinutes: 1,
+ stepHours: 1,
+ showTime: showTimeOption,
+ dateFormat: 'yy-mm-dd', // yy means year with four digits
+ altTimeField: '',
+ beforeShow: function(input, inst) {
+ // Remember that we came from the datepicker; this is used
+ // in tbl_change.js by verificationsAfterFieldChange()
+ $this_element.data('comes_from', 'datepicker');
+ },
+ constrainInput: false
+ });
+}
/**
* selects the content of a given object, f.e. a textarea
@@ -845,17 +876,24 @@ function checkTransmitDump(theForm, theAction)
return true;
} // end of the 'checkTransmitDump()' function
-/**
- * Row marking in horizontal mode (use "live" so that it works also for
- * next pages reached via AJAX); a tr may have the class noclick to remove
- * this behavior.
- */
$(document).ready(function() {
+ /**
+ * Row marking in horizontal mode (use "live" so that it works also for
+ * next pages reached via AJAX); a tr may have the class noclick to remove
+ * this behavior.
+ */
$('tr.odd:not(.noclick), tr.even:not(.noclick)').live('click',function() {
var $tr = $(this);
$tr.toggleClass('marked');
$tr.children().toggleClass('marked');
});
+
+ /**
+ * Add a date/time picker to each element that needs it
+ */
+ $('.datefield, .datetimefield').each(function() {
+ PMA_addDatepicker($(this));
+ });
})
/**
diff --git a/js/messages.php b/js/messages.php
index c8ff9f907..f9f764e24 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -115,6 +115,7 @@ foreach ($js_messages as $name => $js_message) {
}
/* Calendar */
+echo "var themeCalendarImage = '" . $GLOBALS['pmaThemeImage'] . 'b_calendar.png' . "';\n";
echo "if ($.datepicker) {\n";
/* l10n: Display text for calendar close link */
PMA_printJsValue("$.datepicker.regional['']['closeText']", __('Done'));
diff --git a/tbl_change.php b/tbl_change.php
index 4ba5144af..2ce434d60 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -942,10 +942,16 @@ foreach ($rows as $row_id => $vrow) {
>
+ class=""
tabindex=""
id="field__3" />
$vrow) {
// the _3 suffix points to the date field
// the _2 suffix points to the corresponding NULL checkbox
// in dateFormat, 'yy' means the year with 4 digits
- ?>
-
- ' . "\n";
} else {
// o t h e r c a s e s
+ $the_class = 'textfield';
+ $type = $fields_type[$i];
+ if ($type == 'date') {
+ $the_class .= ' datefield';
+ } elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
+ $the_class .= ' datetimefield';
+ }
echo ' ' . "\n";
+ .' size="40" class="' . $the_class . '" id="field_' . $i . '" />' . "\n";
};
- $type = $fields_type[$i];
- if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
- ?>
-
-