justify-content.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. (function() {
  2. var Declaration, JustifyContent, flexSpec,
  3. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4. __hasProp = {}.hasOwnProperty;
  5. flexSpec = require('./flex-spec');
  6. Declaration = require('../declaration');
  7. JustifyContent = (function(_super) {
  8. __extends(JustifyContent, _super);
  9. function JustifyContent() {
  10. return JustifyContent.__super__.constructor.apply(this, arguments);
  11. }
  12. JustifyContent.names = ['justify-content', 'flex-pack', 'box-pack'];
  13. JustifyContent.oldValues = {
  14. 'flex-end': 'end',
  15. 'flex-start': 'start',
  16. 'space-between': 'justify',
  17. 'space-around': 'distribute'
  18. };
  19. JustifyContent.prototype.prefixed = function(prop, prefix) {
  20. var spec, _ref;
  21. _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1];
  22. if (spec === 2009) {
  23. return prefix + 'box-pack';
  24. } else if (spec === 2012) {
  25. return prefix + 'flex-pack';
  26. } else {
  27. return JustifyContent.__super__.prefixed.apply(this, arguments);
  28. }
  29. };
  30. JustifyContent.prototype.normalize = function(prop) {
  31. return 'justify-content';
  32. };
  33. JustifyContent.prototype.set = function(decl, prefix) {
  34. var spec, value;
  35. spec = flexSpec(prefix)[0];
  36. if (spec === 2009 || spec === 2012) {
  37. value = JustifyContent.oldValues[decl.value] || decl.value;
  38. decl.value = value;
  39. if (spec !== 2009 || value !== 'distribute') {
  40. return JustifyContent.__super__.set.call(this, decl, prefix);
  41. }
  42. } else if (spec === 'final') {
  43. return JustifyContent.__super__.set.apply(this, arguments);
  44. }
  45. };
  46. return JustifyContent;
  47. })(Declaration);
  48. module.exports = JustifyContent;
  49. }).call(this);