PDA

View Full Version : DHTML Window Widget - enablecontrols



c1lonewolf
02-21-2012, 06:35 PM
dhtmlwindow (http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm)

I need to find out how to fix the button controls. I added a maximize function.

normal display window:
'minimize <> restore' - correct

'maximized' display window:
'maximize <> restore' - correct

how to put this...
when maxed button 'max' button should display 'restore' which is correct, but when maxed window is minimized 'max butt' should display 'max' && 'min button' should display 'restore'. When minimized window is restored to maximum, min button should return to 'min' && 'max' should return to 'restore'

Question how to access and chage the image/title of another button when function only allows funxtion(button,t) ???

ddadmin
02-21-2012, 09:30 PM
Regarding the maximize question, firstly, you may wish to read this thread (http://www.dynamicdrive.com/forums/showthread.php?t=37670), which contains some useful info on adding a maximize button to your DHTML window. With that said, are you looking to simply embed an extra control that apart from maximizes a window, also restores it (while changing the button's src to match)?

c1lonewolf
02-22-2012, 07:02 PM
Thanks for the updates DDAdmin...I'll check em out.
I have resolved all opertions including the control button changes. There are more modifications I have to make as far a resizing. Plus I've had to modifiy the t.state to work better with the new max, min and restore functions.

I do have one other question, I might find it in the script itself...
I need to get access to only the images within the control container how do I do that. Right now I get all images within the window. This could cause unforseen problem when using div or code input elements within the window.

Anyway thanks for the help.

c1lonewolf
02-23-2012, 02:37 PM
DDAdmin here are the codes for the button dynamics to use with maximize option...

//--- replaces (t.state) in init function ---//
t.previousState="normal"
t.currentState="normal"
//-----------------------------------------------//



enablecontrols:function(e){
var d=dhtmlwindow
var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
d.minimize(sourceobj, this._parent)
else if (/Maximize/i.test(sourceobj.getAttribute("title"))) //if this is the "maximize" control
d.maximize(sourceobj, this._parent)
else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
d.restore(sourceobj, this._parent)
else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
d.close(this._parent)
return false
},

minimize:function(button,t){
dhtmlwindow.rememberattrs(t)

/*--- [(Button Dynamics) Edited By: DH Creation Station - 2012.02.11 - DO NOT EDIT!] -----*/
var buttons=t.controls.getElementsByTagName("img")
if(t.currentState=='maximize' && t.previousState=='normal'){
t.previousState='maximize'
t.currentState='minimize'
for (var cs=0; cs<buttons.length; cs++){
if (/Restore/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[5])
buttons[cs].setAttribute("title", "Maximize")
}
if (/Minimize/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[3])
buttons[cs].setAttribute("title", "Restore")
}
}
}

if(t.currentState=='normal' && t.previousState=='normal'){
t.previousState='normal'
t.currentState='minimize'
for (var cs=0; cs<buttons.length; cs++){
if (/Minimize/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[3])
buttons[cs].setAttribute("title", "Restore")
}
}
}
/*----------------------------------------------------------------------------------------*/
//--- minimize coding goes here ---//
},

maximize:function(button,t){
dhtmlwindow.rememberattrs(t)

/*--- [(Button Dynamics) Edited By: DH Creation Station - 2012.02.11 - DO NOT EDIT!] -----*/
var buttons=t.controls.getElementsByTagName("img")
if(t.currentState=='minimize' && t.previousState=='maximize'){
t.previousState='normal'
t.currentState='maximize'
for (var cs=0; cs<buttons.length; cs++){
if (/Restore/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[4])
buttons[cs].setAttribute("title", "Minimize")
}
if (/Maximize/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[3])
buttons[cs].setAttribute("title", "Restore")
}
}
}

if(t.currentState=='normal' && t.previousState=='normal'){
t.previousState='normal'
t.currentState='maximize'
for (var cs=0; cs<buttons.length; cs++){
if (/Maximize/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[3])
buttons[cs].setAttribute("title", "Restore")
}
}
}

if(t.currentState=='minimize' && t.previousState=='normal'){
t.previousState='normal'
t.currentState='maximize'
for (var cs=0; cs<buttons.length; cs++){
if (/Restore/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[4])
buttons[cs].setAttribute("title", "Minimize")
}
if (/Maximize/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[3])
buttons[cs].setAttribute("title", "Restore")
}
}
}
/*----------------------------------------------------------------------------------------*/
//--- maximize coding goes here ---//
},

restore:function(button,t){
dhtmlwindow.getviewpoint()

/*--- [(Button Dynamics) Edited By: DH Creation Station - 2012.02.11 - DO NOT EDIT!] -----*/
var buttons=t.controls.getElementsByTagName("img")
if(t.currentState=='maximize' && t.previousState=='normal'){
t.previousState='normal'
t.currentState='normal'
//alert( t.previousState +'\n\n'+ t.currentState);
for (var cs=0; cs<buttons.length; cs++){
if (/Restore/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[5])
buttons[cs].setAttribute("title", "Maximize")
}
}
}

if(t.currentState=='minimize' && t.previousState=='maximize'){
t.previousState='normal'
t.currentState='maximize'
for (var cs=0; cs<buttons.length; cs++){
if (/Restore/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[4])
buttons[cs].setAttribute("title", "Minimize")
}
if (/Maximize/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[3])
buttons[cs].setAttribute("title", "Restore")
}
}
}

if(t.currentState=='minimize' && t.previousState=='normal'){
t.previouseState='normal'
t.currentState='normal'

for (var cs=0; cs<buttons.length; cs++){
if (/Restore/i.test(buttons[cs].getAttribute("title"))){
buttons[cs].setAttribute("src", dhtmlwindow.imagefiles[4])
buttons[cs].setAttribute("title", "Minimize")
}
}
}
/*----------------------------------------------------------------------------------------*/
//--- restore coding goes here ---//
},


don't forget to change 'dhtmlwindow.imagefiles ' to match your images array that's the only editing that needs to be done within the markers. How you work your maximize and normal functions are up to you!! :)