Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add: function(src, rel) {
- if (this.cache[src]) {
- return this.cache[src];
- }
- if (this.cache[rel]) {
- return this.cache[rel];
- }
- // The only "rel" value in this function is what you're passing to the "rel" parameter.
- alert( rel ); // take a look at the value
- // create a new image
- var image = new Image();
- // assign the src
- image.src = src;
- // assign the rel. Apparently we need to assign both the property and attribute separately
- image.rel = rel;
- image.setAttribute('rel',rel);
- // set the style of the image
- this.setStyle(image, {display: 'block'});
- // go ahead and return the image if it is already loaded
- if (image.complete && image.width) {
- return image;
- }
- // If we get this far, the image wasn't loaded yet, so we assign an "onload" handler
- image.onload = (function(scope) {
- return function() {
- scope.cache[src] = image;
- };
- })(this);
- // return the image
- return image;
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement