Kilauea

The Global Kilauea Object

Summary
The Global Kilauea Object
An object with properties major, minor, revision, and status.
An array of Kilauea.Instances.
An array of URLs for all loaded script files.
The base URL of Kilauea’s script directory.
An object that contains all plugin classes.
Information about the status of all plugin classes.
An object that contains the URLs from which the respective plugins (identified by their URI in the object keys) has been retrieved.
An object of registered key events with key codes as object keys and Kilauea.Events as values.
The info structure that is used in <Kilauea.Instance.help> and its dependents.
A browser detection utility object.
This object stores and manages everything related to localization.
Initializes the global Kilauea object.
Builds all instances, initializes Kilauea.localization, and registers the document.keydown handler Kilauea.handleKey.
Registers a keystroke mapping.
Handles document.keydown events.
Initializes localization.
Keeps all the language packages fetched so far.
Kilauea.localization not only manages language packages, but also all parts of the DOM tree that once have been localized and added to Kilauea.localization.parts through Kilauea.localization.parts.add.
Adds a part to localization.parts.
Updates all Kilauea.localization.parts, or only the parts with a given language / in a given instance -- depending on the (optional) parameter.
Adds a new language package to Kilauea.localization.
Initializes <Kilauea.lang>.
Fetches a language package for Kilauea and all Kilauea.plugins.
Loads all plugins.
Takes a plugin ID token or an URI+URL and returns an ID object
Registers a plugin.
Returns true if the given element has a certain class attributed to it.
Adds a class to a given element.
Removes a class from a given element.
Returns an element’s computed style for a given CSS property.
Returns all child elements that exhibit a given class.
Yields browser-independent information about the current window’s dimensions.
Converts a value to integer, if possible.
Converts a value to float, if possible.
Compares to URIs without fragment identifiers.
Retrieves an URL without fragment identifiers, URL parameters etc.
Reloads the HTML page, thereby restarting all presentations.
Adds a DOM event handler in a fairly browser-independent way.
Removes a DOM event handler.
Cancels a DOM event.
A cross-browser utility method which returns a XMLHttpRequest object.
Sets Kilauea.scriptURL to Kilauea’s base directory.
Collects all scripts included so far and pushes them onto Kilauea.scripts.
Loads a script at runtime.
Includes a script during page load.
Includes a CSS file during page load.
Handles the picking up in a drag’n’drop action.
Performs the drop of a drag’n’drop.
Updates the element’s position while dragging.
Determines whether a string is an URI.
Returns a plain-text version of a possibly HTML-formatted string.
A Class for Kilauea Events
The function to be used as callback
The object to be used as this pointer when calling fn.
Fires fn with this set to thisObj.
A Utility Class for Panels
A reference to the DOM element.
The current status of the panel’s visibility.
Sets the visibility of the panel.
Hides the panel.
Shows the panel.
Toggles the panel.
Temporarily hides the panel.
Restores the panel after a quickHide.
A Utility Canvas Class
The absolute x-coordinate of the canvas, in pixels.
The absolute y-coordinate of the canvas, in pixels.
The total width of the canvas, in pixels.
The total height of the canvas, in pixels.
Updates the canvas’ position and dimensions.
The Slide Class
A pointer to the slide’s DOM element, usually a div.slide.
The slide’s ID, which is the array index of the slide within Kilauea.Instance.slides.
The Kilauea.Instance.id of the instance to which the slide belongs.
The array of IDs of enclosing Kilauea.Instance.parts.
A fragment identifier for this slide (if present), or a self-assigned pseudo-identifier.
A plain text slide title.
A Kilauea.Panel that contains the annotation, if any.
An array which contains objects for each incremental part of the slide.
Hides the slide.
Shows the slide.
Unveils incrementals up to a given position.
Sets the slide’s visibility.
Finds a matching background in Kilauea.Instance.backgrounds for a Kilauea.Slide.
The Background Class
A pointer to the backgounnd’s DOM element.
Hides the background.
Shows the background.
Sets the backgound’s visibility.
The x-coordinate of the computed position, in pixels.
The y-coordinate of the computed position, in pixels.
Adapts the scroll position to given coordinates.
Resets the background’s position to the top left corner of the canvas.
The Menu Class
The Submenu Class
Adds a hyperlink to a given submenu.
The Kilauea Instance Class
The instance ID.
true, if the presentation instance occupies the whole window.
true, if the presentation is in embedded mode.
A pointer to the top-level DOM element that contains all slides.
The object that contains the Kilauea.Instance’s plugin instances.
Kilauea events that are fired on appropriate occasions.
The instance’s canvas, which is a Kilauea.Canvas.
The array which contains all slides.
The object which contains all backgrounds.
The presentation’s title.
An array where part and subpart information for each presentation is stored.
Shows a given slide with the correct incrementals and notes unveiled.
Creates a hyperlink.
Adds a hyperlink to the instance’s toolbar menu.
Replaces a hyperlink in the instance’s toolbar menu by another.
Description
Description
Adds a hyperlink to a given submenu.
Replaces a hyperlink in the instance’s toolbar menu by another.
Description
Description

Properties

version

An object with properties major, minor, revision, and status.  A typical use case is

alert('Current version: ' + Kilauea.version.major + '.' + Kilauea.version.minor)

instances

An array of Kilauea.Instances.  Each instance keeps its own array index in the property Kilauea.Instance.id.

scripts

An array of URLs for all loaded script files.

scriptURL

The base URL of Kilauea’s script directory.  This property is set by Kilauea.setScriptURL.

plugins

An object that contains all plugin classes.  Plugin URIs are used as object keys.  Note that while the plugin classes are stored in Kilauea.plugins, the actual plugin instances are stored in Kilauea.Instance.plugins.

