pixelated.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. var OldValue = require('../old-value');
  6. var Value = require('../value');
  7. var Pixelated = function (_Value) {
  8. _inherits(Pixelated, _Value);
  9. function Pixelated() {
  10. _classCallCheck(this, Pixelated);
  11. return _possibleConstructorReturn(this, _Value.apply(this, arguments));
  12. }
  13. /**
  14. * Use non-standard name for WebKit and Firefox
  15. */
  16. Pixelated.prototype.replace = function replace(string, prefix) {
  17. if (prefix === '-webkit-') {
  18. return string.replace(this.regexp(), '$1-webkit-optimize-contrast');
  19. } else if (prefix === '-moz-') {
  20. return string.replace(this.regexp(), '$1-moz-crisp-edges');
  21. } else {
  22. return _Value.prototype.replace.call(this, string, prefix);
  23. }
  24. };
  25. /**
  26. * Different name for WebKit and Firefox
  27. */
  28. Pixelated.prototype.old = function old(prefix) {
  29. if (prefix === '-webkit-') {
  30. return new OldValue(this.name, '-webkit-optimize-contrast');
  31. } else if (prefix === '-moz-') {
  32. return new OldValue(this.name, '-moz-crisp-edges');
  33. } else {
  34. return _Value.prototype.old.call(this, prefix);
  35. }
  36. };
  37. return Pixelated;
  38. }(Value);
  39. Object.defineProperty(Pixelated, 'names', {
  40. enumerable: true,
  41. writable: true,
  42. value: ['pixelated']
  43. });
  44. module.exports = Pixelated;