block.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Generated by CoffeeScript 1.9.3
  2. var _common, blockStyleApplier, object, self;
  3. _common = require('./_common');
  4. object = require('utila').object;
  5. module.exports = blockStyleApplier = self = {
  6. applyTo: function(el, style) {
  7. var config, ret;
  8. ret = _common.getStyleTagsFor(style);
  9. ret.blockConfig = config = {};
  10. this._margins(style, config);
  11. this._bullet(style, config);
  12. this._dims(style, config);
  13. return ret;
  14. },
  15. _margins: function(style, config) {
  16. if (style.marginLeft != null) {
  17. object.appendOnto(config, {
  18. linePrependor: {
  19. options: {
  20. amount: parseInt(style.marginLeft)
  21. }
  22. }
  23. });
  24. }
  25. if (style.marginRight != null) {
  26. object.appendOnto(config, {
  27. lineAppendor: {
  28. options: {
  29. amount: parseInt(style.marginRight)
  30. }
  31. }
  32. });
  33. }
  34. if (style.marginTop != null) {
  35. object.appendOnto(config, {
  36. blockPrependor: {
  37. options: {
  38. amount: parseInt(style.marginTop)
  39. }
  40. }
  41. });
  42. }
  43. if (style.marginBottom != null) {
  44. object.appendOnto(config, {
  45. blockAppendor: {
  46. options: {
  47. amount: parseInt(style.marginBottom)
  48. }
  49. }
  50. });
  51. }
  52. },
  53. _bullet: function(style, config) {
  54. var after, before, bullet, conf, ref;
  55. if ((style.bullet != null) && style.bullet.enabled) {
  56. bullet = style.bullet;
  57. conf = {};
  58. conf.alignment = style.bullet.alignment;
  59. ref = _common.getStyleTagsFor({
  60. color: bullet.color,
  61. background: bullet.background
  62. }), before = ref.before, after = ref.after;
  63. conf.char = before + bullet.char + after;
  64. object.appendOnto(config, {
  65. linePrependor: {
  66. options: {
  67. bullet: conf
  68. }
  69. }
  70. });
  71. }
  72. },
  73. _dims: function(style, config) {
  74. var w;
  75. if (style.width != null) {
  76. w = parseInt(style.width);
  77. config.width = w;
  78. }
  79. }
  80. };