Sha256: 85b3c7cb681f7343556f77181f7e35ec08a7c1d4f422a01c15311db244645534

Contents?: true

Size: 1.14 KB

Versions: 209

Compression:

Stored size: 1.14 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]
      var magna = new GOVUK.Modules.MagnaCharta($table, { toggleText: 'Change between chart and table' })
      magna.init()
      $table.className = $table.className + ' js-barchart-table-init'
    }
  }

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

Version data entries

209 entries across 209 versions & 1 rubygems

Version Path
govuk_publishing_components-31.2.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-31.1.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-31.1.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-31.1.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-31.0.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.7.3 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.7.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.7.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.7.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.6.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.6.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.5.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.5.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.5.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.4.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.4.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.3.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.2.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.2.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-30.1.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js