api-reach-react-native-fix
Advanced tools
Comparing version 1.0.1 to 1.0.3
@@ -9,2 +9,10 @@ All notable changes to this project will be documented in this file. | ||
## [1.0.3] - 2019-08-30 | ||
### Fixed | ||
- audit warnings by upgrading dev deps | ||
## [1.0.2] - 2019-08-16 - not released to npm | ||
### Fixed | ||
- not needed file - jsdoc config - published to npm, added to .npmignore | ||
## [1.0.1] - 2019-08-16 | ||
@@ -11,0 +19,0 @@ ### Fixed |
function hideAllButCurrent(){ | ||
//by default all submenut items are hidden | ||
$("nav > ul > li > ul li").hide(); | ||
//but we need to rehide them for search | ||
document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) { | ||
parent.style.display = "none"; | ||
}); | ||
//only current page (if it exists) should be opened | ||
var file = window.location.pathname.split("/").pop(); | ||
$("nav > ul > li > a[href^='"+file+"']").parent().find("> ul li").show(); | ||
var file = window.location.pathname.split("/").pop().replace(/\.html/, ''); | ||
document.querySelectorAll("nav > ul > li > a").forEach(function(parent) { | ||
var href = parent.attributes.href.value.replace(/\.html/, ''); | ||
if (file === href) { | ||
parent.parentNode.querySelectorAll("ul li").forEach(function(elem) { | ||
elem.style.display = "block"; | ||
}); | ||
} | ||
}); | ||
} | ||
$( document ).ready(function() { | ||
hideAllButCurrent(); | ||
}); | ||
hideAllButCurrent(); |
@@ -1,42 +0,83 @@ | ||
$( document ).ready(function() { | ||
jQuery.expr[':'].Contains = function(a,i,m){ | ||
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0; | ||
}; | ||
//on search | ||
$("#nav-search").on("keyup", function(event) { | ||
var search = $(this).val(); | ||
if (!search) { | ||
//no search, show all results | ||
$("nav > ul > li").show(); | ||
if(typeof hideAllButCurrent === "function"){ | ||
//let's do what ever collapse wants to do | ||
hideAllButCurrent(); | ||
var searchAttr = 'data-search-mode'; | ||
function contains(a,m){ | ||
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m) !== -1; | ||
}; | ||
//on search | ||
document.getElementById("nav-search").addEventListener("keyup", function(event) { | ||
var search = this.value.toUpperCase(); | ||
if (!search) { | ||
//no search, show all results | ||
document.documentElement.removeAttribute(searchAttr); | ||
document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(elem) { | ||
elem.style.display = "block"; | ||
}); | ||
if (typeof hideAllButCurrent === "function"){ | ||
//let's do what ever collapse wants to do | ||
hideAllButCurrent(); | ||
} else { | ||
//menu by default should be opened | ||
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) { | ||
elem.style.display = "block"; | ||
}); | ||
} | ||
} else { | ||
//we are searching | ||
document.documentElement.setAttribute(searchAttr, ''); | ||
//show all parents | ||
document.querySelectorAll("nav > ul > li").forEach(function(elem) { | ||
elem.style.display = "block"; | ||
}); | ||
//hide all results | ||
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) { | ||
elem.style.display = "none"; | ||
}); | ||
//show results matching filter | ||
document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) { | ||
if (!contains(elem.parentNode, search)) { | ||
return; | ||
} | ||
else{ | ||
//menu by default should be opened | ||
$("nav > ul > li > ul li").show(); | ||
} | ||
} | ||
else{ | ||
//we are searching | ||
//show all parents | ||
$("nav > ul > li").show(); | ||
//hide all results | ||
$("nav > ul > li > ul li").hide(); | ||
//show results matching filter | ||
$("nav > ul > li > ul").find("a:Contains("+search+")").parent().show(); | ||
//hide parents without children | ||
$("nav > ul > li").each(function(){ | ||
if($(this).find("a:Contains("+search+")").length == 0 && $(this).children("ul").length === 0){ | ||
//has no child at all and does not contain text | ||
$(this).hide(); | ||
elem.parentNode.style.display = "block"; | ||
}); | ||
//hide parents without children | ||
document.querySelectorAll("nav > ul > li").forEach(function(parent) { | ||
var countSearchA = 0; | ||
parent.querySelectorAll("a").forEach(function(elem) { | ||
if (contains(elem, search)) { | ||
countSearchA++; | ||
} | ||
else if($(this).find("a:Contains("+search+")").length == 0 && $(this).find("ul").children(':visible').length == 0){ | ||
//has no visible child and does not contain text | ||
$(this).hide(); | ||
}); | ||
var countUl = 0; | ||
var countUlVisible = 0; | ||
parent.querySelectorAll("ul").forEach(function(ulP) { | ||
// count all elements that match the search | ||
if (contains(ulP, search)) { | ||
countUl++; | ||
} | ||
// count all visible elements | ||
var children = ulP.children | ||
for (i=0; i<children.length; i++) { | ||
var elem = children[i]; | ||
if (elem.style.display != "none") { | ||
countUlVisible++; | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
if (countSearchA == 0 && countUl === 0){ | ||
//has no child at all and does not contain text | ||
parent.style.display = "none"; | ||
} else if(countSearchA == 0 && countUlVisible == 0){ | ||
//has no visible child and does not contain text | ||
parent.style.display = "none"; | ||
} | ||
}); | ||
} | ||
}); |
{ | ||
"name": "api-reach-react-native-fix", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"main": "src/index.js", | ||
@@ -9,24 +9,24 @@ "repository": "git@github.com:dzek69/api-reach-react-native-fix.git", | ||
"scripts": { | ||
"test": "cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=testing mocha 'src/**/*.spec.js'", | ||
"test": "cross-env NODE_ENV=testing mocha 'src/**/*.spec.js'", | ||
"docs": "node build-scripts/docs && jsdoc -r src README.md -t node_modules/docdash -d ./docs -u ./tutorials -c jsdoc.json && node build-scripts/docs.after", | ||
"transpile": "node build-scripts/transpile && babel src -d dist --ignore spec.js", | ||
"transpile": "node build-scripts/transpile && babel src -d dist --ignore **/*.spec.js", | ||
"prepublishOnly": "npm run test && npm run lint && npm run docs", | ||
"prepack": "npm run transpile", | ||
"lint": "cross-env eslint 'src/**/*.js' 'src/*.js'", | ||
"lint": "cross-env eslint --report-unused-disable-directives 'src/**/*.js' 'src/*.js'", | ||
"lint:fix": "npm run lint -- --fix" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.1.5", | ||
"@babel/core": "^7.1.6", | ||
"@babel/polyfill": "^7.0.0", | ||
"@babel/preset-env": "^7.1.6", | ||
"@babel/register": "^7.0.0", | ||
"@dzek69/eslint-config-base": "^0.0.3", | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/polyfill": "^7.4.4", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/register": "^7.5.5", | ||
"@dzek69/eslint-config-base": "^1.0.1", | ||
"babel-plugin-rewire": "^1.2.0", | ||
"cross-env": "^5.2.0", | ||
"docdash": "^1.0.0", | ||
"eslint": "^5.16.0", | ||
"docdash": "^1.1.1", | ||
"eslint": "^6.2.2", | ||
"fs-extra": "^7.0.1", | ||
"jsdoc": "^3.6.2", | ||
"mocha": "^5.2.0", | ||
"jsdoc": "^3.6.3", | ||
"mocha": "^6.2.0", | ||
"must": "^0.13.4" | ||
@@ -33,0 +33,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58035
993