Guest User

Untitled

a guest
May 27th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. function getImageContent(options) {
  2. var image = new Image();
  3.  
  4. var complete = false;
  5.  
  6. // Create a handler when then image has loaded
  7. function updateContentHandler() {
  8. complete = true;
  9. removeLoadingMessage();
  10. setLovefilmBoxContent(
  11. $(template.image).attr({
  12. src: options.src,
  13. height: image.height || options.height,
  14. width: image.width || options.width,
  15. alt: options.alt
  16. })
  17. );
  18. };
  19.  
  20.  
  21. // MSIE uses image.complete flag which we check periodically,
  22. // other browsers use onload properly.
  23. if ($.browser.msie) {
  24. function isImageLoaded() {
  25. if (image.complete) {
  26. updateContentHandler();
  27. return;
  28. }
  29. setTimeout(isImageLoaded, 1000);
  30. }
  31.  
  32. image.src = options.src;
  33. setTimeout(isImageLoaded, 100);
  34. }
  35. else {
  36. image.onload = updateContentHandler;
  37.  
  38. // Set after the onload handler, in case the image is
  39. // already cached
  40. image.src = options.src;
  41.  
  42. /* Work around Webkit browsers not firing load if the image
  43. when the image is cached. (Don't let MSIE see this) */
  44. if (image.width) {
  45. complete = true;
  46. }
  47. }
  48.  
  49.  
  50. // Return the "Loading..." content, to be replaced later with
  51. // the real content
  52. return (complete)
  53. ? null
  54. : getLoadingContent(options);
  55. };
Add Comment
Please, Sign In to add comment