forked from kaelzhang/neuron.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabswitch.js
More file actions
50 lines (36 loc) · 1.17 KB
/
tabswitch.js
File metadata and controls
50 lines (36 loc) · 1.17 KB
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
/**
* Switch Plugin: Tab Switching
* author Kael Zhang
*/
module.exports = {
name: 'tabSwitch',
// no plugins will be added after this one
final_: true,
init: function(self){
var EVENTS = self.get('EVENTS'),
ITEM_ON_CLS = 'itemOnCls';
self.on(EVENTS.BEFORE_SWITCH, function(){
var t = this,
activeItem = t._getItem(t.activeIndex);
activeItem && activeItem.removeClass(t.get(ITEM_ON_CLS));
t._dealTriggerCls(true);
});
self.on(EVENTS.ON_SWITCH, function(){
var t = this,
active = t.activeIndex = t.expectIndex,
activeItem = t._getItem(active);
activeItem && activeItem.addClass(t.get(ITEM_ON_CLS));
t._dealTriggerCls(false, active);
t.fire(EVENTS.COMPLETE_SWITCH);
});
}
};
/**
change log
2012-04-22 Kael:
- fix a runtime error if there's no items at the beginning
2012-04-19 Kael:
- turn back the missing COMPLETE_SWITCH event
2011-10-31 Kael:
- use _dealTriggerCls and _getItem instead of old methods
*/