View RSS Feed

ddadmin

Dynamically minimizing a DHTML Window

Rating: 6 votes, 2.17 average.
Original Script: DHTML Window

By default the DHTML Window script can only be minimized by clicking on the "minimize" icon located on the upper right of the opened window. Someone asked on the forums if there's a way to do this dynamically, such as via a link instead. Well, certainly. Given the below example DHTML Window:

Code:
var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://images.google.com/", "#1: Google Web site", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")
To dynamically "minimize" it, you can call the internal function:
Code:
dhtmlwindow.minimize(googlewin.controls.firstChild, googlewin)
where "googlewin" in the above case is the variable assigned to the DHTML window when you opened it. The following creates a link that minimizes this window:

Code:
<a href="#" onClick="dhtmlwindow.minimize(googlewin.controls.firstChild, googlewin)">Minimize Window</a>

Submit "Dynamically minimizing a DHTML Window" to del.icio.us Submit "Dynamically minimizing a DHTML Window" to StumbleUpon Submit "Dynamically minimizing a DHTML Window" to Google Submit "Dynamically minimizing a DHTML Window" to Digg

Tags: None Add / Edit Tags
Categories
DD Scripts Mods

Comments

  1. houstonrca's Avatar
    Bug....

    This works fine, however when u hit the maximize value for the window while it is minimized it does not go back to its default window sizes...

    Also, what is the dhtml code for maximizing a window?
    Can I do the same for maximizing a window.

    Thanks,
    Houstonrca
  2. EISD's Avatar
    Code:
    minimize:function(button, t){
        if(t.state!="maximized"){
    	dhtmlwindow.rememberattrs(t)
    	button.setAttribute("src", dhtmlwindow.imagefiles[2])
    	button.setAttribute("title", "Restore")
    	t.state="minimized"
    	t.contentarea.style.display="none"
    	t.statusarea.style.display="none"
    	if (typeof t.minimizeorder=="undefined"){
    	dhtmlwindow.minimizeorder++
    	t.minimizeorder=dhtmlwindow.minimizeorder
    	}
    	t.handle.style.cursor="arrow"
    	t.controls.style.visibility="visible"
    	t.style.width="175px"
    	var windowspacing=t.minimizeorder*183
    	t.style.left=windowspacing-90+"px"
    	t.style.top="3px"
    	t.style.zIndex=3002
    	}	
    },
    
    maximize:function(button, t){
       if(t.state!="minimized"){
    	dhtmlwindow.rememberattrs(t)
    	button.setAttribute("src", dhtmlwindow.imagefiles[2])
    	button.setAttribute("title", "Restore")
    	t.state="maximized"
    	t.contentarea.style.display="block"
    	t.statusarea.style.display="none"
    	t.contentarea.style.height=dhtmlwindow.docheight-t.handle.offsetHeight+"px"
    	t.style.width="100%"
    	t.style.top="30px"
    	t.style.left="-2px"
    	t.controls.style.visibility="visible"
    	}
    },
    
    restore:function(button, t){
        dhtmlwindow.getviewpoint()
    	if(t.state=="maximized"){
    	button.setAttribute("src", dhtmlwindow.imagefiles[3])
    	button.setAttribute("title", "Maximize")
    	t.state="fullview"
    	t.style.display="block"
    	t.contentarea.style.display="block"
    	if (t.resizeBool)
    	t.statusarea.style.display="block"
    	t.style.left=parseInt(t.lastx)+dhtmlwindow.scroll_left+"px"
    	t.style.top=parseInt(t.lasty)+dhtmlwindow.scroll_top+"px"
    	t.style.width=parseInt(t.lastwidth)+"px"
    	t.contentarea.style.height=parseInt(t.lastheight)+"px"
    	t.controls.style.visibility="visible"
    	}
    	else if(t.state=="minimized"){
    	button.setAttribute("src", dhtmlwindow.imagefiles[0])
    	button.setAttribute("title", "Minimize")
    	t.state="fullview"
    	t.style.display="block"
    	t.handle.style.cursor="move"
    	t.contentarea.style.display="block"
    	if (t.resizeBool)
    	t.statusarea.style.display="block"
    	t.style.left=parseInt(t.lastx)+dhtmlwindow.scroll_left+"px"
    	t.style.top=parseInt(t.lasty)+dhtmlwindow.scroll_top+"px"
    	t.style.width=parseInt(t.lastwidth)+"px"
    	t.controls.style.visibility="visible"
    	this.zIndexvalue++
    	t.style.zIndex=this.zIndexvalue
    	}
    },
  3. Maddawg6's Avatar
    So here is an interesting dilemma I am trying to work through with dynamically minimizing. If I have more than 1 dhtml window that I am trying to minimize then every window after the 1st one will minimize and at the very end of loading the page, a script kicks off and moves the minimized windows to their original x,y position. They are all still minimized but not in an orderly fashion in the bottom left of the screen. The only one that remains at the bottom on the screen is the first window that was minimized; and only if it is the first window loaded within your web page.

    I'm trying to figure out how to make all my minimized windows stay nice and orderly at the bottom of my page.

    Any help is most appreciated!