Commit ba94cbfe authored by Tiger Oakes's avatar Tiger Oakes Committed by Commit Bot

Changed Update button to refresh tree without page refresh

Makes your browser history cleaner by replacing the current query string with
Javascript rather than making a new request with the form. Updates the UI inline
rather than reloading the page.

Additionally fixed the select element so it renders properly on Mac.

Bug: 847599
Change-Id: I709cb71b184f271fdcfb7561cc56f9e1d29d059a
Reviewed-on: https://chromium-review.googlesource.com/1125284
Commit-Queue: Tiger Oakes <tigero@google.com>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572579}
parent 11b3cf2f
...@@ -292,7 +292,7 @@ ...@@ -292,7 +292,7 @@
<main class="tree-container"> <main class="tree-container">
<header class="tree-header"> <header class="tree-header">
<span class="subtitle">Name</span> <span class="subtitle">Name</span>
<span class="subtitle" id="size-header">{{size_header}}</span> <span class="subtitle" id="size-header" data-value="{{size_header}}">{{size_header}}</span>
</header> </header>
<ul id="symboltree" class="tree" role="tree" aria-labelledby="headline"></ul> <ul id="symboltree" class="tree" role="tree" aria-labelledby="headline"></ul>
</main> </main>
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
background: rgba(0, 0, 0, 0.04); background: rgba(0, 0, 0, 0.04);
} }
select { select {
-webkit-appearance: none;
font: inherit; font: inherit;
background: transparent; background: transparent;
border: 0; border: 0;
...@@ -120,13 +121,27 @@ select { ...@@ -120,13 +121,27 @@ select {
color: #5f6368; color: #5f6368;
border-bottom: 1px solid currentColor; border-bottom: 1px solid currentColor;
} }
select:focus+.select-label { .select-label::after {
content: '';
position: absolute;
top: calc(50% - 5px);
right: 4px;
margin: 5px 7px 5px 8px;
border-style: solid;
border-width: 5px 5px 0 5px;
border-color: currentColor transparent transparent transparent;
transition: transform 0.2s ease-out;
}
select:focus + .select-label {
color: #1a73e8; color: #1a73e8;
bottom: -2px; bottom: -2px;
border-width: 2px; border-width: 2px;
} }
select:focus + .select-label::after {
transform: rotate(180deg);
}
/** <input type='checkbox'> elements */ /** <input type="checkbox"> elements */
input[type='checkbox'] { input[type='checkbox'] {
display: none; display: none;
} }
...@@ -138,7 +153,8 @@ input[type='checkbox'] { ...@@ -138,7 +153,8 @@ input[type='checkbox'] {
cursor: pointer; cursor: pointer;
font-size: 14px; font-size: 14px;
} }
.checkbox-label::before, .checkbox-label::after { .checkbox-label::before,
.checkbox-label::after {
position: absolute; position: absolute;
content: ''; content: '';
border: 2px solid currentColor; border: 2px solid currentColor;
...@@ -172,13 +188,13 @@ input[type='checkbox']:disabled + .checkbox-label { ...@@ -172,13 +188,13 @@ input[type='checkbox']:disabled + .checkbox-label {
/** Tweaks for smaller screen sizes */ /** Tweaks for smaller screen sizes */
@media (max-width: 700px) { @media (max-width: 700px) {
.show-options { .show-options {
grid-template-columns: auto 0; grid-template-columns: auto 0;
} }
.show-options .scrim { .show-options .scrim {
display: block; display: block;
} }
.appbar, .appbar,
.symbols { .symbols {
padding: 0 16px; padding: 0 16px;
} }
} }
...@@ -42,7 +42,7 @@ function _initState() { ...@@ -42,7 +42,7 @@ function _initState() {
* can be manipulated by this object. Keys in the query match with * can be manipulated by this object. Keys in the query match with
* input names. * input names.
*/ */
const _filterParams = new URLSearchParams(location.search.slice(1)); let _filterParams = new URLSearchParams(location.search.slice(1));
const state = { const state = {
/** /**
...@@ -102,6 +102,15 @@ function _initState() { ...@@ -102,6 +102,15 @@ function _initState() {
*/ */
set(name, value) { set(name, value) {
_filterParams.set(name, value); _filterParams.set(name, value);
state.setAll(_filterParams);
},
/**
* Replaces the current state with a new list of values. Afterwards
* display the new state in the URL by replacing the current history entry.
* @param {Iterable<[string, string]>} entries Iterator of key-value pairs
*/
setAll(entries) {
_filterParams = new URLSearchParams(entries);
history.replaceState(null, null, '?' + _filterParams.toString()); history.replaceState(null, null, '?' + _filterParams.toString());
}, },
}; };
...@@ -153,11 +162,21 @@ function _startListeners(state) { ...@@ -153,11 +162,21 @@ function _startListeners(state) {
document.body.classList.add('show-options'); document.body.classList.add('show-options');
} }
// Disable some fields when method_count is set /**
if (state.has('method_count')) { * Disable some fields when method_count is set
document.getElementById('size-header').textContent = 'Methods'; */
form.byteunit.setAttribute('disabled', ''); function setMethodCountModeUI() {
const sizeHeader = document.getElementById('size-header');
if (form.method_count.checked) {
sizeHeader.textContent = 'Methods';
form.byteunit.setAttribute('disabled', '');
} else {
sizeHeader.textContent = sizeHeader.dataset.value;
form.byteunit.removeAttribute('disabled', '');
}
} }
setMethodCountModeUI();
form.method_count.addEventListener('change', setMethodCountModeUI);
} }
/** Utilities for working with the state */ /** Utilities for working with the state */
......
...@@ -352,5 +352,11 @@ ...@@ -352,5 +352,11 @@
); );
} }
form.addEventListener('submit', event => {
event.preventDefault();
state.setAll(new FormData(event.currentTarget));
loadTree(tree_data);
})
self.loadTree = loadTree; self.loadTree = loadTree;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment