diff --git a/4chan_x.user.js b/4chan_x.user.js
index 366f09911..37c71aea1 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -199,26 +199,12 @@
};
ui = {
dialog: function(id, position, html) {
- var el, left, saved, top;
+ var el, saved;
el = d.createElement('div');
el.className = 'reply dialog';
el.innerHTML = html;
el.id = id;
- if (saved = localStorage["" + NAMESPACE + id + ".position"]) {
- el.style.cssText = saved;
- } else {
- left = position.left, top = position.top;
- if (left) {
- el.style.left = left;
- } else {
- el.style.right = 0;
- }
- if (top) {
- el.style.top = top;
- } else {
- el.style.bottom = 0;
- }
- }
+ el.style.cssText = (saved = localStorage["" + NAMESPACE + id + ".position"]) ? saved : position;
el.querySelector('div.move').addEventListener('mousedown', ui.dragstart, false);
return el;
},
@@ -1363,10 +1349,7 @@
THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id;
qr.challenge = $('#recaptcha_challenge_field').value;
html = " X
Quick Reply
";
- qr.el = ui.dialog('qr', {
- top: '0px',
- left: '0px'
- }, html);
+ qr.el = ui.dialog('qr', 'top: 0; left: 0;', html);
$.bind($('input[name=name]', qr.el), 'mousedown', function(e) {
return e.stopPropagation();
});
@@ -1744,10 +1727,7 @@
}
checked = conf['Auto Update'] ? 'checked' : '';
html += " ";
- dialog = ui.dialog('updater', {
- bottom: '0',
- right: '0'
- }, html);
+ dialog = ui.dialog('updater', 'bottom: 0; right: 0;', html);
updater.count = $('#count', dialog);
updater.timer = $('#timer', dialog);
updater.br = $('br[clear]');
@@ -1875,10 +1855,7 @@
init: function() {
var favicon, html, input, inputs, _i, _len;
html = 'Thread Watcher
';
- watcher.dialog = ui.dialog('watcher', {
- top: '50px',
- left: '0px'
- }, html);
+ watcher.dialog = ui.dialog('watcher', 'top: 50px; left: 0px;', html);
$.add(d.body, watcher.dialog);
inputs = $$('.op input');
for (_i = 0, _len = inputs.length; _i < _len; _i++) {
@@ -2474,10 +2451,7 @@
threadStats.posts = 1;
threadStats.images = $('.op img[md5]') ? 1 : 0;
html = "" + threadStats.posts + " / " + threadStats.images + "
";
- dialog = ui.dialog('stats', {
- bottom: '0px',
- left: '0px'
- }, html);
+ dialog = ui.dialog('stats', 'bottom: 0; left: 0;', html);
dialog.className = 'dialog';
threadStats.postcountEl = $('#postcount', dialog);
threadStats.imagecountEl = $('#imagecount', dialog);
diff --git a/script.coffee b/script.coffee
index e0ce98f59..1698fe712 100644
--- a/script.coffee
+++ b/script.coffee
@@ -126,12 +126,7 @@ ui =
el.className = 'reply dialog'
el.innerHTML = html
el.id = id
- if saved = localStorage["#{NAMESPACE}#{id}.position"]
- el.style.cssText = saved
- else
- {left, top} = position
- if left then el.style.left = left else el.style.right = 0
- if top then el.style.top = top else el.style.bottom = 0
+ el.style.cssText = if saved = localStorage["#{NAMESPACE}#{id}.position"] then saved else position
el.querySelector('div.move').addEventListener 'mousedown', ui.dragstart, false
el
dragstart: (e) ->
@@ -1073,7 +1068,7 @@ qr =
"
- qr.el = ui.dialog 'qr', top: '0px', left: '0px', html
+ qr.el = ui.dialog 'qr', 'top: 0; left: 0;', html
$.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation()
$.bind $('input[name=upfile]', qr.el), 'change', qr.validateFileSize
@@ -1393,7 +1388,7 @@ updater =
"
- dialog = ui.dialog 'updater', bottom: '0', right: '0', html
+ dialog = ui.dialog 'updater', 'bottom: 0; right: 0;', html
updater.count = $ '#count', dialog
updater.timer = $ '#timer', dialog
@@ -1501,7 +1496,7 @@ updater =
watcher =
init: ->
html = 'Thread Watcher
'
- watcher.dialog = ui.dialog 'watcher', top: '50px', left: '0px', html
+ watcher.dialog = ui.dialog 'watcher', 'top: 50px; left: 0px;', html
$.add d.body, watcher.dialog
#add watch buttons
@@ -1885,7 +1880,7 @@ threadStats =
threadStats.posts = 1
threadStats.images = if $ '.op img[md5]' then 1 else 0
html = "#{threadStats.posts} / #{threadStats.images}
"
- dialog = ui.dialog 'stats', bottom: '0px', left: '0px', html
+ dialog = ui.dialog 'stats', 'bottom: 0; left: 0;', html
dialog.className = 'dialog'
threadStats.postcountEl = $ '#postcount', dialog
threadStats.imagecountEl = $ '#imagecount', dialog