Skip to content

Commit

Permalink
Fixing #9 with a not-so-good solution
Browse files Browse the repository at this point in the history
I shall detect the highest `zIndex` of the element's ancestors. This
isn't easy without jQuery since some `zIndex` is applied in CSS
selectors.

Also skip small windows from parsing since they are usually scripts from
other sites (such as Facebook) and don't even contain any chinese words.
  • Loading branch information
kong0107 committed Aug 24, 2013
1 parent f1730bd commit 52e0fad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion LER.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ LER = function(){
};
}
else var debug = function(){};
if(window.innerHeight < 50 || window.innerWidth < 100) {
debug("window too small, ignored.");
return;
}

/// 數字補零(其實不是數字也沒關係)
var zeroFill = function(num, strlen){
Expand Down Expand Up @@ -193,6 +197,10 @@ LER = function(){
: (document.body.offsetWidth - popup.offsetWidth)
;
s.left = left + "px";
/* See #9
for(var p = self; p != document.body; p = p.parentNode)
s.zIndex = Math.max(s.zIndex, p.style.zIndex);
*/
var arrow = popup.firstChild;
arrow.style.marginLeft = x - left - (arrow.offsetWidth / 2) + "px";
}, 350);
Expand Down Expand Up @@ -936,4 +944,4 @@ LER = function(){
debugTime: function(str) {debug(str);}
};
}();
LER.debugTime("initialization");
if(typeof LER == "object" && LER.debugTime) LER.debugTime("initialization");
1 change: 1 addition & 0 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
margin: 0;
padding: 0;
text-align: left;
z-index: 1069;
}

.LER-popup-head {
Expand Down
7 changes: 3 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"manifest_version": 2,
"name": "法規亦毒氣",
"description": "將網頁中的法規與條號都轉變成連結,讓您快速查閱指定條文。",
"version": "0.4.4.2",
"permissions": [
"http://law.moj.gov.tw/"
],
"version": "0.4.4.3",
"author": "kong0107",
"homepage_url": "http://g0v.github.io/laweasyread-front/",
"icons" : {"128": "icon.png"},
"options_page": "options.html",
"browser_action": {
Expand Down

0 comments on commit 52e0fad

Please sign in to comment.