Bullet.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Generated by CoffeeScript 1.9.3
  2. var Bullet, _Declaration,
  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. _Declaration = require('./_Declaration');
  6. module.exports = Bullet = (function(superClass) {
  7. var self;
  8. extend(Bullet, superClass);
  9. function Bullet() {
  10. return Bullet.__super__.constructor.apply(this, arguments);
  11. }
  12. self = Bullet;
  13. Bullet.prototype._set = function(val) {
  14. var alignment, bg, char, color, enabled, m, original;
  15. val = String(val);
  16. original = val;
  17. char = null;
  18. enabled = false;
  19. color = 'none';
  20. bg = 'none';
  21. if (m = val.match(/\"([^"]+)\"/) || (m = val.match(/\'([^']+)\'/))) {
  22. char = m[1];
  23. val = val.replace(m[0], '');
  24. enabled = true;
  25. }
  26. if (m = val.match(/(none|left|right|center)/)) {
  27. alignment = m[1];
  28. val = val.replace(m[0], '');
  29. } else {
  30. alignment = 'left';
  31. }
  32. if (alignment === 'none') {
  33. enabled = false;
  34. }
  35. if (m = val.match(/color\:([\w\-]+)/)) {
  36. color = m[1];
  37. val = val.replace(m[0], '');
  38. }
  39. if (m = val.match(/bg\:([\w\-]+)/)) {
  40. bg = m[1];
  41. val = val.replace(m[0], '');
  42. }
  43. if (val.trim() !== '') {
  44. throw Error("Unrecognizable value `" + original + "` for `" + this.prop + "`");
  45. }
  46. return this.val = {
  47. enabled: enabled,
  48. char: char,
  49. alignment: alignment,
  50. background: bg,
  51. color: color
  52. };
  53. };
  54. return Bullet;
  55. })(_Declaration);