Puna API is a javascript API. It is implemented as an object (named 'puna') with methods and properties that provide simple interfaces to cross browser DHTML.
Puna API was tested against Internet Explorer 5+, Firefox 1+ and Opera 8. I developed it primarily for use in business web applications where minimum specifications for browsers are well known. No attempt is made to be compatible with pre-W3C DOM browsers. But now it's a little broken as I haven't kept up with it's maintainance. Now that Web 2.0 libraries are abounding I don't see much point in repeating work that teams of other people are doing on our behalf.
The inspiration for Puna API and it's main purpose is to extend HTML through custom tags and attributes via javascript.
Include punaAPI thus;
<script language="javascript" src="punaAPI.js"></script>The script will write the punaAPI.css reference and hook into events, no other coding is required - except for utilising the API.
How to include a mouse roll over on an image...
<img src="image1.gif" rollover="image2.gif" />or mask an input...
<input type="text" mask="float"/> <input type="text" mask="unsignedInteger"/>
These examples are here for me to call on for browser testing. I often update, edit and break them unpredictably so there are no gaurantees regarding their current state.
<div id='exampleTabset' class='tabset'> <div> <h2>Tab 1 Caption</h2> <!-- tab pane contents go here --> </div> <div> <h2>Tab 2 Caption</h2> <!-- tab pane contents go here --> </div> ... </div>
The tabsets id is not required. Usually the first H2 element in a tab pane is used as the tab caption. But this pane does not include an H2 element, so the script has captioned it according to it's index.
To keep tab-panes from resizing according to their content add a fixed size (and/or other properties) via css;
#exampleTabset .tabpane {
height:500px;
width:100%;
background-color:white;
}
The punaAPI script calls two functions that may be over-ridden in the loading page.
This function fires before the script re-organizes the elements of the page. Code inserted here can alter global variables before they are used.
This function fires after the script has re-organized the page. It provides an array of the tabsets it configured.
tabsets[i].tabpanes[j].tab references a particular tab on the page.
tabsets[i].tabpanes[j].tab.onSelect() is a function that can be over-ridden. It must return true for the tab to be selected and brought forward.
puna.css includes methods for manipulating style sheets. The following radio buttons change the backgroundColor property for the ".tabset div.tabs .tab" selector (which defines the background for tabs).
Green Blue Grey<input type="radio" name="css" onclick="puna.css.change('.tabset div.tabs .tab','backgroundColor','green');"/>Green
<input type="radio" name="css" onclick="puna.css.change('.tabset div.tabs .tab','backgroundColor','blue', 3);"/>Blue
<input type="radio" name="css" onclick="puna.css.change('.tabset div.tabs .tab','backgroundColor','#999', document.styleSheets[3]);"/>Grey
The first (green) instruction does not specify a stylesheet, so it will change the selector in ALL style sheets.
The second (blue) instruction specifies a stylesheet by index.
The third (grey) instruction specifies a stylesheet object.
Multiple occurrences of selectors in a stylesheet are all updated. The function puna.css.selector(SelectorName, [StyleSheet], [PreviousSelector]) can be used to iterate through selectors by specifying [PreviousSelector]. The function usually returns the first matching selector (in all stylesheets if none was specified), but will only return the first subsequent selector if [PreviousSelector] is supplied.
Puna.net.nz demonstrates selecting different stylesheets to change a pages appearance (find the 'Switch StyleSheet' link).
Pop up menu placed menu anywhere in a page, like this menu
This is an anchor with popup text.
This is an anchor with relative popup text.
| Basic Ruled Table, with stickyness | |||||
|---|---|---|---|---|---|
| abc | abc | abc | abc | abc | abc |
| abc | abc | abc | abc | abc | abc |
| abc | abc | menus anywhere | abc | abc | abc |
| abc | abc | abc | abc | abc | abc |
| abc | abc | abc | abc | abc | abc |
| non-Sticking Ruled Table | |||||
|---|---|---|---|---|---|
| abc | abc | abc | abc | abc | abc |
| abc | Synchronized | abc | abc | abc | abc |
| abc | UnSynchronized | abc | abc | abc | abc |
| abc | abc | abc | abc | abc | abc |
| abc | abc | abc | abc | abc | abc |
| Sticky Ruled Table, with synchronized and unsynchronized check boxes | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| abc | Synchronized | abc | Synchronized | abc | abc | abc | abc | abc | |
| abc | Synchronized | abc | UnSynchronized | abc | abc | abc | abc | abc | |
| Still sticky | abc | abc | abc | abc | abc | ||||
| abc | UnSynchronized | abc | UnSynchronized | abc | abc | abc | abc | abc | |
| abc | UnSynchronized | abc | Synchronized | abc | abc | abc | abc | abc | |
This modal dialog is an inline div.