
/* ==========================================================================
   Table Row Links

   Mixin for adding row link click functionality to table organism.

   ========================================================================== */

'use strict';

var closest = require( 'atomic-component/src/utilities/dom-closest' ).closest;

var TableRowLinks = {

  events: {
    'click tbody tr': 'onRowLinkClick'
  },

  ui: {
    base: '.o-table__row-links'
  },

  /**
   * Handle a click of the table.
   *
   * @param {Object} event Mouse event for click on the table.
   */
  onRowLinkClick: function( event ) {
    var target = event.target;
    if( target && target.tagName === 'A' ) {
      return
    }
    target = closest( event.target, 'tr' );
    var link = target.querySelector( 'a' );
    if( link ) window.location = link.getAttribute( 'href' );
  },

  /**
   * Handle initilization of Table Row Links. Added for standalone
   * use cases.
   *
   */
  init: function() {
    var elements = document.querySelector( TableRowLinks.ui.base );
    for ( var i = 0; i < elements.length; ++i ) {
      if( elements[i].hasAttribute( 'data-bound' ) === false ) {
        elements[i].addEventListener( 'click', table,
        TableRowLinks.onRowLinkClick );
      }
    }
  }
};

module.exports = TableRowLinks;

@@ -865,426 +865,8 @@
  );%0A
-  %7D,%0A%0A  /**%0A   * Handle initilization of Table Row Links. Added for standalone%0A   * use cases.%0A   *%0A   */%0A  init: function() %7B%0A    var elements = document.querySelector( TableRowLinks.ui.base );%0A    for ( var i = 0; i %3C elements.length; ++i ) %7B%0A      if( elements%5Bi%5D.hasAttribute( 'data-bound' ) === false ) %7B%0A        elements%5Bi%5D.addEventListener( 'click', table,%0A        TableRowLinks.onRowLinkClick );%0A      %7D%0A    %7D%0A
   %7D%0A

Remove table row links init method