pluginStatus

Information about the status of all plugin classes.  Object keys are the plugin URIs; the value is one of (loading, ok, error, incompatible)

pluginLocations

An object that contains the URLs from which the respective plugins (identified by their URI in the object keys) has been retrieved.

keys

An object of registered key events with key codes as object keys and Kilauea.Events as values.

keyInfo

The info structure that is used in <Kilauea.Instance.help> and its dependents.  As for Kilauea.keys, the object keys are the respective key codes.  The values are objects with properties key - a readable string representation of the key.  For instance, “A” for key code 65 help - the help text

browser

A browser detection utility object.  (Written a la mootools’ browser detection -- not as elegantly, though.)

Properties

xpathwhether document.evaluate is supported, and thus evaluation of xpath expressions
ietrue, if the browser is an internet explorer
ie6true, if the internet explorer has version 6
ie7true, if the internet explorer has version 7
webkittrue, if the browser is a descendant from the webkit / KHTML family; e.g., Safari, Shiira, or Konqueror
webkit419true, if the webkit has version < 419.  E.g., this is true for Safari 2
webkit420true, if the webkit has version > 420. from this version on, webkit yields xpath support.  E.g., this is true for Safari 3
geckotrue, if the browser uses the gecko rendering engine. true for mozilla and most notably Firefox
operaan alias of Opera’s nice window.opera

localization

This object stores and manages everything related to localization.  It is a global object with only one instance per document, which is shared by all Kilauea.Instances.

Properties

langsThe language packages which have been fetched so far.  See Kilauea.localization.langs for more detail.
partsThe parts of the document which contain localized content.  Parts have two methods, Kilauea.localization.parts.add and Kilauea.localization.parts.update.

Methods

addAdd a new language package to Kilauea.localization.langs.  See Kilauea.localization.add.
localizeDetermine the ISO code of the default language of the document.  See <Kilaua.localization.localize>.
fetchFetch a language package at runtime.  See Kilauea.localization.fetch.

Initialization

init

init: function(a)

Initializes the global Kilauea object.  Kilauea.init() must be called before the page fires the load DOM event, and after kilauea.js has been included.  I.e.,

<script type="text/javascript" src="js/kilauea.js"></script>
<script type="text/javascript">
Kilauea.init();
</script>

Kilauea.init registers an document.onload DOM handler, which then calls Kilauea.create.  The parameters passed (if any) are stored in a temporary property Kilauea.params, which gets deleted once Kilauea.create is done.

Parameters

aa parameter object with 0..inf entries of the following form:
<ID>: {
keyBind: <boolean:true>,
onReady: <fn>,
title: <string>,
titleSeparator: <string:"::">
externalTransition: <boolean:false>,
forceEmbeddedMode: <boolean:false>,
menu: {},
settings: {
clickAdvance: <boolean:true>,
showNotes: <boolean:false>,
useRealAnchors: <boolean:true>,
adaptiveTitle: <boolean:true>,
useShortTitles: <boolean:true>,
stackBackgrounds: <boolean:false>,
clickAreas: <boolean:true>,
showToolbar: <boolean:false>,
coupleFooter: <boolean:false>
},
indicators: {
notes: <class Indicator>,
incremental: <class Indicator>}
}

Parameter object properties

IDmust be either a valid id of an element document in this document or “’#body’” (in the latter case, the ID must appear in quotation marks, as it is not a valid javascript object identifier (which, btw, is a good thing, because it’s not a legal xs:NCName either, thus avoiding collisions.))
keyBindspecifies which instance will get the keyboard events. if multiple instances are being set up, and multiple instances claim to get the keyboard events, the first instance to do so wins.  (right now, I can’t see a sensible use case for multiple receivers.)
useRealAnchorsif set to true, existing anchors (i.e., fragment identifiers) are used. otherwise, parenthesized slide numbers are used (as in slidy).
indicatorshave to implement the Indicator class, which is fairly simple: 1) the constructor takes one argument: a pointer to the corresponding html element, and 2) the class has to implement two argument-less methods on() and off() with the respective obvious meanings.
titlethe presentation’s title. if no title is specified, the document’s title tag is chosen instead, or the title of the first presentation slide.
titleSeparatorthe separator used to join parts of the title.  By default, titles are concatenated through a double colon (“::”).
forceEmbeddedModeif set, even full-window presentations are treated as embedded presentations.
onReadya function to be evaluated as soon as the instance is ready
externalTransitionif set, Kilauea.Instance.showSlide does not hide / show the slides itself. this is useful if a plugin (e.g., <transition>) which listens to slideCHhange events takes care of hiding / showing slides.
menua list of menu items that shall appear in the toolbar.  By default, {‘help’: {}, ‘contents’: {}, ‘restart’: {}} are displayed.
settingsa setting obect of the following form
{
clickAdvance: <boolean:true>,
showNotes: <boolean:false>,
useRealAnchors: <boolean:true>,
adaptiveTitle: <boolean:true>,
useShortTitles: <boolean:true>,
stackBackgrounds: <boolean:false>,
clickAreas: <boolean:true>,
showToolbar: <boolean:false>,
coupleFooter: <boolean:false>
}
useShortTitlesindicates that short forms of part titles should be used where present.

create

create: function(e)

Builds all instances, initializes Kilauea.localization, and registers the document.keydown handler Kilauea.handleKey.  This method must not be called directly; it is called on document load.  Call Kilauea.init instead.

Keyboard Events

registerKey

registerKey: function(key,
fun,
thisObj,
sym,
help)

Registers a keystroke mapping.  Accepts parameters key, fun, [thisObj, [sym, help]]

Parameters

