Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -95,6 +95,25 @@ |
96 | 96 | }, |
97 | 97 | |
98 | 98 | /** |
| 99 | + * Append a new style block to the head |
| 100 | + * |
| 101 | + * @param text String CSS to be appended |
| 102 | + * @return the CSS stylesheet |
| 103 | + */ |
| 104 | + 'addCSS' : function( text ) { |
| 105 | + var s = document.createElement( 'style' ); |
| 106 | + s.type = 'text/css'; |
| 107 | + s.rel = 'stylesheet'; |
| 108 | + if ( s.styleSheet ) { |
| 109 | + s.styleSheet.cssText = text; // IE |
| 110 | + } else { |
| 111 | + s.appendChild( document.createTextNode( text + '' ) ); // Safari sometimes borks on null |
| 112 | + } |
| 113 | + document.getElementsByTagName("head")[0].appendChild( s ); |
| 114 | + return s.sheet || s; |
| 115 | + }, |
| 116 | + |
| 117 | + /** |
99 | 118 | * Get the full URL to a page name |
100 | 119 | * |
101 | 120 | * @param str Page name to link to |