ui formatting
This commit is contained in:
parent
b2c08cdd0d
commit
765953536c
20
4chan_x.js
20
4chan_x.js
@ -177,16 +177,17 @@
|
|||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
dragstart: function(e) {
|
dragstart: function(e) {
|
||||||
var el, rect;
|
var d, el, rect;
|
||||||
ui.el = el = e.target.parentNode;
|
ui.el = el = e.target.parentNode;
|
||||||
document.body.className = 'noselect';
|
d = document;
|
||||||
|
d.body.className = 'noselect';
|
||||||
|
d.addEventListener('mousemove', ui.drag, true);
|
||||||
|
d.addEventListener('mouseup', ui.dragend, true);
|
||||||
rect = el.getBoundingClientRect();
|
rect = el.getBoundingClientRect();
|
||||||
ui.dx = e.clientX - rect.left;
|
ui.dx = e.clientX - rect.left;
|
||||||
ui.dy = e.clientY - rect.top;
|
ui.dy = e.clientY - rect.top;
|
||||||
ui.width = document.body.clientWidth - el.offsetWidth;
|
ui.width = document.body.clientWidth - el.offsetWidth;
|
||||||
ui.height = document.body.clientHeight - el.offsetHeight;
|
return ui.height = document.body.clientHeight - el.offsetHeight;
|
||||||
document.addEventListener('mousemove', ui.drag, true);
|
|
||||||
return document.addEventListener('mouseup', ui.dragend, true);
|
|
||||||
},
|
},
|
||||||
drag: function(e) {
|
drag: function(e) {
|
||||||
var bottom, el, left, right, top;
|
var bottom, el, left, right, top;
|
||||||
@ -211,14 +212,15 @@
|
|||||||
return el.style.bottom = bottom;
|
return el.style.bottom = bottom;
|
||||||
},
|
},
|
||||||
dragend: function() {
|
dragend: function() {
|
||||||
var el, id;
|
var d, el, id;
|
||||||
document.removeEventListener('mousemove', ui.drag, true);
|
|
||||||
document.removeEventListener('mouseup', ui.dragend, true);
|
|
||||||
el = ui.el;
|
el = ui.el;
|
||||||
id = el.id;
|
id = el.id;
|
||||||
localStorage["" + id + "Left"] = el.style.left;
|
localStorage["" + id + "Left"] = el.style.left;
|
||||||
localStorage["" + id + "Top"] = el.style.top;
|
localStorage["" + id + "Top"] = el.style.top;
|
||||||
return document.body.className = '';
|
d = document;
|
||||||
|
d.body.className = '';
|
||||||
|
d.removeEventListener('mousemove', ui.drag, true);
|
||||||
|
return d.removeEventListener('mouseup', ui.dragend, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
d = document;
|
d = document;
|
||||||
|
|||||||
@ -98,7 +98,10 @@ ui =
|
|||||||
el
|
el
|
||||||
dragstart: (e) ->
|
dragstart: (e) ->
|
||||||
ui.el = el = e.target.parentNode
|
ui.el = el = e.target.parentNode
|
||||||
document.body.className = 'noselect'
|
d = document
|
||||||
|
d.body.className = 'noselect'
|
||||||
|
d.addEventListener 'mousemove', ui.drag, true
|
||||||
|
d.addEventListener 'mouseup', ui.dragend, true
|
||||||
#distance from pointer to el edge is constant; calculate it here.
|
#distance from pointer to el edge is constant; calculate it here.
|
||||||
# XXX opera reports el.offsetLeft / el.offsetTop as 0
|
# XXX opera reports el.offsetLeft / el.offsetTop as 0
|
||||||
rect = el.getBoundingClientRect()
|
rect = el.getBoundingClientRect()
|
||||||
@ -107,8 +110,6 @@ ui =
|
|||||||
#factor out el from document dimensions
|
#factor out el from document dimensions
|
||||||
ui.width = document.body.clientWidth - el.offsetWidth
|
ui.width = document.body.clientWidth - el.offsetWidth
|
||||||
ui.height = document.body.clientHeight - el.offsetHeight
|
ui.height = document.body.clientHeight - el.offsetHeight
|
||||||
document.addEventListener 'mousemove', ui.drag, true
|
|
||||||
document.addEventListener 'mouseup', ui.dragend, true
|
|
||||||
drag: (e) ->
|
drag: (e) ->
|
||||||
{el} = ui
|
{el} = ui
|
||||||
left = e.clientX - ui.dx
|
left = e.clientX - ui.dx
|
||||||
@ -124,13 +125,17 @@ ui =
|
|||||||
el.style.top = top
|
el.style.top = top
|
||||||
el.style.bottom = bottom
|
el.style.bottom = bottom
|
||||||
dragend: ->
|
dragend: ->
|
||||||
document.removeEventListener 'mousemove', ui.drag, true
|
#{id} = {el} = ui
|
||||||
document.removeEventListener 'mouseup', ui.dragend, true
|
#equivalent to
|
||||||
{el} = ui #{id} = {el} = ui doesn't work
|
#{id} = ui; {el} = ui
|
||||||
|
{el} = ui
|
||||||
{id} = el
|
{id} = el
|
||||||
localStorage["#{id}Left"] = el.style.left
|
localStorage["#{id}Left"] = el.style.left
|
||||||
localStorage["#{id}Top"] = el.style.top
|
localStorage["#{id}Top"] = el.style.top
|
||||||
document.body.className = ''
|
d = document
|
||||||
|
d.body.className = ''
|
||||||
|
d.removeEventListener 'mousemove', ui.drag, true
|
||||||
|
d.removeEventListener 'mouseup', ui.dragend, true
|
||||||
|
|
||||||
#convenience
|
#convenience
|
||||||
d = document
|
d = document
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user