block.js 2.0 KB

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