diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java | 25 | ||||
-rw-r--r-- | src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java | 17 |
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) { |