align-items.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. (function() {
  2. var AlignItems, Declaration, 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. AlignItems = (function(_super) {
  8. __extends(AlignItems, _super);
  9. function AlignItems() {
  10. return AlignItems.__super__.constructor.apply(this, arguments);
  11. }
  12. AlignItems.names = ['align-items', 'flex-align', 'box-align'];
  13. AlignItems.oldValues = {
  14. 'flex-end': 'end',
  15. 'flex-start': 'start'
  16. };
  17. AlignItems.prototype.prefixed = function(prop, prefix) {
  18. var spec, _ref;
  19. _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1];
  20. if (spec === 2009) {
  21. return prefix + 'box-align';
  22. } else if (spec === 2012) {
  23. return prefix + 'flex-align';
  24. } else {
  25. return AlignItems.__super__.prefixed.apply(this, arguments);
  26. }
  27. };
  28. AlignItems.prototype.normalize = function(prop) {
  29. return 'align-items';
  30. };
  31. AlignItems.prototype.set = function(decl, prefix) {
  32. var spec;
  33. spec = flexSpec(prefix)[0];
  34. if (spec === 2009 || spec === 2012) {
  35. decl.value = AlignItems.oldValues[decl.value] || decl.value;
  36. return AlignItems.__super__.set.call(this, decl, prefix);
  37. } else {
  38. return AlignItems.__super__.set.apply(this, arguments);
  39. }
  40. };
  41. return AlignItems;
  42. })(Declaration);
  43. module.exports = AlignItems;
  44. }).call(this);