aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-03-27 11:56:22 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-03-27 11:56:22 +0100
commit5aa81833f9bd70929985425c2d78628f76fe728e (patch)
tree6101c2ef2d8005581f12ee903485aecb65f3fd9e /core
parent7e73b255335a73128ece5f495a48533e49a79226 (diff)
parent701cb27a9e27e26aa6a4460e5a7e4b713b79eac3 (diff)
downloadnextcloud-server-5aa81833f9bd70929985425c2d78628f76fe728e.tar.gz
nextcloud-server-5aa81833f9bd70929985425c2d78628f76fe728e.zip
Merge pull request #15260 from owncloud/adjust-controls-bar-width
adjust controls bar width to not overlay scrollbar
Diffstat (limited to 'core')
-rw-r--r--core/js/js.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js
index ad14c2a855a..274eddffff7 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1261,6 +1261,33 @@ function initCore() {
// initial call
toggleSnapperOnSize();
+ // adjust controls bar width
+ var adjustControlsWidth = function() {
+ if($('#controls').length) {
+ var controlsWidth;
+ // if there is a scrollbar …
+ if($('#app-content').get(0).scrollHeight > $('#app-content').height()) {
+ if($(window).width() > 768) {
+ controlsWidth = $('#content').width() - $('#app-navigation').width() - getScrollBarWidth();
+ } else {
+ controlsWidth = $('#content').width() - getScrollBarWidth();
+ }
+ } else { // if there is none
+ if($(window).width() > 768) {
+ controlsWidth = $('#content').width() - $('#app-navigation').width();
+ } else {
+ controlsWidth = $('#content').width();
+ }
+ }
+ $('#controls').css('width', controlsWidth);
+ $('#controls').css('min-width', controlsWidth);
+ }
+ };
+
+ $(window).resize(_.debounce(adjustControlsWidth, 250));
+
+ $('body').delegate('#app-content', 'apprendered', adjustControlsWidth);
+
}
}
@@ -1685,3 +1712,31 @@ jQuery.fn.selectRange = function(start, end) {
jQuery.fn.exists = function(){
return this.length > 0;
};
+
+function getScrollBarWidth() {
+ var inner = document.createElement('p');
+ inner.style.width = "100%";
+ inner.style.height = "200px";
+
+ var outer = document.createElement('div');
+ outer.style.position = "absolute";
+ outer.style.top = "0px";
+ outer.style.left = "0px";
+ outer.style.visibility = "hidden";
+ outer.style.width = "200px";
+ outer.style.height = "150px";
+ outer.style.overflow = "hidden";
+ outer.appendChild (inner);
+
+ document.body.appendChild (outer);
+ var w1 = inner.offsetWidth;
+ outer.style.overflow = 'scroll';
+ var w2 = inner.offsetWidth;
+ if(w1 === w2) {
+ w2 = outer.clientWidth;
+ }
+
+ document.body.removeChild (outer);
+
+ return (w1 - w2);
+}