{ "version": 3, "sources": ["../../src/scripts/grid.js"], "sourcesContent": ["/* eslint-disable indent */\nlet logichop_var; //jQuery\n\nlet isOpened = false;\nconst siteurl = encodeURI(window.location.protocol + \"//\" + window.location.host + \"/wp-json\");\nconst removeClass = \"faux-remove\";\nconst logichop_custom_vars = typeof logichop_var === \"function\" ? logichop_var(\"Custom\") : \"\";\nconst condition = logichop_custom_vars.Condition_Met;\nconst mql = window.matchMedia(\"(min-width: 64em)\");\n\nfunction scrollToInfo(postid, pos) {\n\tlet el = document.getElementById(postid);\n\tpos = pos || \"center\";\n\t// scroll to selected item\n\tel.scrollIntoView({\n\t\tblock: pos,\n\t});\n}\n\nfunction triggerProductShowHideInfo() {\n\t// now we will listen for click on the buttons\n\tdocument.querySelectorAll(\".grid-item-expand-trigger\").forEach((targetItem) => {\n\t\ttargetItem.addEventListener(\n\t\t\t\"click\",\n\t\t\t(e) => {\n\t\t\t\t// find the parent container\n\t\t\t\tlet parent = e.target.closest(\".grid-item-figure\");\n\t\t\t\t// post id\n\t\t\t\tlet postid = parent.getAttribute(\"data-postid\");\n\t\t\t\t// if no content is expanded:\n\t\t\t\tif (!isOpened) {\n\t\t\t\t\tparent.classList.add(\"expanded-parent\");\n\t\t\t\t\t// load the product template\n\t\t\t\t\tdocument.getElementById(postid).classList.remove(\"faux-remove\");\n\t\t\t\t\t// set the flag appropriately\n\t\t\t\t\tisOpened = true;\n\t\t\t\t\t// return the flag and close the loop\n\t\t\t\t\treturn isOpened;\n\t\t\t\t\t// otherwise, continue through the loop:\n\t\t\t\t\t// if user clicks on an element with content already expanded\n\t\t\t\t\t// which means the user wants to close the expanded content\n\t\t\t\t} else if (isOpened && parent.classList.contains(\"expanded-parent\")) {\n\t\t\t\t\t// remove the class from the parent container\n\t\t\t\t\tparent.classList.remove(\"expanded-parent\");\n\t\t\t\t\t// hide the actual expanded content row from the DOM\n\t\t\t\t\t// prevent another ajax request for already requested item\n\t\t\t\t\tdocument.getElementById(postid).classList.add(removeClass);\n\t\t\t\t\t// scroll back to parent after closing\n\t\t\t\t\tscrollToInfo(\"product-\" + postid, \"start\");\n\t\t\t\t\t// set the flag appropriately\n\t\t\t\t\tisOpened = false;\n\t\t\t\t\t// return the flag and close the loop\n\t\t\t\t\treturn isOpened;\n\t\t\t\t\t// otherwise, continue through the loop:\n\t\t\t\t\t// if user wants to expand new content, but there is already a different expanded container\n\t\t\t\t} else if (isOpened) {\n\t\t\t\t\tlet currentParent = document.querySelector(\".expanded-parent\");\n\t\t\t\t\tif (currentParent !== null) {\n\t\t\t\t\t\tcurrentParent.classList.remove(\"expanded-parent\");\n\t\t\t\t\t\t// hide the current expanded content row from the DOM\n\t\t\t\t\t\t// prevent another ajax request for already requested item\n\t\t\t\t\t\tdocument.getElementById(currentParent.getAttribute(\"data-postid\")).classList.add(removeClass);\n\t\t\t\t\t}\n\t\t\t\t\t// we place the following within a timer here so that the calculations will occur *after* the currently expanded container (clone)\n\t\t\t\t\t// is removed from the DOM, otherwise the row count could be wrong\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tparent.classList.add(\"expanded-parent\");\n\t\t\t\t\t\tdocument.getElementById(postid).classList.remove(\"faux-remove\");\n\t\t\t\t\t\t// set the flag appropriately\n\t\t\t\t\t\tisOpened = true;\n\t\t\t\t\t\t// return the flag and close the loop\n\t\t\t\t\t\treturn isOpened;\n\t\t\t\t\t}, 0);\n\t\t\t\t}\n\t\t\t},\n\t\t\tfalse,\n\t\t);\n\t});\n}\n\n(function ($) {\n\tvar filtersPresent = document.getElementsByClassName(\"grid-filters\");\n\tif (filtersPresent.length > 0) {\n\t\t$(document).on(\"facetwp-loaded\", function () {\n\t\t\tlet FWP = window.FWP;\n\t\t\t$.each(FWP.settings.num_choices, function (key, val) {\n\t\t\t\tlet $wrapper = $('[data-filter-value=\"' + key + '\"]');\n\t\t\t\t// 0 === val ? $wrapper.hide() : $wrapper.show();\n\t\t\t});\n\t\t\tif (mql.matches) {\n\t\t\t\ttriggerProductShowHideInf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AM,EAAE,UAAU,OAAO,aAAa,EAE9DP,EAAW,GAEJA,CAqCT,EACA,EACD,CACD,CAAC,CACF,EAEC,SAAUe,EAAG,CACb,IAAIC,EAAiB,SAAS,uBAAuB,cAAc,EAC/DA,EAAe,OAAS,EAC3BD,EAAE,QAAQ,EAAE,GAAG,iBAAkB,UAAY,CAC5C,IAAIE,EAAM,OAAO,IACjBF,EAAE,KAAKE,EAAI,SAAS,YAAa,SAAUC,EAAKC,EAAK,CACpD,IAAIC,EAAWL,EAAE,uBAAyBG,EAAM,IAAI,CAErD,CAAC,EACGb,EAAI,SACPK,EAA2B,CAE7B,CAAC,EAEGL,EAAI,SACPK,EAA2B,CAG9B,GAAG,MAAM", "names": ["logichop_var", "isOpened", "siteurl", "removeClass", "logichop_custom_vars", "condition", "mql", "scrollToInfo", "postid", "pos", "el", "triggerProductShowHideInfo", "targetItem", "e", "parent", "currentParent", "$", "filtersPresent", "FWP", "key", "val", "$wrapper"] }