MediaWiki r35064 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r35063‎ | r35064 (on ViewVC)‎ | 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:

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
===================================================================
--- trunk/phase3/skins/common/wikibits.js	(revision 35063)
+++ trunk/phase3/skins/common/wikibits.js	(revision 35064)
@@ -31,7 +31,11 @@
 
 function addOnloadHook(hookFunct) {
 	// Allows add-on scripts to add onload functions
-	onloadFuncts[onloadFuncts.length] = hookFunct;
+	if(!doneOnloadHook) {
+		onloadFuncts[onloadFuncts.length] = hookFunct;
+	} else {
+		hookFunct();  // bug in MSIE script loading
+	}
 }
 
 function hookEvent(hookName, hookFunct) {
@@ -42,6 +46,41 @@
 	}
 }
 
+function importScript(page) {
+	return importScriptURI(wgScript + '?action=raw&ctype=text/javascript&title=' + encodeURIComponent(page.replace(/ /g,'_')));
+}
+ 
+var loadedScripts = {}; // included-scripts tracker
+function importScriptURI(url) {
+	if (loadedScripts[url]) {
+		return;
+	}
+	loadedScripts[url] = true;
+	var s = document.createElement('script');
+	s.setAttribute('src',url);
+	s.setAttribute('type','text/javascript');
+	document.getElementsByTagName('head')[0].appendChild(s);
+	return s;
+}
+ 
+function importStylesheet(page) {
+	return importStylesheetURI(wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent(page.replace(/ /g,'_')));
+}
+ 
+function importStylesheetURI(url) {
+	return document.createStyleSheet ? document.createStyleSheet(url) : appendCSS('@import "' + url + '";');
+}
+ 
+function appendCSS(text) {
+	var s = document.createElement('style');
+	s.type = 'text/css';
+	s.rel = 'stylesheet';
+	if (s.styleSheet) s.styleSheet.cssText = text //IE
+	else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
+	document.getElementsByTagName('head')[0].appendChild(s);
+	return s;
+}
+
 // document.write special stylesheet links
 if (typeof stylepath != 'undefined' && typeof skin != 'undefined') {
 	if (is_opera_preseven) {
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 35063)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 35064)
@@ -1347,7 +1347,7 @@
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '145';
+$wgStyleVersion = '146';
 
 
 # Server-side caching:
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 35063)
+++ trunk/phase3/RELEASE-NOTES	(revision 35064)
@@ -117,7 +117,9 @@
 * Use rel="start", "prev", "next" appropriately on Pager-based pages
 * Add support for SQLite
 * AutoAuthenticate hook renamed to UserLoadFromSession
+* (bug 13232) importScript(), importStylesheet() funcs available to custom JS
 
+
 === Bug fixes in 1.13 ===
 
 * (bug 10677) Add link to the file description page on the shared repository
@@ -282,7 +284,10 @@
 * (bug 13693) Categories sometimes claim to have a negative number of members
 * (bug 1701) Korean Hangul syllables now broken down properly in Category lists
   even if the wiki's overall content language is not Korean
+* (bug 12773) addOnloadHook() now calls functions immediately when scripts are
+  loaded after the primary page completion, instead of dropping them
 
+
 === API changes in 1.13 ===
 
 * Fixing main page display in meta=siteinfo

Status & tagging log

  • 15:27, 12 September 2011 Meno25 (Talk | contribs) changed the status of r35064 [removed: ok added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox