pixelated.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (function() {
  2. var OldValue, Pixelated, Value,
  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. OldValue = require('../old-value');
  6. Value = require('../value');
  7. Pixelated = (function(superClass) {
  8. extend(Pixelated, superClass);
  9. function Pixelated() {
  10. return Pixelated.__super__.constructor.apply(this, arguments);
  11. }
  12. Pixelated.names = ['pixelated'];
  13. Pixelated.prototype.replace = function(string, prefix) {
  14. if (prefix === '-webkit-') {
  15. return string.replace(this.regexp(), '$1-webkit-optimize-contrast');
  16. } else if (prefix === '-moz-') {
  17. return string.replace(this.regexp(), '$1-moz-crisp-edges');
  18. } else {
  19. return Pixelated.__super__.replace.apply(this, arguments);
  20. }
  21. };
  22. Pixelated.prototype.old = function(prefix) {
  23. if (prefix === '-webkit-') {
  24. return new OldValue(this.name, '-webkit-optimize-contrast');
  25. } else if (prefix === '-moz-') {
  26. return new OldValue(this.name, '-moz-crisp-edges');
  27. } else {
  28. return Pixelated.__super__.old.apply(this, arguments);
  29. }
  30. };
  31. return Pixelated;
  32. })(Value);
  33. module.exports = Pixelated;
  34. }).call(this);