From b27d0a902b0065cd5e8f2cf8ec1f8cd4141d1776 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Tue, 23 Apr 2013 18:54:11 +0300 Subject: [PATCH] Show the web fonts selectors only if they are enabled Change-Id: I70b9f9468154b542a80a9717afdb414530bd0d37 --- resources/js/ext.uls.displaysettings.js | 42 ++++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/resources/js/ext.uls.displaysettings.js b/resources/js/ext.uls.displaysettings.js index 08709ed8..a7acb794 100644 --- a/resources/js/ext.uls.displaysettings.js +++ b/resources/js/ext.uls.displaysettings.js @@ -56,17 +56,7 @@ + '' + '' - // Webfonts enabling chechbox with label - + '
' - + '
' - + '' - + '
' - + '
' + + '
' // Menus font selection dropdown with label + '
' @@ -84,6 +74,20 @@ + '' + '
' + + '
' // End font selectors + + // Webfonts enabling chechbox with label + + '
' + + '
' + + '' + + '
' + + '
' + + '' // End font settings section // Separator @@ -128,7 +132,15 @@ }, prepareWebfontsCheckbox: function () { - $( '#webfonts-enable-checkbox' ).prop( 'checked', this.isWebFontsEnabled() ); + var webFontsEnabled = this.isWebFontsEnabled(); + + if ( !webFontsEnabled ) { + this.$template.find( + '#uls-display-settings-font-selectors' + ).addClass( 'hide' ); + } + + $( '#webfonts-enable-checkbox' ).prop( 'checked', webFontsEnabled ); }, isWebFontsEnabled: function () { @@ -432,9 +444,14 @@ } ); displaySettings.$template.find( '#webfonts-enable-checkbox' ).on( 'click', function () { + var $fontSelectors = displaySettings.$template.find( + '#uls-display-settings-font-selectors' + ); + displaySettings.enableApplyButton(); if ( this.checked ) { + $fontSelectors.removeClass( 'hide' ); mw.webfonts.preferences.enable(); mw.webfonts.setup(); displaySettings.$webfonts = $( 'body' ).data( 'webfonts' ); @@ -446,6 +463,7 @@ displaySettings.$webfonts.apply( $uiFontSelector.find( 'option:selected' ) ); displaySettings.$webfonts.refresh(); } else { + $fontSelectors.addClass( 'hide' ); mw.webfonts.preferences.disable(); mw.webfonts.preferences.setFont( displaySettings.uiLanguage, 'system' ); displaySettings.$webfonts.refresh();