summaryrefslogtreecommitdiff
path: root/doc/plugins/write.mdwn
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-10-17 20:28:18 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-10-17 20:28:18 -0400
commit79b376f9912891a8748fcbb4580969e4dbf7fc75 (patch)
tree40c99e6f94ddb7e0c9ecea6a1a109e015061dd68 /doc/plugins/write.mdwn
parent16d51e67a7e7257739e1cb3f9a3713d448065e5d (diff)
Add an underlay for javascript, and add ikiwiki.js containing some utility code.
* Add an underlay for javascript, and add ikiwiki.js containing some utility code. * toggle: Stop embedding the full toggle code on each page using it, and move it to toggle.js in the javascript underlay.
Diffstat (limited to 'doc/plugins/write.mdwn')
-rw-r--r--doc/plugins/write.mdwn29
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 1b78f5900..daf70c8e2 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -847,3 +847,32 @@ to a hash containing all the config items. They should also implement a
By the way, to parse a ikiwiki setup file and populate `%config`, a
program just needs to do something like:
`use IkiWiki::Setup; IkiWiki::Setup::load($filename)`
+
+### Javascript
+
+Some plugins use javascript to make ikiwiki look a bit more web-2.0-ish.
+
+All javascript code should be put in `.js` files in the `javascript`
+underlay, and plugins using those files can enable use of the underlay by
+calling `add_underlay("javascript");` in their `import` function.
+
+You'll have to arrange for `<script>` tags to be added to the pages that
+use your javascript. This can be done using a `format` hook.
+
+Ikiwiki provides some utility functions in `ikiwiki.js`, for use by other
+javascript code. These include:
+
+#### `getElementsByClass(cls, node, tag)`
+
+Returns an array of elements with the given class. The node and tag are
+optional and define what document node and element names to search.
+
+#### `hook(name, call)`
+
+The function `call` will be run as part of the hook named `name`.
+
+Note that to hook into `window.onload`, you can use the `onload' hook.
+
+#### `run_hooks(name)`
+
+Runs the hooks with the specified name.