order.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. (function() {
  2. var Declaration, Order, 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. Order = (function(superClass) {
  8. extend(Order, superClass);
  9. function Order() {
  10. return Order.__super__.constructor.apply(this, arguments);
  11. }
  12. Order.names = ['order', 'flex-order', 'box-ordinal-group'];
  13. Order.prototype.prefixed = function(prop, prefix) {
  14. var ref, spec;
  15. ref = flexSpec(prefix), spec = ref[0], prefix = ref[1];
  16. if (spec === 2009) {
  17. return prefix + 'box-ordinal-group';
  18. } else if (spec === 2012) {
  19. return prefix + 'flex-order';
  20. } else {
  21. return Order.__super__.prefixed.apply(this, arguments);
  22. }
  23. };
  24. Order.prototype.normalize = function(prop) {
  25. return 'order';
  26. };
  27. Order.prototype.set = function(decl, prefix) {
  28. var spec;
  29. spec = flexSpec(prefix)[0];
  30. if (spec === 2009) {
  31. decl.value = (parseInt(decl.value) + 1).toString();
  32. return Order.__super__.set.call(this, decl, prefix);
  33. } else {
  34. return Order.__super__.set.apply(this, arguments);
  35. }
  36. };
  37. return Order;
  38. })(Declaration);
  39. module.exports = Order;
  40. }).call(this);