Sha256: 7db21fb0583746b50ac1380d59366ebfbe05820feec0fe0310ce89711ea657a9

Contents?: true

Size: 1.01 KB

Versions: 415

Compression:

Stored size: 1.01 KB

Contents

import PbEnhancedElement from '../pb_enhanced_element'

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

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

    // Each Table
    [].forEach.call(tables, (table: HTMLTableElement) => {
      // Header Titles
      let headers: string[] = [];
      [].forEach.call(table.querySelectorAll('th'), (header: HTMLTableCellElement) => {
        let 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

415 entries across 415 versions & 1 rubygems

Version Path
playbook_ui-12.22.0.pre.alpha.PBNTR12checkingemptyfilters686 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.22.0 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.21.0.pre.alpha.PLAY807RTEcustomtoolbar680 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.21.0 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.20.0.pre.alpha.movemarkdown668 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.20.0.pre.alpha.title2667 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.20.0.pre.alpha.title2665 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.20.0 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.19.0.pre.alpha.PLAY699zindexresponsive650 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.19.0.pre.alpha.movemarkdown639 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.19.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown638 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.19.0.pre.alpha.movemarkdown637 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.18.0.pre.alpha.PLAY785typeaheadts632 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.19.0 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-12.18.0.pre.alpha.PLAY735mobileheadersfix616 app/pb_kits/playbook/pb_table/index.ts