1
|
package eu.dnetlib.client;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.Modal;
|
4
|
import com.github.gwtbootstrap.client.ui.constants.BackdropType;
|
5
|
import com.google.gwt.core.client.GWT;
|
6
|
import com.google.gwt.dom.client.Document;
|
7
|
import com.google.gwt.dom.client.Style;
|
8
|
import com.google.gwt.query.client.Function;
|
9
|
import com.google.gwt.user.client.Event;
|
10
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
11
|
import com.google.gwt.user.client.ui.HTML;
|
12
|
import com.google.gwt.user.client.ui.RootPanel;
|
13
|
import eu.dnetlib.goldoa.domain.Help;
|
14
|
|
15
|
import static com.google.gwt.query.client.GQuery.$;
|
16
|
|
17
|
/**
|
18
|
* Created by stefania on 4/17/15.
|
19
|
*/
|
20
|
public abstract class MyWidgetHelper {
|
21
|
|
22
|
private static DataServiceAsync dataService = GWT.create(DataService.class);
|
23
|
|
24
|
public static void loadHelp(final SidebarPanel sidebarPanel, final String helpId) {
|
25
|
|
26
|
dataService.getHelpById(helpId, new AsyncCallback<Help>() {
|
27
|
|
28
|
@Override
|
29
|
public void onFailure(Throwable throwable) {
|
30
|
|
31
|
}
|
32
|
|
33
|
@Override
|
34
|
public void onSuccess(Help help) {
|
35
|
|
36
|
if(help!=null) {
|
37
|
|
38
|
HTML html = new HTML();
|
39
|
html.setHTML(help.getText());
|
40
|
|
41
|
sidebarPanel.clearContent();
|
42
|
sidebarPanel.addContent(html);
|
43
|
|
44
|
MyWidgetHelper.showSidebar();
|
45
|
RootPanel.get("sidebar").add(sidebarPanel.asWidget());
|
46
|
|
47
|
$(".contactUs").click(new Function() {
|
48
|
|
49
|
public boolean f(Event e) {
|
50
|
|
51
|
final Modal contactUsModal = new Modal();
|
52
|
|
53
|
contactUsModal.addStyleName("contactModal");
|
54
|
contactUsModal.setTitle("Contact Us");
|
55
|
contactUsModal.setAnimation(true);
|
56
|
contactUsModal.setBackdrop(BackdropType.STATIC);
|
57
|
contactUsModal.setDynamicSafe(true);
|
58
|
|
59
|
ContactForm contactForm = new ContactForm();
|
60
|
ContactForm.ContactSubmittedListener contactSubmittedListener = new ContactForm.ContactSubmittedListener() {
|
61
|
@Override
|
62
|
public void contactSubmitted() {
|
63
|
contactUsModal.hide();
|
64
|
}
|
65
|
};
|
66
|
contactForm.setContactSubmittedListener(contactSubmittedListener);
|
67
|
|
68
|
contactUsModal.add(contactForm.asWidget());
|
69
|
|
70
|
contactUsModal.show();
|
71
|
|
72
|
return true;
|
73
|
}
|
74
|
});
|
75
|
}
|
76
|
}
|
77
|
});
|
78
|
}
|
79
|
|
80
|
public static void showSidebar() {
|
81
|
|
82
|
Document.get().getElementById("content").removeClassName("uk-width-medium-1-1");
|
83
|
Document.get().getElementById("content").addClassName("uk-width-medium-3-4");
|
84
|
Document.get().getElementById("sidebar").getStyle().setDisplay(Style.Display.BLOCK);
|
85
|
}
|
86
|
|
87
|
public static void hideSidebar() {
|
88
|
|
89
|
Document.get().getElementById("content").removeClassName("uk-width-medium-3-4");
|
90
|
Document.get().getElementById("content").addClassName("uk-width-medium-1-1");
|
91
|
Document.get().getElementById("sidebar").getStyle().setDisplay(Style.Display.NONE);
|
92
|
}
|
93
|
}
|