r108124 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108123‎ | r108124 | r108125 >
Date:09:23, 5 January 2012
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
CSS and JS cleanup. Misc JS fixes
Modified paths:
  • /trunk/extensions/WebFonts/resources/ext.webfonts.preview.css (modified) (history)
  • /trunk/extensions/WebFonts/resources/ext.webfonts.preview.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/resources/ext.webfonts.preview.js
@@ -1,64 +1,64 @@
22 /**
33 * Preview page script
44 */
5 -jQuery( function( $ ) {
 5+(function( $, mw ) {
 6+ "use strict";
67
7 - var showPreview = function( ) {
8 - var $font = $( 'select#webfonts-font-chooser' ).val();
 8+ var showPreview = function () {
 9+ var font = $( 'select#webfonts-font-chooser' ).val();
910 var $downloadLink = $( 'a#webfonts-preview-download' );
1011 var $previewBox = $( 'div#webfonts-preview-area' );
11 - mw.webfonts.addFont( $font );
12 - $previewBox.css( 'font-family', $font ).addClass( 'webfonts-lang-attr' );
13 - $previewBox.css( 'font-size', parseInt( $( 'select#webfonts-size-chooser' ).val ( ) ) );
14 - var fontconfig = mw.webfonts.config.fonts[$font];
 12+ mw.webfonts.addFont( font );
 13+ $previewBox.css( 'font-family', font ).addClass( 'webfonts-lang-attr' );
 14+ $previewBox.css( 'font-size', parseInt( $( 'select#webfonts-size-chooser' ).val(), 10 ) );
 15+ var fontconfig = mw.webfonts.config.fonts[font];
1516 var base = mw.config.get( 'wgExtensionAssetsPath' ) + '/WebFonts/fonts/';
16 - $downloadLink.prop( 'href' , base + fontconfig.ttf ).removeClass( 'disabled' );
 17+ $downloadLink.prop( 'href', base + 'fontconfig.ttf' ).removeClass( 'disabled' );
1718 return true;
18 - }
 19+ };
1920
20 - var getFontsForLang = function( language ) {
 21+ var getFontsForLang = function ( language ) {
2122 var $fontSelecter = $( 'select#webfonts-font-chooser' );
2223 var $downloadLink = $( 'a#webfonts-preview-download' );
2324 $fontSelecter.empty();
2425 var languages = mw.webfonts.config.languages;
2526 var fonts = languages[language];
26 - if(!fonts) {
 27+ if( !fonts ) {
2728 $downloadLink.removeAttr( 'href' ).addClass( 'disabled' );
2829 return false;
2930 }
30 - $.each(fonts, function(key, value) {
31 - $fontSelecter.append( $('<option>', { value : value } )
32 - .text( value ) );
 31+ $.each( fonts, function( key, value ) {
 32+ $fontSelecter.append( $( '<option>', { value: value } )
 33+ .text( value ) );
3334 } );
3435 showPreview();
3536 return true;
36 - }
 37+ };
 38+
 39+ $( document ).ready( function () {
 40+ $( 'select#wpUserLanguage' ).change( function () {
 41+ var language = $( 'select#wpUserLanguage' ).val();
 42+ getFontsForLang( language );
 43+ } );
3744
38 - $( 'select#wpUserLanguage' ).change( function () {
39 - var language = $( 'select#wpUserLanguage' ).val();
40 - getFontsForLang( language );
41 - } );
 45+ $( 'select#webfonts-font-chooser, select#webfonts-size-chooser' ).change( function () {
 46+ showPreview();
 47+ } );
4248
43 - $( 'select#webfonts-font-chooser' ).change( function () {
44 - showPreview();
45 - } );
 49+ $( 'button#webfonts-preview-bold' ).click( function () {
 50+ document.execCommand( 'bold', false, null );
 51+ } );
 52+
 53+ $( 'button#webfonts-preview-italic' ).click( function () {
 54+ document.execCommand( 'italic', false, null );
 55+ } );
4656
47 - $( 'select#webfonts-size-chooser' ).change( function () {
 57+ $( 'button#webfonts-preview-underline' ).click( function () {
 58+ document.execCommand( 'underline', false, null );
 59+ } );
 60+
 61+ getFontsForLang( $( 'select#wpUserLanguage' ).val() );
4862 showPreview();
4963 } );
50 -
51 - $( 'button#webfonts-preview-bold' ).click( function () {
52 - document.execCommand( 'bold', false, null );
53 - } );
5464
55 - $( 'button#webfonts-preview-italic' ).click( function () {
56 - document.execCommand( 'italic', false, null );
57 - } );
58 -
59 - $( 'button#webfonts-preview-underline' ).click( function () {
60 - document.execCommand( 'underline', false, null );
61 - } );
62 -
63 - getFontsForLang( $( 'select#wpUserLanguage' ).val() );
64 - showPreview();
65 -} );
 65+} )( jQuery, mediaWiki );
Index: trunk/extensions/WebFonts/resources/ext.webfonts.preview.css
@@ -1,18 +1,19 @@
22 select#wpUserLanguage,
33 select#webfonts-font-chooser,
4 -select#webfonts-size-chooser{
 4+select#webfonts-size-chooser {
55 width: 200px;
66 height: 25px;
77 vertical-align: middle;
88 }
99
10 -select#webfonts-size-chooser{
 10+select#webfonts-size-chooser {
1111 width: 50px;
1212 }
1313
14 -div#webfonts-preview-area{
 14+div#webfonts-preview-area {
1515 height: 300px;
1616 border: 1px solid #cccccc;
 17+ border-radius: 0 0 4px 4px;
1718 -webkit-border-radius: 0 0 4px 4px;
1819 -moz-border-radius: 0 0 4px 4px;
1920 text-align: left;
@@ -23,30 +24,30 @@
2425 button#webfonts-preview-bold,
2526 button#webfonts-preview-italic,
2627 button#webfonts-preview-underline,
27 -a#webfonts-preview-download{
 28+a#webfonts-preview-download {
2829 height: 25px;
2930 vertical-align: middle;
3031 font-weight: bold;
3132 text-shadow: 0 1px 0 rgba(255,255,255,0.4);
3233 }
3334
34 -a#webfonts-preview-download.disabled{
 35+a#webfonts-preview-download.disabled {
3536 color: #808080;
3637 }
3738
38 -div#webfonts-preview-toolbar button{
 39+div#webfonts-preview-toolbar button {
3940 width: 30px;
4041 }
4142
42 -button#webfonts-preview-italic{
 43+button#webfonts-preview-italic {
4344 font-style: italic;
4445 }
4546
46 -button#webfonts-preview-underline{
 47+button#webfonts-preview-underline {
4748 text-decoration: underline;
4849 }
4950
50 -a#webfonts-preview-download{
 51+a#webfonts-preview-download {
5152 padding-right: 10px;
5253 padding-left: 10px;
5354 padding-top: 3px;
@@ -54,10 +55,11 @@
5556 text-decoration: none;
5657 }
5758
58 -div#webfonts-preview-toolbar{
 59+div#webfonts-preview-toolbar {
5960 overflow: hidden;
6061 background-color: #F9F9F9;
6162 border: 1px solid #CCCCCC;
 63+ border-radius: 4px 4px 0 0;
6264 -webkit-border-radius: 4px 4px 0 0;
6365 -moz-border-radius: 4px 4px 0 0;
6466 position: relative;

Comments

#Comment by Santhosh.thottingal (talk | contribs)   10:13, 5 January 2012

Thanks!

#Comment by Santhosh.thottingal (talk | contribs)   08:49, 9 January 2012
'fontconfig.ttf' should not be in quotes. Fixed in r108390

Status & tagging log