From eb7c48af0c24d974c4fb1b6d6ac445e6f4a3ba8b Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 5 Nov 2016 18:15:32 -0700 Subject: [PATCH] Move dialog positions into Config. --- src/General/UI.coffee | 6 ++---- src/Linkification/Embedding.coffee | 2 +- src/Monitoring/ThreadStats.coffee | 2 +- src/Monitoring/ThreadUpdater.coffee | 2 +- src/Monitoring/ThreadWatcher.coffee | 2 +- src/Posting/QR.coffee | 2 +- src/config/Config.coffee | 7 +++++++ src/platform/$.coffee | 1 - 8 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/General/UI.coffee b/src/General/UI.coffee index c1b34cd1e..165ff4eb7 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -1,11 +1,9 @@ -dialog = (id, position, properties) -> +dialog = (id, properties) -> el = $.el 'div', className: 'dialog' id: id $.extend el, properties - el.style.cssText = position - $.get "#{id}.position", position, (item) -> - (el.style.cssText = item["#{id}.position"]) + el.style.cssText = Conf["#{id}.position"] move = $ '.move', el $.on move, 'touchstart mousedown', dragstart diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee index 6fe79aeb0..ed6f22e3d 100644 --- a/src/Linkification/Embedding.coffee +++ b/src/Linkification/Embedding.coffee @@ -5,7 +5,7 @@ Embedding = @types[type.key] = type for type in @ordered_types if Conf['Embedding'] - @dialog = UI.dialog 'embedding', 'top: 50px; right: 0px;', + @dialog = UI.dialog 'embedding', <%= readHTML('Embed.html') %> @media = $ '#media-embed', @dialog $.one d, '4chanXInitFinished', @ready diff --git a/src/Monitoring/ThreadStats.coffee b/src/Monitoring/ThreadStats.coffee index dae528d88..1ad67cb3c 100644 --- a/src/Monitoring/ThreadStats.coffee +++ b/src/Monitoring/ThreadStats.coffee @@ -19,7 +19,7 @@ ThreadStats = Header.addShortcut 'stats', sc, 200 else - @dialog = sc = UI.dialog 'thread-stats', 'bottom: 0px; right: 0px;', + @dialog = sc = UI.dialog 'thread-stats', <%= html('
&{statsHTML}
') %> $.addClass doc, 'float' $.ready -> diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index 81518172f..ef1398c75 100644 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -14,7 +14,7 @@ ThreadUpdater = $.extend sc, <%= html('') %> Header.addShortcut 'updater', sc, 100 else - @dialog = sc = UI.dialog 'updater', 'bottom: 0px; left: 0px;', + @dialog = sc = UI.dialog 'updater', <%= html('
') %> $.addClass doc, 'float' $.ready -> diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index 87af3b195..7530c068b 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -10,7 +10,7 @@ ThreadWatcher = className: 'fa fa-eye' @db = new DataBoard 'watchedThreads', @refresh, true - @dialog = UI.dialog 'thread-watcher', 'top: 50px; left: 0px;', <%= readHTML('ThreadWatcher.html') %> + @dialog = UI.dialog 'thread-watcher', <%= readHTML('ThreadWatcher.html') %> @status = $ '#watcher-status', @dialog @list = @dialog.lastElementChild diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 56aa2d283..14b591ad0 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -456,7 +456,7 @@ QR = dialog: -> QR.nodes = nodes = - el: dialog = UI.dialog 'qr', 'top: 50px; right: 0px;', + el: dialog = UI.dialog 'qr', <%= readHTML('QuickReply.html') %> setNode = (name, query) -> diff --git a/src/config/Config.coffee b/src/config/Config.coffee index 81e33717b..c9d2f4835 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -1053,3 +1053,10 @@ Config = 'Max Replies': 1000 'Autohiding Scrollbar': false + + position: + 'embedding.position': 'top: 50px; right: 0px;' + 'thread-stats.position': 'bottom: 0px; right: 0px;' + 'updater.position': 'bottom: 0px; left: 0px;' + 'thread-watcher.position': 'top: 50px; left: 0px;' + 'qr.position': 'top: 50px; right: 0px;' diff --git a/src/platform/$.coffee b/src/platform/$.coffee index ea4394947..288131677 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -602,7 +602,6 @@ $.clear = (cb) -> # Also support case where GM_listValues is not defined. $.delete Object.keys(Conf) $.delete ['previousversion', 'QR Size', 'captchas', 'QR.persona', 'hiddenPSA'] - $.delete ("#{id}.position" for id in ['embedding', 'updater', 'thread-stats', 'thread-watcher', 'qr']) try $.delete $.listValues().map (key) -> key.replace g.NAMESPACE, '' cb?()