Index: branches/salvatoreingala/Gadgets/Gadgets_body.php |
— | — | @@ -658,7 +658,7 @@ |
659 | 659 | $count = 0; //count of present mandatory members |
660 | 660 | foreach ( $optionDefinition as $fieldName => $fieldValue ) { |
661 | 661 | |
662 | | - if ( strcmp( $fieldName, 'type' ) == 0) { |
| 662 | + if ( $fieldName == 'type' ) { |
663 | 663 | continue; //'type' must not be checked |
664 | 664 | } |
665 | 665 | |
Property changes on: branches/salvatoreingala/Gadgets/Gadgets_body.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
666 | 666 | Merged /trunk/extensions/Gadgets/Gadgets_body.php:r88718-89450 |
Index: branches/salvatoreingala/Gadgets/Gadgets.i18n.php |
— | — | @@ -43,9 +43,17 @@ |
44 | 44 | <pre>$2</pre> |
45 | 45 | You must have appropriate permissions on destination wiki (including the right to edit system messages) and import from file uploads must be enabled.', |
46 | 46 | 'gadgets-export-download' => 'Download', |
| 47 | + 'gadgets-configure' => 'Configure', |
| 48 | + 'gadgets-configuration-of' => 'Configuration of $1', |
| 49 | + 'gadgets-unexpected-error' => 'An unexpected error occurred. Please check your connection. If the problems persists, please contact the developers.', |
| 50 | + 'gadgets-save-success' => 'Settings saved successfully.', |
| 51 | + 'gadgets-save-failed' => 'Failed to save settings. If the problems persists, please contact the developers.', |
47 | 52 | 'gadgets-ajax-wrongparams' => 'An AJAX request with wrong parameters has been made; this is most likely a bug.', |
48 | 53 | 'gadgets-ajax-wrongsyntax' => 'There was an unexpected error while reading the saved gadget\'s configuration description.', |
49 | 54 | 'gadgets-ajax-unlogged' => 'This action is only allowed to registered, logged in users.', |
| 55 | + 'gadgets-formbuilder-required' => 'This field is required.', |
| 56 | + 'gadgets-formbuilder-minlength' => 'Please enter at least $1 characters.', |
| 57 | + 'gadgets-formbuilder-maxlength' => 'Please enter no more than $1 characters.', |
50 | 58 | ); |
51 | 59 | |
52 | 60 | /** Message documentation (Message documentation) |
— | — | @@ -510,10 +518,14 @@ |
511 | 519 | 'gadgets-pagetext' => 'Nedenstående er en liste med de specielle gadgets som brugere kan aktivere i deres [[Special:Preferences|indstillinger]], som defineret i [[MediaWiki:Gadgets-definition|definitionerne]]. |
512 | 520 | Denne oversigtsside giver simpel adgang til de beskedsider som definerer hver gadgets beskrivelse og kode.', |
513 | 521 | 'gadgets-uses' => 'Bruger', |
| 522 | + 'gadgets-required-rights' => 'Kræver {{PLURAL:$2|rettigheden $1|følgende rettigheder: $1}}.', |
514 | 523 | 'gadgets-default' => 'Aktiveret for alle som standard.', |
515 | 524 | 'gadgets-export' => 'Eksporter', |
516 | 525 | 'gadgets-export-title' => 'Eksporter gadget', |
517 | 526 | 'gadgets-not-found' => 'Gadget "$1" ikke fundet.', |
| 527 | + 'gadgets-export-text' => 'For at eksportere værktøjet $1, klik på knappen "{{int:gadgets-export-download}}", gem den downloadede fil, gå til Special:Import på destinationswikien og læg den op. Tilføj så følgende til siden MediaWiki:Gadgets-definition: |
| 528 | +<pre>$2</pre> |
| 529 | +Du skal have de nødvendige rettigheder på destinationswikien (herunder rettigheden til at redigere systemmeddelelser) og importering via oplægning af filer skal være slået til.', |
518 | 530 | 'gadgets-export-download' => 'Download', |
519 | 531 | ); |
520 | 532 | |
Index: branches/salvatoreingala/Gadgets/Gadgets.php |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | ); |
65 | 65 | |
66 | 66 | $wgResourceModules['jquery.validate'] = array( |
67 | | - 'scripts' => array( 'jquery.validate.js' ), //TODO: include i18n scripts? |
| 67 | + 'scripts' => array( 'jquery.validate.js' ), |
68 | 68 | 'dependencies' => array( 'jquery' ), |
69 | 69 | 'localBasePath' => $dir . 'modules/', |
70 | 70 | 'remoteExtPath' => 'Gadgets/modules' |
— | — | @@ -72,13 +72,21 @@ |
73 | 73 | $wgResourceModules['jquery.formBuilder'] = array( |
74 | 74 | 'scripts' => array( 'jquery.formBuilder.js' ), |
75 | 75 | 'dependencies' => array( 'jquery', 'jquery.validate' ), |
| 76 | + 'messages' => array( 'gadgets-formbuilder-required', 'gadgets-formbuilder-minlength', 'gadgets-formbuilder-maxlength' ), |
76 | 77 | 'localBasePath' => $dir . 'modules/', |
77 | 78 | 'remoteExtPath' => 'Gadgets/modules' |
78 | 79 | ); |
79 | 80 | |
80 | 81 | $wgResourceModules['ext.gadgets.preferences'] = array( |
81 | 82 | 'scripts' => array( 'ext.gadgets.preferences.js' ), |
82 | | - 'dependencies' => array( 'jquery', 'jquery.json', 'jquery.ui.dialog', 'jquery.formBuilder', 'mediawiki.htmlform', 'ext.gadgets' ), |
| 83 | + 'dependencies' => array( |
| 84 | + 'jquery', 'jquery.json', 'jquery.ui.dialog', 'jquery.formBuilder', |
| 85 | + 'mediawiki.htmlform', 'ext.gadgets' |
| 86 | + ), |
| 87 | + 'messages' => array( |
| 88 | + 'gadgets-configure', 'gadgets-configuration-of', 'gadgets-unexpected-error', |
| 89 | + 'gadgets-save-success', 'gadgets-save-failed' |
| 90 | + ), |
83 | 91 | 'localBasePath' => $dir . 'modules/', |
84 | 92 | 'remoteExtPath' => 'Gadgets/modules' |
85 | 93 | ); |
Index: branches/salvatoreingala/Gadgets/modules/jquery.formBuilder.js |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | function EmptyField( name, desc ) { |
31 | 31 | //Check existence of compulsory fields |
32 | 32 | if ( typeof name == 'undefined' || !desc.type || !desc.label ) { |
33 | | - throw new Error( "Missing arguments" ); //TODO |
| 33 | + $.error( "Missing arguments" ); |
34 | 34 | } |
35 | 35 | |
36 | 36 | this.$p = $( '<p/>' ); |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | LabelField.call( this, name, desc ); |
82 | 82 | |
83 | 83 | if ( typeof desc.value != 'boolean' ) { |
84 | | - throw new Error( "desc.value is invalid" ); |
| 84 | + $.error( "desc.value is invalid" ); |
85 | 85 | } |
86 | 86 | |
87 | 87 | this.$c = $( '<input/>' ) |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | LabelField.call( this, name, desc ); |
106 | 106 | |
107 | 107 | if ( typeof desc.value != 'string' ) { |
108 | | - throw new Error( "desc.value is invalid" ); |
| 108 | + $.error( "desc.value is invalid" ); |
109 | 109 | } |
110 | 110 | |
111 | 111 | this.$text = $( '<input/>' ) |
— | — | @@ -121,8 +121,6 @@ |
122 | 122 | }; |
123 | 123 | |
124 | 124 | StringField.prototype.getValidationSettings = function() { |
125 | | - //TODO: messages |
126 | | - |
127 | 125 | var settings = { |
128 | 126 | rules: {} |
129 | 127 | }, |
— | — | @@ -136,12 +134,20 @@ |
137 | 135 | fieldRules.required = true; |
138 | 136 | } |
139 | 137 | |
140 | | - if ( typeof desc.minLength != 'undefined' ) { |
141 | | - fieldRules.minlength = desc.minLength; |
| 138 | + if ( typeof desc.minlength != 'undefined' ) { |
| 139 | + fieldRules.minlength = desc.minlength; |
142 | 140 | } |
143 | | - if ( typeof desc.maxLength != 'undefined' ) { |
144 | | - fieldRules.maxlength = desc.maxLength; |
| 141 | + if ( typeof desc.maxlength != 'undefined' ) { |
| 142 | + fieldRules.maxlength = desc.maxlength; |
145 | 143 | } |
| 144 | + |
| 145 | + settings.messages = {}; |
| 146 | + |
| 147 | + settings.messages[fieldId] = { |
| 148 | + "required": mw.msg( 'gadgets-formbuilder-required' ), |
| 149 | + "minlength": mw.msg( 'gadgets-formbuilder-minlength', desc.minlength ), |
| 150 | + "maxlength": mw.msg( 'gadgets-formbuilder-maxlength', desc.maxlength ) |
| 151 | + }; |
146 | 152 | |
147 | 153 | return settings; |
148 | 154 | } |
— | — | @@ -154,23 +160,17 @@ |
155 | 161 | "string" : StringField |
156 | 162 | }; |
157 | 163 | |
158 | | - function log( message ) { |
159 | | - if ( typeof window.console != 'undefined' ) { |
160 | | - console.warn( message ); |
161 | | - } |
162 | | - } |
163 | | - |
164 | 164 | function buildFormBody() { |
165 | 165 | var description = this.get(0); |
166 | | - if (typeof description != 'object' ) { |
167 | | - log( "description should be an object, instead of a " + typeof description ); |
| 166 | + if ( typeof description != 'object' ) { |
| 167 | + mw.log( "description should be an object, instead of a " + typeof description ); |
168 | 168 | return null; |
169 | 169 | } |
170 | 170 | |
171 | 171 | var $form = $( '<form/>' ); |
172 | 172 | var $fieldset = $( '<fieldset/>' ).appendTo( $form ); |
173 | 173 | |
174 | | - if (typeof description.label == 'string' ) { |
| 174 | + if ( typeof description.label == 'string' ) { |
175 | 175 | $( '<legend/>' ) |
176 | 176 | .text( $s( description.label ) ) |
177 | 177 | .appendTo( $fieldset ); |
— | — | @@ -178,8 +178,8 @@ |
179 | 179 | |
180 | 180 | //TODO: manage form params |
181 | 181 | |
182 | | - if (typeof description.fields != 'object' ) { |
183 | | - log( "description.fields should be an object, instead of a " + typeof description.fields ); |
| 182 | + if ( typeof description.fields != 'object' ) { |
| 183 | + mw.log( "description.fields should be an object, instead of a " + typeof description.fields ); |
184 | 184 | return null; |
185 | 185 | } |
186 | 186 | |
— | — | @@ -197,14 +197,14 @@ |
198 | 198 | var FieldConstructor = validFields[field.type]; |
199 | 199 | |
200 | 200 | if ( typeof FieldConstructor != 'function' ) { |
201 | | - log( "field with invalid type: " + field.type ); |
| 201 | + mw.log( "field with invalid type: " + field.type ); |
202 | 202 | return null; |
203 | 203 | } |
204 | 204 | |
205 | 205 | try { |
206 | 206 | var f = new FieldConstructor( fieldName, field ); |
207 | 207 | } catch ( e ) { |
208 | | - log( e ); |
| 208 | + mw.log( e ); |
209 | 209 | return null; //constructor failed, wrong syntax in field description |
210 | 210 | } |
211 | 211 | |
— | — | @@ -218,9 +218,6 @@ |
219 | 219 | } |
220 | 220 | |
221 | 221 | fields.push( f ); |
222 | | - |
223 | | - //TODO: validation of the field |
224 | | - |
225 | 222 | } |
226 | 223 | } |
227 | 224 | |
Index: branches/salvatoreingala/Gadgets/modules/ext.gadgets.preferences.js |
— | — | @@ -18,16 +18,14 @@ |
19 | 19 | dataType: "json", |
20 | 20 | success: function( response ) { |
21 | 21 | if ( response === true ) { |
22 | | - alert( 'Configuration saved successfully' ); |
| 22 | + alert( mw.msg( 'gadgets-save-success' ) ); |
23 | 23 | $dialog.dialog( 'close' ); |
24 | 24 | } else { |
25 | | - //TODO |
26 | | - alert( 'Something wrong happened' ); |
| 25 | + alert( mw.msg( 'gadgets-save-failed' ) ); |
27 | 26 | } |
28 | 27 | }, |
29 | 28 | error: function( response ) { |
30 | | - //TODO |
31 | | - alert( 'Something wrong happened' ); |
| 29 | + alert( mw.msg( 'gadgets-save-failed' ) ); |
32 | 30 | } |
33 | 31 | } ); |
34 | 32 | } |
— | — | @@ -44,7 +42,7 @@ |
45 | 43 | } |
46 | 44 | |
47 | 45 | var $link = $( '<a></a>' ) |
48 | | - .text( "Configure" ) //TODO: use a message instead |
| 46 | + .text( mw.msg( 'gadgets-configure' ) ) |
49 | 47 | .click( function() { |
50 | 48 | var postData = 'action=ajax&rs=GadgetsAjax::getPreferences' + |
51 | 49 | '&rsargs[]=gadget|' + encodeURIComponent( gadget ); |
— | — | @@ -61,13 +59,16 @@ |
62 | 60 | |
63 | 61 | var dialogBody = $( response ).formBuilder(); |
64 | 62 | |
65 | | - //window.validator = $( dialogBody ).validate(); |
| 63 | + $( dialogBody ).submit( function() { |
| 64 | + return false; //prevent form submission |
| 65 | + } ); |
66 | 66 | |
| 67 | + |
67 | 68 | $( dialogBody ).dialog( { |
68 | 69 | modal: true, |
69 | 70 | width: 'auto', |
70 | 71 | resizable: false, |
71 | | - title: 'Configuration of ' + gadget, //TODO: use messages |
| 72 | + title: mw.msg( 'gadgets-configuration-of', gadget ), |
72 | 73 | close: function() { |
73 | 74 | $( this ).dialog( 'destroy' ).empty(); //completely destroy on close |
74 | 75 | }, |
— | — | @@ -89,8 +90,7 @@ |
90 | 91 | } ); |
91 | 92 | }, |
92 | 93 | error: function( response ) { |
93 | | - //TODO |
94 | | - alert( 'Something wrong happened' ); |
| 94 | + alert( mw.msg( 'gadgets-unexpected-error' ) ); |
95 | 95 | } |
96 | 96 | } ); |
97 | 97 | |
Property changes on: branches/salvatoreingala/Gadgets |
___________________________________________________________________ |
Modified: svn:mergeinfo |
98 | 98 | Merged /trunk/extensions/Gadgets:r88718-89450 |