r101307 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101306‎ | r101307 | r101308 >
Date:19:22, 30 October 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
Modified paths:
  • /trunk/extensions/SemanticFormsInputs/SFI_Inputs.php (modified) (history)
  • /trunk/extensions/SemanticFormsInputs/libs/datepicker.js (modified) (history)
  • /trunk/extensions/SemanticFormsInputs/libs/menuselect.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticFormsInputs/SFI_Inputs.php
@@ -192,12 +192,10 @@
193193
194194 // register event to validate regexp on submit/preview
195195 $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} }); });
199197 JAVASCRIPT;
200198
201 - $wgOut->addInlineScript( $jstext );
 199+ $wgOut->addScript( Html::inlineScript( $jstext ) );
202200
203201 // create other_args for base input type
204202 $new_other_args = array();
@@ -213,7 +211,7 @@
214212 $funcArgs[] = $cur_value;
215213 $funcArgs[] = $input_name;
216214 $funcArgs[] = $is_mandatory;
217 - $funcArgs[] = $is_disabled;
 215+ $funcArgs[] = $is_disabled;
218216 $funcArgs[] = $new_other_args;
219217
220218 // get the input type hooks for the base input type
@@ -241,74 +239,75 @@
242240
243241 $wgOut->addScript( '<script type="text/javascript" src="' . $sfgScriptPath . '/libs/jquery-ui/jquery.ui.datepicker.min.js"></script> ' );
244242 $wgOut->addExtensionStyle( $sfgScriptPath . '/skins/jquery-ui/base/jquery.ui.datepicker.css' );
 243+ $wgOut->addExtensionStyle( $sfgScriptPath . '/skins/jquery-ui/base/jquery.ui.theme.css' );
245244 $wgOut->addScript( '<script type="text/javascript" src="' . $sfigSettings->scriptPath . '/libs/datepicker.js"></script> ' );
246245
247246 // set localized messages (use MW i18n, not jQuery i18n)
248247 $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";
313312
314313
315314 $wgOut->addInlineScript( $jstext );
@@ -821,8 +820,12 @@
822821 $jsattribsString = Xml::encodeJsVar( $jsattribs );
823822
824823 // 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+//
825828 $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 ); });
827830 JAVASCRIPT;
828831
829832 // insert the code of the JS init function into the pages code
@@ -1213,20 +1216,29 @@
12141217
12151218 }
12161219
 1220+ static function menuselectSetGlobalVars(&$vars) {
 1221+ global $sfigSettings;
 1222+ $vars['sfigScriptPath'] = $sfigSettings->scriptPath;
 1223+ return true;
 1224+ }
 1225+
12171226 /**
12181227 * Setup for input type "menuselect".
12191228 * Adds the Javascript code and css used by all menuselects.
12201229 */
12211230 static private function menuselectSetup() {
12221231
1223 - global $wgOut;
 1232+ global $wgOut, $wgHooks;
12241233 global $sfigSettings;
12251234
12261235 static $hasRun = false;
12271236
12281237 if ( !$hasRun ) {
12291238
1230 - $wgOut->addScript( '<script type="text/javascript">sfigScriptPath="' . $sfigSettings->scriptPath . '";</script> ' );
 1239+ $hasRun = true;
 1240+
 1241+ $wgHooks['MakeGlobalVariablesScript'][] = 'SFIInputs::menuselectSetGlobalVars';
 1242+
12311243 $wgOut->addScript( '<script type="text/javascript" src="' . $sfigSettings->scriptPath . '/libs/menuselect.js"></script> ' );
12321244 $wgOut->addExtensionStyle( $sfigSettings->scriptPath . '/skins/SFI_Menuselect.css' );
12331245
@@ -1301,7 +1313,8 @@
13021314 // write JS code directly to the page's code
13031315 $wgOut->addScript( '<script type="text/javascript">' . $jstext . '</script>' );
13041316
1305 - return array( $html, "", "SFI_MS_init" );
 1317+// return array( $html, "", "SFI_MS_init" );
13061318
 1319+ return $html;
13071320 }
13081321 }
Index: trunk/extensions/SemanticFormsInputs/libs/menuselect.js
@@ -36,8 +36,11 @@
3737 .each( function() {
3838
3939 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+
4245 contents
4346 .wrapAll( '<table><tbody><tr><td class="cont"/>' );
4447
Index: trunk/extensions/SemanticFormsInputs/libs/datepicker.js
@@ -7,7 +7,7 @@
88
99 function SFI_DP_init ( input_id, params ) {
1010
11 - var input = jQuery("#" + input_id);
 11+ var input = jQuery("#" + input_id + "_dp_show");
1212 var re = /\d{4}\/\d{2}\/\d{2}/
1313
1414 if ( params.disabled ) {