Changeset 7061
- Timestamp:
- 06/19/07 14:45:19 (1 year ago)
- Files:
-
- spinoffs/prototype/branches/event/src/event.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/prototype/branches/event/src/event.js
r7056 r7061 230 230 } 231 231 232 // applies the calling method to an array of elements233 var applyToCollection = function(args) {234 if (args[0].constructor != Array) return false;235 var method = args.callee;236 args = $A(args);237 args.shift().each(function(el){ method.apply(null, [el].concat(args)) });238 return true; // the calling method can end239 };240 241 232 // onReady helper stuff 242 233 var readyCallbacks, timer, domReady = function() { … … 249 240 }; 250 241 242 // applies the calling method to an array of elements 243 var applyToCollection = function(args) { 244 switch ([0, 1].detect(function(i){ return args[i] && args[i].constructor == Array })) { 245 case 0: 246 // multiple observers 247 var method = args.callee; 248 args = $A(args); 249 args.shift().each(function(element) { 250 method.apply(null, [element].concat(args)); 251 }); 252 return true; // the calling method can end 253 case 1: 254 // multiple types 255 args[1].each(function(type) { 256 args.callee.call(null, args[0], type, args[2], args[3]) 257 }); 258 return true; 259 default: 260 return false; 261 } 262 }; 263 251 264 return { 252 265 observe: function(element, type, callback, useCapture) {