listen.js
//so that any registrations made will be unmade when boundobject.release() is called!
so that any registrations made will be unmade when boundobject.release() is called!
so that any registrations made will be unmade when boundobject . release () is called!
function listen(obj, attrlist, method, context, boundobject){
    if(!(obj instanceof Object))
       throw "A non-object was passed to listen for the attribute \""+attr+"\" and is an error. Object: "+String(obj)+".";
    if(boundobject !== undefined){            
        if(boundobject['__listening__'] === undefined)
            boundobject['__listening__'] = [];
        if(boundobject.release === undefined)
            boundobject.release = _releaseListens;
    }
    attrlist = stringToList(attrlist);
    var releaselist =  [];
    for(var i = 0; i < attrlist.length ; i ++){
        var attr = attrlist[i];
        if(obj.__listeners__ === undefined)  
            obj.__listeners__ = {};
        if(obj.__listeners__[attr] === undefined)  
            obj.__listeners__[attr] = new Array;
        obj.__listeners__[attr].push([method, context]);   
        releaselist.push([
            obj, attr, method, context, boundobject
        ]);
    }
    if(boundobject)
        boundobject.__listening__.extend(releaselist);
    return releaselist;
}
function listen ( obj , attrlist , method , context , boundobject ) { if ( ! ( obj instanceof Object ) ) throw "A non-object was passed to listen for the attribute \"" + attr + "\" and is an error. Object: " + String ( obj ) + "." ; if ( boundobject !== undefined ) { if ( boundobject [ '__listening__' ] === undefined ) boundobject [ '__listening__' ] = [ ] ; if ( boundobject . release === undefined ) boundobject . release = _releaseListens ; } attrlist = stringToList ( attrlist ) ; var releaselist = [ ] ; for ( var i = 0 ; i < attrlist . length ; i ++ ) { var attr = attrlist [ i ] ; if ( obj . __listeners__ === undefined ) obj . __listeners__ = { } ; if ( obj . __listeners__ [ attr ] === undefined ) obj . __listeners__ [ attr ] = new Array ; obj . __listeners__ [ attr ] . push ( [ method , context ] ) ; releaselist . push ( [ obj , attr , method , context , boundobject ] ) ; } if ( boundobject ) boundobject . __listening__ . extend ( releaselist ) ; return releaselist ; }
so that any registrations made will be unmade when boundobject.release() is called!
so that any registrations made will be unmade when boundobject . release () is called!
/* listening to undefined is badbadbad.  */ /* if they give a boundobject, initialize it if not already */ /* if they pass a single string, make it a list */ /* if they provide a bound object, push the release list onto it. */