Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6287

Show
Ignore:
Timestamp:
03/02/07 14:01:24 (1 year ago)
Author:
mislav
Message:

correct syntax error; more cleanup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/branches/event/src/event.js

    r6237 r6287  
    114114    Object.extend(Observer.prototype, { 
    115115      _add: function() { 
    116         // TODO: create wrapper for Safari? 
    117116        this.element.addEventListener(this.type, this.observer, this.useCapture); 
    118117      }, 
     
    126125        // create a wrapper for scope correction and event object normalization 
    127126        var ob = this.observer, el = this.element, klass = this.constructor; 
    128         this.wrapper = function(e) { 
    129           return ob.call(el, klass.extendEvent(e)) 
    130         }; 
     127        this.wrapper = function(e) { return ob.call(el, klass.extendEvent(e)) }; 
    131128        this.element.attachEvent('on' + this.type, this.wrapper); 
    132129        this.constructor.globalCache.push(this); 
     
    141138      globalCache: [], 
    142139      unloadCache: function() { 
    143         for(var i=0, length = this.globalCache.length; i < length; i++) 
     140        for (var i = 0, length = this.globalCache.length; i < length; i++) 
    144141          this.globalCache[i].remove(); 
    145142      }, 
     
    157154      }, 
    158155      eventMethods: { 
    159         stopPropagation: function() { this.cancelBubble = true; }, 
    160         preventDefault:  function() { this.returnValue = false; }, 
    161         inspect: function() { return '[object Event]';
     156        stopPropagation: function() { this.cancelBubble = true }, 
     157        preventDefault:  function() { this.returnValue = false }, 
     158        inspect: function() { return '[object Event]'
    162159      } 
    163160    }); 
     
    168165 
    169166  // applies the calling method to an array of elements 
    170   function applyToList(args) { 
     167  function applyToCollection(args) { 
    171168    if (args[0].constructor != Array) return false; 
    172169    var method = args.callee; 
    173170    args = $A(args); 
    174     args.shift().each(function(el){ 
    175       method.apply(null, [el].concat(args)); 
    176     }); 
     171    args.shift().each(function(el){ method.apply(null, [el].concat(args)) }); 
    177172    return true; // the calling method can end 
    178   }, 
     173  }; 
    179174   
    180175  return { 
    181176    observe: function(element, type, observer, useCapture) { 
    182       if (applyToList(arguments)) return; 
     177      if (applyToCollection(arguments)) return; 
    183178      new Observer(element, type, observer, useCapture).add(); 
    184179    }, 
    185180    stopObserving: function(element, type, observer, useCapture) { 
    186       if (applyToList(arguments)) return; 
     181      if (applyToCollection(arguments)) return; 
    187182      new Observer(element, type, observer, useCapture).remove(); 
    188183    }