The branch, master has been updated via 9adcdc08d96f991cb05ffd65ac3cba396e80f158 (commit) from d7854c2dacb7d000eb2d722594490149fcf27017 (commit)
- Log ----------------------------------------------------------------- commit 9adcdc08d96f991cb05ffd65ac3cba396e80f158 Author: Marc Delisle marc@infomarc.info Date: Sun Jan 16 11:36:29 2011 -0500
Replace inline Javascript by a function that attaches a date/time picker to the elements which need it
-----------------------------------------------------------------------
Summary of changes: js/functions.js | 48 +++++++++++++++++++++++++++++++++++++++++++----- js/messages.php | 1 + tbl_change.php | 33 +++++++-------------------------- tbl_select.php | 33 ++++++++------------------------- 4 files changed, 59 insertions(+), 56 deletions(-)
diff --git a/js/functions.js b/js/functions.js index 5498f93..6559b34 100644 --- a/js/functions.js +++ b/js/functions.js @@ -55,6 +55,37 @@ function displayPasswordGenerateButton() { $('#div_element_before_generate_password').parent().append('<div class="item"><label for="button_generate_password">' + PMA_messages['strGeneratePassword'] + ':</label><span class="options"><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /></span><input type="text" name="generated_pw" id="generated_pw" /></div>'); }
+/* + * 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 c8ff9f9..f9f764e 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 4ba5144..2ce434d 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -942,10 +942,16 @@ foreach ($rows as $row_id => $vrow) { ><?php echo $special_chars_encoded; ?></textarea> <?php } else { + $the_class = 'textfield'; + if ($field['pma_type'] == 'date') { + $the_class .= ' datefield'; + } elseif ($field['pma_type'] == 'datetime' || substr($field['pma_type'], 0, 9) == 'timestamp') { + $the_class .= ' datetimefield'; + } ?> <input type="text" name="fields<?php echo $field_name_appendix; ?>" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" - class="textfield" <?php echo $unnullify_trigger; ?> + class="<?php echo $the_class; ?>" <?php echo $unnullify_trigger; ?> tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3" /> <?php @@ -973,31 +979,6 @@ foreach ($rows as $row_id => $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 - ?> -<script type="text/javascript"> -//<![CDATA[ -$(function() { - $('#field_<?php echo ($idindex); ?>_3').datepicker({ - showOn: 'button', - buttonImage: '<?php echo $GLOBALS['pmaThemeImage'] . 'b_calendar.png'; ?>', - buttonImageOnly: true, - duration: '', - time24h: true, - stepMinutes: 1, - stepHours: 1, - <?php echo ($field['pma_type'] == 'date' ? "showTime: false,":"showTime: true,"); ?> - dateFormat: 'yy-mm-dd', // yy means year with four digits - altTimeField: '', - beforeShow: function(input, inst) { - // Remember that we came from the datepicker - $(input).data('comes_from', 'datepicker'); - }, - constrainInput: false - }); -}); -//]]> -</script> - <?php } } } diff --git a/tbl_select.php b/tbl_select.php index dacf59c..08bc546 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -201,33 +201,16 @@ if (!isset($param) || $param[0] == '') { echo ' </select>' . "\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 ' <input type="text" name="fields[' . $i . ']"' - .' size="40" class="textfield" id="field_' . $i . '" />' . "\n"; + .' size="40" class="' . $the_class . '" id="field_' . $i . '" />' . "\n"; }; - $type = $fields_type[$i]; - if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') { - ?> -<script type="text/javascript"> -//<![CDATA[ -$(function() { - $('#field_<?php echo $i; ?>').datepicker({ - showOn: 'button', - buttonImage: '<?php echo $GLOBALS['pmaThemeImage'] . 'b_calendar.png'; ?>', - buttonImageOnly: true, - duration: '', - time24h: true, - stepMinutes: 1, - stepHours: 1, - <?php echo ($type == 'date' ? "showTime: false,":"showTime: true,"); ?> - dateFormat: 'yy-mm-dd', // yy means year with four digits - altTimeField: '', - constrainInput: false - }); -}); -//]]> -</script> - <?php - } ?> <input type="hidden" name="names[<?php echo $i; ?>]" value="<?php echo htmlspecialchars($fields_list[$i]); ?>" />
hooks/post-receive