From 1ef79b7bddc1cdb417249f21524512aeb8ac6343 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 12 Mar 2011 15:52:36 -0800 Subject: [PATCH] fix thread watcher position --- 4chan_x.js | 50 ++++++++++++++++++++++++++++---------------------- script.coffee | 38 ++++++++++++++++++++------------------ 2 files changed, 48 insertions(+), 40 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 75aedf87c..6963d0458 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -140,26 +140,30 @@ el.className = 'reply dialog'; el.innerHTML = html; el.id = id; - switch (position) { - case 'topleft': - left = '0px'; - top = '0px'; - break; - case 'topright': - left = null; - top = '0px'; - break; - case 'bottomleft': - left = '0px'; - top = null; - break; - case 'bottomright': - left = null; - top = null; - break; - case 'center': - left = '50%'; - top = '25%'; + if (typeof position === 'object') { + left = position.left, top = position.top; + } else { + switch (position) { + case 'topleft': + left = '0px'; + top = '0px'; + break; + case 'topright': + left = null; + top = '0px'; + break; + case 'bottomleft': + left = '0px'; + top = null; + break; + case 'bottomright': + left = null; + top = null; + break; + case 'center': + left = '50%'; + top = '25%'; + } } left = GM_getValue("" + id + "Left", left); top = GM_getValue("" + id + "Top", top); @@ -1798,8 +1802,10 @@ } if (getConfig('Thread Watcher')) { html = '
Thread Watcher
'; - watcher = new Dialog('watcher', 'topleft', html).el; - watcher.style.top = '50px'; + watcher = new Dialog('watcher', { + top: '50px', + left: '0px' + }, html).el; mv(watcher, d.body); watcherUpdate(); threads = g.watched[g.BOARD] || []; diff --git a/script.coffee b/script.coffee index 1a06ffcee..162359a54 100644 --- a/script.coffee +++ b/script.coffee @@ -78,22 +78,25 @@ class Dialog el.className = 'reply dialog' el.innerHTML = html el.id = id - switch position - when 'topleft' - left = '0px' - top = '0px' - when 'topright' - left = null - top = '0px' - when 'bottomleft' - left = '0px' - top = null - when 'bottomright' - left = null - top = null - when 'center' - left = '50%' - top = '25%' + if typeof position is 'object' + {left, top} = position + else + switch position + when 'topleft' + left = '0px' + top = '0px' + when 'topright' + left = null + top = '0px' + when 'bottomleft' + left = '0px' + top = null + when 'bottomright' + left = null + top = null + when 'center' + left = '50%' + top = '25%' left = GM_getValue "#{id}Left", left top = GM_getValue "#{id}Top", top if left then el.style.left = left else el.style.right = '0px' @@ -1364,8 +1367,7 @@ if getConfig 'Quick Report' if getConfig 'Thread Watcher' #create watcher html = '
Thread Watcher
' - watcher = new Dialog('watcher', 'topleft', html).el - watcher.style.top = '50px' #don't cover the board links + watcher = new Dialog('watcher', top: '50px', left: '0px', html).el mv watcher, d.body watcherUpdate()