From b475bb5f2088700c5ca09f2e45359e1e750c4b6f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 4 Aug 2016 14:44:23 +0300 Subject: [PATCH] Debugging resizable plugins. --- apps/common/main/lib/controller/Plugins.js | 18 ++++++++++++++---- apps/common/main/lib/view/Plugins.js | 22 +++++++++++++--------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index 4cb9de023..a4c32a331 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -226,7 +226,9 @@ define([ var me = this, arrBtns = variation.get_Buttons(), newBtns = {}, - size = variation.get_Size(); + size = variation.get_Size(), + maxsize = variation.get_MaximumSize(), + minsize = variation.get_MinimumSize(); if (!size || size.length<2) size = [800, 600]; if (_.isArray(arrBtns)) { @@ -242,7 +244,11 @@ define([ height: size[1], // inner height url: _baseUrl + variation.get_Url(), buttons: newBtns, - toolcallback: _.bind(this.onToolClose, this) + toolcallback: _.bind(this.onToolClose, this), + maxwidth: maxsize[0], + maxheight: maxsize[1], + minwidth: minsize[0], + minheight: minsize[1] }); me.pluginDlg.on('render:after', function(obj){ obj.getChild('.footer .dlg-btn').on('click', _.bind(me.onDlgBtnClick, me)); @@ -251,6 +257,8 @@ define([ me.pluginDlg = undefined; }).on('drag', function(args){ me.api.asc_pluginEnableMouseEvents(args[1]=='start'); + }).on('resize', function(args){ + me.api.asc_pluginEnableMouseEvents(args[1]=='start'); }); me.pluginDlg.show(); } @@ -286,7 +294,8 @@ define([ onPluginMouseUp: function(x, y) { if (this.pluginDlg) { - this.pluginDlg.binding.dragStop(); + if (this.pluginDlg.binding.dragStop) this.pluginDlg.binding.dragStop(); + if (this.pluginDlg.binding.resizeStop) this.pluginDlg.binding.resizeStop(); } else Common.NotificationCenter.trigger('frame:mouseup', jQuery.Event("mouseup", { pageX: x+this._moveOffset.x, pageY: y+this._moveOffset.y } )); }, @@ -294,7 +303,8 @@ define([ onPluginMouseMove: function(x, y) { if (this.pluginDlg) { var offset = this.pluginContainer.offset(); - this.pluginDlg.binding.drag(jQuery.Event("mousemove", { pageX: x+offset.left, pageY: y+offset.top } )); + if (this.pluginDlg.binding.drag) this.pluginDlg.binding.drag(jQuery.Event("mousemove", { pageX: x+offset.left, pageY: y+offset.top } )); + if (this.pluginDlg.binding.resize) this.pluginDlg.binding.resize(jQuery.Event("mousemove", { pageX: x+offset.left, pageY: y+offset.top } )); } else Common.NotificationCenter.trigger('frame:mousemove', jQuery.Event("mousemove", { pageX: x+this._moveOffset.x, pageY: y+this._moveOffset.y } )); } diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js index ea8d5c649..7bf7bc9e0 100644 --- a/apps/common/main/lib/view/Plugins.js +++ b/apps/common/main/lib/view/Plugins.js @@ -230,6 +230,10 @@ define([ Common.UI.Window.prototype.render.call(this); this.$window.find('> .body').css({height: 'auto', overflow: 'hidden'}); + this.boxEl = this.$window.find('.body > .box'); + this._headerFooterHeight = (this.options.buttons && _.size(this.options.buttons)>0) ? 85 : 34; + this._headerFooterHeight += ((parseInt(this.$window.css('border-top-width')) + parseInt(this.$window.css('border-bottom-width')))); + var iframe = document.createElement("iframe"); iframe.id = 'plugin_iframe'; iframe.name = 'pluginFrameEditor', @@ -251,6 +255,10 @@ define([ iframe.src = this.url; $('#id-plugin-placeholder').append(iframe); + + this.on('resizing', function(args){ + me.boxEl.css('height', parseInt(me.$window.css('height')) - me._headerFooterHeight); + }); }, _onLoad: function() { @@ -262,23 +270,19 @@ define([ 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, - borders_height = (parseInt(this.$window.css('border-top-width')) + parseInt(this.$window.css('border-bottom-width'))), borders_width = (parseInt(this.$window.css('border-left-width')) + parseInt(this.$window.css('border-right-width'))); - if (maxHeight .box'); - boxEl.css('height', height); + this.boxEl.css('height', height); - Common.UI.Window.prototype.setHeight.call(this, height + header_footer + borders_height); + Common.UI.Window.prototype.setHeight.call(this, height + this._headerFooterHeight); Common.UI.Window.prototype.setWidth.call(this, width + borders_width); this.$window.css('left',(maxWidth - width - borders_width) / 2); - this.$window.css('top',((maxHeight - height - header_footer - borders_height) / 2) * 0.9); + this.$window.css('top',((maxHeight - height - this._headerFooterHeight) / 2) * 0.9); }, textLoading : 'Loading'