From a518abfcae49809749e18a37710bca8bb8b157b9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 2 Aug 2016 13:55:45 +0300 Subject: [PATCH] Fixed bug with initial size and resizing for plugins window. --- apps/common/main/lib/controller/Plugins.js | 9 ++- apps/common/main/lib/model/Plugin.js | 5 +- apps/common/main/lib/view/Plugins.js | 68 ++++++++----------- .../main/app/controller/Main.js | 5 +- .../main/app/controller/Main.js | 5 +- .../main/app/controller/Main.js | 5 +- 6 files changed, 53 insertions(+), 44 deletions(-) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index a8ab21ae6..04c2aca10 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -135,6 +135,9 @@ define([ variation.set_InitData(itemVar.get('initData')); variation.set_UpdateOleOnResize(itemVar.get('isUpdateOleOnResize')); variation.set_Buttons(itemVar.get('buttons')); + variation.set_Size(itemVar.get('size')); + variation.set_MaximumSize(itemVar.get('maximumSize')); + variation.set_MinimumSize(itemVar.get('minimumSize')); variationsArr.push(variation); }); plugin.set_Variations(variationsArr); @@ -223,7 +226,9 @@ define([ } else { var me = this, arrBtns = variation.get_Buttons(), - newBtns = {}; + newBtns = {}, + size = variation.get_Size(); + if (!size || size.length<2) size = [400, 400]; if (_.isArray(arrBtns)) { _.each(arrBtns, function(b, index){ @@ -234,6 +239,8 @@ define([ var _baseUrl = (plugin.get_BaseUrl().length == 0) ? me.panelPlugins.pluginsPath : plugin.get_BaseUrl(); me.pluginDlg = new Common.Views.PluginDlg({ title: plugin.get_Name(), + width: size[0], // inner width + height: size[1], // inner height url: _baseUrl + variation.get_Url(), buttons: newBtns, toolcallback: _.bind(this.onToolClose, this) diff --git a/apps/common/main/lib/model/Plugin.js b/apps/common/main/lib/model/Plugin.js index 83308797f..4a0841769 100644 --- a/apps/common/main/lib/model/Plugin.js +++ b/apps/common/main/lib/model/Plugin.js @@ -63,7 +63,10 @@ define([ initDataType: 0, initData: "", isUpdateOleOnResize: false, - buttons: [] + buttons: [], + size: [400, 400], + maximumSize: [], + minimumSize: [] } } }); diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js index 76b3f56dc..809dbdf70 100644 --- a/apps/common/main/lib/view/Plugins.js +++ b/apps/common/main/lib/view/Plugins.js @@ -187,13 +187,15 @@ define([ initialize : function(options) { var _options = {}; _.extend(_options, { - width: 800, - height: (window.innerHeight-600)<0 ? window.innerHeight: 600, cls: 'advanced-settings-dlg', header: true }, options); var header_footer = (_options.buttons && _.size(_options.buttons)>0) ? 85 : 34; + _options.width = (window.innerWidth-_options.width)<0 ? window.innerWidth: _options.width, + _options.height += header_footer; + _options.height = (window.innerHeight-_options.height)<0 ? window.innerHeight: _options.height; + this.template = [ '
', '
', @@ -227,59 +229,47 @@ define([ iframe.frameBorder = 0; iframe.scrolling = "no"; iframe.onload = _.bind(this._onLoad,this); - $('#id-plugin-placeholder').append(iframe); - - this.loadMask = new Common.UI.LoadMask({owner: $('#id-plugin-placeholder')}); - this.loadMask.setTitle(this.textLoading); - this.loadMask.show(); - - iframe.src = this.url; var me = this; + setTimeout(function(){ + if (me.isLoaded) return; + me.loadMask = new Common.UI.LoadMask({owner: $('#id-plugin-placeholder')}); + me.loadMask.setTitle(this.textLoading); + me.loadMask.show(); + if (me.isLoaded) me.loadMask.hide(); + }, 500); - this.on('close', function(obj){ - }); - - this.on('show', function(obj){ - var h = me.getHeight(); - if (window.innerHeight>h && h<600 || window.innerHeight= 0) { - var min = parseInt(this.$window.css('min-height')); - height < min && (height = min); - this.$window.height(height); - - var header_height = (this.initConfig.header) ? parseInt(this.$window.find('> .header').css('height')) : 0; - - this.$window.find('> .body').css('height', height-header_height); - this.$window.find('> .body > .box').css('height', height-85); - - var top = ((parseInt(window.innerHeight) - parseInt(height)) / 2) * 0.9; - var left = (parseInt(window.innerWidth) - parseInt(this.initConfig.width)) / 2; - - this.$window.css('left',left); - this.$window.css('top',top); - } - }, - setInnerSize: function(width, height) { + var maxHeight = parseInt(window.innerHeight), + maxWidth = parseInt(window.innerWidth), + header_footer = (this.options.buttons && _.size(this.options.buttons)>0) ? 85 : 34; + if (maxHeight .box'); boxEl.css('height', height); - Common.UI.Window.prototype.setHeight.call(this, height + 85); + Common.UI.Window.prototype.setHeight.call(this, height + header_footer); Common.UI.Window.prototype.setWidth.call(this, width); + + var top = ((maxHeight - height - header_footer) / 2) * 0.9; + var left = (maxWidth - width) / 2; + + this.$window.css('left',(maxWidth - width) / 2); + this.$window.css('top',((maxHeight - height - header_footer) / 2) * 0.9); }, textLoading : 'Loading' diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 326d52ac1..7df6d5b15 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1726,7 +1726,10 @@ define([ initDataType: itemVar.initDataType, initData: itemVar.initData, isUpdateOleOnResize : itemVar.isUpdateOleOnResize, - buttons: itemVar.buttons + buttons: itemVar.buttons, + size: itemVar.size, + minimumSize: itemVar.minimumSize, + maximumSize: itemVar.maximumSize })); }); if (variationsArr.length>0) diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 596aacb9d..b69d69f7d 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1512,7 +1512,10 @@ define([ initDataType: itemVar.initDataType, initData: itemVar.initData, isUpdateOleOnResize : itemVar.isUpdateOleOnResize, - buttons: itemVar.buttons + buttons: itemVar.buttons, + size: itemVar.size, + minimumSize: itemVar.minimumSize, + maximumSize: itemVar.maximumSize })); }); if (variationsArr.length>0) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 0321aef64..0fd78dd62 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1721,7 +1721,10 @@ define([ initDataType: itemVar.initDataType, initData: itemVar.initData, isUpdateOleOnResize : itemVar.isUpdateOleOnResize, - buttons: itemVar.buttons + buttons: itemVar.buttons, + size: itemVar.size, + minimumSize: itemVar.minimumSize, + maximumSize: itemVar.maximumSize })); }); if (variationsArr.length>0)