UNPKG

@mikezimm/npmfunctions

Version:
54 lines 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.minimizeHeader = void 0; var FPSDocument_1 = require("./FPSDocument"); /** * This minimizes the header on site pages where you do not want the Page Title at the top. originally copied from Pivot Tiles * * @param document * @param minimize * @param alertError * @param consoleResult */ function minimizeHeader(document, minimize, alertError, consoleResult) { if (alertError === void 0) { alertError = true; } if (consoleResult === void 0) { consoleResult = false; } var fpsWindowProps = (0, FPSDocument_1.createFPSWindowProps)(); //If this was already attempted, then exit if (fpsWindowProps.header.attempted === true) { return; } else if (minimize !== true) { return; } else { fpsWindowProps.header.attempted = true; } var height = minimize === true ? '0px' : null; var divs = document.querySelectorAll('[data-automation-id="pageHeader"]'); console.log("divs.length: ", divs.length); //inspiration from: https://reactgo.com/select-element-data-attribute-js/ divs.forEach(function (el) { try { if (el.style) { el.style.height = height; } else { el.style = { height: height }; } if (consoleResult === true) { console.log('minimizeHeader: set minimize to ', minimize); } fpsWindowProps.header.success++; } catch (e) { if (alertError === true) { alert('minimizeHeader: Could not find element with data-automation-id="pageHeader"'); } console.log('minimizeHeader: Could not find element with data-automation-id="pageHeader"'); fpsWindowProps.header.errors++; } }); } exports.minimizeHeader = minimizeHeader; //# sourceMappingURL=minimzeHeader.js.map