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