Package cssutils :: Package css :: Module cssmediarule :: Class CSSMediaRule |
[hide private]
[frames] | no frames]

# Class CSSMediaRule

source code

     object --+
              |
      util.Base --+
                  |
    cssrule.CSSRule --+
                      |
                     CSSMediaRule

Objects implementing the CSSMediaRule interface can be identified by the MEDIA_RULE constant. On these objects the type attribute must return the value of that constant.

# Properties

cssRules: A css::CSSRuleList of all CSS rules contained within the
  media block.
media: of type stylesheets::MediaList, (DOM readonly)
  A list of media types for this rule of type MediaList.
inherited from CSSRule
  cssText

## cssutils only

atkeyword:
  the literal keyword used

# Format

media
  : MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* ruleset* '}' S*;

Nested Classes | [hide private]
Inherited from `util.Base` (private): `_prods`

Instance Methods | [hide private]
__init__(self, mediaText=`'``all``'`, readonly=False) constructor | source code
_getCssText(self) returns serialized property cssText | source code
_setCssText(self, cssText) DOMException on setting | source code
_getMedia(self) returns MediaList | source code
_getCssRules(self) | source code
deleteRule(self, index) within the media block's rule collection of the rule to remove. | source code
insertRule(self, rule, index=None) The parsable text representing the rule. | source code
__repr__(self) repr(x) | source code
__str__(self) str(x) | source code
Inherited from `cssrule.CSSRule` (private): `_getTypeString` Inherited from `util.Base` (private): `_checkReadonly`, `_getProductions`, `_newseq`, `_nexttoken`, `_parse`, `_tokenize2`, `_tokensupto2`, `_tokenvalue`, `_type`, `_valuestr` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`

Static Methods | [hide private]
Inherited from `util.Base` (private): `_normalize`

Class Variables | [hide private]
| type = `4` The type of this rule, as defined by a CSSRule type constant.
Inherited from `cssrule.CSSRule`: `COMMENT`, `UNKNOWN_RULE` Inherited from `cssrule.CSSRule` (private): `_typestrings` Inherited from `util.Base` (private): `_SHORTHANDPROPERTIES`, `_log`

Properties | [hide private]
| cssText (DOM attribute) The parsable textual representation.
| media (DOM readonly) A list of media types for this rule of type MediaList
| cssRules (DOM readonly) A css::CSSRuleList of all CSS rules contained within the media block.
Inherited from `cssrule.CSSRule`: `typeString` Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, mediaText=`'``all``'`, readonly=False) (Constructor) | source code
constructor Overrides: cssrule.CSSRule.__init__

### _getCssText(self) | source code
returns serialized property cssText Overrides: cssrule.CSSRule._getCssText

### _setCssText(self, cssText) | source code
DOMException on setting NO_MODIFICATION_ALLOWED_ERR: (self) Raised if the rule is readonly. INVALID_MODIFICATION_ERR: (self) Raised if the specified CSS string value represents a different type of rule than the current one. HIERARCHY_REQUEST_ERR: (self) Raised if the rule cannot be inserted at this point in the style sheet. SYNTAX_ERR: (self) Raised if the specified CSS string value has a syntax error and is unparsable. Overrides: cssrule.CSSRule._setCssText

### deleteRule(self, index) | source code
index within the media block's rule collection of the rule to remove. Used to delete a rule from the media block. DOMExceptions INDEX_SIZE_ERR: (self) Raised if the specified index does not correspond to a rule in the media rule list. NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this media rule is readonly.

### insertRule(self, rule, index=None) | source code
rule The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content. cssutils also allows rule to be a valid CSSRule object index within the media block's rule collection of the rule before which to insert the specified rule. If the specified index is equal to the length of the media blocks's rule collection, the rule will be added to the end of the media block. If index is not given or None rule will be appended to rule list. Used to insert a new rule into the media block. DOMException on setting HIERARCHY_REQUEST_ERR: (no use case yet as no @charset or @import allowed)) Raised if the rule cannot be inserted at the specified index, e.g., if an @import rule is inserted after a standard rule set or other at-rule. INDEX_SIZE_ERR: (self) Raised if the specified index is not a valid insertion point. NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this media rule is readonly. SYNTAX_ERR: (CSSStyleRule) Raised if the specified rule has a syntax error and is unparsable. returns the index within the media block's rule collection of the newly inserted rule.

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

Property Details | [hide private]

  ### cssText (DOM attribute) The parsable textual representation. Get Method: cssutils.css.cssmediarule.CSSMediaRule._getCssText(self) - returns serialized property cssText Set Method: cssutils.css.cssmediarule.CSSMediaRule._setCssText(self, cssText) - DOMException on setting Delete Method:
      None

  ### media (DOM readonly) A list of media types for this rule of type MediaList Get Method: cssutils.css.cssmediarule.CSSMediaRule._getMedia(self) - returns MediaList Set Method:
      None
  Delete Method:
      None

  ### cssRules (DOM readonly) A css::CSSRuleList of all CSS rules contained within the media block. Get Method: cssutils.css.cssmediarule.CSSMediaRule._getCssRules(self) Set Method:
      None
  Delete Method:
      None