r103296 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103295‎ | r103296 | r103297 >
Date:04:49, 16 November 2011
Author:santhosh
Status:ok
Tags:
Comment:
Refactor buildMenu to seperate the UI integration to skin, so that skin integration can be overridden by skin specific scripts.
Modified paths:
  • /trunk/extensions/WebFonts/resources/ext.webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/resources/ext.webfonts.js
@@ -246,10 +246,10 @@
247247 },
248248
249249 /**
250 - * Prepare the menu for the webfonts.
 250+ * Prepare the div containing menu items.
251251 * @param config The webfont configuration.
252252 */
253 - buildMenu: function(config) {
 253+ buildMenuItems: function ( config ){
254254 var haveSchemes = false;
255255 // Build font dropdown
256256 var $fontsMenu = $( '<ul>' ).attr( 'id', 'webfonts-fontsmenu' );
@@ -280,7 +280,7 @@
281281 if ( !haveSchemes && !$( '.webfonts-lang-attr' ).length ) {
282282 // No schemes available, and no tags with lang attr
283283 // with fonts loaded. Don't show the menu.
284 - return;
 284+ return null;
285285 }
286286
287287 var $resetLink = $( '<input type="radio" />' )
@@ -307,12 +307,22 @@
308308 .addClass( 'menu' )
309309 .append( $fontsMenu )
310310 .append();
311 -
 311+ return $menuDiv;
 312+ },
 313+ /**
 314+ * Prepare the menu for the webfonts.
 315+ * @param config The webfont configuration.
 316+ */
 317+ buildMenu: function(config) {
 318+ var $menuItemsDiv = mw.webfonts.buildMenuItems( config );
 319+ if( $menuItemsDiv == null ) {
 320+ return;
 321+ }
312322 var $div = $( '<div>' )
313323 .attr( 'id', 'webfonts-menu' )
314324 .addClass( 'webfontMenu' )
315325 .append( $( '<a>' ).prop( 'href', '#' ).text( mw.message( 'webfonts-load' ).escaped() ) )
316 - .append( $menuDiv );
 326+ .append( $menuItemsDiv );
317327
318328 // This is the fonts link
319329 var $li = $( '<li>' )

Status & tagging log