background-repeat.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var IPropertyDescriptor_1 = require("../IPropertyDescriptor");
  4. var parser_1 = require("../syntax/parser");
  5. var BACKGROUND_REPEAT;
  6. (function (BACKGROUND_REPEAT) {
  7. BACKGROUND_REPEAT[BACKGROUND_REPEAT["REPEAT"] = 0] = "REPEAT";
  8. BACKGROUND_REPEAT[BACKGROUND_REPEAT["NO_REPEAT"] = 1] = "NO_REPEAT";
  9. BACKGROUND_REPEAT[BACKGROUND_REPEAT["REPEAT_X"] = 2] = "REPEAT_X";
  10. BACKGROUND_REPEAT[BACKGROUND_REPEAT["REPEAT_Y"] = 3] = "REPEAT_Y";
  11. })(BACKGROUND_REPEAT = exports.BACKGROUND_REPEAT || (exports.BACKGROUND_REPEAT = {}));
  12. exports.backgroundRepeat = {
  13. name: 'background-repeat',
  14. initialValue: 'repeat',
  15. prefix: false,
  16. type: IPropertyDescriptor_1.PropertyDescriptorParsingType.LIST,
  17. parse: function (tokens) {
  18. return parser_1.parseFunctionArgs(tokens)
  19. .map(function (values) {
  20. return values
  21. .filter(parser_1.isIdentToken)
  22. .map(function (token) { return token.value; })
  23. .join(' ');
  24. })
  25. .map(parseBackgroundRepeat);
  26. }
  27. };
  28. var parseBackgroundRepeat = function (value) {
  29. switch (value) {
  30. case 'no-repeat':
  31. return BACKGROUND_REPEAT.NO_REPEAT;
  32. case 'repeat-x':
  33. case 'repeat no-repeat':
  34. return BACKGROUND_REPEAT.REPEAT_X;
  35. case 'repeat-y':
  36. case 'no-repeat repeat':
  37. return BACKGROUND_REPEAT.REPEAT_Y;
  38. case 'repeat':
  39. default:
  40. return BACKGROUND_REPEAT.REPEAT;
  41. }
  42. };
  43. //# sourceMappingURL=background-repeat.js.map