Skip to content

Commit

Permalink
more fixes for IE8
Browse files Browse the repository at this point in the history
  • Loading branch information
Costo committed Jan 26, 2012
1 parent a9aca72 commit d4bb3ca
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions js/script.js
Expand Up @@ -2,6 +2,22 @@
*/ */


// el.innerText / el.textContent helper
var text;
if (document.body.innerText) {
text = function (el, v) { return v ? el.innerText = v : el.innerText; };
} else if (document.body.textContent) {
text = function (el, v) { return v ? el.textContent = v : el.textContent; };
}

// el.addEventListener / el.attachEvent helper
var addEvent;
if (window.attachEvent) {
addEvent = function (el, ev, cb) { el.attachEvent("on" + ev, cb); };
} else if (window.addEventListener) {
addEvent = function (el, ev, cb, capture) { el.addEventListener(ev, cb, capture); };
}

// gtieX augments. so a search is matching .gtie8, // gtieX augments. so a search is matching .gtie8,
// need to match .gtie7 and .gtie6 too // need to match .gtie7 and .gtie6 too
var ies = ['gtie6', 'gtie7', 'gtie8', 'gtie9', 'gtie10']; var ies = ['gtie6', 'gtie7', 'gtie8', 'gtie9', 'gtie10'];
Expand All @@ -13,7 +29,7 @@ var search = document.getElementById('livesearch'),


[].map.call(searchresults, function(result) { [].map.call(searchresults, function(result) {
var tags = result.querySelector('.tags'), var tags = result.querySelector('.tags'),
tagslist = tags.innerText.split(' '), tagslist = text(tags).split(' '),
ielist = tagslist.filter(function(tag) { ielist = tagslist.filter(function(tag) {
return tag.match(/gtie.*/); return tag.match(/gtie.*/);
}); });
Expand Down Expand Up @@ -80,15 +96,18 @@ function showsearch(hash) {
}; };


// keyboard shortcut for / to go to search box. // keyboard shortcut for / to go to search box.
(window.addEventListener || window.attachEvent)('keyup', function(e){ addEvent(window, 'keyup', function(e){
if (e.which == 191 && document.activeElement != search) if (e.which == 191 && document.activeElement != search)
search.focus(); search.focus();
}); });


var moredetails = document.getElementById("clickmore"); var moredetails = document.getElementById("clickmore");


moredetails.onclick = function(e) { moredetails.onclick = function(e) {
classList(e.target).toggle('active'); e || (e = window.event);
classList(document.getElementById(/#(.*)/.exec(e.target.href)[1])).toggle('active'); var target = e.target || e.srcElement;
e.preventDefault();
classList(target).toggle('active');
classList(document.getElementById(/#(.*)/.exec(target.href)[1])).toggle('active');
e.preventDefault && e.preventDefault();
}; };

0 comments on commit d4bb3ca

Please sign in to comment.