diff --git a/.gitignore b/.gitignore index 9c32455..7904443 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/assets/*.js +/assets/*.map /data/ /node_modules/ /config.ini diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2055c83 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +CC=node_modules/.bin/coffee +ASSETDIR=assets + +SRC=$(wildcard $(ASSETDIR)/*.coffee) +BUILD=$(SRC:%.coffee=%.js) + +all: coffee + +# coffeescript files + +coffee: $(BUILD) + +$(ASSETDIR)/%.js: $(ASSETDIR)/%.coffee + $(CC) -m -c $< + +# cleanup + +.PHONY: clean +clean: + -rm $(BUILD) + + diff --git a/assets/main.coffee b/assets/main.coffee new file mode 100644 index 0000000..d2b9a5a --- /dev/null +++ b/assets/main.coffee @@ -0,0 +1,81 @@ +document.addEventListener 'DOMContentLoaded', (event) -> + + window.mdc.autoInit() + window.tabBar = new mdc.tabs.MDCTabBar document.querySelector '#tab-bar' + + # Hide all panels but the selected one + activatePanel = (panelId) -> + allPanels = document.querySelectorAll '.panel' + for panel, i in allPanels + if panel.id is panelId + tabBar.activeTabIndex = i + panel.style.display = if panel.id is panelId then 'block' else 'none' + + # React to clicking the tabs + window.tabBar.listen 'MDCTabBar:change', (t) -> + nthChildIndex = t.detail.activeTabIndex + tabId = t.srcElement.id + tab = document.querySelector "##{tabId} .mdc-tab:nth-child(#{nthChildIndex + 1})" + panelId = tab.dataset.panel + activatePanel panelId + + # If specific tab/panel given in URL, e.g. #motion, switch to that + hash = location.hash + if hash.length > 1 + activatePanel 'family-' + hash.substring 1 + else + activatePanel 'family-keyone' + + window.showTooltip = (event) -> + tt = document.querySelector('#tooltip') + tt_title = document.querySelector('#tooltip-title') + tt_text = document.querySelector('#tooltip-text') + + ref = event.target.parentNode.dataset.ref + ver = event.target.innerText + + tt_title.innerHTML = ver + tt_text.innerHTML = "for #{ref}" + + + # Show tooltip + tt.style.visibility = 'hidden' + tt.style.display = 'block' + positionTooltip event.clientX + window.scrollX, event.clientY + window.scrollY + tt.style.visibility = 'visible' + + window.positionTooltip = (mouseX, mouseY) -> + tooltip = document.querySelector '#tooltip' + + #pageHeight = document.documentElement.getBoundingClientRect().height + viewportBottom = document.documentElement.clientHeight + document.documentElement.scrollTop + viewportRight = document.documentElement.clientWidth + document.documentElement.scrollLeft + cursorOffset = 20 + tooltipHeight = tooltip.clientHeight + tooltipWidth = tooltip.clientWidth + + #console.log('Cursor: %o, Planned bottom: %o, Viewport bottom: %o', mouseY, mouseY+cursorOffset+tooltipHeight, viewportBottom) + + # Check if tooltip is outside bottom of document + if mouseY + cursorOffset + tooltipHeight >= viewportBottom + # show tooltip ABOVE cursor + tooltip.style.top = (mouseY - cursorOffset - tooltipHeight) + 'px' + else + # show tooltip below cursor + tooltip.style.top = (mouseY + cursorOffset) + 'px' + + if mouseX + cursorOffset + tooltipWidth >= viewportRight + # show tooltip LEFT of cursor + tooltip.style.left = (mouseX - cursorOffset - tooltipWidth) + 'px' + else + # show tooltip right of cursor + tooltip.style.left = (mouseX + cursorOffset) + 'px' + + versionitems = document.querySelectorAll '.version' + for vi in versionitems + vi.addEventListener 'mousemove', (event) -> + positionTooltip event.clientX + window.scrollX, event.clientY + window.scrollY + vi.addEventListener 'mouseover', (event) -> + showTooltip event + vi.addEventListener 'mouseout', (event) -> + document.querySelector('#tooltip').style.display = 'none' diff --git a/assets/style.css b/assets/style.css index 742bfe5..771c757 100644 --- a/assets/style.css +++ b/assets/style.css @@ -15,17 +15,28 @@ body { margin-top: 70px; } +#tooltip { + background-color: white; + z-index: 200; + position: absolute; + display: none; +} + +#tooltip h1 { + font-weight: bold; +} + table td+td { border-left: 1px dashed silver; text-align: center; } -td { +th, td { font-family: monospace; white-space: nowrap; } -td.ref { +th.ref { font-weight: bold; } diff --git a/index_main.php b/index_main.php index 560a487..f6718eb 100644 --- a/index_main.php +++ b/index_main.php @@ -5,6 +5,8 @@ + +
$models) { $allVersions = $db->getAllVersionsForModel($model); echo ''; + echo ' | ||||
'; if (mb_strlen($name) > 0) { echo '' . $ref . ''; } else { echo $ref; } - echo ''; + echo ' | '; $refVersions = $db->getAllVersionsForRef($ref); $allOta = $db->getAllVersionsForRef($ref, $db::OTA_ONLY); foreach ($allVersions as $v) { if (in_array($v, $refVersions, true)) { - if (in_array($v, $allOta)) { - echo '' . $v . ' | '; - } else { - echo '' . $v . ' | '; + $moreClasses = ''; + if (!in_array($v, $allOta)) { + $moreClasses = ' fullonly mdc-theme--secondary-dark'; } + echo '' . $v . ' | '; } else { echo '- - - | '; } @@ -89,38 +91,14 @@ foreach ($allVars as $family => $models) { echo ''; } ?> +
---|