mirror of
https://github.com/marcriera/ddgo-controller-docs.git
synced 2025-05-01 06:07:05 +02:00
deploy: 59f02f1d84
This commit is contained in:
parent
f157108a8c
commit
2e2e54e756
250 changed files with 1981 additions and 5036 deletions
513
js/theme.js
513
js/theme.js
|
@ -13,32 +13,9 @@ var touchsupport = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0)
|
|||
|
||||
var formelements = 'button, datalist, fieldset, input, label, legend, meter, optgroup, option, output, progress, select, textarea';
|
||||
|
||||
// rapidoc: #280 disable broad document syntax highlightning
|
||||
window.Prism = window.Prism || {};
|
||||
Prism.manual = true;
|
||||
|
||||
// PerfectScrollbar
|
||||
var psc;
|
||||
var psm;
|
||||
var pst;
|
||||
|
||||
function scrollbarWidth(){
|
||||
// https://davidwalsh.name/detect-scrollbar-width
|
||||
// Create the measurement node
|
||||
var scrollDiv = document.createElement("div");
|
||||
scrollDiv.className = "scrollbar-measure";
|
||||
document.body.appendChild(scrollDiv);
|
||||
// Get the scrollbar width
|
||||
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
// Delete the DIV
|
||||
document.body.removeChild(scrollDiv);
|
||||
return scrollbarWidth;
|
||||
}
|
||||
|
||||
function switchTab(tabGroup, tabId) {
|
||||
var tabs = jQuery(".tab-panel").has("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']");
|
||||
var allTabItems = tabs.find("[data-tab-group='"+tabGroup+"']");
|
||||
var targetTabItems = tabs.find("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']");
|
||||
allTabItems = jQuery("[data-tab-group='"+tabGroup+"']");
|
||||
targetTabItems = jQuery("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']");
|
||||
|
||||
// if event is undefined then switchTab was called from restoreTabSelection
|
||||
// so it's not a button event and we don't need to safe the selction or
|
||||
|
@ -87,10 +64,10 @@ function restoreTabSelections() {
|
|||
}
|
||||
}
|
||||
|
||||
function initMermaid( update, attrs ) {
|
||||
function initMermaid( update ) {
|
||||
// we are either in update or initialization mode;
|
||||
// during initialization, we want to edit the DOM;
|
||||
// during update we only want to execute if something changed
|
||||
// during update we only want to execute if something chanegd
|
||||
var decodeHTML = function( html ){
|
||||
var txt = document.createElement( 'textarea' );
|
||||
txt.innerHTML = html;
|
||||
|
@ -113,9 +90,10 @@ function initMermaid( update, attrs ) {
|
|||
return '%%{init: ' + JSON.stringify( graph.dir ) + '}%%\n' + graph.content;
|
||||
};
|
||||
|
||||
var init_func = function( attrs ){
|
||||
var init_func = function(){
|
||||
state.is_initialized = true;
|
||||
var is_initialized = false;
|
||||
var theme = attrs.theme;
|
||||
var theme = variants.getColorValue( 'MERMAID-theme' );
|
||||
document.querySelectorAll('.mermaid').forEach( function( element ){
|
||||
var parse = parseGraph( decodeHTML( element.innerHTML ) );
|
||||
|
||||
|
@ -137,9 +115,9 @@ function initMermaid( update, attrs ) {
|
|||
return is_initialized;
|
||||
}
|
||||
|
||||
var update_func = function( attrs ){
|
||||
var update_func = function(){
|
||||
var is_initialized = false;
|
||||
var theme = attrs.theme;
|
||||
var theme = variants.getColorValue( 'MERMAID-theme' );
|
||||
document.querySelectorAll( '.mermaid-container' ).forEach( function( e ){
|
||||
var element = e.querySelector( '.mermaid' );
|
||||
var code = e.querySelector( '.mermaid-code' );
|
||||
|
@ -173,66 +151,28 @@ function initMermaid( update, attrs ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if( !state.is_initialized ){
|
||||
state.is_initialized = true;
|
||||
window.addEventListener( 'beforeprint', function(){
|
||||
initMermaid( true, {
|
||||
'theme': variants.getColorValue( 'PRINT-MERMAID-theme' ),
|
||||
});
|
||||
}.bind( this ) );
|
||||
window.addEventListener( 'afterprint', function(){
|
||||
initMermaid( true );
|
||||
}.bind( this ) );
|
||||
}
|
||||
|
||||
attrs = attrs || {
|
||||
'theme': variants.getColorValue( 'MERMAID-theme' ),
|
||||
};
|
||||
var is_initialized = ( update ? update_func( attrs ) : init_func( attrs ) );
|
||||
var is_initialized = ( update ? update_func() : init_func() );
|
||||
if( is_initialized ){
|
||||
mermaid.init();
|
||||
$(".mermaid svg").svgPanZoom({});
|
||||
}
|
||||
}
|
||||
|
||||
function initSwagger( update, attrs ){
|
||||
var state = this;
|
||||
if( update && !state.is_initialized ){
|
||||
return;
|
||||
}
|
||||
function initSwagger( update ){
|
||||
if( typeof variants == 'undefined' ){
|
||||
return;
|
||||
}
|
||||
|
||||
if( !state.is_initialized ){
|
||||
state.is_initialized = true;
|
||||
window.addEventListener( 'beforeprint', function(){
|
||||
initSwagger( true, {
|
||||
'bg-color': variants.getColorValue( 'PRINT-MAIN-BG-color' ),
|
||||
'mono-font': variants.getColorValue( 'PRINT-CODE-font' ),
|
||||
'primary-color': variants.getColorValue( 'PRINT-TAG-BG-color' ),
|
||||
'regular-font': variants.getColorValue( 'PRINT-MAIN-font' ),
|
||||
'text-color': variants.getColorValue( 'PRINT-MAIN-TEXT-color' ),
|
||||
'theme': variants.getColorValue( 'PRINT-SWAGGER-theme' ),
|
||||
});
|
||||
}.bind( this ) );
|
||||
window.addEventListener( 'afterprint', function(){
|
||||
initSwagger( true );
|
||||
}.bind( this ) );
|
||||
}
|
||||
|
||||
attrs = attrs || {
|
||||
'bg-color': variants.getColorValue( 'MAIN-BG-color' ),
|
||||
'mono-font': variants.getColorValue( 'CODE-font' ),
|
||||
'primary-color': variants.getColorValue( 'TAG-BG-color' ),
|
||||
'regular-font': variants.getColorValue( 'MAIN-font' ),
|
||||
'text-color': variants.getColorValue( 'MAIN-TEXT-color' ),
|
||||
'theme': variants.getColorValue( 'SWAGGER-theme' ),
|
||||
};
|
||||
var attrs = [
|
||||
[ 'bg-color', variants.getColorValue( 'MAIN-BG-color' ) ],
|
||||
[ 'mono-font', variants.getColorValue( 'CODE-font' ) ],
|
||||
[ 'primary-color', variants.getColorValue( 'TAG-BG-color' ) ],
|
||||
[ 'regular-font', variants.getColorValue( 'MAIN-font' ) ],
|
||||
[ 'text-color', variants.getColorValue( 'MAIN-TEXT-color' ) ],
|
||||
[ 'theme', variants.getColorValue( 'SWAGGER-theme' ) ],
|
||||
];
|
||||
document.querySelectorAll( 'rapi-doc' ).forEach( function( e ){
|
||||
Object.keys( attrs ).forEach( function( key ){
|
||||
/* this doesn't work for FF 102, maybe related to custom elements? */
|
||||
e.setAttribute( key, attrs[key] );
|
||||
attrs.forEach( function( attr ){
|
||||
e.setAttribute( attr[0], attr[1] );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -279,12 +219,10 @@ function initCodeClipboard(){
|
|||
}
|
||||
|
||||
$('code').each(function() {
|
||||
var code = $(this);
|
||||
var text = code.text();
|
||||
var parent = code.parent();
|
||||
var inPre = parent.prop('tagName') == 'PRE';
|
||||
var code = $(this),
|
||||
text = code.text();
|
||||
|
||||
if (inPre || text.length > 5) {
|
||||
if (text.length > 5) {
|
||||
var clip = new ClipboardJS('.copy-to-clipboard-button', {
|
||||
text: function(trigger) {
|
||||
var text = $(trigger).prev('code').text();
|
||||
|
@ -311,6 +249,8 @@ function initCodeClipboard(){
|
|||
});
|
||||
});
|
||||
|
||||
var parent = code.parent();
|
||||
var inPre = parent.prop('tagName') == 'PRE';
|
||||
code.addClass('copy-to-clipboard-code');
|
||||
if( inPre ){
|
||||
parent.addClass( 'copy-to-clipboard' );
|
||||
|
@ -328,10 +268,6 @@ function initCodeClipboard(){
|
|||
}
|
||||
|
||||
function initArrowNav(){
|
||||
if( isPrint ){
|
||||
return;
|
||||
}
|
||||
|
||||
// button navigation
|
||||
jQuery(function() {
|
||||
jQuery('a.nav-prev').click(function(){
|
||||
|
@ -365,10 +301,7 @@ function initMenuScrollbar(){
|
|||
return;
|
||||
}
|
||||
|
||||
var elc = document.querySelector('#body-inner');
|
||||
var elm = document.querySelector('#content-wrapper');
|
||||
var elt = document.querySelector('#TableOfContents');
|
||||
|
||||
var content = '#body-inner';
|
||||
var autofocus = false;
|
||||
document.addEventListener('keydown', function(event){
|
||||
// for initial keyboard scrolling support, no element
|
||||
|
@ -378,52 +311,42 @@ function initMenuScrollbar(){
|
|||
// it and give focus to the scrollbar - only
|
||||
// to just remove the focus right after scrolling
|
||||
// happend
|
||||
var c = elc && elc.matches(':hover');
|
||||
var m = elm && elm.matches(':hover');
|
||||
var t = elt && elt.matches(':hover');
|
||||
var p = document.querySelector(content).matches(':hover');
|
||||
var m = document.querySelector('#content-wrapper').matches(':hover');
|
||||
var f = event.target.matches( formelements );
|
||||
if( !c && !m && !t && !f ){
|
||||
if( !p && !m && !f ){
|
||||
// only do this hack if none of our scrollbars
|
||||
// is hovered
|
||||
autofocus = true;
|
||||
// if we are showing the sidebar as a flyout we
|
||||
// want to scroll the content-wrapper, otherwise we want
|
||||
// to scroll the body
|
||||
var nt = document.querySelector('body').matches('.toc-flyout');
|
||||
var nm = document.querySelector('body').matches('.sidebar-flyout');
|
||||
if( nt ){
|
||||
pst && pst.scrollbarY.focus();
|
||||
}
|
||||
else if( nm ){
|
||||
psm && psm.scrollbarY.focus();
|
||||
var n = document.querySelector('body').matches('.sidebar-flyout');
|
||||
if( n ){
|
||||
psm.scrollbarY.focus();
|
||||
}
|
||||
else{
|
||||
document.querySelector('#body-inner').focus();
|
||||
psc && psc.scrollbarY.focus();
|
||||
psc.scrollbarY.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
// scrollbars will install their own keyboard handlers
|
||||
// that need to be executed inbetween our own handlers
|
||||
// PSC removed for #242 #243 #244
|
||||
// psc = elc && new PerfectScrollbar('#body-inner');
|
||||
psm = elm && new PerfectScrollbar('#content-wrapper');
|
||||
pst = elt && new PerfectScrollbar('#TableOfContents');
|
||||
var psm = new PerfectScrollbar('#content-wrapper');
|
||||
var psc = new PerfectScrollbar(content);
|
||||
document.addEventListener('keydown', function(){
|
||||
// if we facked initial scrolling, we want to
|
||||
// remove the focus to not leave visual markers on
|
||||
// the scrollbar
|
||||
if( autofocus ){
|
||||
psc && psc.scrollbarY.blur();
|
||||
psm && psm.scrollbarY.blur();
|
||||
pst && pst.scrollbarY.blur();
|
||||
psc.scrollbarY.blur();
|
||||
psm.scrollbarY.blur();
|
||||
autofocus = false;
|
||||
}
|
||||
});
|
||||
// on resize, we have to redraw the scrollbars to let new height
|
||||
// affect their size
|
||||
window.addEventListener('resize', function(){
|
||||
pst && pst.update();
|
||||
psm && psm.update();
|
||||
psc && psc.update();
|
||||
});
|
||||
|
@ -434,20 +357,6 @@ function initMenuScrollbar(){
|
|||
psm && psm.update();
|
||||
});
|
||||
});
|
||||
|
||||
// finally, we want to adjust the contents right padding if there is a scrollbar visible
|
||||
var scrollbarSize = scrollbarWidth();
|
||||
function adjustContentWidth(){
|
||||
var left = parseFloat( getComputedStyle( elc ).getPropertyValue( 'padding-left' ) );
|
||||
var right = left;
|
||||
if( elc.scrollHeight > elc.clientHeight ){
|
||||
// if we have a scrollbar reduce the right margin by the scrollbar width
|
||||
right = Math.max( 0, left - scrollbarSize );
|
||||
}
|
||||
elc.style[ 'padding-right' ] = '' + right + 'px';
|
||||
}
|
||||
window.addEventListener('resize', adjustContentWidth );
|
||||
adjustContentWidth();
|
||||
}
|
||||
|
||||
function initLightbox(){
|
||||
|
@ -505,119 +414,19 @@ function initImageStyles(){
|
|||
});
|
||||
}
|
||||
|
||||
function sidebarEscapeHandler( event ){
|
||||
if( event.key == "Escape" ){
|
||||
var b = document.querySelector( 'body' );
|
||||
b.classList.remove( 'sidebar-flyout' );
|
||||
document.removeEventListener( 'keydown', sidebarEscapeHandler );
|
||||
document.querySelector( '#body-inner' ).focus();
|
||||
psc && psc.scrollbarY.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function tocEscapeHandler( event ){
|
||||
if( event.key == "Escape" ){
|
||||
var b = document.querySelector( 'body' );
|
||||
b.classList.remove( 'toc-flyout' );
|
||||
document.removeEventListener( 'keydown', tocEscapeHandler );
|
||||
document.querySelector( '#body-inner' ).focus();
|
||||
psc && psc.scrollbarY.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function sidebarShortcutHandler( event ){
|
||||
if( event.altKey && event.ctrlKey && event.which == 77 /* m */ ){
|
||||
showNav();
|
||||
}
|
||||
}
|
||||
|
||||
function tocShortcutHandler( event ){
|
||||
if( event.altKey && event.ctrlKey && event.which == 84 /* t */ ){
|
||||
showToc();
|
||||
}
|
||||
}
|
||||
|
||||
function editShortcutHandler( event ){
|
||||
if( event.altKey && event.ctrlKey && event.which == 69 /* e */ ){
|
||||
showEdit();
|
||||
}
|
||||
}
|
||||
|
||||
function printShortcutHandler( event ){
|
||||
if( event.altKey && event.ctrlKey && event.which == 80 /* p */ ){
|
||||
showPrint();
|
||||
}
|
||||
}
|
||||
|
||||
function showNav(){
|
||||
if( !document.querySelector( '#sidebar-overlay' ) ){
|
||||
// we may not have a flyout
|
||||
return;
|
||||
}
|
||||
var b = document.querySelector( 'body' );
|
||||
b.classList.toggle( 'sidebar-flyout' );
|
||||
if( b.classList.contains( 'sidebar-flyout' ) ){
|
||||
b.classList.remove( 'toc-flyout' );
|
||||
document.removeEventListener( 'keydown', tocEscapeHandler );
|
||||
document.addEventListener( 'keydown', sidebarEscapeHandler );
|
||||
}
|
||||
else{
|
||||
document.removeEventListener( 'keydown', sidebarEscapeHandler );
|
||||
document.querySelector( '#body-inner' ).focus();
|
||||
psc && psc.scrollbarY.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function showToc(){
|
||||
var t = document.querySelector( '#toc-menu' );
|
||||
if( !t ){
|
||||
// we may not have a toc
|
||||
return;
|
||||
}
|
||||
var b = document.querySelector( 'body' );
|
||||
b.classList.toggle( 'toc-flyout' );
|
||||
if( b.classList.contains( 'toc-flyout' ) ){
|
||||
pst && pst.update();
|
||||
document.addEventListener( 'keydown', tocEscapeHandler );
|
||||
}
|
||||
else{
|
||||
document.removeEventListener( 'keydown', tocEscapeHandler );
|
||||
document.querySelector( '#body-inner' ).focus();
|
||||
psc && psc.scrollbarY.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function showEdit(){
|
||||
var l = document.querySelector( '#top-github-link a' );
|
||||
if( l ){
|
||||
l.click();
|
||||
}
|
||||
}
|
||||
|
||||
function showPrint(){
|
||||
var l = document.querySelector( '#top-print-link a' );
|
||||
if( l ){
|
||||
l.click();
|
||||
}
|
||||
}
|
||||
|
||||
function initToc(){
|
||||
if( isPrint ){
|
||||
return;
|
||||
}
|
||||
|
||||
document.addEventListener( 'keydown', editShortcutHandler );
|
||||
document.addEventListener( 'keydown', printShortcutHandler );
|
||||
document.addEventListener( 'keydown', sidebarShortcutHandler );
|
||||
document.addEventListener( 'keydown', tocShortcutHandler );
|
||||
// avoid keyboard navigation for input fields
|
||||
jQuery(formelements).keydown(function (e) {
|
||||
if( e.altKey && event.ctrlKey ){
|
||||
if( e.which == 77 /* m */ || e.which == 84 /* t */ || e.which == 69 /* e */ || e.which == 80 /* p */ ){
|
||||
e.stopPropagation();
|
||||
}
|
||||
function showNav(){
|
||||
var b = document.querySelector( 'body' );
|
||||
b.classList.toggle( 'sidebar-flyout' );
|
||||
var n = b.matches('.sidebar-flyout');
|
||||
if( n ){
|
||||
b.classList.remove( 'toc-flyout' );
|
||||
}
|
||||
});
|
||||
}
|
||||
function showToc(){
|
||||
var b = document.querySelector( 'body' );
|
||||
b.classList.toggle( 'toc-flyout' );
|
||||
}
|
||||
|
||||
document.querySelector( '#sidebar-overlay' ).addEventListener( 'click', showNav );
|
||||
document.querySelector( '#sidebar-toggle' ).addEventListener( 'click', showNav );
|
||||
|
@ -629,10 +438,6 @@ function initToc(){
|
|||
t.addEventListener( 'click', showToc );
|
||||
p.addEventListener( 'click', showToc );
|
||||
}
|
||||
|
||||
// finally give initial focus to allow keyboard scrolling in FF
|
||||
document.querySelector( '#body-inner' ).focus();
|
||||
psc && psc.scrollbarY.focus();
|
||||
}
|
||||
|
||||
function initSwipeHandler(){
|
||||
|
@ -659,11 +464,7 @@ function initSwipeHandler(){
|
|||
else if( diffx > 30 ){
|
||||
startx = null;
|
||||
starty = null;
|
||||
var b = document.querySelector( 'body' );
|
||||
b.classList.remove( 'sidebar-flyout' );
|
||||
document.removeEventListener( 'keydown', sidebarEscapeHandler );
|
||||
document.querySelector( '#body-inner' ).focus();
|
||||
psc && psc.scrollbarY.focus();
|
||||
document.querySelector( 'body' ).classList.toggle( 'sidebar-flyout' );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -685,36 +486,6 @@ function initSwipeHandler(){
|
|||
document.querySelectorAll( '#sidebar *' ).forEach( function(e){ e.addEventListener("touchend", handleEndX); }, false);
|
||||
}
|
||||
|
||||
function clearHistory() {
|
||||
var visitedItem = baseUriFull + 'visited-url/'
|
||||
for( var item in sessionStorage ){
|
||||
if( item.substring( 0, visitedItem.length ) === visitedItem ){
|
||||
sessionStorage.removeItem( item );
|
||||
var url = item.substring( visitedItem.length );
|
||||
// in case we have `relativeURLs=true` we have to strip the
|
||||
// relative path to root
|
||||
url = url.replace( /\.\.\//g, '/' ).replace( /^\/+\//, '/' );
|
||||
jQuery('[data-nav-id="' + url + '"]').removeClass('visited');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initHistory() {
|
||||
var visitedItem = baseUriFull + 'visited-url/'
|
||||
sessionStorage.setItem(visitedItem+jQuery('body').data('url'), 1);
|
||||
|
||||
// loop through the sessionStorage and see if something should be marked as visited
|
||||
for( var item in sessionStorage ){
|
||||
if( item.substring( 0, visitedItem.length ) === visitedItem && sessionStorage.getItem( item ) == 1 ){
|
||||
var url = item.substring( visitedItem.length );
|
||||
// in case we have `relativeURLs=true` we have to strip the
|
||||
// relative path to root
|
||||
url = url.replace( /\.\.\//g, '/' ).replace( /^\/+\//, '/' );
|
||||
jQuery('[data-nav-id="' + url + '"]').addClass('visited');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function scrollToActiveMenu() {
|
||||
window.setTimeout(function(){
|
||||
var e = document.querySelector( '#sidebar ul.topics li.active a' );
|
||||
|
@ -740,81 +511,8 @@ function scrollToFragment() {
|
|||
}, 10);
|
||||
}
|
||||
|
||||
function mark(){
|
||||
var value = sessionStorage.getItem(baseUriFull+'search-value');
|
||||
$(".highlightable").highlight(value, { element: 'mark' });
|
||||
$("mark").parents(".expand").addClass("expand-marked");
|
||||
$("mark").parents("li").each( function(){
|
||||
var i = jQuery(this).children("input.toggle:not(.menu-marked)");
|
||||
if( i.length ){
|
||||
e = jQuery(i[0]);
|
||||
e.attr("data-checked", (e.prop('checked')?"true":"false")).addClass("menu-marked");
|
||||
i[0].checked = true;
|
||||
}
|
||||
});
|
||||
psm && psm.update();
|
||||
}
|
||||
|
||||
function unmark(){
|
||||
sessionStorage.removeItem(baseUriFull+'search-value');
|
||||
$("mark").parents("li").each( function(){
|
||||
var i = jQuery(this).children("input.toggle.menu-marked");
|
||||
if( i.length ){
|
||||
e = jQuery(i[0]);
|
||||
i[0].checked = (e.attr("data-checked")=="true");
|
||||
e.attr("data-checked", null).removeClass("menu-marked");
|
||||
}
|
||||
});
|
||||
$("mark").parents(".expand-marked").removeClass("expand-marked");
|
||||
$(".highlightable").unhighlight({ element: 'mark' })
|
||||
psm && psm.update();
|
||||
}
|
||||
|
||||
function initSearch() {
|
||||
jQuery('[data-search-input]').on('input', function() {
|
||||
var input = jQuery(this);
|
||||
var value = input.val();
|
||||
unmark();
|
||||
if (value.length) {
|
||||
sessionStorage.setItem(baseUriFull+'search-value', value);
|
||||
mark();
|
||||
}
|
||||
});
|
||||
jQuery('[data-search-clear]').on('click', function() {
|
||||
jQuery('[data-search-input]').val('').trigger('input');
|
||||
unmark();
|
||||
});
|
||||
mark();
|
||||
|
||||
// custom sizzle case insensitive "contains" pseudo selector
|
||||
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
|
||||
return function( elem ) {
|
||||
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
||||
};
|
||||
});
|
||||
|
||||
// set initial search value on page load
|
||||
if (sessionStorage.getItem(baseUriFull+'search-value')) {
|
||||
var searchValue = sessionStorage.getItem(baseUriFull+'search-value')
|
||||
$('[data-search-input]').val(searchValue);
|
||||
$('[data-search-input]').trigger('input');
|
||||
var searchedElem = $('#body-inner').find(':contains(' + searchValue + ')').get(0);
|
||||
if (searchedElem) {
|
||||
searchedElem.scrollIntoView(true);
|
||||
var scrolledY = window.scrollY;
|
||||
if(scrolledY){
|
||||
window.scroll(0, scrolledY - 125);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mark some additonal stuff as searchable
|
||||
$('#topbar a:not(:has(img)):not(.btn)').addClass('highlight');
|
||||
$('#body-inner a:not(:has(img)):not(.btn):not(a[rel="footnote"])').addClass('highlight');
|
||||
}
|
||||
|
||||
// Get Parameters from some url
|
||||
function getUrlParameter(sPageURL) {
|
||||
var getUrlParameter = function getUrlParameter(sPageURL) {
|
||||
var url = sPageURL.split('?');
|
||||
var obj = {};
|
||||
if (url.length == 2) {
|
||||
|
@ -872,8 +570,86 @@ jQuery(function() {
|
|||
initCodeClipboard();
|
||||
restoreTabSelections();
|
||||
initSwipeHandler();
|
||||
initHistory();
|
||||
initSearch();
|
||||
|
||||
jQuery('[data-clear-history-toggle]').on('click', function() {
|
||||
for( var item in sessionStorage ){
|
||||
if( item.substring( 0, baseUriFull.length ) === baseUriFull ){
|
||||
sessionStorage.removeItem( item );
|
||||
}
|
||||
}
|
||||
location.reload();
|
||||
return false;
|
||||
});
|
||||
|
||||
var ajax;
|
||||
jQuery('[data-search-input]').on('input', function() {
|
||||
var input = jQuery(this),
|
||||
value = input.val(),
|
||||
items = jQuery('[data-nav-id]');
|
||||
items.removeClass('search-match');
|
||||
if (!value.length) {
|
||||
$('ul.topics').removeClass('searched');
|
||||
items.css('display', 'block');
|
||||
sessionStorage.removeItem(baseUriFull+'search-value');
|
||||
$("mark").parents(".expand-marked").removeClass("expand-marked");
|
||||
$(".highlightable").unhighlight({ element: 'mark' })
|
||||
return;
|
||||
}
|
||||
|
||||
sessionStorage.setItem(baseUriFull+'search-value', value);
|
||||
$("mark").parents(".expand-marked").removeClass("expand-marked");
|
||||
$(".highlightable").unhighlight({ element: 'mark' }).highlight(value, { element: 'mark' });
|
||||
$("mark").parents(".expand").addClass("expand-marked");
|
||||
|
||||
if (ajax && ajax.abort) ajax.abort();
|
||||
|
||||
jQuery('[data-search-clear]').on('click', function() {
|
||||
jQuery('[data-search-input]').val('').trigger('input');
|
||||
sessionStorage.removeItem(baseUriFull+'search-input');
|
||||
$("mark").parents(".expand-marked").removeClass("expand-marked");
|
||||
$(".highlightable").unhighlight({ element: 'mark' })
|
||||
});
|
||||
});
|
||||
|
||||
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
|
||||
return function( elem ) {
|
||||
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
||||
};
|
||||
});
|
||||
|
||||
if (sessionStorage.getItem(baseUriFull+'search-value')) {
|
||||
var searchValue = sessionStorage.getItem(baseUriFull+'search-value')
|
||||
$('[data-search-input]').val(searchValue);
|
||||
$('[data-search-input]').trigger('input');
|
||||
var searchedElem = $('#body-inner').find(':contains(' + searchValue + ')').get(0);
|
||||
if (searchedElem) {
|
||||
searchedElem.scrollIntoView(true);
|
||||
var scrolledY = window.scrollY;
|
||||
if(scrolledY){
|
||||
window.scroll(0, scrolledY - 125);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(".highlightable").highlight(sessionStorage.getItem(baseUriFull+'search-value'), { element: 'mark' });
|
||||
$("mark").parents(".expand").addClass("expand-marked");
|
||||
|
||||
$('#topbar a:not(:has(img)):not(.btn)').addClass('highlight');
|
||||
$('#body-inner a:not(:has(img)):not(.btn):not(a[rel="footnote"])').addClass('highlight');
|
||||
|
||||
var visitedItem = baseUriFull + 'visited-url/'
|
||||
sessionStorage.setItem(visitedItem+jQuery('body').data('url'), 1);
|
||||
|
||||
// loop through the sessionStorage and see if something should be marked as visited
|
||||
for( var item in sessionStorage ){
|
||||
if( item.substring( 0, visitedItem.length ) === visitedItem && sessionStorage.getItem( item ) == 1 ){
|
||||
var url = item.substring( visitedItem.length );
|
||||
// in case we have `relativeURLs=true` we have to strip the
|
||||
// relative path to root
|
||||
url = url.replace( /\.\.\//g, '/' ).replace( /^\/+\//, '/' );
|
||||
jQuery('[data-nav-id="' + url + '"]').addClass('visited');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
jQuery.extend({
|
||||
|
@ -949,30 +725,3 @@ jQuery.fn.highlight = function(words, options) {
|
|||
jQuery.highlight(this, re, settings.element, settings.className);
|
||||
});
|
||||
};
|
||||
|
||||
function useMermaid( config ){
|
||||
if( !Object.assign ){
|
||||
// We don't support Mermaid for IE11 anyways, so bail out early
|
||||
return;
|
||||
}
|
||||
if (typeof mermaid != 'undefined' && typeof mermaid.mermaidAPI != 'undefined') {
|
||||
mermaid.initialize( Object.assign( { "securityLevel": "antiscript", "startOnLoad": false }, config ) );
|
||||
if( config.theme && variants ){
|
||||
var write_style = variants.findLoadedStylesheet( 'variant-style' );
|
||||
write_style.setProperty( '--CONFIG-MERMAID-theme', config.theme );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( window.themeUseMermaid ){
|
||||
useMermaid( window.themeUseMermaid );
|
||||
}
|
||||
|
||||
function useSwagger( config ){
|
||||
if( config.theme && variants ){
|
||||
var write_style = variants.findLoadedStylesheet( 'variant-style' );
|
||||
write_style.setProperty( '--CONFIG-SWAGGER-theme', config.theme );
|
||||
}
|
||||
}
|
||||
if( window.themeUseSwagger ){
|
||||
useSwagger( window.themeUseSwagger );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue