PDA

View Full Version : Windows Widget minimize function



Maddawg6
05-10-2010, 10:09 PM
1) Script Title: Script: DHTML Window widget
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

3) Describe problem: I have searched the forums but have not found what I'm looking for. Is there a method in which I can open a dhtmlwindow but then immediately minimize it? I've tried following the code but cannot get the correct parameters to pass to make this happen.

In the end, I would like to load several dhtmwindows as a user front page and if they minimize, I want to capture that and load it like that the next time they refresh or visit the home page. If I can manipulate the minimize function then I can insert the value into a PHP variable and use that when the user comes back to the page.

Any help is appreciated.

ddadmin
05-11-2010, 07:25 PM
Have you checked out this blog post: http://www.dynamicdrive.com/forums/blog.php?b=31 ?

Maddawg6
05-12-2010, 06:17 PM
YES! I searched and searched but couldn't find that one post I so needed. Thanks much for pointing me in the right direction!

I'm off and running. Thanks again for the great work that this site provides!

Maddawg6
05-14-2010, 03:04 PM
OK, so that started me down another path. Now that I know how to call up the minimize function, there is an issue when calling it multiple times.

The example is:

dhtmlwindow.minimize(googlewin.controls.firstChild, googlewin)

The problem is that multiple dhtml windows will minimize but they minimize in their associated x,y position rather than nicely stacked in the lower left. When the page loads they all appear in the lower left but at the end they move. The only one that will stay minimized in the lower left is the first one loaded within the web page.

I've already been able to modify the script within other posts to help with maximizing so if you have any thoughts on this minimize issue throw them out there please and maybe that will help trigger something towards a solution.

THANKS!

ddadmin
05-14-2010, 09:12 PM
Ah yes I see it. The issue occurs because the minimized function is called "too early", before certain calculations have been completed yet. One workaround is to call the function after the page has loaded. The caveat is that each DHTML window may appear briefly on the page before it disappears.

To call the minimize function when the page has loaded, wrap the original function with the code in red:


dhtmlwindow.addEvent(window, function(){dhtmlwindow.minimize(googlewin.controls.firstChild, googlewin)}, "load")

Maddawg6
05-14-2010, 10:21 PM
Hmmm, so I tried this. I commented out the old and put this new code right under it. Same issue. So then I started thinking about what you said in that not everything is loading so I placed this new code as the last piece of code in the same web page. Nada.

So is your assumption that this new code calls the event after the page has loaded? Any other suggestions?

ddadmin
05-15-2010, 12:45 AM
It should work- I tried it on the DHTML windows in demo.htm (file you downloaded as part of the zip). Do the windows minimize for you, just still in the wrong place? A link to the problem page would help.

Maddawg6
05-17-2010, 02:02 PM
It only works in your example because it is the first dhtml window loaded. The "effect" I'm referencing only happens when trying to minimize multiple dhtml windows. Try this minimize code for both the 1st and 2nd dhtml example windows and you'll see the 2nd window load, minimize and then move the minimized window to its first loaded position. The 2nd minimized window will not stay nicely stacked in the lower left of the screen...

Also, unfortunately I cannot provide a link because what I am working on is an internal site... it is also sensitive in nature thus I cannot post code snipets from my work... sorry...

ddadmin
05-18-2010, 10:02 AM
Ah yes you're right. Time for a new approach. Try the modified .js file instead, which builds this feature in. Then, to have a DHTML window initially minimized, just define the attribute in red below when opening a window:


var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://images.google.com/", "#1: Google Web site", "width=590px,height=350px,resize=1,scrolling=1,center=1,minimize=1", "recal")

p.s: You should remove the code I posted earlier above to minimize a window, as it's not longer needed:


dhtmlwindow.addEvent(window, function(){dhtmlwindow.minimize(googlewin.controls.firstChild, googlewin)}, "load")

Maddawg6
05-18-2010, 03:33 PM
That is the solution! THANKS!

I also needed the maximize feature to work so I've uploaded the js file I've been working on so this now includes the ability to minimize a dhtml window upon loading along with the ability to maximize.

On another note, I am now trying to get this script to use the Maximize button while a window is in a minimized state, and use the Minimize button while a window is in a maximized state.



3313