@afixt/test-utils 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +2 -1
- package/.github/dependabot.yml +36 -0
- package/.github/workflows/ci.yml +71 -0
- package/.github/workflows/security.yml +142 -0
- package/.husky/pre-commit +1 -0
- package/.jscpd.json +27 -0
- package/.markdownlint.json +9 -0
- package/.prettierignore +13 -0
- package/.prettierrc +10 -0
- package/docs/arrayUtils.js.html +2 -2
- package/docs/domUtils.js.html +2 -2
- package/docs/getAccessibleName.js.html +2 -2
- package/docs/getAccessibleText.js.html +2 -2
- package/docs/getAriaAttributesByElement.js.html +2 -2
- package/docs/getCSSGeneratedContent.js.html +2 -2
- package/docs/getComputedRole.js.html +2 -2
- package/docs/getFocusableElements.js.html +2 -2
- package/docs/getGeneratedContent.js.html +2 -2
- package/docs/getImageText.js.html +2 -2
- package/docs/getStyleObject.js.html +2 -2
- package/docs/global.html +2 -2
- package/docs/hasAccessibleName.js.html +2 -2
- package/docs/hasAttribute.js.html +2 -2
- package/docs/hasCSSGeneratedContent.js.html +2 -2
- package/docs/hasHiddenParent.js.html +2 -2
- package/docs/hasParent.js.html +2 -2
- package/docs/hasValidAriaAttributes.js.html +2 -2
- package/docs/hasValidAriaRole.js.html +2 -2
- package/docs/index.html +2 -2
- package/docs/index.js.html +2 -2
- package/docs/isAriaAttributesValid.js.html +2 -2
- package/docs/isComplexTable.js.html +2 -2
- package/docs/isDataTable.js.html +2 -2
- package/docs/isFocusable.js.html +2 -2
- package/docs/isHidden.js.html +2 -2
- package/docs/isOffScreen.js.html +2 -2
- package/docs/isValidUrl.js.html +2 -2
- package/docs/isVisible.js.html +2 -2
- package/docs/module-afixt-test-utils.html +2 -2
- package/docs/scripts/core.js +726 -726
- package/docs/scripts/core.min.js +22 -22
- package/docs/scripts/resize.js +90 -90
- package/docs/scripts/search.js +265 -265
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -202
- package/docs/scripts/third-party/fuse.js +8 -8
- package/docs/scripts/third-party/hljs-line-num-original.js +369 -369
- package/docs/scripts/third-party/hljs-original.js +5171 -5171
- package/docs/scripts/third-party/popper.js +5 -5
- package/docs/scripts/third-party/tippy.js +1 -1
- package/docs/scripts/third-party/tocbot.js +671 -671
- package/docs/styles/clean-jsdoc-theme-base.css +1159 -1159
- package/docs/styles/clean-jsdoc-theme-dark.css +412 -412
- package/docs/styles/clean-jsdoc-theme-light.css +482 -482
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +29 -29
- package/docs/testContrast.js.html +2 -2
- package/docs/testLang.js.html +2 -2
- package/docs/testOrder.js.html +2 -2
- package/eslint.config.mjs +84 -0
- package/package.json +68 -41
- package/scratchpads/issue-6-standardize-repo.md +109 -0
- package/src/getAccessibleName.js +156 -112
- package/src/getAccessibleText.js +71 -42
- package/test/getAccessibleName.test.js +379 -315
- package/test/getAccessibleText.test.js +375 -308
- package/.eslintrc +0 -78
- package/.github/workflows/test.yml +0 -26
package/docs/scripts/core.min.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var accordionLocalStorageKey="accordion-id",themeLocalStorageKey="theme",fontSizeLocalStorageKey="font-size",html=document.querySelector("html"),MAX_FONT_SIZE=30,MIN_FONT_SIZE=10,localStorage=window.localStorage;function getTheme(){var e=localStorage.getItem(themeLocalStorageKey);if(e)return e;switch(e=document.body.getAttribute("data-theme")){case"dark":case"light":return e;case"fallback-dark":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";case"fallback-light":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";default:return"dark"}}function localUpdateTheme(e){var t=document.body,o=document.querySelectorAll(".theme-svg-use"),n="dark"===e?"#light-theme-icon":"#dark-theme-icon";t.setAttribute("data-theme",e),t.classList.remove("dark","light"),t.classList.add(e),o.forEach(function(e){e.setAttribute("xlink:href",n)})}function updateTheme(e){localUpdateTheme(e),localStorage.setItem(themeLocalStorageKey,e)}function toggleTheme(){updateTheme("dark"===document.body.getAttribute("data-theme")?"light":"dark")}function setAccordionIdToLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));t[e]=e,localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function removeAccordionIdFromLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));delete t[e],localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function getAccordionIdsFromLocalStorage(){return JSON.parse(localStorage.getItem(accordionLocalStorageKey))||{}}function toggleAccordion(e){"false"===e.getAttribute("data-isopen")?(e.setAttribute("data-isopen","true"),setAccordionIdToLocalStorage(e.id)):(e.setAttribute("data-isopen","false"),removeAccordionIdFromLocalStorage(e.id))}function initAccordion(){void 0!==localStorage.getItem(accordionLocalStorageKey)&&null!==localStorage.getItem(accordionLocalStorageKey)||localStorage.setItem(accordionLocalStorageKey,"{}");var e=document.querySelectorAll(".sidebar-section-title"),t=getAccordionIdsFromLocalStorage();e.forEach(function(e){e.addEventListener("click",function(){toggleAccordion(e)}),e.id in t&&toggleAccordion(e)})}function isSourcePage(){return Boolean(document.querySelector("#source-page"))}function bringElementIntoView(e,t=!0){var o,n,i,c;e&&(tocbotInstance&&setTimeout(()=>tocbotInstance.updateTocListActiveElement(e),60),o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16,o&&(c+=o.scrollHeight),n&&n.scrollBy(0,i-c),t&&history.pushState(null,null,"#"+e.id))}function bringLinkToView(e){e.preventDefault(),e.stopPropagation();var e=e.currentTarget.getAttribute("href");!e||(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e)}function bringIdToViewOnMount(){var e,t;isSourcePage()||""!==(e=window.location.hash)&&((t=document.getElementById(e.slice(1)))||(e=decodeURI(e),t=document.getElementById(e.slice(1))),t&&bringElementIntoView(t,!1))}function createAnchorElement(e){var t=document.createElement("a");return t.textContent="#",t.href="#"+e,t.classList.add("link-anchor"),t.onclick=bringLinkToView,t}function addAnchor(){var e=document.querySelector(".main-content").querySelector("section");[e.querySelectorAll("h1"),e.querySelectorAll("h2"),e.querySelectorAll("h3"),e.querySelectorAll("h4")].forEach(function(e){e.forEach(function(e){var t=createAnchorElement(e.id);e.classList.add("has-anchor"),e.append(t)})})}function copy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function showTooltip(e){var t=document.getElementById(e);t.classList.add("show-tooltip"),setTimeout(function(){t.classList.remove("show-tooltip")},3e3)}function copyFunction(e){var t=document.getElementById(e);copy((t.querySelector(".linenums")||t.querySelector("code")).innerText.trim().replace(/(^\t)/gm,"")),showTooltip("tooltip-"+e)}function hideTocOnSourcePage(){isSourcePage()&&(document.querySelector(".toc-container").style.display="none")}function getPreTopBar(e,t=""){e='<button aria-label="copy code" class="icon-button copy-code" onclick="copyFunction(\''+e+'\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>'+('<div class="tooltip" id="tooltip-'+e+'">Copied!</div>')+"</button>";return'<div class="pre-top-bar-container">'+('<div class="code-lang-name-container"><div class="code-lang-name">'+t.toLocaleUpperCase()+"</div></div>")+e+"</div>"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.appendChild(e))})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function localUpdateFontSize(e){html.style.fontSize=e+"px";var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function updateFontSize(e){localUpdateFontSize(e),localStorage.setItem(fontSizeLocalStorageKey,e)}function incrementFont(e){var t=getFontSize();t<MAX_FONT_SIZE&&updateFontSize(t+1)}function decrementFont(e){var t=getFontSize();MIN_FONT_SIZE<t&&updateFontSize(t-1)}function fontSizeTooltip(){var e=getFontSize();return`
|
|
2
|
-
<div class="font-size-tooltip">
|
|
3
|
-
<button aria-label="decrease-font-size" class="icon-button ${MAX_FONT_SIZE<=e?"disabled":""}" onclick="decrementFont(event)">
|
|
4
|
-
<svg>
|
|
5
|
-
<use xlink:href="#minus-icon"></use>
|
|
6
|
-
</svg>
|
|
7
|
-
</button>
|
|
8
|
-
<div class="font-size-text" id="b77a68a492f343baabea06fad81f651e">
|
|
9
|
-
${e}
|
|
10
|
-
</div>
|
|
11
|
-
<button aria-label="increase-font-size" class="icon-button ${e<=MIN_FONT_SIZE?"disabled":""}" onclick="incrementFont(event)">
|
|
12
|
-
<svg>
|
|
13
|
-
<use xlink:href="#add-icon"></use>
|
|
14
|
-
</svg>
|
|
15
|
-
</button>
|
|
16
|
-
<button class="icon-button" onclick="updateFontSize(16)">
|
|
17
|
-
<svg>
|
|
18
|
-
<use xlink:href="#reset-icon"></use>
|
|
19
|
-
</svg>
|
|
20
|
-
</button>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
1
|
+
var accordionLocalStorageKey="accordion-id",themeLocalStorageKey="theme",fontSizeLocalStorageKey="font-size",html=document.querySelector("html"),MAX_FONT_SIZE=30,MIN_FONT_SIZE=10,localStorage=window.localStorage;function getTheme(){var e=localStorage.getItem(themeLocalStorageKey);if(e)return e;switch(e=document.body.getAttribute("data-theme")){case"dark":case"light":return e;case"fallback-dark":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";case"fallback-light":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";default:return"dark"}}function localUpdateTheme(e){var t=document.body,o=document.querySelectorAll(".theme-svg-use"),n="dark"===e?"#light-theme-icon":"#dark-theme-icon";t.setAttribute("data-theme",e),t.classList.remove("dark","light"),t.classList.add(e),o.forEach(function(e){e.setAttribute("xlink:href",n)})}function updateTheme(e){localUpdateTheme(e),localStorage.setItem(themeLocalStorageKey,e)}function toggleTheme(){updateTheme("dark"===document.body.getAttribute("data-theme")?"light":"dark")}function setAccordionIdToLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));t[e]=e,localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function removeAccordionIdFromLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));delete t[e],localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function getAccordionIdsFromLocalStorage(){return JSON.parse(localStorage.getItem(accordionLocalStorageKey))||{}}function toggleAccordion(e){"false"===e.getAttribute("data-isopen")?(e.setAttribute("data-isopen","true"),setAccordionIdToLocalStorage(e.id)):(e.setAttribute("data-isopen","false"),removeAccordionIdFromLocalStorage(e.id))}function initAccordion(){void 0!==localStorage.getItem(accordionLocalStorageKey)&&null!==localStorage.getItem(accordionLocalStorageKey)||localStorage.setItem(accordionLocalStorageKey,"{}");var e=document.querySelectorAll(".sidebar-section-title"),t=getAccordionIdsFromLocalStorage();e.forEach(function(e){e.addEventListener("click",function(){toggleAccordion(e)}),e.id in t&&toggleAccordion(e)})}function isSourcePage(){return Boolean(document.querySelector("#source-page"))}function bringElementIntoView(e,t=!0){var o,n,i,c;e&&(tocbotInstance&&setTimeout(()=>tocbotInstance.updateTocListActiveElement(e),60),o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16,o&&(c+=o.scrollHeight),n&&n.scrollBy(0,i-c),t&&history.pushState(null,null,"#"+e.id))}function bringLinkToView(e){e.preventDefault(),e.stopPropagation();var e=e.currentTarget.getAttribute("href");!e||(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e)}function bringIdToViewOnMount(){var e,t;isSourcePage()||""!==(e=window.location.hash)&&((t=document.getElementById(e.slice(1)))||(e=decodeURI(e),t=document.getElementById(e.slice(1))),t&&bringElementIntoView(t,!1))}function createAnchorElement(e){var t=document.createElement("a");return t.textContent="#",t.href="#"+e,t.classList.add("link-anchor"),t.onclick=bringLinkToView,t}function addAnchor(){var e=document.querySelector(".main-content").querySelector("section");[e.querySelectorAll("h1"),e.querySelectorAll("h2"),e.querySelectorAll("h3"),e.querySelectorAll("h4")].forEach(function(e){e.forEach(function(e){var t=createAnchorElement(e.id);e.classList.add("has-anchor"),e.append(t)})})}function copy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function showTooltip(e){var t=document.getElementById(e);t.classList.add("show-tooltip"),setTimeout(function(){t.classList.remove("show-tooltip")},3e3)}function copyFunction(e){var t=document.getElementById(e);copy((t.querySelector(".linenums")||t.querySelector("code")).innerText.trim().replace(/(^\t)/gm,"")),showTooltip("tooltip-"+e)}function hideTocOnSourcePage(){isSourcePage()&&(document.querySelector(".toc-container").style.display="none")}function getPreTopBar(e,t=""){e='<button aria-label="copy code" class="icon-button copy-code" onclick="copyFunction(\''+e+'\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>'+('<div class="tooltip" id="tooltip-'+e+'">Copied!</div>')+"</button>";return'<div class="pre-top-bar-container">'+('<div class="code-lang-name-container"><div class="code-lang-name">'+t.toLocaleUpperCase()+"</div></div>")+e+"</div>"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.appendChild(e))})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function localUpdateFontSize(e){html.style.fontSize=e+"px";var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function updateFontSize(e){localUpdateFontSize(e),localStorage.setItem(fontSizeLocalStorageKey,e)}function incrementFont(e){var t=getFontSize();t<MAX_FONT_SIZE&&updateFontSize(t+1)}function decrementFont(e){var t=getFontSize();MIN_FONT_SIZE<t&&updateFontSize(t-1)}function fontSizeTooltip(){var e=getFontSize();return`
|
|
2
|
+
<div class="font-size-tooltip">
|
|
3
|
+
<button aria-label="decrease-font-size" class="icon-button ${MAX_FONT_SIZE<=e?"disabled":""}" onclick="decrementFont(event)">
|
|
4
|
+
<svg>
|
|
5
|
+
<use xlink:href="#minus-icon"></use>
|
|
6
|
+
</svg>
|
|
7
|
+
</button>
|
|
8
|
+
<div class="font-size-text" id="b77a68a492f343baabea06fad81f651e">
|
|
9
|
+
${e}
|
|
10
|
+
</div>
|
|
11
|
+
<button aria-label="increase-font-size" class="icon-button ${e<=MIN_FONT_SIZE?"disabled":""}" onclick="incrementFont(event)">
|
|
12
|
+
<svg>
|
|
13
|
+
<use xlink:href="#add-icon"></use>
|
|
14
|
+
</svg>
|
|
15
|
+
</button>
|
|
16
|
+
<button class="icon-button" onclick="updateFontSize(16)">
|
|
17
|
+
<svg>
|
|
18
|
+
<use xlink:href="#reset-icon"></use>
|
|
19
|
+
</svg>
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
23
|
`}function initTooltip(){tippy(".theme-toggle",{content:"Toggle Theme",delay:500}),tippy(".search-button",{content:"Search",delay:500}),tippy(".font-size",{content:"Change font size",delay:500}),tippy(".codepen-button",{content:"Open code in CodePen",placement:"left"}),tippy(".copy-code",{content:"Copy this code",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){for(const t of document.querySelectorAll("table")){if(t.classList.contains("hljs-ln"))return;var e=document.createElement("div");e.classList.add("table-div"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}function hideMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.remove("show"),t&&t.setAttribute("data-isopen","false"),o&&o.setAttribute("xlink:href","#menu-icon")}function showMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.add("show"),t&&t.setAttribute("data-isopen","true"),o&&o.setAttribute("xlink:href","#close-icon")}function onMobileMenuClick(){("true"===document.querySelector("#mobile-menu").getAttribute("data-isopen")?hideMobileMenu:showMobileMenu)()}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function addHrefToSidebarTitle(){document.querySelectorAll(".sidebar-title-anchor").forEach(function(e){e.setAttribute("href",baseURL)})}function highlightActiveLinkInSidebar(){var e=document.location.href.split("/");const t=decodeURI(e[e.length-1]);let o=document.querySelector(`.sidebar a[href*='${t}']`);if(!o)try{o=document.querySelector(`.sidebar a[href*='${t.split("#")[0]}']`)}catch(e){return void console.error(e)}o&&(o.parentElement.classList.add("active"),o.scrollIntoView())}function onDomContentLoaded(){var e=document.querySelectorAll(".theme-toggle");initMobileMenu(),e&&e.forEach(function(e){e.addEventListener("click",toggleTheme)}),hljs.addPlugin({"after:highlightElement":function(e){e.el.parentNode.setAttribute("data-lang","code")}}),hljs.highlightAll(),hljs.initLineNumbersOnLoad({singleLine:!0}),initAccordion(),addAnchor(),processAllPre(),hideTocOnSourcePage(),setTimeout(function(){bringIdToViewOnMount(),isSourcePage()&&highlightAndBringLineIntoView()},1e3),initTooltip(),fixTable(),addHrefToSidebarTitle(),highlightActiveLinkInSidebar()}updateTheme(getTheme()),function(){var e=getFontSize(),t=localStorage.getItem(fontSizeLocalStorageKey);t?(t=Number.parseInt(t,10))!==e&&updateFontSize(t):updateFontSize(e)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",e=>{e=new URL(e.newURL);""!==e.hash&&bringIdToViewOnMount(e.hash)}),window.addEventListener("storage",e=>{"undefined"!==e.newValue&&(initTooltip(),e.key===themeLocalStorageKey&&localUpdateTheme(e.newValue),e.key===fontSizeLocalStorageKey&&localUpdateFontSize(e.newValue))});
|
package/docs/scripts/resize.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
// This file is @deprecated
|
|
3
|
-
|
|
4
|
-
var NAVBAR_OPTIONS = {};
|
|
5
|
-
|
|
6
|
-
(function() {
|
|
7
|
-
var NAVBAR_RESIZE_LOCAL_STORAGE_KEY = 'NAVBAR_RESIZE_LOCAL_STORAGE_KEY';
|
|
8
|
-
|
|
9
|
-
var navbar = document.querySelector('#navbar');
|
|
10
|
-
var footer = document.querySelector('#footer');
|
|
11
|
-
var mainSection = document.querySelector('#main');
|
|
12
|
-
var localStorageResizeObject = JSON.parse(
|
|
13
|
-
// eslint-disable-next-line no-undef
|
|
14
|
-
localStorage.getItem(NAVBAR_RESIZE_LOCAL_STORAGE_KEY)
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Check whether we have any resize value in local storage or not.
|
|
19
|
-
* If we have resize value then resize the navbar.
|
|
20
|
-
**/
|
|
21
|
-
if (localStorageResizeObject) {
|
|
22
|
-
navbar.style.width = localStorageResizeObject.width;
|
|
23
|
-
mainSection.style.marginLeft = localStorageResizeObject.width;
|
|
24
|
-
footer.style.marginLeft = localStorageResizeObject.width;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var navbarSlider = document.querySelector('#navbar-resize');
|
|
28
|
-
|
|
29
|
-
function resizeNavbar(event) {
|
|
30
|
-
var pageX = event.pageX,
|
|
31
|
-
pageXPlusPx = event.pageX + 'px',
|
|
32
|
-
min = Number.parseInt(NAVBAR_OPTIONS.min, 10) || 300,
|
|
33
|
-
max = Number.parseInt(NAVBAR_OPTIONS.max, 10) || 600;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Just to add some checks. If min is smaller than 10 then
|
|
37
|
-
* user may accidentally end up reducing the size of navbar
|
|
38
|
-
* less than 10. In that case user will not able to resize navbar
|
|
39
|
-
* because navbar slider will be hidden.
|
|
40
|
-
*/
|
|
41
|
-
if (min < 10) {
|
|
42
|
-
min = 10;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Only resize if pageX in range between min and max
|
|
47
|
-
* allowed value.
|
|
48
|
-
*/
|
|
49
|
-
if (min < pageX && pageX < max) {
|
|
50
|
-
navbar.style.width = pageXPlusPx;
|
|
51
|
-
mainSection.style.marginLeft = pageXPlusPx;
|
|
52
|
-
footer.style.marginLeft = pageXPlusPx;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function setupEventListeners() {
|
|
57
|
-
// eslint-disable-next-line no-undef
|
|
58
|
-
window.addEventListener('mousemove', resizeNavbar);
|
|
59
|
-
// eslint-disable-next-line no-undef
|
|
60
|
-
window.addEventListener('touchmove', resizeNavbar);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function afterRemovingEventListeners() {
|
|
64
|
-
// eslint-disable-next-line no-undef
|
|
65
|
-
localStorage.setItem(
|
|
66
|
-
NAVBAR_RESIZE_LOCAL_STORAGE_KEY,
|
|
67
|
-
JSON.stringify({
|
|
68
|
-
width: navbar.style.width
|
|
69
|
-
})
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function removeEventListeners() {
|
|
74
|
-
// eslint-disable-next-line no-undef
|
|
75
|
-
window.removeEventListener('mousemove', resizeNavbar);
|
|
76
|
-
// eslint-disable-next-line no-undef
|
|
77
|
-
window.removeEventListener('touchend', resizeNavbar);
|
|
78
|
-
afterRemovingEventListeners();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
navbarSlider.addEventListener('mousedown', setupEventListeners);
|
|
82
|
-
navbarSlider.addEventListener('touchstart', setupEventListeners);
|
|
83
|
-
// eslint-disable-next-line no-undef
|
|
84
|
-
window.addEventListener('mouseup', removeEventListeners);
|
|
85
|
-
})();
|
|
86
|
-
|
|
87
|
-
// eslint-disable-next-line no-unused-vars
|
|
88
|
-
function setupResizeOptions(options) {
|
|
89
|
-
NAVBAR_OPTIONS = options;
|
|
90
|
-
}
|
|
1
|
+
/* global document */
|
|
2
|
+
// This file is @deprecated
|
|
3
|
+
|
|
4
|
+
var NAVBAR_OPTIONS = {};
|
|
5
|
+
|
|
6
|
+
(function() {
|
|
7
|
+
var NAVBAR_RESIZE_LOCAL_STORAGE_KEY = 'NAVBAR_RESIZE_LOCAL_STORAGE_KEY';
|
|
8
|
+
|
|
9
|
+
var navbar = document.querySelector('#navbar');
|
|
10
|
+
var footer = document.querySelector('#footer');
|
|
11
|
+
var mainSection = document.querySelector('#main');
|
|
12
|
+
var localStorageResizeObject = JSON.parse(
|
|
13
|
+
// eslint-disable-next-line no-undef
|
|
14
|
+
localStorage.getItem(NAVBAR_RESIZE_LOCAL_STORAGE_KEY)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Check whether we have any resize value in local storage or not.
|
|
19
|
+
* If we have resize value then resize the navbar.
|
|
20
|
+
**/
|
|
21
|
+
if (localStorageResizeObject) {
|
|
22
|
+
navbar.style.width = localStorageResizeObject.width;
|
|
23
|
+
mainSection.style.marginLeft = localStorageResizeObject.width;
|
|
24
|
+
footer.style.marginLeft = localStorageResizeObject.width;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var navbarSlider = document.querySelector('#navbar-resize');
|
|
28
|
+
|
|
29
|
+
function resizeNavbar(event) {
|
|
30
|
+
var pageX = event.pageX,
|
|
31
|
+
pageXPlusPx = event.pageX + 'px',
|
|
32
|
+
min = Number.parseInt(NAVBAR_OPTIONS.min, 10) || 300,
|
|
33
|
+
max = Number.parseInt(NAVBAR_OPTIONS.max, 10) || 600;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Just to add some checks. If min is smaller than 10 then
|
|
37
|
+
* user may accidentally end up reducing the size of navbar
|
|
38
|
+
* less than 10. In that case user will not able to resize navbar
|
|
39
|
+
* because navbar slider will be hidden.
|
|
40
|
+
*/
|
|
41
|
+
if (min < 10) {
|
|
42
|
+
min = 10;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Only resize if pageX in range between min and max
|
|
47
|
+
* allowed value.
|
|
48
|
+
*/
|
|
49
|
+
if (min < pageX && pageX < max) {
|
|
50
|
+
navbar.style.width = pageXPlusPx;
|
|
51
|
+
mainSection.style.marginLeft = pageXPlusPx;
|
|
52
|
+
footer.style.marginLeft = pageXPlusPx;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function setupEventListeners() {
|
|
57
|
+
// eslint-disable-next-line no-undef
|
|
58
|
+
window.addEventListener('mousemove', resizeNavbar);
|
|
59
|
+
// eslint-disable-next-line no-undef
|
|
60
|
+
window.addEventListener('touchmove', resizeNavbar);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function afterRemovingEventListeners() {
|
|
64
|
+
// eslint-disable-next-line no-undef
|
|
65
|
+
localStorage.setItem(
|
|
66
|
+
NAVBAR_RESIZE_LOCAL_STORAGE_KEY,
|
|
67
|
+
JSON.stringify({
|
|
68
|
+
width: navbar.style.width
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function removeEventListeners() {
|
|
74
|
+
// eslint-disable-next-line no-undef
|
|
75
|
+
window.removeEventListener('mousemove', resizeNavbar);
|
|
76
|
+
// eslint-disable-next-line no-undef
|
|
77
|
+
window.removeEventListener('touchend', resizeNavbar);
|
|
78
|
+
afterRemovingEventListeners();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
navbarSlider.addEventListener('mousedown', setupEventListeners);
|
|
82
|
+
navbarSlider.addEventListener('touchstart', setupEventListeners);
|
|
83
|
+
// eslint-disable-next-line no-undef
|
|
84
|
+
window.addEventListener('mouseup', removeEventListeners);
|
|
85
|
+
})();
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line no-unused-vars
|
|
88
|
+
function setupResizeOptions(options) {
|
|
89
|
+
NAVBAR_OPTIONS = options;
|
|
90
|
+
}
|