From d35577f1a8c2e2d320cca6f574b9dc7ed53cb5c8 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 29 Mar 2022 09:42:01 -0600 Subject: [PATCH] * Api: Fix splitter widget did not restore size from preference --- api/js/etemplate/et2_widget_split.js | 12 ++++++++---- api/js/etemplate/et2_widget_split.ts | 13 +++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/api/js/etemplate/et2_widget_split.js b/api/js/etemplate/et2_widget_split.js index c8af89b0a8..9edb055cac 100644 --- a/api/js/etemplate/et2_widget_split.js +++ b/api/js/etemplate/et2_widget_split.js @@ -154,11 +154,15 @@ var et2_split = /** @class */ (function (_super) { if (this.id) { var pref = this.egw().preference('splitter-size-' + this.id, this.egw().getAppName()); if (pref) { - if (this.orientation == "v" && pref['sizeLeft'] < this.dynheight.outerNode.width() || - this.orientation == "h" && pref['sizeTop'] < this.dynheight.outerNode.height()) { - options = jQuery.extend(options, pref); - this.prefSize = pref[this.orientation == "v" ? 'sizeLeft' : 'sizeTop']; + // Change from percent back to numeric + if (typeof pref.sizeLeft !== "undefined") { + pref.sizeLeft = ((parseFloat(pref.sizeLeft) / 100) * widget.dynheight.outerNode.width()); } + if (typeof pref.sizeTop !== "undefined") { + pref.sizeTop = ((parseFloat(pref.sizeTop) / 100) * widget.dynheight.outerNode.height()); + } + options = jQuery.extend(options, pref); + this.prefSize = pref[this.orientation == "v" ? 'sizeLeft' : 'sizeTop']; } // If there is no preference yet, set it to half size // Otherwise the right pane gets the fullsize diff --git a/api/js/etemplate/et2_widget_split.ts b/api/js/etemplate/et2_widget_split.ts index 1f0dd31426..2b1c7742a2 100644 --- a/api/js/etemplate/et2_widget_split.ts +++ b/api/js/etemplate/et2_widget_split.ts @@ -219,12 +219,17 @@ class et2_split extends et2_DOMWidget implements et2_IResizeable, et2_IPrint let pref = this.egw().preference('splitter-size-' + this.id, this.egw().getAppName()); if(pref) { - if(this.orientation == "v" && pref['sizeLeft'] < this.dynheight.outerNode.width() || - this.orientation == "h" && pref['sizeTop'] < this.dynheight.outerNode.height()) + // Change from percent back to numeric + if(typeof pref.sizeLeft !== "undefined") { - options = jQuery.extend(options, pref); - this.prefSize = pref[this.orientation == "v" ?'sizeLeft' : 'sizeTop']; + pref.sizeLeft = ((parseFloat(pref.sizeLeft) / 100) * widget.dynheight.outerNode.width()); } + if(typeof pref.sizeTop !== "undefined") + { + pref.sizeTop = ((parseFloat(pref.sizeTop) / 100) * widget.dynheight.outerNode.height()); + } + options = jQuery.extend(options, pref); + this.prefSize = pref[this.orientation == "v" ? 'sizeLeft' : 'sizeTop']; } // If there is no preference yet, set it to half size // Otherwise the right pane gets the fullsize