From 017819df00936c78ed314bda7d91ce8e8f0b9eb1 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 19 Aug 2018 09:51:45 +0200 Subject: [PATCH] Fix so Classic skin splitter does not escape out of window (#6397) --- CHANGELOG | 1 + skins/classic/splitter.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e7eb565c7..55d900aed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ CHANGELOG Roundcube Webmail - Fix so fallback from BINARY to BODY FETCH is used also on [PARSE] errors in dovecot 2.3 (#6383) - Enigma: Fix deleting keys with authentication subkeys (#6381) - Fix invalid regular expressions that throw warnings on PHP 7.3 (#6398) +- Fix so Classic skin splitter does not escape out of window (#6397) RELEASE 1.3.7 ------------- diff --git a/skins/classic/splitter.js b/skins/classic/splitter.js index 4117b2c29..460c35a21 100644 --- a/skins/classic/splitter.js +++ b/skins/classic/splitter.js @@ -56,6 +56,9 @@ function rcube_splitter(attrib) // add the mouse event listeners $(this.elm).mousedown(onDragStart); + + // Update splitter position and elements with on window resize + $(window).resize(function(e) { if (e.target === window) me.resize(); }); if (bw.ie) $(window).resize(onResize); @@ -88,9 +91,12 @@ function rcube_splitter(attrib) } } else { - this.p1.style.width = Math.floor(this.pos - this.p1pos.left - this.layer.width / 2) + 'px'; - this.p2.style.left = Math.ceil(this.pos + this.layer.width / 2) + 'px'; - this.layer.move(Math.round(this.pos - this.layer.width / 2 + 1), this.layer.y); + var max_width = $(window).width() - $(this.p1).offset().left - 150, + pos = Math.min(this.pos, max_width); + + this.p1.style.width = Math.floor(pos - this.p1pos.left - this.layer.width / 2) + 'px'; + this.p2.style.left = Math.ceil(pos + this.layer.width / 2) + 'px'; + this.layer.move(Math.round(pos - this.layer.width / 2 + 1), this.layer.y); if (bw.ie) { var new_width = parseInt(this.p2.parentNode.offsetWidth, 10) - parseInt(this.p2.style.left, 10) ; this.p2.style.width = (new_width > 0 ? new_width : 0) + 'px';