display-flex.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. (function() {
  2. var DisplayFlex, OldDisplayFlex, OldValue, Value, 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. OldValue = require('../old-value');
  7. Value = require('../value');
  8. OldDisplayFlex = (function(_super) {
  9. __extends(OldDisplayFlex, _super);
  10. function OldDisplayFlex(_at_unprefixed, _at_prefixed) {
  11. this.unprefixed = _at_unprefixed;
  12. this.prefixed = _at_prefixed;
  13. }
  14. OldDisplayFlex.prototype.check = function(value) {
  15. return value === this.name;
  16. };
  17. return OldDisplayFlex;
  18. })(OldValue);
  19. DisplayFlex = (function(_super) {
  20. __extends(DisplayFlex, _super);
  21. DisplayFlex.names = ['display-flex', 'inline-flex'];
  22. function DisplayFlex(name, prefixes) {
  23. DisplayFlex.__super__.constructor.apply(this, arguments);
  24. if (name === 'display-flex') {
  25. this.name = 'flex';
  26. }
  27. }
  28. DisplayFlex.prototype.check = function(decl) {
  29. return decl.value === this.name;
  30. };
  31. DisplayFlex.prototype.prefixed = function(prefix) {
  32. var spec, _ref;
  33. _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1];
  34. return prefix + (spec === 2009 ? this.name === 'flex' ? 'box' : 'inline-box' : spec === 2012 ? this.name === 'flex' ? 'flexbox' : 'inline-flexbox' : spec === 'final' ? this.name : void 0);
  35. };
  36. DisplayFlex.prototype.replace = function(string, prefix) {
  37. return this.prefixed(prefix);
  38. };
  39. DisplayFlex.prototype.old = function(prefix) {
  40. var prefixed;
  41. prefixed = this.prefixed(prefix);
  42. if (prefixed) {
  43. return new OldValue(this.name, prefixed);
  44. }
  45. };
  46. return DisplayFlex;
  47. })(Value);
  48. module.exports = DisplayFlex;
  49. }).call(this);