Add options for header and page QR shortcuts. #280

This commit is contained in:
Zixaphir 2013-05-09 02:02:59 -07:00
parent c78443ac00
commit 94124f953b
8 changed files with 137 additions and 74 deletions

View File

@ -3,6 +3,8 @@ zixaphir
- Fix stubs in reply hiding menu not following stubs config
- Fix thread hiding
- Fix Board Subtitle option
- Revert to Mayhem-style notifications
- Add options for adding QR Shortcuts to the header or page
### 2.0.1 - 2013-05-08
seaweed

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -243,9 +243,13 @@ Config =
]
'Posting':
'Quick Reply': [
'Header Shortcut': [
true
'All-in-one form to reply, create threads, automate dumping and more.'
'Add a shortcut to the header to toggle the QR.'
]
'Page Shortcut': [
false
'Add a shortcut to the top of the page to toggle the QR.'
]
'Persistent QR': [
true

View File

@ -1120,6 +1120,10 @@ input:checked + .rice {
#selectrice:empty {
display: none;
}
/* Post Form Shortcut */
.qr-shortcut.on-page {
font-size: 250%;
}
/* Post Form */
#qr {
z-index: 20;
@ -1346,16 +1350,6 @@ input:not([type=radio]) {
opacity: 0;
z-index: -1;
}
#showQR {
display: #{if _conf["Hide Show Post Form"] then "none" else "block"};
z-index: 4;
#{Style.sidebarLocation[0]}: 2px;
width: #{width}px;
background-color: transparent;
text-align: center;
position: fixed;
top: auto;
}
/* Fake File Input */
#qr-filename,
.has-file #qr-no-file {

View File

@ -1,9 +1,16 @@
QR =
init: ->
return if !Conf['Quick Reply']
@db = new DataBoard 'yourPosts'
$.ready @initReady
$.on d, '4chanXInitFinished', @persist if Conf['Persistent QR']
Post::callbacks.push
name: 'Quick Reply'
cb: @node
return unless Conf['Header Shortcut'] or Conf['Page Shortcut']
sc = $.el 'a',
className: "qr-shortcut #{unless Conf['Persistent QR'] then 'disabled' else ''}"
textContent: 'QR'
@ -19,14 +26,16 @@ QR =
QR.close()
$.toggleClass @, 'disabled'
Header.addShortcut sc
return Header.addShortcut sc if Conf['Header Shortcut']
$.ready @initReady
$.on d, '4chanXInitFinished', @persist if Conf['Persistent QR']
Post::callbacks.push
name: 'Quick Reply'
cb: @node
$.addClass sc, 'on-page'
sc.textContent = if g.VIEW is 'thread' then 'Reply to Thread' else 'Start a Thread'
con = $.el 'div',
className: 'center'
$.add con, sc
$.asap (-> d.body), ->
$.asap (-> $.id 'postForm'), ->
$.before $.id('postForm'), con
initReady: ->
QR.postingIsEnabled = !!$.id 'postForm'
@ -117,9 +126,9 @@ QR =
QR.captcha.nodes.input.focus()
alert el.textContent if d.hidden
QR.notifications.push new Notification 'warning', el
notifications: []
cleanNotifications: ->
for notification in QR.notifications
notification.close()
@ -571,7 +580,7 @@ QR =
# Load this post's values.
for name in ['thread', 'name', 'email', 'sub', 'com']
QR.nodes[name].value = @[name] or null
QR.tripcodeHider.call QR.nodes['name']
@showFileData()
QR.characterCount()
@ -703,16 +712,16 @@ QR =
dragStart: ->
$.addClass @, 'drag'
dragEnd: ->
$.rmClass @, 'drag'
dragEnter: ->
$.addClass @, 'over'
dragLeave: ->
$.rmClass @, 'over'
dragOver: (e) ->
e.preventDefault()
e.dataTransfer.dropEffect = 'move'
@ -782,7 +791,7 @@ QR =
$.addClass QR.nodes.el, 'has-captcha'
$.after QR.nodes.dumpList.parentElement, [imgContainer, input]
sync: (@captchas) ->
QR.captcha.count()
@ -944,7 +953,7 @@ QR =
$.on nodes.dumpButton, 'click', -> nodes.el.classList.toggle 'dump'
$.on nodes.addPost, 'click', -> new QR.post true
$.on nodes.form, 'submit', QR.submit
$.on nodes.fileRM, 'click', (e) ->
$.on nodes.fileRM, 'click', (e) ->
e.stopPropagation()
QR.selected.rmFile()
$.on nodes.spoiler, 'change', -> QR.selected.nodes.spoiler.click()
@ -969,9 +978,9 @@ QR =
QR.status()
QR.cooldown.init()
QR.captcha.init()
Rice.nodes dialog
$.add d.body, dialog
if Conf['Auto Hide QR']
@ -987,7 +996,7 @@ QR =
else if !check and @.className.match "\\btripped\\b" then $.rmClass @, 'tripped'
preSubmitHooks: []
submit: (e) ->
e?.preventDefault()
@ -1155,11 +1164,11 @@ QR =
QR.status()
QR.error err
return
QR.cleanNotifications()
h1 = $ 'h1', tmpDoc
if Conf['Posting Success Notifications']
QR.notifications.push new Notification 'success', h1.textContent, 5