Changeset 8925

Show
Ignore:
Timestamp:
06/04/07 22:18:55 (19 months ago)
Author:
alex
Message:

ensure that repeated showings of a dialog continue to show the background. Improve background show/hide to actually fade things in and out. We want dialogs to be visually attractive. More work on transitions may be in order (e.g., Lightbox effects). Refs #3247

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/layout/Dialog.js

    r8904 r8925  
    1313        [dijit.layout.ContentPane, dijit.base.TemplatedWidget], 
    1414        { 
    15                 // summary 
    16                 //      Pops up a modal dialog window, blocking access to the screen and also graying out the screen 
    17                 //      Dialog is extended from ContentPane so it supports all the same parameters (href, etc.) 
     15                // summary: 
     16                //              Pops up a modal dialog window, blocking access to the screen 
     17                //              and also graying out the screen Dialog is extended from 
     18                //              ContentPane so it supports all the same parameters (href, etc.) 
    1819 
    1920                templatePath: dojo.moduleUrl("dijit.layout", "templates/Dialog.html"), 
     
    4243                 
    4344                _trapTabs: function(/*Event*/ e){ 
    44                         // summary 
    45                         //      callback on focus 
    46                         if(e.target == this.tabStartOuter) { 
    47                                 if(this._fromTrap) { 
    48                                         this.tabStart.focus(); 
    49                                         this._fromTrap = false; 
    50                                 } else { 
     45                        // summary: callback on focus 
     46                        if(e.target == this.tabStartOuter){ 
     47                                if(this._fromTrap){ 
     48                                        this.tabStart.focus(); 
     49                                        this._fromTrap = false; 
     50                                }else{ 
    5151                                        this._fromTrap = true; 
    5252                                        this.tabEnd.focus(); 
    5353                                } 
    54                         } else if (e.target == this.tabStart) { 
    55                                 if(this._fromTrap) { 
    56                                         this._fromTrap = false; 
    57                                 } else { 
     54                        }else if(e.target == this.tabStart){ 
     55                                if(this._fromTrap){ 
     56                                        this._fromTrap = false; 
     57                                }else{ 
    5858                                        this._fromTrap = true; 
    5959                                        this.tabEnd.focus(); 
    6060                                } 
    61                         } else if(e.target == this.tabEndOuter) { 
    62                                 if(this._fromTrap) { 
     61                        }else if(e.target == this.tabEndOuter){ 
     62                                if(this._fromTrap){ 
    6363                                        this.tabEnd.focus(); 
    6464                                        this._fromTrap = false; 
    65                                 } else { 
    66                                         this._fromTrap = true; 
    67                                         this.tabStart.focus(); 
    68                                 } 
    69                         } else if(e.target == this.tabEnd) { 
    70                                 if(this._fromTrap) { 
    71                                         this._fromTrap = false; 
    72                                 } else { 
    73                                         this._fromTrap = true; 
    74                                         this.tabStart.focus(); 
    75                                 } 
    76                         } 
    77                 }, 
    78  
    79                 _clearTrap: function(/*Event*/ e) { 
    80                         // summary 
    81                         //      callback on blur 
    82                         var _this = this; 
    83                         setTimeout(function() { 
    84                                 _this._fromTrap = false; 
    85                         }, 100); 
    86                 }, 
    87  
    88                 _setup: function() { 
    89                         // summary 
    90                         //      stuff we need to do before showing the Dialog for the first time 
    91                         //      (but we defer it until right beforehand, for performance reasons) 
     65                                }else{ 
     66                                        this._fromTrap = true; 
     67                                        this.tabStart.focus(); 
     68                                } 
     69                        }else if(e.target == this.tabEnd){ 
     70                                if(this._fromTrap){ 
     71                                        this._fromTrap = false; 
     72                                }else{ 
     73                                        this._fromTrap = true; 
     74                                        this.tabStart.focus(); 
     75                                } 
     76                        } 
     77                }, 
     78 
     79                _clearTrap: function(/*Event*/ e){ 
     80                        // summary: callback on blur 
     81                        setTimeout(dojo.hitch(this, function(){ 
     82                                this._fromTrap = false; 
     83                        }), 100); 
     84                }, 
     85 
     86                _visibleBgOpacity: 0.4, 
     87 
     88                _setup: function(){ 
     89                        // summary: 
     90                        //              stuff we need to do before showing the Dialog for the first 
     91                        //              time (but we defer it until right beforehand, for 
     92                        //              performance reasons) 
    9293 
    9394                        var b = dojo.body(); 
     
    108109                        this._fadeIn = dojo.fadeIn({ 
    109110                                node: node, 
    110                                 duration: this._duration, 
    111                                 onEnd: dojo.hitch(this, "_showBackground") 
    112                         }); 
     111                                duration: this._duration 
     112                        }).combine([ 
     113                                dojo.animateProperty({ 
     114                                        node: this.bg, 
     115                                        duration: this._duration, 
     116                                        onBegin: dojo.hitch(this, "_showBackground"), 
     117                                        properties: { 
     118                                                opacity: { start: 0, end: this._visibleBgOpacity } 
     119                                        } 
     120                                }) 
     121                        ]); 
     122 
    113123                        this._fadeOut = dojo.fadeOut({ 
    114124                                node: node, 
     
    117127                                        node.style.display="none"; 
    118128                                } 
    119                         }); 
     129                        }).combine([ 
     130                                dojo.fadeOut({ 
     131                                        node: this.bg, 
     132                                        duration: this._duration 
     133                                }) 
     134                        ]); 
    120135                }, 
    121136 
     
    129144                }, 
    130145 
    131                 _sizeBackground: function() { 
     146                _sizeBackground: function(){ 
    132147                        // summary 
    133148                        //              Sets the background to the size of the viewport (rather than the size 
     
    149164                        // by the previous resizing 
    150165                        viewport = dijit.util.getViewport(); 
    151                         if (viewport.w != w) { this.bg.style.width = viewport.w + "px"; } 
    152                         if (viewport.h != h) { this.bg.style.height = viewport.h + "px"; } 
    153                 }, 
    154  
    155                 _showBackground: function() { 
     166                        if(viewport.w != w){ this.bg.style.width = viewport.w + "px"; } 
     167                        if(viewport.h != h){ this.bg.style.height = viewport.h + "px"; } 
     168                }, 
     169 
     170                _showBackground: function(){ 
     171                        console.debug("_showBackground"); 
    156172                        this.bg.style.display = "block"; 
    157173                        if(this.bgIframe.iframe){ 
     
    160176                }, 
    161177 
    162                 _center: function() { 
     178                _center: function(){ 
    163179                        // summary: position modal dialog in center of screen 
    164180 
     
    181197 
    182198                _onKey: function(/*Event*/ evt){ 
    183                         if (evt.keyCode){ 
     199                        if(evt.keyCode){ 
    184200                                // see if the key is for the dialog 
    185201                                var node = evt.target; 
    186202                                while (node != null){ 
    187                                         if (node == this.domNode){ 
     203                                        if(node == this.domNode){ 
    188204                                                return; // yes, so just let it go 
    189205                                        } 
     
    195211                                // opera won't tab to a div 
    196212                                }else if (!dojo.isOpera){ 
    197                                         try { 
     213                                        try{ 
    198214                                                this.tabStart.focus();  
    199                                         } catch(e){} 
    200                                 } 
    201                         } 
    202                 }, 
    203  
    204                 show: function() { 
     215                                        }catch(e){} 
     216                                } 
     217                        } 
     218                }, 
     219 
     220                show: function(){ 
    205221                        // summary: display the dialog 
    206222 
  • dojo/trunk/_base/fx.js

    r8728 r8925  
    214214                combine: function(/*dojo._Animation[]*/ anims){ 
    215215                        dojo.forEach(anims, function(anim){ 
    216                                 dojo.connect(this, "play", anim, "play"); 
     216                                dojo.forEach([  
     217                                        "beforeBegin", "onBegin", "onAnimate", "onEnd",  
     218                                        "onPlay", "onPause", "onStop", "play"  
     219                                ], function(evt){ 
     220                                        if(anim[evt]){ 
     221                                                // if(!this[evt]){ this[evt] = function(){}; } 
     222                                                dojo.connect(this, evt, anim, evt); 
     223                                        } 
     224                                }, this); 
    217225                        }, this); 
    218226                        return this; // dojo._Animation 
     
    339347                                                } 
    340348                                        } 
     349                                        this._percent = 0; 
    341350                                        this.fire("onEnd"); 
    342351                                }