-
{{ block.settings.content }}
+
+
{{ block.settings.content }}
{%- endif -%}
@@ -191,165 +189,15 @@
{%- comment -%} ------------------ THE JS ----------------- {%- endcomment -%}
-{% javascript %}
-
-(function FAQ(SD) {
- 'use strict';
-
- var support = getSupport();
- var sectionsIds = getSectionIds('data-faq-config');
- var sectionInit = compose(publicAPI, setEvents, getBlocks, getConfig);
- var sections = sectionsIds.map(sectionInit);
-
- SD.faq = zipObj(sectionsIds, sections);
-
- function publicAPI(config) {
- return {
- id: config.sectionId,
- config: config,
- blocks: zipObj(config.blockIds, config.blocks),
- init: sectionInit
- }
- }
-
- //**************************
-
-
- function blockEvents(block) {
- block.trigger.addEventListener('click', function triggerClick() { toggle(block) });
- }
-
- function toggle(block) {
- block.collapsed ? expand(block) : collapse(block);
- }
-
- function expand(block) {
- block.button.setAttribute('aria-expanded', true);
- block.panel.removeAttribute('hidden');
- animate(block.panel, 'normal');
- return block;
- }
-
- function collapse(block) {
- block.button.setAttribute('aria-expanded', false);
- block.panel.setAttribute('hidden', '');
- animate(block.panel, 'reverse');
- return block;
- }
-
- function isCollapsed(block) {
- return (attr('aria-expanded', block.button) === 'false');
- }
-
- function animate(element, direction) {
- if (!support.WebAnimations) return;
-
- element.setAttribute('data-is-animating', true);
-
- element.animate([
- { height: 0 },
- { height: element.offsetHeight + 'px' }],
-
- { duration: 240,
- fill: 'both',
- easing: 'cubic-bezier(0.4, 0.0, 0.2, 1)',
- direction: direction
- }
-
- ).onfinish = function() {
- element.removeAttribute('data-is-animating');
- this.cancel();
- };
- }
-
- //**************************
-
-
- function getBlocks(config) {
- config.blocks = config.blockIds.map(block);
- return config;
- }
-
- function block(blockId) {
- return {
- trigger: document.querySelector('[data-faq-trigger="' + blockId + '"]'),
- button: document.querySelector('[data-faq-button="' + blockId + '"]'),
- panel: document.querySelector('[data-faq-panel="' + blockId + '"]'),
-
- get collapsed() { return isCollapsed(this) },
- select: function select() { return expand(this) },
- deselect: function deselect() { return collapse(this) }
- }
- }
-
- function setEvents(config) {
- config.blocks.forEach(blockEvents);
- return config;
- }
-
- function getSectionIds(sectionAttr) {
- var sectionConfigAttr = ['[',sectionAttr,']'].join('');
-
- return nodeList(sectionConfigAttr).map(
- function sectionId(element) {
- return element.getAttribute(sectionAttr);
- }
- );
- }
-
- function getConfig(sectionId) {
- return JSON.parse(document.querySelector('[data-faq-config="' + sectionId + '"]').innerHTML);
- }
-
- //**************************
-
-
- function nodeList(str, root) {
- if (!root) root = document;
- var nodeList = root.querySelectorAll(str);
- return Array.prototype.slice.call(nodeList);
- }
-
- function attr(str, element) {
- return element.getAttribute(str);
- }
-
- function zipObj(keys, values) {
- return keys.reduce(
- function zipObj(acc, key, idx) {
- acc[key] = values[idx];
- return acc;
- }, {}
- )
- }
-
- function compose() {
- var funcs = Array.prototype.slice.call(arguments).reverse();
- return function() {
- return funcs.slice(1).reduce(function(res, fn) {
- return fn(res);
- }, funcs[0].apply(undefined, arguments));
- };
- }
-
- function getSupport() {
- return {
- WebAnimations: (typeof Element.prototype.animate === 'function')
- }
- }
-
-})(window.SectionsDesign = window.SectionsDesign || {})
-
-{% endjavascript %}
+
{%- comment -%} ---------------- THE NO-JS ---------------- {%- endcomment -%}
@@ -382,7 +230,7 @@
(evt.type === 'shopify:block:select')
? block.select()
- : block.deselect()
+ : block.deselect();
}
})(window.SectionsDesign = window.SectionsDesign || {});