align-self.js 1.6 KB

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