Skip to content
Browse files

more fixes for IE8

  • Loading branch information...
1 parent a9aca72 commit d4bb3cab59f544f01971b450652f44889bc9a306 @Costo Costo committed Jan 26, 2012
Showing with 24 additions and 5 deletions.
  1. +24 −5 js/script.js
View
29 js/script.js
@@ -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,
// need to match .gtie7 and .gtie6 too
var ies = ['gtie6', 'gtie7', 'gtie8', 'gtie9', 'gtie10'];
@@ -13,7 +29,7 @@ var search = document.getElementById('livesearch'),
[].map.call(searchresults, function(result) {
var tags = result.querySelector('.tags'),
- tagslist = tags.innerText.split(' '),
+ tagslist = text(tags).split(' '),
ielist = tagslist.filter(function(tag) {
return tag.match(/gtie.*/);
});
@@ -80,15 +96,18 @@ function showsearch(hash) {
};
// 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)
search.focus();
});
var moredetails = document.getElementById("clickmore");
moredetails.onclick = function(e) {
- classList(e.target).toggle('active');
- classList(document.getElementById(/#(.*)/.exec(e.target.href)[1])).toggle('active');
- e.preventDefault();
+ e || (e = window.event);
+ var target = e.target || e.srcElement;
+
+ 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.
Something went wrong with that request. Please try again.