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

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

View File

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

View File

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

View File

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

View File

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