diff options
Diffstat (limited to 'node_modules/renderkid/lib/layout/block/linePrependor')
-rw-r--r-- | node_modules/renderkid/lib/layout/block/linePrependor/Default.js | 58 | ||||
-rw-r--r-- | node_modules/renderkid/lib/layout/block/linePrependor/_LinePrependor.js | 17 |
2 files changed, 75 insertions, 0 deletions
diff --git a/node_modules/renderkid/lib/layout/block/linePrependor/Default.js b/node_modules/renderkid/lib/layout/block/linePrependor/Default.js new file mode 100644 index 000000000..891ffcb8f --- /dev/null +++ b/node_modules/renderkid/lib/layout/block/linePrependor/Default.js @@ -0,0 +1,58 @@ +// Generated by CoffeeScript 1.9.3 +var DefaultLinePrependor, SpecialString, tools, + 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; }, + hasProp = {}.hasOwnProperty; + +tools = require('../../../tools'); + +SpecialString = require('../../SpecialString'); + +module.exports = DefaultLinePrependor = (function(superClass) { + var self; + + extend(DefaultLinePrependor, superClass); + + function DefaultLinePrependor() { + return DefaultLinePrependor.__super__.constructor.apply(this, arguments); + } + + self = DefaultLinePrependor; + + DefaultLinePrependor.pad = function(howMuch) { + return tools.repeatString(" ", howMuch); + }; + + DefaultLinePrependor.prototype._render = function(inherited, options) { + var addToLeft, addToRight, alignment, bullet, char, charLen, diff, left, output, space, toWrite; + if (this._lineNo === 0 && (bullet = this._config.bullet)) { + char = bullet.char; + charLen = SpecialString(char).length; + alignment = bullet.alignment; + space = this._config.amount; + toWrite = char; + addToLeft = ''; + addToRight = ''; + if (space > charLen) { + diff = space - charLen; + if (alignment === 'right') { + addToLeft = self.pad(diff); + } else if (alignment === 'left') { + addToRight = self.pad(diff); + } else if (alignment === 'center') { + left = Math.round(diff / 2); + addToLeft = self.pad(left); + addToRight = self.pad(diff - left); + } else { + throw Error("Unkown alignment `" + alignment + "`"); + } + } + output = addToLeft + char + addToRight; + } else { + output = self.pad(this._config.amount); + } + return inherited + output; + }; + + return DefaultLinePrependor; + +})(require('./_LinePrependor')); diff --git a/node_modules/renderkid/lib/layout/block/linePrependor/_LinePrependor.js b/node_modules/renderkid/lib/layout/block/linePrependor/_LinePrependor.js new file mode 100644 index 000000000..cd6821af9 --- /dev/null +++ b/node_modules/renderkid/lib/layout/block/linePrependor/_LinePrependor.js @@ -0,0 +1,17 @@ +// Generated by CoffeeScript 1.9.3 +var _LinePrependor; + +module.exports = _LinePrependor = (function() { + function _LinePrependor(_config) { + this._config = _config; + this._lineNo = -1; + } + + _LinePrependor.prototype.render = function(inherited, options) { + this._lineNo++; + return '<none>' + this._render(inherited, options) + '</none>'; + }; + + return _LinePrependor; + +})(); |