Consolidate QR Shortcut code.

This commit is contained in:
ccd0 2015-01-25 18:19:31 -08:00
parent 0e10415d71
commit e079c55e60
2 changed files with 13 additions and 21 deletions

View File

@ -215,8 +215,6 @@ Keybinds =
if thread? if thread?
QR.quote.call $ 'input', $('.post.highlight', thread) or thread QR.quote.call $ 'input', $('.post.highlight', thread) or thread
QR.nodes.com.focus() QR.nodes.com.focus()
if Conf['QR Shortcut']
$.rmClass $('.qr-shortcut'), 'disabled'
tags: (tag, ta) -> tags: (tag, ta) ->
supported = switch tag supported = switch tag

View File

@ -15,7 +15,7 @@ QR =
if Conf['QR Shortcut'] if Conf['QR Shortcut']
sc = $.el 'a', sc = $.el 'a',
className: "qr-shortcut fa fa-comment-o #{unless Conf['Persistent QR'] then 'disabled' else ''}" className: 'qr-shortcut fa fa-comment-o disabled'
textContent: 'QR' textContent: 'QR'
title: 'Quick Reply' title: 'Quick Reply'
href: 'javascript:;' href: 'javascript:;'
@ -24,10 +24,8 @@ QR =
if Conf['Persistent QR'] or !QR.nodes or QR.nodes.el.hidden if Conf['Persistent QR'] or !QR.nodes or QR.nodes.el.hidden
QR.open() QR.open()
QR.nodes.com.focus() QR.nodes.com.focus()
$.rmClass @, 'disabled'
else else
QR.close() QR.close()
$.addClass @, 'disabled'
Header.addShortcut sc Header.addShortcut sc
@ -62,8 +60,6 @@ QR =
$.event 'CloseMenu' $.event 'CloseMenu'
QR.open() QR.open()
QR.nodes.com.focus() QR.nodes.com.focus()
if Conf['QR Shortcut']
$.rmClass $('.qr-shortcut'), 'disabled'
if Conf['Bottom QR Link'] and g.VIEW is 'thread' if Conf['Bottom QR Link'] and g.VIEW is 'thread'
linkBot = $.el 'div', linkBot = $.el 'div',
@ -74,8 +70,6 @@ QR =
$.event 'CloseMenu' $.event 'CloseMenu'
QR.open() QR.open()
QR.nodes.com.focus() QR.nodes.com.focus()
if Conf['QR Shortcut']
$.rmClass $('.qr-shortcut'), 'disabled'
$.prepend $('.navLinksBot'), linkBot $.prepend $('.navLinksBot'), linkBot
@ -110,14 +104,17 @@ QR =
QR.captcha.setup() if QR.nodes.el.hidden QR.captcha.setup() if QR.nodes.el.hidden
QR.nodes.el.hidden = false QR.nodes.el.hidden = false
QR.unhide() QR.unhide()
return else
try try
QR.dialog() QR.dialog()
catch err catch err
delete QR.nodes delete QR.nodes
Main.handleErrors Main.handleErrors
message: 'Quick Reply dialog creation crashed.' message: 'Quick Reply dialog creation crashed.'
error: err error: err
return
if Conf['QR Shortcut']
$.rmClass $('.qr-shortcut'), 'disabled'
close: -> close: ->
if QR.req if QR.req
QR.abort() QR.abort()
@ -127,7 +124,7 @@ QR =
d.activeElement.blur() d.activeElement.blur()
$.rmClass QR.nodes.el, 'dump' $.rmClass QR.nodes.el, 'dump'
if Conf['QR Shortcut'] if Conf['QR Shortcut']
$.toggleClass $('.qr-shortcut'), 'disabled' $.addClass $('.qr-shortcut'), 'disabled'
new QR.post true new QR.post true
for post in QR.posts.splice 0, QR.posts.length - 1 for post in QR.posts.splice 0, QR.posts.length - 1
post.delete() post.delete()
@ -280,9 +277,6 @@ QR =
QR.selected.save com QR.selected.save com
QR.selected.save thread QR.selected.save thread
if Conf['QR Shortcut']
$.rmClass $('.qr-shortcut'), 'disabled'
characterCount: -> characterCount: ->
counter = QR.nodes.charCount counter = QR.nodes.charCount
count = QR.nodes.com.textLength count = QR.nodes.com.textLength