From: Rob H. <ro...@na...> - 2002-03-01 08:25:45
|
Hello, I implemented a very rough version of pop-up dialogs and output for the vcs/file toolbar, I think there are alot of approaches we can take but here is what seemed to be the best to me ( currently it only works in the browse_module_menu, but you'll see how easy it is to do your own popups ) : To start with, we need to give the current window a name : window.name = "mainWindow"; This is so the popup will know how to submit back to us. Next, we define a function that opens a pop-up window ( to save typing all that stuff out all the time ) : function myOpenWindow() { window.open('about:blank','popUp','width=400,height=400'); } This creates a popup window named "popUp", initially it'll be blank. I modified browse_module_header's <form> tag to open this window and use it for the target of any submits that come from this form : <form method="get" submit="<TMPL_VAR NAME=PROGNAME>" name="browse" onsubmit="myOpenWindow()" target="popUp"> So, when the form is submitted the myOpenWindow function is called, opening a window named popUp, which received the form submit ( because it's the target ). I created a new public method in SandWeb::UI called print_popup. It is basically the same as print_screen, but does not call the footer or menu_bar ( hey nick, framework looks wierd without footer or menu_bar, it looks like it has stuff to support it coded directly in framework.html Is this on purpose? ). There's no reason for users to get a menu_bar inside a popup dialog, so you use the print_popup in place of print_screen in the CGI for any menu that should be in a popup. This doesn't actually have anything to do with the generation of the popup window per se, but it produces format suitable for a popup dialog. The final thing to do is modify the template of the command that is being put in the popup window to do this : <form action="<TMPL_VAR NAME=PROGNAME>" target="mainWindow" onsubmit="setTimeout('window.close()',2000)"> This is in create_file.html, what it means is that is will submit to mainWindow ( this is what we named the browse_module window, remember? ) and wait 2000 ms to close the window ( if we close right away, there isn't time to submit to mainWindow ). That's it! Problems so far : * delete_file doesn't work as you might expect it to, it needs a menu to give us output in a popup * I could leave delete_file alone actually, but that would require figuring out if it is possible to do this stuff on a per-<input> basis, I only discovered how to do this on a per-<form> basis * vcs_output is in a pop-up, which is cool, but I haven't figured out a good strategy for refreshing mainWindow yet. I think it could be done when the popup window containing vcs_output is closed by the user, but I'm not positive. Right now you have to click reload if you want to see the results of a VCS command * I have barely tested this, please let me know what else is wrong that I've missed :) I know that this will break some of the VCS command templates, I'll try to commit those in the next couple minutes before I go to sleep. -- Rob |