font.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. var TYPES = require('../parsers').TYPES;
  3. var valueType = require('../parsers').valueType;
  4. var shorthandParser = require('../parsers').shorthandParser;
  5. var shorthandSetter = require('../parsers').shorthandSetter;
  6. var shorthandGetter = require('../parsers').shorthandGetter;
  7. var shorthand_for = {
  8. 'font-family': require('./fontFamily'),
  9. 'font-size': require('./fontSize'),
  10. 'font-style': require('./fontStyle'),
  11. 'font-variant': require('./fontVariant'),
  12. 'font-weight': require('./fontWeight'),
  13. 'line-height': require('./lineHeight'),
  14. };
  15. var static_fonts = [
  16. 'caption',
  17. 'icon',
  18. 'menu',
  19. 'message-box',
  20. 'small-caption',
  21. 'status-bar',
  22. 'inherit',
  23. ];
  24. var setter = shorthandSetter('font', shorthand_for);
  25. module.exports.definition = {
  26. set: function(v) {
  27. var short = shorthandParser(v, shorthand_for);
  28. if (short !== undefined) {
  29. return setter.call(this, v);
  30. }
  31. if (valueType(v) === TYPES.KEYWORD && static_fonts.indexOf(v.toLowerCase()) !== -1) {
  32. this._setProperty('font', v);
  33. }
  34. },
  35. get: shorthandGetter('font', shorthand_for),
  36. enumerable: true,
  37. configurable: true,
  38. };