Skip to content

Commit

Permalink
Fix for events naming convention in Asset
Browse files Browse the repository at this point in the history
  • Loading branch information
fakedarren committed Jan 14, 2010
1 parent af92e76 commit 00a88a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Docs/Utilities/Assets.md
Expand Up @@ -46,7 +46,7 @@ Injects a css file in the page.
### Arguments:

1. source - (*string*) The path of the CSS file.
2. properties - (*object*) Some additional attributes you might want to add to the link Element; this is the same as the second argument you might pass to including the Element constructor. For instance you might specify an onload event or perhaps an id.
2. properties - (*object*) Some additional attributes you might want to add to the link Element; this is the same as the second argument you might pass to including the Element constructor. For instance you might specify an onLoad event or perhaps an id.

### Returns:

Expand All @@ -70,20 +70,20 @@ Preloads an image and returns the img element.
### Arguments:

1. source - (*string*) The path of the image file.
2. properties - (*object*) Some additional attributes you might want to add to the img Element including the onload/onerror/onabort events.
2. properties - (*object*) Some additional attributes you might want to add to the img Element including the onLoad/onError/onAbort events.

### Returns:

* (*element*) A new HTML img Element.

### Examples:

var myImage = new Asset.image('/images/myImage.png', {id: 'myImage', title: 'myImage', onload: myFunction});
var myImage = new Asset.image('/images/myImage.png', {id: 'myImage', title: 'myImage', onLoad: myFunction});

### Notes:

- Does not inject the image into the page.
- WARNING: DO NOT use addEvent for load/error/abort on the returned element, give them as onload/onerror/onabort in the properties argument.
- WARNING: DO NOT use addEvent for load/error/abort on the returned element, give them as onLoad/onError/onAbort in the properties argument.



Expand Down
5 changes: 4 additions & 1 deletion Source/Utilities/Assets.js
Expand Up @@ -27,7 +27,9 @@ var Asset = {
document: document,
check: $lambda(true)
}, properties);


if (properties.onLoad) properties.onload = properties.onLoad;

var script = new Element('script', {src: source, type: 'text/javascript'});

var load = properties.onload.bind(script),
Expand Down Expand Up @@ -72,6 +74,7 @@ var Asset = {
var element = document.id(image) || new Element('img');
['load', 'abort', 'error'].each(function(name){
var type = 'on' + name;
if (properties['on' + name.capitalize()]) properties[type] = properties['on' + name.capitalize()];
var event = properties[type];
delete properties[type];
image[type] = function(){
Expand Down

0 comments on commit 00a88a6

Please sign in to comment.