aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2008-04-23 09:09:53 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2008-04-23 09:09:53 +0000
commit171a5a7840cdb3fc38bea5a36c7c17951c74c27d (patch)
tree2b46d66285a5231de2f0d1aac812160417b8368e /src
parent5c6735e405c95ae44101538a3cc7f8d4a5488efc (diff)
downloadvaadin-framework-171a5a7840cdb3fc38bea5a36c7c17951c74c27d.tar.gz
vaadin-framework-171a5a7840cdb3fc38bea5a36c7c17951c74c27d.zip
ApplicationConnection now loads theme css
svn changeset:4206/svn branch:trunk
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java25
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java17
2 files changed, 25 insertions, 17 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
index 1b8f0f0b31..8a9380ff5a 100755
--- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
@@ -97,6 +97,10 @@ public class ApplicationConnection {
this.widgetSet = widgetSet;
configuration = cnf;
+ if (cnf.getThemeUri() != null) {
+ injectCss(cnf.getThemeUri() + "/styles.css");
+ }
+
if (isDebugMode()) {
console = new DebugConsole(this);
} else {
@@ -127,6 +131,27 @@ public class ApplicationConnection {
}
/**
+ * Injects CSS to head element
+ *
+ * TODO since gwt 1.5 this can be made non-native
+ *
+ * @param css
+ */
+ private native static void injectCss(String cssUri)
+ /*-{
+
+ if(!$wnd.itmill.themesLoaded[cssUri]) {
+ var stylesheet = $doc.createElement('link');
+ stylesheet.setAttribute('rel', 'stylesheet');
+ stylesheet.setAttribute('type', 'text/css');
+ stylesheet.setAttribute('href', cssUri);
+ var h = $doc.getElementsByTagName("head")[0];
+ h.appendChild(stylesheet);
+ $wnd.itmill.themesLoaded[cssUri] = true;
+ }
+ }-*/;
+
+ /**
* Method to check if application is in testing mode. Can be used after
* application init.
*
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
index f1cfcd90ef..af972ca82c 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
@@ -798,23 +798,6 @@ public class ApplicationServlet extends HttpServlet {
}
page.write("};\n//]]>\n</script>\n");
- if (themeName != null) {
- // Custom theme's stylesheet, load only once, in different script
- // tag to be dominate styles injected by widget
- // set
- page.write("<script type=\"text/javascript\">\n");
- page.write("//<![CDATA[\n");
- page.write("if(!itmill.themesLoaded['" + themeName + "']) {\n");
- page.write("var stylesheet = document.createElement('link');\n");
- page.write("stylesheet.setAttribute('rel', 'stylesheet');\n");
- page.write("stylesheet.setAttribute('type', 'text/css');\n");
- page.write("stylesheet.setAttribute('href', '" + themeUri
- + "/styles.css');\n");
- page.write("document.body.appendChild(stylesheet);\n");
- page.write("itmill.themesLoaded['" + themeName + "'] = true;\n}\n");
- page.write("//]]>\n</script>\n");
- }
-
page.write("<div id=\"" + appId + "\" class=\"i-app\"></div>\n");
if (!fragment) {