From c1ac28bf8e44343537181951fdc3e13335ed876f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 1 Aug 2016 16:25:59 +0300 Subject: [PATCH] Debug resizing plugin left panel and moving plugin modal window. --- apps/common/main/lib/component/Layout.js | 17 ++++++++++++----- apps/common/main/lib/controller/Plugins.js | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/component/Layout.js b/apps/common/main/lib/component/Layout.js index 4ef9ac6a8..3c874347b 100644 --- a/apps/common/main/lib/component/Layout.js +++ b/apps/common/main/lib/component/Layout.js @@ -172,11 +172,6 @@ define([ }, this); this.freeze = options.freeze; this.freeze && this.freezePanels(this.freeze); - - Common.NotificationCenter.on({ - 'frame:mouseMove': this.resize.eventMove, - 'frame:mouseup': this.resize.eventStop - }); }, doLayout: function() { @@ -236,6 +231,11 @@ define([ mouseup : this.resize.eventStop }); + Common.NotificationCenter.on({ + 'frame:mousemove': this.resize.eventMove, + 'frame:mouseup': this.resize.eventStop + }); + var panel = e.data.panel; this.resize.type = e.data.type; this.resize.$el = panel.el; @@ -289,6 +289,13 @@ define([ mouseup : this.resize.eventStop }); + Common.NotificationCenter.off({ + 'frame:mousemove': this.resize.eventMove, + 'frame:mouseup': this.resize.eventStop + }); + + if (!this.resize.$el) return; + if (this.resize.type == 'vertical') { var prop = 'height'; var value = e.pageY - this.resize.inity; diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index 258d5437f..a8ab21ae6 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -66,6 +66,8 @@ define([ storePlugins: this.getApplication().getCollection('Common.Collections.Plugins') }); this.panelPlugins.on('render:after', _.bind(this.onAfterRender, this)); + + this._moveOffset = {x:0, y:0}; }, setApi: function(api) { @@ -94,6 +96,9 @@ define([ Common.NotificationCenter.on({ 'layout:resizestart': function(e){ if (me.panelPlugins.isVisible()) { + var offset = me.panelPlugins.currentPluginFrame.offset(); + me._moveOffset = {x: offset.left + parseInt(me.panelPlugins.currentPluginFrame.css('padding-left')), + y: offset.top + parseInt(me.panelPlugins.currentPluginFrame.css('padding-top'))}; me.api.asc_pluginEnableMouseEvents(true); } }, @@ -235,8 +240,11 @@ define([ }); me.pluginDlg.on('render:after', function(obj){ obj.getChild('.footer .dlg-btn').on('click', _.bind(me.onDlgBtnClick, me)); + me.pluginContainer = me.pluginDlg.$window.find('#id-plugin-container'); }).on('close', function(obj){ me.pluginDlg = undefined; + }).on('drag', function(args){ + me.api.asc_pluginEnableMouseEvents(args[1]=='start'); }); me.pluginDlg.show(); } @@ -267,11 +275,18 @@ define([ }, onPluginMouseUp: function(x, y) { - Common.NotificationCenter.trigger('frame:mouseup', jQuery.Event("mouseup", { pageX: x, pageY: y } )); + if (this.pluginDlg) { + this.pluginDlg.binding.dragStop(); + } else + Common.NotificationCenter.trigger('frame:mouseup', jQuery.Event("mouseup", { pageX: x+this._moveOffset.x, pageY: y+this._moveOffset.y } )); }, onPluginMouseMove: function(x, y) { - Common.NotificationCenter.trigger('frame:mousemove', jQuery.Event("mousemove", { pageX: x, pageY: y } )); + if (this.pluginDlg) { + var offset = this.pluginContainer.offset(); + this.pluginDlg.binding.drag(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 } )); } }, Common.Controllers.Plugins || {}));