Index: trunk/extensions/SemanticFormsInputs/SFI_Inputs.php |
— | — | @@ -192,12 +192,10 @@ |
193 | 193 | |
194 | 194 | // register event to validate regexp on submit/preview |
195 | 195 | $jstext = <<<JAVASCRIPT |
196 | | -jQuery(function(){ |
197 | | - jQuery('#input_$sfgFieldNum').SemanticForms_registerInputValidation( SFI_RE_validate, {retext: {$regexp}, inverse: {$inverseString}, message: {$message} }); |
198 | | -}); |
| 196 | +jQuery(function(){ jQuery('#input_$sfgFieldNum').SemanticForms_registerInputValidation( SFI_RE_validate, {retext: {$regexp}, inverse: {$inverseString}, message: {$message} }); }); |
199 | 197 | JAVASCRIPT; |
200 | 198 | |
201 | | - $wgOut->addInlineScript( $jstext ); |
| 199 | + $wgOut->addScript( Html::inlineScript( $jstext ) ); |
202 | 200 | |
203 | 201 | // create other_args for base input type |
204 | 202 | $new_other_args = array(); |
— | — | @@ -213,7 +211,7 @@ |
214 | 212 | $funcArgs[] = $cur_value; |
215 | 213 | $funcArgs[] = $input_name; |
216 | 214 | $funcArgs[] = $is_mandatory; |
217 | | - $funcArgs[] = $is_disabled; |
| 215 | + $funcArgs[] = $is_disabled; |
218 | 216 | $funcArgs[] = $new_other_args; |
219 | 217 | |
220 | 218 | // get the input type hooks for the base input type |
— | — | @@ -241,74 +239,75 @@ |
242 | 240 | |
243 | 241 | $wgOut->addScript( '<script type="text/javascript" src="' . $sfgScriptPath . '/libs/jquery-ui/jquery.ui.datepicker.min.js"></script> ' ); |
244 | 242 | $wgOut->addExtensionStyle( $sfgScriptPath . '/skins/jquery-ui/base/jquery.ui.datepicker.css' ); |
| 243 | + $wgOut->addExtensionStyle( $sfgScriptPath . '/skins/jquery-ui/base/jquery.ui.theme.css' ); |
245 | 244 | $wgOut->addScript( '<script type="text/javascript" src="' . $sfigSettings->scriptPath . '/libs/datepicker.js"></script> ' ); |
246 | 245 | |
247 | 246 | // set localized messages (use MW i18n, not jQuery i18n) |
248 | 247 | $jstext = |
249 | | - "jQuery(function(){\n" |
250 | | - . " jQuery.datepicker.regional['wiki'] = {\n" |
251 | | - . " closeText: '" . wfMsg( 'semanticformsinputs-close' ) . "',\n" |
252 | | - . " prevText: '" . wfMsg( 'semanticformsinputs-prev' ) . "',\n" |
253 | | - . " nextText: '" . wfMsg( 'semanticformsinputs-next' ) . "',\n" |
254 | | - . " currentText: '" . wfMsg( 'semanticformsinputs-today' ) . "',\n" |
255 | | - . " monthNames: ['" |
256 | | - . wfMsg( 'january' ) . "','" |
257 | | - . wfMsg( 'february' ) . "','" |
258 | | - . wfMsg( 'march' ) . "','" |
259 | | - . wfMsg( 'april' ) . "','" |
260 | | - . wfMsg( 'may_long' ) . "','" |
261 | | - . wfMsg( 'june' ) . "','" |
262 | | - . wfMsg( 'july' ) . "','" |
263 | | - . wfMsg( 'august' ) . "','" |
264 | | - . wfMsg( 'september' ) . "','" |
265 | | - . wfMsg( 'october' ) . "','" |
266 | | - . wfMsg( 'november' ) . "','" |
267 | | - . wfMsg( 'december' ) . "'],\n" |
268 | | - . " monthNamesShort: ['" |
269 | | - . wfMsg( 'jan' ) . "','" |
270 | | - . wfMsg( 'feb' ) . "','" |
271 | | - . wfMsg( 'mar' ) . "','" |
272 | | - . wfMsg( 'apr' ) . "','" |
273 | | - . wfMsg( 'may' ) . "','" |
274 | | - . wfMsg( 'jun' ) . "','" |
275 | | - . wfMsg( 'jul' ) . "','" |
276 | | - . wfMsg( 'aug' ) . "','" |
277 | | - . wfMsg( 'sep' ) . "','" |
278 | | - . wfMsg( 'oct' ) . "','" |
279 | | - . wfMsg( 'nov' ) . "','" |
280 | | - . wfMsg( 'dec' ) . "'],\n" |
281 | | - . " dayNames: ['" |
282 | | - . wfMsg( 'sunday' ) . "','" |
283 | | - . wfMsg( 'monday' ) . "','" |
284 | | - . wfMsg( 'tuesday' ) . "','" |
285 | | - . wfMsg( 'wednesday' ) . "','" |
286 | | - . wfMsg( 'thursday' ) . "','" |
287 | | - . wfMsg( 'friday' ) . "','" |
288 | | - . wfMsg( 'saturday' ) . "'],\n" |
289 | | - . " dayNamesShort: ['" |
290 | | - . wfMsg( 'sun' ) . "','" |
291 | | - . wfMsg( 'mon' ) . "','" |
292 | | - . wfMsg( 'tue' ) . "','" |
293 | | - . wfMsg( 'wed' ) . "','" |
294 | | - . wfMsg( 'thu' ) . "','" |
295 | | - . wfMsg( 'fri' ) . "','" |
296 | | - . wfMsg( 'sat' ) . "'],\n" |
297 | | - . " dayNamesMin: ['" |
298 | | - . $wgLang->firstChar( wfMsg( 'sun' ) ) . "','" |
299 | | - . $wgLang->firstChar( wfMsg( 'mon' ) ) . "','" |
300 | | - . $wgLang->firstChar( wfMsg( 'tue' ) ) . "','" |
301 | | - . $wgLang->firstChar( wfMsg( 'wed' ) ) . "','" |
302 | | - . $wgLang->firstChar( wfMsg( 'thu' ) ) . "','" |
303 | | - . $wgLang->firstChar( wfMsg( 'fri' ) ) . "','" |
304 | | - . $wgLang->firstChar( wfMsg( 'sat' ) ) . "'],\n" |
305 | | - . " weekHeader: '',\n" |
306 | | - . " dateFormat: '" . wfMsg( 'semanticformsinputs-dateformatshort' ) . "',\n" |
307 | | - . " firstDay: '" . wfMsg( 'semanticformsinputs-firstdayofweek' ) . "',\n" |
308 | | - . " isRTL: " . ( $wgLang->isRTL() ? "true":"false" ) . ",\n" |
309 | | - . " showMonthAfterYear: false,\n" |
310 | | - . " yearSuffix: ''};\n" |
311 | | - . " jQuery.datepicker.setDefaults(jQuery.datepicker.regional['wiki']);\n" |
312 | | - . "});\n"; |
| 248 | + "jQuery(function(){\n" |
| 249 | + . " jQuery.datepicker.regional['wiki'] = {\n" |
| 250 | + . " closeText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-close' ) ) . "',\n" |
| 251 | + . " prevText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-prev' ) ) . "',\n" |
| 252 | + . " nextText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-next' ) ) . "',\n" |
| 253 | + . " currentText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-today' ) ) . "',\n" |
| 254 | + . " monthNames: ['" |
| 255 | + . Xml::escapeJsString( wfMsg( 'january' ) ) . "','" |
| 256 | + . Xml::escapeJsString( wfMsg( 'february' ) ) . "','" |
| 257 | + . Xml::escapeJsString( wfMsg( 'march' ) ) . "','" |
| 258 | + . Xml::escapeJsString( wfMsg( 'april' ) ) . "','" |
| 259 | + . Xml::escapeJsString( wfMsg( 'may_long' ) ) . "','" |
| 260 | + . Xml::escapeJsString( wfMsg( 'june' ) ) . "','" |
| 261 | + . Xml::escapeJsString( wfMsg( 'july' ) ) . "','" |
| 262 | + . Xml::escapeJsString( wfMsg( 'august' ) ) . "','" |
| 263 | + . Xml::escapeJsString( wfMsg( 'september' ) ) . "','" |
| 264 | + . Xml::escapeJsString( wfMsg( 'october' ) ) . "','" |
| 265 | + . Xml::escapeJsString( wfMsg( 'november' ) ) . "','" |
| 266 | + . Xml::escapeJsString( wfMsg( 'december' ) ) . "'],\n" |
| 267 | + . " monthNamesShort: ['" |
| 268 | + . Xml::escapeJsString( wfMsg( 'jan' ) ) . "','" |
| 269 | + . Xml::escapeJsString( wfMsg( 'feb' ) ) . "','" |
| 270 | + . Xml::escapeJsString( wfMsg( 'mar' ) ) . "','" |
| 271 | + . Xml::escapeJsString( wfMsg( 'apr' ) ) . "','" |
| 272 | + . Xml::escapeJsString( wfMsg( 'may' ) ) . "','" |
| 273 | + . Xml::escapeJsString( wfMsg( 'jun' ) ) . "','" |
| 274 | + . Xml::escapeJsString( wfMsg( 'jul' ) ) . "','" |
| 275 | + . Xml::escapeJsString( wfMsg( 'aug' ) ) . "','" |
| 276 | + . Xml::escapeJsString( wfMsg( 'sep' ) ) . "','" |
| 277 | + . Xml::escapeJsString( wfMsg( 'oct' ) ) . "','" |
| 278 | + . Xml::escapeJsString( wfMsg( 'nov' ) ) . "','" |
| 279 | + . Xml::escapeJsString( wfMsg( 'dec' ) ) . "'],\n" |
| 280 | + . " dayNames: ['" |
| 281 | + . Xml::escapeJsString( wfMsg( 'sunday' ) ) . "','" |
| 282 | + . Xml::escapeJsString( wfMsg( 'monday' ) ) . "','" |
| 283 | + . Xml::escapeJsString( wfMsg( 'tuesday' ) ) . "','" |
| 284 | + . Xml::escapeJsString( wfMsg( 'wednesday' ) ) . "','" |
| 285 | + . Xml::escapeJsString( wfMsg( 'thursday' ) ) . "','" |
| 286 | + . Xml::escapeJsString( wfMsg( 'friday' ) ) . "','" |
| 287 | + . Xml::escapeJsString( wfMsg( 'saturday' ) ) . "'],\n" |
| 288 | + . " dayNamesShort: ['" |
| 289 | + . Xml::escapeJsString( wfMsg( 'sun' ) ) . "','" |
| 290 | + . Xml::escapeJsString( wfMsg( 'mon' ) ) . "','" |
| 291 | + . Xml::escapeJsString( wfMsg( 'tue' ) ) . "','" |
| 292 | + . Xml::escapeJsString( wfMsg( 'wed' ) ) . "','" |
| 293 | + . Xml::escapeJsString( wfMsg( 'thu' ) ) . "','" |
| 294 | + . Xml::escapeJsString( wfMsg( 'fri' ) ) . "','" |
| 295 | + . Xml::escapeJsString( wfMsg( 'sat' ) ) . "'],\n" |
| 296 | + . " dayNamesMin: ['" |
| 297 | + . Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'sun' ) ) ) . "','" |
| 298 | + . Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'mon' ) ) ) . "','" |
| 299 | + . Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'tue' ) ) ) . "','" |
| 300 | + . Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'wed' ) ) ) . "','" |
| 301 | + . Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'thu' ) ) ) . "','" |
| 302 | + . Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'fri' ) ) ) . "','" |
| 303 | + . Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'sat' ) ) ) . "'],\n" |
| 304 | + . " weekHeader: '',\n" |
| 305 | + . " dateFormat: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-dateformatshort' ) ) . "',\n" |
| 306 | + . " firstDay: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-firstdayofweek' ) ) . "',\n" |
| 307 | + . " isRTL: " . ( $wgLang->isRTL() ? "true" : "false" ) . ",\n" |
| 308 | + . " showMonthAfterYear: false,\n" |
| 309 | + . " yearSuffix: ''};\n" |
| 310 | + . " jQuery.datepicker.setDefaults(jQuery.datepicker.regional['wiki']);\n" |
| 311 | + . "});\n"; |
313 | 312 | |
314 | 313 | |
315 | 314 | $wgOut->addInlineScript( $jstext ); |
— | — | @@ -821,8 +820,12 @@ |
822 | 821 | $jsattribsString = Xml::encodeJsVar( $jsattribs ); |
823 | 822 | |
824 | 823 | // wrap the JS code fragment in a function for deferred init |
| 824 | +// $jstext = <<<JAVASCRIPT |
| 825 | +//jQuery(function(){ jQuery('#input_{$sfgFieldNum}_dp_show').SemanticForms_registerInputInit(SFI_DP_init, $jsattribsString ); }); |
| 826 | +//JAVASCRIPT; |
| 827 | +// |
825 | 828 | $jstext = <<<JAVASCRIPT |
826 | | -jQuery(function(){ jQuery('#input_{$sfgFieldNum}_dp_show').SemanticForms_registerInputInit(SFI_DP_init, $jsattribsString ); }); |
| 829 | +jQuery(function(){ jQuery('#input_{$sfgFieldNum}').SemanticForms_registerInputInit(SFI_DP_init, $jsattribsString ); }); |
827 | 830 | JAVASCRIPT; |
828 | 831 | |
829 | 832 | // insert the code of the JS init function into the pages code |
— | — | @@ -1213,20 +1216,29 @@ |
1214 | 1217 | |
1215 | 1218 | } |
1216 | 1219 | |
| 1220 | + static function menuselectSetGlobalVars(&$vars) { |
| 1221 | + global $sfigSettings; |
| 1222 | + $vars['sfigScriptPath'] = $sfigSettings->scriptPath; |
| 1223 | + return true; |
| 1224 | + } |
| 1225 | + |
1217 | 1226 | /** |
1218 | 1227 | * Setup for input type "menuselect". |
1219 | 1228 | * Adds the Javascript code and css used by all menuselects. |
1220 | 1229 | */ |
1221 | 1230 | static private function menuselectSetup() { |
1222 | 1231 | |
1223 | | - global $wgOut; |
| 1232 | + global $wgOut, $wgHooks; |
1224 | 1233 | global $sfigSettings; |
1225 | 1234 | |
1226 | 1235 | static $hasRun = false; |
1227 | 1236 | |
1228 | 1237 | if ( !$hasRun ) { |
1229 | 1238 | |
1230 | | - $wgOut->addScript( '<script type="text/javascript">sfigScriptPath="' . $sfigSettings->scriptPath . '";</script> ' ); |
| 1239 | + $hasRun = true; |
| 1240 | + |
| 1241 | + $wgHooks['MakeGlobalVariablesScript'][] = 'SFIInputs::menuselectSetGlobalVars'; |
| 1242 | + |
1231 | 1243 | $wgOut->addScript( '<script type="text/javascript" src="' . $sfigSettings->scriptPath . '/libs/menuselect.js"></script> ' ); |
1232 | 1244 | $wgOut->addExtensionStyle( $sfigSettings->scriptPath . '/skins/SFI_Menuselect.css' ); |
1233 | 1245 | |
— | — | @@ -1301,7 +1313,8 @@ |
1302 | 1314 | // write JS code directly to the page's code |
1303 | 1315 | $wgOut->addScript( '<script type="text/javascript">' . $jstext . '</script>' ); |
1304 | 1316 | |
1305 | | - return array( $html, "", "SFI_MS_init" ); |
| 1317 | +// return array( $html, "", "SFI_MS_init" ); |
1306 | 1318 | |
| 1319 | + return $html; |
1307 | 1320 | } |
1308 | 1321 | } |
Index: trunk/extensions/SemanticFormsInputs/libs/menuselect.js |
— | — | @@ -36,8 +36,11 @@ |
37 | 37 | .each( function() { |
38 | 38 | |
39 | 39 | var item = jQuery( this ); |
40 | | - var contents = item.contents().not( "ul" ); |
41 | | - |
| 40 | + var contents = item.contents()//.not( "ul" ); |
| 41 | + .filter(function() { |
| 42 | + return ! jQuery( this ).is('ul'); |
| 43 | + }); |
| 44 | + |
42 | 45 | contents |
43 | 46 | .wrapAll( '<table><tbody><tr><td class="cont"/>' ); |
44 | 47 | |
Index: trunk/extensions/SemanticFormsInputs/libs/datepicker.js |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | |
9 | 9 | function SFI_DP_init ( input_id, params ) { |
10 | 10 | |
11 | | - var input = jQuery("#" + input_id); |
| 11 | + var input = jQuery("#" + input_id + "_dp_show"); |
12 | 12 | var re = /\d{4}\/\d{2}\/\d{2}/ |
13 | 13 | |
14 | 14 | if ( params.disabled ) { |