keya key (accepts both keyCode values and ASCII chars. for non-alphabetic chars, key codes are recommended.)
funa function which accepts one argument ‘inst’, denoting the keybound instance
thisObjan object to be used as this pointer
symthe keyboard symbol
helpan explaining help text

handleKey

handleKey: function(e)

Handles document.keydown events.  It first loops over the custom callbacks in Kilauea.keys, which have been registered using Kilauea.registerKey, then performs the built-in actions.

Returns: Always returns true.  If the event should be cancelled, the callback function must explicitly call Kilauea.cancelEvent or Kilauea.stopPropagation.

Localization

setupLocalization

setupLocalization: function()

Initializes localization.

localization. langs

Keeps all the language packages fetched so far.  ISO language codes are used as object keys; the object entries are pairs of an english string and its respective translation, e.g.

Kilauea.localization.langs = {
'de': {
"help": "Hilfe",
"Remote Panel": "Fernsitzungssteuerungsanzeige"
},
'pl': {
"help": "Pomoc"
}
};

localization. parts

Kilauea.localization not only manages language packages, but also all parts of the DOM tree that once have been localized and added to Kilauea.localization.parts through Kilauea.localization.parts.add.  Besides other advantages, this permits to change languages at runtime (in fact, language packages are always fetched at runtime, because Kilauea first determines the language of the document (Kilauea.localization.localize) and all instances (within Kilauea.Instance’s constructor), and then loads the localization files with Kilauea.loadScript.)

localization. parts.add

Adds a part to localization.parts.

Parameters

instThe ID of the Kilauea.Instance to which the inserted node belongs
nodeA node with localized content.  Either an element or an attribute node. in the latter case, make sure to retrieve the node through *.getAttributeNode (and not *.getAttribute, which returns the nodeValue).
langAn ISO language code.

localization. parts. update

Updates all Kilauea.localization.parts, or only the parts with a given language / in a given instance -- depending on the (optional) parameter.

Parameters

xEither a ISO language code or an Kilauea.Instance.id, or no argument at all.

There are two principal use cases for this method

  • a language pack has been added / updated, and all parts using this language have to be updated
  • an instanced changed its <Kilauea.Instance.lang>, and all parts belonging to this instance have to be updated

Therefore, we do a little polymorphic magic (knowing that instance IDs are integers and language codes don’t.)  Furthermore, a call to this method without an argument issues updates of all parts in all instances

localization.add

Adds a new language package to Kilauea.localization.  The language information is then stored in Kilauea.localization.langs.  See the sample code and documentation in Kilauea.localization.langs.

Parameters

langThe ISO language code
objThe object which contains pairs of english strings and respective translations

Note that if two language packages translate the same english string, only one translation will be kept in Kilauea.localization.langs.  The language package which has been included after all others wins.

localization. localize

Initializes <Kilauea.lang>.  Looks for possible language attributes on the document’s element.  Respects both @lang and @xml:lang.

localization. fetch

Fetches a language package for Kilauea and all Kilauea.plugins.

Plugin Support

loadPlugins

loadPlugins: function(a)

Loads all plugins.

Parameters

athe same parameter object as for <Kilaeua.create>

The method also fills Kilauea.pluginLocations and it loads the respective CSS file for each plugin.

resolvePluginID

resolvePluginID: function(id)

Takes a plugin ID token or an URI+URL and returns an ID object

Parameters

ideither an ID token or a full-fledged URI + URL, separated by whitespace

Returns

An object with properties

idthe id -- either the ID token or the plugin URI
urlthe location of the directory from which the plugin is to be retrieved (the trailing slash is included)
namethe name of the plugin’s js file, without the extension.

