加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
patchForBug715838.uc.js 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
alice0775 提交于 2012-02-05 18:07 . iroiro
// ==UserScript==
// @name patchForBug715838.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description Workaround Bug 715838 - Double-clicking title bar in small window sends click event to the maximized window on mouse position
// @include main
// @compatibility Firefox 4.0 5.0 6.0 7.0
// @author Alice0775
// @version 2012/01/07
// @Note
// ==/UserScript==
var bug715838 = {
timer: null,
duration: 500,
handleEvent: function(event) {
switch (event.type) {
case "mousemove":
this.onmousemove(event);
break;
case "resize":
this.onresize(event);
break;
case "mouseup":
this.onmouseup(event);
break;
case "unload":
this.uninit();
break;
}
},
init: function() {
window.addEventListener("unload", this, false);
window.addEventListener("resize", this, true);
},
uninit: function() {
window.removeEventListener("resize", this, true);
window.removeEventListener("unload", this, false);
},
onresize: function(event) {
if (event.originalTarget != window)
return;
if (window.windowState == window.STATE_MAXIMIZED) {
window.addEventListener("mouseup", this, true);
window.addEventListener("mousemove", this, true);
if (this.timer)
clearTimeout(this.timer);
this.timer = setTimeout(function(self) {
window.removeEventListener("mouseup", self, true);
window.removeEventListener("mousemove", self, true);
}, this.duration, this);
}
},
onmouseup: function(event) {
event.stopPropagation();
window.removeEventListener("mouseup", this, true);
window.removeEventListener("mousemove", this, true);
if (this.timer)
clearTimeout(this.timer);
},
onmousemove: function(event) {
window.removeEventListener("mousemove", this, true);
if (this.timer)
clearTimeout(this.timer);
setTimeout(function(self) {
window.removeEventListener("mouseup", self, true);
}, 0, this);
}
}
bug715838.init();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化