DokuWiki entry: plugin:jquery
Download and install the plugin using the Plugin Manager using the following URL. Refer to :Plugins on how to install plugins manually.
http://wiki.birth-online.de/_media/software/php/jquery.tar.gzManual download:
The plugin provides a script.js containing jQuery v1.3.1 which is automatically sent to the browser via the js.php. It also registers a hook before the TPL_METAHEADER_OUTPUT event and adds the JavaScript line:
jQuery.noConflict();
to make jQuery leave the $() function untouched. (DokuWiki internal helper)
You can then use jQuery via jQuery(…) instead of $(…) anywhere in the page. See Using jQuery with Other Libraries for more info.
Also this plugin throws the JQUERY_READY event which you can use to add JavaScript code which should be run after loading the document.
This Action plugin will add an export icon to the lower right of the page for exporting the page as ODT document (see :plugin:odt) - without touching the main.php:
<?php /** * ODT Plugin: Exports to ODT * Export icon action part */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_odt extends DokuWiki_Action_Plugin { /** * return some info */ function getInfo(){ return confToHash(dirname(__FILE__).'/info.txt'); } /* * plugin should use this method to register its handlers with the dokuwiki's event controller */ function register(&$controller) { $controller->register_hook('JQUERY_READY', 'BEFORE', $this, '_addjs'); } function _addjs(&$event, $param) { global $ID; // add the link from http://www.dokuwiki.org/plugin:odt#usage to the page $event->data[] = 'jQuery(\'DIV.stylefoot DIV.doc\').append(\' <a href="' . exportlink($ID, 'odt') . '"><img src="' . DOKU_BASE . 'lib/images/fileicons/odt.png" alt="ODT Export" title="ODT Export" /></a>\');'; } } ?>
(Save this as action.php to your lib/plugins/odt folder to make the icon appear.)
This Action plugin will load and add the Kwicks effect to objects of the CSS class .kwicks.
<?php /** * Kwicks Plugin */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_jquery_kwicks extends DokuWiki_Action_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Markus Birth', 'email' => 'johndoe@example.org', 'date' => '2009-04-06', 'name' => 'jQuery Kwicks Plugin', 'desc' => 'Provides Kwicks effect using jQuery', 'url' => 'http://www.jeremymartin.name/projects.php?project=kwicks', ); } /* * plugin should use this method to register its handlers with the dokuwiki's event controller */ function register(&$controller) { $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_addkwickslib'); $controller->register_hook('JQUERY_READY', 'BEFORE', $this, '_addkwicks'); } function _addkwickslib(&$event, $param) { // Note: Can't use a script.js as you can't control when it is loaded // (might be before jquery.js is loaded, which would produce an error) // Using this way, jQuery is already loaded through js.php. $event->data['script'][] = array( 'type' => 'text/javascript', 'charset' => 'utf-8', 'src' => DOKU_BASE . 'lib/plugins/jquery_kwicks/jquery.kwicks.js', ); } function _addkwicks(&$event, $param) { $event->data[] = 'jQuery(\'.kwicks\').kwicks({ max: 253, spacing: 2 });'; } } ?>
(Save this as action.php to a lib/plugins/jquery_kwicks folder.)
Please report problems on the plugin page of the DokuWiki homepage.