-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExt.layout.CardLayoutOverride.js
More file actions
89 lines (87 loc) · 3.73 KB
/
Ext.layout.CardLayoutOverride.js
File metadata and controls
89 lines (87 loc) · 3.73 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Ext.override(Ext.layout.CardLayout, {
setActiveItem: function(newCard, animation,hideActive) {
var me = this,
owner = me.owner,
doc = Ext.getDoc(),
oldCard = me.activeItem,
newIndex;
animation = (animation == undefined) ? this.getAnimation(newCard, owner) : animation;
var hideActive = hideActive == undefined ? false : hideActive;
newCard = me.parseActiveItem(newCard);
newIndex = owner.items.indexOf(newCard);
// If the card is not a child of the owner, then add it
if (newIndex == -1) {
owner.add(newCard);
}
// Is this a valid, different card?
if (newCard && oldCard != newCard && owner.onBeforeCardSwitch(newCard, oldCard, newIndex, !!animation) !== false) {
// If the card has not been rendered yet, now is the time to do so.
if (!newCard.rendered) {
this.layout();
}
// Fire the beforeactivate and beforedeactivate events on the cards
if (newCard.fireEvent('beforeactivate', newCard, oldCard) === false) {
return false;
}
if (oldCard && oldCard.fireEvent('beforedeactivate', oldCard, newCard) === false) {
return false;
}
// Make sure the new card is shown, but only show if not explictly prohibited
if (newCard.hidden && !hideActive) {
newCard.show();
}
me.activeItem = newCard;
if (animation) {
doc.on('click', Ext.emptyFn, me, {
single: true,
preventDefault: true
});
Ext.Anim.run(newCard, animation, {
out: false,
autoClear: true,
scope: me,
after: function() {
Ext.defer(function() {
doc.un('click', Ext.emptyFn, me);
},
50, me);
newCard.fireEvent('activate', newCard, oldCard);
if (!oldCard) {
// If there is no old card, the we have to make sure that we fire
// onCardSwitch here.
owner.onCardSwitch(newCard, oldCard, newIndex, true);
}
}
});
if (oldCard) {
Ext.Anim.run(oldCard, animation, {
out: true,
autoClear: true,
after: function() {
oldCard.fireEvent('deactivate', oldCard, newCard);
if (me.hideInactive && me.activeItem != oldCard) {
oldCard.hide();
}
// We fire onCardSwitch in the after of the oldCard animation
// because that is the last one to fire, and we want to make sure
// both animations are finished before firing it.
owner.onCardSwitch(newCard, oldCard, newIndex, true);
}
});
}
}
else {
newCard.fireEvent('activate', newCard, oldCard);
if (oldCard) {
oldCard.fireEvent('deactivate', oldCard, newCard);
if (me.hideInactive) {
oldCard.hide();
}
}
owner.onCardSwitch(newCard, oldCard, newIndex, false);
}
return newCard;
}
return false;
}
})