Sha256: b4cf429faa8277bbf71036cdfcdcfcae198d08abb9c721884f6101e24254730d
Contents?: true
Size: 720 Bytes
Versions: 44
Compression:
Stored size: 720 Bytes
Contents
export default class AutoLabelByPositionComponent { constructor(options = {}) { this.listSelector = options.listSelector; this.labelSelector = options.labelSelector; this.onPositionComputed = options.onPositionComputed; this.run(); } run() { const $list = $(this.listSelector); $list.each((idx, el) => { const $label = $(el).find(this.labelSelector); const labelContent = $label.html(); if (labelContent.match(/#(\d+)/)) { $label.html(labelContent.replace(/#(\d+)/, `#${idx + 1}`)); } else { $label.html(`${labelContent} #${idx + 1}`); } if (this.onPositionComputed) { this.onPositionComputed(el, idx); } }); } }
Version data entries
44 entries across 44 versions & 1 rubygems