Sha256: e6761bbeb04ed73b6a2e3c8b9c8f1ddda340e3021e2a8f39803c89d4ec729da4
Contents?: true
Size: 1 KB
Versions: 44
Compression:
Stored size: 1 KB
Contents
export default class AutoButtonsByPositionComponent { constructor(options = {}) { this.listSelector = options.listSelector; this.hideOnFirstSelector = options.hideOnFirstSelector; this.hideOnLastSelector = options.hideOnLastSelector; this.run(); } run() { const $list = $(this.listSelector); const hideOnFirst = this.hideOnFirstSelector; const hideOnLast = this.hideOnLastSelector; if ($list.length === 1) { const $item = $list.first(); $item.find(hideOnFirst).hide(); $item.find(hideOnLast).hide(); } else { $list.each((idx, el) => { if (el.id === $list.first().attr("id")) { $(el).find(hideOnFirst).hide(); $(el).find(hideOnLast).show(); } else if (el.id === $list.last().attr("id")) { $(el).find(hideOnLast).hide(); $(el).find(hideOnFirst).show(); } else { $(el).find(hideOnLast).show(); $(el).find(hideOnFirst).show(); } }); } } }
Version data entries
44 entries across 44 versions & 1 rubygems