From 7cacb568fb7efaee1f47d660cdf0ff589d86ab3f Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Fri, 26 Apr 2013 13:58:30 -0700 Subject: [PATCH] use the header as a veiwport border for dialogs. --- builds/4chan-X.js | 6 ++++-- builds/4chan-X.user.js | 6 ++++-- builds/crx/script.js | 6 ++++-- src/lib/ui.coffee | 11 +++++++---- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/builds/4chan-X.js b/builds/4chan-X.js index ad3f00b59..4f7cda08d 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -2113,6 +2113,8 @@ dy: e.clientY - rect.top, height: screenHeight - rect.height, width: screenWidth - rect.width, + topBorder: Conf["Bottom Header"] ? 0 : Header.bar.getBoundingClientRect().height, + bottomBorder: Conf["Bottom Header"] ? Header.bar.getBoundingClientRect().height : 0, screenHeight: screenHeight, screenWidth: screenWidth, isTouching: isTouching @@ -2149,9 +2151,9 @@ left = clientX - this.dx; left = left < 10 ? 0 : this.width - left < 10 ? null : left / this.screenWidth * 100 + '%'; top = clientY - this.dy; - top = top < 10 ? 0 : this.height - top < 10 ? null : top / this.screenHeight * 100 + '%'; + top = top < (10 + this.topBorder) ? this.topBorder + 'px' : this.height - top < (10 + this.bottomBorder) ? null : top / this.screenHeight * 100 + '%'; right = left === null ? 0 : null; - bottom = top === null ? 0 : null; + bottom = top === null ? this.bottomBorder + 'px' : null; style = this.style; style.left = left; style.right = right; diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index a7c15fd35..ae889f517 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -2109,6 +2109,8 @@ dy: e.clientY - rect.top, height: screenHeight - rect.height, width: screenWidth - rect.width, + topBorder: Conf["Bottom Header"] ? 0 : Header.bar.getBoundingClientRect().height, + bottomBorder: Conf["Bottom Header"] ? Header.bar.getBoundingClientRect().height : 0, screenHeight: screenHeight, screenWidth: screenWidth, isTouching: isTouching @@ -2145,9 +2147,9 @@ left = clientX - this.dx; left = left < 10 ? 0 : this.width - left < 10 ? null : left / this.screenWidth * 100 + '%'; top = clientY - this.dy; - top = top < 10 ? 0 : this.height - top < 10 ? null : top / this.screenHeight * 100 + '%'; + top = top < (10 + this.topBorder) ? this.topBorder + 'px' : this.height - top < (10 + this.bottomBorder) ? null : top / this.screenHeight * 100 + '%'; right = left === null ? 0 : null; - bottom = top === null ? 0 : null; + bottom = top === null ? this.bottomBorder + 'px' : null; style = this.style; style.left = left; style.right = right; diff --git a/builds/crx/script.js b/builds/crx/script.js index d8dca89f7..2aee518ff 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -2022,6 +2022,8 @@ dy: e.clientY - rect.top, height: screenHeight - rect.height, width: screenWidth - rect.width, + topBorder: Conf["Bottom Header"] ? 0 : Header.bar.getBoundingClientRect().height, + bottomBorder: Conf["Bottom Header"] ? Header.bar.getBoundingClientRect().height : 0, screenHeight: screenHeight, screenWidth: screenWidth, isTouching: isTouching @@ -2058,9 +2060,9 @@ left = clientX - this.dx; left = left < 10 ? 0 : this.width - left < 10 ? null : left / this.screenWidth * 100 + '%'; top = clientY - this.dy; - top = top < 10 ? 0 : this.height - top < 10 ? null : top / this.screenHeight * 100 + '%'; + top = top < (10 + this.topBorder) ? this.topBorder + 'px' : this.height - top < (10 + this.bottomBorder) ? null : top / this.screenHeight * 100 + '%'; right = left === null ? 0 : null; - bottom = top === null ? 0 : null; + bottom = top === null ? this.bottomBorder + 'px' : null; style = this.style; style.left = left; style.right = right; diff --git a/src/lib/ui.coffee b/src/lib/ui.coffee index b2fff3393..aa4ef9f5f 100644 --- a/src/lib/ui.coffee +++ b/src/lib/ui.coffee @@ -222,6 +222,8 @@ UI = do -> dy: e.clientY - rect.top height: screenHeight - rect.height width: screenWidth - rect.width + topBorder: if Conf["Bottom Header"] then 0 else Header.bar.getBoundingClientRect().height + bottomBorder: if Conf["Bottom Header"] then Header.bar.getBoundingClientRect().height else 0 screenHeight: screenHeight screenWidth: screenWidth isTouching: isTouching @@ -254,9 +256,9 @@ UI = do -> left / @screenWidth * 100 + '%' top = clientY - @dy - top = if top < 10 - 0 - else if @height - top < 10 + top = if top < (10 + @topBorder) + @topBorder + 'px' + else if @height - top < (10 + @bottomBorder) null else top / @screenHeight * 100 + '%' @@ -265,8 +267,9 @@ UI = do -> 0 else null + bottom = if top is null - 0 + @bottomBorder + 'px' else null