_base.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. define("dojox/image/_base", ["dojo", "dojox"], function(dojo, dojox){
  2. dojo.getObject("image", true, dojox);
  3. var d = dojo;
  4. var cacheNode;
  5. dojox.image.preload = function(/* Array */urls){
  6. // summary: Preload a list of images in the dom.
  7. //
  8. // urls: Array
  9. // The list of urls to load. Can be any valid .src attribute.
  10. //
  11. // example:
  12. // Load two images into cache:
  13. // | dojox.image.preload(["foo.png", "bar.gif"]);
  14. //
  15. // example:
  16. // Using djConfig:
  17. // | var djConfig = {
  18. // | preloadImages:["bar.png", "baz.png", "http://example.com/icon.gif"]
  19. // | };
  20. //
  21. // returns: Array
  22. // An Array of DomNodes that have been cached.
  23. if(!cacheNode){
  24. cacheNode = d.create("div", {
  25. style:{ position:"absolute", top:"-9999px", height:"1px", overflow:"hidden" }
  26. }, d.body());
  27. }
  28. // place them in the hidden cachenode
  29. return d.map(urls, function(url){
  30. return d.create("img", { src: url }, cacheNode);
  31. });
  32. };
  33. /*=====
  34. dojo.mixin(djConfig, {
  35. // preloadImages: Array?
  36. // An optional array of urls to preload immediately upon
  37. // page load. Uses `dojox.image`, and is unused if not present.
  38. preloadImages: []
  39. });
  40. =====*/
  41. if(d.config.preloadImages){
  42. d.addOnLoad(function(){
  43. dojox.image.preload(d.config.preloadImages);
  44. });
  45. }
  46. // dojo.declare("dojox.image.Image", dijit._Widget, {
  47. // // summary: an Image widget
  48. // //
  49. // // example:
  50. // // | new dojox.Image({ src:"foo.png", id:"bar" });
  51. //
  52. // alt: "",
  53. // src: dojo._blankGif,
  54. // title: "",
  55. //
  56. // onLoad: function(e){
  57. // // summary: Stub fired when this image is really ready.
  58. // },
  59. //
  60. // _onLoad: function(e){
  61. // // summary: private function to normalize `onLoad` for this
  62. // // instance.
  63. // this.onLoad(e);
  64. // },
  65. //
  66. // _setSrcAttr: function(newSrc){
  67. // // summary: Function so widget.attr('src', someUrl) works
  68. //
  69. // var ts = this.domNode, os = td.src;
  70. // if(os !== newSrc){
  71. // td.src = newSrc;
  72. // }
  73. // },
  74. //
  75. // /* Sugar Functions: */
  76. //
  77. // crossFade: function(newSrc){
  78. // // summary: Set this Image to a new src with crossfading
  79. // //
  80. // // example:
  81. // // dijit.byId("bar").crossFade("/images/newImage.png");
  82. // //
  83. //
  84. // d.fadeOut({
  85. // node: this.domNode,
  86. // onEnd: d.hitch(this, function(){
  87. // this.attr('src', newSrc);
  88. // d.fadeIn({
  89. // node: this.domNode,
  90. // delay: 75
  91. // }).play();
  92. // })
  93. // }).play();
  94. // },
  95. //
  96. // /* Overrides */
  97. //
  98. // buildRendering: function(){
  99. // // override buildrendering to create a real "img" instead of a div
  100. // // when no srcNodeRef is passed. also wire up single onload.
  101. // this.domNode = this.srcNodeRef || d.create('img');
  102. // this.connect(this.domNode, "onload", "_onload");
  103. // }
  104. //
  105. // });
  106. });