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

Source Code for Module 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 print "css file", cssFile 19 if _doc is None: 20 _doc = doc() 21 _doc.getElementsByTagName("head").item(0).appendChild(self._e)
22
23 - def remove(self):
24 parent = DOM.getParent(self._e) 25 DOM.removeChild(parent, self._e)
26
27 -def setStyleElementText(el, text):
28 DOM.appendChild(el, doc().createTextNode(text))
29
30 -class StyleSheetCssText:
31
32 - def __init__(self, text='', _doc=None):
33 self._e = DOM.createElement('style') 34 self._e.setAttribute('type', 'text/css') 35 setStyleElementText(self._e, text) 36 37 if _doc is None: 38 _doc = doc() 39 _doc.getElementsByTagName("head").item(0).appendChild(self._e)
40
41 - def remove(self):
42 parent = DOM.getParent(self._e) 43 DOM.removeChild(parent, self._e)
44