forked from alice0775/userChrome.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patchForBug541844.uc.js
85 lines (76 loc) · 2.65 KB
/
patchForBug541844.uc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// ==UserScript==
// @name patchForBug541844.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description Bug 541844 - Clicking add-on icons which are next to the menubar (on autohide) hides menubar without opening the clicked add-onを修正
// @include main
// @compatibility Firefox 3.6 3.7a5pre
// @author Alice0775
// @version 2010/04/09 22:00
// ==/UserScript==
var bug541844 = {
get menutoolbar () {
delete this.menutoolbar;
return this.menutoolbar = document.getElementById("toolbar-menubar");
},
get menubar () {
delete this.menubar;
return this.menubar = document.getElementById("main-menubar");
},
init: function() {
window.addEventListener('unload', this, false);
this.menutoolbar.addEventListener('DOMMenuBarActive', this, true);
this.menutoolbar.addEventListener('DOMMenuBarInactive', this, true);
this.menutoolbar.mousemoved = false;
},
uninit: function() {
window.removeEventListener('unload', this, false);
this.menutoolbar.removeEventListener('DOMMenuBarActive', this, true);
this.menutoolbar.removeEventListener('DOMMenuBarInactive', this, true);
this.menutoolbar.removeEventListener('mousemove', this, true);
window.removeEventListener('mousemove', this, true);
},
handleEvent: function(event) {
if (!(this.menutoolbar.getAttribute("autohide") == "true")) {
this.menutoolbar.removeEventListener('mousemove', this, true);
window.removeEventListener('mousemove', this, true);
return;
}
switch (event.type) {
case 'mousemove':
this.onmousemove(event);
break;
case 'DOMMenuBarActive':
this.menutoolbar.mousemoved = false;
this.menutoolbar.addEventListener('mousemove', this, true);
break;
case 'DOMMenuBarInactive':
this.menutoolbar.removeEventListener('mousemove', this, true);
if (this.menutoolbar.mousemoved) {
event.stopPropagation();
this.menutoolbar.mousemoved = false;
window.addEventListener('mousemove', this, true);
}
break;
}
},
onmousemove: function(event) {
var elem = event.target;
while (elem) {
//window.userChrome_js.debug(elem.localName);
if (elem == this.menubar) {
return;
};
if (elem == this.menutoolbar.parentNode) {
this.menutoolbar.mousemoved = true;
return;
}
elem = elem.parentNode;
}
if (this.menutoolbar.mousemoved) {
this.menutoolbar._setInactiveAsync();
this.menutoolbar.mousemoved = false;
window.removeEventListener('mousemove', this, true);
}
}
}
bug541844.init();