r105024 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105023‎ | r105024 | r105025 >
Date:23:13, 2 December 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
bugfixes and more refactoring for timepicker and datetimpicker; preparation of version 0.5
Modified paths:
  • /trunk/extensions/SemanticFormsInputs/SemanticFormsInputs.php (modified) (history)
  • /trunk/extensions/SemanticFormsInputs/libs/datetimepicker.js (modified) (history)
  • /trunk/extensions/SemanticFormsInputs/libs/timepicker.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticFormsInputs/SemanticFormsInputs.php
@@ -3,9 +3,13 @@
44 * Additional input types for [http://www.mediawiki.org/wiki/Extension:SemanticForms Semantic Forms].
55 *
66 * @defgroup SFI Semantic Forms Inputs
 7+ *
78 * @author Stephan Gambke
 9+ * @author Yaron Koren
 10+ * @author Jeroen de Dauw
811 * @author Sanyam Goyal
9 - * @version 0.4.2 alpha
 12+ *
 13+ * @version 0.5
1014 */
1115
1216 /**
@@ -23,11 +27,11 @@
2428 die( '<b>Error:</b> <a href="https://www.mediawiki.org/wiki/Extension:Semantic_Forms_Inputs">Semantic Forms Inputs</a> is a Semantic Forms extension. You need to install <a href="https://www.mediawiki.org/wiki/Extension:Semantic_Forms">Semantic Forms</a> first.' );
2529 }
2630
27 -if ( version_compare( '2.3', SF_VERSION ) != -1 ) {
28 - die( '<b>Error:</b> This version of <a href="https://www.mediawiki.org/wiki/Extension:Semantic_Forms_Inputs">Semantic Forms Inputs</a> is only compatible with Semantic Forms 2.4 or above. You need to upgrade <a href="https://www.mediawiki.org/wiki/Extension:Semantic_Forms">Semantic Forms</a> first.' );
 31+if ( version_compare( '2.3.1', SF_VERSION ) != -1 ) {
 32+ die( '<b>Error:</b> This version of <a href="https://www.mediawiki.org/wiki/Extension:Semantic_Forms_Inputs">Semantic Forms Inputs</a> is only compatible with Semantic Forms 2.3.1 or above. You need to upgrade <a href="https://www.mediawiki.org/wiki/Extension:Semantic_Forms">Semantic Forms</a> first.' );
2933 }
3034
31 -define( 'SFI_VERSION', '0.4.2 alpha' );
 35+define( 'SFI_VERSION', '0.5' );
3236
3337 // create and initialize settings
3438 $sfigSettings = new SFISettings();
@@ -36,7 +40,7 @@
3741 $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'other'][] = array(
3842 'path' => __FILE__,
3943 'name' => 'Semantic Forms Inputs',
40 - 'author' => array( '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]', 'Sanyam Goyal', 'Yaron Koren' ),
 44+ 'author' => array( '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]', 'others' ),
4145 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Forms_Inputs',
4246 'descriptionmsg' => 'semanticformsinputs-desc',
4347 'version' => SFI_VERSION,
@@ -63,7 +67,6 @@
6468 class SFISettings {
6569 // general settings
6670 public $scriptPath;
67 - //public $yuiBase;
6871
6972 // settings for input type datepicker
7073 public $datePickerFirstDate;
Index: trunk/extensions/SemanticFormsInputs/libs/datetimepicker.js
@@ -10,13 +10,21 @@
1111
1212 var input = jQuery( '#' + inputId );
1313
 14+ var hiddenInput = jQuery( '<input type="hidden" >' );
 15+
 16+ hiddenInput.attr( {
 17+ id: inputId,
 18+ name: input.attr( 'name' ),
 19+ value: input.val()
 20+ } );
 21+
 22+ input.replaceWith( hiddenInput );
 23+ input = hiddenInput;
 24+
1425 // create and insert subinput elements
15 - var subinputs = jQuery( params.subinputs );
 26+ var subinputs = jQuery( params.subinputs );
1627 input.before( subinputs );
1728
18 - // hide datetimepicker's true input
19 - input.attr('hidden', 'hidden');
20 -
2129 // call initialisation functions for subinputs
2230 for (var subinputId in params.subinputsInitData) {
2331
@@ -36,11 +44,24 @@
3745
3846 dp.add(tp)
3947 .change (function(){
40 - input.val(
41 - jQuery.datepicker.formatDate( dp.datepicker( 'option', 'altFormat' ), dp.datepicker( 'getDate' ), null ) +
42 - ' ' + tp.val()
43 - );
44 - })
 48+
 49+ var date;
 50+
 51+ // try parsing the date value
 52+ try {
 53+
 54+ date = jQuery.datepicker.parseDate( dp.datepicker( 'option', 'dateFormat' ), dp.val(), null );
 55+ date = jQuery.datepicker.formatDate( dp.datepicker( 'option', 'altFormat' ), date );
 56+
 57+ } catch ( e ) {
 58+ // value does not conform to specified format
 59+ // just return the value as is
 60+ date = dp.val();
 61+ }
 62+
 63+ input.val( jQuery.trim( date + ' ' + tp.val() ) );
 64+
 65+ });
4566
4667 if ( params.resetButtonImage ) {
4768
@@ -52,7 +73,7 @@
5374 } else {
5475
5576 var resetbutton = jQuery('<button type="button" class="ui-datetimepicker-trigger ' + params.userClasses + '" ><img src="' + params.resetButtonImage + '" alt="..." title="..."></button>');
56 - tp.parent().append( resetbutton );
 77+ input.before( resetbutton );
5778
5879 resetbutton.click( function(){
5980
Index: trunk/extensions/SemanticFormsInputs/libs/timepicker.js
@@ -128,23 +128,23 @@
129129 // build html structure
130130 var sp = jQuery( '<span class="SFI_timepicker" id="' + inputID + '_tree" ></span>' ).insertBefore( '#' + inputIDshow );
131131
132 - var ulh = jQuery( '<ul>' ).appendTo( sp );
 132+ var ulh = jQuery( '<ul class="SFI_timepicker_hours" >' ).appendTo( sp );
133133
134134
135135 for ( var h = minh; h <= maxh; ++h ) {
136136
137 - var lih = jQuery( '<li class="ui-state-default">' + ( ( h < 10 ) ? '0' : '' ) + h + '</li>' ).appendTo( ulh );
 137+ var lih = jQuery( '<li class="ui-state-default SFI_timepicker_hour">' + ( ( h < 10 ) ? '0' : '' ) + h + '</li>' ).appendTo( ulh );
138138
139139 //TODO: Replace value for "show" by formatted string
140140 lih
141141 .data( 'value', ( ( h < 10 ) ? '0' : '' ) + h + ':00' )
142142 .data( 'show', ( ( h < 10 ) ? '0' : '' ) + h + ':00' );
143143
144 - var ulm = jQuery( '<ul>' ).appendTo( lih );
 144+ var ulm = jQuery( '<ul class="SFI_timepicker_minutes" >' ).appendTo( lih );
145145
146146 for ( var m = ( (h == minh) ? minm : 0 ) ; m <= ( (h == maxh) ? maxm : 59 ); m += interv ) {
147147
148 - var lim = jQuery( '<li class="ui-state-default">' + ( ( m < 10 ) ? '0' : '' ) + m + '</li>' ).appendTo( ulm );
 148+ var lim = jQuery( '<li class="ui-state-default SFI_timepicker_minute">' + ( ( m < 10 ) ? '0' : '' ) + m + '</li>' ).appendTo( ulm );
149149
150150 //TODO: Replace value for "show" by formatted string
151151 lim