Adding A Minimize Button To Your CFWindow

Here's a quick example of how to add a functional minimize button to your CFWindow.

<script>
createWin = function(){
ColdFusion.Window.create('Window1', 'This is a CF window','win.cfm',{x:100,y:100,height:300,width:400,modal:false,closable:true,collapsible:true,draggable:true,resizable:true,center:true,initshow:true})
//get the Ext window object
var w = ColdFusion.Window.getWindowObject('Window1');
//add the class for the collapse button
w.collapseBtn = w.toolbox.createChild({cls:"x-dlg-collapse"});
//add a listener for the collapse click
w.collapseBtn.on("click", w.collapseClick, w);
//add the class to swap the image on mouse over
w.collapseBtn.addClassOnOver("x-dlg-collapse-over");
}

</script>

<cfset ajaxOnLoad('createWin') />

Demo



Comments
Nice. I like the skin job you did to the cfwindow. Care to elaborate on that aspect of it?
# Posted By Jason | 2/13/08 3:32 PM
How do you change the style of the window? Your's is a nice blue and I have an ugly teal/whatever color.
# Posted By spiraldev | 2/13/08 3:36 PM
# Posted By todd sharp | 2/13/08 4:00 PM
So '.collapseClick' is a built-in method of ColdFusion Windows, eh? Is this documented somewhere on Adobe's site, or in Ext?
# Posted By Tom Mollerus | 2/13/08 4:16 PM
Well CF exposes certain things via tag attributes/JS config options - the collapsible option was *not* exposed by them for whatever reason. However, tapping into the underlying Ext.BasicDialog object allowed me to add the functionality. Essentially anything you can do with an Ext object you can do by tapping into the CF exposed object.

Make sense?
# Posted By todd sharp | 2/13/08 4:21 PM
Very cool. Can it minimize to the bottom left of the browser window?
# Posted By Sam Farmer | 2/13/08 6:55 PM
How bout this Sam: Add another click listener, if the current state is collapsed move the window to wherever:

createWin = function(){
ColdFusion.Window.create('Window1', 'This is a CF window','win.cfm',{x:100,y:100,height:300,width:400,modal:false,closable:true,collapsible:true,draggable:true,resizable:true,center:true,initshow:true})
//get the Ext window object
   var w = ColdFusion.Window.getWindowObject('Window1');
   //add the class for the collapse button
   w.collapseBtn = w.toolbox.createChild({cls:"x-dlg-collapse"});
   //add a listener for the collapse click
w.collapseBtn.on("click", w.collapseClick, w);
w.collapseBtn.on("click", moveWin, w);
//add the class to swap the image on mouse over
w.collapseBtn.addClassOnOver("x-dlg-collapse-over");
}

moveWin = function(){
   var win = ColdFusion.Window.getWindowObject('Window1');
   if(win.collapsed){
      win.moveTo(10,10);
   }   
}
# Posted By todd sharp | 2/14/08 10:25 AM
Even cooler:

createWin = function(){
ColdFusion.Window.create('Window1', 'This is a CF window','win.cfm',{x:100,y:100,height:300,width:400,modal:false,closable:true,collapsible:true,draggable:true,resizable:true,center:true,initshow:true})
//get the Ext window object
   var w = ColdFusion.Window.getWindowObject('Window1');
   //add the class for the collapse button
   w.collapseBtn = w.toolbox.createChild({cls:"x-dlg-collapse"});
   //add a listener for the collapse click
w.collapseBtn.on("click", w.collapseClick, w);
w.collapseBtn.on("click", moveWin, w);
//add the class to swap the image on mouse over
w.collapseBtn.addClassOnOver("x-dlg-collapse-over");
}

moveWin = function(){
   var win = ColdFusion.Window.getWindowObject('Window1');
   var e = win.getEl();
   var s = win.shadow.el;

   if(win.collapsed){
      e.alignTo(document, "bl", [0,-30], true);
      s.alignTo(document, "bl", [0,-30], true);
   }   
}

This will animate the window to minimize to the bottom left.
# Posted By todd sharp | 2/14/08 11:20 AM
This is very neat. However, the x and y coordinates are not working for me nor is the CSS file. I've tried both IE7 and FF2, also, have tried to initialize the two functions via cfajaxload and on adajaxload and the other with BODY onload to no avail. Any idea?

Thanks.

Don
# Posted By Don Li | 2/17/08 11:29 PM
Nice one.
# Posted By Jackie | 5/23/08 2:09 PM

Calendar

Sun Mon Tue Wed Thu Fri Sat
   1234
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Subscribe

Enter your email address to subscribe to this blog.

Tags

actionscript ajax blogging cfsnippets coldfusion flash forms flex funny stuff javascript misc model-glue off topic personal project learn slidesix sql

Recent Comments

Adding Auto Generated Code Downloads to BlogCFC
ada5fsa said: http://www.ibiblio.org/st... http://www.ncaonline.org/...... [More]

Chinese Birth Calendar Accuracy Test
mama to be said: ok so i will be 2 months shy of 18 when i have my baby. this calendar does not technically work for ... [More]

Fixing 'User Profile Service Failed The Logon' on Vista
Mike said: That fix worked although all i did was remove .bak and reset state to 0. User was able to log in to... [More]

Chinese Birth Calendar Accuracy Test
Melissa said: Wrong for my daughter, which it predicted to be a boy... we'll see for #2. Predicts a girl (maybe, f... [More]

Adding Auto Generated Code Downloads to BlogCFC
fweerw said: http://www.ibiblio.org/st... http://www.cambodia.ait.a...... [More]

RSS


adobe community experts

coldfusionbloggers

FullAsAGoog MXNA

Consumed By Feed-Squirrel.com