source: Dev/branches/rest-dojo-ui/client/dojox/image/_base.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.7 KB
Line 
1define(["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: Preload a list of images in the dom.
9                //
10                // urls: Array
11                //              The list of urls to load. Can be any valid .src attribute.
12                //
13                //      example:
14                //      Load two images into cache:
15                //      |       dojox.image.preload(["foo.png", "bar.gif"]);
16                //
17                //      example:
18                //      Using djConfig:
19                //      |       var djConfig = {
20                //      |               preloadImages:["bar.png", "baz.png", "http://example.com/icon.gif"]
21                //      |       };
22                //
23                // returns: Array
24                //              An Array of DomNodes that have been cached.
25               
26                if(!cacheNode){
27                        cacheNode = d.create("div", {
28                                style:{ position:"absolute", top:"-9999px", height:"1px", overflow:"hidden" }
29                        }, d.body());
30                }
31
32                // place them in the hidden cachenode
33                return d.map(urls, function(url){
34                        return d.create("img", { src: url }, cacheNode);
35                });
36       
37        };
38       
39        /*=====
40        dojo.mixin(djConfig, {
41                // preloadImages: Array?
42                //              An optional array of urls to preload immediately upon
43                //              page load. Uses `dojox.image`, and is unused if not present.
44                preloadImages: []
45        });
46        =====*/
47       
48        if(d.config.preloadImages){
49                d.addOnLoad(function(){
50                        dojox.image.preload(d.config.preloadImages);
51                });
52        }
53               
54//      dojo.declare("dojox.image.Image", dijit._Widget, {
55//              // summary: an Image widget
56//              //
57//              // example:
58//              //      | new dojox.Image({ src:"foo.png", id:"bar" });
59//
60//              alt: "",
61//              src: dojo._blankGif,
62//              title: "",
63//
64//              onLoad: function(e){
65//                      // summary: Stub fired when this image is really ready.
66//              },
67//
68//              _onLoad: function(e){
69//                      // summary: private function to normalize `onLoad` for this
70//                      //      instance.
71//                      this.onLoad(e);
72//              },
73//
74//              _setSrcAttr: function(newSrc){
75//                      // summary: 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: Set this Image to a new src with crossfading
87//                      //
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});
Note: See TracBrowser for help on using the repository browser.