From 92ffb4ff8c84b2ffe1e686eacf17ca7e3762fa65 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Fri, 9 Aug 2013 22:41:57 -0700 Subject: [PATCH] Why? Because I can. --- builds/appchan-x.user.js | 100 ++++++++++++++++++---------------- builds/crx/script.js | 94 +++++++++++++++++--------------- src/General/Config.coffee | 4 ++ src/Posting/QuickReply.coffee | 82 ++++++++++++++-------------- 4 files changed, 149 insertions(+), 131 deletions(-) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 891108f66..993ab2648 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -204,7 +204,8 @@ 'Cooldown': [true, 'Indicate the remaining time before posting again.'], 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'], 'Posting Success Notifications': [true, 'Show notifications on successful post creation or file uploading.'], - 'Captcha Warning Notifications': [true, 'When disabled, shows a red border on the CAPTCHA input until a key is pressed instead of a notification.'] + 'Captcha Warning Notifications': [true, 'When disabled, shows a red border on the CAPTCHA input until a key is pressed instead of a notification.'], + 'Dump List Before Comment': [false, 'Position of the QR\'s Dump List.'] }, 'Quote Links': { 'Quote Backlinks': [true, 'Add quote backlinks.'], @@ -8043,7 +8044,7 @@ title: 'Verification', autocomplete: 'off', spellcheck: false, - tabIndex: 55 + tabIndex: 45 }); this.nodes = { challenge: $.id('recaptcha_challenge_field_holder'), @@ -8072,7 +8073,7 @@ $.on(input, 'blur', QR.focusout); $.on(input, 'focus', QR.focusin); $.addClass(QR.nodes.el, 'has-captcha'); - return $.after(QR.nodes.dumpList.parentElement, [imgContainer, input]); + return $.after(QR.nodes.com.parentElement, [imgContainer, input]); }, sync: function(captchas) { QR.captcha.captchas = captchas; @@ -8183,45 +8184,46 @@ } }, dialog: function() { - var dialog, elm, mimeTypes, name, nodes, thread, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2; + var check, dialog, elm, key, mimeTypes, name, nodes, thread, value, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3; - dialog = UI.dialog('qr', 'top:0;right:0;', "
No selected fileSpoiler+DumpRemove File
"); QR.nodes = nodes = { - el: dialog, - move: $('.move', dialog), - autohide: $('#autohide', dialog), - thread: $('select', dialog), - threadPar: $('#qr-thread-select', dialog), - close: $('.close', dialog), - form: $('form', dialog), - dumpButton: $('#dump-button', dialog), - name: $('[data-name=name]', dialog), - email: $('[data-name=email]', dialog), - sub: $('[data-name=sub]', dialog), - com: $('[data-name=com]', dialog), - dumpList: $('#dump-list', dialog), - addPost: $('#add-post', dialog), - charCount: $('#char-count', dialog), - fileSubmit: $('#file-n-submit', dialog), - filename: $('#qr-filename', dialog), - fileRM: $('#qr-filerm', dialog), - fileExtras: $('#qr-extras-container', dialog), - spoiler: $('#qr-file-spoiler', dialog), - spoilerPar: $('#qr-spoiler-label', dialog), - status: $('[type=submit]', dialog), - fileInput: $('[type=file]', dialog) + el: dialog = UI.dialog('qr', 'top:0;right:0;', "
No selected fileSpoiler+DumpRemove File
") + }; + _ref = { + move: '.move', + autohide: '#autohide', + thread: 'select', + threadPar: '#qr-thread-select', + close: '.close', + form: 'form', + dumpButton: '#dump-button', + name: '[data-name=name]', + email: '[data-name=email]', + sub: '[data-name=sub]', + com: '[data-name=com]', + dumpList: '#dump-list', + addPost: '#add-post', + charCount: '#char-count', + fileSubmit: '#file-n-submit', + filename: '#qr-filename', + fileRM: '#qr-filerm', + fileExtras: '#qr-extras-container', + spoiler: '#qr-file-spoiler', + spoilerPar: '#qr-spoiler-label', + status: '[type=submit]', + fileInput: '[type=file]' + }; + for (key in _ref) { + value = _ref[key]; + nodes[key] = $(value, dialog); + } + check = { + jpg: 'image/jpeg', + pdf: 'application/pdf', + swf: 'application/x-shockwave-flash' }; mimeTypes = $('ul.rules > li').textContent.trim().match(/: (.+)/)[1].toLowerCase().replace(/\w+/g, function(type) { - switch (type) { - case 'jpg': - return 'image/jpeg'; - case 'pdf': - return 'application/pdf'; - case 'swf': - return 'application/x-shockwave-flash'; - default: - return "image/" + type; - } + return check[type] || ("image/" + type); }); QR.mimeTypes = mimeTypes.split(', '); QR.mimeTypes.push(''); @@ -8232,6 +8234,10 @@ } else { nodes.spoiler.parentElement.hidden = true; } + if (Conf['Dump List Before Comment']) { + $.after(nodes.name.parentElement, nodes.dumpList.parentElement); + nodes.addPost.tabIndex = 35; + } if (g.BOARD.ID === 'f') { nodes.flashTag = $.el('select', { name: 'filetag', @@ -8246,9 +8252,9 @@ })); } $.on(nodes.filename.parentNode, 'click keyup', QR.openFileInput); - _ref = $$('*', QR.nodes.el); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - elm = _ref[_i]; + _ref1 = $$('*', QR.nodes.el); + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + elm = _ref1[_i]; $.on(elm, 'blur', QR.focusout); $.on(elm, 'focus', QR.focusin); } @@ -8273,14 +8279,14 @@ return QR.selected.nodes.spoiler.click(); }); $.on(nodes.fileInput, 'change', QR.fileInput); - _ref1 = ['spoilerPar', 'dumpButton', 'fileRM']; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - name = _ref1[_j]; + _ref2 = ['spoilerPar', 'dumpButton', 'fileRM']; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + name = _ref2[_j]; $.on(nodes[name], 'mouseover', QR.mouseover); } - _ref2 = ['name', 'email', 'sub', 'com']; - for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { - name = _ref2[_k]; + _ref3 = ['name', 'email', 'sub', 'com']; + for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) { + name = _ref3[_k]; $.on(nodes[name], 'input', function() { return QR.selected.save(this); }); diff --git a/builds/crx/script.js b/builds/crx/script.js index 0398c6d04..367b86cd5 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -187,7 +187,8 @@ 'Cooldown': [true, 'Indicate the remaining time before posting again.'], 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'], 'Posting Success Notifications': [true, 'Show notifications on successful post creation or file uploading.'], - 'Captcha Warning Notifications': [true, 'When disabled, shows a red border on the CAPTCHA input until a key is pressed instead of a notification.'] + 'Captcha Warning Notifications': [true, 'When disabled, shows a red border on the CAPTCHA input until a key is pressed instead of a notification.'], + 'Dump List Before Comment': [false, 'Position of the QR\'s Dump List.'] }, 'Quote Links': { 'Quote Backlinks': [true, 'Add quote backlinks.'], @@ -8045,7 +8046,7 @@ title: 'Verification', autocomplete: 'off', spellcheck: false, - tabIndex: 55 + tabIndex: 45 }); this.nodes = { challenge: $.id('recaptcha_challenge_field_holder'), @@ -8072,7 +8073,7 @@ $.sync('captchas', this.sync); this.reload(); $.addClass(QR.nodes.el, 'has-captcha'); - return $.after(QR.nodes.dumpList.parentElement, [imgContainer, input]); + return $.after(QR.nodes.com.parentElement, [imgContainer, input]); }, sync: function(captchas) { QR.captcha.captchas = captchas; @@ -8183,45 +8184,46 @@ } }, dialog: function() { - var dialog, mimeTypes, name, nodes, thread, _i, _j, _len, _len1, _ref, _ref1; + var check, dialog, key, mimeTypes, name, nodes, thread, value, _i, _j, _len, _len1, _ref, _ref1, _ref2; - dialog = UI.dialog('qr', 'top:0;right:0;', "
No selected fileSpoiler+DumpRemove File
"); QR.nodes = nodes = { - el: dialog, - move: $('.move', dialog), - autohide: $('#autohide', dialog), - thread: $('select', dialog), - threadPar: $('#qr-thread-select', dialog), - close: $('.close', dialog), - form: $('form', dialog), - dumpButton: $('#dump-button', dialog), - name: $('[data-name=name]', dialog), - email: $('[data-name=email]', dialog), - sub: $('[data-name=sub]', dialog), - com: $('[data-name=com]', dialog), - dumpList: $('#dump-list', dialog), - addPost: $('#add-post', dialog), - charCount: $('#char-count', dialog), - fileSubmit: $('#file-n-submit', dialog), - filename: $('#qr-filename', dialog), - fileRM: $('#qr-filerm', dialog), - fileExtras: $('#qr-extras-container', dialog), - spoiler: $('#qr-file-spoiler', dialog), - spoilerPar: $('#qr-spoiler-label', dialog), - status: $('[type=submit]', dialog), - fileInput: $('[type=file]', dialog) + el: dialog = UI.dialog('qr', 'top:0;right:0;', "
No selected fileSpoiler+DumpRemove File
") + }; + _ref = { + move: '.move', + autohide: '#autohide', + thread: 'select', + threadPar: '#qr-thread-select', + close: '.close', + form: 'form', + dumpButton: '#dump-button', + name: '[data-name=name]', + email: '[data-name=email]', + sub: '[data-name=sub]', + com: '[data-name=com]', + dumpList: '#dump-list', + addPost: '#add-post', + charCount: '#char-count', + fileSubmit: '#file-n-submit', + filename: '#qr-filename', + fileRM: '#qr-filerm', + fileExtras: '#qr-extras-container', + spoiler: '#qr-file-spoiler', + spoilerPar: '#qr-spoiler-label', + status: '[type=submit]', + fileInput: '[type=file]' + }; + for (key in _ref) { + value = _ref[key]; + nodes[key] = $(value, dialog); + } + check = { + jpg: 'image/jpeg', + pdf: 'application/pdf', + swf: 'application/x-shockwave-flash' }; mimeTypes = $('ul.rules > li').textContent.trim().match(/: (.+)/)[1].toLowerCase().replace(/\w+/g, function(type) { - switch (type) { - case 'jpg': - return 'image/jpeg'; - case 'pdf': - return 'application/pdf'; - case 'swf': - return 'application/x-shockwave-flash'; - default: - return "image/" + type; - } + return check[type] || ("image/" + type); }); QR.mimeTypes = mimeTypes.split(', '); QR.mimeTypes.push(''); @@ -8232,6 +8234,10 @@ } else { nodes.spoiler.parentElement.hidden = true; } + if (Conf['Dump List Before Comment']) { + $.after(nodes.name.parentElement, nodes.dumpList.parentElement); + nodes.addPost.tabIndex = 35; + } if (g.BOARD.ID === 'f') { nodes.flashTag = $.el('select', { name: 'filetag', @@ -8267,14 +8273,14 @@ return QR.selected.nodes.spoiler.click(); }); $.on(nodes.fileInput, 'change', QR.fileInput); - _ref = ['spoilerPar', 'dumpButton', 'fileRM']; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - name = _ref[_i]; + _ref1 = ['spoilerPar', 'dumpButton', 'fileRM']; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + name = _ref1[_i]; $.on(nodes[name], 'mouseover', QR.mouseover); } - _ref1 = ['name', 'email', 'sub', 'com']; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - name = _ref1[_j]; + _ref2 = ['name', 'email', 'sub', 'com']; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + name = _ref2[_j]; $.on(nodes[name], 'input', function() { return QR.selected.save(this); }); diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 5310a0aed..cc7b7daf0 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -297,6 +297,10 @@ Config = true 'When disabled, shows a red border on the CAPTCHA input until a key is pressed instead of a notification.' ] + 'Dump List Before Comment': [ + false + 'Position of the QR\'s Dump List.' + ] 'Quote Links': 'Quote Backlinks': [ diff --git a/src/Posting/QuickReply.coffee b/src/Posting/QuickReply.coffee index cb9653e98..2268b9ccd 100644 --- a/src/Posting/QuickReply.coffee +++ b/src/Posting/QuickReply.coffee @@ -45,8 +45,8 @@ QR = initReady: -> QR.postingIsEnabled = !!$.id 'postForm' unless QR.postingIsEnabled - return - + return + $.on d, 'QRGetSelectedPost', ({detail: cb}) -> cb QR.selected $.on d, 'QRAddPreSubmitHook', ({detail: cb}) -> @@ -757,7 +757,7 @@ QR = title: 'Verification' autocomplete: 'off' spellcheck: false - tabIndex: 55 + tabIndex: 45 @nodes = challenge: $.id 'recaptcha_challenge_field_holder' img: imgContainer.firstChild @@ -785,7 +785,7 @@ QR = <% } %> $.addClass QR.nodes.el, 'has-captcha' - $.after QR.nodes.dumpList.parentElement, [imgContainer, input] + $.after QR.nodes.com.parentElement, [imgContainer, input] sync: (captchas) -> QR.captcha.captchas = captchas @@ -864,46 +864,44 @@ QR = e.preventDefault() dialog: -> - dialog = UI.dialog 'qr', 'top:0;right:0;', """ - <%= grunt.file.read('src/General/html/Features/QuickReply.html').replace(/>\s+<').trim() %> - """ - QR.nodes = nodes = - el: dialog - move: $ '.move', dialog - autohide: $ '#autohide', dialog - thread: $ 'select', dialog - threadPar: $ '#qr-thread-select', dialog - close: $ '.close', dialog - form: $ 'form', dialog - dumpButton: $ '#dump-button', dialog - name: $ '[data-name=name]', dialog - email: $ '[data-name=email]', dialog - sub: $ '[data-name=sub]', dialog - com: $ '[data-name=com]', dialog - dumpList: $ '#dump-list', dialog - addPost: $ '#add-post', dialog - charCount: $ '#char-count', dialog - fileSubmit: $ '#file-n-submit', dialog - filename: $ '#qr-filename', dialog - fileRM: $ '#qr-filerm', dialog - fileExtras: $ '#qr-extras-container', dialog - spoiler: $ '#qr-file-spoiler', dialog - spoilerPar: $ '#qr-spoiler-label', dialog - status: $ '[type=submit]', dialog - fileInput: $ '[type=file]', dialog + el: + dialog = UI.dialog 'qr', 'top:0;right:0;', """<%= grunt.file.read('src/General/html/Features/QuickReply.html').replace(/>\s+<').trim() %>""" + + nodes[key] = $ value, dialog for key, value of { + move: '.move' + autohide: '#autohide' + thread: 'select' + threadPar: '#qr-thread-select' + close: '.close' + form: 'form' + dumpButton: '#dump-button' + name: '[data-name=name]' + email: '[data-name=email]' + sub: '[data-name=sub]' + com: '[data-name=com]' + dumpList: '#dump-list' + addPost: '#add-post' + charCount: '#char-count' + fileSubmit: '#file-n-submit' + filename: '#qr-filename' + fileRM: '#qr-filerm' + fileExtras: '#qr-extras-container' + spoiler: '#qr-file-spoiler' + spoilerPar: '#qr-spoiler-label' + status: '[type=submit]' + fileInput: '[type=file]' + } + + check = + jpg: 'image/jpeg' + pdf: 'application/pdf' + swf: 'application/x-shockwave-flash' # Allow only this board's supported files. mimeTypes = $('ul.rules > li').textContent.trim().match(/: (.+)/)[1].toLowerCase().replace /\w+/g, (type) -> - switch type - when 'jpg' - 'image/jpeg' - when 'pdf' - 'application/pdf' - when 'swf' - 'application/x-shockwave-flash' - else - "image/#{type}" + check[type] or "image/#{type}" + QR.mimeTypes = mimeTypes.split ', ' # Add empty mimeType to avoid errors with URLs selected in Window's file dialog. QR.mimeTypes.push '' @@ -915,6 +913,10 @@ QR = else nodes.spoiler.parentElement.hidden = true + if Conf['Dump List Before Comment'] + $.after nodes.name.parentElement, nodes.dumpList.parentElement + nodes.addPost.tabIndex = 35 + if g.BOARD.ID is 'f' nodes.flashTag = $.el 'select', name: 'filetag'