From cd89d9318910fe7b2a7193172d1956a57fa82dba Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 8 Apr 2013 21:10:43 +0200 Subject: [PATCH 1/9] Move the qphl class back to the post instead of the postContainer. It's the source of performance issues when quote previewing in large threads. --- css/style.css | 2 +- src/features.coffee | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/css/style.css b/css/style.css index 11fbebef1..583de63cb 100644 --- a/css/style.css +++ b/css/style.css @@ -432,7 +432,7 @@ a[href="javascript:;"] { max-height: 300px; max-width: 500px; } -.qphl > .post { +.qphl { outline: 2px solid rgba(216, 94, 49, .7); } diff --git a/src/features.coffee b/src/features.coffee index a0c93c28a..ea30e7b67 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -2728,7 +2728,7 @@ QuotePreview = # Remove the clone that's in the qp from the array. posts.pop() for post in posts - $.addClass post.nodes.root, 'qphl' + $.addClass post.nodes.post, 'qphl' quoterID = $.x('ancestor::*[@id][1]', @).id.match(/\d+$/)[0] clone = Get.postFromRoot qp.firstChild @@ -2746,7 +2746,7 @@ QuotePreview = return unless Conf['Quote Highlighting'] for post in [post].concat post.clones - $.rmClass post.nodes.root, 'qphl' + $.rmClass post.nodes.post, 'qphl' return QuoteBacklink = From 661f969de1b647bee088ce962f05930fe323c11c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 8 Apr 2013 23:25:44 +0200 Subject: [PATCH 2/9] Close #992. --- CHANGELOG.md | 1 + src/features.coffee | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 463426d76..1a8d67678 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- Fixed the Header going above posts when following quotelinks for example. - Fixed a bug where dead quotelinks would disappear. ### 3.0.1 - *2013-04-08* diff --git a/src/features.coffee b/src/features.coffee index ea30e7b67..f39ac2b55 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -21,6 +21,7 @@ Header = @menu = new UI.Menu 'header' $.on $('.menu-button', @bar), 'click', @menuToggle $.on @toggle, 'mousedown', @toggleBarVisibility + $.on window, 'hashchange', Header.hashScroll catalogToggler = $.el 'label', innerHTML: " Use catalog board links" @@ -131,6 +132,12 @@ Header = setBarVisibility: (hide) -> Header.headerToggler.firstElementChild.checked = hide (if hide then $.addClass else $.rmClass) Header.bar, 'autohide' + hashScroll: -> + return unless post = $.id @location.hash[1..] + postRect = post.getBoundingClientRect() + headRect = Header.toggle.getBoundingClientRect() + root = if $.engine is 'webkit' then d.body else doc + root.scrollTop += postRect.top - headRect.top - headRect.height toggleBarVisibility: (e) -> return if e.type is 'mousedown' and e.button isnt 0 # not LMB hide = if @nodeName is 'INPUT' From 2263b02b651bdca014b4ae5a8dd7098a8ded6313 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 9 Apr 2013 08:54:41 +0200 Subject: [PATCH 3/9] Fix #999 --- src/features.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features.coffee b/src/features.coffee index f39ac2b55..e3cd4dbd4 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -3456,7 +3456,7 @@ ExpandComment = post = Get.postFromNode @ ExpandComment.expand post expand: (post) -> - if post.nodes.longComment + if post.nodes.longComment and !post.nodes.longComment.parentNode $.replace post.nodes.shortComment, post.nodes.longComment post.nodes.comment = post.nodes.longComment return From 33d154c8c8f3de1b13695ba095eb7b31d4e92baa Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 9 Apr 2013 08:58:13 +0200 Subject: [PATCH 4/9] Close #994 --- css/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/css/style.css b/css/style.css index 583de63cb..e33e11f5c 100644 --- a/css/style.css +++ b/css/style.css @@ -6,6 +6,7 @@ padding: 0; } .field { + background-color: #FFF; border: 1px solid #CCC; -moz-box-sizing: border-box; box-sizing: border-box; From fe2f4d4c0a7ba8286902b7c3a0242bae93615611 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 9 Apr 2013 09:05:30 +0200 Subject: [PATCH 5/9] Close #990 --- CHANGELOG.md | 1 + src/config.coffee | 1 + src/qr.coffee | 3 +++ 3 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a8d67678..482ad9b78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- Added Cooldown setting back in. - Fixed the Header going above posts when following quotelinks for example. - Fixed a bug where dead quotelinks would disappear. diff --git a/src/config.coffee b/src/config.coffee index 6e9294292..402fed7be 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -52,6 +52,7 @@ Config = 'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.'] 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'] 'Hide Original Post Form': [true, 'Hide the normal post form.'] + 'Cooldown': [true, 'Prevent "flood detected" errors.'] 'Quote Links': 'Quote Backlinks': [true, 'Add quote backlinks.'] 'OP Backlinks': [true, 'Add backlinks to the OP.'] diff --git a/src/qr.coffee b/src/qr.coffee index 15fc6ca6e..aa1f79318 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -128,6 +128,7 @@ QR = cooldown: init: -> + return unless Conf['Cooldown'] board = g.BOARD.ID QR.cooldown.types = thread: switch board @@ -144,6 +145,7 @@ QR = QR.cooldown.start() $.sync "cooldown.#{board}", QR.cooldown.sync start: -> + return unless Conf['Cooldown'] return if QR.cooldown.isCounting QR.cooldown.isCounting = true QR.cooldown.count() @@ -154,6 +156,7 @@ QR = QR.cooldown.cooldowns[id] = cooldowns[id] QR.cooldown.start() set: (data) -> + return unless Conf['Cooldown'] {req, post, isReply, delay} = data start = if req then req.uploadEndTime else Date.now() if delay From d64159592267955f36772ea5b5bc221023df9171 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 9 Apr 2013 11:40:46 +0200 Subject: [PATCH 6/9] Add a setting to move the header to the bottom of the screen. --- CHANGELOG.md | 1 + css/style.css | 61 +++++++++++++++++++++++++++++++++++++------ src/config.coffee | 1 + src/features.coffee | 63 +++++++++++++++++++++++++++++++++++---------- 4 files changed, 104 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 482ad9b78..9623e5eb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- Added an setting in the Header's menu to move it at the bottom of the screen. - Added Cooldown setting back in. - Fixed the Header going above posts when following quotelinks for example. - Fixed a bug where dead quotelinks would disappear. diff --git a/css/style.css b/css/style.css index e33e11f5c..a729961c2 100644 --- a/css/style.css +++ b/css/style.css @@ -104,18 +104,34 @@ a[href="javascript:;"] { display: none !important; } #header { - top: 0; right: 0; left: 0; } +#header.top { + top: 0; +} +#header.bottom { + bottom: 0; +} #header-bar { - border-width: 0 0 1px; + border-width: 0; display: -webkit-flex; display: flex; padding: 3px 4px 4px; position: relative; transition: all .1s .05s ease-in-out; } +#header.top #header-bar { + border-bottom-width: 1px; +} +#header.bottom #header-bar { + box-shadow: 0 -1px 2px rgba(0, 0, 0, .15); + border-top-width: 1px; +} +#header.bottom .menu-button i { + border-top: none; + border-bottom: 6px solid; +} #board-list { -webkit-flex: 1; flex: 1; @@ -123,26 +139,49 @@ a[href="javascript:;"] { } #header-bar.autohide:not(:hover) { box-shadow: none; + transition: all .8s .6s cubic-bezier(.55, .055, .675, .19); +} +#header.top #header-bar.autohide:not(:hover) { margin-bottom: -1em; -webkit-transform: translateY(-100%); transform: translateY(-100%); - transition: all .8s .6s cubic-bezier(.55, .055, .675, .19); +} +#header.bottom #header-bar.autohide:not(:hover) { + -webkit-transform: translateY(100%); + transform: translateY(100%); } #toggle-header-bar { - cursor: n-resize; left: 0; right: 0; - bottom: -8px; height: 10px; position: absolute; } -#header-bar.autohide:not(:hover) #toggle-header-bar, #toggle-header-bar:hover { - bottom: -16px; +#header.top #toggle-header-bar { + cursor: n-resize; + bottom: -8px; +} +#header.bottom #toggle-header-bar { + cursor: s-resize; + top: -8px; +} +#header-bar.autohide:not(:hover) #toggle-header-bar, +#toggle-header-bar:hover { height: 18px; } -#header-bar.autohide #toggle-header-bar { +#header.top #header-bar.autohide:not(:hover) #toggle-header-bar, +#header.top #toggle-header-bar:hover { + bottom: -16px; +} +#header.bottom #header-bar.autohide:not(:hover) #toggle-header-bar, +#header.bottom #toggle-header-bar:hover { + top: -16px; +} +#header.top #header-bar.autohide #toggle-header-bar { cursor: s-resize; } +#header.bottom #header-bar.autohide #toggle-header-bar { + cursor: n-resize; +} #header-bar a:not(.entry) { text-decoration: none; padding: 1px; @@ -168,6 +207,12 @@ a[href="javascript:;"] { height: 0; text-align: center; } +#header.bottom #notifications { + position: fixed; + top: 0; + left: 0; + width: 100%; +} .notification { color: #FFF; font-weight: 700; diff --git a/src/config.coffee b/src/config.coffee index 402fed7be..f5b799b59 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -132,6 +132,7 @@ Config = '#//archive.installgentoo.net/%board/image/%MD5;text:View same on installgentoo /%board/' ].join '\n' 'Custom CSS': false + 'Bottom header': false 'Header auto-hide': false 'Header catalog links': false boardnav: '[current-title / toggle-all]' diff --git a/src/features.coffee b/src/features.coffee index e3cd4dbd4..d0dbb2805 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -21,7 +21,7 @@ Header = @menu = new UI.Menu 'header' $.on $('.menu-button', @bar), 'click', @menuToggle $.on @toggle, 'mousedown', @toggleBarVisibility - $.on window, 'hashchange', Header.hashScroll + $.on window, 'load hashchange', Header.hashScroll catalogToggler = $.el 'label', innerHTML: " Use catalog board links" @@ -32,6 +32,17 @@ Header = el: catalogToggler order: 50 + @positionToggler = $.el 'label', + innerHTML: " Bottom header" + $.on @positionToggler.firstElementChild, 'change', @toggleBarPosition + $.event 'AddMenuEntry', + type: 'header' + el: @positionToggler + order: 108 + + @setBarPosition Conf['Bottom header'] + $.sync 'Bottom header', @setBarPosition + @headerToggler = $.el 'label', innerHTML: " Auto-hide header" $.on @headerToggler.firstElementChild, 'change', @toggleBarVisibility @@ -129,15 +140,31 @@ Header = Header.setCatalogLinks @checked $.set 'Header catalog links', @checked + setBarPosition: (bottom) -> + $.event 'CloseMenu' + Header.positionToggler.firstElementChild.checked = bottom + Header.bar.parentNode.className = if bottom + 'bottom' + else + 'top' + toggleBarPosition: -> + bottom = @checked + Header.setBarPosition bottom + Conf['Bottom header'] = bottom + $.set 'Bottom header', bottom + setBarVisibility: (hide) -> Header.headerToggler.firstElementChild.checked = hide (if hide then $.addClass else $.rmClass) Header.bar, 'autohide' hashScroll: -> return unless post = $.id @location.hash[1..] - postRect = post.getBoundingClientRect() - headRect = Header.toggle.getBoundingClientRect() - root = if $.engine is 'webkit' then d.body else doc - root.scrollTop += postRect.top - headRect.top - headRect.height + Header.scrollToPost post + scrollToPost: (post) -> + {top} = post.getBoundingClientRect() + unless Conf['Bottom header'] + headRect = Header.toggle.getBoundingClientRect() + top += - headRect.top - headRect.height + (if $.engine is 'webkit' then 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' @@ -1900,8 +1927,11 @@ Keybinds = location.href = url hl: (delta, thread) -> - headRect = Header.bar.getBoundingClientRect() - topMargin = headRect.top + headRect.height + if Conf['Bottom header'] + topMargin = 0 + else + headRect = Header.toggle.getBoundingClientRect() + topMargin = headRect.top + headRect.height if postEl = $ '.reply.highlight', thread $.rmClass postEl, 'highlight' rect = postEl.getBoundingClientRect() @@ -1965,8 +1995,11 @@ Nav = Nav.scroll +1 getThread: (full) -> - headRect = Header.bar.getBoundingClientRect() - topMargin = headRect.top + headRect.height + if Conf['Bottom header'] + topMargin = 0 + else + headRect = Header.toggle.getBoundingClientRect() + topMargin = headRect.top + headRect.height threads = $$ '.thread:not([hidden])' for thread, i in threads rect = thread.getBoundingClientRect() @@ -3242,8 +3275,10 @@ ImageExpand = return unless rect.top <= 0 or rect.left <= 0 # Scroll back to the thumbnail when contracting the image # to avoid being left miles away from the relevant post. - headRect = Header.toggle.getBoundingClientRect() - top = rect.top - headRect.top - headRect.height + {top} = rect + unless Conf['Bottom header'] + headRect = Header.toggle.getBoundingClientRect() + top += - headRect.top - headRect.height root = if $.engine is 'webkit' then d.body else doc root.scrollTop += top if rect.top < 0 root.scrollLeft = 0 if rect.left < 0 @@ -3653,13 +3688,13 @@ Unread = defaultValue: 0 Unread.addPosts posts if (hash = location.hash.match /\d+/) and post = @posts[hash[0]] - post.nodes.root.scrollIntoView() + Header.scrollToPost post.nodes.root else if Unread.posts.length # Scroll to before the first unread post. $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root).scrollIntoView false else if posts.length # Scroll to the last read post. - posts[posts.length - 1].nodes.root.scrollIntoView() + Header.scrollToPost posts[posts.length - 1].nodes.root $.on d, 'ThreadUpdate', Unread.onUpdate $.on d, 'scroll visibilitychange', Unread.read $.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line'] @@ -4143,7 +4178,7 @@ ThreadUpdater = if Conf['Bottom Scroll'] (if $.engine is 'webkit' then d.body else doc).scrollTop = d.body.clientHeight else - nodes[0].scrollIntoView() + Header.scrollToPost nodes[0] $.queueTask -> # Enable 4chan features. From 85af346fd919dd27a98b506fe7f06d237241d4d2 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 9 Apr 2013 11:41:29 +0200 Subject: [PATCH 7/9] Release 4chan X v3.0.2. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9623e5eb8..72c984e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### 3.0.2 - *2013-04-09* + - Added an setting in the Header's menu to move it at the bottom of the screen. - Added Cooldown setting back in. - Fixed the Header going above posts when following quotelinks for example. diff --git a/package.json b/package.json index 6fcb5961b..1877b74e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.0.1", + "version": "3.0.2", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From 50a13f306fe96fa6807aaba13d09fa66ac643b7f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 9 Apr 2013 11:48:34 +0200 Subject: [PATCH 8/9] typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72c984e5d..234582144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ### 3.0.2 - *2013-04-09* -- Added an setting in the Header's menu to move it at the bottom of the screen. +- Added a setting in the Header's menu to move it at the bottom of the screen. - Added Cooldown setting back in. - Fixed the Header going above posts when following quotelinks for example. - Fixed a bug where dead quotelinks would disappear. From 354f566672b2dc8a556c33d6a24c0ec33ee995c8 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 9 Apr 2013 13:45:16 +0200 Subject: [PATCH 9/9] Fix loading image expansion in clones. --- src/features.coffee | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/features.coffee b/src/features.coffee index d0dbb2805..bbdb3e3b2 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -3224,8 +3224,15 @@ ImageExpand = name: 'Image Expansion' cb: @node node: -> - return unless @file and @file.isImage - $.on @file.thumb.parentNode, 'click', ImageExpand.cb.toggle + return unless @file?.isImage + {thumb} = @file + $.on thumb.parentNode, 'click', ImageExpand.cb.toggle + if @isClone and $.hasClass thumb, 'expanding' + # If we clone a post where the image is still loading, + # make it loading in the clone too. + ImageExpand.contract @ + ImageExpand.expand @ + return if ImageExpand.on and !@isHidden ImageExpand.expand @ cb: