]>
git.proxmox.com Git - sencha-touch.git/blob - src/src/event/ListenerStack.js
6 Ext
.define('Ext.event.ListenerStack', {
8 currentOrder
: 'current',
12 constructor: function() {
19 this.lateBindingMap
= {};
24 add: function(fn
, scope
, options
, order
) {
25 var lateBindingMap
= this.lateBindingMap
,
26 listeners
= this.getAll(order
),
28 bindingMap
, listener
, id
;
30 if (typeof fn
== 'string' && scope
.isIdentifiable
) {
33 bindingMap
= lateBindingMap
[id
];
40 bindingMap
[fn
] = true;
44 lateBindingMap
[id
] = bindingMap
= {};
45 bindingMap
[fn
] = true;
51 listener
= listeners
[i
];
53 if (listener
.fn
=== fn
&& listener
.scope
=== scope
) {
54 listener
.options
= options
;
61 listener
= this.create(fn
, scope
, options
, order
);
63 if (options
&& options
.prepend
) {
64 delete options
.prepend
;
65 listeners
.unshift(listener
);
68 listeners
.push(listener
);
76 getAt: function(index
, order
) {
77 return this.getAll(order
)[index
];
80 getAll: function(order
) {
82 order
= this.currentOrder
;
85 return this.listeners
[order
];
88 count: function(order
) {
89 return this.getAll(order
).length
;
92 create: function(fn
, scope
, options
, order
) {
98 isLateBinding
: typeof fn
== 'string',
100 options
: options
|| {},
105 remove: function(fn
, scope
, order
) {
106 var listeners
= this.getAll(order
),
107 i
= listeners
.length
,
109 lateBindingMap
= this.lateBindingMap
,
113 // Start from the end index, faster than looping from the
114 // beginning for "single" listeners,
115 // which are normally LIFO
117 listener
= listeners
[i
];
119 if (listener
.fn
=== fn
&& listener
.scope
=== scope
) {
120 listeners
.splice(i
, 1);
124 if (typeof fn
== 'string' && scope
.isIdentifiable
) {
127 if (lateBindingMap
[id
] && lateBindingMap
[id
][fn
]) {
128 delete lateBindingMap
[id
][fn
];