Changeset 13684

Show
Ignore:
Timestamp:
05/10/08 20:29:28 (5 days ago)
Author:
dante
Message:

refs #6668 - shows how a fisheyelite can be destroy(true)'d and be re-applied with no leaking.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojox/trunk/widget/tests/test_FisheyeLite.html

    r13421 r13684  
    6767                dojo.require("dojo.parser"); 
    6868                dojo.require("dojox.widget.FisheyeLite"); 
    69                 dojo.addOnLoad(function(){ 
     69 
     70                var beenDestroyed = false; 
     71                var hasInit = false; 
     72                var init = function(e){ 
     73                         
     74                        if(e && !beenDestroyed){ return; } 
     75                        e && e.preventDefault(); 
    7076                         
    7177                        // turn li's in this page into fisheye items, presumtiously:     
    7278                        dojo.query("li.bounce").instantiate(dojox.widget.FisheyeLite,{}); 
    7379 
    74                         dojo.query("span.line") 
     80                        var l = dojo.query("span.line") 
    7581                                .instantiate(dojox.widget.FisheyeLite,{ 
    7682                                // make a widget from each of the lines in the lineHeightTest 
     
    8086                                        easeOut: dojox.fx.easing.backInOut, 
    8187                                        durationOut: 500 
    82                                 }) 
    83                                 .connect("onclick",function(e){ 
     88                                }); 
     89                                 
     90                        if(!hasInit){ 
     91                                l.connect("onclick",function(e){ 
    8492                                // you can still access the onclick of the real node 
    8593                                        alert(e.target.innerHTML); 
    86                                 }) 
    87                         ; 
    88  
    89                         dojo.query("a").instantiate(dojox.widget.FisheyeLite,{ 
     94                                }); 
     95                        } 
     96 
     97                        var lm = dojo.query("a").instantiate(dojox.widget.FisheyeLite,{ 
    9098                                properties:{ 
    9199                                        fontSize:1.15, 
    92100                                        letterSpacing:2.85 
    93101                                } 
    94                         }) 
     102                        }); 
     103                        if(!hasInit){ 
    95104                        // stop anchors from doing _anything_    
    96                         .connect("onclick",dojo,"stopEvent"); 
     105                                lm.connect("onclick",dojo,"stopEvent"); 
     106                        } 
    97107 
    98108                        dojo.query(".imgBounce").instantiate(dojox.widget.FisheyeLite,{ 
     
    114124                        // a few in markup, mostly from the query()'ies: 
    115125                        console.log("fisheyes on this page: ", vv); 
    116  
    117                 });              
     126                                 
     127                        beenDestroyed = false; 
     128                        hasInit = true; 
     129                }; 
     130                dojo.addOnLoad(init); 
     131                 
     132                dojo.addOnLoad(function(){ 
     133                        dojo.query("#restore").connect("onclick",init); 
     134                        dojo.query("#destroy").connect("onclick",destroyAll); 
     135                }); 
     136                 
     137                var destroyAll = function(e){ 
     138                        e && e.preventDefault(); 
     139                        if(confirm("really?")){ 
     140                                dijit.registry.filter(function(w){ 
     141                                        return w && w.declaredClass == "dojox.widget.FisheyeLite"; 
     142                                }).forEach(function(w){ 
     143                                        w.destroy(true); 
     144                                }); 
     145                                beenDestroyed = true; 
     146                        } 
     147                }; 
     148                         
    118149        </script> 
    119150    </head> 
     
    163194                                </div> 
    164195 
     196                                <div> 
     197                                        <div dojoType="dojox.widget.FisheyeLite" properties="{ fontSize:1.25 }" style="padding:3px" 
     198                                        ><a id='destroy' href="#" class="fisheyeTarget">test destroy()</a></div> 
     199 
     200                                        <div dojoType="dojox.widget.FisheyeLite" properties="{ fontSize:1.25 }" style="padding:3px" 
     201                                        ><a id='restore' href="#" class="fisheyeTarget">restore</a></div> 
     202                                </div> 
     203 
    165204                                <p> 
    166205                                Lorem ipsum dolor sit amet, <a href="#">consectetuer</a> adipiscing elit. Aenean 
     
    194233                                semper iaculis.  Sed molestie tortor at ipsum.  
    195234                                </p> 
     235                                 
    196236                                <h3>another list: (no target, or ilk)</h3> 
    197237                                <div style="height:125px; position:relative;"> 
     
    248288                                 
    249289                                <p>the end</p> 
    250  
     290                                 
    251291                </div>   
    252292    </body>