Sha256: ead5a82c61a940821260593b8d7bb1fb67091d42109e5cc1cc433b4cd0f60023

Contents?: true

Size: 1.03 KB

Versions: 357

Compression:

Stored size: 1.03 KB

Contents

import PbEnhancedElement from '../pb_enhanced_element'

export default class PbTable extends PbEnhancedElement {
  static get selector(): string {
    return '.table-responsive-collapse'
  }

  connect(): void {
    const tables = document.querySelectorAll('.table-responsive-collapse');

    // Each Table
    [].forEach.call(tables, (table: HTMLTableElement) => {
      // Header Titles
      const headers: string[] = [];
      [].forEach.call(table.querySelectorAll('th'), (header: HTMLTableCellElement) => {
        const colSpan = header.colSpan
        for (let i = 0; i < colSpan; i++) {
          headers.push(header.textContent.replace(/\r?\n|\r/, ''));
        }
      });

      // for each row in tbody
      [].forEach.call(table.querySelectorAll('tbody tr'), (row: HTMLTableRowElement) => {
        // for each cell
        [].forEach.call(row.cells, (cell: HTMLTableCellElement, headerIndex: number) => {
          // apply the attribute
          cell.setAttribute('data-title', headers[headerIndex])
        })
      })
    })
  }
}

Version data entries

357 entries across 357 versions & 1 rubygems

Version Path
playbook_ui-14.9.0.pre.rc.4 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.9.0.pre.rc.3 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.9.0.pre.rc.2 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4567 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4565 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.alpha.PLAY1598floatinguiupgrade4563 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.alpha.play1648heightglobalprops4559 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.9.0.pre.rc.1 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.alpha.PLAY16254545 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.alpha.PLAY1615movenegativetoleftofcurrencysign4543 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.alpha.PLAY1615movenegativetoleftofcurrencysign4539 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.9.0.pre.rc.0 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.7.0.pre.alpha.dependabotnpmandyarnfloatinguireact026284532 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.7.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4523 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.rc.8 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.rc.7 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.rc.6 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.rc.5 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-14.8.0.pre.rc.4 app/pb_kits/playbook/pb_table/index.ts