r96190 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96189‎ | r96190 | r96191 >
Date:14:38, 3 September 2011
Author:santhosh
Status:resolved (Comments)
Tags:
Comment:
Make the labels of input method menu clickable.
Modified paths:
  • /trunk/extensions/Narayam/js/ext.narayam.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Narayam/js/ext.narayam.core.js
@@ -417,18 +417,24 @@
418418 this.buildMenu = function() {
419419 var haveSchemes = false;
420420 // Build schemes option list
421 - var $ul = $( '<ul/>' );
 421+ var $narayamMenuItems = $( '<ul/>' );
422422 for ( scheme in schemes ) {
423423 $input = $( '<input type="radio" name="narayam-input-method" class="narayam-scheme" />' );
424424 $input
425425 .attr( 'id', 'narayam-' + scheme )
426426 .val( scheme );
 427+
 428+ $narayamMenuItemLabel=$( '<label />' )
 429+ .attr("for",'narayam-' + scheme)
 430+ .append( $input)
 431+ .append( mw.msg( schemes[scheme].namemsg ) );
427432
428 - $( '<li/>' )
 433+ var $narayamMenuItem = $( '<li/>' )
429434 .append( $input )
430 - .append( mw.msg( schemes[scheme].namemsg ) )
431 - .appendTo( $ul );
 435+ .append($narayamMenuItemLabel);
 436+
432437 haveSchemes = true;
 438+ $narayamMenuItems.append($narayamMenuItem);
433439 }
434440
435441 if ( !haveSchemes ) {
@@ -457,7 +463,7 @@
458464
459465 var helppage = mw.msg( 'narayam-help-page' );
460466 if ( helppage ) {
461 - $ul.append( $( '<li class="narayam-help-link" />')
 467+ $narayamMenuItems.append( $( '<li class="narayam-help-link" />')
462468 .append(
463469 $( '<a/>' )
464470 .text( mw.msg( 'narayam-help' ) )
@@ -466,11 +472,11 @@
467473 );
468474 }
469475
470 - $ul.prepend( $( '<li/>' ).append( $label ) );
 476+ $narayamMenuItems.prepend( $( '<li/>' ).append( $label ) );
471477
472 - var $menuItems = $( '<div id="narayam-menu-items" class="menu-items" />' );
473 - $menuItems
474 - .append( $ul );
 478+ var $menuItemsDiv = $( '<div id="narayam-menu-items" class="menu-items" />' );
 479+ $menuItemsDiv
 480+ .append( $narayamMenuItems );
475481
476482 var $menu = $( '<div id="narayam-menu" class="narayam-menu" />');
477483 $menu
@@ -479,7 +485,7 @@
480486 .text( mw.msg( 'narayam-menu' ) )
481487 .attr( 'title', mw.msg( 'narayam-menu-tooltip' ) )
482488 )
483 - .append( $menuItems );
 489+ .append( $menuItemsDiv );
484490
485491 var $li = $( '<li id="pt-narayam" />');
486492 $li

Follow-up revisions

RevisionCommit summaryAuthorDate
r96567JSHint and whitespace fixes, mostly missing semicolons and missing 'var's. Co...catrope14:44, 8 September 2011
r96714Follow up of r96190 , escape the name message.santhosh05:50, 10 September 2011

Comments

#Comment by Catrope (talk | contribs)   15:23, 8 September 2011
+					.append( mw.msg( schemes[scheme].namemsg ) );

This interprets the name message as HTML. This needs escaping, using either something like .append( $( '' ).text( mw.msg( ... ) ) ); or something like .append( mw.html.escape( mw.msg( ... ) ) );

#Comment by Santhosh.thottingal (talk | contribs)   05:53, 10 September 2011

Fixed in r96714

Status & tagging log