Categories | Question details Back To List | ||
getDimension() returns wrong height getDimension() returns wrong height I am implementing some functionality to implement a windows-style minimize and restore. When they restore the window, I want to not only restore to the previous location, but also to the previous dimensions. I use getDimension() to get the width and height. The width value is correct, but the height value always returns 30. Am i missing something? dhtmlxWindows library v.2.5 build 91111 (Professional Edition) Answer posted by Alex (support) on Jan 23, 2010 03:42 Locally the issue wasn't reproduced. Please provide the complete sample Answer posted by Dan Obregon on Jan 25, 2010 07:53 When you click on the Google menu item, it gives you correct window dimensions. When you click on the park (minimize) link, the width is correct, but the height is 30. The following is the code sample you requested: <html> <head> <title>Test</title> <link rel="stylesheet" type="text/css" href=../dhtmlx.css"> <script src="../dhtmlxLayout/sources/dhtmlxcommon.js"></script> <script src="../dhtmlxLayout/sources/dhtmlxcontainer.js"></script> <script src="../dhtmlxLayout/sources/dhtmlxlayout.js"></script> <script src="../dhtmlx/dhtmlxWindows/sources/dhtmlxwindows.js"></script> <script src="../dhtmlx/dhtmlxMenu/sources/dhtmlxmenu.js"></script> <script src="../dhtmlxMenu/sources/ext/dhtmlxmenu_ext.js"></script> <script language="javascript"> var dhxWins; // The main windows manager var layoutWin; // The main layout window var dhxLayout; // The layout manager var oSB; // The status bar var arrWindowPositions = new Array(); // An array of x,y coordinates for windows before they are minimized var next_min_position_x = 10; // The next available x position to minimize to var next_min_position_y = 0; // The next available y position to minimize to USE_DHTML = true; // Whether or not DHTML is being used var PARK_AMOUNT = 25; // The height of a parked (minimized) window var arrWindows = new Array() // An array of registered windows var WINDOW_ID = 0; // The next available window id var C_MIN_WIDTH = 300; var C_MIN_HEIGHT = 30; // Minimize Action function doMinimizeAction(window_id) { var position = dhxWins.window(window_id).getPosition(); var dimension = dhxWins.window(window_id).getDimension(); alert(dimension[0] + "+" + dimension[1]) // alert(dhxWins.window(window_id).style.height); => 30px // alert(dhxWins.window(window_id).style.height); arrWindowPositions[window_id] = [position[0], position[1], dimension[0], dimension[1] ]; next_min_position_y -= PARK_AMOUNT; dhxWins.window(window_id).setPosition(next_min_position_x,next_min_position_y); dhxWins.window(window_id).setDimension(C_MIN_WIDTH,C_MIN_HEIGHT); } // Restore Action function doRestoreAction (window_id) { var old_position = arrWindowPositions[window_id]; next_min_position_y += PARK_AMOUNT; arrWindowPositions[window_id] = null; dhxWins.window(window_id).setPosition(old_position[0], old_position[1]); dhxWins.window(window_id).setDimension(old_position[2], old_position[3]); } // Resize Action function handleResizeEvent() {dhxLayout.setSizes();} // Status Bar Items function clearStatusBar() {oSB.setText(""); } function getStatusBarText() {return oSB.getText();} function setStatusBarText(sText) {oSB.setText(sText)} // Called by children - unregister the given window function closeWindow(win_id) { if ( dhxWins.isWindow(win_id) ) { unregisterWindow(win_id); dhxWins.window(win_id).close(); } else { var arrIDs = getWindowId(win_id); for ( var i=0; i<arrIDs.length; i++) { if ( dhxWins.window(arrIDs[i]).isParked() ) {next_min_position_y += PARK_AMOUNT;} dhxWins.window(arrIDs[i]).close(); unregisterWindow(arrIDs[i]) } } } // Window registration procs function registerWindow(win_id,win_type) { arrWindows.push({"id":win_id,"type":win_type});} function unregisterWindow(win_id){for (var i=0;i<arrWindows.length;i++) if (arrWindows[i]!=null&&arrWindows[i]['id']==win_id) arrWindows[i]=null;} function getWindowType(win_id) {for (var i=0;i<arrWindows.length;i++) if (arrWindows[i]!=null&&arrWindows[i]['id']==win_id ) return arrWindows[i]['type']; return "";} function getNewWindowId() {var the_new_id = WINDOW_ID;WINDOW_ID++;return the_new_id;} function getWindowId(win_type) {var arrID=new Array(); for (var i=0;i<arrWindows.length;i++) if (arrWindows[i]!= null&&arrWindows[i]['type']==win_type) arrID.push(arrWindows[i]['id']); return arrID;} function initMainMenu(menu) { menu.setIconsPath("/scripts/DHTMLX/imgs/"); menu.addNewSibling(null,"google", "Google", false); menu.attachEvent("onClick", function(id, zoneId, casState) { handleMenuClicks(id, zoneId, casState);}); } function doOnLoad() { // Create the main layout first dhxLayout = new dhtmlXLayoutObject("parentDIV", "1C"); dhxLayout.cells("a").setText("Test"); dhxLayout.setEffect("resize",false); dhxLayout.setEffect("collapse",false); dhxLayout.setEffect("highlight",false); next_min_position_y = dhxLayout.cells("a").getHeight() - 20; // Status bar creation oSB = dhxLayout.attachStatusBar(); // Create the window manager dhxWins = dhxLayout.dhxWins; dhxWins.enableAutoViewport(false); dhxWins.attachViewportTo("parentDIV"); dhxWins.setImagePath("/scripts/DHTMLX/imgs/"); // Create window manager event handlers dhxWins.attachEvent("onClose", function(win) { if ( getWindowType(win.getId()) == "win_models") if ( !handleModelWindowClose(win) ) return false; clearStatusBar(); unregisterWindow(win.getId()); return true; }); dhxWins.attachEvent("onResizeFinish", function(win) { win._frame.contentWindow.handleResizeEvent(); }); dhxWins.attachEvent("onParkUp", function(win){ doMinimizeAction(win.getId());}); dhxWins.attachEvent("onParkDown", function(win){doRestoreAction(win.getId());}); // Create the main menu var menu = dhxLayout.cells("a").attachMenu(); initMainMenu(menu); } function handleMenuClicks(id, zoneId, casState) { var oWin; var maxWidth = dhxLayout.cells("a").getWidth(); var maxHeight = dhxLayout.cells("a").getHeight()-60; var window_id = ""; var window_title = ""; var window_url = ""; var the_window_id = getNewWindowId(); switch(id) { case "google": window_id = "win_google"; window_title = "Google"; window_url = "http://www.google.com"; break; default: alert(id); break; } if (casState["ctrl"] == true) {} if (casState["alt"] == true) {} if (casState["shift"] == true) {} oWin = dhxWins.createWindow(the_window_id, 0, 60, maxWidth, maxHeight); registerWindow(the_window_id,window_id); oWin.setText(window_title); oWin.button("minmax1").hide(); oWin.button("minmax2").hide(); oWin.attachURL(window_url); var dimensions = oWin.getDimension(); alert(dimensions[0] +"x"+ dimensions[1]); } </script> </head> <body onLoad="doOnLoad();" onResize="handleResizeEvent();"> <div id="parentDIV" style="position:relative;height:98%;border:1px #cecece solid;margin:3px;"> </div> </body></html> Answer posted by Alex (support) on Jan 26, 2010 03:48 >> When you click on the park (minimize) link, the width is correct, but the height is 30. But the window height is 30 after the park method is called. This behavior is correct. PS: Please ask questions on our forum http://forum.dhtmlx.com/ |