Hm, this from something I did (uses jquery):

public class ModalDialogPanel extends ModalWindow {
        ...
        public enum Position {
                TR, TL, BR, BL
        }

        ...

        /**
         * @param target
         * @param component Element to use for position of popup.
         */
        public void open(AjaxRequestTarget target, Component component) {
                open(target, component, Position.TL);
        }

        public void open(AjaxRequestTarget target, Component component, 
Position position) {
                open(target);
                String left = "", top = "";
                switch (position) {
                case TL:
                        left = "pos.left";
                        top = "pos.top + ch/2";
                        break;
                case TR:
                        left = "pos.left - ow + cw";
                        top = "pos.top + ch/2";
                        break;
                case BL:
                        left = "pos.left";
                        top = "pos.top + ch/2 - oh";
                        break;
                case BR:
                        left = "pos.left - ow + cw";
                        top = "pos.top + ch/2 - oh";
                        break;
                }
                
                
                target.appendJavaScript(
                        "(" + $f(
                          "var pos = " + $(component).offset(),
                          "var ch = " + $(component).outerHeight(),
                          "var cw = " + $(component).outerWidth(),
                          "var width = $(window).width()",
                          "var height = $(window).height()",
                          "var w = Wicket.Window.get();",
                          "var ow = w.window.offsetWidth",
                          "var oh = w.window.offsetHeight",
                          "var left = " + left,
                          "var top = " + top,
                          "left = Math.max(0,Math.min(left,width-ow))",
                          "top = Math.max(0,Math.min(top,height-oh))",
                  "w.window.style.left=left+'px';",
                  "w.window.style.top=top+'px';"
                  )+")();");
    }
}

-----Original Message-----
From: Wujek Srujek [mailto:wujek.sru...@gmail.com] 
Sent: Friday, October 12, 2012 8:56 AM
To: users@wicket.apache.org
Subject: ModalDialog - control the location

Hi. We have the requirement that we need to show more than one popup at a
time - this means buttons / links in a popup trigger showing other popups
(whether it's good style or not is irrelevant, this is a requirement...).
We are using ModalWindow for that, and it is always shown in the center of
the screen. What we would like to have is to be able to 'stack' windows,
where the new one is shown +20 from the top and +20 to the right from the
top one:
 ________
| ________|_
| |                  |
| |                  |
| |                  |
  |_________|

My idea is to override the center method in a way that:
1. introduces a counter of the windows
2. calls the original method
3. retrieves the top and and left styles, parses them into an integer
4. top = top + counter * 20; left = left + counter * 20
5. sets the style to these new values

As I have very, very little knowledge of javascript, I'm failing to
implement that. Could I get some help from you? Namely, I have trouble
getting accessing the modal window, and its current styles.

Regards,
wujek


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to