r35064 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35063‎ | r35064 | r35065 >
Date:22:52, 19 May 2008
Author:brion
Status:old
Tags:
Comment:
* (bug 12773) addOnloadHook() now calls functions immediately when scripts are
loaded after the primary page completion, instead of dropping them
* (bug 13232) importScript(), importStylesheet() funcs available to custom JS

Increases wikibits.js by 1k or so, but it should help with those custom scripts :D
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -31,7 +31,11 @@
3232
3333 function addOnloadHook(hookFunct) {
3434 // Allows add-on scripts to add onload functions
35 - onloadFuncts[onloadFuncts.length] = hookFunct;
 35+ if(!doneOnloadHook) {
 36+ onloadFuncts[onloadFuncts.length] = hookFunct;
 37+ } else {
 38+ hookFunct(); // bug in MSIE script loading
 39+ }
3640 }
3741
3842 function hookEvent(hookName, hookFunct) {
@@ -42,6 +46,41 @@
4347 }
4448 }
4549
 50+function importScript(page) {
 51+ return importScriptURI(wgScript + '?action=raw&ctype=text/javascript&title=' + encodeURIComponent(page.replace(/ /g,'_')));
 52+}
 53+
 54+var loadedScripts = {}; // included-scripts tracker
 55+function importScriptURI(url) {
 56+ if (loadedScripts[url]) {
 57+ return;
 58+ }
 59+ loadedScripts[url] = true;
 60+ var s = document.createElement('script');
 61+ s.setAttribute('src',url);
 62+ s.setAttribute('type','text/javascript');
 63+ document.getElementsByTagName('head')[0].appendChild(s);
 64+ return s;
 65+}
 66+
 67+function importStylesheet(page) {
 68+ return importStylesheetURI(wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent(page.replace(/ /g,'_')));
 69+}
 70+
 71+function importStylesheetURI(url) {
 72+ return document.createStyleSheet ? document.createStyleSheet(url) : appendCSS('@import "' + url + '";');
 73+}
 74+
 75+function appendCSS(text) {
 76+ var s = document.createElement('style');
 77+ s.type = 'text/css';
 78+ s.rel = 'stylesheet';
 79+ if (s.styleSheet) s.styleSheet.cssText = text //IE
 80+ else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
 81+ document.getElementsByTagName('head')[0].appendChild(s);
 82+ return s;
 83+}
 84+
4685 // document.write special stylesheet links
4786 if (typeof stylepath != 'undefined' && typeof skin != 'undefined') {
4887 if (is_opera_preseven) {
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1347,7 +1347,7 @@
13481348 * to ensure that client-side caches don't keep obsolete copies of global
13491349 * styles.
13501350 */
1351 -$wgStyleVersion = '145';
 1351+$wgStyleVersion = '146';
13521352
13531353
13541354 # Server-side caching:
Index: trunk/phase3/RELEASE-NOTES
@@ -117,7 +117,9 @@
118118 * Use rel="start", "prev", "next" appropriately on Pager-based pages
119119 * Add support for SQLite
120120 * AutoAuthenticate hook renamed to UserLoadFromSession
 121+* (bug 13232) importScript(), importStylesheet() funcs available to custom JS
121122
 123+
122124 === Bug fixes in 1.13 ===
123125
124126 * (bug 10677) Add link to the file description page on the shared repository
@@ -282,7 +284,10 @@
283285 * (bug 13693) Categories sometimes claim to have a negative number of members
284286 * (bug 1701) Korean Hangul syllables now broken down properly in Category lists
285287 even if the wiki's overall content language is not Korean
 288+* (bug 12773) addOnloadHook() now calls functions immediately when scripts are
 289+ loaded after the primary page completion, instead of dropping them
286290
 291+
287292 === API changes in 1.13 ===
288293
289294 * Fixing main page display in meta=siteinfo

Status & tagging log