From 9ac1193cca6d7e9a8e74dcff32bcaacc538434b1 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Apr 2013 01:22:11 +0200 Subject: [PATCH 01/19] Update .gitignore. --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b79a916f9..868b74e84 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ builds/ node_modules/ -tmp/ +tmp-crx/ +tmp-userjs/ +tmp-userscript/ From 7805d1b1e690eae5771bf1545f5cd00a104802dd Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Apr 2013 01:26:12 +0200 Subject: [PATCH 02/19] Update deps. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a3869bc44..7ab48ab5d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "grunt": "~0.4.1", "grunt-bump": "~0.0.0", "grunt-concurrent": "~0.1.1", - "grunt-contrib-clean": "~0.4.0", + "grunt-contrib-clean": "~0.4.1", "grunt-contrib-coffee": "~0.6.6", "grunt-contrib-compress": "~0.4.10", "grunt-contrib-concat": "~0.2.0", From 6f50ec01153e7fd2db2cdd03b860815b9dcd3882 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Apr 2013 04:58:55 +0200 Subject: [PATCH 03/19] Shave off one useless line. --- src/qr.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qr.coffee b/src/qr.coffee index f64c88a37..54d8c5447 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -819,7 +819,6 @@ QR = $.add nodes.thread, $.el 'option', value: thread textContent: "Thread No.#{thread}" - $.after nodes.autohide, nodes.thread <% if (type === 'userscript') { %> # XXX Firefox lacks focusin/focusout support. From 8298f7e35d9b4279d56746b54b240bc9626b9b85 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Apr 2013 16:08:38 +0200 Subject: [PATCH 04/19] Remove the Download Link config on non-crx extensions. --- src/config.coffee | 4 +++- src/features.coffee | 7 ------- src/qr.coffee | 6 +++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/config.coffee b/src/config.coffee index acc178684..1be799305 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -33,7 +33,9 @@ Config = 'Thread Hiding Link': [true, 'Add a link to hide entire threads.'] 'Reply Hiding Link': [true, 'Add a link to hide single replies.'] 'Delete Link': [true, 'Add post and image deletion links to the menu.'] - 'Download Link': [true, 'Add a download with original filename link to the menu. Chrome-only currently.'] + <% if (type === 'crx') { %> + 'Download Link': [true, 'Add a download with original filename link to the menu.'] + <% } %> 'Archive Link': [true, 'Add an archive link to the menu.'] 'Monitoring': 'Thread Updater': [true, 'Fetch and insert new replies. Has more options in its own dialog.'] diff --git a/src/features.coffee b/src/features.coffee index fbc45b7ed..a895da9e9 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -1737,15 +1737,8 @@ DeleteLink = DownloadLink = init: -> - <% if (type === 'userscript') { %> - # Firefox won't let us download cross-domain content. - return - <% } %> return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Download Link'] - # Test for download feature support. - return unless 'download' of $.el 'a' - a = $.el 'a', className: 'download-link' textContent: 'Download file' diff --git a/src/qr.coffee b/src/qr.coffee index 54d8c5447..575e1653f 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -791,7 +791,7 @@ QR = QR.mimeTypes = mimeTypes.split ', ' # Add empty mimeType to avoid errors with URLs selected in Window's file dialog. QR.mimeTypes.push '' - nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value + nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value <% if (type !== 'userjs') { %> # Opera's accept attribute is fucked up nodes.fileInput.accept = "text/*, #{mimeTypes}" @@ -826,8 +826,8 @@ QR = $.on elm, 'blur', QR.focusout $.on elm, 'focus', QR.focusin <% } %> - $.on QR.nodes.el, 'focusin', QR.focusin - $.on QR.nodes.el, 'focusout', QR.focusout + $.on dialog, 'focusin', QR.focusin + $.on dialog, 'focusout', QR.focusout for node in [nodes.fileButton, nodes.filename.parentNode] $.on node, 'click', QR.openFileInput $.on nodes.autohide, 'change', QR.toggleHide From a30243622e1d7fecd2efbce8e38527984e686722 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Apr 2013 16:11:46 +0200 Subject: [PATCH 05/19] Fix #1044. --- src/features.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features.coffee b/src/features.coffee index a895da9e9..5135fc4c1 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -1288,7 +1288,7 @@ ThreadHiding = ThreadHiding.saveHiddenState thread hide: (thread, makeStub=Conf['Stubs']) -> - return if thread.hidden + return if thread.isHidden {OP} = thread threadRoot = OP.nodes.root.parentNode threadRoot.hidden = thread.isHidden = true From 55e1ee09ca54ce8cb982c9a5ef898e3d72a841ca Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Apr 2013 17:45:29 +0200 Subject: [PATCH 06/19] Use vh and vw units for images in quote previews when possible. --- css/style.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/css/style.css b/css/style.css index aefedc2c3..55706ff94 100644 --- a/css/style.css +++ b/css/style.css @@ -485,6 +485,8 @@ a.hide-announcement { #qp img { max-height: 300px; max-width: 500px; + max-height: 80vh; + max-width: 50vw; } .qphl { outline: 2px solid rgba(216, 94, 49, .7); From 382346f6de81556a9b205290610997db2033c73b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Apr 2013 22:48:35 +0200 Subject: [PATCH 07/19] Simpler CSS to center the settings dialog. --- css/style.css | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/css/style.css b/css/style.css index 55706ff94..3692870f4 100644 --- a/css/style.css +++ b/css/style.css @@ -260,10 +260,6 @@ a[href="javascript:;"] { background-color: rgba(0, 0, 0, .5); display: -webkit-flex; display: flex; - -webkit-align-items: center; - align-items: center; - -webkit-justify-content: center; - justify-content: center; position: fixed; top: 0; left: 0; @@ -280,6 +276,7 @@ a[href="javascript:;"] { width: 900px; min-width: 0; max-width: 100%; + margin: auto; padding: 3px; display: -webkit-flex; display: flex; From f93b2dcbd571e3f005442b7b1d99c4bc8eb9427f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Apr 2013 23:10:52 +0200 Subject: [PATCH 08/19] Fix #1048. --- src/features.coffee | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/features.coffee b/src/features.coffee index 5135fc4c1..a95713cf9 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -2421,6 +2421,8 @@ Get = OP.info.comment.replace(/\n+/g, ' // ') or Conf['Anonymize'] and 'Anonymous' or $('.nameBlock', OP.nodes.info).textContent.trim() + if excerpt.length > 70 + excerpt = "#{excerpt[...67]}..." "/#{thread.board}/ - #{excerpt}" postFromRoot: (root) -> link = $ 'a[title="Highlight this post"]', root @@ -3727,10 +3729,7 @@ ThreadExcerpt = name: 'Thread Excerpt' cb: @node node: -> - d.title = if (excerpt = Get.threadExcerpt @).length > 80 - "#{excerpt[...77]}..." - else - excerpt + d.title = Get.threadExcerpt @ Unread = init: -> From b68939772b85279b02bfa07f8caba6aa9e49fe1e Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 02:19:35 +0200 Subject: [PATCH 09/19] No need to recreate the span each time. --- src/features.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/features.coffee b/src/features.coffee index a95713cf9..4a4bfb427 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -790,6 +790,7 @@ PSAHiding = PSAHiding.btn = btn = $.el 'a', title: 'Toggle announcement.' + innerHTML: '' href: 'javascript:;' $.on btn, 'click', PSAHiding.toggle @@ -816,10 +817,10 @@ PSAHiding = sync: (hiddenPSAs) -> {btn} = PSAHiding psa = $.id 'globalMessage' - [psa.hidden, btn.innerHTML, btn.className] = if PSAHiding.trim(psa) in hiddenPSAs - [true, '[ + ]', 'show-announcement'] + [psa.hidden, btn.firstChild.textContent, btn.className] = if PSAHiding.trim(psa) in hiddenPSAs + [true, '[\u00A0+\u00A0]', 'show-announcement'] else - [false, '[ - ]', 'hide-announcement'] + [false, '[\u00A0-\u00A0]', 'hide-announcement'] trim: (psa) -> psa.textContent.replace(/\W+/g, '').toLowerCase() From d1248421bc6c244b6d0b57bdf199eede76a1d939 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 16:07:58 +0200 Subject: [PATCH 10/19] Thought I'd update the contributing guidelines. --- CONTRIBUTING.md | 9 ++++++++- src/features.coffee | 5 ++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 685ca0727..460cfb6db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,6 @@ -## Reporting bugs +## Reporting bugs and suggestions +Reporting bugs: 1. Make sure both your **browser** and **4chan X** are up to date. 2. Disable your other extensions & scripts to identify conflicts. 3. If your issue persists, open a [new issue](https://github.com/MayhemYDG/4chan-x/issues) with the following information: @@ -13,6 +14,12 @@ Open your console with: - `Ctrl + Shift + K` on Firefox. - `Ctrl + Shift + O` on Opera. +Respect these guidelines: +- Describe the issue clearly, put some effort into it. A one-liner isn't a good enough description. +- If you to get your suggestion implemented sooner, make it convincing. +- If you want to criticize, make it convincing and constructive. +- Be mature. Act like an idiot and you will be blocked without warning. + ## Development & Contribution ### Get started diff --git a/src/features.coffee b/src/features.coffee index 4a4bfb427..f731c64bf 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -299,7 +299,7 @@ Settings = @@ -804,8 +804,7 @@ PSAHiding = toggle: (e) -> hide = $.hasClass @, 'hide-announcement' text = PSAHiding.trim $.id 'globalMessage' - $.get 'hiddenPSAs', [], (item) -> - {hiddenPSAs} = item + $.get 'hiddenPSAs', [], ({hiddenPSAs}) -> if hide hiddenPSAs.push text else From 8d53abbbfd9eab14145b735c5dab7756cd577bb5 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 16:14:35 +0200 Subject: [PATCH 11/19] This needs a newline. --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 460cfb6db..39602ae45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ ## Reporting bugs and suggestions Reporting bugs: + 1. Make sure both your **browser** and **4chan X** are up to date. 2. Disable your other extensions & scripts to identify conflicts. 3. If your issue persists, open a [new issue](https://github.com/MayhemYDG/4chan-x/issues) with the following information: From c4a81c7939ca03c3900b4a86005cad489654ed03 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 16:15:15 +0200 Subject: [PATCH 12/19] +want --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 39602ae45..5e386b1ee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ Open your console with: Respect these guidelines: - Describe the issue clearly, put some effort into it. A one-liner isn't a good enough description. -- If you to get your suggestion implemented sooner, make it convincing. +- If you want to get your suggestion implemented sooner, make it convincing. - If you want to criticize, make it convincing and constructive. - Be mature. Act like an idiot and you will be blocked without warning. From a6dc7262fc05eef785bf86bcae553353f5ce364b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 19:19:54 +0200 Subject: [PATCH 13/19] Scroll to unread posts on window load instead of dom load. --- src/features.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/features.coffee b/src/features.coffee index f731c64bf..212b921c5 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -3759,8 +3759,9 @@ Unread = $.on d, 'ThreadUpdate', Unread.onUpdate $.on d, 'scroll visibilitychange', Unread.read $.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line'] + $.on window, 'load', Unread.scroll if Conf['Scroll to Last Read Post'] - return unless Conf['Scroll to Last Read Post'] + scroll: -> # Let the header's onload callback handle it. return if (hash = location.hash.match /\d+/) and hash[0] of @posts if Unread.posts.length From c9f1a4b6d9222c3d11a11b1b0cdbb098ee5c52c1 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 21:40:23 +0200 Subject: [PATCH 14/19] Close #1045. --- CHANGELOG.md | 2 ++ src/config.coffee | 1 + src/features.coffee | 5 +---- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81fb35c70..b25e5ed4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Added the option `Hide Unread Count at (0)`, disabled by default. + ### 3.1.4 - *2013-04-17* - Fix QR remembering the file spoiler state when it shouldn't, for real this time. diff --git a/src/config.coffee b/src/config.coffee index 1be799305..b59267a25 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -40,6 +40,7 @@ Config = 'Monitoring': 'Thread Updater': [true, 'Fetch and insert new replies. Has more options in its own dialog.'] 'Unread Count': [true, 'Show the unread posts count in the tab title.'] + 'Hide Unread Count at (0)': [false, 'Hide the unread posts count when it reaches 0.'] 'Unread Tab Icon': [true, 'Show a different favicon when there are unread posts.'] 'Unread Line': [true, 'Show a line to distinguish read posts from unread ones.'] 'Scroll to Last Read Post': [true, 'Scroll back to the last read post when reopening a thread.'] diff --git a/src/features.coffee b/src/features.coffee index 212b921c5..fb332c691 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -3865,10 +3865,7 @@ Unread = count = Unread.posts.length if Conf['Unread Count'] - d.title = if g.DEAD - "(#{Unread.posts.length}) /#{g.BOARD}/ - 404" - else - "(#{Unread.posts.length}) #{Unread.title}" + d.title = "#{if count or !Conf['Hide Unread Count at (0)'] then "(#{count}) " else ''}#{if g.DEAD then "/#{g.BOARD}/ - 404" else "#{Unread.title}"}" <% if (type === 'crx') { %> # XXX Chrome bug where it doesn't always update the tab title. # crbug.com/124381 From c99fe351e6101669afd48b3e4b8a899629b54e73 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 22:27:19 +0200 Subject: [PATCH 15/19] Don't hide the copyright notice or whatever's at the bottom if you use bottom header. --- css/style.css | 11 ++++++++--- src/features.coffee | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/css/style.css b/css/style.css index 3692870f4..6993399d2 100644 --- a/css/style.css +++ b/css/style.css @@ -93,11 +93,12 @@ a[href="javascript:;"] { } /* Header */ -.fourchan-x body { - -moz-box-sizing: border-box; - box-sizing: border-box; +:root.top-header body { margin-top: 2em; } +:root.bottom-header body { + margin-bottom: 2em; +} .fourchan-x #boardNavDesktop, .fourchan-x #navtopright, .fourchan-x #boardNavDesktopFoot { @@ -256,6 +257,10 @@ a[href="javascript:;"] { } /* Settings */ +:root.fourchan-x body { + -moz-box-sizing: border-box; + box-sizing: border-box; +} #overlay { background-color: rgba(0, 0, 0, .5); display: -webkit-flex; diff --git a/src/features.coffee b/src/features.coffee index fb332c691..3fc1044c0 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -146,6 +146,12 @@ Header = setBarPosition: (bottom) -> $.event 'CloseMenu' + if bottom + $.addClass doc, 'bottom-header' + $.rmClass doc, 'top-header' + else + $.addClass doc, 'top-header' + $.rmClass doc, 'bottom-header' Header.positionToggler.firstElementChild.checked = bottom Header.bar.parentNode.className = if bottom 'bottom' From 7575b72b95b21b620c12fc6117197e32b1b4ec5f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 23:17:25 +0200 Subject: [PATCH 16/19] Update deps. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7ab48ab5d..23fb3d107 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,10 @@ }, "devDependencies": { "grunt": "~0.4.1", - "grunt-bump": "~0.0.0", - "grunt-concurrent": "~0.1.1", + "grunt-bump": "~0.0.2", + "grunt-concurrent": "~0.2.0", "grunt-contrib-clean": "~0.4.1", - "grunt-contrib-coffee": "~0.6.6", + "grunt-contrib-coffee": "~0.6.7", "grunt-contrib-compress": "~0.4.10", "grunt-contrib-concat": "~0.2.0", "grunt-contrib-copy": "~0.4.1", From 46549862a2f49d721fabe8631ef402380c464355 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 18 Apr 2013 23:35:12 +0200 Subject: [PATCH 17/19] Use grunt-shell instead of grunt-exec. --- Gruntfile.js | 32 +++++++++++++++++--------------- package.json | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 84468860b..6b0a847b4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,6 +6,11 @@ module.exports = function(grunt) { data: pkg } }; + var shellOptions = { + stdout: true, + stderr: true, + failOnError: true + }; // Project configuration. grunt.initConfig({ @@ -75,22 +80,19 @@ module.exports = function(grunt) { concurrent: { build: ['build-crx', 'build-userjs', 'build-userscript'] }, - exec: { + shell: { commit: { - command: function() { - var release = pkg.meta.name + ' v' + pkg.version; - return [ - 'git checkout ' + pkg.meta.mainBranch, - 'git commit -am "Release ' + release + '."', - 'git tag -a ' + pkg.version + ' -m "' + release + '."', - 'git tag -af stable-v3 -m "' + release + '."' - ].join(' && '); - }, - stdout: true + options: shellOptions, + command: [ + 'git checkout <%= pkg.meta.mainBranch %>', + 'git commit -am "Release <%= pkg.meta.name %> v<%= pkg.version %>."', + 'git tag -a <%= pkg.version %> -m "<%= pkg.meta.name %> v<%= pkg.version %>."', + 'git tag -af stable-v3 -m "<%= pkg.meta.name %> v<%= pkg.version %>."' + ].join(' && ') }, push: { - command: 'git push origin --tags -f && git push origin --all', - stdout: true + options: shellOptions, + command: 'git push origin --tags -f && git push origin --all' } }, watch: { @@ -139,7 +141,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-exec'); + grunt.loadNpmTasks('grunt-shell'); grunt.registerTask('default', ['build']); @@ -171,7 +173,7 @@ module.exports = function(grunt) { 'clean:tmpuserscript' ]); - grunt.registerTask('release', ['exec:commit', 'exec:push', 'build-crx', 'compress:crx']); + grunt.registerTask('release', ['shell:commit', 'shell:push', 'build-crx', 'compress:crx']); grunt.registerTask('patch', ['bump', 'reloadPkg', 'updcl:3', 'release']); grunt.registerTask('minor', ['bump:minor', 'reloadPkg', 'updcl:2', 'release']); grunt.registerTask('major', ['bump:major', 'reloadPkg', 'updcl:1', 'release']); diff --git a/package.json b/package.json index 23fb3d107..246d3913a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "grunt-contrib-concat": "~0.2.0", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-watch": "~0.3.1", - "grunt-exec": "~0.4.0" + "grunt-shell": "~0.2.2" }, "repository": { "type": "git", From 4207ae31c0340a873fe13a1917c82b3494540079 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 19 Apr 2013 00:32:08 +0200 Subject: [PATCH 18/19] Add archive redirection to 4plebs. --- src/features.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/features.coffee b/src/features.coffee index 3fc1044c0..1633fdc41 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -2094,6 +2094,8 @@ Redirect = "//nsfw.foolz.us/#{boardID}/full_image/#{filename}" when 'po' "//archive.thedarkcave.org/#{boardID}/full_image/#{filename}" + when 'hr', 'tv' + "http://archive.4plebs.org/#{boardID}/full_image/#{filename}" when 'ck', 'fa', 'lit', 's4s' "//fuuka.warosu.org/#{boardID}/full_image/#{filename}" when 'cgl', 'g', 'mu', 'w' @@ -2112,6 +2114,8 @@ Redirect = "https://nsfw.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}" when 'c', 'int', 'out', 'po' "//archive.thedarkcave.org/_/api/chan/post/?board=#{boardID}&num=#{postID}" + when 'hr', 'x' + "http://archive.4plebs.org/_/api/chan/post/?board=#{boardID}&num=#{postID}" # for fuuka-based archives: # https://github.com/eksopl/fuuka/issues/27 to: (data) -> @@ -2123,6 +2127,8 @@ Redirect = Redirect.path '//nsfw.foolz.us', 'foolfuuka', data when 'int', 'out', 'po' Redirect.path '//archive.thedarkcave.org', 'foolfuuka', data + when 'hr' + Redirect.path 'http://archive.4plebs.org', 'foolfuuka', data when 'ck', 'fa', 'lit', 's4s' Redirect.path '//fuuka.warosu.org', 'fuuka', data when 'diy', 'g', 'sci' From 2e9ae1d9da97d0bfe4a0b7d30f2c1f529f4cc804 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 19 Apr 2013 04:32:29 +0200 Subject: [PATCH 19/19] Group Header options into the Header sub-menu. --- Gruntfile.js | 3 +- src/features.coffee | 110 ++++++++++++++++++++++---------------------- 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6b0a847b4..e40c4d9d9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -98,8 +98,7 @@ module.exports = function(grunt) { watch: { all: { options: { - interrupt: true, - nospawn: true + interrupt: true }, files: [ 'Gruntfile.js', diff --git a/src/features.coffee b/src/features.coffee index 1633fdc41..822325e8a 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -15,46 +15,45 @@ Header =
""".replace />\s+<' # get rid of spaces between elements - @bar = $ '#header-bar', headerEl + @bar = $ '#header-bar', headerEl @toggle = $ '#toggle-header-bar', @bar @menu = new UI.Menu 'header' $.on $('.menu-button', @bar), 'click', @menuToggle $.on @toggle, 'mousedown', @toggleBarVisibility $.on window, 'load hashchange', Header.hashScroll + $.on d, 'CreateNotification', @createNotification catalogToggler = $.el 'label', - innerHTML: " Use catalog board links" - $.on catalogToggler.firstElementChild, 'change', @toggleCatalogLinks - $.sync 'Header catalog links', @setCatalogLinks - $.event 'AddMenuEntry', - type: 'header' - el: catalogToggler - order: 50 + innerHTML: ' Use catalog board links' + headerToggler = $.el 'label', + innerHTML: ' Auto-hide header' + barPositionToggler = $.el 'label', + innerHTML: ' Bottom header' - @positionToggler = $.el 'label', - innerHTML: " Bottom header" - $.on @positionToggler.firstElementChild, 'change', @toggleBarPosition - $.event 'AddMenuEntry', - type: 'header' - el: @positionToggler - order: 108 + @catalogToggler = catalogToggler.firstElementChild + @headerToggler = headerToggler.firstElementChild + @barPositionToggler = barPositionToggler.firstElementChild - @setBarPosition Conf['Bottom header'] - $.sync 'Bottom header', @setBarPosition - - @headerToggler = $.el 'label', - innerHTML: " Auto-hide header" - $.on @headerToggler.firstElementChild, 'change', @toggleBarVisibility - $.event 'AddMenuEntry', - type: 'header' - el: @headerToggler - order: 109 + $.on @catalogToggler, 'change', @toggleCatalogLinks + $.on @headerToggler, 'change', @toggleBarVisibility + $.on @barPositionToggler, 'change', @toggleBarPosition @setBarVisibility Conf['Header auto-hide'] - $.sync 'Header auto-hide', @setBarVisibility + @setBarPosition Conf['Bottom header'] - $.on d, 'CreateNotification', @createNotification + $.sync 'Header auto-hide', @setBarVisibility + $.sync 'Bottom header', @setBarPosition + + $.event 'AddMenuEntry', + type: 'header' + el: $.el 'span', textContent: 'Header' + order: 105 + subEntries: [ + {el: catalogToggler} + {el: headerToggler} + {el: barPositionToggler} + ] $.asap (-> d.body), -> return unless Main.isThisPageLegit() @@ -83,6 +82,7 @@ Header = fullBoardList.hidden = false Header.setCatalogLinks Conf['Header catalog links'] + $.sync 'Header catalog links', Header.setCatalogLinks generateBoardList: (text) -> unless list = $ '#custom-board-list', Header.bar @@ -134,38 +134,51 @@ Header = full.hidden = showBoardList setCatalogLinks: (useCatalog) -> + Header.catalogToggler.checked = useCatalog as = $$ '#board-list a[href*="boards.4chan.org"]', Header.bar - str = if useCatalog then 'catalog' else '' + path = if useCatalog then 'catalog' else '' for a in as continue if a.dataset.only - a.pathname = "/#{a.pathname.split('/')[1]}/#{str}" + a.pathname = "/#{a.pathname.split('/')[1]}/#{path}" return toggleCatalogLinks: -> + $.cb.checked.call @ Header.setCatalogLinks @checked - $.set 'Header catalog links', @checked + + setBarVisibility: (hide) -> + Header.headerToggler.checked = hide + $.event 'CloseMenu' + (if hide then $.addClass else $.rmClass) Header.bar, 'autohide' + toggleBarVisibility: (e) -> + return if e.type is 'mousedown' and e.button isnt 0 # not LMB + hide = if @nodeName is 'INPUT' + @checked + else + !$.hasClass Header.bar, 'autohide' + Conf['Header auto-hide'] = hide + $.set 'Header auto-hide', hide + Header.setBarVisibility hide + message = if hide + 'The header bar will automatically hide itself.' + else + 'The header bar will remain visible.' + new Notification 'info', message, 2 setBarPosition: (bottom) -> + Header.barPositionToggler.checked = bottom $.event 'CloseMenu' if bottom $.addClass doc, 'bottom-header' $.rmClass doc, 'top-header' + Header.bar.parentNode.className = 'bottom' else $.addClass doc, 'top-header' $.rmClass doc, 'bottom-header' - Header.positionToggler.firstElementChild.checked = bottom - Header.bar.parentNode.className = if bottom - 'bottom' - else - 'top' + Header.bar.parentNode.className = 'top' toggleBarPosition: -> - bottom = @checked - Header.setBarPosition bottom - Conf['Bottom header'] = bottom - $.set 'Bottom header', bottom + $.cb.checked.call @ + Header.setBarPosition @checked - setBarVisibility: (hide) -> - Header.headerToggler.firstElementChild.checked = hide - (if hide then $.addClass else $.rmClass) Header.bar, 'autohide' hashScroll: -> return unless post = $.id @location.hash[1..] return if (Get.postFromRoot post).isHidden @@ -176,19 +189,6 @@ Header = headRect = Header.toggle.getBoundingClientRect() top += - headRect.top - headRect.height <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop += top - toggleBarVisibility: (e) -> - return if e.type is 'mousedown' and e.button isnt 0 # not LMB - hide = if @nodeName is 'INPUT' - @checked - else - !$.hasClass Header.bar, 'autohide' - Header.setBarVisibility hide - message = if hide - 'The header bar will automatically hide itself.' - else - 'The header bar will remain visible.' - new Notification 'info', message, 2 - $.set 'Header auto-hide', hide addShortcut: (el) -> shortcut = $.el 'span',