You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/09/21 10:30:11 UTC
svn commit: r578017 - in /myfaces/tomahawk/trunk/sandbox/core/src/main:
java/org/apache/myfaces/custom/dojoaddresource/
resources/org/apache/myfaces/custom/dojoaddresource/
resources/org/apache/myfaces/custom/dojoaddresource/resource/
Author: imario
Date: Fri Sep 21 01:30:10 2007
New Revision: 578017
URL: http://svn.apache.org/viewvc?rev=578017&view=rev
Log:
Deal with ordering of added stylesheets. Code in dojoaddresource.js is taken from dojo and modified to use insertBefore instead of appendChild. As far as I read the dojo "dual" license it is allowed to do this.
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/dojoaddresource.js (with props)
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojoaddresource/DojoAddResource.java
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojoaddresource/DojoAddResource.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojoaddresource/DojoAddResource.java?rev=578017&r1=578016&r2=578017&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojoaddresource/DojoAddResource.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojoaddresource/DojoAddResource.java Fri Sep 21 01:30:10 2007
@@ -829,11 +829,14 @@
// the DojoInitializer component before any other component (right after f:view)
DojoUtils.addMainInclude(context, null, null, DojoUtils.getDjConfigInstance(context));
+ addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, DojoAddResource.class, "dojoaddresource.js");
+
writer.startElement(HTML.SCRIPT_ELEM, null);
writer.writeAttribute(HTML.SCRIPT_LANGUAGE_ATTR, HTML.SCRIPT_LANGUAGE_JAVASCRIPT, null);
writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
- writer.write("dojo.html.insertCssFile('");
+ // writer.write("dojo.html.insertCssFile('");
+ writer.write("oamInsertCssFile('");
writer.write(context.getExternalContext().encodeActionURL(this.getResourceUri()));
writer.write("');");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/dojoaddresource.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/dojoaddresource.js?rev=578017&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/dojoaddresource.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/dojoaddresource.js Fri Sep 21 01:30:10 2007
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function oamInsertCssFile(/* string */URI)
+{
+ // summary
+ // calls css by XmlHTTP and inserts it into DOM as <style [widgetType="widgetType"]> *downloaded cssText*</style>
+ if (!URI)
+ {
+ return;
+ }
+ var cssStr = dojo.hostenv.getText(URI, false, true);
+ if (cssStr === null)
+ {
+ return;
+ }
+ cssStr = dojo.html.fixPathsInCssText(cssStr, URI);
+
+ return oamInsertCssText(cssStr);
+}
+
+function oamInsertCssText(/* string */cssStr)
+{
+ // summary
+ // Attempt to insert CSS rules into the document through inserting a style element
+ // DomNode Style = insertCssText(String ".dojoMenu {color: green;}"[, DomDoc document, dojo.uri.Uri Url ])
+ if (!cssStr)
+ {
+ return; // HTMLStyleElement
+ }
+ var doc = document;
+
+ var style = doc.createElement("style");
+ style.setAttribute("type", "text/css");
+ // IE is b0rken enough to require that we add the element to the doc
+ // before changing it's properties
+ var head = doc.getElementsByTagName("head")[0];
+ if (!head)
+ { // must have a head tag
+ dojo.debug("No head tag in document, aborting styles");
+ return; // HTMLStyleElement
+ }
+ else
+ {
+ var links = head.getElementsByTagName("link");
+ if (links && links.length > 0)
+ {
+ head.insertBefore(style, links[0]);
+ }
+ else
+ {
+ head.appendChild(style);
+ }
+ }
+
+ if (style.styleSheet)
+ {// IE
+ var setFunc = function()
+ {
+ try
+ {
+ style.styleSheet.cssText = cssStr;
+ }
+ catch(e)
+ {
+ dojo.debug(e);
+ }
+ };
+ if (style.styleSheet.disabled)
+ {
+ setTimeout(setFunc, 10);
+ }
+ else
+ {
+ setFunc();
+ }
+ }
+ else
+ { // w3c
+ var cssText = doc.createTextNode(cssStr);
+ style.appendChild(cssText);
+ }
+ return style; // HTMLStyleElement
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/dojoaddresource.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/dojoaddresource.js
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojoaddresource/resource/dojoaddresource.js
------------------------------------------------------------------------------
svn:mime-type = text/plain