1 /* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
2 /* This file is part of version 0.96beta2 released Fri, 20 Mar 2009 11:01:14 +0100 */
3 function DynamicCSS(e
,d
){this.editor
=e
;var a
=e
.config
;var b
=this;var g
=null;var c
=null;var f
={id
:"DynamicCSS-class",tooltip
:this._lc("Choose stylesheet"),options
:{"":""},action:function(h
){b
.onSelect(h
,this)},refresh:function(h
){b
.updateValue(h
,this)}};a
.registerDropdown(f
);a
.addToolbarElement(["T[CSS]","DynamicCSS-class","separator"],"formatblock",-1)}DynamicCSS
.parseStyleSheet=function(a
){iframe
=a
._iframe
.contentWindow
.document
;cssArray
=DynamicCSS
.cssArray
;if(!cssArray
){cssArray
=new Array()}for(i
=0;i
<iframe
.styleSheets
.length
;i
++){if(iframe
.styleSheets
[i
].title
=="XinhaInternalCSS"){continue}if(Xinha
.is_gecko
){try{cssArray
=DynamicCSS
.applyCSSRule(iframe
.styleSheets
[i
].cssRules
,cssArray
)}catch(b
){}}else{try{if(iframe
.styleSheets
[i
].rules
){cssArray
=DynamicCSS
.applyCSSRule(iframe
.styleSheets
[i
].rules
,cssArray
)}if(iframe
.styleSheets
[i
].imports
){for(j
=0;j
<iframe
.styleSheets
[i
].imports
.length
;j
++){cssArray
=DynamicCSS
.applyCSSRule(iframe
.styleSheets
[i
].imports
[j
].rules
,cssArray
)}}}catch(b
){}}}DynamicCSS
.cssArray
=cssArray
};DynamicCSS
.applyCSSRule=function(a
,b
){for(rule
in a
){if(typeof a
[rule
]=="function"){continue}if(a
[rule
].selectorText
){if(a
[rule
].selectorText
.search(/:+/)==-1){cssElements
=a
[rule
].selectorText
.split(",");for(k
=0;k
<cssElements
.length
;k
++){cssElement
=cssElements
[k
].split(".");tagName
=cssElement
[0].toLowerCase().trim();className
=cssElement
[1];if(!tagName
){tagName
="all"}if(!b
[tagName
]){b
[tagName
]=new Array()}if(className
){if(tagName
=="all"){cssName
=className
}else{cssName
="<"+className
+">"}}else{className
="none";if(tagName
=="all"){cssName
=Xinha
._lc("Default","DynamicCSS")}else{cssName
="<"+Xinha
._lc("Default","DynamicCSS")+">"}}b
[tagName
][className
]=cssName
;DynamicCSS
.cssLength
++}}}else{if(a
[rule
].styleSheet
){b
=DynamicCSS
.applyCSSRule(a
[rule
].styleSheet
.cssRules
,b
)}}}return b
};DynamicCSS
._pluginInfo
={name
:"DynamicCSS",version
:"1.5.2",developer
:"Holger Hees",developer_url
:"http://www.systemconcept.de/",c_owner
:"Holger Hees",sponsor
:"System Concept GmbH",sponsor_url
:"http://www.systemconcept.de/",license
:"htmlArea"};DynamicCSS
.prototype._lc=function(a
){return Xinha
._lc(a
,"DynamicCSS")};DynamicCSS
.prototype.onSelect=function(e
,f
){var b
=e
._toolbarObjects
[f
.id
];var a
=b
.element
.selectedIndex
;var d
=b
.element
.value
;var c
=e
.getParentElement();if(d
!="none"){c
.className
=d
;DynamicCSS
.lastClass
=d
}else{if(Xinha
.is_gecko
){c
.removeAttribute("class")}else{c
.removeAttribute("className")}}e
.updateToolbar()};DynamicCSS
.prototype.reparseTimer=function(b
,c
,a
){if(DynamicCSS
.parseCount
<9){setTimeout(function(){DynamicCSS
.cssLength
=0;DynamicCSS
.parseStyleSheet(b
);if(DynamicCSS
.cssOldLength
!=DynamicCSS
.cssLength
){DynamicCSS
.cssOldLength
=DynamicCSS
.cssLength
;DynamicCSS
.lastClass
=null;a
.updateValue(b
,c
)}a
.reparseTimer(b
,c
,a
)},DynamicCSS
.parseCount
*1000);DynamicCSS
.parseCount
=DynamicCSS
.parseCount
*2}};DynamicCSS
.prototype.updateValue=function(e
,b
){cssArray
=DynamicCSS
.cssArray
;if(!cssArray
){DynamicCSS
.cssLength
=0;DynamicCSS
.parseStyleSheet(e
);cssArray
=DynamicCSS
.cssArray
;DynamicCSS
.cssOldLength
=DynamicCSS
.cssLength
;DynamicCSS
.parseCount
=1;this.reparseTimer(e
,b
,this)}var h
=e
.getParentElement();var a
=h
.tagName
.toLowerCase();var f
=h
.className
;if(this.lastTag
!=a
||this.lastClass
!=f
){this.lastTag
=a
;this.lastClass
=f
;var g
=e
._toolbarObjects
[b
.id
].element
;while(g
.length
>0){g
.options
[g
.length
-1]=null}g
.options
[0]=new Option(this._lc("Default"),"none");if(cssArray
){if(a
!="body"||e
.config
.fullPage
){if(cssArray
[a
]){for(cssClass
in cssArray
[a
]){if(typeof cssArray
[a
][cssClass
]!="string"){continue}if(cssClass
=="none"){g
.options
[0]=new Option(cssArray
[a
][cssClass
],cssClass
)}else{g
.options
[g
.length
]=new Option(cssArray
[a
][cssClass
],cssClass
)}}}if(cssArray
.all
){for(cssClass
in cssArray
.all
){if(typeof cssArray
.all
[cssClass
]!="string"){continue}g
.options
[g
.length
]=new Option(cssArray
.all
[cssClass
],cssClass
)}}}else{if(cssArray
[a
]&&cssArray
[a
]["none"]){g
.options
[0]=new Option(cssArray
[a
]["none"],"none")}}}g
.selectedIndex
=0;if(typeof f
!="undefined"&&/\S/.test(f
)){var l
=g
.options
;for(var c
=l
.length
;--c
>=0;){var d
=l
[c
];if(f
==d
.value
){g
.selectedIndex
=c
;break}}if(g
.selectedIndex
==0){g
.options
[g
.length
]=new Option(this._lc("Undefined"),f
);g
.selectedIndex
=g
.length
-1}}if(g
.length
>1){g
.disabled
=false}else{g
.disabled
=true}}};