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