Difference between revisions of "User:Paxed/JQueryWithUI"

From NetHackWiki
Jump to navigation Jump to search
(document briefly the extension.)
 
(correct link)
Line 7: Line 7:
 
* Add <tt>require_once("$IP/extensions/JQueryWithUI/JQueryWithUI.php");</tt> to the end of your LocalSettings.php
 
* Add <tt>require_once("$IP/extensions/JQueryWithUI/JQueryWithUI.php");</tt> to the end of your LocalSettings.php
  
----
+
==Code for JQueryWithUI.php==
Code for JQueryWithUI.php:
 
 
<pre>
 
<pre>
 
<?php
 
<?php
Line 22: Line 21:
 
         'version' => 0.1,
 
         'version' => 0.1,
 
         'author' => '[http://nethackwiki.com/wiki/User:Paxed Pasi Kallinen]',
 
         'author' => '[http://nethackwiki.com/wiki/User:Paxed Pasi Kallinen]',
         'url' => 'http://nethackwiki.com/wiki/NetHackWiki:JQueryWithUI',
+
         'url' => 'http://nethackwiki.com/wiki/User:Paxed/JQueryWithUI',
 
         'description'  => 'Adds JQuery and JQuery-UI to MW 1.16',
 
         'description'  => 'Adds JQuery and JQuery-UI to MW 1.16',
 
);
 
);

Revision as of 10:37, 13 November 2010

To make JQuery v1.4.4 and JQuery-UI v1.8.6 work on NetHackWiki (which uses MediaWiki 1.16), I made a quick'n'dirty extension.

Installation

  • Download JQuery and JQuery-UI, and unzip them into your_wiki_dir/extensions/JQueryWithUI/
  • Save the code below as your_wiki_dir/extensions/JQueryWithUI/JQueryWithUI.php
  • Edit the code so it links to the versions of JQuery and JQuery-UI you set up. (In the code, those are 1.4.4 and 1.8.6)
  • Add require_once("$IP/extensions/JQueryWithUI/JQueryWithUI.php"); to the end of your LocalSettings.php

Code for JQueryWithUI.php

<?php
/**                                                                                                                                          
 * JQueryWithUI - a MediaWiki extension that provides the JQuery and JQueryUI                                                                
 */

if ( !defined( 'MEDIAWIKI' ) ) die();
   
$wgExtensionCredits['other'][] = array(
        'path' => __FILE__,
        'name' => 'JQuery With UI',
        'version' => 0.1,
        'author' => '[http://nethackwiki.com/wiki/User:Paxed Pasi Kallinen]',
        'url' => 'http://nethackwiki.com/wiki/User:Paxed/JQueryWithUI',
        'description'  => 'Adds JQuery and JQuery-UI to MW 1.16',
);
   
$wgHooks['BeforePageDisplay'][] = 'wfJQueryWithUIHeaders';

function wfJQueryWithUIHeaders() {
        global $wgOut;
        wfOutputJQueryWithUIHeaders($wgOut);
        return true;
}

function wfOutputJQueryWithUIHeaders($outputPage) {
        global $wgJsMimeType, $wgStylePath, $wgScriptPath;
        $outputPage->addLink(
                array(
                        'rel' => 'stylesheet',
                        'type' => 'text/css',
                        'href' => $wgScriptPath.'/extensions/JQueryWithUI/css/smoothness/jquery-ui-1.8.6.custom.css'
                )
        );
        $outputPage->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/JQueryWithUI/js/jquery-1.4.4.min.js\"></scr\
ipt>\n");
        $outputPage->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/JQueryWithUI/js/jquery-ui-1.8.6.custom.min.\
js\"></script>\n");
}
 
?>