Two examples for input and returned object (assuming that kilauea.js resides in a directory with relative path js/

Kilauea.resolvePluginID("bigtimes")
=> { id: 'bigtimes', url: 'js/plugins/bigtimes/', name: 'bigtimes'}

Kilauea.resolvePluginID("http://sharpeleven.net/kilauea/bigtimes \\
http://myserver/somedirectory/bigtimes.js");
=> { id: 'http://sharpeleven.net/kilauea/bigtimes',
url: 'http://myserver/somedirectory/',
name: 'bigtimes' }

addPlugin

addPlugin: function(uri,
id,
pl,
requireVersion)

Registers a plugin.

Parameters

urithe plugin URI
idthe plugin’s ID token
plthe plugin class itself
requireVersionan optional version object which determines a minimal Kilauea.version that the plugin needs in order to work properly.  The object must have the following properties
{major: <int>, minor: <int>}

The method inserts the plugin class into Kilauea.plugins, and makes the plugin usable for Kilauea.Instances to be instantiated and inserted into Kilauea.Instance.plugins.  Besides inserting the plugin class, this method also replaces all those object keys in Kilauea.pluginLocations, which up to now have only been an ID token, by the plugin’s full URI.

Style Utility Methods

hasClass

hasClass: function(e,
c)

Returns true if the given element has a certain class attributed to it.

Parameters

ea DOM element
ca class name

Returns

true, if the element has the class assigned to it, false otherwise.

addClass

addClass: function(e,
c)

Adds a class to a given element.

Parameters

ea DOM element
ca class name

removeClass

removeClass: function(e,
c)

Removes a class from a given element.

Parameters

ea DOM element
ca class name

getStyle

getStyle: function(obj,
css)

Returns an element’s computed style for a given CSS property.

Parameters

obja DOM element node
cssa CSS property (W3C style; i.e.  border-left-color)

Returns

The computed style, if possible, and null otherwise.

The method tries really hard to get the computed value of the desired style property.  It is easily possible that it fails nevertheless, due to the quite disparate approaches to, and support of, computed styles across different browsers.  Furthermore, the results may be inconsistent across differen browser families.  For example, gecko translates a “border-width: thin” into a pixel value, which is parseable as integer, while IE returns the declared value “thin”.  You might want to postprocess the return value of Kilauea.getStyle using Kilauea.toInteger.

getByClass

getByClass: function(parent,
c)

Returns all child elements that exhibit a given class.

Parameters

parentthe parent DOM element containind the child nodes to search among
ca class name

Returns

An array of zero or more elements.

Note that although this method sounds like the family of DOM methods such as *.getElementByID, the syntax of Kilauea.getByClass is different: This method cannot be applied as a method of the DOM element, the DOM element has rather to be passed as an argument.  The reason is that Kilauea does not alter or extend any DOM nodes.

redraw

redraw: function(e)

Redraws all Kilauea.Instances through Kilauea.Instance.redraw.

windowDimensions

windowDimensions: function()

Yields browser-independent information about the current window’s dimensions.

Returns

An object with properties:

widththe window’s width, or null
heightthe window’s height, or null

Conversion Utilities

toInteger

toInteger: function(i,
def,
ref)

Converts a value to integer, if possible.  Kilauea.toInteger is more powerful than javascript’s parseInt() in that it accepts two additional parameters.

Parameters

iThe value to convert
defA default value that should be returned if the conversion of i fails
refA reference value against which percentual values are computed

Returns

  • If i is castable with parseInt (e.g., 14px), then parseInt(i)
  • If i is a percent value (e.g., 30%), then parseInt(i) * ref / 100
  • The default value def otherwise, or null, if no default is specified

toInteger

Converts a value to float, if possible.  Similar to Kilauea.toInteger, but works for floating point numbers.

Parameters

iThe value to convert
defA default value that should be returned if the conversion of i fails
refA reference value against which percentual values are computed

Returns

  • If i is castable with parseFloat (e.g., 0.7ex), then parseInt(i)
  • If i is a percent value (e.g., 49%), then parseInt(i) * ref / 100
  • The default value def otherwise, or null, if no default is specified

Location Utilities

compareAddress

compareAddress: function(l1,
l2)

Compares to URIs without fragment identifiers.  It also normalizes file:/// to file:/ and thus avoids browser-dependent confusion (e.g., in Opera).

Parameters

l1A location object -- either window.location or the location property of a hyperlink element
l2An other (optional) location object to be compared with l1.  If no second parameter is passed, window.location is used.

Returns

true, if the locations are identical, otherwise false

pageAddress

pageAddress: function(l)

Retrieves an URL without fragment identifiers, URL parameters etc.

Parameters

lAn optional location object, Defaults to window.location

Returns

The URL without fragment identifiers, URL parameters etc.

For example, assuming that window.location is “http://sharpeleven.net- /some- /file#part?param=value"

var me = Kilauea.pageAddress();
alert(me);
=> 'http://sharpeleven.net/some/file'

restart

restart: function()

Reloads the HTML page, thereby restarting all presentations.  This clear the <Kilauea.Instance.histories> of all instances as well.

DOM Event Utilities

addEvent

addEvent: function(node,
type,
fn,
capt)

Adds a DOM event handler in a fairly browser-independent way.  See John Resig’s similar function on http://ejohn.org- /projects- /flexible-javascript-events- /, on which Kilauea.addEvent is partly based.

Parameters

nodethe DOM element on which the event handler should listen
typethe type of the DOM event
fnthe function to be called on DOM events.  Note that fn is evaluated with the this pointer pointing to the element which has been passed to Kilauea.addEvent as first argument
captwhether to use event capture.  Defaults to false, because usually, one wants to have event handling during the bubble phase.  IE’s event model only knows event bubbling, and this parameter thus has no effect in IE.

For more information about the different DOM event models, see

removeEvent

removeEvent: function(node,
type,
fn,
capt)

Removes a DOM event handler.  This is the complementary method to Kilauea.addEvent.  Note that this does not work reliably for anonymous functions.

Parameters

nodethe DOM element on which the event handler should listen
typethe type of the DOM event
fnthe function to be called on DOM events.  Note that fn is evaluated with the this pointer pointing to the element which has been passed to Kilauea.addEvent as first argument
captwhether to use event capture.  Defaults to false, because usually, one wants to have event handling during the bubble phase.  IE’s event model only knows event bubbling, and this parameter thus has no effect in IE.

cancelEvent

cancelEvent: function(ev)

Cancels a DOM event.

Parameters

eva DOM event

Returns

false.  This is useful for writing

return cancelEvent(ev);

stopPropagation

stopPropagation: function(e)

A cross-browser implementation of http://www.w3.org- /TR- /DOM-Level-2-Events- /events.html#Events-Event-stopPropagation.

Parameters

ea DOM event

AJAX Utilities

getXHR

getXHR: function()

A cross-browser utility method which returns a XMLHttpRequest object.

Returns

An XMLHttpRequest object.

Load/ Include Utilities

setScriptURL

setScriptURL: function()

Sets Kilauea.scriptURL to Kilauea’s base directory.

collectScripts

collectScripts: function()

Collects all scripts included so far and pushes them onto Kilauea.scripts.

loadScript

loadScript: function(url,
isUTF8)

Loads a script at runtime.  This method is different from Kilauea.includeScript in that it works at runtime, not during page load.  As a consequence, no document.load event fires when the loading of the script completes.

Parameters

urlthe URL to the script.  No expansion / modification of the URL is done; the caller has to make sure that the URL is correct.
isUTF8whether the file is UTF8-encoded.  Defaults to false.  For example, Kilauea.localization.fetch utilizes this feature, as language packages are very likely to contain special characters.

includeScript

includeScript: function(url,
isUTF8)

Includes a script during page load.  As opposed to Kilauea.loadScript, this method inserts a script element into the document header.  Th script then is loaded during page load, and the loading process of the script is taken into consideration when determining completion of document.load.

Parameters

urlthe URL to the script.  No expansion / modification of the URL is done; the caller has to make sure that the URL is correct.
isUTF8whether the file is UTF8-encoded.  Defaults to false.

includeCSS

includeCSS: function(url)

Includes a CSS file during page load.  Similar to Kilauea.includeScript, but works for CSS files rather than for scripts.

Parameters

urlthe URL to the script.  No expansion / modification of the URL is done; the caller has to make sure that the URL is correct.

Drag’n’drop support

draggable.pick

Handles the picking up in a drag’n’drop action.  As a side-effect, the z-index of the element which is to be dragged is set to 700 while dragging.

Parameters

ethe mousedown event

draggable.drop

Performs the drop of a drag’n’drop.

Parameters

ethe mouseup event

draggable.drag

Updates the element’s position while dragging.

Parameters

ethe mousemove event

Miscellaneous Methods

isURI

isURI: function(n)

Determines whether a string is an URI.  Applys the following regular expression pattern to the string

/^(\w+:\/\/)/

Parameters

na string Returns: true, if the string is an URI, otherwise false.

html2text

html2text: function(el)

Returns a plain-text version of a possibly HTML-formatted string.  It recursively traverses all child elements, retrieves all text nodes and concats these strings.

Parameters

ela DOM element Returns: A string representation of the element’s content.

Kilauea. Event

A Class for Kilauea Events

A utility class that stores an event callback and a this pointer.

Parameters

fna function
thisObjan optional pointer to an object that is to be used as this when calling the function.  (Similar to the second argument in Array.forEach.  See http://developer.mozilla.org- /en- /docs- /Core_JavaScript_1.5_Reference:Global_Objects:Array:forEach)
Summary
The function to be used as callback
The object to be used as this pointer when calling fn.
Fires fn with this set to thisObj.

Properties

fn

The function to be used as callback

thisObj

The object to be used as this pointer when calling fn.

Functions

fire

this.fire = function(t,
inst)

Fires fn with this set to thisObj.

Kilauea. Panel

A Utility Class for Panels

Constructor Parameters

elmThe panel’s DOM element
defVisThe initial default visibility -- either ‘hidden’ or ‘visible’
embeddedWhether the panel is part of an embedded presentation
isDragWhether the panel should be draggable through Kilauea.draggable (default is false)
Summary
A reference to the DOM element.
The current status of the panel’s visibility.
Sets the visibility of the panel.
Hides the panel.
Shows the panel.
Toggles the panel.
Temporarily hides the panel.
Restores the panel after a quickHide.

Properties

ref

A reference to the DOM element.  This can be used if for example the DOM contents of the panels are altered.

status

The current status of the panel’s visibility.

Functions

set

this.set = function(v)

Sets the visibility of the panel.

Parameters

vthe visibility.  Either ‘visible’ or ‘hidden’.

hide

this.hide = function()

Hides the panel.

show

this.show = function()

Shows the panel.

toggle

this.toggle = function()

Toggles the panel.

quickHide

this.quickHide = function()

Temporarily hides the panel.

restore

this.restore = function()

Restores the panel after a quickHide.

Kilauea. Canvas

A Utility Canvas Class

A utility class for the canvas element which encloses Kilauea presentations in <Kilauea.embeddedMode>.

Constructor Parameters

elThe DOM element.
isFullWhether the Canvas is the full browser window itself.
Summary
The absolute x-coordinate of the canvas, in pixels.
The absolute y-coordinate of the canvas, in pixels.
The total width of the canvas, in pixels.
The total height of the canvas, in pixels.
Updates the canvas’ position and dimensions.

Properties

left

The absolute x-coordinate of the canvas, in pixels.

top

The absolute y-coordinate of the canvas, in pixels.

width

The total width of the canvas, in pixels.

height

The total height of the canvas, in pixels.

Functions

update

this.update = function()

Updates the canvas’ position and dimensions.  For instance, this method gets called by Kilauea.Instance.redraw if the presentation is in Kilauea.Instance.embeddedMode.

Kilauea. Slide

The Slide Class

The slide class used for all Kilauea.Instance.slides.  This class is only accessible within the scope of Kilauea.Instance’s constructor.

Constructor Parameters

sthe slide’s DOM element (usually a div.slide)
idthe slide’s ID, which will be the position where the slide can be found within Kilauea.Instance.slides
instthe ID of the Kilauea.Instance to which the slide belongs
partIDsan array of Kilauea.Instance.parts IDs, which denote the hierarchy of enclosing parts
Summary
A pointer to the slide’s DOM element, usually a div.slide.
The slide’s ID, which is the array index of the slide within Kilauea.Instance.slides.
The Kilauea.Instance.id of the instance to which the slide belongs.
The array of IDs of enclosing Kilauea.Instance.parts.
A fragment identifier for this slide (if present), or a self-assigned pseudo-identifier.
A plain text slide title.
A Kilauea.Panel that contains the annotation, if any.
An array which contains objects for each incremental part of the slide.
Hides the slide.
Shows the slide.
Unveils incrementals up to a given position.
Sets the slide’s visibility.
Finds a matching background in Kilauea.Instance.backgrounds for a Kilauea.Slide.

Properties

ref

A pointer to the slide’s DOM element, usually a div.slide.

id

The slide’s ID, which is the array index of the slide within Kilauea.Instance.slides.

inst

The Kilauea.Instance.id of the instance to which the slide belongs.

partInfo

The array of IDs of enclosing Kilauea.Instance.parts.

anchor

A fragment identifier for this slide (if present), or a self-assigned pseudo-identifier.  Pseudo-identifiers have the form “(<slide number>)”.  Note that self-assigned anchors may confilct with other user-defined anchors.

title

A plain text slide title.

note

A Kilauea.Panel that contains the annotation, if any.

incrementals

An array which contains objects for each incremental part of the slide.  The object has two methods, unveil - unveils the incremental part cover - covers the incremental part Slide.incrementals are used in Slide.unveilUpto.

Functions

hide

this.hide = function()

Hides the slide.

Returns

The Slide.id.

show

this.show = function()

Shows the slide.  Not ot be confused with Kilauea.Instance.showSlide, which does a lot more besides showing slides.  (In fact, it doesn’t even necessarily show slides: e.g., the <transition> plugin may take care of that.)

Returns

The Slide.id.

unveilUpto

this.unveilUpto = function(i)

Unveils incrementals up to a given position.  The position is the array index of the incremental part within Slide.incrementals.  Parameters: i - the incremental index up to which incrementals shall be unveiled.

Returns

The the current incremental index.

set

this.set = function(vis)

Sets the slide’s visibility.

Parameters

visthe desired visibility.  Either true or false.

findBackground

this.findBackground = function(bg)

Finds a matching background in Kilauea.Instance.backgrounds for a Kilauea.Slide.  Backgrounds are associated to slides via the class attribute.  If a slide bears the class ‘xyz’ in its classname and there is a background with _class=”background xyz”_, then this background is the matching background for that slide.

Parameters

gbAn associative arrray of backgrounds, where the keys are the background names (i.e., ‘xyz’ in the above example).

Returns

A background name, or ‘#default’, if no explicitly associated backgound can be found.

Kilauea. Background

The Background Class

Constructor Parameters

sThe DOM element.
Summary
A pointer to the backgounnd’s DOM element.
Hides the background.
Shows the background.
Sets the backgound’s visibility.
The x-coordinate of the computed position, in pixels.
The y-coordinate of the computed position, in pixels.
Adapts the scroll position to given coordinates.
Resets the background’s position to the top left corner of the canvas.

Properties and Functions

ref

A pointer to the backgounnd’s DOM element.  THis is important if the background’s DOM content has to be modified.

hide

this.hide = function()

Hides the background.

show

this.show = function()

Shows the background.

set

this.set = function(vis)

Sets the backgound’s visibility.

Parameters

visThe desired visibility -- either true or false.

left

The x-coordinate of the computed position, in pixels.

top

The y-coordinate of the computed position, in pixels.

adaptScroll

this.adaptScroll = function(left,
top)

Adapts the scroll position to given coordinates.  This is used in order to get the same behaviour (i.e., backgrounds move together with slides while scrolling) in Kilauea.Instance.embeddedMode as in standalone mode.

Parameters

leftthe x-coordinate
topthe y-coordinate

resetScroll

this.resetScroll = function()

Resets the background’s position to the top left corner of the canvas.

Kilauea.Menu

The Menu Class

Constructor Parameters

mThe ul DOM element.

Kilauea. Submenu

The Submenu Class

Constructor Parameters

mThe li DOM element.
parentThe parent Kilauea.Menu.
idThe submenu’s ID, which is its key within the parent’s <Kilauea.Menu.submenus> object.
Summary
Adds a hyperlink to a given submenu.

Functions

addEntry

this.addEntry = function(a)

Adds a hyperlink to a given submenu.

Parameters

aA hyperlink DOM element.  It is recommended to generate this element by using Kilauea.Instance.getLink.

Returns

The newly appended menu entry (which is a list DOM element, and which can be used to remove or replace the entry by means of Kilauea.Instance.removeFromSubmenu or Kilauea.Instance.replaceInSubmenu, respectively), or null.

Kilauea. Instance

The Kilauea Instance Class

Summary
The instance ID.
true, if the presentation instance occupies the whole window.
true, if the presentation is in embedded mode.
A pointer to the top-level DOM element that contains all slides.
The object that contains the Kilauea.Instance’s plugin instances.
Kilauea events that are fired on appropriate occasions.
The instance’s canvas, which is a Kilauea.Canvas.
The array which contains all slides.
The object which contains all backgrounds.
The presentation’s title.
An array where part and subpart information for each presentation is stored.
Shows a given slide with the correct incrementals and notes unveiled.
Creates a hyperlink.
Adds a hyperlink to the instance’s toolbar menu.
Replaces a hyperlink in the instance’s toolbar menu by another.
Description
Description
Adds a hyperlink to a given submenu.
Replaces a hyperlink in the instance’s toolbar menu by another.
Description
Description

Poperties

id

The instance ID.  Every Kilauea.Instance can access itself via Kilauea.instances[this.id]

isFullWindow

true, if the presentation instance occupies the whole window.  Full-window presentations are treated differently, e.g. with regard to <Kilauea.Instance.updateLocation>: In full-window presentations, the URL in the address bar of the browser is updated.

embeddedMode

true, if the presentation is in embedded mode.  The principal difference from standalone mode is that presentations are wrapped in a special div.kilaueaCanvas wich has fixed dimensions and the CSS property overflow: hidden;.  Doing so, multiple slideshow presentations in one single XHMTL document (and in one single broser window) become possible.

container

A pointer to the top-level DOM element that contains all slides.

plugins

The object that contains the Kilauea.Instance’s plugin instances.  The object keys are the plugin URIs.

Note the difference to Kilauea.plugins, which contains the plugin classes, not the instances.

events

Kilauea events that are fired on appropriate occasions.  External applications or Kilauea plugins can listen to these events by means of <Kilauea.Instance.registerEvent>.

The available event types are slideChange - fired, if the slide changes.  This is not the case if only incremental parts are unveiled or if there is a change from / to alSlideMode. incrementalChange - fired if incremental parts of a slide are unveiled or covered again. eos - fired, if the end of the slides is reached.  Note that this may happen several times (in case the presentator moves back and forth to the last slide). ready - fired after complete initialization of the respective Kilauea.Instance.  Registration of this particular event is different, as <registerEvent> cannot be used before complete initialization of the Kilauea.Instance.  Instead, the function which is to be executed for this event must be passed as property onReady of the parameter object of Kilauea.init. singleSlideView - fired if singleSlideMode is reached after allSlideMode allSlideView - fired if allSlideMode is reached after singleSlideMode redraw - fired after redraws of the Kilauea.Instance.

canvas

The instance’s canvas, which is a Kilauea.Canvas.

slides

The array which contains all slides.

backgrounds

The object which contains all backgrounds.  The background names are used for object keys.  Kilauea.Instance.backgrounds always contains at least one entry, which then has the key ‘#default’ and may have a null value.

title

The presentation’s title.  Either the title specified in Kilauea.init’s parameter object, or an inferred title from the cover slide.

parts

An array where part and subpart information for each presentation is stored.

The array contains an entry for every part and for every slide.  Array indices are used for identifying the entries.  In the former case, the entry is an object with properties title - A plain text part title.  It is either given by an id attribute on the part’s DOM element (which usually is a div.part) or it gets inferred from a outline slide (usually a div.slide.outline). href - A (pseudo) fragment identifier that can be used for linking to the part, equivalent to Slide.anchor. children - An array with part IDs of children elements, which can be slides or parts.  In the latter case, the entry has only one property, slide - The Slide.id of the slide.  Kilauea.Instance.parts is especially useful for building hierarchical table of contents, as done in <Kilauea.Instance.getHierarchicalToc>.

Auxiliary Methods

Slide Manipulation and Retrieval

showSlide

showSlide: function(sn,
inc)

Shows a given slide with the correct incrementals and notes unveiled.

Kilauea.Instance.showSlide should be called with legal slide indices, although it legalizes all parameters by using <Kilauea.Instance.legalSlide> and <Kilauea.Instance.legalIncremental>.  The method fires the following Kilauea.Instance.events, if appropriate:

  • slideChange
  • incrementalChange
  • eos

Parameters

sna slide number
incan incremental index

Updater Methods

Plugin Methods

DOM Event Handler

Custom Kilauea Event Methods

Help Panel

TOC Panel

Toolbar Methods

getLink

getLink: function(chld,
title,
href,
thisObj,
params)

Creates a hyperlink.

Parameters

chldeither a string (the link text) or a DOM node (to be inserted as the link’s child node)
titlea title string href- getLink accepts either a URL as string or a pointer to a function. in the latter case, the following optional parameters are possible:
thisObja pointer to an object which should be used as <i>this</i>, when the function is evaluated
paramsan array of arguments to be passed to the function

The method localizes all strings and adds them as parts to Kilauea.localization.

Returns

A hyperlink DOM element

addToToolbarMenu

addToToolbarMenu: function(a)

Adds a hyperlink to the instance’s toolbar menu.

Parameters

aa hyperlink DOM element.  It is recommended to generate this element by using Kilauea.Instance.getLink.

Returns

The newly appended menu entry (which is a list DOM element), or null.

replaceInToolbarMenu

replaceInToolbarMenu: function(li,
a)

Replaces a hyperlink in the instance’s toolbar menu by another.

Parameters

lithe menu entry to be replaced.  Usually obtained earlier by a call to Kilauea.Instance.addToToolbarMenu.
aa hyperlink DOM element.  It is recommended to generate this element by using Kilauea.Instance.getLink.

Returns

The new menu entry (which is a list DOM element), or null.

getSubmenu

getSubmenu: function(t)

Description

Parameters

Returns

removeSubmenu

removeSubmenu: function(m)

Description

Parameters

ma submenu, usually a li DOM element created through Kilauea.Instance.getSubmenu

Returns

addToSubmenu

addToSubmenu: function(m,
a)

Adds a hyperlink to a given submenu.

Parameters

ma submenu, which must be a li DOM element, preferrably created through Kilauea.Instance.getSubmenu
aa hyperlink DOM element.  It is recommended to generate this element by using Kilauea.Instance.getLink.

Returns

The newly appended menu entry (which is a list DOM element, and which can be used to remove or replace the entry by means of Kilauea.Instance.removeFromSubmenu or Kilauea.Instance.replaceInSubmenu, respectively), or null.

replaceInSubmenu

replaceInSubmenu: function(m,
li,
a)

Replaces a hyperlink in the instance’s toolbar menu by another.

Parameters

ma submenu, which must be a li DOM element, preferrably created through Kilauea.Instance.getSubmenu
lithe menu entry to be replaced.  Usually obtained earlier by a call to Kilauea.Instance.addToSubmenu.
aa hyperlink DOM element.  It is recommended to generate this element by using Kilauea.Instance.getLink.

Returns

The new menu entry (which is a list DOM element), or null.

removeFromSubmenu

removeFromSubmenu: function(m,
li)

Description

Parameters

ma submenu, which must be a li DOM element, preferrably created through Kilauea.Instance.getSubmenu
lithe menu entry to be replaced.  Usually obtained earlier by a call to Kilauea.Instance.addToSubmenu.

Returns

Outliner

Miscellaneous Methods

redraw

redraw: function()

Description

Parameters

Returns

The Kilauea Instance Class
A Class for Kilauea Events
init: function(a)
Initializes the global Kilauea object.
create: function(e)
Builds all instances, initializes Kilauea.localization, and registers the document.keydown handler Kilauea.handleKey.
This object stores and manages everything related to localization.
handleKey: function(e)
Handles document.keydown events.
registerKey: function(key,
fun,
thisObj,
sym,
help)
Registers a keystroke mapping.
setupLocalization: function()
Initializes localization.
Kilauea.localization not only manages language packages, but also all parts of the DOM tree that once have been localized and added to Kilauea.localization.parts through Kilauea.localization.parts.add.
Adds a part to localization.parts.
An object that contains all plugin classes.
loadPlugins: function(a)
Loads all plugins.
resolvePluginID: function(id)
Takes a plugin ID token or an URI+URL and returns an ID object
addPlugin: function(uri,
id,
pl,
requireVersion)
Registers a plugin.
hasClass: function(e,
c)
Returns true if the given element has a certain class attributed to it.
addClass: function(e,
c)
Adds a class to a given element.
removeClass: function(e,
c)
Removes a class from a given element.
getStyle: function(obj,
css)
Returns an element’s computed style for a given CSS property.
getByClass: function(parent,
c)
Returns all child elements that exhibit a given class.
redraw: function(e)
Redraws all Kilauea.Instances through Kilauea.Instance.redraw.
redraw: function()
Description
windowDimensions: function()
Yields browser-independent information about the current window’s dimensions.
toInteger: function(i,
def,
ref)
Converts a value to integer, if possible.
compareAddress: function(l1,
l2)
Compares to URIs without fragment identifiers.
pageAddress: function(l)
Retrieves an URL without fragment identifiers, URL parameters etc.
restart: function()
Reloads the HTML page, thereby restarting all presentations.
addEvent: function(node,
type,
fn,
capt)
Adds a DOM event handler in a fairly browser-independent way.
removeEvent: function(node,
type,
fn,
capt)
Removes a DOM event handler.
cancelEvent: function(ev)
Cancels a DOM event.
stopPropagation: function(e)
A cross-browser implementation of http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event-stopPropagation.
getXHR: function()
A cross-browser utility method which returns a XMLHttpRequest object.
setScriptURL: function()
Sets Kilauea.scriptURL to Kilauea’s base directory.
The base URL of Kilauea’s script directory.
collectScripts: function()
Collects all scripts included so far and pushes them onto Kilauea.scripts.
An array of URLs for all loaded script files.
loadScript: function(url,
isUTF8)
Loads a script at runtime.
includeScript: function(url,
isUTF8)
Includes a script during page load.
includeCSS: function(url)
Includes a CSS file during page load.
isURI: function(n)
Determines whether a string is an URI.
html2text: function(el)
Returns a plain-text version of a possibly HTML-formatted string.
The function to be used as callback
this.fire = function(t,
inst)
Fires fn with this set to thisObj.
The object to be used as this pointer when calling fn.
this.set = function(v)
Sets the visibility of the panel.
this.hide = function()
Hides the panel.
this.show = function()
Shows the panel.
this.toggle = function()
Toggles the panel.
this.quickHide = function()
Temporarily hides the panel.
this.restore = function()
Restores the panel after a quickHide.
this.update = function()
Updates the canvas’ position and dimensions.
The array which contains all slides.
The instance ID.
An array where part and subpart information for each presentation is stored.
A Utility Class for Panels
this.hide = function()
Hides the slide.
this.show = function()
Shows the slide.
this.unveilUpto = function(i)
Unveils incrementals up to a given position.
this.set = function(vis)
Sets the slide’s visibility.
this.findBackground = function(bg)
Finds a matching background in Kilauea.Instance.backgrounds for a Kilauea.Slide.
The object which contains all backgrounds.
The Slide Class
this.hide = function()
Hides the background.
this.show = function()
Shows the background.
this.set = function(vis)
Sets the backgound’s visibility.
this.adaptScroll = function(left,
top)
Adapts the scroll position to given coordinates.
this.resetScroll = function()
Resets the background’s position to the top left corner of the canvas.
this.addEntry = function(a)
Adds a hyperlink to a given submenu.
A Utility Canvas Class
showSlide: function(sn,
inc)
Shows a given slide with the correct incrementals and notes unveiled.
getLink: function(chld,
title,
href,
thisObj,
params)
Creates a hyperlink.
addToToolbarMenu: function(a)
Adds a hyperlink to the instance’s toolbar menu.
replaceInToolbarMenu: function(li,
a)
Replaces a hyperlink in the instance’s toolbar menu by another.
getSubmenu: function(t)
Description
removeSubmenu: function(m)
Description
addToSubmenu: function(m,
a)
Adds a hyperlink to a given submenu.
replaceInSubmenu: function(m,
li,
a)
Replaces a hyperlink in the instance’s toolbar menu by another.
removeFromSubmenu: function(m,
li)
Description
The object that contains the Kilauea.Instance’s plugin instances.
An object of registered key events with key codes as object keys and Kilauea.Events as values.
Keeps all the language packages fetched so far.
Updates all Kilauea.localization.parts, or only the parts with a given language / in a given instance -- depending on the (optional) parameter.
Adds a new language package to Kilauea.localization.
Fetches a language package for Kilauea and all Kilauea.plugins.
Initializes Kilauea.lang.
An object that contains the URLs from which the respective plugins (identified by their URI in the object keys) has been retrieved.
An object with properties major, minor, revision, and status.
The Global Kilauea Object
true, if the presentation is in embedded mode.
An array which contains objects for each incremental part of the slide.
The slide’s ID, which is the array index of the slide within Kilauea.Instance.slides.
The Menu Class
A fragment identifier for this slide (if present), or a self-assigned pseudo-identifier.
Kilauea events that are fired on appropriate occasions.