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-42.1.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-42.0.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-41.1.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-41.1.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-41.1.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-41.0.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-40.1.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-40.0.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-39.2.5 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-39.2.4 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-39.2.3 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-39.2.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-39.2.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-39.2.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-39.1.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-39.0.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-38.4.2 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-38.1.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-38.1.0 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
govuk_publishing_components-38.0.1 app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js