jQuery: The Write Less, Do More JavaScript Library

Changeset 5595

Show
Ignore:
Timestamp:
05/14/08 16:42:45 (3 months ago)
Author:
scott.gonzalez
Message:

UI Dialog: Fixed #2857: Changed name of "top" var to prevent problems with frames in old browsers.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/ui.dialog.js

    r5582 r5595  
    178178         
    179179        position: function(pos) { 
    180             var wnd = $(window), doc = $(document), top = doc.scrollTop(), left = doc.scrollLeft(), minTop = top; 
     180            var wnd = $(window), doc = $(document), 
     181                pTop = doc.scrollTop(), pLeft = doc.scrollLeft(), 
     182                minTop = pTop; 
     183             
    181184            if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) { 
    182                 pos = [pos == 'right' || pos == 'left' ? pos : 'center', pos == 'top' || pos == 'bottom' ? pos : 'middle']; 
     185                pos = [ 
     186                    pos == 'right' || pos == 'left' ? pos : 'center', 
     187                    pos == 'top' || pos == 'bottom' ? pos : 'middle' 
     188                ]; 
    183189            } 
    184190            if (pos.constructor != Array) { 
     
    186192            } 
    187193            if (pos[0].constructor == Number) { 
    188                 left += pos[0]; 
     194                pLeft += pos[0]; 
    189195            } else { 
    190196                switch (pos[0]) { 
    191197                    case 'left': 
    192                         left += 0; 
     198                        pLeft += 0; 
    193199                        break; 
    194200                    case 'right': 
    195                         left += (wnd.width()) - (this.uiDialog.width()); 
     201                        pLeft += (wnd.width()) - (this.uiDialog.width()); 
    196202                        break; 
    197203                    case 'center': 
    198204                    default: 
    199                         left += (wnd.width() / 2) - (this.uiDialog.width() / 2); 
     205                        pLeft += (wnd.width() / 2) - (this.uiDialog.width() / 2); 
    200206                } 
    201207            } 
    202208            if (pos[1].constructor == Number) { 
    203                 top += pos[1]; 
     209                pTop += pos[1]; 
    204210            } else { 
    205211                switch (pos[1]) { 
    206212                    case 'top': 
    207                         top += 0; 
     213                        pTop += 0; 
    208214                        break; 
    209215                    case 'bottom': 
    210                         top += (wnd.height()) - (this.uiDialog.height()); 
     216                        pTop += (wnd.height()) - (this.uiDialog.height()); 
    211217                        break; 
    212218                    case 'middle': 
    213219                    default: 
    214                         top += (wnd.height() / 2) - (this.uiDialog.height() / 2); 
     220                        pTop += (wnd.height() / 2) - (this.uiDialog.height() / 2); 
    215221                } 
    216222            } 
    217             top = top < minTop ? minTop : top; 
    218             this.uiDialog.css({top: top, left: left}); 
    219         }, 
    220              
     223             
     224            // prevent the dialog from being too high (make sure the titlebar 
     225            // is accessible) 
     226            pTop = Math.max(pTop, minTop); 
     227            this.uiDialog.css({top: pTop, left: pLeft}); 
     228        }, 
     229         
    221230        open: function() { 
    222231            this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;