diff --git a/source/Ox.UI/js/Window/Dialog.js b/source/Ox.UI/js/Window/Dialog.js index 41b0a1d8..29e59db1 100644 --- a/source/Ox.UI/js/Window/Dialog.js +++ b/source/Ox.UI/js/Window/Dialog.js @@ -177,7 +177,8 @@ Ox.Dialog = function(options, self) { } !self.options.fixedSize && [ - 'TopLeft', 'Top', 'TopRight', 'Left', 'Right', 'BottomLeft', 'Bottom', 'BottomRight' + 'TopLeft', 'Top', 'TopRight', 'Left', + 'Right', 'BottomLeft', 'Bottom', 'BottomRight' ].forEach(function(edge) { Ox.Element() .addClass('OxResize OxResize' + edge) @@ -196,12 +197,12 @@ Ox.Dialog = function(options, self) { var ms = animate ? 100 : 0; self.centered && decenter(); that.animate({ - left: Math.round( - (window.innerWidth - self.options.width) / 2 - ) + 'px', - top: Math.round( - (window.innerHeight - self.options.height - self.barsHeight) * 0.4 - ) + 'px', + left: Math.round(( + window.innerWidth - self.options.width + ) * 0.5) + 'px', + top: Math.round(( + window.innerHeight - self.options.height - self.barsHeight + ) * 0.4) + 'px', width: self.options.width + 'px', height: self.options.height + self.barsHeight + 'px' }, ms, function() { @@ -209,9 +210,9 @@ Ox.Dialog = function(options, self) { left: 0, top: 0, right: 0, - bottom: Math.round( - (window.innerHeight - self.options.height - self.barsHeight) * 0.2 - ) + 'px', + bottom: Math.round(( + window.innerHeight - self.options.height - self.barsHeight + ) * 0.2) + 'px', margin: 'auto' }); self.centered = true; @@ -303,7 +304,9 @@ Ox.Dialog = function(options, self) { height: self.originalHeight } : { left: Math.round((window.innerWidth - self.options.maxWidth) / 2), - top: Math.round((window.innerHeight - self.options.maxHeight - self.barsHeight) / 2), + top: Math.round(( + window.innerHeight - self.options.maxHeight - self.barsHeight + ) / 2), width: self.options.maxWidth, height: self.options.maxHeight }, true); @@ -315,11 +318,15 @@ Ox.Dialog = function(options, self) { if (!self.centered) { offset = that.offset(); left = Ox.limit( - offset.left + Math.round((self.options.width - self.initialWidth) / 2), + offset.left + Math.round(( + self.options.width - self.initialWidth + ) / 2), self.minLeft, self.maxLeft ); top = Ox.limit( - offset.top + Math.round((self.options.height - self.initialHeight) / 2), + offset.top + Math.round(( + self.options.height - self.initialHeight + ) / 2), self.minTop, self.maxTop ); } @@ -356,10 +363,15 @@ Ox.Dialog = function(options, self) { } function resize(event) { - var horizontal, vertical, offset, ratio = self.drag.width / self.drag.height; + var horizontal, vertical, offset, + ratio = self.drag.width / self.drag.height; if (!self.drag.fixedRatio && event.shiftKey) { - self.drag.centerX = Math.round(self.drag.left + self.drag.width / 2); - self.drag.centerY = Math.round(self.drag.top + self.drag.height / 2); + self.drag.centerX = Math.round( + self.drag.left + self.drag.width / 2 + ); + self.drag.centerY = Math.round( + self.drag.top + self.drag.height / 2 + ); } self.drag.fixedCenter = self.options.fixedCenter || event.altKey; self.drag.fixedRatio = self.options.fixedRatio || event.shiftKey; @@ -402,7 +414,8 @@ Ox.Dialog = function(options, self) { if (self.drag.isTop && vertical) { self.options.height = Ox.limit( self.options.height + ( - self.drag.top - Ox.limit(event.clientY, self.minTop, self.maxTop) + self.drag.top + - Ox.limit(event.clientY, self.minTop, self.maxTop) ) * (self.drag.fixedCenter ? 2 : 1), self.options.minHeight, self.options.maxHeight @@ -434,7 +447,8 @@ Ox.Dialog = function(options, self) { if (self.drag.isRight && horizontal) { self.options.width = Ox.limit( self.options.width + ( - Math.max(event.clientX, 24) - self.drag.left - self.drag.width + Math.max(event.clientX, 24) + - self.drag.left - self.drag.width ) * (self.drag.fixedCenter ? 2 : 1), self.options.minWidth, self.options.maxWidth @@ -467,7 +481,8 @@ Ox.Dialog = function(options, self) { if (self.drag.isBottom && vertical) { self.options.height = Ox.limit( self.options.height + ( - Math.max(event.clientY, 24) - self.drag.top - self.drag.height - self.barsHeight + Math.max(event.clientY, 24) + - self.drag.top - self.drag.height - self.barsHeight ) * (self.drag.fixedCenter ? 2 : 1), self.options.minHeight, self.options.maxHeight @@ -503,7 +518,8 @@ Ox.Dialog = function(options, self) { self.drag.width = self.options.width; self.drag.height = self.options.height; self.drag.minLeft = 24 - self.options.width; - self.drag.minTop = self.hasButtons ? 24 - self.options.height - self.barsHeight : 0; + self.drag.minTop = self.hasButtons + ? 24 - self.options.height - self.barsHeight : 0; that.triggerEvent('resize', { width: self.options.width, height: self.options.height @@ -521,7 +537,9 @@ Ox.Dialog = function(options, self) { function resizeWindow() { self.options.width = Math.min(self.options.width, window.innerWidth); - self.options.height = Math.min(self.options.height, window.innerHeight - self.barsHeight); + self.options.height = Math.min( + self.options.height, window.innerHeight - self.barsHeight + ); var offset = that.offset(); setMinAndMax(); if (self.centered) { @@ -562,7 +580,8 @@ Ox.Dialog = function(options, self) { function setContent() { var animate = !!self.$content, - isImage = !Ox.UI.isElement(self.options.content) && self.options.content.is('img'); + isImage = !Ox.isOxElement(self.options.content) + && self.options.content.is('img'); if (animate) { self.$content.animate({ opacity: 0 @@ -616,7 +635,8 @@ Ox.Dialog = function(options, self) { self.options.width = css.width; self.options.height = css.height; self.minLeft = 24 - self.options.width; - self.minTop = self.hasButtons ? 24 - self.options.height - self.barsHeight : 0; + self.minTop = self.hasButtons + ? 24 - self.options.height - self.barsHeight : 0; triggerEvent && that.triggerEvent('resize', { width: self.options.width, height: self.options.height @@ -631,21 +651,33 @@ Ox.Dialog = function(options, self) { self.maxTop = window.innerHeight - 24; self.minLeft = 24 - self.options.width; self.minTop = self.hasButtons ? 24 - self.options.height : 0; - self.options.maxHeight = Ox.limit(self.initialMaxHeight, 64, window.innerHeight - self.barsHeight); - self.options.maxWidth = Ox.limit(self.initialMaxWidth, 128, window.innerWidth); + self.options.maxHeight = Ox.limit( + self.initialMaxHeight, 64, window.innerHeight - self.barsHeight + ); + self.options.maxWidth = Ox.limit( + self.initialMaxWidth, 128, window.innerWidth + ); if (self.options.fixedRatio) { ratio = self.options.width / self.options.height; maxRatio = self.options.maxWidth / self.options.maxHeight; minRatio = self.options.minWidth / self.options.minHeight; if (maxRatio > ratio) { - self.options.maxWidth = Math.round(self.options.maxHeight * ratio); + self.options.maxWidth = Math.round( + self.options.maxHeight * ratio + ); } else if (maxRatio < ratio) { - self.options.maxHeight = Math.round(self.options.maxWidth / ratio); + self.options.maxHeight = Math.round( + self.options.maxWidth / ratio + ); } if (minRatio > ratio) { - self.options.minWidth = Math.round(self.options.minHeight * ratio); + self.options.minWidth = Math.round( + self.options.minHeight * ratio + ); } else if (minRatio < ratio) { - self.options.minHeight = Math.round(self.options.minWidth / ratio); + self.options.minHeight = Math.round( + self.options.minWidth / ratio + ); } } }