1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-24 15:40:15 +01:00

Compatibility update for Internet Explorer

This commit is contained in:
squidfunk 2016-12-28 18:54:26 +01:00
parent 3f5957bd01
commit db73d4863a
12 changed files with 113 additions and 103 deletions

View File

@ -39,12 +39,13 @@ export default /* JSX */ {
/* Set all properties */ /* Set all properties */
if (properties) if (properties)
for (const attr of Object.keys(properties)) Array.prototype.forEach.call(Object.keys(properties), attr => {
el.setAttribute(attr, properties[attr]) el.setAttribute(attr, properties[attr])
})
/* Iterate child nodes */ /* Iterate child nodes */
const iterateChildNodes = nodes => { const iterateChildNodes = nodes => {
for (const node of nodes) { Array.prototype.forEach.call(nodes, node => {
/* Directly append text content */ /* Directly append text content */
if (typeof node === "string" || if (typeof node === "string" ||
@ -59,7 +60,7 @@ export default /* JSX */ {
} else { } else {
el.appendChild(node) el.appendChild(node)
} }
} })
} }
/* Iterate child nodes and return element */ /* Iterate child nodes and return element */

View File

@ -39,6 +39,7 @@ export default (gulp, config, args) => {
.pipe( .pipe(
stream({ stream({
entry: [ entry: [
"core-js/fn/promise",
"whatwg-fetch", "whatwg-fetch",
"application.js" "application.js"
], ],

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -110,7 +110,7 @@
<script src="https://cdn.mathjax.org/{{ path }}"></script> <script src="https://cdn.mathjax.org/{{ path }}"></script>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<script src="{{ base_url }}/assets/javascripts/application-5c0b7e9d97.js"></script> <script src="{{ base_url }}/assets/javascripts/application-7f2d08a2e5.js"></script>
<script> <script>
/* Configuration for application */ /* Configuration for application */
var config = { var config = {

View File

@ -29,7 +29,7 @@ repo_name: squidfunk/mkdocs-material
repo_url: https://github.com/squidfunk/mkdocs-material repo_url: https://github.com/squidfunk/mkdocs-material
# Copyright # Copyright
copyright: 'Copyright &copy 2016 Martin Donath' copyright: 'Copyright &copy; 2016 Martin Donath'
# Documentation and theme # Documentation and theme
theme_dir: material theme_dir: material

View File

@ -36,11 +36,12 @@
"babel-loader": "^6.2.4", "babel-loader": "^6.2.4",
"babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-react-jsx": "^6.8.0", "babel-plugin-transform-react-jsx": "^6.8.0",
"babel-polyfill": "^6.16.0", "babel-polyfill": "^6.20.0",
"babel-preset-es2015": "^6.13.2", "babel-preset-es2015": "^6.13.2",
"babel-register": "^6.16.3", "babel-register": "^6.16.3",
"babel-root-import": "^4.1.3", "babel-root-import": "^4.1.3",
"chai": "^3.5.0", "chai": "^3.5.0",
"core-js": "^2.4.1",
"css-mqpacker": "^4.0.0", "css-mqpacker": "^4.0.0",
"del": "^2.2.0", "del": "^2.2.0",
"eslint": "^3.6.1", "eslint": "^3.6.1",

View File

@ -62,7 +62,7 @@ export default class Application {
/* Wrap all data tables */ /* Wrap all data tables */
const tables = document.querySelectorAll("table:not([class])") const tables = document.querySelectorAll("table:not([class])")
for (const table of tables) { Array.prototype.forEach.call(tables, table => {
const wrap = document.createElement("div") const wrap = document.createElement("div")
wrap.classList.add("md-typeset__table") wrap.classList.add("md-typeset__table")
if (table.nextSibling) { if (table.nextSibling) {
@ -71,7 +71,7 @@ export default class Application {
table.parentNode.appendChild(wrap) table.parentNode.appendChild(wrap)
} }
wrap.appendChild(table) wrap.appendChild(table)
} })
}).listen() }).listen()
/* Cross-browser helper to dispatch/fire an event */ /* Cross-browser helper to dispatch/fire an event */
@ -108,10 +108,11 @@ export default class Application {
/* Component: collapsible elements for navigation */ /* Component: collapsible elements for navigation */
const collapsibles = const collapsibles =
document.querySelectorAll("[data-md-component=collapsible]") document.querySelectorAll("[data-md-component=collapsible]")
for (const collapse of collapsibles) Array.prototype.forEach.call(collapsibles, collapse => {
new Material.Event.MatchMedia("(min-width: 1200px)", new Material.Event.MatchMedia("(min-width: 1200px)",
new Material.Event.Listener(collapse.previousElementSibling, "click", new Material.Event.Listener(collapse.previousElementSibling, "click",
new Material.Nav.Collapse(collapse))) new Material.Nav.Collapse(collapse)))
})
/* Component: pane monitor for iOS scrolling fixes */ /* Component: pane monitor for iOS scrolling fixes */
new Material.Event.MatchMedia("(max-width: 1199px)", new Material.Event.MatchMedia("(max-width: 1199px)",
@ -218,9 +219,10 @@ export default class Application {
/* Render repository source information */ /* Render repository source information */
})().then(facts => { })().then(facts => {
const sources = document.querySelectorAll("[data-md-source]") const sources = document.querySelectorAll("[data-md-source]")
for (const source of sources) Array.prototype.forEach.call(sources, source => {
new Material.Source.Repository(source) new Material.Source.Repository(source)
.initialize(facts) .initialize(facts)
})
}) })
} }
} }

View File

@ -53,9 +53,11 @@ export default class Listener {
* Register listener for all relevant events * Register listener for all relevant events
*/ */
listen() { listen() {
for (const el of this.els_) Array.prototype.forEach.call(this.els_, el => {
for (const event of this.events_) this.events_.forEach(event => {
el.addEventListener(event, this.update_, false) el.addEventListener(event, this.update_, false)
})
})
/* Execute setup handler, if implemented */ /* Execute setup handler, if implemented */
if (typeof this.handler_.setup === "function") if (typeof this.handler_.setup === "function")
@ -66,9 +68,11 @@ export default class Listener {
* Unregister listener for all relevant events * Unregister listener for all relevant events
*/ */
unlisten() { unlisten() {
for (const el of this.els_) Array.prototype.forEach.call(this.els_, el => {
for (const event of this.events_) this.events_.forEach(event => {
el.removeEventListener(event, this.update_) el.removeEventListener(event, this.update_)
})
})
/* Execute reset handler, if implemented */ /* Execute reset handler, if implemented */
if (typeof this.handler_.reset === "function") if (typeof this.handler_.reset === "function")

View File

@ -100,8 +100,9 @@ export default class Blur {
* Reset anchor states * Reset anchor states
*/ */
reset() { reset() {
for (const el of this.els_) Array.prototype.forEach.call(this.els_, el => {
el.dataset.mdState = "" el.dataset.mdState = ""
})
/* Reset index and page y-offset */ /* Reset index and page y-offset */
this.index_ = 0 this.index_ = 0

View File

@ -48,23 +48,23 @@ export default class Scrolling {
/* Find all toggles and check which one is active */ /* Find all toggles and check which one is active */
const toggles = this.el_.querySelectorAll("[data-md-toggle]") const toggles = this.el_.querySelectorAll("[data-md-toggle]")
for (const toggle of toggles) { Array.prototype.forEach.call(toggles, toggle => {
if (!toggle.checked) if (toggle.checked) {
return
/* Find corresponding navigational pane */ /* Find corresponding navigational pane */
let pane = toggle.nextElementSibling let pane = toggle.nextElementSibling
while (pane.tagName !== "NAV") while (pane.tagName !== "NAV")
pane = pane.nextElementSibling pane = pane.nextElementSibling
/* Find current and parent list elements */ /* Find current and parent list elements */
const parent = toggle.parentNode.parentNode const parent = toggle.parentNode.parentNode
const target = pane.children[pane.children.length - 1] const target = pane.children[pane.children.length - 1]
/* Always reset all lists when transitioning */ /* Always reset all lists when transitioning */
parent.style.webkitOverflowScrolling = "" parent.style.webkitOverflowScrolling = ""
target.style.webkitOverflowScrolling = "touch" target.style.webkitOverflowScrolling = "touch"
} }
})
} }
/** /**
@ -116,22 +116,22 @@ export default class Scrolling {
/* Find all toggles and check which one is active */ /* Find all toggles and check which one is active */
const toggles = this.el_.querySelectorAll("[data-md-toggle]") const toggles = this.el_.querySelectorAll("[data-md-toggle]")
for (const toggle of toggles) { Array.prototype.forEach.call(toggles, toggle => {
if (!toggle.checked) if (toggle.checked) {
return
/* Find corresponding navigational pane */ /* Find corresponding navigational pane */
let pane = toggle.nextElementSibling let pane = toggle.nextElementSibling
while (pane.tagName !== "NAV") while (pane.tagName !== "NAV")
pane = pane.nextElementSibling pane = pane.nextElementSibling
/* Find current and parent list elements */ /* Find current and parent list elements */
const parent = toggle.parentNode.parentNode const parent = toggle.parentNode.parentNode
const target = pane.children[pane.children.length - 1] const target = pane.children[pane.children.length - 1]
/* Always reset all lists when transitioning */ /* Always reset all lists when transitioning */
parent.style.webkitOverflowScrolling = "" parent.style.webkitOverflowScrolling = ""
target.style.webkitOverflowScrolling = "" target.style.webkitOverflowScrolling = ""
} }
})
} }
} }

View File

@ -111,7 +111,7 @@ export default class Result {
/* Perform search on index and render documents */ /* Perform search on index and render documents */
const result = this.index_.search(ev.target.value) const result = this.index_.search(ev.target.value)
for (const item of result) { result.forEach(item => {
const doc = this.data_[item.ref] const doc = this.data_[item.ref]
this.list_.appendChild( this.list_.appendChild(
<li class="md-search-result__item"> <li class="md-search-result__item">
@ -128,7 +128,7 @@ export default class Result {
</a> </a>
</li> </li>
) )
} })
/* Update search metadata */ /* Update search metadata */
this.meta_.textContent = this.meta_.textContent =