[Phpfreechat-svn] SF.net SVN: phpfreechat: [933] trunk
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-01-21 22:09:56
|
Revision: 933 http://svn.sourceforge.net/phpfreechat/?rev=933&view=rev Author: kerphi Date: 2007-01-21 14:09:53 -0800 (Sun, 21 Jan 2007) Log Message: ----------- Bug fix: IE6 crash on old WinXP version [5h00] Modified Paths: -------------- trunk/data/public/js/createstylerule.js trunk/src/phpfreechat.class.php Modified: trunk/data/public/js/createstylerule.js =================================================================== --- trunk/data/public/js/createstylerule.js 2007-01-21 11:26:08 UTC (rev 932) +++ trunk/data/public/js/createstylerule.js 2007-01-21 22:09:53 UTC (rev 933) @@ -1,27 +1,35 @@ // from http://www.bobbyvandersluis.com/articles/dynamicCSS.php -function createStyleRule(selector, declaration) { +var pfcCSS = Class.create(); +pfcCSS.prototype = { + initialize: function() + { if (!document.getElementsByTagName || !(document.createElement || document.createElementNS)) return; var agt = navigator.userAgent.toLowerCase(); - var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); - var is_iewin = (is_ie && (agt.indexOf("win") != -1)); - var is_iemac = (is_ie && (agt.indexOf("mac") != -1)); - if (is_iemac) return; // script doesn't work properly in IE/Mac + this.is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); + this.is_iewin = (is_ie && (agt.indexOf("win") != -1)); + this.is_iemac = (is_ie && (agt.indexOf("mac") != -1)); + if (this.is_iemac) return; // script doesn't work properly in IE/Mac + var head = document.getElementsByTagName("head")[0]; - var style = (typeof document.createElementNS != "undefined") ? + this.style = (typeof document.createElementNS != "undefined") ? document.createElementNS("http://www.w3.org/1999/xhtml", "style") : document.createElement("style"); - if (!is_iewin) { - var styleRule = document.createTextNode(selector + " {" + declaration + "}"); - style.appendChild(styleRule); // bugs in IE/Win + this.style.setAttribute("type", "text/css"); + this.style.setAttribute("media", "screen"); + head.appendChild(this.style); + + this.lastStyle = document.styleSheets[document.styleSheets.length - 1]; + }, + + applyRule: function(selector, declaration) + { + if (!this.is_iewin) { + var styleRule = document.createTextNode(selector + " {" + declaration + "}"); + this.style.appendChild(styleRule); // bugs in IE/Win } - style.setAttribute("type", "text/css"); - style.setAttribute("media", "screen"); - head.appendChild(style); - if (is_iewin && document.styleSheets && document.styleSheets.length > 0) { - var lastStyle = document.styleSheets[document.styleSheets.length - 1]; - if (typeof lastStyle.addRule == "object") { - lastStyle.addRule(selector, declaration); - } + if (this.is_iewin && document.styleSheets && document.styleSheets.length > 0) { + this.lastStyle.addRule(selector, declaration); } + } } \ No newline at end of file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2007-01-21 11:26:08 UTC (rev 932) +++ trunk/src/phpfreechat.class.php 2007-01-21 22:09:53 UTC (rev 933) @@ -420,7 +420,8 @@ } $t->setTemplate($c->getFilePathFromTheme('style.css')); $css_code .= $t->getOutput(); - + + $css->parse($css_code); foreach($css->css as $k => $v) { @@ -428,13 +429,11 @@ { $rules = ''; foreach($v2 as $k3 => $v3) - { $rules .= $k3.':'.$v3.';'; - } - $js .= "c['".$k2."']='".$rules."';\n"; + $js .= "c['".$k2."']='".str_replace("\n", "", $rules)."';\n"; } - } - $js .= "var k = c.keys(); c.each(function (a,b) { createStyleRule(a[0],a[1]); });"; + } + $js .= "var pfccss = new pfcCSS(); var k = c.keys(); c.each(function (a) { pfccss.applyRule(a[0],a[1]); });"; $xml_reponse->script($js); return $xml_reponse; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |