diff --git a/doc/templates/uno/service/search.js b/doc/templates/uno/service/search.js index 4e0d222a14f0..71c05501677d 100644 --- a/doc/templates/uno/service/search.js +++ b/doc/templates/uno/service/search.js @@ -148,17 +148,32 @@ function enableSearch() { indexReady.promise().done(function () { $("body").on("query-ready", function () { - worker.postMessage({q: query}); + postSearchQuery(worker, query); }); - if (query && (query.length >= 3)) { - worker.postMessage({q: query}); - } + postSearchQuery(worker, query); }).then(r => r.resolve()); } - // Highlight the searching keywords + /** + * This function posts the message to the worker if the string has at least + * three characters. + * + * @param worker The search worker used by DocFx (lunr) + * @param searchQuery The string to post to the worker. + */ + function postSearchQuery(worker, searchQuery) { + if (searchQuery && (searchQuery.length >= 3)) { + worker.postMessage({q: `${searchQuery}*`}); + } else { + worker.postMessage({q: ''}); + } + } + + /** + * Highlight the searching keywords + */ function highlightKeywords() { const q = url('?q'); if (q != null) { @@ -182,9 +197,9 @@ function enableSearch() { return e.key !== 'Enter'; }); - searchQuery.on("keyup", function () { + searchQuery.on("keyup", function (e) { $('#search-results').show(); - query = $(this).val(); + query = `${e.target.value}`; $("body").trigger("query-ready"); $('#search-results>.search-list').text('Search Results for "' + query + '"'); }).off("keydown"); diff --git a/doc/templates/uno/styles/docfx.js b/doc/templates/uno/styles/docfx.js index 62928b9c46de..8100c0559643 100644 --- a/doc/templates/uno/styles/docfx.js +++ b/doc/templates/uno/styles/docfx.js @@ -1 +1 @@ -const active="active",expanded="in",filtered="filtered",show="show",hide="hide",collapsed="collapsed";function renderAffix(){var e=function(){const e=$($.map(["h1","h2","h3","h4"],function(e){return".article article "+e}).join(", ")),i=[];e.each(function(e,t){if(t.id){var n,n={name:(n=$(t).text())&&n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">"),href:"#"+t.id,items:[]};if(i.length){const r=i[i.length-1];if(t.tagName===r.type)r.siblings.push(n);else if(t.tagName[1]>r.type[1])i.push({type:t.tagName,siblings:[n]});else{for(;t.tagName[1]{e()?(n(),$("footer").fadeIn()):(t(),$("footer").fadeOut())})}function renderLinks(){"true"===$("meta[property='docfx:newtab']").attr("content")&&$(document.links).filter(function(){return this.hostname!==window.location.hostname}).attr("target","_blank")}function updateLogo(){window.innerWidth<980?$("#logo").attr("src","../images/UnoLogoSmall.png"):$("#logo").attr("src","../images/uno-logo.svg")}function updateLogoOnResize(){$(window).on("resize",function(){updateLogo()})}function renderNavbar(){void 0===$("#navbar ul")[0]?function(){let t=$("meta[property='docfx\\:navrel']").attr("content");if(t){t=t.replace(/\\/g,"/");let a=$("meta[property='docfx\\:tocrel']").attr("content")||"";a=a&&a.replace(/\\/g,"/"),$.get(t,function(e){$(e).find("#toc>ul").appendTo("#navbar");e=t.lastIndexOf("/");let i="";-1ul").addClass("navbar-nav");const o=getAbsolutePath(window.location.pathname);$("#navbar").find("a[href]").each(function(e,t){var n=$(t).attr("href");if(isRelativePath(n)){n=i+n,$(t).attr("href",n);let e=!1;var r=t.name;r?getDirectory(getAbsolutePath(i+r))===getDirectory(getAbsolutePath(a))&&(e=!0):getAbsolutePath(n)===o&&("dropdown"===$(t).attr("data-toggle")||(e=!0)),e&&$(t).addClass(active)}}),renderNavbar()})}}():($("#navbar ul a.active").parents("li").addClass(active),renderBreadcrumb())}function renderLogo(){$("img.svg").each(function(){const n=jQuery(this),r=n.attr("id"),i=n.attr("class");var e=n.attr("src");jQuery.get(e,function(e){let t=$(e).find("svg");void 0!==r&&(t=t.attr("id",r)),void 0!==i&&(t=t.attr("class",i+" replaced-svg")),t=t.removeAttr("xmlns:a"),n.replaceWith(t)},"xml")})}function renderSidebar(){var e=$("#sidetoggle .sidetoc")[0];const t=$("footer"),r=$(".sidetoc");if(void 0===e)!function(){let o=$("meta[property='docfx\\:tocrel']").attr("content");o&&(o=o.replace(/\\/g,"/"),$("#sidetoc").load(o+" #sidetoggle > div",function(){var e=o.lastIndexOf("/");let r="";-1 li > .expand-stub").on("click",function(e){$(e.target).parent().toggleClass(expanded)}),$(".toc .nav > li > .expand-stub + a:not([href])").on("click",function(e){$(e.target).parent().toggleClass(expanded)}),$("#toc_filter_input").on("input",function(){const s=this.value;if(""!==s){const e=$("#toc li>a");e.filter(function(e,t){return 0===$(t).siblings().length}).each(function(e,t){let n=$(t).attr("title");const r=$(t).parent();var i,o=r.parents("ul>li");for(let e=0;e ul > li > a[data-tab="'+r+'"]:not([hidden])');if(null===i)return;i.dispatchEvent(new CustomEvent("click",{bubbles:!0}))}}(t),c(r)),r}(document.body)}function renderTables(){$("table").addClass("table table-bordered table-striped table-condensed").wrap('
')}function highlight(){$("pre code").each(function(e,t){hljs.highlightBlock(t)}),$("pre code[highlight-lines]").each(function(e,t){if(""!==t.innerHTML){const i=t.innerHTML.split("\n"),o=t.getAttribute("highlight-lines");if(o){let e=o.split(",");var n;for(n of e.map(Number)){var r=n.match(/^(\d+)\-(\d+)?$/);let e=0,t=0;if(r)e=+r[1],t=+r[2],(isNaN(t)||t>i.length)&&(t=i.length);else{if(isNaN(n))continue;e=+n,t=e}e<=0||t<=0||e>t||e>i.length||(i[e-1]=''+i[e-1],i[t-1]=i[t-1]+"")}t.innerHTML=i.join("\n")}}})}function enableSearch(){let o;const a=$("meta[property='docfx\\:rel']").attr("content");if(void 0!==a)try{var e=new Worker(a+"styles/search-worker.js");e||window.worker?function(e){const t=$.Deferred();e.onmessage=function(e){switch(e.data.e){case"index-ready":t.resolve();break;case"query-ready":i(e.data.d)}},t.promise().done(function(){$("body").on("query-ready",function(){e.postMessage({q:o})}),o&&3<=o.length&&e.postMessage({q:o})}).then(e=>e.resolve())}(e):function(){console.log("using local search");const n=lunr(function(){this.ref("href"),this.field("title",{boost:50}),this.field("keywords",{boost:20})});lunr.tokenizer.seperator=/[\s\-\.]+/;let r={};const e=new XMLHttpRequest,t=a+"index.json";t&&(e.open("GET",t),e.onload=function(){if(200===this.status)for(var e in r=JSON.parse(this.responseText),r)r.hasOwnProperty(e)&&n.add(r[e])},e.send());$("body").on("queryReady",function(){const e=n.search(o),t=[];e.forEach(function(e){e=r[e.ref];t.push({href:e.href,title:e.title,keywords:e.keywords})}),i(t)})}(),t(),$(window).on("resize",()=>t()),$(document).on("click",".navbar-collapse.in",function(e){$(e.target).is("a")&&$(this).collapse(hide)}),function(){const e=url("?q");if(null!=e){const t=e.split("%20");t.forEach(function(e){""!==e&&($(".data-searchable *").mark(e),$("article *").mark(e))})}}(),$("body").on("searchEvent",function(){$("#search-results>.sr-items").html("

