From: Mischa POSLAWSKY Date: Tue, 7 Dec 2010 23:27:29 +0000 (+0100) Subject: browser: disable search features dependent on classList X-Git-Tag: v1.4~37 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/21c02bb6fd2f83f18a8f3ac9023478e6670aa7f7?ds=sidebyside browser: disable search features dependent on classList --- diff --git a/searchlocal.js b/searchlocal.js index 8ac328d..0989971 100644 --- a/searchlocal.js +++ b/searchlocal.js @@ -1,4 +1,5 @@ var filterupdate; +var filtertoggles = document.body.classList !== undefined; function filtercell(el, set, action) { if (set === undefined) return; @@ -20,8 +21,7 @@ function filtercell(el, set, action) { break; case 'filter': el.style.display = set ? '' : 'none'; - if (!Element.prototype.hasOwnProperty('classList')) return; - el.classList.remove('focus'); + if (filtertoggles) el.classList.remove('focus'); break; default: // reset el.classList.remove('focus'); @@ -116,7 +116,7 @@ function newelement(tagname, attrlist, childlist) { for (var name in attrlist) el.setAttribute(name, attrlist[name]); if (childlist) for (var i = 0; i < childlist.length; i++) - el.appendChild(childlist[i]); + if (childlist[i]) el.appendChild(childlist[i]); return el; } @@ -131,10 +131,10 @@ function prependsearch(target) { newelement('input', { type: 'search', name: 'q', - onkeyup: "if (!filterupdate) filterupdate = " + onkeyup: "if (filtertoggles && !filterupdate) filterupdate = " + "window.setTimeout(filtertable, 300, undefined, 'focus')", }), - newelement('input', { + filtertoggles && newelement('input', { type: 'button', value: 'toggle', onclick: "filtertable(this.form.q.value, 'target')",