mirror of
https://github.com/mbirth/tcl_update_db.git
synced 2024-12-27 04:54:08 +00:00
Move script tags to top, run after DOM Ready.
This commit is contained in:
parent
3e86408b90
commit
61706d8651
@ -1,25 +1,27 @@
|
|||||||
window.mdc.autoInit()
|
document.addEventListener 'DOMContentLoaded', (event) ->
|
||||||
window.tabBar = new mdc.tabs.MDCTabBar document.querySelector '#tab-bar'
|
|
||||||
|
|
||||||
# Hide all panels but the selected one
|
window.mdc.autoInit()
|
||||||
activatePanel = (panelId) ->
|
window.tabBar = new mdc.tabs.MDCTabBar document.querySelector '#tab-bar'
|
||||||
|
|
||||||
|
# Hide all panels but the selected one
|
||||||
|
activatePanel = (panelId) ->
|
||||||
allPanels = document.querySelectorAll '.panel'
|
allPanels = document.querySelectorAll '.panel'
|
||||||
for panel, i in allPanels
|
for panel, i in allPanels
|
||||||
if panel.id is panelId
|
if panel.id is panelId
|
||||||
tabBar.activeTabIndex = i
|
tabBar.activeTabIndex = i
|
||||||
panel.style.display = if panel.id is panelId then 'block' else 'none'
|
panel.style.display = if panel.id is panelId then 'block' else 'none'
|
||||||
|
|
||||||
# React to clicking the tabs
|
# React to clicking the tabs
|
||||||
window.tabBar.listen 'MDCTabBar:change', (t) ->
|
window.tabBar.listen 'MDCTabBar:change', (t) ->
|
||||||
nthChildIndex = t.detail.activeTabIndex
|
nthChildIndex = t.detail.activeTabIndex
|
||||||
tabId = t.srcElement.id
|
tabId = t.srcElement.id
|
||||||
tab = document.querySelector "##{tabId} .mdc-tab:nth-child(#{nthChildIndex + 1})"
|
tab = document.querySelector "##{tabId} .mdc-tab:nth-child(#{nthChildIndex + 1})"
|
||||||
panelId = tab.dataset.panel
|
panelId = tab.dataset.panel
|
||||||
activatePanel panelId
|
activatePanel panelId
|
||||||
|
|
||||||
# If specific tab/panel given in URL, e.g. #motion, switch to that
|
# If specific tab/panel given in URL, e.g. #motion, switch to that
|
||||||
hash = location.hash
|
hash = location.hash
|
||||||
if hash.length > 1
|
if hash.length > 1
|
||||||
activatePanel 'family-' + hash.substring 1
|
activatePanel 'family-' + hash.substring 1
|
||||||
else
|
else
|
||||||
activatePanel 'family-keyone'
|
activatePanel 'family-keyone'
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
<link rel="stylesheet" href="node_modules/material-components-web/dist/material-components-web.css"/>
|
<link rel="stylesheet" href="node_modules/material-components-web/dist/material-components-web.css"/>
|
||||||
<link rel="stylesheet" href="assets/material-icons.css"/>
|
<link rel="stylesheet" href="assets/material-icons.css"/>
|
||||||
<link rel="stylesheet" href="assets/style.css"/>
|
<link rel="stylesheet" href="assets/style.css"/>
|
||||||
|
<script type="text/javascript" src="node_modules/material-components-web/dist/material-components-web.js"></script>
|
||||||
|
<script type="text/javascript" src="assets/main.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="mdc-typography">
|
<body class="mdc-typography">
|
||||||
<?php
|
<?php
|
||||||
@ -90,7 +92,5 @@ foreach ($allVars as $family => $models) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</main>
|
</main>
|
||||||
<script type="text/javascript" src="node_modules/material-components-web/dist/material-components-web.js"></script>
|
|
||||||
<script type="text/javascript" src="assets/main.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user