/
tabs.js
61 lines (49 loc) · 1.14 KB
/
tabs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
---
description: MGFX.Tabs
authors:
- Sean McArthur (http://mcarthurgfx.com)
license:
- MIT-style license
requires:
core/1.2.4: '*'
more/1.2.4.1: Fx.Elements
provides:
- MGFX.Tabs
...
*/
//MGFX.Tabs. Copyright (c) 2008-2009 Sean McArthur <http://mcarthurgfx.com/>, MIT Style License.
var MGFX = MGFX || {};
MGFX.Tabs = new Class({
Extends: MGFX.Rotater,
options: {
autoplay: false,
onShowSlide: function(slideIndex) {
this.tabs.removeClass('active');
this.tabs[slideIndex].addClass('active');
}
},
initialize: function(tabs, slides, options){
this.setOptions(options);
this.tabs = $$(tabs);
this.createTabs();
if(this.options.hash && window.location.hash) {
var hash = window.location.hash.substring(1);
this.tabs.each(function(el, index) {
if(el.get('id') == hash) {
options.startIndex = index;
}
});
}
return this.parent(slides,options);
},
createTabs: function () {
this.tabs.each(function(tab,index){
tab.addEvent('click', function(event){
event.preventDefault();
this.showSlide(index);
this.stop(true);
}.bind(this));
}.bind(this));
}.protect()
});