From 94595fa16e03d6284a80a6a46b360a71c27dff03 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 26 Jun 2017 14:21:26 +0300 Subject: [PATCH] Refactoring window component. --- apps/common/main/lib/component/Window.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/common/main/lib/component/Window.js b/apps/common/main/lib/component/Window.js index 7cf76c390..c82cd68c1 100644 --- a/apps/common/main/lib/component/Window.js +++ b/apps/common/main/lib/component/Window.js @@ -248,8 +248,8 @@ define([ Common.UI.Menu.Manager.hideAll(); var zoom = (event instanceof jQuery.Event) ? Common.Utils.zoom() : 1; this.dragging.enabled = true; - this.dragging.initx = event.pageX*zoom - parseInt(this.$window.css('left')); - this.dragging.inity = event.pageY*zoom - parseInt(this.$window.css('top')); + this.dragging.initx = event.pageX*zoom - this.getLeft(); + this.dragging.inity = event.pageY*zoom - this.getTop(); if (window.innerHeight == undefined) { var main_width = document.documentElement.offsetWidth; @@ -259,8 +259,8 @@ define([ main_height = Common.Utils.innerHeight(); } - this.dragging.maxx = main_width - parseInt(this.$window.css("width")); - this.dragging.maxy = main_height - parseInt(this.$window.css("height")); + this.dragging.maxx = main_width - this.getWidth(); + this.dragging.maxy = main_height - this.getHeight(); $(document).on('mousemove', this.binding.drag); $(document).on('mouseup', this.binding.dragStop); @@ -298,16 +298,16 @@ define([ function _resizestart(event) { Common.UI.Menu.Manager.hideAll(); var el = $(event.target), - left = parseInt(this.$window.css('left')), - top = parseInt(this.$window.css('top')); + left = this.getLeft(), + top = this.getTop(); this.resizing.enabled = true; this.resizing.initpage_x = event.pageX*Common.Utils.zoom(); this.resizing.initpage_y = event.pageY*Common.Utils.zoom(); this.resizing.initx = this.resizing.initpage_x - left; this.resizing.inity = this.resizing.initpage_y - top; - this.resizing.initw = parseInt(this.$window.css("width")); - this.resizing.inith = parseInt(this.$window.css("height")); + this.resizing.initw = this.getWidth(); + this.resizing.inith = this.getHeight(); this.resizing.type = [el.hasClass('left') ? -1 : (el.hasClass('right') ? 1 : 0), el.hasClass('top') ? -1 : (el.hasClass('bottom') ? 1 : 0)]; var main_width = (window.innerHeight == undefined) ? document.documentElement.offsetWidth : Common.Utils.innerWidth(), @@ -827,6 +827,14 @@ define([ return this.$window.find('> .header > .title').text(); }, + getLeft: function() { + return parseInt(this.$window.css('left')); + }, + + getTop: function() { + return parseInt(this.$window.css('top')); + }, + isVisible: function() { return this.$window && this.$window.is(':visible'); },