r79334 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79333‎ | r79334 | r79335 >
Date:11:41, 31 December 2010
Author:foxtrott
Status:deferred
Tags:
Comment:
bugfix

datepicker will not choke on badly formatted dates anymore
Modified paths:
  • /trunk/extensions/SemanticFormsInputs/SFI_Inputs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticFormsInputs/SFI_Inputs.php
@@ -840,12 +840,7 @@
841841 // assemble JS code to attach datepicker to input field
842842 $jstext = <<<JAVASCRIPT
843843 jQuery("#" + inputId + "_show").datepicker( $jsattribsString );
844 - jQuery("#" + inputId + "_show").datepicker( "setDate", jQuery.datepicker.parseDate("yy/mm/dd", "$cur_value", null) );
845844 jQuery("#" + inputId + "_show").datepicker( "option", "altField", "#" + inputId);
846 - jQuery("#" + inputId + "_show").change(function() {
847 - jQuery("#" + inputId ).attr("value", jQuery.datepicker.parseDate(jQuery(this).datepicker( "option", "dateFormat"), jQuery(this).attr("value"), null));
848 - });
849 -
850845 JAVASCRIPT;
851846
852847 // append setting of first date
@@ -952,10 +947,27 @@
953948 JAVASCRIPT;
954949 }
955950
956 - // wrap the JS code fragment in a function which can be called by SF for deferred init
 951+ // set value of datepicker, attach event listener for keyboard input
 952+ // and wrap the JS code fragment in a function which can be called
 953+ // by SF for deferred init
957954 $jstext = <<<JAVASCRIPT
958955 function initInput$sfgFieldNum(inputId) {
959956 $jstext
 957+ try {
 958+ jQuery("#" + inputId + "_show").datepicker( "setDate", jQuery.datepicker.parseDate("yy/mm/dd", "$cur_value", null) );
 959+ } catch (e) {
 960+ jQuery("#" + inputId + "_show").attr("value", "$cur_value");
 961+ jQuery("#" + inputId).attr("value", "$cur_value");
 962+ }
 963+
 964+ jQuery("#" + inputId + "_show").change(function() {
 965+ try {
 966+ jQuery("#" + inputId ).attr("value", jQuery.datepicker.parseDate(jQuery(this).datepicker( "option", "dateFormat"), jQuery(this).attr("value"), null));
 967+ } catch (e) {
 968+ jQuery("#" + inputId).attr("value", jQuery(this).attr("value"));
 969+ }
 970+ });
 971+
960972 }
961973
962974 addOnloadHook(function(){initInput$sfgFieldNum("input_$sfgFieldNum");});

Follow-up revisions

RevisionCommit summaryAuthorDate
r79339Followup r79334. more bugfixes...foxtrott14:51, 31 December 2010

Status & tagging log