CSSMediaRule.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //.CommonJS
  2. var CSSOM = {
  3. CSSRule: require("./CSSRule").CSSRule,
  4. MediaList: require("./MediaList").MediaList
  5. };
  6. ///CommonJS
  7. /**
  8. * @constructor
  9. * @see http://dev.w3.org/csswg/cssom/#cssmediarule
  10. * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSMediaRule
  11. */
  12. CSSOM.CSSMediaRule = function CSSMediaRule() {
  13. CSSOM.CSSRule.call(this);
  14. this.media = new CSSOM.MediaList();
  15. this.cssRules = [];
  16. };
  17. CSSOM.CSSMediaRule.prototype = new CSSOM.CSSRule();
  18. CSSOM.CSSMediaRule.prototype.constructor = CSSOM.CSSMediaRule;
  19. CSSOM.CSSMediaRule.prototype.type = 4;
  20. //FIXME
  21. //CSSOM.CSSMediaRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
  22. //CSSOM.CSSMediaRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
  23. // http://opensource.apple.com/source/WebCore/WebCore-658.28/css/CSSMediaRule.cpp
  24. Object.defineProperty(CSSOM.CSSMediaRule.prototype, "cssText", {
  25. get: function() {
  26. var cssTexts = [];
  27. for (var i=0, length=this.cssRules.length; i < length; i++) {
  28. cssTexts.push(this.cssRules[i].cssText);
  29. }
  30. return "@media " + this.media.mediaText + " {" + cssTexts.join("") + "}";
  31. }
  32. });
  33. //.CommonJS
  34. exports.CSSMediaRule = CSSOM.CSSMediaRule;
  35. ///CommonJS