# HG changeset patch # User Guido Berhoerster # Date 1412531192 -7200 # Node ID 69552aee9993ac87a4c11c6f0c4e266ad0968998 # Parent b19db583b5f8138e001becb227c24d7a2c93a651 Use custom expander instead of details element Use a custom expander instead of a details element which is not (yet) universally supported. diff -r b19db583b5f8 -r 69552aee9993 booket.css --- a/booket.css Sat Oct 04 22:16:56 2014 +0200 +++ b/booket.css Sun Oct 05 19:46:32 2014 +0200 @@ -113,6 +113,24 @@ font-weight: bold; } +.expander > .expander-label { + cursor: pointer; +} + +.expander > .expander-label::before { + content: "\25B6"; + margin-right: .5em; +} + +.expander[data-expander-open] > .expander-label::before { + content: "\25BC"; + margin-right: .5em; +} + +.expander:not([data-expander-open]) > :not(.expander-label) { + display: none; +} + #logo { height: 2em; } diff -r b19db583b5f8 -r 69552aee9993 booket.html --- a/booket.html Sat Oct 04 22:16:56 2014 +0200 +++ b/booket.html Sun Oct 05 19:46:32 2014 +0200 @@ -183,13 +183,13 @@ diff -r b19db583b5f8 -r 69552aee9993 booket.js --- a/booket.js Sat Oct 04 22:16:56 2014 +0200 +++ b/booket.js Sun Oct 05 19:46:32 2014 +0200 @@ -1325,6 +1325,7 @@ this.bookmarkListElement = document.querySelector('ul#bookmark-list'); this.bookmarkListElement.addEventListener('input', this); this.bookmarkListElement.addEventListener('click', this); + this.bookmarkListElement.addEventListener('keydown', this); this.bookmarkListElement.addEventListener('submit', this); this.bookmarkListElement.addEventListener('reset', this); @@ -1343,6 +1344,13 @@ extend(BookmarkView, ObservableMixin); +BookmarkView.prototype.getAncestorClass = function (node, className) { + while ((node = node.parentNode) !== null && + (!node.classList || !node.classList.contains(className))); + + return node; +}; + BookmarkView.prototype.handleEvent = function (e) { var bookmarkletData; var parsedData; @@ -1417,6 +1425,25 @@ this.notify(e.target.name, getAncestorElementDatasetItem(e.target, 'tag')); break; + default: + if ((node = this.getAncestorClass(e.target, 'expander')) !== null) { + if (node.dataset.expanderOpen !== undefined) { + delete node.dataset.expanderOpen; + } else { + node.dataset.expanderOpen = ''; + } + } + break; + } + break; + case 'keydown': + if (e.keyCode === 32 && + (node = this.getAncestorClass(e.target, 'expander')) !== null) { + if (node.dataset.expanderOpen !== undefined) { + delete node.dataset.expanderOpen; + } else { + node.dataset.expanderOpen = ''; + } } break; case 'submit':