forked from jsbin/jsbin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.js
More file actions
50 lines (40 loc) · 1.61 KB
/
edit.js
File metadata and controls
50 lines (40 loc) · 1.61 KB
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
// shows this is run through jsbin & you can edit
(function () {
if (window.location.hash == '#noedit') return;
var ie = (!+"\v1");
function set(el, props, hover) {
for (var prop in props) {
el.style[prop] = props[prop];
}
}
function hide() {
set(el, { opacity: '0' });
}
var el = document.createElement('a');
set(el, { opacity: 1, position: 'fixed', top: '-1px', right: '-1px', padding: '5px 10px', background: '#ccc', color: '#333', 'text-shadow': '0px 1px 1px #fff', 'border-top-right-radius': '5px', MozBorderRadiusBottomleft: '5px', border: '1px solid #999', textDecoration: 'none', font: '12px "Helvetica Neue", Arial, Helvetica', WebkitTransition: 'opacity ease-out 100ms', MozTransition: 'opacity ease-out 100ms', OTransition: 'opacity ease-out 100ms', transition: 'opacity ease-out 100ms' });
el.innerHTML = 'Edit in jsbin.com';
el.href = window.location.pathname + (window.location.pathname.substr(-1) == '/' ? '' : '/') + 'edit';
el.onmouseover = function () {
this.style.opacity = 1;
};
el.onmouseout = function () {
this.style.opacity = 0;
};
document.body.appendChild(el);
setTimeout(hide, 2000);
var moveTimer = null;
if (document.addEventListener) {
document.addEventListener('mousemove', show, false);
} else {
document.attachEvent('onmousemove', show);
}
function show() {
if (!ie && (el.style.opacity*1) == 0) { // TODO IE compat
el.style.opacity = 1;
} else if (ie) {
set(el, { display: 'block', opacity: '1' });
}
clearTimeout(moveTimer);
moveTimer = setTimeout(hide, 2000);
}
})();