Index: trunk/extensions/WebFonts/resources/ext.webfonts.js |
— | — | @@ -7,31 +7,31 @@ |
8 | 8 | return 'webfont-' + font.toLowerCase().replace(/[_ ]/g, '-' ).replace(/[^-a-z]/g, '' ); |
9 | 9 | } |
10 | 10 | |
11 | | - $.webfonts = { |
| 11 | + mw.webfonts = { |
12 | 12 | |
13 | 13 | oldconfig: false, |
14 | | - config: $.webfonts.config, |
| 14 | + config: mw.webfonts.config, |
15 | 15 | version: '0.1.2', |
16 | 16 | fonts : [], |
17 | 17 | set: function( font ) { |
18 | 18 | if ( !font || font === 'none' ) { |
19 | | - $.webfonts.reset(); |
| 19 | + mw.webfonts.reset(); |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | | - if ( !( font in $.webfonts.config.fonts ) ) { |
| 23 | + if ( !( font in mw.webfonts.config.fonts ) ) { |
24 | 24 | mw.log( 'Requested unknown font', font ); |
25 | 25 | return; |
26 | 26 | } |
27 | | - var config = $.webfonts.config.fonts[font]; |
| 27 | + var config = mw.webfonts.config.fonts[font]; |
28 | 28 | |
29 | 29 | // Load the style sheet for the font |
30 | | - $.webfonts.addFont( font ); |
| 30 | + mw.webfonts.addFont( font ); |
31 | 31 | |
32 | 32 | // Save the current font and its size. Used for reset. |
33 | | - if ( !$.webfonts.oldconfig ) { |
| 33 | + if ( !mw.webfonts.oldconfig ) { |
34 | 34 | var $body = $( 'body' ); |
35 | | - $.webfonts.oldconfig = { |
| 35 | + mw.webfonts.oldconfig = { |
36 | 36 | fontFamily: $body.css( 'font-family' ), |
37 | 37 | fontSize: $body.css( 'font-size' ) |
38 | 38 | }; |
— | — | @@ -42,14 +42,14 @@ |
43 | 43 | |
44 | 44 | if ( 'normalization' in config ) { |
45 | 45 | $( document ).ready( function() { |
46 | | - $.webfonts.normalize( config.normalization ); |
| 46 | + mw.webfonts.normalize( config.normalization ); |
47 | 47 | } ); |
48 | 48 | } |
49 | 49 | // Store the font choise in cookie |
50 | 50 | $.cookie( 'webfonts-font', font, { 'path': '/', 'expires': 30 } ); |
51 | 51 | |
52 | 52 | // If we had reset the fonts for tags with lang attribute, apply the fonts again. |
53 | | - $.webfonts.loadFontsForLangAttr(); |
| 53 | + mw.webfonts.loadFontsForLangAttr(); |
54 | 54 | }, |
55 | 55 | |
56 | 56 | /** |
— | — | @@ -57,11 +57,11 @@ |
58 | 58 | */ |
59 | 59 | reset: function() { |
60 | 60 | $( 'body' ).css( { |
61 | | - fontFamily: $.webfonts.oldconfig.fontFamily, |
62 | | - fontSize: $.webfonts.oldconfig.fontSize |
| 61 | + fontFamily: mw.webfonts.oldconfig.fontFamily, |
| 62 | + fontSize: mw.webfonts.oldconfig.fontSize |
63 | 63 | }); |
64 | 64 | // We need to reset the font family of Input and Select explicitly. |
65 | | - $( 'input, select' ).css( 'font-family', $.webfonts.oldconfig.fontFamily ); |
| 65 | + $( 'input, select' ).css( 'font-family', mw.webfonts.oldconfig.fontFamily ); |
66 | 66 | |
67 | 67 | // Reset the fonts applied for tags with lang attribute. |
68 | 68 | $( '.webfonts-lang-attr' ).css( 'font-family', 'none' ).removeClass( 'webfonts-lang-attr' ); |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | * @param fontFamily The font-family name |
103 | 103 | */ |
104 | 104 | loadCSS: function( fontFamily ) { |
105 | | - var fontconfig = $.webfonts.config.fonts[fontFamily]; |
| 105 | + var fontconfig = mw.webfonts.config.fonts[fontFamily]; |
106 | 106 | var base = mw.config.get( 'wgExtensionAssetsPath' ) + '/WebFonts/fonts/'; |
107 | 107 | var fontFormats = []; |
108 | 108 | var styleString = |
— | — | @@ -148,11 +148,11 @@ |
149 | 149 | */ |
150 | 150 | addFont: function( fontFamilyName ) { |
151 | 151 | // Avoid duplicate loading |
152 | | - if ( $.inArray( fontFamilyName, $.webfonts.fonts ) === -1 ) { |
| 152 | + if ( $.inArray( fontFamilyName, mw.webfonts.fonts ) === -1 ) { |
153 | 153 | // Check whether the requested font is available. |
154 | | - if ( fontFamilyName in $.webfonts.config.fonts ) { |
155 | | - $.webfonts.loadCSS( fontFamilyName ); |
156 | | - $.webfonts.fonts.push( fontFamilyName ); |
| 154 | + if ( fontFamilyName in mw.webfonts.config.fonts ) { |
| 155 | + mw.webfonts.loadCSS( fontFamilyName ); |
| 156 | + mw.webfonts.fonts.push( fontFamilyName ); |
157 | 157 | } |
158 | 158 | } |
159 | 159 | }, |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | */ |
165 | 165 | setup: function() { |
166 | 166 | var config = []; |
167 | | - var languages = $.webfonts.config.languages; |
| 167 | + var languages = mw.webfonts.config.languages; |
168 | 168 | var requested = [mw.config.get( 'wgUserVariant' ), mw.config.get( 'wgContentLanguage' ), mw.config.get( 'wgUserLanguage' )]; |
169 | 169 | |
170 | 170 | for ( var i = 0; i < requested.length; i++ ) { |
— | — | @@ -178,7 +178,7 @@ |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Build font dropdown |
182 | | - $.webfonts.buildMenu( config ); |
| 182 | + mw.webfonts.buildMenu( config ); |
183 | 183 | // See if there is a font in cookie if not first font is default font. |
184 | 184 | var cookieFont = $.cookie( 'webfonts-font' ); |
185 | 185 | var selectedFont = null; |
— | — | @@ -192,18 +192,18 @@ |
193 | 193 | selectedFont = config[0]; |
194 | 194 | } |
195 | 195 | if ( selectedFont && selectedFont !== 'none' ) { |
196 | | - $.webfonts.set( selectedFont ); |
| 196 | + mw.webfonts.set( selectedFont ); |
197 | 197 | // Mark it as checked |
198 | 198 | $( '#'+fontID( selectedFont ) ).prop( 'checked', true ); |
199 | 199 | } |
200 | 200 | |
201 | | - $.webfonts.loadFontsForFontFamilyStyle(); |
202 | | - $.webfonts.loadFontsForLangAttr(); |
| 201 | + mw.webfonts.loadFontsForFontFamilyStyle(); |
| 202 | + mw.webfonts.loadFontsForLangAttr(); |
203 | 203 | |
204 | 204 | if ( $( '.webfonts-lang-attr' ).length && !$( '#webfonts-fontsmenu' ).length ) { |
205 | 205 | // We need to show the reset option even if there is no font to show |
206 | 206 | // for the language, if there is lang attr based font embedding. |
207 | | - $.webfonts.buildMenu( config ); |
| 207 | + mw.webfonts.buildMenu( config ); |
208 | 208 | } |
209 | 209 | }, |
210 | 210 | |
— | — | @@ -212,13 +212,13 @@ |
213 | 213 | * for that language if available. |
214 | 214 | */ |
215 | 215 | loadFontsForLangAttr: function() { |
216 | | - var languages = $.webfonts.config.languages; |
| 216 | + var languages = mw.webfonts.config.languages; |
217 | 217 | // If there are tags with lang attribute, |
218 | 218 | $( 'body' ).find( '*[lang]' ).each( function( index ) { |
219 | 219 | // .. check the availability of font, add a font-family style if it does not have any |
220 | 220 | if( languages[this.lang] && ( !this.style.fontFamily || this.style.fontFamily === 'none' ) ) { |
221 | 221 | fontFamily = languages[this.lang][0]; |
222 | | - $.webfonts.addFont( fontFamily ); |
| 222 | + mw.webfonts.addFont( fontFamily ); |
223 | 223 | $(this).css( 'font-family', fontFamily ).addClass( 'webfonts-lang-attr' ); |
224 | 224 | } |
225 | 225 | }); |
— | — | @@ -230,7 +230,7 @@ |
231 | 231 | * If that font is available, embed it. |
232 | 232 | */ |
233 | 233 | loadFontsForFontFamilyStyle: function() { |
234 | | - var languages = $.webfonts.config.languages; |
| 234 | + var languages = mw.webfonts.config.languages; |
235 | 235 | // If there are tags with font-family style definition, get a list of fonts to be loaded |
236 | 236 | $( 'body' ).find( '*[style]' ).each( function( index ) { |
237 | 237 | if( this.style.fontFamily ) { |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 | $.each( fontFamilyItems, function( index, fontFamily ) { |
240 | 240 | // Remove the ' characters if any. |
241 | 241 | fontFamily = fontFamily.replace( /'/g, '' ); |
242 | | - $.webfonts.addFont( fontFamily ); |
| 242 | + mw.webfonts.addFont( fontFamily ); |
243 | 243 | }); |
244 | 244 | } |
245 | 245 | }); |
— | — | @@ -254,7 +254,7 @@ |
255 | 255 | // Build font dropdown |
256 | 256 | var $fontsMenu = $( '<ul>' ).attr( 'id', 'webfonts-fontsmenu' ); |
257 | 257 | $fontsMenu.delegate( 'input:radio', 'change', function( e ) { |
258 | | - $.webfonts.set( $(this).val() ); |
| 258 | + mw.webfonts.set( $(this).val() ); |
259 | 259 | } ); |
260 | 260 | for ( var scheme in config ) { |
261 | 261 | var $fontLink = $( '<input type="radio" />' ) |
— | — | @@ -288,7 +288,7 @@ |
289 | 289 | .attr( 'value', 'webfont-none' ) |
290 | 290 | .attr( 'id', 'webfont-none' ) |
291 | 291 | .click( function( e ) { |
292 | | - $.webfonts.set( 'none' ); |
| 292 | + mw.webfonts.set( 'none' ); |
293 | 293 | }); |
294 | 294 | |
295 | 295 | var $resetLabel = $( '<label>' ) |
— | — | @@ -336,7 +336,7 @@ |
337 | 337 | }; |
338 | 338 | |
339 | 339 | $( document ).ready( function() { |
340 | | - $.webfonts.setup(); |
| 340 | + mw.webfonts.setup(); |
341 | 341 | } ); |
342 | 342 | |
343 | 343 | } ) ( jQuery ); |
Index: trunk/extensions/WebFonts/resources/ext.webfonts.fontlist.js |
— | — | @@ -4,9 +4,9 @@ |
5 | 5 | */ |
6 | 6 | |
7 | 7 | ( function ( $ ) { |
8 | | - $.webfonts = {}; |
| 8 | + mw.webfonts = {}; |
9 | 9 | |
10 | | - $.webfonts.config = { |
| 10 | + mw.webfonts.config = { |
11 | 11 | fonts: { |
12 | 12 | RufScript: { |
13 | 13 | eot: "Latn/Rufscript.eot", |