r105019 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105018‎ | r105019 | r105020 >
Date:22:57, 2 December 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
fix bug 29257 (Datepicker does not save a date entered via browser's autocompletion)
Modified paths:
  • /trunk/extensions/SemanticFormsInputs/libs/datepicker.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticFormsInputs/libs/datepicker.js
@@ -56,7 +56,7 @@
5757 inputShow.after( resetbutton );
5858 resetbutton.click( function(){
5959 inputShow.datepicker( 'setDate', null);
60 - })
 60+ });
6161 }
6262
6363 inputShow.datepicker( {
@@ -76,10 +76,6 @@
7777 'beforeShowDay': function ( date ) {return SFI_DP_checkDate( '#' + input_id + '_show', date );}
7878 } );
7979
80 - if ( ! params.partOfDTP ) {
81 - inputShow.datepicker( 'option', 'altField', input );
82 - }
83 -
8480 if ( params.minDate ) {
8581 inputShow.datepicker( 'option', 'minDate',
8682 jQuery.datepicker.parseDate( 'yy/mm/dd', params.minDate, null ) );
@@ -144,14 +140,23 @@
145141 }
146142 }
147143
148 - // delete date when user deletes input field
149 - inputShow.change(function() {
 144+ if ( ! params.partOfDTP ) {
150145
151 - if ( this.value == '' ) {
152 - inputShow.datepicker( 'setDate', null );
153 - }
154 -
155 - });
 146+ inputShow.datepicker( 'option', 'altField', input );
 147+
 148+ // when the input loses focus set the date value
 149+ inputShow.change( function(){
 150+ // try parsing the value
 151+ try {
 152+ var value = jQuery.datepicker.parseDate( params.dateFormat, this.value, null );
 153+ input.val( jQuery.datepicker.formatDate( 'yy/mm/dd', value ) );
 154+ } catch ( e ) {
 155+ // value does not conform to specified format
 156+ // just return the value as is
 157+ input.val( this.value );
 158+ }
 159+ });
 160+ }
156161 }
157162 }
158163