mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-28 09:20:52 +01:00
Added back patched
This commit is contained in:
parent
d664fafa6a
commit
44751785a0
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
material/assets/javascripts/bundle.4fa4ebaf.min.js
vendored
Normal file
2
material/assets/javascripts/bundle.4fa4ebaf.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
material/assets/javascripts/bundle.4fa4ebaf.min.js.map
Normal file
1
material/assets/javascripts/bundle.4fa4ebaf.min.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
material/assets/javascripts/vendor.e32ed4d0.min.js.map
Normal file
1
material/assets/javascripts/vendor.e32ed4d0.min.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -1,16 +1,16 @@
|
|||||||
{
|
{
|
||||||
"assets/javascripts/bundle.js": "assets/javascripts/bundle.2bc3a92a.min.js",
|
"assets/javascripts/bundle.js": "assets/javascripts/bundle.4fa4ebaf.min.js",
|
||||||
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.2bc3a92a.min.js.map",
|
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.4fa4ebaf.min.js.map",
|
||||||
"assets/javascripts/vendor.js": "assets/javascripts/vendor.6b8ac966.min.js",
|
"assets/javascripts/vendor.js": "assets/javascripts/vendor.e32ed4d0.min.js",
|
||||||
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.6b8ac966.min.js.map",
|
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.e32ed4d0.min.js.map",
|
||||||
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.b9424174.min.js",
|
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.b9424174.min.js",
|
||||||
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.b9424174.min.js.map",
|
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.b9424174.min.js.map",
|
||||||
"assets/stylesheets/main.css": "assets/stylesheets/main.6ced4fc6.min.css",
|
"assets/stylesheets/main.css": "assets/stylesheets/main.a86e6725.min.css",
|
||||||
"assets/stylesheets/main.css.map": "assets/stylesheets/main.6ced4fc6.min.css.map",
|
"assets/stylesheets/main.css.map": "assets/stylesheets/main.a86e6725.min.css.map",
|
||||||
"assets/stylesheets/palette.css": "assets/stylesheets/palette.e70b70b6.min.css",
|
"assets/stylesheets/palette.css": "assets/stylesheets/palette.e70b70b6.min.css",
|
||||||
"assets/stylesheets/palette.css.map": "assets/stylesheets/palette.e70b70b6.min.css.map",
|
"assets/stylesheets/palette.css.map": "assets/stylesheets/palette.e70b70b6.min.css.map",
|
||||||
"overrides/assets/javascripts/bundle.js": "overrides/assets/javascripts/bundle.b79ba6f2.min.js",
|
"overrides/assets/javascripts/bundle.js": "overrides/assets/javascripts/bundle.9f9f98ea.min.js",
|
||||||
"overrides/assets/javascripts/bundle.js.map": "overrides/assets/javascripts/bundle.b79ba6f2.min.js.map",
|
"overrides/assets/javascripts/bundle.js.map": "overrides/assets/javascripts/bundle.9f9f98ea.min.js.map",
|
||||||
"overrides/assets/javascripts/vendor.js": "overrides/assets/javascripts/vendor.1aa446d9.min.js",
|
"overrides/assets/javascripts/vendor.js": "overrides/assets/javascripts/vendor.1aa446d9.min.js",
|
||||||
"overrides/assets/javascripts/vendor.js.map": "overrides/assets/javascripts/vendor.1aa446d9.min.js.map",
|
"overrides/assets/javascripts/vendor.js.map": "overrides/assets/javascripts/vendor.1aa446d9.min.js.map",
|
||||||
"overrides/assets/stylesheets/main.css": "overrides/assets/stylesheets/main.8e98f424.min.css",
|
"overrides/assets/stylesheets/main.css": "overrides/assets/stylesheets/main.8e98f424.min.css",
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
material/assets/stylesheets/main.a86e6725.min.css.map
Normal file
1
material/assets/stylesheets/main.a86e6725.min.css.map
Normal file
File diff suppressed because one or more lines are too long
@ -39,7 +39,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.6ced4fc6.min.css' | url }}">
|
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.a86e6725.min.css' | url }}">
|
||||||
{% if config.theme.palette %}
|
{% if config.theme.palette %}
|
||||||
{% set palette = config.theme.palette %}
|
{% set palette = config.theme.palette %}
|
||||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e70b70b6.min.css' | url }}">
|
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e70b70b6.min.css' | url }}">
|
||||||
@ -216,8 +216,8 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/vendor.6b8ac966.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/vendor.e32ed4d0.min.js' | url }}"></script>
|
||||||
<script src="{{ 'assets/javascripts/bundle.2bc3a92a.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.4fa4ebaf.min.js' | url }}"></script>
|
||||||
{% for path in config["extra_javascript"] %}
|
{% for path in config["extra_javascript"] %}
|
||||||
<script src="{{ path | url }}"></script>
|
<script src="{{ path | url }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
2
material/overrides/assets/javascripts/bundle.9f9f98ea.min.js
vendored
Normal file
2
material/overrides/assets/javascripts/bundle.9f9f98ea.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){function t(t){for(var r,i,a=t[0],s=t[1],u=t[2],f=0,p=[];f<a.length;f++)i=a[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r]);for(l&&l(t);p.length;)p.shift()();return c.push.apply(c,u||[]),n()}function n(){for(var e,t=0;t<c.length;t++){for(var n=c[t],r=!0,a=1;a<n.length;a++){var s=n[a];0!==o[s]&&(r=!1)}r&&(c.splice(t--,1),e=i(i.s=n[0]))}return e}var r={},o={0:0},c=[];function i(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="";var a=window.webpackJsonp=window.webpackJsonp||[],s=a.push.bind(a);a.push=t,a=a.slice();for(var u=0;u<a.length;u++)t(a[u]);var l=s;return c.push([37,1]),n()}({37:function(e,t,n){"use strict";n.r(t);var r=n(20),o=n(3),c=n(38),i=n(29),a=n(25);n(32),n(39);function s(e,t=document){return t.querySelector(e)||void 0}function u(e,t=document){const n=s(e,t);if(void 0===n)throw new ReferenceError(`Missing element: expected "${e}" to be present`);return n}n(50);var l=n(51);var f=n(17),p=n(40),d=n(41),b=n(42),g=n(43),h=n(44);n(45),n(46);const v=new f.a;Object(p.a)(()=>Object(d.a)(new ResizeObserver(e=>{for(const t of e)v.next(t)}))).pipe(Object(i.a)(e=>b.a.pipe(Object(l.a)(e)).pipe(Object(g.a)(()=>e.disconnect()))),Object(h.a)(1));n(31);n(47);u("[data-md-toggle=drawer]"),u("[data-md-toggle=search]");n(52),n(53);n(48),n(49);function O(e,t){if("string"==typeof t||"number"==typeof t)e.innerHTML+=t.toString();else if(t instanceof Node)e.appendChild(t);else if(Array.isArray(t))for(const n of t)O(e,n)}function j(e,t,...n){const r=document.createElement(e);if(t)for(const e of Object.keys(t))"boolean"!=typeof t[e]?r.setAttribute(e,t[e]):t[e]&&r.setAttribute(e,"");for(const e of n)O(r,e);return r}function m(e,t){return t.length?j("div",{class:""},j("span",null,function(e){if(e>999){return((e+1e-6)/1e3).toFixed(+((e-950)%1e3>99))+"k"}return e.toString()}(e.length)," results"),j("ul",{class:"tx-icon-search__list"},e.slice(0,10).map(e=>j("li",{class:"tx-icon-search__item"},j("span",{class:"twemoji"},j("img",{src:"https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/material/.icons/"+e,style:"width: 18px; height: 18px"}))," – ",j("button",{class:"md-clipboard--inline","data-clipboard-text":":"+e.replace(/\.svg$/,"").replace(/\//g,"-")+":"},j("code",null,function(e,t){return`:${Object(r.wrap)(e.replace(/\.svg$/,"").replace(/\//g,"-"),t,{wrap:{tagOpen:"<b>",tagClose:"</b>"}})}:`}(e,t))))))):j("div",{class:""})}const y=u("#__config"),w=JSON.parse(y.textContent),x=Object(o.a)(fetch(w.base+"/overrides/assets/javascripts/icons.json").then(e=>e.json())),_=s("#icon-search");_&&x.pipe(Object(i.a)(e=>Object(c.a)(_,"keyup").pipe(Object(a.a)(()=>Object(r.filter)(e,_.value))))).subscribe(e=>{const t=u(".tx-icon-result");t.innerHTML="",t.appendChild(m(e,_.value))}),Object(c.a)(document.body,"click").subscribe(e=>{if(e.target instanceof HTMLElement){e.target.closest("a[href^=http]")instanceof HTMLLinkElement&&ga("send","event","outbound","click",y.href)}})}}));
|
||||||
|
//# sourceMappingURL=bundle.9f9f98ea.min.js.map
|
File diff suppressed because one or more lines are too long
@ -1,2 +0,0 @@
|
|||||||
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){function t(t){for(var r,i,a=t[0],s=t[1],u=t[2],f=0,p=[];f<a.length;f++)i=a[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r]);for(l&&l(t);p.length;)p.shift()();return c.push.apply(c,u||[]),n()}function n(){for(var e,t=0;t<c.length;t++){for(var n=c[t],r=!0,a=1;a<n.length;a++){var s=n[a];0!==o[s]&&(r=!1)}r&&(c.splice(t--,1),e=i(i.s=n[0]))}return e}var r={},o={0:0},c=[];function i(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="";var a=window.webpackJsonp=window.webpackJsonp||[],s=a.push.bind(a);a.push=t,a=a.slice();for(var u=0;u<a.length;u++)t(a[u]);var l=s;return c.push([37,1]),n()}({37:function(e,t,n){"use strict";n.r(t);var r=n(20),o=n(3),c=n(38),i=n(45),a=n(29),s=n(25);n(32),n(39);function u(e,t=document){return t.querySelector(e)||void 0}function l(e,t=document){const n=u(e,t);if(void 0===n)throw new ReferenceError(`Missing element: expected "${e}" to be present`);return n}n(50);var f=n(51);var p=n(17),d=n(40),b=n(41),g=n(42),h=n(43),v=n(44);n(46);const O=new p.a;Object(d.a)(()=>Object(b.a)(new ResizeObserver(e=>{for(const t of e)O.next(t)}))).pipe(Object(a.a)(e=>g.a.pipe(Object(f.a)(e)).pipe(Object(h.a)(()=>e.disconnect()))),Object(v.a)(1));n(31);n(47);l("[data-md-toggle=drawer]"),l("[data-md-toggle=search]");n(52),n(53);n(48),n(49);function j(e,t){if("string"==typeof t||"number"==typeof t)e.innerHTML+=t.toString();else if(t instanceof Node)e.appendChild(t);else if(Array.isArray(t))for(const n of t)j(e,n)}function m(e,t,...n){const r=document.createElement(e);if(t)for(const e of Object.keys(t))"boolean"!=typeof t[e]?r.setAttribute(e,t[e]):t[e]&&r.setAttribute(e,"");for(const e of n)j(r,e);return r}function y(e,t){return t.length?m("div",{class:""},m("span",null,function(e){if(e>999){return((e+1e-6)/1e3).toFixed(+((e-950)%1e3>99))+"k"}return e.toString()}(e.length)," results"),m("ul",{class:"tx-icon-search__list"},e.slice(0,10).map(e=>m("li",{class:"tx-icon-search__item"},m("span",{class:"twemoji"},m("img",{src:"https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/material/.icons/"+e,style:"width: 18px; height: 18px"}))," – ",m("button",{class:"md-clipboard--inline","data-clipboard-text":":"+e.replace(/\.svg$/,"").replace(/\//g,"-")+":"},m("code",null,function(e,t){return`:${Object(r.wrap)(e.replace(/\.svg$/,"").replace(/\//g,"-"),t,{wrap:{tagOpen:"<b>",tagClose:"</b>"}})}:`}(e,t))))))):m("div",{class:""})}const w=l("#__config"),x=JSON.parse(w.textContent),_=Object(o.a)(fetch(x.base+"/overrides/assets/javascripts/icons.json").then(e=>e.json())),k=u("#icon-search");k&&_.pipe(Object(i.a)(console.log),Object(a.a)(e=>Object(c.a)(k,"keyup").pipe(Object(s.a)(()=>Object(r.filter)(e,k.value))))).subscribe(e=>{const t=l(".tx-icon-result");t.innerHTML="",t.appendChild(y(e,k.value))}),Object(c.a)(document.body,"click").subscribe(e=>{if(e.target instanceof HTMLElement){e.target.closest("a[href^=http]")instanceof HTMLLinkElement&&ga("send","event","outbound","click",w.href)}})}}));
|
|
||||||
//# sourceMappingURL=bundle.b79ba6f2.min.js.map
|
|
File diff suppressed because one or more lines are too long
@ -54,5 +54,5 @@
|
|||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script src="{{ 'overrides/assets/javascripts/vendor.1aa446d9.min.js' | url }}"></script>
|
<script src="{{ 'overrides/assets/javascripts/vendor.1aa446d9.min.js' | url }}"></script>
|
||||||
<script src="{{ 'overrides/assets/javascripts/bundle.b79ba6f2.min.js' | url }}"></script>
|
<script src="{{ 'overrides/assets/javascripts/bundle.9f9f98ea.min.js' | url }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -58,6 +58,10 @@ import {
|
|||||||
setupClipboardJS,
|
setupClipboardJS,
|
||||||
setupInstantLoading
|
setupInstantLoading
|
||||||
} from "./integrations"
|
} from "./integrations"
|
||||||
|
import {
|
||||||
|
patchIndeterminate,
|
||||||
|
patchScrollfix
|
||||||
|
} from "./patches"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Program
|
* Program
|
||||||
@ -86,6 +90,10 @@ setupClipboardJS({ alert$ })
|
|||||||
if (feature("navigation.instant"))
|
if (feature("navigation.instant"))
|
||||||
setupInstantLoading({ document$, location$, viewport$ })
|
setupInstantLoading({ document$, location$, viewport$ })
|
||||||
|
|
||||||
|
/* Set up patches */
|
||||||
|
patchIndeterminate({ document$ })
|
||||||
|
patchScrollfix({ document$ })
|
||||||
|
|
||||||
/* Set up header observable */
|
/* Set up header observable */
|
||||||
const header$ = watchHeader(
|
const header$ = watchHeader(
|
||||||
getElementOrThrow("[data-md-component=header]"),
|
getElementOrThrow("[data-md-component=header]"),
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
EMPTY,
|
||||||
NEVER,
|
NEVER,
|
||||||
Observable,
|
Observable,
|
||||||
Subject,
|
Subject,
|
||||||
@ -31,6 +32,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
bufferCount,
|
bufferCount,
|
||||||
catchError,
|
catchError,
|
||||||
|
concatMap,
|
||||||
debounceTime,
|
debounceTime,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
distinctUntilKeyChanged,
|
distinctUntilKeyChanged,
|
||||||
@ -47,7 +49,9 @@ import { configuration } from "~/_"
|
|||||||
import {
|
import {
|
||||||
Viewport,
|
Viewport,
|
||||||
ViewportOffset,
|
ViewportOffset,
|
||||||
|
createElement,
|
||||||
getElement,
|
getElement,
|
||||||
|
getElementOrThrow,
|
||||||
getElements,
|
getElements,
|
||||||
replaceElement,
|
replaceElement,
|
||||||
request,
|
request,
|
||||||
@ -279,17 +283,44 @@ export function setupInstantLoading(
|
|||||||
"[data-md-component=container]",
|
"[data-md-component=container]",
|
||||||
"[data-md-component=skip]"
|
"[data-md-component=skip]"
|
||||||
]) {
|
]) {
|
||||||
const next = getElement(selector, replacement)
|
const source = getElement(selector)
|
||||||
const prev = getElement(selector)
|
const target = getElement(selector, replacement)
|
||||||
if (
|
if (
|
||||||
typeof next !== "undefined" &&
|
typeof source !== "undefined" &&
|
||||||
typeof prev !== "undefined"
|
typeof target !== "undefined"
|
||||||
) {
|
) {
|
||||||
replaceElement(prev, next)
|
replaceElement(source, target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/* Re-evaluate scripts */
|
||||||
|
document$
|
||||||
|
.pipe(
|
||||||
|
skip(1),
|
||||||
|
map(() => getElementOrThrow("[data-md-component=container]")),
|
||||||
|
switchMap(el => of(...getElements("script", el))),
|
||||||
|
concatMap(el => {
|
||||||
|
const script = createElement("script")
|
||||||
|
if (el.src) {
|
||||||
|
script.src = el.src
|
||||||
|
replaceElement(el, script)
|
||||||
|
|
||||||
|
/* Complete when script is loaded */
|
||||||
|
return new Observable(observer => {
|
||||||
|
script.onload = () => observer.complete()
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Complete immediately */
|
||||||
|
} else {
|
||||||
|
script.textContent = el.textContent!
|
||||||
|
replaceElement(el, script)
|
||||||
|
return EMPTY
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
/* Debounce update of viewport offset */
|
/* Debounce update of viewport offset */
|
||||||
viewport$
|
viewport$
|
||||||
.pipe(
|
.pipe(
|
||||||
|
59
src/assets/javascripts/patches/indeterminate/index.ts
Normal file
59
src/assets/javascripts/patches/indeterminate/index.ts
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Observable } from "rxjs"
|
||||||
|
|
||||||
|
import { getElements } from "~/browser"
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Helper types
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch options
|
||||||
|
*/
|
||||||
|
interface PatchOptions {
|
||||||
|
document$: Observable<Document> /* Document observable */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Functions
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch indeterminate checkboxes
|
||||||
|
*
|
||||||
|
* @param options - Options
|
||||||
|
*/
|
||||||
|
export function patchIndeterminate(
|
||||||
|
{ document$ }: PatchOptions
|
||||||
|
): void {
|
||||||
|
document$.subscribe(() => {
|
||||||
|
for (const el of getElements<HTMLInputElement>(
|
||||||
|
"[data-md-state=indeterminate]"
|
||||||
|
)) {
|
||||||
|
el.setAttribute("data-md-state", "")
|
||||||
|
el.indeterminate = true
|
||||||
|
el.checked = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
24
src/assets/javascripts/patches/index.ts
Normal file
24
src/assets/javascripts/patches/index.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from "./indeterminate"
|
||||||
|
export * from "./scrollfix"
|
94
src/assets/javascripts/patches/scrollfix/index.ts
Normal file
94
src/assets/javascripts/patches/scrollfix/index.ts
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Observable, fromEvent, of } from "rxjs"
|
||||||
|
import { mapTo, mergeMap, switchMap, tap } from "rxjs/operators"
|
||||||
|
|
||||||
|
import { getElements } from "~/browser"
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Helper types
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch options
|
||||||
|
*/
|
||||||
|
interface PatchOptions {
|
||||||
|
document$: Observable<Document> /* Document observable */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Helper functions
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given device is an Apple device
|
||||||
|
*
|
||||||
|
* @returns Test result
|
||||||
|
*/
|
||||||
|
function isAppleDevice(): boolean {
|
||||||
|
return /(iPad|iPhone|iPod)/.test(navigator.userAgent)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Functions
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch all elements with `data-md-scrollfix` attributes
|
||||||
|
*
|
||||||
|
* This is a year-old patch which ensures that overflow scrolling works at the
|
||||||
|
* top and bottom of containers on iOS by ensuring a `1px` scroll offset upon
|
||||||
|
* the start of a touch event.
|
||||||
|
*
|
||||||
|
* @see https://bit.ly/2SCtAOO - Original source
|
||||||
|
*
|
||||||
|
* @param options - Options
|
||||||
|
*/
|
||||||
|
export function patchScrollfix(
|
||||||
|
{ document$ }: PatchOptions
|
||||||
|
): void {
|
||||||
|
if (isAppleDevice()) {
|
||||||
|
document$
|
||||||
|
.pipe(
|
||||||
|
switchMap(() => of(...getElements("[data-md-scrollfix]"))),
|
||||||
|
tap(el => el.removeAttribute("data-md-scrollfix")),
|
||||||
|
mergeMap(el => fromEvent(el, "touchstart")
|
||||||
|
.pipe(
|
||||||
|
mapTo(el)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.subscribe(el => {
|
||||||
|
const top = el.scrollTop
|
||||||
|
|
||||||
|
/* We're at the top of the container */
|
||||||
|
if (top === 0) {
|
||||||
|
el.scrollTop = 1
|
||||||
|
|
||||||
|
/* We're at the bottom of the container */
|
||||||
|
} else if (top + el.offsetHeight === el.scrollHeight) {
|
||||||
|
el.scrollTop = top - 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user