]> source.dussan.org Git - vaadin-framework.git/commitdiff
injecting theme stylesheets a node later for better inheritance hierarchy
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 17 Apr 2008 14:51:55 +0000 (14:51 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 17 Apr 2008 14:51:55 +0000 (14:51 +0000)
svn changeset:4195/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java

index 0f6bb18c41d01e49c73d101766820703eee0b54d..f1cfcd90ef2c2d398090f171d488cfa51b4fbac0 100644 (file)
@@ -783,18 +783,6 @@ public class ApplicationServlet extends HttpServlet {
         page.write("document.write(\"<script language='javascript' src='"
                 + staticFilePath + "/" + WIDGETSET_DIRECTORY_PATH + widgetset
                 + "/" + widgetset + ".nocache.js'><\\/script>\");\n}\n");
-        if (themeName != null) {
-            // Custom theme's stylesheet, load only once
-            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.getElementsByTagName(\"head\")"
-                    + "[0].appendChild(stylesheet);\n");
-            page.write("itmill.themesLoaded['" + themeName + "'] = true;\n}\n");
-        }
 
         page.write("itmill.toolkitConfigurations[\"" + appId + "\"] = {");
         page.write("appUri:'" + appUrl + "', ");
@@ -810,10 +798,26 @@ 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) {
-            // close html
             page.write("</body>\n</html>\n");
         }