add cms, add todo
[ssproject1617.git] / testcms-final-anon / system / admin / theme / assets / js / tabs.js
1 (function() {
2 var hide = function() {
3 $$('.tab').setStyles({
4 'display': 'none'
5 });
6
7 $$('.tabs a').removeClass('active');
8 };
9
10 var show = function(id) {
11 $$('[data-tab=' + id + ']').setStyles({
12 'display': 'block'
13 });
14
15 $$('a[href$=#' + id + ']').addClass('active');
16 };
17
18 var tab = function() {
19 var id = this.get('href').split('#').pop();
20
21 hide();
22 show(id);
23 };
24
25 // hide all
26 hide();
27
28 // show first
29 var hash = window.location.hash, first = hash.length ? hash.split('#').pop() : 'post';
30 show(first);
31
32 // bind to menu
33 $$('.tabs a').addEvent('click', tab);
34 }());