-
Notifications
You must be signed in to change notification settings - Fork 0
/
iconhover.js
54 lines (53 loc) · 1.72 KB
/
iconhover.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
function $$(f) {
var script = document.createElement("script");
script.type = "text/javascript";
script.textContent = "(" + f.toString() + ")(jQuery)";
document.body.appendChild(script).parentNode.removeChild(script);
};
//Hover TopBar Icons
$$(function($){
var btns = [];
var achieve = { btn: '.topbar-icon.icon-achievements.js-achievements-button', mod: '.topbar-dialog.achievements-dialog' };
btns.push(achieve);
var inbox = { btn: '.topbar-icon.icon-inbox.js-inbox-button', mod: '.topbar-dialog.inbox-dialog' };
btns.push(inbox);
var se = { btn: '.topbar-icon.icon-site-switcher.js-site-switcher-button.js-gps-track', mod: '.topbar-dialog.siteSwitcher-dialog' };
btns.push(se);
for( var ind in btns ){
var tar = btns[ind].btn;
var mod = btns[ind].mod;
var $ach = $(tar);
(function($ach,mod){
var d = StackExchange.helpers.DelayedReaction(function () {
if( $(mod).is(':visible') )return;
$ach.click();
}, 450, { always: function () {
j.cancel() }
});
var j = StackExchange.helpers.DelayedReaction(function () {
if( !$(mod).is(':visible') )return;
$ach.click();
}, 1E3, { always: function () {
d.cancel() }
});
var a = StackExchange.helpers.DelayedReaction(function () {
}, 450, { always: function () {
j.cancel(); d.cancel(); }
});
var b = StackExchange.helpers.DelayedReaction(function () {
if( !$(mod).is(':visible') )return;
$ach.click();
}, 450, { always: function () {
j.cancel(); a.cancel(); }
});
$ach.mouseenter(d.trigger);
$ach.mouseleave(j.trigger);
$ach.click(function(){
a.cancel();
d.cancel();
});
$('body').on('mouseenter',mod,a.trigger);
$('body').on('mouseleave',mod,b.trigger);
})($ach,mod)
}
});