diff options
author | Yorhel <git@yorhel.nl> | 2008-11-22 10:59:34 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2008-11-22 10:59:34 +0100 |
commit | 7127e3d70fc98ff0ceabb41afaa4b3021b3fd337 (patch) | |
tree | a72b68f76919b510ce6949e006b371b37403f9f2 /static | |
parent | d73bf4eb79b45245ea11137d3438e46a341a9343 (diff) |
Fixed htmlForm to allow multiple formsubs, and wrote a javascript tab switcher
This JS tab switcher (prefixed jt*) can be used for about anything
where you need client-side tabs, not limited only to forms. Only
one tab sequence is allowed on one page, though.
Diffstat (limited to 'static')
-rw-r--r-- | static/f/script.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/static/f/script.js b/static/f/script.js index a3b473b0..dd7d41b5 100644 --- a/static/f/script.js +++ b/static/f/script.js @@ -112,6 +112,54 @@ function ivClose() { + +/* J A V A S C R I P T T A B S */ + +function jtInit() { + var sel = ''; + var first = ''; + var l = x('jt_select').getElementsByTagName('a'); + for(var i=0;i<l.length;i++) + if(l[i].id.substr(0,7) == 'jt_sel_') { + l[i].onclick = jtSel; + if(!first) + first = l[i].id; + if(location.hash && l[i].id == 'jt_sel_'+location.hash.substr(1)) + sel = l[i].id; + } + if(!first) + return; + if(!sel) + sel = first; + jtSel(sel, 1); +} + +function jtSel(which, nolink) { + which = typeof(which) == 'string' ? which : which && which.id ? which.id : this.id; + which = which.substr(7); + + var l = x('jt_select').getElementsByTagName('a'); + for(var i=0;i<l.length;i++) + if(l[i].id.substr(0,7) == 'jt_sel_') { + var name = l[i].id.substr(7); + x('jt_box_'+name).style.display = name == which ? 'block' : 'none'; + var o = x('jt_sel_'+name).parentNode; + if(o.className.indexOf('tabselected') >= 0) { + if(name != which) + o.className = o.className.replace(/tabselected/, ''); + } else + if(name == which) + o.className += ' tabselected'; + } + + if(!nolink) + location.href = '#'+which; + return false; +} + + + + /* O N L O A D E V E N T */ DOMLoad(function() { @@ -151,6 +199,9 @@ DOMLoad(function() { // initialize image viewer ivInit(); + // Javascript tabs + jtInit(); + // spam protection on all forms if(document.forms.length >= 1) for(i=0; i<document.forms.length; i++) |