Use localStorage.get/setItem in UI.
This commit is contained in:
parent
4997bca3fc
commit
f15b920850
@ -199,12 +199,12 @@
|
|||||||
|
|
||||||
UI = {
|
UI = {
|
||||||
dialog: function(id, position, html) {
|
dialog: function(id, position, html) {
|
||||||
var el, saved;
|
var el;
|
||||||
el = d.createElement('div');
|
el = d.createElement('div');
|
||||||
el.className = 'reply dialog';
|
el.className = 'reply dialog';
|
||||||
el.innerHTML = html;
|
el.innerHTML = html;
|
||||||
el.id = id;
|
el.id = id;
|
||||||
el.style.cssText = (saved = localStorage["" + Main.namespace + id + ".position"]) ? saved : position;
|
el.style.cssText = localStorage.getItem("" + Main.namespace + id + ".position") || position;
|
||||||
el.querySelector('.move').addEventListener('mousedown', UI.dragstart, false);
|
el.querySelector('.move').addEventListener('mousedown', UI.dragstart, false);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
@ -233,9 +233,7 @@
|
|||||||
return style.bottom = top === null ? '0px' : null;
|
return style.bottom = top === null ? '0px' : null;
|
||||||
},
|
},
|
||||||
dragend: function() {
|
dragend: function() {
|
||||||
var el;
|
localStorage.setItem("" + Main.namespace + UI.el.id + ".position", UI.el.style.cssText);
|
||||||
el = UI.el;
|
|
||||||
localStorage["" + Main.namespace + el.id + ".position"] = el.style.cssText;
|
|
||||||
d.removeEventListener('mousemove', UI.drag, false);
|
d.removeEventListener('mousemove', UI.drag, false);
|
||||||
d.removeEventListener('mouseup', UI.dragend, false);
|
d.removeEventListener('mouseup', UI.dragend, false);
|
||||||
return delete UI.el;
|
return delete UI.el;
|
||||||
|
|||||||
@ -164,15 +164,15 @@ UI =
|
|||||||
el = d.createElement 'div'
|
el = d.createElement 'div'
|
||||||
el.className = 'reply dialog'
|
el.className = 'reply dialog'
|
||||||
el.innerHTML = html
|
el.innerHTML = html
|
||||||
el.id = id
|
el.id = id
|
||||||
el.style.cssText = if saved = localStorage["#{Main.namespace}#{id}.position"] then saved else position
|
el.style.cssText = localStorage.getItem("#{Main.namespace}#{id}.position") or position
|
||||||
el.querySelector('.move').addEventListener 'mousedown', UI.dragstart, false
|
el.querySelector('.move').addEventListener 'mousedown', UI.dragstart, false
|
||||||
el
|
el
|
||||||
dragstart: (e) ->
|
dragstart: (e) ->
|
||||||
#prevent text selection
|
#prevent text selection
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
UI.el = el = @parentNode
|
UI.el = el = @parentNode
|
||||||
d.addEventListener 'mousemove', UI.drag, false
|
d.addEventListener 'mousemove', UI.drag, false
|
||||||
d.addEventListener 'mouseup', UI.dragend, false
|
d.addEventListener 'mouseup', UI.dragend, false
|
||||||
#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
|
||||||
@ -200,12 +200,8 @@ UI =
|
|||||||
style.right = if left is null then '0px' else null
|
style.right = if left is null then '0px' else null
|
||||||
style.bottom = if top is null then '0px' else null
|
style.bottom = if top is null then '0px' else null
|
||||||
dragend: ->
|
dragend: ->
|
||||||
#$ coffee -bpe '{a} = {b} = c'
|
localStorage.setItem "#{Main.namespace}#{UI.el.id}.position", UI.el.style.cssText
|
||||||
#var a, b;
|
d.removeEventListener 'mousemove', UI.drag, false
|
||||||
#a = (b = c.b, c).a;
|
|
||||||
{el} = UI
|
|
||||||
localStorage["#{Main.namespace}#{el.id}.position"] = el.style.cssText
|
|
||||||
d.removeEventListener 'mousemove', UI.drag, false
|
|
||||||
d.removeEventListener 'mouseup', UI.dragend, false
|
d.removeEventListener 'mouseup', UI.dragend, false
|
||||||
delete UI.el
|
delete UI.el
|
||||||
hover: (e) ->
|
hover: (e) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user