Bug Tracker

Changeset 5379

Show
Ignore:
Timestamp:
05/02/08 14:28:31 (7 months ago)
Author:
rdworth
Message:

UI Dialog - Reimplemented [5327] with a minor fix, and added test cases.

Location:
trunk/ui
Files:
2 modified

Legend:

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

    r5027 r5379  
    6060                    "Array-300-80" : "$('#foo').dialog({\n\t position: [300, 80] \n});", 
    6161                    "Array-80-300" : "$('#foo').dialog({\n\t position: [80, 300] \n});", 
     62                    "Array-left-50" : "$('#foo').dialog({\n\t position: ['left', 50] \n});", 
     63                    "Array-right-bottom" : "$('#foo').dialog({\n\t position: ['right', 'bottom'] \n});", 
     64                    "Array-80-middle" : "$('#foo').dialog({\n\t position: [80, 'middle'] \n});", 
     65                    "Array-foo-top" : "$('#foo').dialog({\n\t position: ['foo', 'top'] \n});", 
     66                    "Array-100-foo" : "$('#foo').dialog({\n\t position: [100, 'foo'] \n});", 
    6267                    "foo" : "$('#foo').dialog({\n\t position: 'foo' \n});" 
    6368                }, 
  • trunk/ui/ui.dialog.js

    r5376 r5379  
    207207            if (pos.constructor == Array) { 
    208208                // [x, y] 
    209                 top += pos[1]; 
    210                 left += pos[0]; 
     209                if (pos[0].constructor == Number) { 
     210                    left += pos[0]; 
     211                } else { 
     212                    switch (pos[0]) { 
     213                        case 'center': 
     214                            left += (wnd.width() / 2) - (uiDialog.width() / 2); 
     215                            break; 
     216                        case 'left': 
     217                            left += 0; 
     218                            break; 
     219                        case 'right': 
     220                            left += (wnd.width()) - (uiDialog.width()); 
     221                            break; 
     222                        default: 
     223                            //center 
     224                            left += (wnd.width() / 2) - (uiDialog.width() / 2); 
     225                    } 
     226                } 
     227                if (pos[1].constructor == Number) { 
     228                    top += pos[1]; 
     229                } else { 
     230                    switch (pos[1]) { 
     231                        case 'middle': 
     232                            top += (wnd.height() / 2) - (uiDialog.height() / 2); 
     233                            break; 
     234                        case 'top': 
     235                            top += 0; 
     236                            break; 
     237                        case 'bottom': 
     238                            top += (wnd.height()) - (uiDialog.height()); 
     239                            break; 
     240                        default: 
     241                            //middle 
     242                            top += (wnd.height() / 2) - (uiDialog.height() / 2); 
     243                    } 
     244                } 
    211245            } else { 
    212246                switch (pos) {