Index: trunk/extensions/WebFonts/resources/ext.webfonts.js |
— | — | @@ -0,0 +1,335 @@ |
| 2 | +(function($){ |
| 3 | + |
| 4 | + function fontID(font) { |
| 5 | + if ( typeof font !== 'string' ) { |
| 6 | + return font; |
| 7 | + } |
| 8 | + return "webfont-"+font.toLowerCase().replace(/[_ ]/g, '-').replace(/[^-a-z]/g, ''); |
| 9 | + } |
| 10 | + |
| 11 | + $.webfonts = { |
| 12 | + |
| 13 | + oldconfig: false, |
| 14 | + config: $.webfonts.config, |
| 15 | + /* Version number */ |
| 16 | + version: "0.1.2", |
| 17 | + fonts : [], |
| 18 | + set: function( font ) { |
| 19 | + if ( !font || font === "none" ) { |
| 20 | + $.webfonts.reset(); |
| 21 | + return; |
| 22 | + } |
| 23 | + |
| 24 | + if ( !(font in $.webfonts.config.fonts) ) { |
| 25 | + mw.log( "Requested unknown font", font ); |
| 26 | + return; |
| 27 | + } |
| 28 | + var config = $.webfonts.config.fonts[font]; |
| 29 | + |
| 30 | + //load the style sheet for the font |
| 31 | + $.webfonts.addFont(font); |
| 32 | + |
| 33 | + //save the current font and its size. Used for reset. |
| 34 | + if ( !$.webfonts.oldconfig ) { |
| 35 | + var $body = $("body"); |
| 36 | + $.webfonts.oldconfig = { |
| 37 | + "font-family": $body.css('font-family'), |
| 38 | + "font-size": $body.css('font-size') |
| 39 | + }; |
| 40 | + } |
| 41 | + |
| 42 | + //Set the font, fallback fonts.Need to change the fonts of Input Select and Textarea explicitly. |
| 43 | + $("body, input, select, textarea").css('font-family', "'"+ font +"', Helvetica, Arial, sans-serif"); |
| 44 | + |
| 45 | + if ( 'normalization' in config ) { |
| 46 | + $(document).ready(function() { |
| 47 | + $.webfonts.normalize(config.normalization); |
| 48 | + }); |
| 49 | + } |
| 50 | + //set the font option in cookie |
| 51 | + $.cookie( 'webfonts-font', font, { 'path': '/', 'expires': 30 } ); |
| 52 | + |
| 53 | + // If we had reset the fonts for tags with lang attribute, apply the fonts again. |
| 54 | + $.webfonts.loadFontsForLangAttr(); |
| 55 | + }, |
| 56 | + |
| 57 | + /** |
| 58 | + * Reset the font with old configuration |
| 59 | + */ |
| 60 | + reset: function() { |
| 61 | + $("body").css({ |
| 62 | + 'font-family': $.webfonts.oldconfig["font-family"], |
| 63 | + //reset the font size from old configuration |
| 64 | + 'font-size': $.webfonts.oldconfig["font-size"] |
| 65 | + }); |
| 66 | + //we need to reset the fonts of Input and Select explicitly. |
| 67 | + $("input, select").css('font-family', $.webfonts.oldconfig["font-family"]); |
| 68 | + |
| 69 | + // Reset the fonts applied for tags with lang attribute. |
| 70 | + $(".webfonts-lang-attr").css( 'font-family', 'none' ).removeClass( 'webfonts-lang-attr' ); |
| 71 | + |
| 72 | + //remove the cookie |
| 73 | + $.cookie( 'webfonts-font', 'none', { 'path': '/', 'expires': 30 } ); |
| 74 | + }, |
| 75 | + |
| 76 | + /** |
| 77 | + * Does a find replace of string on the page. |
| 78 | + * @param normalization_rules hashmap of replacement rules. |
| 79 | + */ |
| 80 | + normalize: function(normalization_rules) { |
| 81 | + $.each(normalization_rules, function(search, replace) { |
| 82 | + var search_pattern = new RegExp(search,"g"); |
| 83 | + return $("*").each(function() { |
| 84 | + var node = this.firstChild, |
| 85 | + val, new_val; |
| 86 | + if ( node ) { |
| 87 | + do { |
| 88 | + if ( node.nodeType === 3 ) { |
| 89 | + val = node.nodeValue; |
| 90 | + new_val = val.replace(search_pattern, replace); |
| 91 | + if ( new_val !== val ) { |
| 92 | + node.nodeValue = new_val; |
| 93 | + } |
| 94 | + } |
| 95 | + } while ( node = node.nextSibling ); |
| 96 | + } |
| 97 | + }); |
| 98 | + }); |
| 99 | + }, |
| 100 | + |
| 101 | + /* |
| 102 | + * Construct the css required for the fontfamily, inject it to the head of the body |
| 103 | + * so that it gets loaded. |
| 104 | + * @param fontfamily The fontfamily name |
| 105 | + */ |
| 106 | + loadcss: function(fontfamily) { |
| 107 | + var fontconfig = $.webfonts.config.fonts[fontfamily]; |
| 108 | + var base = mw.config.get( "wgExtensionAssetsPath" ) + "/WebFonts/fonts/"; |
| 109 | + var styleString = |
| 110 | + "<style type='text/css'>\n@font-face {\n" |
| 111 | + + "\tfont-family: '"+fontfamily+"';\n"; |
| 112 | + if ( 'eot' in fontconfig ) { |
| 113 | + styleString += "\tsrc: url('"+base+fontconfig.eot+"');\n"; |
| 114 | + } |
| 115 | + styleString += "\tsrc: "; |
| 116 | + // If the font is present locally, use it. |
| 117 | + var ua = navigator.userAgent; |
| 118 | + if( ua.match( /Android 2\.3/ ) == null ) { |
| 119 | + // Android 2.3.x does not respect local() syntax. |
| 120 | + // http://code.google.com/p/android/issues/detail?id=10609 |
| 121 | + styleString += "local('"+fontfamily+"'),"; |
| 122 | + } |
| 123 | + |
| 124 | + if ( 'woff' in fontconfig ) { |
| 125 | + styleString += "\t\turl('"+base+fontconfig.woff+"') format('woff'),"; |
| 126 | + } |
| 127 | + if ( 'svg' in fontconfig ) { |
| 128 | + styleString += "\t\turl('"+base+fontconfig.svg+"#"+fontfamily+"') format('svg'),"; |
| 129 | + } |
| 130 | + if ( 'ttf' in fontconfig ) { |
| 131 | + styleString += "\t\turl('"+base+fontconfig.ttf+"') format('truetype');\n"; |
| 132 | + } |
| 133 | + |
| 134 | + styleString += "\tfont-weight: normal;\n}\n</style>\n"; |
| 135 | + |
| 136 | + //inject the css to the head of the page. |
| 137 | + $(styleString).appendTo("head"); |
| 138 | + |
| 139 | + }, |
| 140 | + |
| 141 | + /* |
| 142 | + * Add a font to the page. |
| 143 | + * This method ensures that css are not duplicated and |
| 144 | + * keep track of added fonts. |
| 145 | + * @param fontFamilyName The fontfamily name |
| 146 | + */ |
| 147 | + addFont: function( fontFamilyName ) { |
| 148 | + // avoid duplication |
| 149 | + if ( $.inArray( fontFamilyName, $.webfonts.fonts ) < 0 ){ |
| 150 | + // check whether the requested font is available. |
| 151 | + if ( fontFamilyName in $.webfonts.config.fonts ) { |
| 152 | + $.webfonts.loadcss( fontFamilyName ); |
| 153 | + $.webfonts.fonts.push( fontFamilyName ); |
| 154 | + } |
| 155 | + } |
| 156 | + }, |
| 157 | + |
| 158 | + /** |
| 159 | + * Setup the font selection menu. |
| 160 | + * It also apply the font from cookie, if any. |
| 161 | + */ |
| 162 | + setup: function() { |
| 163 | + var config = []; |
| 164 | + var languages = $.webfonts.config.languages; |
| 165 | + var requested = [mw.config.get( 'wgUserVariant' ), mw.config.get( 'wgContentLanguage' ), mw.config.get( 'wgUserLanguage' )]; |
| 166 | + |
| 167 | + for (var i = 0; i < requested.length; i++) { |
| 168 | + if (requested[i] in languages) { |
| 169 | + var fonts = languages[requested[i]]; |
| 170 | + for (var j = 0; j < fonts.length; j++) { |
| 171 | + if ( $.inArray(fonts[j], config) === -1 ) { |
| 172 | + config.push(fonts[j]); |
| 173 | + } |
| 174 | + } |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + // Build font dropdown |
| 179 | + $.webfonts.buildMenu(config); |
| 180 | + // See if there is a font in cookie if not first font is default font. |
| 181 | + var cookieFont = $.cookie( 'webfonts-font' ); |
| 182 | + var selectedFont = null; |
| 183 | + // check whether this font is for the current userlang/contentlang |
| 184 | + if ( $.inArray(cookieFont, config) !== -1){ |
| 185 | + selectedFont = cookieFont; |
| 186 | + } |
| 187 | + else{ |
| 188 | + // We cannot use cookie font since it is not one of the fonts suitable |
| 189 | + // for current language. |
| 190 | + selectedFont = config[0]; |
| 191 | + } |
| 192 | + if ( selectedFont && selectedFont !== 'none' ) { |
| 193 | + $.webfonts.set( selectedFont ); |
| 194 | + //mark it as checked |
| 195 | + $( '#'+fontID( selectedFont ) ).prop( 'checked', true ); |
| 196 | + } |
| 197 | + |
| 198 | + $.webfonts.loadFontsForFontFamilyStyle(); |
| 199 | + $.webfonts.loadFontsForLangAttr(); |
| 200 | + if ( $(".webfonts-lang-attr").length && !$( '#webfonts-fontsmenu' ).length ){ |
| 201 | + // We need to show the reset option even if there is no font to show |
| 202 | + // for the language, if there is lang attr based font embedding. |
| 203 | + $.webfonts.buildMenu(config); |
| 204 | + } |
| 205 | + }, |
| 206 | + |
| 207 | + /** |
| 208 | + * Scan the page for tags with lang attr and load the default font |
| 209 | + * for that language if available. |
| 210 | + */ |
| 211 | + loadFontsForLangAttr: function() { |
| 212 | + var languages = $.webfonts.config.languages; |
| 213 | + //if there are tags with lang attribute, |
| 214 | + $('body').find('*[lang]').each(function(index) { |
| 215 | + //check the availability of font. |
| 216 | + //add a font-family style if it does not have any |
| 217 | + if( languages[this.lang] && ( !this.style.fontFamily || this.style.fontFamily == "none" ) ) { |
| 218 | + fontFamily = languages[this.lang][0]; |
| 219 | + $.webfonts.addFont( fontFamily ); |
| 220 | + $(this).css('font-family', fontFamily).addClass('webfonts-lang-attr'); |
| 221 | + } |
| 222 | + }); |
| 223 | + |
| 224 | + }, |
| 225 | + |
| 226 | + /** |
| 227 | + * Scan the page for tags with font-family style declarations |
| 228 | + * If that font is available, embed it. |
| 229 | + */ |
| 230 | + loadFontsForFontFamilyStyle: function() { |
| 231 | + var languages = $.webfonts.config.languages; |
| 232 | + //if there are tags with font-family style definition, get a list of fonts to be loaded |
| 233 | + $('body').find('*[style]').each(function(index) { |
| 234 | + if( this.style.fontFamily ) { |
| 235 | + var fontFamilyItems = this.style.fontFamily.split(","); |
| 236 | + $.each( fontFamilyItems, function(index, fontFamily) { |
| 237 | + //remove the ' characters if any. |
| 238 | + fontFamily = fontFamily.replace(/'/g, ''); |
| 239 | + $.webfonts.addFont( fontFamily ); |
| 240 | + }); |
| 241 | + } |
| 242 | + }); |
| 243 | + |
| 244 | + }, |
| 245 | + |
| 246 | + /** |
| 247 | + * Prepare the menu for the webfonts. |
| 248 | + * @param config The webfont configuration. |
| 249 | + */ |
| 250 | + buildMenu: function(config) { |
| 251 | + var haveSchemes = false; |
| 252 | + // Build font dropdown |
| 253 | + var $fontsMenu = $( '<ul>' ).attr('id','webfonts-fontsmenu'); |
| 254 | + $fontsMenu.delegate('input:radio', 'change', function( event ) { |
| 255 | + $.webfonts.set( $(this).val() ); |
| 256 | + }); |
| 257 | + for ( var scheme in config ) { |
| 258 | + var $fontLink = $( '<input type="radio" />' ) |
| 259 | + .attr( "name", "font" ) |
| 260 | + .attr( "id", fontID( config[scheme] ) ) |
| 261 | + .val( config[scheme] ); |
| 262 | + |
| 263 | + var $fontLabel = $( '<label>' ) |
| 264 | + .attr("for",fontID(config[scheme])) |
| 265 | + .append( $fontLink ) |
| 266 | + .append( config[scheme] ); |
| 267 | + |
| 268 | + var $fontMenuItem = $( '<li>' ) |
| 269 | + .val( config[scheme] ) |
| 270 | + .append( $fontLabel ); |
| 271 | + |
| 272 | + haveSchemes = true; |
| 273 | + |
| 274 | + $fontsMenu.append($fontMenuItem); |
| 275 | + |
| 276 | + } |
| 277 | + |
| 278 | + if ( !haveSchemes && !$('.webfonts-lang-attr').length ) { |
| 279 | + // No schemes available, and no tags with lang attr |
| 280 | + // with fonts loaded. Don't show the menu. |
| 281 | + return; |
| 282 | + } |
| 283 | + |
| 284 | + var $resetLink = $( '<input type="radio" />' ) |
| 285 | + .attr("name","font") |
| 286 | + .attr("value","webfont-none") |
| 287 | + .attr("id","webfont-none") |
| 288 | + .click( function( event ) { |
| 289 | + $.webfonts.set( 'none'); |
| 290 | + }); |
| 291 | + |
| 292 | + var $resetLabel = $( '<label>' ) |
| 293 | + .attr("for","webfont-none") |
| 294 | + .append( $resetLink ) |
| 295 | + .append( mw.msg("webfonts-reset")); |
| 296 | + |
| 297 | + var $resetLinkItem = $( '<li>' ) |
| 298 | + .val( 'none' ) |
| 299 | + .append( $resetLabel ); |
| 300 | + |
| 301 | + $fontsMenu.append($resetLinkItem); |
| 302 | + |
| 303 | + var $menuDiv = $( '<div>' ).attr('id','webfonts-fonts') |
| 304 | + .addClass( 'menu' ) |
| 305 | + .append( $fontsMenu ) |
| 306 | + .append(); |
| 307 | + |
| 308 | + var $div = $( '<div>' ).attr('id','webfonts-menu') |
| 309 | + .addClass( 'webfontMenu' ) |
| 310 | + .append( $('<a>').prop( 'href', '#' ).append( mw.msg( "webfonts-load" ) ) ) |
| 311 | + .append( $menuDiv ); |
| 312 | + |
| 313 | + //this is the fonts link |
| 314 | + var $li = $( '<li>' ).attr('id','pt-webfont') |
| 315 | + .append( $div ); |
| 316 | + |
| 317 | + //if rtl, add to the right of top personal links. Else, to the left |
| 318 | + var fn = $('body').hasClass( 'rtl' ) ? "append" : "prepend"; |
| 319 | + $('#p-personal ul:first')[fn]( $li ); |
| 320 | + //workaround for IE bug - activex components like input fields coming on top of everything. |
| 321 | + //TODO: is there a better solution other than hiding it on hover? |
| 322 | + if ( $.browser.msie ) { |
| 323 | + $("#webfonts-menu").hover(function(){ |
| 324 | + $("#searchform").css({ visibility: "hidden" }); |
| 325 | + },function(){ |
| 326 | + $("#searchform").css({ visibility: "visible" }); |
| 327 | + }); |
| 328 | + } |
| 329 | + } |
| 330 | + }; |
| 331 | + |
| 332 | + $( document ).ready( function() { |
| 333 | + $.webfonts.setup(); |
| 334 | + } ); |
| 335 | + |
| 336 | +})(jQuery); |
Property changes on: trunk/extensions/WebFonts/resources/ext.webfonts.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 337 | + native |
Index: trunk/extensions/WebFonts/resources/ext.webfonts.fontlist.js |
— | — | @@ -0,0 +1,320 @@ |
| 2 | +/** |
| 3 | + * Configuration file for webfonts |
| 4 | + * First font is the default font for the language |
| 5 | + */ |
| 6 | + |
| 7 | +(function ($) { |
| 8 | + $.webfonts = {}; |
| 9 | + |
| 10 | + $.webfonts.config = { |
| 11 | + fonts: { |
| 12 | + RufScript: { |
| 13 | + eot: "Latn/Rufscript.eot", |
| 14 | + ttf: "Latn/Rufscript.ttf", |
| 15 | + woff: "Latn/Rufscript.woff" |
| 16 | + }, |
| 17 | + |
| 18 | + Perizia: { |
| 19 | + eot: "Latn/Perizia.eot", |
| 20 | + ttf: "Latn/Perizia.ttf", |
| 21 | + woff: "Latn/Perizia.woff" |
| 22 | + }, |
| 23 | + |
| 24 | + Ubuntu: { |
| 25 | + eot: "Latn/ubuntu-r-webfont.eot", |
| 26 | + ttf: "Latn/ubuntu-r.ttf", |
| 27 | + woff: "Latn/ubuntu-r-webfont.woff", |
| 28 | + svg: "Latn/ubuntu-r-webfont.svg" |
| 29 | + }, |
| 30 | + |
| 31 | + AnjaliOldLipi: { |
| 32 | + eot: "Mlym/AnjaliOldLipi.eot", |
| 33 | + ttf: "Mlym/AnjaliOldLipi.ttf", |
| 34 | + woff: "Mlym/AnjaliOldLipi.woff" |
| 35 | + }, |
| 36 | + |
| 37 | + Meera: { |
| 38 | + eot: "Mlym/Meera.eot", |
| 39 | + ttf: "Mlym/Meera.ttf", |
| 40 | + woff: "Mlym/Meera.woff", |
| 41 | + scale: 1.5, |
| 42 | + normalization: { |
| 43 | + "ൾ": "ള്", |
| 44 | + "ൻ": "ന്", |
| 45 | + "ർ": "ര്", |
| 46 | + "ൺ ": "ണ്", |
| 47 | + "ൽ": "ല്", |
| 48 | + "ൿ": "ക് ", |
| 49 | + "ൻറ": "ന്റ", |
| 50 | + "ന്റെ": "ന്റെ" |
| 51 | + } |
| 52 | + }, |
| 53 | + |
| 54 | + Rachana: { |
| 55 | + eot: "Mlym/Rachana.eot", |
| 56 | + ttf: "Mlym/Rachana.ttf", |
| 57 | + woff: "Mlym/Rachana.woff", |
| 58 | + normalization: { |
| 59 | + "ൾ": "ള്", |
| 60 | + "ൻ": "ന്", |
| 61 | + "ർ": "ര്", |
| 62 | + "ൺ ": "ണ്", |
| 63 | + "ൽ": "ല്", |
| 64 | + "ൿ": "ക് ", |
| 65 | + "ൻറ": "ന്റ", |
| 66 | + "ന്റെ": "ന്റെ" |
| 67 | + } |
| 68 | + }, |
| 69 | + |
| 70 | + RaghuMalayalam: { |
| 71 | + eot: "Mlym/RaghuMalayalam.eot", |
| 72 | + ttf: "Mlym/RaghuMalayalam.ttf", |
| 73 | + woff: "Mlym/RaghuMalayalam.woff", |
| 74 | + normalization: { |
| 75 | + "ൾ": "ള്", |
| 76 | + "ൻ": "ന്", |
| 77 | + "ർ": "ര്", |
| 78 | + "ൺ ": "ണ്", |
| 79 | + "ൽ": "ല്", |
| 80 | + "ൿ": "ക് ", |
| 81 | + "ൻറ": "ന്റ", |
| 82 | + "ന്റെ": "ന്റെ" |
| 83 | + } |
| 84 | + }, |
| 85 | + |
| 86 | + "Lohit Oriya": { |
| 87 | + eot: "Orya/Lohit-Oriya.eot", |
| 88 | + ttf: "Orya/Lohit-Oriya.ttf", |
| 89 | + woff: "Orya/Lohit-Oriya.woff" |
| 90 | + }, |
| 91 | + |
| 92 | + "Utkal": { |
| 93 | + eot: "Orya/utkal.eot", |
| 94 | + ttf: "Orya/utkal.ttf", |
| 95 | + woff: "Orya/utkal.woff" |
| 96 | + }, |
| 97 | + |
| 98 | + "Lohit Tamil": { |
| 99 | + eot: "Taml/Lohit-Tamil.eot", |
| 100 | + ttf: "Taml/Lohit-Tamil.ttf", |
| 101 | + woff: "Taml/Lohit-Tamil.woff" |
| 102 | + }, |
| 103 | + |
| 104 | + "Lohit Telugu": { |
| 105 | + eot: "Telu/LohitTelugu.eot", |
| 106 | + ttf: "Telu/LohitTelugu.ttf", |
| 107 | + woff: "Telu/LohitTelugu.woff" |
| 108 | + }, |
| 109 | + |
| 110 | + "Lohit Bengali": { |
| 111 | + eot: "Beng/LohitBengali.eot", |
| 112 | + ttf: "Beng/LohitBengali.ttf", |
| 113 | + woff: "Beng/LohitBengali.woff" |
| 114 | + }, |
| 115 | + |
| 116 | + "Samyak Gujarati": { |
| 117 | + eot: "Gujr/SamyakGujarati.eot", |
| 118 | + ttf: "Gujr/SamyakGujarati.ttf", |
| 119 | + woff: "Gujr/SamyakGujarati.woff" |
| 120 | + }, |
| 121 | + |
| 122 | + "Lohit Hindi": { |
| 123 | + eot: "Deva/LohitHindi.eot", |
| 124 | + ttf: "Deva/LohitHindi.ttf", |
| 125 | + woff: "Deva/LohitHindi.woff" |
| 126 | + }, |
| 127 | + |
| 128 | + "Samyak Devanagari": { |
| 129 | + eot: "Deva/SamyakDevanagari.eot", |
| 130 | + ttf: "Deva/SamyakDevanagari.ttf", |
| 131 | + woff: "Deva/SamyakDevanagari.woff" |
| 132 | + }, |
| 133 | + |
| 134 | + "Miriam CLM": { |
| 135 | + eot: "Hebr/MiriamCLM-Book.eot", |
| 136 | + ttf: "Hebr/MiriamCLM-Book.ttf", |
| 137 | + woff: "Hebr/MiriamCLM-Book.woff" |
| 138 | + }, |
| 139 | + |
| 140 | + "Taamey Frank CLM": { |
| 141 | + eot: "Hebr/TaameyFrankCLM.eot", |
| 142 | + ttf: "Hebr/TaameyFrankCLM.ttf", |
| 143 | + woff: "Hebr/TaameyFrankCLM.woff", |
| 144 | + svg: "Hebr/TaameyFrankCLM.svg" |
| 145 | + }, |
| 146 | + |
| 147 | + Kedage: { |
| 148 | + eot: "Knda/Kedage.eot", |
| 149 | + ttf: "Knda/Kedage.ttf", |
| 150 | + woff: "Knda/Kedage.woff" |
| 151 | + }, |
| 152 | + |
| 153 | + "Lohit Kannada": { |
| 154 | + eot: "Knda/LohitKannada.eot", |
| 155 | + ttf: "Knda/LohitKannada.ttf", |
| 156 | + woff: "Knda/LohitKannada.woff" |
| 157 | + }, |
| 158 | + |
| 159 | + "Masterpiece Uni Sans": { |
| 160 | + eot: "Mymr/MasterpieceUniSans.eot", |
| 161 | + ttf: "Mymr/MasterpieceUniSans.ttf", |
| 162 | + woff: "Mymr/MasterpieceUniSans.woff", |
| 163 | + svg: "Mymr/MasterpieceUniSans.svg" |
| 164 | + }, |
| 165 | + |
| 166 | + "Padauk-Regular": { |
| 167 | + eot: "Mymr/Padauk-Regular.eot", |
| 168 | + ttf: "Mymr/Padauk-Regular.ttf", |
| 169 | + woff: "Mymr/Padauk-Regular.woff", |
| 170 | + svg: "Mymr/Padauk-Regular.svg" |
| 171 | + }, |
| 172 | + |
| 173 | + Myanmar3: { |
| 174 | + eot: "Mymr/Myanmar3.eot", |
| 175 | + ttf: "Mymr/Myanmar3.ttf", |
| 176 | + woff: "Mymr/Myanmar3.woff", |
| 177 | + svg: "Mymr/Myanmar3.svg" |
| 178 | + }, |
| 179 | + |
| 180 | + Yunghkio: { |
| 181 | + eot: "Mymr/Yunghkio.eot", |
| 182 | + ttf: "Mymr/Yunghkio.ttf", |
| 183 | + woff: "Mymr/Yunghkio.woff", |
| 184 | + svg: "Mymr/Yunghkio.svg" |
| 185 | + }, |
| 186 | + |
| 187 | + KhmerOSbattambang: { |
| 188 | + eot: "Khmr/KhmerOSbattambang.eot", |
| 189 | + ttf: "Khmr/KhmerOSbattambang.ttf", |
| 190 | + woff: "Khmr/KhmerOSbattambang.woff", |
| 191 | + svg: "Khmr/KhmerOSbattambang.svg" |
| 192 | + }, |
| 193 | + |
| 194 | + KhmerOSbokor: { |
| 195 | + eot: "Khmr/KhmerOSbokor.eot", |
| 196 | + ttf: "Khmr/KhmerOSbokor.ttf", |
| 197 | + woff: "Khmr/KhmerOSbokor.woff", |
| 198 | + svg: "Khmr/KhmerOSbokor.svg" |
| 199 | + }, |
| 200 | + |
| 201 | + KhmerOS: { |
| 202 | + eot: "Khmr/KhmerOS.eot", |
| 203 | + ttf: "Khmr/KhmerOS.ttf", |
| 204 | + woff: "Khmr/KhmerOS.woff", |
| 205 | + svg: "Khmr/KhmerOS.svg" |
| 206 | + }, |
| 207 | + |
| 208 | + KhmerOSsiemreap: { |
| 209 | + eot: "Khmr/KhmerOSsiemreap.eot", |
| 210 | + ttf: "Khmr/KhmerOSsiemreap.ttf", |
| 211 | + woff: "Khmr/KhmerOSsiemreap.woff", |
| 212 | + svg: "Khmr/KhmerOSsiemreap.svg" |
| 213 | + }, |
| 214 | + |
| 215 | + KhmerOSmuollight: { |
| 216 | + eot: "Khmr/KhmerOSmuollight.eot", |
| 217 | + ttf: "Khmr/KhmerOSmuollight.ttf", |
| 218 | + woff: "Khmr/KhmerOSmuollight.woff", |
| 219 | + svg: "Khmr/KhmerOSmuollight.svg" |
| 220 | + }, |
| 221 | + |
| 222 | + KhmerOSmuol: { |
| 223 | + eot: "Khmr/KhmerOSmuol.eot", |
| 224 | + ttf: "Khmr/KhmerOSmuol.ttf", |
| 225 | + woff: "Khmr/KhmerOSmuol.woff", |
| 226 | + svg: "Khmr/KhmerOSmuol.svg" |
| 227 | + }, |
| 228 | + |
| 229 | + KhmerOSmuolpali: { |
| 230 | + eot: "Khmr/KhmerOSmuolpali.eot", |
| 231 | + ttf: "Khmr/KhmerOSmuolpali.ttf", |
| 232 | + woff: "Khmr/KhmerOSmuolpali.woff", |
| 233 | + svg: "Khmr/KhmerOSmuolpali.svg" |
| 234 | + }, |
| 235 | + |
| 236 | + KhmerOSfreehand: { |
| 237 | + eot: "Khmr/KhmerOSfreehand.eot", |
| 238 | + ttf: "Khmr/KhmerOSfreehand.ttf", |
| 239 | + woff: "Khmr/KhmerOSfreehand.woff", |
| 240 | + svg: "Khmr/KhmerOSfreehand.svg" |
| 241 | + }, |
| 242 | + |
| 243 | + KhmerOSfasthand: { |
| 244 | + eot: "Khmr/KhmerOSfasthand.eot", |
| 245 | + ttf: "Khmr/KhmerOSfasthand.ttf", |
| 246 | + woff: "Khmr/KhmerOSfasthand.woff", |
| 247 | + svg: "Khmr/KhmerOSfasthand.svg" |
| 248 | + }, |
| 249 | + |
| 250 | + Pagul: { |
| 251 | + eot: "Saur/Pagul.eot", |
| 252 | + ttf: "Saur/Pagul.ttf", |
| 253 | + woff: "Saur/Pagul.woff" |
| 254 | + }, |
| 255 | + |
| 256 | + AbyssinicaSIL: { |
| 257 | + eot: "Ethi/AbyssinicaSIL-R.eot", |
| 258 | + ttf: "Ethi/AbyssinicaSIL-R.ttf", |
| 259 | + woff: "Ethi/AbyssinicaSIL-R.woff" |
| 260 | + }, |
| 261 | + |
| 262 | + "Iranian Sans": { |
| 263 | + eot: "Arab/IranianSans.eot", |
| 264 | + ttf: "Arab/IranianSans.ttf", |
| 265 | + woff: "Arab/IranianSans.woff" |
| 266 | + }, |
| 267 | + |
| 268 | + "Charis SIL": { |
| 269 | + eot: "Latn/CharisSIL-R.eot", |
| 270 | + ttf: "Latn/CharisSIL-R.ttf", |
| 271 | + woff: "Latn/CharisSIL-R.woff" |
| 272 | + }, |
| 273 | + |
| 274 | + "Thendral": { |
| 275 | + eot: "Taml/ThendralUni.eot", |
| 276 | + ttf: "Taml/ThendralUni.ttf", |
| 277 | + woff: "Taml/ThendralUni.woff" |
| 278 | + }, |
| 279 | + |
| 280 | + "Thenee": { |
| 281 | + eot: "Taml/TheneeUni.eot", |
| 282 | + ttf: "Taml/TheneeUni.ttf", |
| 283 | + woff: "Taml/TheneeUni.woff" |
| 284 | + }, |
| 285 | + |
| 286 | + "Vaigai": { |
| 287 | + eot: "Taml/VaigaiUni.eot", |
| 288 | + ttf: "Taml/VaigaiUni.ttf", |
| 289 | + woff: "Taml/VaigaiUni.woff" |
| 290 | + } |
| 291 | + }, |
| 292 | + |
| 293 | + languages: { |
| 294 | + // en: [ "RufScript", "Perizia", "Ubuntu" ], |
| 295 | + ml: [ "AnjaliOldLipi", "Meera", "Rachana", "RaghuMalayalam" ], |
| 296 | + or: [ "Lohit Oriya" , "Utkal" ], |
| 297 | + ta: [ "Lohit Tamil", "Thendral", "Thenee", "Vaigai" ], |
| 298 | + te: [ "Lohit Telugu" ], |
| 299 | + bn: [ "Lohit Bengali" ], |
| 300 | + as: [ "Lohit Bengali" ], |
| 301 | + bpy: [ "Lohit Bengali" ], |
| 302 | + gu: [ "Samyak Gujarati" ], |
| 303 | + hi: [ "Samyak Devanagari", "Lohit Hindi" ], |
| 304 | + mr: [ "Samyak Devanagari", "Lohit Hindi" ], |
| 305 | + ks: [ "Samyak Devanagari", "Lohit Hindi" ], |
| 306 | + sa: [ "Lohit Hindi", "Samyak Devanagari" ], |
| 307 | + he: [ "Miriam CLM", "Taamey Frank CLM" ], |
| 308 | + hbo: [ "Taamey Frank CLM" ], |
| 309 | + kn: [ "Kedage", "Lohit Kannada" ], |
| 310 | + my: [ "Masterpiece Uni Sans", "Padauk-Regular", "Myanmar3", "Yunghkio" ], |
| 311 | + km: [ "KhmerOSbattambang", "KhmerOSsiemreap", "KhmerOS", "KhmerOSbokor", |
| 312 | + "KhmerOSmuollight", "KhmerOSmuol", "KhmerOSmuolpali", |
| 313 | + "KhmerOSfreehand", "KhmerOSfasthand" ], |
| 314 | + saz: [ "Pagul" ], |
| 315 | + am: [ "AbyssinicaSIL" ], |
| 316 | + ti: [ "AbyssinicaSIL" ], |
| 317 | + fa: [ "Iranian Sans" ], |
| 318 | + cdo: [ "Charis SIL" ] |
| 319 | + } |
| 320 | + }; |
| 321 | +})(jQuery); |
Property changes on: trunk/extensions/WebFonts/resources/ext.webfonts.fontlist.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 322 | + native |
Index: trunk/extensions/WebFonts/resources/images/font-icon.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/extensions/WebFonts/resources/images/font-icon.png |
___________________________________________________________________ |
Added: svn:mime-type |
2 | 323 | + image/png |
Index: trunk/extensions/WebFonts/resources/ext.webfonts.css |
— | — | @@ -0,0 +1,126 @@ |
| 2 | +li#pt-webfont{ |
| 3 | + /* @embed */ |
| 4 | + background: url(images/font-icon.png) no-repeat scroll left top transparent; |
| 5 | + padding-left: 15px !important; |
| 6 | +} |
| 7 | + |
| 8 | +div#webfonts-menu{ |
| 9 | + font-size: 100%; |
| 10 | + z-index: 99999; |
| 11 | +} |
| 12 | + |
| 13 | +div#webfonts-fonts{ |
| 14 | + font-size: 100%; |
| 15 | + z-index: 99999; |
| 16 | +} |
| 17 | + |
| 18 | + |
| 19 | +div#webfonts-menu .menu ul{ |
| 20 | + padding-left:5px!important; |
| 21 | +} |
| 22 | + |
| 23 | + |
| 24 | +div#webfonts-fonts li{ |
| 25 | + margin: 0; |
| 26 | + padding:5px; |
| 27 | + font-size: 100%; |
| 28 | + float: none; |
| 29 | +} |
| 30 | + |
| 31 | +/* Variants and Actions */ |
| 32 | +/* @noflip */ |
| 33 | +div.webfontMenu { |
| 34 | + direction: ltr; |
| 35 | + float: left; |
| 36 | + cursor: pointer; |
| 37 | +} |
| 38 | +div.webfontMenuFocus { |
| 39 | + background-position: -22px 60%; |
| 40 | +} |
| 41 | + |
| 42 | +/* @noflip */ |
| 43 | +body.rtl div.webfontMenu ul li { |
| 44 | + direction: rtl; |
| 45 | +} |
| 46 | + |
| 47 | +div.webfontMenu div.menu { |
| 48 | + position: relative; |
| 49 | + display: none; |
| 50 | + clear: both; |
| 51 | + text-align: left; |
| 52 | +} |
| 53 | + |
| 54 | +/* OVERRIDDEN BY COMPLIANT BROWSERS */ |
| 55 | +/* @noflip */ |
| 56 | +body.rtl div.webfontMenu div.menu { |
| 57 | + margin-left: 24px; |
| 58 | +} |
| 59 | +/* IGNORED BY IE6 */ |
| 60 | +/* @noflip */ |
| 61 | +body.rtl div.webfontMenu > div.menu { |
| 62 | + margin-left: auto; |
| 63 | +} |
| 64 | +/* IGNORED BY IE6 */ |
| 65 | +/* Also fixes old versions of FireFox */ |
| 66 | +/* @noflip */ |
| 67 | +body.rtl div.webfontMenu > div.menu, |
| 68 | +x:-moz-any-link { |
| 69 | + margin-left: 23px; |
| 70 | +} |
| 71 | +/* Enable forcing showing of the menu for accessibility */ |
| 72 | +div.webfontMenu:hover div.menu, div.webfontMenu div.menuForceShow { |
| 73 | + display: block; |
| 74 | +} |
| 75 | +div.webfontMenu ul { |
| 76 | + position: absolute; |
| 77 | + background-color: white; |
| 78 | + border: solid 1px silver; |
| 79 | + border-top-width: 0; |
| 80 | + list-style: none; |
| 81 | + list-style-image: none; |
| 82 | + list-style-type: none; |
| 83 | + padding: 0; |
| 84 | + margin: 0; |
| 85 | + margin-left: -1px; |
| 86 | + text-align: left; |
| 87 | +} |
| 88 | +/* Fixes old versions of FireFox */ |
| 89 | +div.webfontMenu ul, |
| 90 | +x:-moz-any-link { |
| 91 | + min-width: 5em; |
| 92 | +} |
| 93 | +/* Returns things back to normal in modern versions of FireFox */ |
| 94 | +div.webfontMenu ul, |
| 95 | +x:-moz-any-link, |
| 96 | +x:default { |
| 97 | + min-width: 0; |
| 98 | +} |
| 99 | +div.webfontMenu li { |
| 100 | + padding: 0; |
| 101 | + margin: 0; |
| 102 | + text-align: left; |
| 103 | + line-height: 1em; |
| 104 | +} |
| 105 | +/* OVERRIDDEN BY COMPLIANT BROWSERS */ |
| 106 | +div.webfontMenu li a { |
| 107 | + display: inline-block; |
| 108 | + padding: 0.5em; |
| 109 | + white-space: nowrap; |
| 110 | + color: #0645ad; |
| 111 | + cursor: pointer; |
| 112 | + font-size: 0.8em; |
| 113 | +} |
| 114 | +/* IGNORED BY IE6 */ |
| 115 | +div.webfontMenu li > a { |
| 116 | + display: block; |
| 117 | +} |
| 118 | +div.webfontMenu li.selected a, |
| 119 | +div.webfontMenu li.selected a:visited { |
| 120 | + color: #333333; |
| 121 | + text-decoration: none; |
| 122 | +} |
| 123 | +div.webfontMenu a { |
| 124 | + display: block; |
| 125 | + padding-left:5px; |
| 126 | + padding-right:5px; |
| 127 | +} |
Property changes on: trunk/extensions/WebFonts/resources/ext.webfonts.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 128 | + native |
Index: trunk/extensions/WebFonts/js/webfonts.js |
— | — | @@ -1,335 +0,0 @@ |
2 | | -(function($){ |
3 | | - |
4 | | - function fontID(font) { |
5 | | - if ( typeof font !== 'string' ) { |
6 | | - return font; |
7 | | - } |
8 | | - return "webfont-"+font.toLowerCase().replace(/[_ ]/g, '-').replace(/[^-a-z]/g, ''); |
9 | | - } |
10 | | - |
11 | | - $.webfonts = { |
12 | | - |
13 | | - oldconfig: false, |
14 | | - config: $.webfonts.config, |
15 | | - /* Version number */ |
16 | | - version: "0.1.2", |
17 | | - fonts : [], |
18 | | - set: function( font ) { |
19 | | - if ( !font || font === "none" ) { |
20 | | - $.webfonts.reset(); |
21 | | - return; |
22 | | - } |
23 | | - |
24 | | - if ( !(font in $.webfonts.config.fonts) ) { |
25 | | - mw.log( "Requested unknown font", font ); |
26 | | - return; |
27 | | - } |
28 | | - var config = $.webfonts.config.fonts[font]; |
29 | | - |
30 | | - //load the style sheet for the font |
31 | | - $.webfonts.addFont(font); |
32 | | - |
33 | | - //save the current font and its size. Used for reset. |
34 | | - if ( !$.webfonts.oldconfig ) { |
35 | | - var $body = $("body"); |
36 | | - $.webfonts.oldconfig = { |
37 | | - "font-family": $body.css('font-family'), |
38 | | - "font-size": $body.css('font-size') |
39 | | - }; |
40 | | - } |
41 | | - |
42 | | - //Set the font, fallback fonts.Need to change the fonts of Input Select and Textarea explicitly. |
43 | | - $("body, input, select, textarea").css('font-family', "'"+ font +"', Helvetica, Arial, sans-serif"); |
44 | | - |
45 | | - if ( 'normalization' in config ) { |
46 | | - $(document).ready(function() { |
47 | | - $.webfonts.normalize(config.normalization); |
48 | | - }); |
49 | | - } |
50 | | - //set the font option in cookie |
51 | | - $.cookie( 'webfonts-font', font, { 'path': '/', 'expires': 30 } ); |
52 | | - |
53 | | - // If we had reset the fonts for tags with lang attribute, apply the fonts again. |
54 | | - $.webfonts.loadFontsForLangAttr(); |
55 | | - }, |
56 | | - |
57 | | - /** |
58 | | - * Reset the font with old configuration |
59 | | - */ |
60 | | - reset: function() { |
61 | | - $("body").css({ |
62 | | - 'font-family': $.webfonts.oldconfig["font-family"], |
63 | | - //reset the font size from old configuration |
64 | | - 'font-size': $.webfonts.oldconfig["font-size"] |
65 | | - }); |
66 | | - //we need to reset the fonts of Input and Select explicitly. |
67 | | - $("input, select").css('font-family', $.webfonts.oldconfig["font-family"]); |
68 | | - |
69 | | - // Reset the fonts applied for tags with lang attribute. |
70 | | - $(".webfonts-lang-attr").css( 'font-family', 'none' ).removeClass( 'webfonts-lang-attr' ); |
71 | | - |
72 | | - //remove the cookie |
73 | | - $.cookie( 'webfonts-font', 'none', { 'path': '/', 'expires': 30 } ); |
74 | | - }, |
75 | | - |
76 | | - /** |
77 | | - * Does a find replace of string on the page. |
78 | | - * @param normalization_rules hashmap of replacement rules. |
79 | | - */ |
80 | | - normalize: function(normalization_rules) { |
81 | | - $.each(normalization_rules, function(search, replace) { |
82 | | - var search_pattern = new RegExp(search,"g"); |
83 | | - return $("*").each(function() { |
84 | | - var node = this.firstChild, |
85 | | - val, new_val; |
86 | | - if ( node ) { |
87 | | - do { |
88 | | - if ( node.nodeType === 3 ) { |
89 | | - val = node.nodeValue; |
90 | | - new_val = val.replace(search_pattern, replace); |
91 | | - if ( new_val !== val ) { |
92 | | - node.nodeValue = new_val; |
93 | | - } |
94 | | - } |
95 | | - } while ( node = node.nextSibling ); |
96 | | - } |
97 | | - }); |
98 | | - }); |
99 | | - }, |
100 | | - |
101 | | - /* |
102 | | - * Construct the css required for the fontfamily, inject it to the head of the body |
103 | | - * so that it gets loaded. |
104 | | - * @param fontfamily The fontfamily name |
105 | | - */ |
106 | | - loadcss: function(fontfamily) { |
107 | | - var fontconfig = $.webfonts.config.fonts[fontfamily]; |
108 | | - var base = mw.config.get( "wgExtensionAssetsPath" ) + "/WebFonts/fonts/"; |
109 | | - var styleString = |
110 | | - "<style type='text/css'>\n@font-face {\n" |
111 | | - + "\tfont-family: '"+fontfamily+"';\n"; |
112 | | - if ( 'eot' in fontconfig ) { |
113 | | - styleString += "\tsrc: url('"+base+fontconfig.eot+"');\n"; |
114 | | - } |
115 | | - styleString += "\tsrc: "; |
116 | | - // If the font is present locally, use it. |
117 | | - var ua = navigator.userAgent; |
118 | | - if( ua.match( /Android 2\.3/ ) == null ) { |
119 | | - // Android 2.3.x does not respect local() syntax. |
120 | | - // http://code.google.com/p/android/issues/detail?id=10609 |
121 | | - styleString += "local('"+fontfamily+"'),"; |
122 | | - } |
123 | | - |
124 | | - if ( 'woff' in fontconfig ) { |
125 | | - styleString += "\t\turl('"+base+fontconfig.woff+"') format('woff'),"; |
126 | | - } |
127 | | - if ( 'svg' in fontconfig ) { |
128 | | - styleString += "\t\turl('"+base+fontconfig.svg+"#"+fontfamily+"') format('svg'),"; |
129 | | - } |
130 | | - if ( 'ttf' in fontconfig ) { |
131 | | - styleString += "\t\turl('"+base+fontconfig.ttf+"') format('truetype');\n"; |
132 | | - } |
133 | | - |
134 | | - styleString += "\tfont-weight: normal;\n}\n</style>\n"; |
135 | | - |
136 | | - //inject the css to the head of the page. |
137 | | - $(styleString).appendTo("head"); |
138 | | - |
139 | | - }, |
140 | | - |
141 | | - /* |
142 | | - * Add a font to the page. |
143 | | - * This method ensures that css are not duplicated and |
144 | | - * keep track of added fonts. |
145 | | - * @param fontFamilyName The fontfamily name |
146 | | - */ |
147 | | - addFont: function( fontFamilyName ) { |
148 | | - // avoid duplication |
149 | | - if ( $.inArray( fontFamilyName, $.webfonts.fonts ) < 0 ){ |
150 | | - // check whether the requested font is available. |
151 | | - if ( fontFamilyName in $.webfonts.config.fonts ) { |
152 | | - $.webfonts.loadcss( fontFamilyName ); |
153 | | - $.webfonts.fonts.push( fontFamilyName ); |
154 | | - } |
155 | | - } |
156 | | - }, |
157 | | - |
158 | | - /** |
159 | | - * Setup the font selection menu. |
160 | | - * It also apply the font from cookie, if any. |
161 | | - */ |
162 | | - setup: function() { |
163 | | - var config = []; |
164 | | - var languages = $.webfonts.config.languages; |
165 | | - var requested = [mw.config.get( 'wgUserVariant' ), mw.config.get( 'wgContentLanguage' ), mw.config.get( 'wgUserLanguage' )]; |
166 | | - |
167 | | - for (var i = 0; i < requested.length; i++) { |
168 | | - if (requested[i] in languages) { |
169 | | - var fonts = languages[requested[i]]; |
170 | | - for (var j = 0; j < fonts.length; j++) { |
171 | | - if ( $.inArray(fonts[j], config) === -1 ) { |
172 | | - config.push(fonts[j]); |
173 | | - } |
174 | | - } |
175 | | - } |
176 | | - } |
177 | | - |
178 | | - // Build font dropdown |
179 | | - $.webfonts.buildMenu(config); |
180 | | - // See if there is a font in cookie if not first font is default font. |
181 | | - var cookieFont = $.cookie( 'webfonts-font' ); |
182 | | - var selectedFont = null; |
183 | | - // check whether this font is for the current userlang/contentlang |
184 | | - if ( $.inArray(cookieFont, config) !== -1){ |
185 | | - selectedFont = cookieFont; |
186 | | - } |
187 | | - else{ |
188 | | - // We cannot use cookie font since it is not one of the fonts suitable |
189 | | - // for current language. |
190 | | - selectedFont = config[0]; |
191 | | - } |
192 | | - if ( selectedFont && selectedFont !== 'none' ) { |
193 | | - $.webfonts.set( selectedFont ); |
194 | | - //mark it as checked |
195 | | - $( '#'+fontID( selectedFont ) ).prop( 'checked', true ); |
196 | | - } |
197 | | - |
198 | | - $.webfonts.loadFontsForFontFamilyStyle(); |
199 | | - $.webfonts.loadFontsForLangAttr(); |
200 | | - if ( $(".webfonts-lang-attr").length && !$( '#webfonts-fontsmenu' ).length ){ |
201 | | - // We need to show the reset option even if there is no font to show |
202 | | - // for the language, if there is lang attr based font embedding. |
203 | | - $.webfonts.buildMenu(config); |
204 | | - } |
205 | | - }, |
206 | | - |
207 | | - /** |
208 | | - * Scan the page for tags with lang attr and load the default font |
209 | | - * for that language if available. |
210 | | - */ |
211 | | - loadFontsForLangAttr: function() { |
212 | | - var languages = $.webfonts.config.languages; |
213 | | - //if there are tags with lang attribute, |
214 | | - $('body').find('*[lang]').each(function(index) { |
215 | | - //check the availability of font. |
216 | | - //add a font-family style if it does not have any |
217 | | - if( languages[this.lang] && ( !this.style.fontFamily || this.style.fontFamily == "none" ) ) { |
218 | | - fontFamily = languages[this.lang][0]; |
219 | | - $.webfonts.addFont( fontFamily ); |
220 | | - $(this).css('font-family', fontFamily).addClass('webfonts-lang-attr'); |
221 | | - } |
222 | | - }); |
223 | | - |
224 | | - }, |
225 | | - |
226 | | - /** |
227 | | - * Scan the page for tags with font-family style declarations |
228 | | - * If that font is available, embed it. |
229 | | - */ |
230 | | - loadFontsForFontFamilyStyle: function() { |
231 | | - var languages = $.webfonts.config.languages; |
232 | | - //if there are tags with font-family style definition, get a list of fonts to be loaded |
233 | | - $('body').find('*[style]').each(function(index) { |
234 | | - if( this.style.fontFamily ) { |
235 | | - var fontFamilyItems = this.style.fontFamily.split(","); |
236 | | - $.each( fontFamilyItems, function(index, fontFamily) { |
237 | | - //remove the ' characters if any. |
238 | | - fontFamily = fontFamily.replace(/'/g, ''); |
239 | | - $.webfonts.addFont( fontFamily ); |
240 | | - }); |
241 | | - } |
242 | | - }); |
243 | | - |
244 | | - }, |
245 | | - |
246 | | - /** |
247 | | - * Prepare the menu for the webfonts. |
248 | | - * @param config The webfont configuration. |
249 | | - */ |
250 | | - buildMenu: function(config) { |
251 | | - var haveSchemes = false; |
252 | | - // Build font dropdown |
253 | | - var $fontsMenu = $( '<ul>' ).attr('id','webfonts-fontsmenu'); |
254 | | - $fontsMenu.delegate('input:radio', 'change', function( event ) { |
255 | | - $.webfonts.set( $(this).val() ); |
256 | | - }); |
257 | | - for ( var scheme in config ) { |
258 | | - var $fontLink = $( '<input type="radio" />' ) |
259 | | - .attr( "name", "font" ) |
260 | | - .attr( "id", fontID( config[scheme] ) ) |
261 | | - .val( config[scheme] ); |
262 | | - |
263 | | - var $fontLabel = $( '<label>' ) |
264 | | - .attr("for",fontID(config[scheme])) |
265 | | - .append( $fontLink ) |
266 | | - .append( config[scheme] ); |
267 | | - |
268 | | - var $fontMenuItem = $( '<li>' ) |
269 | | - .val( config[scheme] ) |
270 | | - .append( $fontLabel ); |
271 | | - |
272 | | - haveSchemes = true; |
273 | | - |
274 | | - $fontsMenu.append($fontMenuItem); |
275 | | - |
276 | | - } |
277 | | - |
278 | | - if ( !haveSchemes && !$('.webfonts-lang-attr').length ) { |
279 | | - // No schemes available, and no tags with lang attr |
280 | | - // with fonts loaded. Don't show the menu. |
281 | | - return; |
282 | | - } |
283 | | - |
284 | | - var $resetLink = $( '<input type="radio" />' ) |
285 | | - .attr("name","font") |
286 | | - .attr("value","webfont-none") |
287 | | - .attr("id","webfont-none") |
288 | | - .click( function( event ) { |
289 | | - $.webfonts.set( 'none'); |
290 | | - }); |
291 | | - |
292 | | - var $resetLabel = $( '<label>' ) |
293 | | - .attr("for","webfont-none") |
294 | | - .append( $resetLink ) |
295 | | - .append( mw.msg("webfonts-reset")); |
296 | | - |
297 | | - var $resetLinkItem = $( '<li>' ) |
298 | | - .val( 'none' ) |
299 | | - .append( $resetLabel ); |
300 | | - |
301 | | - $fontsMenu.append($resetLinkItem); |
302 | | - |
303 | | - var $menuDiv = $( '<div>' ).attr('id','webfonts-fonts') |
304 | | - .addClass( 'menu' ) |
305 | | - .append( $fontsMenu ) |
306 | | - .append(); |
307 | | - |
308 | | - var $div = $( '<div>' ).attr('id','webfonts-menu') |
309 | | - .addClass( 'webfontMenu' ) |
310 | | - .append( $('<a>').prop( 'href', '#' ).append( mw.msg( "webfonts-load" ) ) ) |
311 | | - .append( $menuDiv ); |
312 | | - |
313 | | - //this is the fonts link |
314 | | - var $li = $( '<li>' ).attr('id','pt-webfont') |
315 | | - .append( $div ); |
316 | | - |
317 | | - //if rtl, add to the right of top personal links. Else, to the left |
318 | | - var fn = $('body').hasClass( 'rtl' ) ? "append" : "prepend"; |
319 | | - $('#p-personal ul:first')[fn]( $li ); |
320 | | - //workaround for IE bug - activex components like input fields coming on top of everything. |
321 | | - //TODO: is there a better solution other than hiding it on hover? |
322 | | - if ( $.browser.msie ) { |
323 | | - $("#webfonts-menu").hover(function(){ |
324 | | - $("#searchform").css({ visibility: "hidden" }); |
325 | | - },function(){ |
326 | | - $("#searchform").css({ visibility: "visible" }); |
327 | | - }); |
328 | | - } |
329 | | - } |
330 | | - }; |
331 | | - |
332 | | - $( document ).ready( function() { |
333 | | - $.webfonts.setup(); |
334 | | - } ); |
335 | | - |
336 | | -})(jQuery); |
Index: trunk/extensions/WebFonts/js/webfonts.fontlist.js |
— | — | @@ -1,320 +0,0 @@ |
2 | | -/** |
3 | | - * Configuration file for webfonts |
4 | | - * First font is the default font for the language |
5 | | - */ |
6 | | - |
7 | | -(function ($) { |
8 | | - $.webfonts = {}; |
9 | | - |
10 | | - $.webfonts.config = { |
11 | | - fonts: { |
12 | | - RufScript: { |
13 | | - eot: "Latn/Rufscript.eot", |
14 | | - ttf: "Latn/Rufscript.ttf", |
15 | | - woff: "Latn/Rufscript.woff" |
16 | | - }, |
17 | | - |
18 | | - Perizia: { |
19 | | - eot: "Latn/Perizia.eot", |
20 | | - ttf: "Latn/Perizia.ttf", |
21 | | - woff: "Latn/Perizia.woff" |
22 | | - }, |
23 | | - |
24 | | - Ubuntu: { |
25 | | - eot: "Latn/ubuntu-r-webfont.eot", |
26 | | - ttf: "Latn/ubuntu-r.ttf", |
27 | | - woff: "Latn/ubuntu-r-webfont.woff", |
28 | | - svg: "Latn/ubuntu-r-webfont.svg" |
29 | | - }, |
30 | | - |
31 | | - AnjaliOldLipi: { |
32 | | - eot: "Mlym/AnjaliOldLipi.eot", |
33 | | - ttf: "Mlym/AnjaliOldLipi.ttf", |
34 | | - woff: "Mlym/AnjaliOldLipi.woff" |
35 | | - }, |
36 | | - |
37 | | - Meera: { |
38 | | - eot: "Mlym/Meera.eot", |
39 | | - ttf: "Mlym/Meera.ttf", |
40 | | - woff: "Mlym/Meera.woff", |
41 | | - scale: 1.5, |
42 | | - normalization: { |
43 | | - "ൾ": "ള്", |
44 | | - "ൻ": "ന്", |
45 | | - "ർ": "ര്", |
46 | | - "ൺ ": "ണ്", |
47 | | - "ൽ": "ല്", |
48 | | - "ൿ": "ക് ", |
49 | | - "ൻറ": "ന്റ", |
50 | | - "ന്റെ": "ന്റെ" |
51 | | - } |
52 | | - }, |
53 | | - |
54 | | - Rachana: { |
55 | | - eot: "Mlym/Rachana.eot", |
56 | | - ttf: "Mlym/Rachana.ttf", |
57 | | - woff: "Mlym/Rachana.woff", |
58 | | - normalization: { |
59 | | - "ൾ": "ള്", |
60 | | - "ൻ": "ന്", |
61 | | - "ർ": "ര്", |
62 | | - "ൺ ": "ണ്", |
63 | | - "ൽ": "ല്", |
64 | | - "ൿ": "ക് ", |
65 | | - "ൻറ": "ന്റ", |
66 | | - "ന്റെ": "ന്റെ" |
67 | | - } |
68 | | - }, |
69 | | - |
70 | | - RaghuMalayalam: { |
71 | | - eot: "Mlym/RaghuMalayalam.eot", |
72 | | - ttf: "Mlym/RaghuMalayalam.ttf", |
73 | | - woff: "Mlym/RaghuMalayalam.woff", |
74 | | - normalization: { |
75 | | - "ൾ": "ള്", |
76 | | - "ൻ": "ന്", |
77 | | - "ർ": "ര്", |
78 | | - "ൺ ": "ണ്", |
79 | | - "ൽ": "ല്", |
80 | | - "ൿ": "ക് ", |
81 | | - "ൻറ": "ന്റ", |
82 | | - "ന്റെ": "ന്റെ" |
83 | | - } |
84 | | - }, |
85 | | - |
86 | | - "Lohit Oriya": { |
87 | | - eot: "Orya/Lohit-Oriya.eot", |
88 | | - ttf: "Orya/Lohit-Oriya.ttf", |
89 | | - woff: "Orya/Lohit-Oriya.woff" |
90 | | - }, |
91 | | - |
92 | | - "Utkal": { |
93 | | - eot: "Orya/utkal.eot", |
94 | | - ttf: "Orya/utkal.ttf", |
95 | | - woff: "Orya/utkal.woff" |
96 | | - }, |
97 | | - |
98 | | - "Lohit Tamil": { |
99 | | - eot: "Taml/Lohit-Tamil.eot", |
100 | | - ttf: "Taml/Lohit-Tamil.ttf", |
101 | | - woff: "Taml/Lohit-Tamil.woff" |
102 | | - }, |
103 | | - |
104 | | - "Lohit Telugu": { |
105 | | - eot: "Telu/LohitTelugu.eot", |
106 | | - ttf: "Telu/LohitTelugu.ttf", |
107 | | - woff: "Telu/LohitTelugu.woff" |
108 | | - }, |
109 | | - |
110 | | - "Lohit Bengali": { |
111 | | - eot: "Beng/LohitBengali.eot", |
112 | | - ttf: "Beng/LohitBengali.ttf", |
113 | | - woff: "Beng/LohitBengali.woff" |
114 | | - }, |
115 | | - |
116 | | - "Samyak Gujarati": { |
117 | | - eot: "Gujr/SamyakGujarati.eot", |
118 | | - ttf: "Gujr/SamyakGujarati.ttf", |
119 | | - woff: "Gujr/SamyakGujarati.woff" |
120 | | - }, |
121 | | - |
122 | | - "Lohit Hindi": { |
123 | | - eot: "Deva/LohitHindi.eot", |
124 | | - ttf: "Deva/LohitHindi.ttf", |
125 | | - woff: "Deva/LohitHindi.woff" |
126 | | - }, |
127 | | - |
128 | | - "Samyak Devanagari": { |
129 | | - eot: "Deva/SamyakDevanagari.eot", |
130 | | - ttf: "Deva/SamyakDevanagari.ttf", |
131 | | - woff: "Deva/SamyakDevanagari.woff" |
132 | | - }, |
133 | | - |
134 | | - "Miriam CLM": { |
135 | | - eot: "Hebr/MiriamCLM-Book.eot", |
136 | | - ttf: "Hebr/MiriamCLM-Book.ttf", |
137 | | - woff: "Hebr/MiriamCLM-Book.woff" |
138 | | - }, |
139 | | - |
140 | | - "Taamey Frank CLM": { |
141 | | - eot: "Hebr/TaameyFrankCLM.eot", |
142 | | - ttf: "Hebr/TaameyFrankCLM.ttf", |
143 | | - woff: "Hebr/TaameyFrankCLM.woff", |
144 | | - svg: "Hebr/TaameyFrankCLM.svg" |
145 | | - }, |
146 | | - |
147 | | - Kedage: { |
148 | | - eot: "Knda/Kedage.eot", |
149 | | - ttf: "Knda/Kedage.ttf", |
150 | | - woff: "Knda/Kedage.woff" |
151 | | - }, |
152 | | - |
153 | | - "Lohit Kannada": { |
154 | | - eot: "Knda/LohitKannada.eot", |
155 | | - ttf: "Knda/LohitKannada.ttf", |
156 | | - woff: "Knda/LohitKannada.woff" |
157 | | - }, |
158 | | - |
159 | | - "Masterpiece Uni Sans": { |
160 | | - eot: "Mymr/MasterpieceUniSans.eot", |
161 | | - ttf: "Mymr/MasterpieceUniSans.ttf", |
162 | | - woff: "Mymr/MasterpieceUniSans.woff", |
163 | | - svg: "Mymr/MasterpieceUniSans.svg" |
164 | | - }, |
165 | | - |
166 | | - "Padauk-Regular": { |
167 | | - eot: "Mymr/Padauk-Regular.eot", |
168 | | - ttf: "Mymr/Padauk-Regular.ttf", |
169 | | - woff: "Mymr/Padauk-Regular.woff", |
170 | | - svg: "Mymr/Padauk-Regular.svg" |
171 | | - }, |
172 | | - |
173 | | - Myanmar3: { |
174 | | - eot: "Mymr/Myanmar3.eot", |
175 | | - ttf: "Mymr/Myanmar3.ttf", |
176 | | - woff: "Mymr/Myanmar3.woff", |
177 | | - svg: "Mymr/Myanmar3.svg" |
178 | | - }, |
179 | | - |
180 | | - Yunghkio: { |
181 | | - eot: "Mymr/Yunghkio.eot", |
182 | | - ttf: "Mymr/Yunghkio.ttf", |
183 | | - woff: "Mymr/Yunghkio.woff", |
184 | | - svg: "Mymr/Yunghkio.svg" |
185 | | - }, |
186 | | - |
187 | | - KhmerOSbattambang: { |
188 | | - eot: "Khmr/KhmerOSbattambang.eot", |
189 | | - ttf: "Khmr/KhmerOSbattambang.ttf", |
190 | | - woff: "Khmr/KhmerOSbattambang.woff", |
191 | | - svg: "Khmr/KhmerOSbattambang.svg" |
192 | | - }, |
193 | | - |
194 | | - KhmerOSbokor: { |
195 | | - eot: "Khmr/KhmerOSbokor.eot", |
196 | | - ttf: "Khmr/KhmerOSbokor.ttf", |
197 | | - woff: "Khmr/KhmerOSbokor.woff", |
198 | | - svg: "Khmr/KhmerOSbokor.svg" |
199 | | - }, |
200 | | - |
201 | | - KhmerOS: { |
202 | | - eot: "Khmr/KhmerOS.eot", |
203 | | - ttf: "Khmr/KhmerOS.ttf", |
204 | | - woff: "Khmr/KhmerOS.woff", |
205 | | - svg: "Khmr/KhmerOS.svg" |
206 | | - }, |
207 | | - |
208 | | - KhmerOSsiemreap: { |
209 | | - eot: "Khmr/KhmerOSsiemreap.eot", |
210 | | - ttf: "Khmr/KhmerOSsiemreap.ttf", |
211 | | - woff: "Khmr/KhmerOSsiemreap.woff", |
212 | | - svg: "Khmr/KhmerOSsiemreap.svg" |
213 | | - }, |
214 | | - |
215 | | - KhmerOSmuollight: { |
216 | | - eot: "Khmr/KhmerOSmuollight.eot", |
217 | | - ttf: "Khmr/KhmerOSmuollight.ttf", |
218 | | - woff: "Khmr/KhmerOSmuollight.woff", |
219 | | - svg: "Khmr/KhmerOSmuollight.svg" |
220 | | - }, |
221 | | - |
222 | | - KhmerOSmuol: { |
223 | | - eot: "Khmr/KhmerOSmuol.eot", |
224 | | - ttf: "Khmr/KhmerOSmuol.ttf", |
225 | | - woff: "Khmr/KhmerOSmuol.woff", |
226 | | - svg: "Khmr/KhmerOSmuol.svg" |
227 | | - }, |
228 | | - |
229 | | - KhmerOSmuolpali: { |
230 | | - eot: "Khmr/KhmerOSmuolpali.eot", |
231 | | - ttf: "Khmr/KhmerOSmuolpali.ttf", |
232 | | - woff: "Khmr/KhmerOSmuolpali.woff", |
233 | | - svg: "Khmr/KhmerOSmuolpali.svg" |
234 | | - }, |
235 | | - |
236 | | - KhmerOSfreehand: { |
237 | | - eot: "Khmr/KhmerOSfreehand.eot", |
238 | | - ttf: "Khmr/KhmerOSfreehand.ttf", |
239 | | - woff: "Khmr/KhmerOSfreehand.woff", |
240 | | - svg: "Khmr/KhmerOSfreehand.svg" |
241 | | - }, |
242 | | - |
243 | | - KhmerOSfasthand: { |
244 | | - eot: "Khmr/KhmerOSfasthand.eot", |
245 | | - ttf: "Khmr/KhmerOSfasthand.ttf", |
246 | | - woff: "Khmr/KhmerOSfasthand.woff", |
247 | | - svg: "Khmr/KhmerOSfasthand.svg" |
248 | | - }, |
249 | | - |
250 | | - Pagul: { |
251 | | - eot: "Saur/Pagul.eot", |
252 | | - ttf: "Saur/Pagul.ttf", |
253 | | - woff: "Saur/Pagul.woff" |
254 | | - }, |
255 | | - |
256 | | - AbyssinicaSIL: { |
257 | | - eot: "Ethi/AbyssinicaSIL-R.eot", |
258 | | - ttf: "Ethi/AbyssinicaSIL-R.ttf", |
259 | | - woff: "Ethi/AbyssinicaSIL-R.woff" |
260 | | - }, |
261 | | - |
262 | | - "Iranian Sans": { |
263 | | - eot: "Arab/IranianSans.eot", |
264 | | - ttf: "Arab/IranianSans.ttf", |
265 | | - woff: "Arab/IranianSans.woff" |
266 | | - }, |
267 | | - |
268 | | - "Charis SIL": { |
269 | | - eot: "Latn/CharisSIL-R.eot", |
270 | | - ttf: "Latn/CharisSIL-R.ttf", |
271 | | - woff: "Latn/CharisSIL-R.woff" |
272 | | - }, |
273 | | - |
274 | | - "Thendral": { |
275 | | - eot: "Taml/ThendralUni.eot", |
276 | | - ttf: "Taml/ThendralUni.ttf", |
277 | | - woff: "Taml/ThendralUni.woff" |
278 | | - }, |
279 | | - |
280 | | - "Thenee": { |
281 | | - eot: "Taml/TheneeUni.eot", |
282 | | - ttf: "Taml/TheneeUni.ttf", |
283 | | - woff: "Taml/TheneeUni.woff" |
284 | | - }, |
285 | | - |
286 | | - "Vaigai": { |
287 | | - eot: "Taml/VaigaiUni.eot", |
288 | | - ttf: "Taml/VaigaiUni.ttf", |
289 | | - woff: "Taml/VaigaiUni.woff" |
290 | | - } |
291 | | - }, |
292 | | - |
293 | | - languages: { |
294 | | - // en: [ "RufScript", "Perizia", "Ubuntu" ], |
295 | | - ml: [ "AnjaliOldLipi", "Meera", "Rachana", "RaghuMalayalam" ], |
296 | | - or: [ "Lohit Oriya" , "Utkal" ], |
297 | | - ta: [ "Lohit Tamil", "Thendral", "Thenee", "Vaigai" ], |
298 | | - te: [ "Lohit Telugu" ], |
299 | | - bn: [ "Lohit Bengali" ], |
300 | | - as: [ "Lohit Bengali" ], |
301 | | - bpy: [ "Lohit Bengali" ], |
302 | | - gu: [ "Samyak Gujarati" ], |
303 | | - hi: [ "Samyak Devanagari", "Lohit Hindi" ], |
304 | | - mr: [ "Samyak Devanagari", "Lohit Hindi" ], |
305 | | - ks: [ "Samyak Devanagari", "Lohit Hindi" ], |
306 | | - sa: [ "Lohit Hindi", "Samyak Devanagari" ], |
307 | | - he: [ "Miriam CLM", "Taamey Frank CLM" ], |
308 | | - hbo: [ "Taamey Frank CLM" ], |
309 | | - kn: [ "Kedage", "Lohit Kannada" ], |
310 | | - my: [ "Masterpiece Uni Sans", "Padauk-Regular", "Myanmar3", "Yunghkio" ], |
311 | | - km: [ "KhmerOSbattambang", "KhmerOSsiemreap", "KhmerOS", "KhmerOSbokor", |
312 | | - "KhmerOSmuollight", "KhmerOSmuol", "KhmerOSmuolpali", |
313 | | - "KhmerOSfreehand", "KhmerOSfasthand" ], |
314 | | - saz: [ "Pagul" ], |
315 | | - am: [ "AbyssinicaSIL" ], |
316 | | - ti: [ "AbyssinicaSIL" ], |
317 | | - fa: [ "Iranian Sans" ], |
318 | | - cdo: [ "Charis SIL" ] |
319 | | - } |
320 | | - }; |
321 | | -})(jQuery); |
Index: trunk/extensions/WebFonts/WebFonts.php |
— | — | @@ -41,16 +41,16 @@ |
42 | 42 | $wgWebFontsEnabledByDefault = true; |
43 | 43 | |
44 | 44 | $wgResourceModules['webfonts'] = array( |
45 | | - 'scripts' => 'js/webfonts.js', |
46 | | - 'styles' => 'css/webfonts.css', |
| 45 | + 'scripts' => 'resources/ext.webfonts.js', |
| 46 | + 'styles' => 'resources/ext.webfonts.css', |
47 | 47 | 'localBasePath' => $dir, |
48 | 48 | 'remoteExtPath' => 'WebFonts', |
49 | 49 | 'messages' => array( 'webfonts-load', 'webfonts-reset' ), |
50 | | - 'dependencies' => array( 'jquery.cookie', 'webfonts.fontlist'), |
| 50 | + 'dependencies' => array( 'jquery.cookie', 'ext.webfonts.fontlist'), |
51 | 51 | ); |
52 | 52 | |
53 | | -$wgResourceModules['webfonts.fontlist'] = array( |
54 | | - 'scripts' => 'js/webfonts.fontlist.js', |
| 53 | +$wgResourceModules['ext.webfonts.fontlist'] = array( |
| 54 | + 'scripts' => 'resources/ext.webfonts.fontlist.js', |
55 | 55 | 'localBasePath' => $dir, |
56 | 56 | 'remoteExtPath' => 'WebFonts', |
57 | 57 | ); |