Builder3/Window.js
[app.Builder.js] / Observable.js
index 45d9f49..46cb8a2 100644 (file)
@@ -89,9 +89,9 @@ Observable = XObject.define(
          * @param {Object}   options (optional) An object containing handler configuration
          * properties. This may contain any of the following properties:<ul>
          * <li>scope {Object} The scope in which to execute the handler function. The handler function's "this" context.</li>
-         * <li>delay {Number} The number of milliseconds to delay the invocation of the handler after te event fires.</li>
+         * <li>delay {Number} The number of milliseconds to delay the invocation of the handler after te event fires.NOT AVAIALBLE</li>
          * <li>single {Boolean} True to add a handler to handle just the next firing of the event, and then remove itself.</li>
-         * <li>buffer {Number} Causes the handler to be scheduled to run in an {@link Roo.DelayedTask} delayed
+         * <li>buffer {Number} Causes the handler to be scheduled to run in an {@link DelayedEvent} delayed NOT AVAIALBLE
          * by the specified number of milliseconds. If the event fires again within that time, the original
          * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</li>
          * </ul><br>
@@ -160,7 +160,7 @@ Observable = XObject.define(
             eventName = eventName.toLowerCase();
             var ce = this.events[eventName] || true;
             if(typeof ce == "boolean"){
-                ce = new Roo.Event(this, eventName);
+                ce = new Event(this, eventName);
                 this.events[eventName] = ce;
             }
             ce.addListener(fn, scope, o);
@@ -189,11 +189,26 @@ Observable = XObject.define(
                 }
             }
         },
-
+        _combine : function(){
+            var as = arguments, l = as.length, r = [];
+            for(var i = 0; i < l; i++){
+                var a = as[i];
+                if(a instanceof Array){
+                    r = r.concat(a);
+                }else if(a.length !== undefined && !a.substr){
+                    r = r.concat(Array.prototype.slice.call(a, 0));
+                }else{
+                    r.push(a);
+                }
+            }
+            return r;
+        },
+        
         relayEvents : function(o, events){
             var createHandler = function(ename){
                 return function(){
-                    return this.fireEvent.apply(this, Roo.combine(ename, Array.prototype.slice.call(arguments, 0)));
+                    return this.fireEvent.apply(this, Event.prototype.combine(ename, 
+                            Array.prototype.slice.call(arguments, 0)));
                 };
             };
             for(var i = 0, len = events.length; i < len; i++){
@@ -211,7 +226,7 @@ Observable = XObject.define(
             if(!this.events){
                 this.events = {};
             }
-            Roo.applyIf(this.events, o);
+            XObject.extendIf(this.events, o);
         },
 
         /**
@@ -223,7 +238,7 @@ Observable = XObject.define(
             var e = this.events[eventName];
             return typeof e == "object" && e.listeners.length > 0;
         }
-};
+});
  
 /**
  * Starts capture on the specified Observable. All events will be passed
@@ -248,53 +263,66 @@ Observable.releaseCapture = function(o){
     o.fireEvent = Observable.prototype.fireEvent;
 };
 
-(function(){
 
-    var createBuffered = function(h, o, scope){
-        var task = new Roo.DelayedTask();
-        return function(){
-            task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
-        };
+var createSingle = function(h, e, fn, scope){
+    return function(){
+        e.removeListener(fn, scope);
+        return h.apply(scope, arguments);
     };
+};
 
-    var createSingle = function(h, e, fn, scope){
-        return function(){
-            e.removeListener(fn, scope);
-            return h.apply(scope, arguments);
-        };
-    };
+// NOT SUPPORTED YET>
+//var createBuffered = function(h, o, scope){
+//    var task = new DelayedTask();
+//    return function(){
+//        task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
+//    };
+//};
+
+
+//var createDelayed = function(h, o, scope){
+//    return function(){
+//        var args = Array.prototype.slice.call(arguments, 0);
+//        setTimeout(function(){
+//            h.apply(scope, args);
+//        }, o.delay || 10);
+//    };
+//};
 
-    var createDelayed = function(h, o, scope){
-        return function(){
-            var args = Array.prototype.slice.call(arguments, 0);
-            setTimeout(function(){
-                h.apply(scope, args);
-            }, o.delay || 10);
-        };
-    };
 
-    Roo.Event = function(obj, name){
+/**
+ * Event Object - manages a specific event.
+ * 
+ * 
+ * 
+ */
+
+
+
+Event = XObject.define(
+    function(obj, name){
         this.name = name;
         this.obj = obj;
         this.listeners = [];
-    };
-
-    Roo.Event.prototype = {
+    },
+    Object, 
+    {
         addListener : function(fn, scope, options){
             var o = options || {};
             scope = scope || this.obj;
             if(!this.isListening(fn, scope)){
                 var l = {fn: fn, scope: scope, options: o};
                 var h = fn;
-                if(o.delay){
-                    h = createDelayed(h, o, scope);
-                }
+               // if(o.delay){
+                //       h = createDelayed(h, o, scope);
+               // }
                 if(o.single){
                     h = createSingle(h, this, fn, scope);
                 }
-                if(o.buffer){
-                    h = createBuffered(h, o, scope);
-                }
+                //if(o.buffer){
+               //     h = createBuffered(h, o, scope);
+                //}
                 l.fireFn = h;
                 if(!this.firing){ // if we are currently firing this event, don't disturb the listener loop
                     this.listeners.push(l);
@@ -355,5 +383,5 @@ Observable.releaseCapture = function(o){
             }
             return true;
         }
-    };
-})();
\ No newline at end of file
+    }
+);