l-hammer/You-need-to-know-css

View on GitHub
libs/search.min.js

Summary

Maintainability
A
0 mins
Test Coverage
!function(){var n,e={};function t(n){var e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};return String(n).replace(/[&<>"'/]/g,function(n){return e[n]})}function o(t,o){n=Docsify;var a="auto"===t.paths,i=localStorage.getItem("docsify.search.expires")<Date.now();if(e=JSON.parse(localStorage.getItem("docsify.search.index")),i)e={};else if(!a)return;var r=a?function(e){var t=[];return n.dom.findAll("a:not([data-nosearch])").forEach(function(n){var o=n.href,a=n.getAttribute("href"),i=e.parse(o).path;i&&-1===t.indexOf(i)&&!Docsify.util.isAbsolutePath(a)&&t.push(i)}),t}(o.router):t.paths,s=r.length,c=0;r.forEach(function(a){if(e[a])return c++;n.get(o.router.getFile(a),!1,o.config.requestHeaders).then(function(n){e[a]=function(n,e,t,o){void 0===e&&(e="");var a,i=window.marked.lexer(e),r=window.Docsify.slugify,s={};return i.forEach(function(e){if("heading"===e.type&&e.depth<=o)a=t.toURL(n,{id:r(e.text)}),s[a]={slug:a,title:e.text,body:""};else{if(!a)return;s[a]?s[a].body?s[a].body+="\n"+(e.text||""):s[a].body=e.text:s[a]={slug:a,title:"",body:""}}}),r.clear(),s}(a,n,o.router,t.depth),s===++c&&(i=t.maxAge,localStorage.setItem("docsify.search.expires",Date.now()+i),localStorage.setItem("docsify.search.index",JSON.stringify(e)));var i})})}var a="";function i(n){var o=Docsify.dom.find("div.search"),i=Docsify.dom.find(o,".results-panel"),r=Docsify.dom.find(o,".clear-button");if(!n)return i.classList.remove("show"),r.classList.remove("show"),void(i.innerHTML="");var s="";(function(n){var o=[],a=[];Object.keys(e).forEach(function(n){a=a.concat(Object.keys(e[n]).map(function(t){return e[n][t]}))});var i=(n=n.trim()).split(/[\s\-,\\/]+/);1!==i.length&&(i=[].concat(n,i));for(var r=function(n){var e=a[n],r=!1,s="",c=e.title&&e.title.trim(),l=e.body&&e.body.trim(),d=e.slug||"";if(c&&l&&(i.forEach(function(n){var e=new RegExp(n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&"),"gi"),o=-1,a=-1;if(o=c&&c.search(e),a=l&&l.search(e),o<0&&a<0)r=!1;else{r=!0,a<0&&(a=0);var i=0,d=0;(d=0==(i=a<11?0:a-10)?70:a+n.length+60)>l.length&&(d=l.length);var h="..."+t(l).substring(i,d).replace(e,'<em class="search-keyword">'+n+"</em>")+"...";s+=h}}),r)){var h={title:t(c),content:s,url:d};o.push(h)}},s=0;s<a.length;s++)r(s);return o})(n).forEach(function(n){s+='<div class="matching-post">\n<a href="'+n.url+'">\n<h2>'+n.title+"</h2>\n<p>"+n.content+"</p>\n</a>\n</div>"}),i.classList.add("show"),r.classList.add("show"),i.innerHTML=s||'<p class="empty">'+a+"</p>"}function r(n,e){var t=e.router.parse().query.s;Docsify.dom.style("\n.sidebar {\n  padding-top: 0;\n}\n\n.search {\n  margin-bottom: 20px;\n  padding: 6px;\n  border-bottom: 1px solid #eee;\n}\n\n.search .input-wrap {\n  display: flex;\n  align-items: center;\n}\n\n.search .results-panel {\n  display: none;\n}\n\n.search .results-panel.show {\n  display: block;\n}\n\n.search input {\n  outline: none;\n  border: none;\n  width: 100%;\n  padding: 0 7px;\n  line-height: 36px;\n  font-size: 14px;\n}\n\n.search input::-webkit-search-decoration,\n.search input::-webkit-search-cancel-button,\n.search input {\n  -webkit-appearance: none;\n  -moz-appearance: none;\n  appearance: none;\n}\n.search .clear-button {\n  width: 36px;\n  text-align: right;\n  display: none;\n}\n\n.search .clear-button.show {\n  display: block;\n}\n\n.search .clear-button svg {\n  transform: scale(.5);\n}\n\n.search h2 {\n  font-size: 17px;\n  margin: 10px 0;\n}\n\n.search a {\n  text-decoration: none;\n  color: inherit;\n}\n\n.search .matching-post {\n  border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n  border-bottom: 0;\n}\n\n.search p {\n  font-size: 14px;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  display: -webkit-box;\n  -webkit-line-clamp: 2;\n  -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n  text-align: center;\n}"),function(n,e){void 0===e&&(e="");var t='<div class="input-wrap">\n      <input type="search" value="'+e+'" />\n      <div class="clear-button">\n        <svg width="26" height="24">\n          <circle cx="12" cy="12" r="11" fill="#ccc" />\n          <path stroke="white" stroke-width="2" d="M8.25,8.25,15.75,15.75" />\n          <path stroke="white" stroke-width="2"d="M8.25,15.75,15.75,8.25" />\n        </svg>\n      </div>\n    </div>\n    <div class="results-panel"></div>\n    </div>',o=Docsify.dom.create("div",t),a=Docsify.dom.find("aside");Docsify.dom.toggleClass(o,"search"),Docsify.dom.before(a,o)}(0,t),function(){var n,e=Docsify.dom.find("div.search"),t=Docsify.dom.find(e,"input"),o=Docsify.dom.find(e,".input-wrap");Docsify.dom.on(e,"click",function(n){return"A"!==n.target.tagName&&n.stopPropagation()}),Docsify.dom.on(t,"input",function(e){clearTimeout(n),n=setTimeout(function(n){return i(e.target.value.trim())},100)}),Docsify.dom.on(o,"click",function(n){"INPUT"!==n.target.tagName&&(t.value="",i())})}(),t&&setTimeout(function(n){return i(t)},500)}function s(n,e){!function(n,e){var t=Docsify.dom.getNode('.search input[type="search"]');if(t)if("string"==typeof n)t.placeholder=n;else{var o=Object.keys(n).filter(function(n){return e.indexOf(n)>-1})[0];t.placeholder=n[o]}}(n.placeholder,e.route.path),function(n,e){if("string"==typeof n)a=n;else{var t=Object.keys(n).filter(function(n){return e.indexOf(n)>-1})[0];a=n[t]}}(n.noData,e.route.path)}var c={placeholder:"Type to search",noData:"No Results!",paths:"auto",depth:2,maxAge:864e5};$docsify.plugins=[].concat(function(n,e){var t=Docsify.util,a=e.config.search||c;Array.isArray(a)?c.paths=a:"object"==typeof a&&(c.paths=Array.isArray(a.paths)?a.paths:"auto",c.maxAge=t.isPrimitive(a.maxAge)?a.maxAge:c.maxAge,c.placeholder=a.placeholder||c.placeholder,c.noData=a.noData||c.noData,c.depth=a.depth||c.depth);var i="auto"===c.paths;n.mounted(function(n){r(0,e),!i&&o(c,e)}),n.doneEach(function(n){s(c,e),i&&o(c,e)})},$docsify.plugins)}();