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-28.2.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-28.1.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-28.0.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.20.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.19.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.18.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.17.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.16.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.15.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.14.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.14.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.14.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.13.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.12.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.11.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.10.5 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.10.4 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.10.3 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.10.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-27.10.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js