Bug fix for dygraph point selection touch event.
[dygraphs.git] / gwt / org / danvk / Dygraphs.java
CommitLineData
71ac4733
AV
1package org.danvk;
2
3import com.google.gwt.core.client.GWT;
4import com.google.gwt.dom.client.Document;
5import com.google.gwt.dom.client.ScriptElement;
6import com.google.gwt.resources.client.ClientBundle;
7import com.google.gwt.resources.client.TextResource;
8
9/**
10 * Methods for installing Dygraphs source in a GWT document.
11 *
12 * @author flooey@google.com (Adam Vartanian)
13 */
14public class Dygraphs {
15
16 // Protected because the GWT compiler has to generate a subclass.
17 protected interface Resources extends ClientBundle {
fd6b8dad 18 @Source("org/danvk/dygraph.min.js")
71ac4733
AV
19 TextResource dygraphs();
20 }
21
22 private static final Resources RESOURCES = GWT.create(Resources.class);
23 private static boolean installed = false;
24
25 /**
26 * Install the Dygraphs JavaScript source into the current document. This
27 * method is idempotent.
28 */
29 public static synchronized void install() {
30 if (!installed) {
31 ScriptElement e = Document.get().createScriptElement();
32 e.setText(RESOURCES.dygraphs().getText());
33 Document.get().getBody().appendChild(e);
34 installed = true;
35 }
36 }
37
38 // Prevent construction
39 private Dygraphs() { }
40
41}