Sha256: 156a2ead9b7339adf55419d9e200745d6f042ead276a380c89d9dff6004c2482

Contents?: true

Size: 676 Bytes

Versions: 306

Compression:

Stored size: 676 Bytes

Contents

const SLIDE_HEADING_ELEMENTS = document.querySelectorAll('.hero-slider__slider--slide-heading'); // Element from HTML
const regEx = /\*\*(\S+)\*\*/g;
const replacement = '<span class="typography__power-text">$1</span>';

function replaceRegex(el) {
  return el.innerHTML = el.innerHTML.replace(regEx, replacement);
}

function loopOverNodeList(nodeList) {
  for (var i = 0; i < nodeList.length; i++) {
    replaceRegex(nodeList[i]);
  }
}

function wrapPowerText() {
  if ( !document.querySelectorAll('.hero-slider__slider--slide-heading') )
    return; // Bail out of theres no slider in the page.
  loopOverNodeList(SLIDE_HEADING_ELEMENTS);
}

export default wrapPowerText;

Version data entries

306 entries across 306 versions & 2 rubygems

Version Path
kcc-gem-theme-1.25.6 assets/js/theme/src/wrapPowerText.js
kcc-gem-theme-1.25.5 assets/js/theme/src/wrapPowerText.js
kcc-gem-theme-1.24.5 assets/js/theme/src/wrapPowerText.js
kcc-gem-theme-1.23.5 assets/js/theme/src/wrapPowerText.js
kcc-gem-theme-1.22.5 assets/js/theme/src/wrapPowerText.js
kcc-gem-theme-1.21.5 assets/js/theme/src/wrapPowerText.js