Index: trunk/extensions/SemanticFormsInputs/SemanticFormsInputs.php |
— | — | @@ -3,9 +3,13 @@ |
4 | 4 | * Additional input types for [http://www.mediawiki.org/wiki/Extension:SemanticForms Semantic Forms]. |
5 | 5 | * |
6 | 6 | * @defgroup SFI Semantic Forms Inputs |
| 7 | + * |
7 | 8 | * @author Stephan Gambke |
| 9 | + * @author Yaron Koren |
| 10 | + * @author Jeroen de Dauw |
8 | 11 | * @author Sanyam Goyal |
9 | | - * @version 0.4.2 alpha |
| 12 | + * |
| 13 | + * @version 0.5 |
10 | 14 | */ |
11 | 15 | |
12 | 16 | /** |
— | — | @@ -23,11 +27,11 @@ |
24 | 28 | 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.' ); |
25 | 29 | } |
26 | 30 | |
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.' ); |
29 | 33 | } |
30 | 34 | |
31 | | -define( 'SFI_VERSION', '0.4.2 alpha' ); |
| 35 | +define( 'SFI_VERSION', '0.5' ); |
32 | 36 | |
33 | 37 | // create and initialize settings |
34 | 38 | $sfigSettings = new SFISettings(); |
— | — | @@ -36,7 +40,7 @@ |
37 | 41 | $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'other'][] = array( |
38 | 42 | 'path' => __FILE__, |
39 | 43 | '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' ), |
41 | 45 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Forms_Inputs', |
42 | 46 | 'descriptionmsg' => 'semanticformsinputs-desc', |
43 | 47 | 'version' => SFI_VERSION, |
— | — | @@ -63,7 +67,6 @@ |
64 | 68 | class SFISettings { |
65 | 69 | // general settings |
66 | 70 | public $scriptPath; |
67 | | - //public $yuiBase; |
68 | 71 | |
69 | 72 | // settings for input type datepicker |
70 | 73 | public $datePickerFirstDate; |
Index: trunk/extensions/SemanticFormsInputs/libs/datetimepicker.js |
— | — | @@ -10,13 +10,21 @@ |
11 | 11 | |
12 | 12 | var input = jQuery( '#' + inputId ); |
13 | 13 | |
| 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 | + |
14 | 25 | // create and insert subinput elements |
15 | | - var subinputs = jQuery( params.subinputs ); |
| 26 | + var subinputs = jQuery( params.subinputs ); |
16 | 27 | input.before( subinputs ); |
17 | 28 | |
18 | | - // hide datetimepicker's true input |
19 | | - input.attr('hidden', 'hidden'); |
20 | | - |
21 | 29 | // call initialisation functions for subinputs |
22 | 30 | for (var subinputId in params.subinputsInitData) { |
23 | 31 | |
— | — | @@ -36,11 +44,24 @@ |
37 | 45 | |
38 | 46 | dp.add(tp) |
39 | 47 | .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 | + }); |
45 | 66 | |
46 | 67 | if ( params.resetButtonImage ) { |
47 | 68 | |
— | — | @@ -52,7 +73,7 @@ |
53 | 74 | } else { |
54 | 75 | |
55 | 76 | 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 ); |
57 | 78 | |
58 | 79 | resetbutton.click( function(){ |
59 | 80 | |
Index: trunk/extensions/SemanticFormsInputs/libs/timepicker.js |
— | — | @@ -128,23 +128,23 @@ |
129 | 129 | // build html structure |
130 | 130 | var sp = jQuery( '<span class="SFI_timepicker" id="' + inputID + '_tree" ></span>' ).insertBefore( '#' + inputIDshow ); |
131 | 131 | |
132 | | - var ulh = jQuery( '<ul>' ).appendTo( sp ); |
| 132 | + var ulh = jQuery( '<ul class="SFI_timepicker_hours" >' ).appendTo( sp ); |
133 | 133 | |
134 | 134 | |
135 | 135 | for ( var h = minh; h <= maxh; ++h ) { |
136 | 136 | |
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 ); |
138 | 138 | |
139 | 139 | //TODO: Replace value for "show" by formatted string |
140 | 140 | lih |
141 | 141 | .data( 'value', ( ( h < 10 ) ? '0' : '' ) + h + ':00' ) |
142 | 142 | .data( 'show', ( ( h < 10 ) ? '0' : '' ) + h + ':00' ); |
143 | 143 | |
144 | | - var ulm = jQuery( '<ul>' ).appendTo( lih ); |
| 144 | + var ulm = jQuery( '<ul class="SFI_timepicker_minutes" >' ).appendTo( lih ); |
145 | 145 | |
146 | 146 | for ( var m = ( (h == minh) ? minm : 0 ) ; m <= ( (h == maxh) ? maxm : 59 ); m += interv ) { |
147 | 147 | |
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 ); |
149 | 149 | |
150 | 150 | //TODO: Replace value for "show" by formatted string |
151 | 151 | lim |