return false;
};
};
// tabs init with a custom tab template and an "add" callback filling in the content
final Tabs tabs = $("#tabs").as(Ui).tabs( //
Tabs.Options.create().tabTemplate("<li><a href=\"#{href}\">#{label}</a> <span class=\"ui-icon ui-icon-close\">Remove Tab</span></li>")) //
.bind(Tabs.Event.add, new Function() {
@Override
public boolean f(Event e, Object data) {
final Tabs.Event event = ((JavaScriptObject) data).cast();
String tab_content = tab_content_input.val();
if(tab_content == null || tab_content.isEmpty()) {
tab_content = "Tab " + tab_counter + " content.";
}
$(event.panel()).append("<p>" + tab_content + "</p>");
// close icon: removing the tab on click
// note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
$("span.ui-icon-close", event.tab().getParentElement()).click(removeTab);
return false;
}
});
$("#tabs span.ui-icon-close").click(removeTab);
final Function addTab = new Function() {
@Override
public void f(Element e) {
String tab_title = tab_title_input.val();
if(tab_title == null || tab_title.isEmpty()) {
tab_title = "Tab " + tab_counter;
}
tabs.add("#tabs-" + tab_counter, tab_title);
tab_counter++;
}
};
// modal dialog init: custom buttons and a "close" callback reseting the form inside