DeclarationBlock.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Generated by CoffeeScript 1.9.3
  2. var Arbitrary, DeclarationBlock, declarationClasses;
  3. module.exports = DeclarationBlock = (function() {
  4. var self;
  5. self = DeclarationBlock;
  6. function DeclarationBlock() {
  7. this._declarations = {};
  8. }
  9. DeclarationBlock.prototype.set = function(prop, value) {
  10. var key, val;
  11. if (typeof prop === 'object') {
  12. for (key in prop) {
  13. val = prop[key];
  14. this.set(key, val);
  15. }
  16. return this;
  17. }
  18. prop = self.sanitizeProp(prop);
  19. this._getDeclarationClass(prop).setOnto(this._declarations, prop, value);
  20. return this;
  21. };
  22. DeclarationBlock.prototype._getDeclarationClass = function(prop) {
  23. var cls;
  24. if (prop[0] === '_') {
  25. return Arbitrary;
  26. }
  27. if (!(cls = declarationClasses[prop])) {
  28. throw Error("Unkown property `" + prop + "`. Write it as `_" + prop + "` if you're defining a custom property");
  29. }
  30. return cls;
  31. };
  32. DeclarationBlock.sanitizeProp = function(prop) {
  33. return String(prop).trim();
  34. };
  35. return DeclarationBlock;
  36. })();
  37. Arbitrary = require('./declarationBlock/Arbitrary');
  38. declarationClasses = {
  39. color: require('./declarationBlock/Color'),
  40. background: require('./declarationBlock/Background'),
  41. width: require('./declarationBlock/Width'),
  42. height: require('./declarationBlock/Height'),
  43. bullet: require('./declarationBlock/Bullet'),
  44. display: require('./declarationBlock/Display'),
  45. margin: require('./declarationBlock/Margin'),
  46. marginTop: require('./declarationBlock/MarginTop'),
  47. marginLeft: require('./declarationBlock/MarginLeft'),
  48. marginRight: require('./declarationBlock/MarginRight'),
  49. marginBottom: require('./declarationBlock/MarginBottom'),
  50. padding: require('./declarationBlock/Padding'),
  51. paddingTop: require('./declarationBlock/PaddingTop'),
  52. paddingLeft: require('./declarationBlock/PaddingLeft'),
  53. paddingRight: require('./declarationBlock/PaddingRight'),
  54. paddingBottom: require('./declarationBlock/PaddingBottom')
  55. };