*
* @param window the new window (not null)
* @return the component id of the new window (used to remove it)
*/
public String addWindow(final IYuiWindow window) {
YuiPanel yuiPanel = new YuiPanel(getRepeater().newChildId()) {
@Override
protected String getOpts() {
return newOptions(window.getDimension(), window.getAdditionalOpts());
}
@Override
protected String getResizeOpts() {
return "{handles : ['br'], proxy: true, status: true, animate: false}";
}
@Override
protected Component newBodyPanel(String id) {
return window.newBody(id);
}
@Override
protected Component newFooterPanel(String id) {
return window.newFooter(id);
}
@Override
protected Component newHeaderPanel(String id) {
return window.newHeader(id);
}
@Override
protected void onHide(AjaxRequestTarget target, String type) {
getRepeater().remove(this);
removeElementFromDom(target, getMarkupId());
}
};
yuiPanel.setOutputMarkupId(true);
yuiPanel.setUsesOverlayManager(true);
getRepeater().add(yuiPanel);
AjaxRequestTarget target = AjaxRequestTarget.get();
if (target != null) {
String createDiv = "(function(){var c=document.createElement('div');c.id='%s';Wicket.$('%s').appendChild(c)})();";
target.prependJavascript(String.format(createDiv, yuiPanel.getMarkupId(), getMarkupId()));
target.addComponent(yuiPanel);
// TODO: find out why javascript of yuiPanel's header contributor
// fails during the AJAX update in FireFox, works fine in IE.
}
return yuiPanel.getId();
}