[Mapbender-commits] r1696 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Oct 2 08:44:39 EDT 2007
Author: christoph
Date: 2007-10-02 08:44:39 -0400 (Tue, 02 Oct 2007)
New Revision: 1696
Added:
trunk/mapbender/http/javascripts/style.js
Log:
Adds a style tag to the document's head
Added: trunk/mapbender/http/javascripts/style.js
===================================================================
--- trunk/mapbender/http/javascripts/style.js (rev 0)
+++ trunk/mapbender/http/javascripts/style.js 2007-10-02 12:44:39 UTC (rev 1696)
@@ -0,0 +1,49 @@
+/**
+ * creates a style tag in the head of the document.
+ *
+ */
+var StyleTag = function() {
+
+ /**
+ * Creates the style tag in the head of the document. Something like a constructor.
+ *
+ */
+ var createStyleTag = function() {
+ // TODO: Internet Explorer routine seems a little buggy
+ if (top.ie) {
+ // create a Style Sheet object (IE only)
+ styleSheetObj=document.createStyleSheet();
+
+ // get the DOM node of the style sheet object, set the type
+ styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+ styleObj.setAttribute("type","text/css");
+ }
+ else {
+ // create the style node, set the style
+ styleObj=document.createElement("style");
+ styleObj.setAttribute("type","text/css");
+
+ }
+ // append the node to the head
+ document.getElementsByTagName("head")[0].appendChild(styleObj);
+ };
+
+ /**
+ * Adds a class className with the CSS in cssString
+ */
+ this.addClass = function(className, cssString) {
+ // TODO: Internet Explorer routine seems a little buggy
+ if (top.ie) {
+ styleSheetObj.addRule(className,cssString);
+ }
+ else {
+ // insert the content via createTextNode
+ styleObj.appendChild(document.createTextNode("."+className+"{\n\t"+cssString+"\n}\n"));
+ }
+ };
+
+ var styleObj;
+ var styleSheetObj; //IE only...
+
+ createStyleTag();
+};
\ No newline at end of file
More information about the Mapbender_commits
mailing list