Erm, some of that was unnecessary.

This commit is contained in:
Zixaphir 2013-04-14 13:10:42 -07:00
parent 0cd3e95989
commit f098f19a11
4 changed files with 31 additions and 33 deletions

View File

@ -236,7 +236,9 @@
innerHTML: html, innerHTML: html,
id: id id: id
}); });
el.style.cssText = localStorage.getItem("" + g.NAMESPACE + id + ".position") || position; $.get("" + id + ".position", position, function(item) {
return el.style.cssText = item["" + id + ".position"];
});
move = $('.move', el); move = $('.move', el);
$.on(move, 'touchstart mousedown', dragstart); $.on(move, 'touchstart mousedown', dragstart);
_ref = move.children; _ref = move.children;
@ -571,18 +573,17 @@
$.off(d, 'mousemove', this.move); $.off(d, 'mousemove', this.move);
$.off(d, 'mouseup', this.up); $.off(d, 'mouseup', this.up);
} }
return localStorage.setItem("" + g.NAMESPACE + this.id + ".position", this.style.cssText); return $.set("" + this.id + ".position", this.style.cssText);
}; };
hoverstart = function(_arg) { hoverstart = function(_arg) {
var asapTest, cb, close, el, endEvents, latestEvent, o, root; var asapTest, cb, el, endEvents, latestEvent, o, root;
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, cb = _arg.cb, close = _arg.close; root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, cb = _arg.cb;
o = { o = {
root: root, root: root,
el: el, el: el,
style: el.style, style: el.style,
cb: cb, cb: cb,
close: close,
endEvents: endEvents, endEvents: endEvents,
latestEvent: latestEvent, latestEvent: latestEvent,
clientHeight: doc.clientHeight, clientHeight: doc.clientHeight,
@ -606,9 +607,9 @@
this.latestEvent = e; this.latestEvent = e;
height = this.el.offsetHeight; height = this.el.offsetHeight;
clientX = e.clientX, clientY = e.clientY; clientX = e.clientX, clientY = e.clientY;
top = clientY + (close ? 0 : -120); top = clientY - 120;
top = this.clientHeight <= height || top <= 0 ? 0 : top + height >= this.clientHeight ? this.clientHeight - height : top; top = this.clientHeight <= height || top <= 0 ? 0 : top + height >= this.clientHeight ? this.clientHeight - height : top;
_ref = clientX <= this.clientWidth - 400 ? [clientX + (this.close ? 15 : 45) + 'px', null] : [null, this.clientWidth - clientX + 45 + 'px'], left = _ref[0], right = _ref[1]; _ref = clientX <= this.clientWidth - 400 ? [clientX + 45 + 'px', null] : [null, this.clientWidth - clientX + 45 + 'px'], left = _ref[0], right = _ref[1];
style = this.style; style = this.style;
style.top = top + 'px'; style.top = top + 'px';
style.left = left; style.left = left;

View File

@ -233,7 +233,9 @@
innerHTML: html, innerHTML: html,
id: id id: id
}); });
el.style.cssText = localStorage.getItem("" + g.NAMESPACE + id + ".position") || position; $.get("" + id + ".position", position, function(item) {
return el.style.cssText = item["" + id + ".position"];
});
move = $('.move', el); move = $('.move', el);
$.on(move, 'touchstart mousedown', dragstart); $.on(move, 'touchstart mousedown', dragstart);
_ref = move.children; _ref = move.children;
@ -568,18 +570,17 @@
$.off(d, 'mousemove', this.move); $.off(d, 'mousemove', this.move);
$.off(d, 'mouseup', this.up); $.off(d, 'mouseup', this.up);
} }
return localStorage.setItem("" + g.NAMESPACE + this.id + ".position", this.style.cssText); return $.set("" + this.id + ".position", this.style.cssText);
}; };
hoverstart = function(_arg) { hoverstart = function(_arg) {
var asapTest, cb, close, el, endEvents, latestEvent, o, root; var asapTest, cb, el, endEvents, latestEvent, o, root;
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, cb = _arg.cb, close = _arg.close; root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, cb = _arg.cb;
o = { o = {
root: root, root: root,
el: el, el: el,
style: el.style, style: el.style,
cb: cb, cb: cb,
close: close,
endEvents: endEvents, endEvents: endEvents,
latestEvent: latestEvent, latestEvent: latestEvent,
clientHeight: doc.clientHeight, clientHeight: doc.clientHeight,
@ -603,9 +604,9 @@
this.latestEvent = e; this.latestEvent = e;
height = this.el.offsetHeight; height = this.el.offsetHeight;
clientX = e.clientX, clientY = e.clientY; clientX = e.clientX, clientY = e.clientY;
top = clientY + (close ? 0 : -120); top = clientY - 120;
top = this.clientHeight <= height || top <= 0 ? 0 : top + height >= this.clientHeight ? this.clientHeight - height : top; top = this.clientHeight <= height || top <= 0 ? 0 : top + height >= this.clientHeight ? this.clientHeight - height : top;
_ref = clientX <= this.clientWidth - 400 ? [clientX + (this.close ? 15 : 45) + 'px', null] : [null, this.clientWidth - clientX + 45 + 'px'], left = _ref[0], right = _ref[1]; _ref = clientX <= this.clientWidth - 400 ? [clientX + 45 + 'px', null] : [null, this.clientWidth - clientX + 45 + 'px'], left = _ref[0], right = _ref[1];
style = this.style; style = this.style;
style.top = top + 'px'; style.top = top + 'px';
style.left = left; style.left = left;

View File

@ -210,7 +210,9 @@
innerHTML: html, innerHTML: html,
id: id id: id
}); });
el.style.cssText = localStorage.getItem("" + g.NAMESPACE + id + ".position") || position; $.get("" + id + ".position", position, function(item) {
return el.style.cssText = item["" + id + ".position"];
});
move = $('.move', el); move = $('.move', el);
$.on(move, 'touchstart mousedown', dragstart); $.on(move, 'touchstart mousedown', dragstart);
_ref = move.children; _ref = move.children;
@ -545,18 +547,17 @@
$.off(d, 'mousemove', this.move); $.off(d, 'mousemove', this.move);
$.off(d, 'mouseup', this.up); $.off(d, 'mouseup', this.up);
} }
return localStorage.setItem("" + g.NAMESPACE + this.id + ".position", this.style.cssText); return $.set("" + this.id + ".position", this.style.cssText);
}; };
hoverstart = function(_arg) { hoverstart = function(_arg) {
var asapTest, cb, close, el, endEvents, latestEvent, o, root; var asapTest, cb, el, endEvents, latestEvent, o, root;
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, cb = _arg.cb, close = _arg.close; root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, cb = _arg.cb;
o = { o = {
root: root, root: root,
el: el, el: el,
style: el.style, style: el.style,
cb: cb, cb: cb,
close: close,
endEvents: endEvents, endEvents: endEvents,
latestEvent: latestEvent, latestEvent: latestEvent,
clientHeight: doc.clientHeight, clientHeight: doc.clientHeight,
@ -580,9 +581,9 @@
this.latestEvent = e; this.latestEvent = e;
height = this.el.offsetHeight; height = this.el.offsetHeight;
clientX = e.clientX, clientY = e.clientY; clientX = e.clientX, clientY = e.clientY;
top = clientY + (close ? 0 : -120); top = clientY - 120;
top = this.clientHeight <= height || top <= 0 ? 0 : top + height >= this.clientHeight ? this.clientHeight - height : top; top = this.clientHeight <= height || top <= 0 ? 0 : top + height >= this.clientHeight ? this.clientHeight - height : top;
_ref = clientX <= this.clientWidth - 400 ? [clientX + (this.close ? 15 : 45) + 'px', null] : [null, this.clientWidth - clientX + 45 + 'px'], left = _ref[0], right = _ref[1]; _ref = clientX <= this.clientWidth - 400 ? [clientX + 45 + 'px', null] : [null, this.clientWidth - clientX + 45 + 'px'], left = _ref[0], right = _ref[1];
style = this.style; style = this.style;
style.top = top + 'px'; style.top = top + 'px';
style.left = left; style.left = left;

View File

@ -4,7 +4,8 @@ UI = do ->
className: 'dialog' className: 'dialog'
innerHTML: html innerHTML: html
id: id id: id
el.style.cssText = localStorage.getItem("#{g.NAMESPACE}#{id}.position") or position $.get "#{id}.position", position, (item) ->
el.style.cssText = item["#{id}.position"]
move = $ '.move', el move = $ '.move', el
$.on move, 'touchstart mousedown', dragstart $.on move, 'touchstart mousedown', dragstart
for child in move.children for child in move.children
@ -192,6 +193,7 @@ UI = do ->
@parseEntry subEntry @parseEntry subEntry
return return
dragstart = (e) -> dragstart = (e) ->
return if e.type is 'mousedown' and e.button isnt 0 # not LMB return if e.type is 'mousedown' and e.button isnt 0 # not LMB
# prevent text selection # prevent text selection
@ -225,13 +227,11 @@ UI = do ->
o.up = dragend.bind o o.up = dragend.bind o
$.on d, 'mousemove', o.move $.on d, 'mousemove', o.move
$.on d, 'mouseup', o.up $.on d, 'mouseup', o.up
touchmove = (e) -> touchmove = (e) ->
for touch in e.changedTouches for touch in e.changedTouches
if touch.identifier is @identifier if touch.identifier is @identifier
drag.call @, touch drag.call @, touch
return return
drag = (e) -> drag = (e) ->
{clientX, clientY} = e {clientX, clientY} = e
@ -265,13 +265,11 @@ UI = do ->
style.right = right style.right = right
style.top = top style.top = top
style.bottom = bottom style.bottom = bottom
touchend = (e) -> touchend = (e) ->
for touch in e.changedTouches for touch in e.changedTouches
if touch.identifier is @identifier if touch.identifier is @identifier
dragend.call @ dragend.call @
return return
dragend = -> dragend = ->
if @isTouching if @isTouching
$.off d, 'touchmove', @move $.off d, 'touchmove', @move
@ -279,15 +277,14 @@ UI = do ->
else # mouseup else # mouseup
$.off d, 'mousemove', @move $.off d, 'mousemove', @move
$.off d, 'mouseup', @up $.off d, 'mouseup', @up
localStorage.setItem "#{g.NAMESPACE}#{@id}.position", @style.cssText $.set "#{@id}.position", @style.cssText
hoverstart = ({root, el, latestEvent, endEvents, asapTest, cb, close}) -> hoverstart = ({root, el, latestEvent, endEvents, asapTest, cb}) ->
o = { o = {
root: root root: root
el: el el: el
style: el.style style: el.style
cb: cb cb: cb
close: close
endEvents: endEvents endEvents: endEvents
latestEvent: latestEvent latestEvent: latestEvent
clientHeight: doc.clientHeight clientHeight: doc.clientHeight
@ -303,13 +300,12 @@ UI = do ->
$.on root, endEvents, o.hoverend $.on root, endEvents, o.hoverend
$.on root, 'mousemove', o.hover $.on root, 'mousemove', o.hover
hover = (e) -> hover = (e) ->
@latestEvent = e @latestEvent = e
height = @el.offsetHeight height = @el.offsetHeight
{clientX, clientY} = e {clientX, clientY} = e
top = clientY + (if close then 0 else -120) top = clientY - 120
top = if @clientHeight <= height or top <= 0 top = if @clientHeight <= height or top <= 0
0 0
else if top + height >= @clientHeight else if top + height >= @clientHeight
@ -318,7 +314,7 @@ UI = do ->
top top
[left, right] = if clientX <= @clientWidth - 400 [left, right] = if clientX <= @clientWidth - 400
[clientX + (if @close then 15 else 45) + 'px', null] [clientX + 45 + 'px', null]
else else
[null, @clientWidth - clientX + 45 + 'px'] [null, @clientWidth - clientX + 45 + 'px']
@ -326,7 +322,6 @@ UI = do ->
style.top = top + 'px' style.top = top + 'px'
style.left = left style.left = left
style.right = right style.right = right
hoverend = -> hoverend = ->
$.rm @el $.rm @el
$.off @root, @endEvents, @hoverend $.off @root, @endEvents, @hoverend