diff --git a/js/legacy/markdown-it-checkbox.js b/js/legacy/markdown-it-checkbox.js new file mode 100644 index 000000000..3f195748d --- /dev/null +++ b/js/legacy/markdown-it-checkbox.js @@ -0,0 +1,110 @@ +var _, checkboxReplace; + +_ = require('underscore'); + +checkboxReplace = function(md, options, Token) { + "use strict"; + var arrayReplaceAt, createTokens, defaults, lastId, pattern, splitTextToken; + arrayReplaceAt = md.utils.arrayReplaceAt; + lastId = 0; + defaults = { + divWrap: false, + divClass: 'checkbox', + idPrefix: 'checkbox' + }; + options = _.extend(defaults, options); + pattern = /\[(X|\s|\_|\-)\]\s(.*)/i; + createTokens = function(checked, label, Token) { + var id, idNumeric, nodes, token; + nodes = []; + + /** + *
+ */ + if (options.divWrap) { + token = new Token("checkbox_open", "div", 1); + token.attrs = [["class", options.divClass]]; + nodes.push(token); + } + + /** + * + */ + id = options.idPrefix + lastId; + idNumeric = lastId; + lastId += 1; + token = new Token("checkbox_input", "input", 0); + token.attrs = [["type", "checkbox"], ["id", id], ["data-id", idNumeric]]; + if (checked === true) { + token.attrs.push(["checked", "true"]); + } + nodes.push(token); + + /** + *