-<html>
-<head>
- <title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body onload="prettyPrint();">
- <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-(function(){
+<html>\r
+<head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
+ <title>The source code</title>\r
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body onload="prettyPrint();">\r
+ <pre class="prettyprint lang-js">(function(){
var EXTUTIL = Ext.util,
TOARRAY = Ext.toArray,
ISOBJECT = Ext.isObject,
TRUE = true,
FALSE = false;
-<div id="cls-Ext.util.Observable"></div>/**
+/**
* @class Ext.util.Observable
* Base class that provides a common interface for publishing events. Subclasses are expected to
* to have a property "events" with all the events defined, and, optionally, a property "listeners"
var me = this;
me.events = me.events || {};
if (Ext.isString(o)) {
- EACH(arguments, function(a) {
- me.events[a] = me.events[a] || TRUE;
- });
+ var a = arguments,
+ i = a.length;
+ while(i--) {
+ me.events[a[i]] = me.events[a[i]] || TRUE;
+ }
} else {
Ext.applyIf(me.events, o);
}
};
};
-function createBuffered(h, o, scope){
- var task = new EXTUTIL.DelayedTask();
+function createBuffered(h, o, l, scope){
+ l.task = new EXTUTIL.DelayedTask();
return function(){
- task.delay(o.buffer, h, scope, TOARRAY(arguments));
+ l.task.delay(o.buffer, h, scope, TOARRAY(arguments));
};
-}
+};
function createSingle(h, e, fn, scope){
return function(){
e.removeListener(fn, scope);
return h.apply(scope, arguments);
};
-}
+};
-function createDelayed(h, o, scope){
+function createDelayed(h, o, l, scope){
return function(){
- var args = TOARRAY(arguments);
- (function(){
- h.apply(scope, args);
- }).defer(o.delay || 10);
+ var task = new EXTUTIL.DelayedTask();
+ if(!l.tasks) {
+ l.tasks = [];
+ }
+ l.tasks.push(task);
+ task.delay(o.delay || 10, h, scope, TOARRAY(arguments));
};
};
h = createTargeted(h, o, scope);
}
if(o.delay){
- h = createDelayed(h, o, scope);
+ h = createDelayed(h, o, l, scope);
}
if(o.single){
h = createSingle(h, this, fn, scope);
}
if(o.buffer){
- h = createBuffered(h, o, scope);
+ h = createBuffered(h, o, l, scope);
}
l.fireFn = h;
return l;
},
findListener : function(fn, scope){
- var s, ret = -1;
- EACH(this.listeners, function(l, i) {
- s = l.scope;
- if(l.fn == fn && (s == scope || s == this.obj)){
- ret = i;
- return FALSE;
+ var list = this.listeners,
+ i = list.length,
+ l,
+ s;
+ while(i--) {
+ l = list[i];
+ if(l) {
+ s = l.scope;
+ if(l.fn == fn && (s == scope || s == this.obj)){
+ return i;
+ }
}
- },
- this);
- return ret;
+ }
+ return -1;
},
isListening : function(fn, scope){
removeListener : function(fn, scope){
var index,
+ l,
+ k,
me = this,
ret = FALSE;
if((index = me.findListener(fn, scope)) != -1){
if (me.firing) {
me.listeners = me.listeners.slice(0);
}
+ l = me.listeners[index];
+ if(l.task) {
+ l.task.cancel();
+ delete l.task;
+ }
+ k = l.tasks && l.tasks.length;
+ if(k) {
+ while(k--) {
+ l.tasks[k].cancel();
+ }
+ delete l.tasks;
+ }
me.listeners.splice(index, 1);
ret = TRUE;
}
return ret;
},
+ // Iterate to stop any buffered/delayed events
clearListeners : function(){
- this.listeners = [];
+ var me = this,
+ l = me.listeners,
+ i = l.length;
+ while(i--) {
+ me.removeListener(l[i].fn, l[i].scope);
+ }
},
fire : function(){
var me = this,
args = TOARRAY(arguments),
- ret = TRUE;
+ listeners = me.listeners,
+ len = listeners.length,
+ i = 0,
+ l;
- EACH(me.listeners, function(l) {
+ if(len > 0){
me.firing = TRUE;
- if (l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) {
- return ret = me.firing = FALSE;
+ for (; i < len; i++) {
+ l = listeners[i];
+ if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) {
+ return (me.firing = FALSE);
+ }
}
- });
+ }
me.firing = FALSE;
- return ret;
+ return TRUE;
}
};
-})();</pre>
-</body>
+})();</pre> \r
+</body>\r
</html>
\ No newline at end of file