Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getImageContent(options) {
- var image = new Image();
- var complete = false;
- // Create a handler when then image has loaded
- function updateContentHandler() {
- complete = true;
- removeLoadingMessage();
- setLovefilmBoxContent(
- $(template.image).attr({
- src: options.src,
- height: image.height || options.height,
- width: image.width || options.width,
- alt: options.alt
- })
- );
- };
- // MSIE uses image.complete flag which we check periodically,
- // other browsers use onload properly.
- if ($.browser.msie) {
- function isImageLoaded() {
- if (image.complete) {
- updateContentHandler();
- return;
- }
- setTimeout(isImageLoaded, 1000);
- }
- image.src = options.src;
- setTimeout(isImageLoaded, 100);
- }
- else {
- image.onload = updateContentHandler;
- // Set after the onload handler, in case the image is
- // already cached
- image.src = options.src;
- /* Work around Webkit browsers not firing load if the image
- when the image is cached. (Don't let MSIE see this) */
- if (image.width) {
- complete = true;
- }
- }
- // Return the "Loading..." content, to be replaced later with
- // the real content
- return (complete)
- ? null
- : getLoadingContent(options);
- };
Add Comment
Please, Sign In to add comment