From 90426ea4d842f7c1b475bcba6312012b6b8ee66c Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 31 Oct 2011 17:00:29 -0700 Subject: [PATCH] use ui.dialog --- 4chan_x.user.js | 14 ++++++-------- script.coffee | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fc3fb2a5d..8569a520b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -207,13 +207,15 @@ }; ui = { dialog: function(id, position, html) { - var el, saved; + var el, saved, _ref; el = d.createElement('div'); el.className = 'reply dialog'; el.innerHTML = html; el.id = id; el.style.cssText = (saved = localStorage["" + NAMESPACE + id + ".position"]) ? saved : position; - el.querySelector('div.move').addEventListener('mousedown', ui.dragstart, false); + if ((_ref = el.querySelector('div.move')) != null) { + _ref.addEventListener('mousedown', ui.dragstart, false); + } return el; }, dragstart: function(e) { @@ -1219,10 +1221,7 @@ }, dialog: function() { var arr, back, checked, description, dialog, hiddenNum, hiddenThreads, input, key, li, obj, overlay, ta, time, ul, _i, _j, _len, _len2, _ref, _ref2, _ref3; - dialog = $.el('div', { - id: 'options', - className: 'reply dialog', - innerHTML: '\ + dialog = ui.dialog('options', '', '\
\
\ 4chan X\ @@ -1299,8 +1298,7 @@ Reset the unread count to 0\ \
\ -
' - }); +'); _ref = config.main; for (key in _ref) { obj = _ref[key]; diff --git a/script.coffee b/script.coffee index 81e9a2749..2383d36de 100644 --- a/script.coffee +++ b/script.coffee @@ -134,7 +134,7 @@ ui = el.innerHTML = html el.id = id el.style.cssText = if saved = localStorage["#{NAMESPACE}#{id}.position"] then saved else position - el.querySelector('div.move').addEventListener 'mousedown', ui.dragstart, false + el.querySelector('div.move')?.addEventListener 'mousedown', ui.dragstart, false el dragstart: (e) -> #prevent text selection @@ -865,7 +865,7 @@ options = $.replace home, a dialog: -> - dialog = $.el 'div', id: 'options', className: 'reply dialog', innerHTML: ' + dialog = ui.dialog 'options', '', '