git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d7726fe
)
browser: only reset focus after filter
author
Mischa POSLAWSKY
<perl@shiar.org>
Tue, 7 Dec 2010 19:48:50 +0000
(20:48 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Wed, 15 Dec 2010 21:40:44 +0000
(22:40 +0100)
Keep target states.
searchlocal.js
patch
|
blob
|
history
diff --git
a/searchlocal.js
b/searchlocal.js
index e6f16ff92c672c28ffa519b32864fac2ce0d366a..8741044c4afce0b92cf9f876bcfc520e6ff8cfb4 100644
(file)
--- a/
searchlocal.js
+++ b/
searchlocal.js
@@
-18,7
+18,8
@@
function filtercell(el, set, action) {
case 'filter':
el.style.display = set ? '' : 'none';
if (!Element.prototype.hasOwnProperty('classList')) return;
case 'filter':
el.style.display = set ? '' : 'none';
if (!Element.prototype.hasOwnProperty('classList')) return;
- // continue
+ el.classList.remove('focus');
+ break;
default: // reset
el.classList.remove('focus');
el.classList.remove('target');
default: // reset
el.classList.remove('focus');
el.classList.remove('target');
@@
-28,7
+29,7
@@
function filtercell(el, set, action) {
function filterrows(table, match, action) {
var rows = table.tBodies[0].rows;
for (var i = 0; i < rows.length; i++) {
function filterrows(table, match, action) {
var rows = table.tBodies[0].rows;
for (var i = 0; i < rows.length; i++) {
- filtercell(rows[i], match(rows[i]), action);
+ filtercell(rows[i], match
&& match
(rows[i]), action);
}
}
}
}
@@
-52,6
+53,10
@@
function filtertable(query, action) {
return row.cells[0].title.match(query, 'i');
};
}
return row.cells[0].title.match(query, 'i');
};
}
+ else if (action == 'focus' && query.length <= 1) {
+ // prevent superfluous highlighting
+ var match = false;
+ }
else {
// title text (case-insensitive unless caps in input)
var match = function(row) {
else {
// title text (case-insensitive unless caps in input)
var match = function(row) {
@@
-82,7
+87,7
@@
function prependsearch(target) {
newelement('input', {
type: 'search',
name: 'q',
newelement('input', {
type: 'search',
name: 'q',
- onkeyup: "filtertable(this.value,
this.value.length > 1 ? 'focus' : 'reset
')",
+ onkeyup: "filtertable(this.value,
'focus
')",
}),
newelement('input', {
type: 'button',
}),
newelement('input', {
type: 'button',