PageSourceSearch

https://plasticseurope.org/wp-content/themes/plasticseurope-theme/dist/scripts/pillar-tab.js

js plasticseurope.org collected 2026-10-02 02:32:14 UTC 6,071 bytes, 190 lines download raw bytes

1/******/ (function(modules) { // webpackBootstrap
2/******/ 	// The module cache
3/******/ 	var installedModules = {};
4/******/
5/******/ 	// The require function
6/******/ 	function __webpack_require__(moduleId) {
7/******/
8/******/ 		// Check if module is in cache
9/******/ 		if(installedModules[moduleId]) {
10/******/ 			return installedModules[moduleId].exports;
11/******/ 		}
12/******/ 		// Create a new module (and put it into the cache)
13/******/ 		var module = installedModules[moduleId] = {
14/******/ 			i: moduleId,
15/******/ 			l: false,
16/******/ 			exports: {}
17/******/ 		};
18/******/
19/******/ 		// Execute the module function
20/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ 		// Flag the module as loaded
23/******/ 		module.l = true;
24/******/
25/******/ 		// Return the exports of the module
26/******/ 		return module.exports;
27/******/ 	}
28/******/
29/******/
30/******/ 	// expose the modules object (__webpack_modules__)
31/******/ 	__webpack_require__.m = modules;
32/******/
33/******/ 	// expose the module cache
34/******/ 	__webpack_require__.c = installedModules;
35/******/
36/******/ 	// define getter function for harmony exports
37/******/ 	__webpack_require__.d = function(exports, name, getter) {
38/******/ 		if(!__webpack_require__.o(exports, name)) {
39/******/ 			Object.defineProperty(exports, name, {
40/******/ 				configurable: false,
41/******/ 				enumerable: true,
42/******/ 				get: getter
43/******/ 			});
44/******/ 		}
45/******/ 	};
46/******/
47/******/ 	// getDefaultExport function for compatibility with non-harmony modules
48/******/ 	__webpack_require__.n = function(module) {
49/******/ 		var getter = module && module.__esModule ?
50/******/ 			function getDefault() { return module['default']; } :
51/******/ 			function getModuleExports() { return module; };
52/******/ 		__webpack_require__.d(getter, 'a', getter);
53/******/ 		return getter;
54/******/ 	};
55/******/
56/******/ 	// Object.prototype.hasOwnProperty.call
57/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58/******/
59/******/ 	// __webpack_public_path__
60/******/ 	__webpack_require__.p = "/wp-content/themes/plasticseurope-theme/dist/";
61/******/
62/******/ 	// Load entry module and return exports
63/******/ 	return __webpack_require__(__webpack_require__.s = 173);
64/******/ })
65/************************************************************************/
66/******/ ({
67
68/***/ 173:
69/***/ (function(module, exports, __webpack_require__) {
70
71__webpack_require__(174);
72module.exports = __webpack_require__(175);
73
74
75/***/ }),
76
77/***/ 174:
78/***/ (function(module, exports) {
79
80/* eslint no-console: ["error", { allow: ["error"] }] */
81document.addEventListener( 'DOMContentLoaded', function () {
82  var toSvgElements = document.querySelectorAll( '.to-svg img' );
83  var svgReplacementPromises = [];
84
85  toSvgElements.forEach( function ( img ) {
86    var imgSrc = img.getAttribute( 'src' );
87
88    if ( imgSrc && imgSrc.endsWith( '.svg' ) ) {
89      var promise = fetch( imgSrc )
90        .then( function ( response ) { return response.text(); } )
91        .then( function ( data ) {
92          var parser = new window.DOMParser();
93          var svgDoc = parser.parseFromString(
94            data,
95            'image/svg+xml'
96          );
97          var svgElement = svgDoc.querySelector( 'svg' );
98
99          if ( svgElement ) {
100            // Copy over any attributes from the img to the svg
101            svgElement.setAttribute(
102              'class',
103              img.getAttribute( 'class' )
104            );
105            svgElement.setAttribute(
106              'width',
107              img.getAttribute( 'width' )
108            );
109            svgElement.setAttribute(
110              'height',
111              img.getAttribute( 'height' )
112            );
113            svgElement.setAttribute(
114              'alt',
115              img.getAttribute( 'alt' )
116            );
117
118            // Replace img with the inline svg
119            img.parentNode.replaceChild( svgElement, img );
120          }
121        } )
122        .catch( function ( error ) {
123          console.error( 'Error fetching the SVG:', error );
124        } );
125
126      // Add the fetch promise to the array
127      svgReplacementPromises.push( promise );
128    }
129  } );
130
131  // Once all SVGs are replaced, run the tab functionality
132  Promise.all( svgReplacementPromises ).then( function () {
133    var sections = document.querySelectorAll( '.pillar-tabs' );
134
135    sections.forEach( function ( section ) {
136      var divTabOpeners = section.querySelectorAll( 'div.pillar-tab' );
137      var gTabOpeners = section.querySelectorAll( 'g.pillar-tab' );
138      var tabContents = section.querySelectorAll( '.pillar-content' );
139
140      var clearActiveStates = function () {
141        divTabOpeners.forEach( function ( opener ) {
142          opener.classList.remove( 'active' );
143        } );
144        gTabOpeners.forEach( function ( opener ) {
145          opener.classList.remove( 'active' );
146        } );
147        tabContents.forEach( function ( content ) {
148          content.classList.remove( 'active' );
149        } );
150      };
151
152      var activateTab = function ( index ) {
153        tabContents[ index ].classList.add( 'active' );
154      };
155
156      divTabOpeners.forEach( function ( opener, index ) {
157        opener.addEventListener( 'click', function () {
158          clearActiveStates();
159          opener.classList.add( 'active' );
160          if ( gTabOpeners && gTabOpeners[ index ] ) {
161            gTabOpeners[ index ].classList.add( 'active' );
162          }
163          activateTab( index );
164        } );
165      } );
166
167      gTabOpeners.forEach( function ( opener, index ) {
168        opener.addEventListener( 'click', function () {
169          clearActiveStates();
170          opener.classList.add( 'active' );
171          divTabOpeners[ index ].classList.add( 'active' );
172          activateTab( index );
173        } );
174      } );
175    } );
176  } );
177} );
178
179
180/***/ }),
181
182/***/ 175:
183/***/ (function(module, exports) {
184
185// removed by extract-text-webpack-plugin
186
187/***/ })
188
189/******/ });
190//# sourceMappingURL=pillar-tab.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.