Code listing for tp.js
- /*
- * date: 2002-10-11
- * info: http://inspire.server101.com/js/tp/
- */
- var tp = [];
- var tpl = [];
- function tpSet(i, c) {
- if (document.createElement) {
- var e = document.getElementById(i);
- var l = document.createElement('ul');
- var p = document.createElement('div');
- e.className = l.className = p.className = c;
- var a, j;
- for (j = 2; j < arguments.length; j++) {
- c = document.getElementById(arguments[j]);
- tp[arguments[j]] = c.parentNode.removeChild(c);
- a = l.appendChild(document.createElement('li'));
- a.className = c.className;
- tpl[arguments[j]] = a = a.appendChild(document.createElement('a'));
- a.setAttribute('href', 'javascript:tpShow(\''+i+'\', \''+arguments[j]+'\');');
- a.appendChild(document.createTextNode(c.getAttribute('title')));
- }
- p.appendChild(tp[arguments[2]]);
- tpl[arguments[2]].className = 'active';
- while (e.firstChild) e.removeChild(e.firstChild);
- e.appendChild(l);
- e.appendChild(p);
- }}
- function tpShow(e, p) {
- e = document.getElementById(e).lastChild;
- tpl[e.replaceChild(tp[p], e.firstChild).getAttribute('id')].className = null;
- tpl[p].className = 'active';
- }
function tpSet(i, c)
Sets elements as tabbed panels.
- i
- String: id of element to contain tabs and panels (tab control).
- c
- String: class name to be used.
- [arguments]
- Optional strings: id of each element to create a tabbed panel from.
function tpShow(e, p)
Show (swap) a tabbed panel.
- e
- String: id of element to contain tabs and panels (tab control).
- p
- String: id of tab to show.