http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90792
Revision: 90792
Author: krinkle
Date: 2011-06-25 19:38:56 +0000 (Sat, 25 Jun 2011)
Log Message:
-----------
Extension to load a different version of jQuery without hacking core. Hooks
into startup module and loads a WikiModule for MediaWiki:JQuery.js instead
Added Paths:
-----------
trunk/extensions/LocalJQuery/
trunk/extensions/LocalJQuery/LocalJQuery.php
Added: trunk/extensions/LocalJQuery/LocalJQuery.php
===================================================================
--- trunk/extensions/LocalJQuery/LocalJQuery.php
(rev 0)
+++ trunk/extensions/LocalJQuery/LocalJQuery.php 2011-06-25 19:38:56 UTC
(rev 90792)
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Local jQuery - An extension to load jQuery from the wiki
+ *
+ *
+ * For more info see http://mediawiki.org/wiki/Extension:Local_jQuery
+ *
+ * @file
+ * @ingroup Extensions
+ * @author Timo Tijhof, [email protected]
+ * @copyright © 2011 Timo Tijhof
+ * @license Creative Commons 1.0 Universal (CC0 1.0) Public Domain Dedication
+ */
+
+if( !defined( 'MEDIAWIKI' ) ) {
+ echo( "This file is an extension to the MediaWiki software and cannot
be used standalone.\n" );
+ die( 1 );
+}
+
+if ( version_compare( $wgVersion, '1.18', '<' ) ) {
+ die( "LocalJQuery extension requires MediaWiki 1.18+\n" );
+}
+
+$wgExtensionCredits['other'][] = array(
+ 'path' => __FILE__,
+ 'name' => 'Local jQuery',
+ 'author' => array( 'Timo Tijhof' ),
+ 'url' => 'http://mediawiki.org/wiki/Extension:Local_jQuery',
+ 'descriptionmsg' => 'Load jQuery from [[MediaWiki:JQuery.js]] (with
ResourceLoader)',
+);
+
+// Create a wiki module for MediaWiki:JQuery.js
+class JQueryWikiModule extends ResourceLoaderWikiModule {
+ protected function getPages( ResourceLoaderContext $context ) {
+ return array(
+ 'MediaWiki:JQuery.js' => array( 'type' => 'script' ),
+ );
+ }
+}
+
+// Register it
+$wgResourceModules['jquery-wiki'] = array(
+ 'class' => 'JQueryWikiModule',
+);
+
+// Load it during startup instead of the default jquery
+$wgHooks['ResourceLoaderGetStartupModules'][] = 'efLoadJQueryFromWiki';
+function efLoadJQueryFromWiki( &$modules ) {
+ $key = array_search( 'jquery', $modules );
+ if ( $key !== false ) {
+ $modules[$key] = 'jquery-wiki';
+ } else {
+ $modules[] = 'jquery-wiki';
+ }
+ return true;
+}
Property changes on: trunk/extensions/LocalJQuery/LocalJQuery.php
___________________________________________________________________
Added: svn:eol-style
+ native
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs