_base.js 3.0 KB

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