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-13.34.0 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.33.1.pre.alpha.play1407statvaluekitinconsistencies3352 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.33.1.pre.alpha.PLAY14143340 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.33.1.pre.alpha.PLAY14143336 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.33.1.pre.alpha.PLAY14063320 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.33.1 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14143288 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14143272 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14143271 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY1138iconkitaddcolorprop3268 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14143267 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.play1416movealiaslogic3266 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14143264 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14143260 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14143255 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14143251 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.play1416movealiaslogic3239 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.32.0.pre.alpha.PLAY14103236 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.31.0.pre.alpha.play1416movealiaslogic3232 app/pb_kits/playbook/pb_table/index.ts
playbook_ui-13.31.0.pre.alpha.PBNTR342navtabbing3231 app/pb_kits/playbook/pb_table/index.ts