media.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*!
  2. * Stylus - Media
  3. * Copyright (c) Automattic <developer.wordpress.com>
  4. * MIT Licensed
  5. */
  6. /**
  7. * Module dependencies.
  8. */
  9. var Atrule = require('./atrule');
  10. /**
  11. * Initialize a new `Media` with the given `val`
  12. *
  13. * @param {String} val
  14. * @api public
  15. */
  16. var Media = module.exports = function Media(val){
  17. Atrule.call(this, 'media');
  18. this.val = val;
  19. };
  20. /**
  21. * Inherit from `Atrule.prototype`.
  22. */
  23. Media.prototype.__proto__ = Atrule.prototype;
  24. /**
  25. * Clone this node.
  26. *
  27. * @return {Media}
  28. * @api public
  29. */
  30. Media.prototype.clone = function(parent){
  31. var clone = new Media;
  32. clone.val = this.val.clone(parent, clone);
  33. clone.block = this.block.clone(parent, clone);
  34. clone.lineno = this.lineno;
  35. clone.column = this.column;
  36. clone.filename = this.filename;
  37. return clone;
  38. };
  39. /**
  40. * Return a JSON representation of this node.
  41. *
  42. * @return {Object}
  43. * @api public
  44. */
  45. Media.prototype.toJSON = function(){
  46. return {
  47. __type: 'Media',
  48. val: this.val,
  49. block: this.block,
  50. lineno: this.lineno,
  51. column: this.column,
  52. filename: this.filename
  53. };
  54. };
  55. /**
  56. * Return @media "val".
  57. *
  58. * @return {String}
  59. * @api public
  60. */
  61. Media.prototype.toString = function(){
  62. return '@media ' + this.val;
  63. };