1.  
  2. var handleClick = function(e) {
  3. var label = e.getTarget();
  4. if (prevLabel) {
  5. prevLabel.setStyleProperty("fontWeight", "normal");
  6. }
  7. label.setStyleProperty("fontWeight", "bold");
  8. prevLabel = label;
  9. var file = label.file;
  10. var fadeOut = new BiOpacityAnimator(0, 500, false, BiComponentAnimation.CONSTANT_SPEED, dbBackground, BiFpsGenerator.DEFAULT_FRAME_RATE, true, true);
  11. fadeOut.setType("fadeOut");
  12. fadeOut.setSpeed("fast");
  13. fadeOut.start();
  14.  
  15. var handleAnimationEnd = function(e) {
  16. DashboardManager.throbber.setStyleProperty("display", "");
  17. // BEGIN :: Cache image file
  18. if (!DashboardManager.cachePropertyExists(file)) {
  19. var imgLoader = new BiImageLoader();
  20. imgLoader.setUri("./" + file);
  21. imgLoader.load();
  22.  
  23. var loadDone = function(e) {
  24. DashboardManager.throbber.setStyleProperty("display", "none");
  25. DashboardManager.addPropertyToCache(file);
  26.  
  27. dbBackground.setStyleProperty("backgroundImage", "url(./" + file + ")");
  28. dbBackground.setStyleProperty("backgroundRepeat", "no-repeat");
  29. dbBackground.setOpacity(0);
  30. var fadeIn = new BiOpacityAnimator(0, 500, false, BiComponentAnimation.CONSTANT_SPEED, dbBackground, BiFpsGenerator.DEFAULT_FRAME_RATE, true, true);
  31. fadeIn.setType("fadeIn");
  32. fadeIn.setSpeed("fast");
  33. fadeIn.start();
  34. this.removeEventListener("animationend", handleAnimationEnd);
  35. this.dispose();
  36. fadeIn.addEventListener("animationend", function(e){this.dispose();});
  37. this.removeEventListener("load", loadDone);
  38. imgLoader.dispose();
  39. }
  40. imgLoader.addEventListener("load", loadDone);
  41. }
  42. // END :: Cache image file
  43. else {
  44. DashboardManager.throbber.setStyleProperty("display", "none");
  45. dbBackground.setStyleProperty("backgroundImage", "url(./" + file + ")");
  46. dbBackground.setStyleProperty("backgroundRepeat", "no-repeat");
  47. dbBackground.setOpacity(0);
  48. var fadeIn = new BiOpacityAnimator(0, 500, false, BiComponentAnimation.CONSTANT_SPEED, dbBackground, BiFpsGenerator.DEFAULT_FRAME_RATE, true, true);
  49. fadeIn.setType("fadeIn");
  50. fadeIn.setSpeed("fast");
  51. fadeIn.start();
  52. this.removeEventListener("animationend", handleAnimationEnd);
  53. this.dispose();
  54. fadeIn.addEventListener("animationend", function(e){this.dispose();});
  55. this.removeEventListener("load", loadDone);
  56. }
  57. }
  58. fadeOut.addEventListener("animationend", handleAnimationEnd);
  59. }
  60. body.addEventListener("click", handleClick);
  61.  
  62.