No results found

");const e=$("#search-query");e.on("input",function(e){return"Enter"!==e.key}),e.on("keyup",function(){$("#search-results").show(),o=$(this).val(),$("body").trigger("query-ready"),$("#search-results>.search-list").text('Search Results for "'+o+'"')}).off("keydown")})}catch(e){console.error(e)}function t(){const e=$("#autocollapse");null===e.height()&&setTimeout(t,300),e.removeClass(collapsed),60.sr-items").html("

No results found

"):($("#search-results>.sr-items").empty().append(e.slice(0,20).map(function(e){!function(e,t){const n=e.split(/\/+/);var r=t.split(/\/+/);let i=n.length-1;const o=[];for(let e=0;e").attr("class","sr-item").attr("href",n);r=$("
").attr("class","item-title").text(r),e=$("
").attr("class","item-brief").text(e);return i.append(r).append(e),i})),o.split(/\s+/).forEach(function(e){""!==e&&(e=e.replace(/\*/g,""),$("#search-results>.sr-items *").mark(e))}))}}function getAbsolutePath(e){e=$('')[0];return e.host+e.pathname}function isRelativePath(e){return void 0!==e&&""!==e&&"/"!==e[0]&&!isAbsolutePath(e)}function isAbsolutePath(e){return/^(?:[a-z]+:)?\/\//i.test(e)}function getDirectory(e){if(!e)return"";var t=e.lastIndexOf("/");return-1===t?"":-1';c++;for(let e=0;e'+l+"":"
  • "+l,o+=t(a,r)||"",o+="
  • ")}o+="";return o}({items:e},[].concat(t).join(" "))}function breakPlainText(e){return e&&e.replace(/([a-z])([A-Z])|(\.)(\w)/g,"$1$3$2$4")}function workAroundFixedHeaderForAnchors(){const o=!(!history||!history.pushState),a=/^#[^ ]+$/;function e(e,t){let n,r,i;return a.test(e)&&(n=document.getElementById(e.slice(1)),n&&(r=n.getBoundingClientRect(),i=window.pageYOffset+r.top-$("header").first().height(),window.scrollTo(window.pageXOffset,i),o&&t&&history.pushState({},document.title,location.pathname+e)),n)}function t(){e(window.location.hash,!1)}$(window).on("hashchange",()=>t()),t(),$(document).on("ready",function(){$("body").scrollspy({offset:150})})}function breakText(){$(".xref").addClass("text-break");const e=$(".text-break");e.each(function(){$(this).breakWord()})}workAroundFixedHeaderForAnchors(),highlight(),enableSearch(),renderTables(),renderAlerts(),renderLinks(),renderNavbar(),renderSidebar(),renderAffix(),renderFooter(),renderLogo(),breakText(),renderTabs(),updateLogo(),window.refresh=function(e){void 0!==e&&void 0!==e.content||console.error("Null Argument"),$("article.content").html(e.content),highlight(),renderTables(),renderAlerts(),renderAffix(),renderTabs()},$(document).on("wordpressMenuHasLoaded",function(){const t=window.location.pathname;var n="/docs/articles/";const e=document.getElementById("menu-menu-principal"),r=e.getElementsByTagName("a");for(let e=0;e/g,">"),href:"#"+t.id,items:[]};if(i.length){const r=i[i.length-1];if(t.tagName===r.type)r.siblings.push(n);else if(t.tagName[1]>r.type[1])i.push({type:t.tagName,siblings:[n]});else{for(;t.tagName[1]{e()?(n(),$("footer").fadeIn()):(t(),$("footer").fadeOut())})}function renderLinks(){"true"===$("meta[property='docfx:newtab']").attr("content")&&$(document.links).filter(function(){return this.hostname!==window.location.hostname}).attr("target","_blank")}function updateLogo(){window.innerWidth<980?$("#logo").attr("src","../images/UnoLogoSmall.png"):$("#logo").attr("src","../images/uno-logo.svg")}function updateLogoOnResize(){$(window).on("resize",function(){updateLogo()})}function renderNavbar(){void 0===$("#navbar ul")[0]?function(){let t=$("meta[property='docfx\\:navrel']").attr("content");if(t){t=t.replace(/\\/g,"/");let a=$("meta[property='docfx\\:tocrel']").attr("content")||"";a=a&&a.replace(/\\/g,"/"),$.get(t,function(e){$(e).find("#toc>ul").appendTo("#navbar");e=t.lastIndexOf("/");let i="";-1ul").addClass("navbar-nav");const o=getAbsolutePath(window.location.pathname);$("#navbar").find("a[href]").each(function(e,t){var n=$(t).attr("href");if(isRelativePath(n)){n=i+n,$(t).attr("href",n);let e=!1;var r=t.name;r?getDirectory(getAbsolutePath(i+r))===getDirectory(getAbsolutePath(a))&&(e=!0):getAbsolutePath(n)===o&&("dropdown"===$(t).attr("data-toggle")||(e=!0)),e&&$(t).addClass(active)}}),renderNavbar()})}}():($("#navbar ul a.active").parents("li").addClass(active),renderBreadcrumb())}function renderLogo(){$("img.svg").each(function(){const n=jQuery(this),r=n.attr("id"),i=n.attr("class");var e=n.attr("src");jQuery.get(e,function(e){let t=$(e).find("svg");void 0!==r&&(t=t.attr("id",r)),void 0!==i&&(t=t.attr("class",i+" replaced-svg")),t=t.removeAttr("xmlns:a"),n.replaceWith(t)},"xml")})}function renderSidebar(){var e=$("#sidetoggle .sidetoc")[0];const t=$("footer"),r=$(".sidetoc");if(void 0===e)!function(){let o=$("meta[property='docfx\\:tocrel']").attr("content");o&&(o=o.replace(/\\/g,"/"),$("#sidetoc").load(o+" #sidetoggle > div",function(){var e=o.lastIndexOf("/");let r="";-1 li > .expand-stub").on("click",function(e){$(e.target).parent().toggleClass(expanded)}),$(".toc .nav > li > .expand-stub + a:not([href])").on("click",function(e){$(e.target).parent().toggleClass(expanded)}),$("#toc_filter_input").on("input",function(){const s=this.value;if(""!==s){const e=$("#toc li>a");e.filter(function(e,t){return 0===$(t).siblings().length}).each(function(e,t){let n=$(t).attr("title");const r=$(t).parent();var i,o=r.parents("ul>li");for(let e=0;e ul > li > a[data-tab="'+r+'"]:not([hidden])');if(null===i)return;i.dispatchEvent(new CustomEvent("click",{bubbles:!0}))}}(t),c(r)),r}(document.body)}function renderTables(){$("table").addClass("table table-bordered table-striped table-condensed").wrap('
    ')}function highlight(){$("pre code").each(function(e,t){hljs.highlightBlock(t)}),$("pre code[highlight-lines]").each(function(e,t){if(""!==t.innerHTML){const i=t.innerHTML.split("\n"),o=t.getAttribute("highlight-lines");if(o){let e=o.split(",");var n;for(n of e.map(Number)){var r=n.match(/^(\d+)\-(\d+)?$/);let e=0,t=0;if(r)e=+r[1],t=+r[2],(isNaN(t)||t>i.length)&&(t=i.length);else{if(isNaN(n))continue;e=+n,t=e}e<=0||t<=0||e>t||e>i.length||(i[e-1]=''+i[e-1],i[t-1]=i[t-1]+"")}t.innerHTML=i.join("\n")}}})}function enableSearch(){let o;const a=$("meta[property='docfx\\:rel']").attr("content");if(void 0!==a)try{var e=new Worker(a+"styles/search-worker.js");e||window.worker?function(e){const t=$.Deferred();e.onmessage=function(e){switch(e.data.e){case"index-ready":t.resolve();break;case"query-ready":i(e.data.d)}},t.promise().done(function(){$("body").on("query-ready",function(){n(e,o)}),n(e,o)}).then(e=>e.resolve())}(e):function(){console.log("using local search");const n=lunr(function(){this.ref("href"),this.field("title",{boost:50}),this.field("keywords",{boost:20})});lunr.tokenizer.seperator=/[\s\-\.]+/;let r={};const e=new XMLHttpRequest,t=a+"index.json";t&&(e.open("GET",t),e.onload=function(){if(200===this.status)for(var e in r=JSON.parse(this.responseText),r)r.hasOwnProperty(e)&&n.add(r[e])},e.send());$("body").on("queryReady",function(){const e=n.search(o),t=[];e.forEach(function(e){e=r[e.ref];t.push({href:e.href,title:e.title,keywords:e.keywords})}),i(t)})}(),t(),$(window).on("resize",()=>t()),$(document).on("click",".navbar-collapse.in",function(e){$(e.target).is("a")&&$(this).collapse(hide)}),function(){const e=url("?q");if(null!=e){const t=e.split("%20");t.forEach(function(e){""!==e&&($(".data-searchable *").mark(e),$("article *").mark(e))})}}(),$("body").on("searchEvent",function(){$("#search-results>.sr-items").html("

    No results found

    ");const e=$("#search-query");e.on("input",function(e){return"Enter"!==e.key}),e.on("keyup",function(e){$("#search-results").show(),o=`${e.target.value}`,$("body").trigger("query-ready"),$("#search-results>.search-list").text('Search Results for "'+o+'"')}).off("keydown")})}catch(e){console.error(e)}function t(){const e=$("#autocollapse");null===e.height()&&setTimeout(t,300),e.removeClass(collapsed),60.sr-items").html("

    No results found

    "):($("#search-results>.sr-items").empty().append(e.slice(0,20).map(function(e){!function(e,t){const n=e.split(/\/+/);var r=t.split(/\/+/);let i=n.length-1;const o=[];for(let e=0;e").attr("class","sr-item").attr("href",n);r=$("
    ").attr("class","item-title").text(r),e=$("
    ").attr("class","item-brief").text(e);return i.append(r).append(e),i})),o.split(/\s+/).forEach(function(e){""!==e&&(e=e.replace(/\*/g,""),$("#search-results>.sr-items *").mark(e))}))}}function getAbsolutePath(e){e=$('')[0];return e.host+e.pathname}function isRelativePath(e){return void 0!==e&&""!==e&&"/"!==e[0]&&!isAbsolutePath(e)}function isAbsolutePath(e){return/^(?:[a-z]+:)?\/\//i.test(e)}function getDirectory(e){if(!e)return"";var t=e.lastIndexOf("/");return-1===t?"":-1';c++;for(let e=0;e'+l+"":"
  • "+l,o+=t(a,r)||"",o+="
  • ")}o+="";return o}({items:e},[].concat(t).join(" "))}function breakPlainText(e){return e&&e.replace(/([a-z])([A-Z])|(\.)(\w)/g,"$1$3$2$4")}function workAroundFixedHeaderForAnchors(){const o=!(!history||!history.pushState),a=/^#[^ ]+$/;function e(e,t){let n,r,i;return a.test(e)&&(n=document.getElementById(e.slice(1)),n&&(r=n.getBoundingClientRect(),i=window.pageYOffset+r.top-$("header").first().height(),window.scrollTo(window.pageXOffset,i),o&&t&&history.pushState({},document.title,location.pathname+e)),n)}function t(){e(window.location.hash,!1)}$(window).on("hashchange",()=>t()),t(),$(document).on("ready",function(){$("body").scrollspy({offset:150})})}function breakText(){$(".xref").addClass("text-break");const e=$(".text-break");e.each(function(){$(this).breakWord()})}workAroundFixedHeaderForAnchors(),highlight(),enableSearch(),renderTables(),renderAlerts(),renderLinks(),renderNavbar(),renderSidebar(),renderAffix(),renderFooter(),renderLogo(),breakText(),renderTabs(),updateLogo(),window.refresh=function(e){void 0!==e&&void 0!==e.content||console.error("Null Argument"),$("article.content").html(e.content),highlight(),renderTables(),renderAlerts(),renderAffix(),renderTabs()},$(document).on("wordpressMenuHasLoaded",function(){const t=window.location.pathname;var n="/docs/articles/";const e=document.getElementById("menu-menu-principal"),r=e.getElementsByTagName("a");for(let e=0;e