Package library :: Package pyjamas :: Package ui :: Module CSS
[hide private]
[frames] | no frames]

Source Code for Module library.pyjamas.ui.CSS

 1  """ CSS Stylesheet messing 
 2   
 3      Copyright (C) 2010, Stolati <mickael.kerbrat@gmail.com> 
 4      Copyright (C) 2010, Luke Kenneth Casson Leighton <lkcl@lkcl.net> 
 5  """ 
 6   
 7  from __pyjamas__ import doc 
 8  from pyjamas import DOM 
 9   
10 -class StyleSheetCssFile:
11
12 - def __init__(self, cssFile='', _doc=None):
13 self._e = DOM.createElement('link') 14 self._e.setAttribute('rel', 'stylesheet') 15 self._e.setAttribute('type', 'text/css') 16 self._e.setAttribute('href', cssFile); 17 18 if _doc is None: 19 _doc = doc() 20 _doc.getElementsByTagName("head").item(0).appendChild(self._e)
21
22 - def remove(self):
23 parent = DOM.getParent(self._e) 24 DOM.removeChild(parent, self._e)
25
26 -def setStyleElementText(el, text):
27 DOM.appendChild(el, doc().createTextNode(text))
28
29 -class StyleSheetCssText:
30
31 - def __init__(self, text='', _doc=None):
32 self._e = DOM.createElement('style') 33 self._e.setAttribute('type', 'text/css') 34 setStyleElementText(self._e, text) 35 36 if _doc is None: 37 _doc = doc() 38 _doc.getElementsByTagName("head").item(0).appendChild(self._e)
39
40 - def remove(self):
41 parent = DOM.getParent(self._e) 42 DOM.removeChild(parent, self._e)
43