Sha256: dca14825cc8180681c7a5faaada724aa8d9a00b6e42da4fd690dc6beb813d2ca

Contents?: true

Size: 1.13 KB

Versions: 149

Compression:

Stored size: 1.13 KB

Contents

// = require govuk_publishing_components/lib/govspeak/magna-charta

window.GOVUK = window.GOVUK || {};

(function (GOVUK, $) {
  'use strict'

  var BarchartEnhancement = function ($element) {
    this.$element = $element
  }

  BarchartEnhancement.prototype.init = function () {
    var $barchartsOriginal = this.$element.querySelectorAll('.js-barchart-table')
    var $barcharts = []

    for (var j = 0; j < $barchartsOriginal.length; j++) {
      // this prevents the code from initialising more than once
      // we'd use :not selectors for $barchartsOriginal but for lack of IE8 support
      var styles = $barchartsOriginal[j].className
      if (styles.indexOf('mc-chart') === -1 && styles.indexOf('js-barchart-table-init') === -1) {
        $barcharts.push($barchartsOriginal[j])
      }
    }

    for (var i = 0; i < $barcharts.length; i++) {
      var $table = $barcharts[i]
      new GOVUK.Modules.MagnaCharta().start($table, { toggleText: 'Change between chart and table' })
      $table.className = $table.className + ' js-barchart-table-init'
    }
  }

  GOVUK.GovspeakBarchartEnhancement = BarchartEnhancement
}(window.GOVUK, window.jQuery))

Version data entries

149 entries across 149 versions & 1 rubygems

Version Path
govuk_publishing_components-23.15.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.14.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.13.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.13.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.12.3 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.12.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.12.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.12.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.11.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.11.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.10.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.10.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.10.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.9.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.9.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.9.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.8.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.7.7 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.7.6 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-23.7.5 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js