From bee1f77a2ea68ecdd1985f09e92b6645c4569840 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 26 Jun 2017 14:38:09 +0300 Subject: [PATCH] Plugins: resize plugin dialog when browser window is resized. --- apps/common/main/lib/view/Plugins.js | 54 +++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js index ed0c02fe6..f86e05933 100644 --- a/apps/common/main/lib/view/Plugins.js +++ b/apps/common/main/lib/view/Plugins.js @@ -296,10 +296,10 @@ define([ var header_footer = (_options.buttons && _.size(_options.buttons)>0) ? 85 : 34; if (!_options.header) header_footer -= 34; - this.bordersOffset = (_options.header) ? 10 : 25; - _options.width = (Common.Utils.innerWidth()-this.bordersOffset-_options.width)<0 ? Common.Utils.innerWidth()-this.bordersOffset: _options.width; + this.bordersOffset = 25; + _options.width = (Common.Utils.innerWidth()-this.bordersOffset*2-_options.width)<0 ? Common.Utils.innerWidth()-this.bordersOffset*2: _options.width; _options.height += header_footer; - _options.height = (Common.Utils.innerHeight()-this.bordersOffset-_options.height)<0 ? Common.Utils.innerHeight()-this.bordersOffset: _options.height; + _options.height = (Common.Utils.innerHeight()-this.bordersOffset*2-_options.height)<0 ? Common.Utils.innerHeight()-this.bordersOffset*2: _options.height; _options.cls += ' advanced-settings-dlg'; this.template = [ @@ -356,6 +356,14 @@ define([ this.on('resizing', function(args){ me.boxEl.css('height', parseInt(me.$window.css('height')) - me._headerFooterHeight); }); + + var onMainWindowResize = function(){ + me.onWindowResize(); + }; + $(window).on('resize', onMainWindowResize); + this.on('close', function() { + $(window).off('resize', onMainWindowResize); + }); }, _onLoad: function() { @@ -367,11 +375,12 @@ define([ setInnerSize: function(width, height) { var maxHeight = Common.Utils.innerHeight(), maxWidth = Common.Utils.innerWidth(), - borders_width = (parseInt(this.$window.css('border-left-width')) + parseInt(this.$window.css('border-right-width'))); - if (maxHeight - this.bordersOffsetmain_height-bordersOffset) + this.$window.css('top', main_height-bordersOffset - win_height); + if (leftmain_width-bordersOffset) + this.$window.css('left', main_width-bordersOffset-win_width); + } else { + if (win_height>main_height-bordersOffset*2) { + this.setHeight(Math.max(main_height-bordersOffset*2, this.initConfig.minheight)); + this.boxEl.css('height', Math.max(main_height-bordersOffset*2, this.initConfig.minheight) - this._headerFooterHeight); + this.$window.css('top', bordersOffset); + } + if (win_width>main_width-bordersOffset*2) { + this.setWidth(Math.max(main_width-bordersOffset*2, this.initConfig.minwidth)); + this.$window.css('left', bordersOffset); + } + } + }, + textLoading : 'Loading' }, Common.Views.PluginDlg || {})); }); \ No newline at end of file