cosmetic changes; Ox.UI.isElement -> Ox.isOxElement
This commit is contained in:
parent
6efb08ab60
commit
6a5c380795
1 changed files with 61 additions and 29 deletions
|
@ -177,7 +177,8 @@ Ox.Dialog = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
!self.options.fixedSize && [
|
!self.options.fixedSize && [
|
||||||
'TopLeft', 'Top', 'TopRight', 'Left', 'Right', 'BottomLeft', 'Bottom', 'BottomRight'
|
'TopLeft', 'Top', 'TopRight', 'Left',
|
||||||
|
'Right', 'BottomLeft', 'Bottom', 'BottomRight'
|
||||||
].forEach(function(edge) {
|
].forEach(function(edge) {
|
||||||
Ox.Element()
|
Ox.Element()
|
||||||
.addClass('OxResize OxResize' + edge)
|
.addClass('OxResize OxResize' + edge)
|
||||||
|
@ -196,12 +197,12 @@ Ox.Dialog = function(options, self) {
|
||||||
var ms = animate ? 100 : 0;
|
var ms = animate ? 100 : 0;
|
||||||
self.centered && decenter();
|
self.centered && decenter();
|
||||||
that.animate({
|
that.animate({
|
||||||
left: Math.round(
|
left: Math.round((
|
||||||
(window.innerWidth - self.options.width) / 2
|
window.innerWidth - self.options.width
|
||||||
) + 'px',
|
) * 0.5) + 'px',
|
||||||
top: Math.round(
|
top: Math.round((
|
||||||
(window.innerHeight - self.options.height - self.barsHeight) * 0.4
|
window.innerHeight - self.options.height - self.barsHeight
|
||||||
) + 'px',
|
) * 0.4) + 'px',
|
||||||
width: self.options.width + 'px',
|
width: self.options.width + 'px',
|
||||||
height: self.options.height + self.barsHeight + 'px'
|
height: self.options.height + self.barsHeight + 'px'
|
||||||
}, ms, function() {
|
}, ms, function() {
|
||||||
|
@ -209,9 +210,9 @@ Ox.Dialog = function(options, self) {
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: Math.round(
|
bottom: Math.round((
|
||||||
(window.innerHeight - self.options.height - self.barsHeight) * 0.2
|
window.innerHeight - self.options.height - self.barsHeight
|
||||||
) + 'px',
|
) * 0.2) + 'px',
|
||||||
margin: 'auto'
|
margin: 'auto'
|
||||||
});
|
});
|
||||||
self.centered = true;
|
self.centered = true;
|
||||||
|
@ -303,7 +304,9 @@ Ox.Dialog = function(options, self) {
|
||||||
height: self.originalHeight
|
height: self.originalHeight
|
||||||
} : {
|
} : {
|
||||||
left: Math.round((window.innerWidth - self.options.maxWidth) / 2),
|
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,
|
width: self.options.maxWidth,
|
||||||
height: self.options.maxHeight
|
height: self.options.maxHeight
|
||||||
}, true);
|
}, true);
|
||||||
|
@ -315,11 +318,15 @@ Ox.Dialog = function(options, self) {
|
||||||
if (!self.centered) {
|
if (!self.centered) {
|
||||||
offset = that.offset();
|
offset = that.offset();
|
||||||
left = Ox.limit(
|
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
|
self.minLeft, self.maxLeft
|
||||||
);
|
);
|
||||||
top = Ox.limit(
|
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
|
self.minTop, self.maxTop
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -356,10 +363,15 @@ Ox.Dialog = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize(event) {
|
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) {
|
if (!self.drag.fixedRatio && event.shiftKey) {
|
||||||
self.drag.centerX = Math.round(self.drag.left + self.drag.width / 2);
|
self.drag.centerX = Math.round(
|
||||||
self.drag.centerY = Math.round(self.drag.top + self.drag.height / 2);
|
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.fixedCenter = self.options.fixedCenter || event.altKey;
|
||||||
self.drag.fixedRatio = self.options.fixedRatio || event.shiftKey;
|
self.drag.fixedRatio = self.options.fixedRatio || event.shiftKey;
|
||||||
|
@ -402,7 +414,8 @@ Ox.Dialog = function(options, self) {
|
||||||
if (self.drag.isTop && vertical) {
|
if (self.drag.isTop && vertical) {
|
||||||
self.options.height = Ox.limit(
|
self.options.height = Ox.limit(
|
||||||
self.options.height + (
|
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.drag.fixedCenter ? 2 : 1),
|
||||||
self.options.minHeight,
|
self.options.minHeight,
|
||||||
self.options.maxHeight
|
self.options.maxHeight
|
||||||
|
@ -434,7 +447,8 @@ Ox.Dialog = function(options, self) {
|
||||||
if (self.drag.isRight && horizontal) {
|
if (self.drag.isRight && horizontal) {
|
||||||
self.options.width = Ox.limit(
|
self.options.width = Ox.limit(
|
||||||
self.options.width + (
|
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.drag.fixedCenter ? 2 : 1),
|
||||||
self.options.minWidth,
|
self.options.minWidth,
|
||||||
self.options.maxWidth
|
self.options.maxWidth
|
||||||
|
@ -467,7 +481,8 @@ Ox.Dialog = function(options, self) {
|
||||||
if (self.drag.isBottom && vertical) {
|
if (self.drag.isBottom && vertical) {
|
||||||
self.options.height = Ox.limit(
|
self.options.height = Ox.limit(
|
||||||
self.options.height + (
|
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.drag.fixedCenter ? 2 : 1),
|
||||||
self.options.minHeight,
|
self.options.minHeight,
|
||||||
self.options.maxHeight
|
self.options.maxHeight
|
||||||
|
@ -503,7 +518,8 @@ Ox.Dialog = function(options, self) {
|
||||||
self.drag.width = self.options.width;
|
self.drag.width = self.options.width;
|
||||||
self.drag.height = self.options.height;
|
self.drag.height = self.options.height;
|
||||||
self.drag.minLeft = 24 - self.options.width;
|
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', {
|
that.triggerEvent('resize', {
|
||||||
width: self.options.width,
|
width: self.options.width,
|
||||||
height: self.options.height
|
height: self.options.height
|
||||||
|
@ -521,7 +537,9 @@ Ox.Dialog = function(options, self) {
|
||||||
|
|
||||||
function resizeWindow() {
|
function resizeWindow() {
|
||||||
self.options.width = Math.min(self.options.width, window.innerWidth);
|
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();
|
var offset = that.offset();
|
||||||
setMinAndMax();
|
setMinAndMax();
|
||||||
if (self.centered) {
|
if (self.centered) {
|
||||||
|
@ -562,7 +580,8 @@ Ox.Dialog = function(options, self) {
|
||||||
|
|
||||||
function setContent() {
|
function setContent() {
|
||||||
var animate = !!self.$content,
|
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) {
|
if (animate) {
|
||||||
self.$content.animate({
|
self.$content.animate({
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
@ -616,7 +635,8 @@ Ox.Dialog = function(options, self) {
|
||||||
self.options.width = css.width;
|
self.options.width = css.width;
|
||||||
self.options.height = css.height;
|
self.options.height = css.height;
|
||||||
self.minLeft = 24 - self.options.width;
|
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', {
|
triggerEvent && that.triggerEvent('resize', {
|
||||||
width: self.options.width,
|
width: self.options.width,
|
||||||
height: self.options.height
|
height: self.options.height
|
||||||
|
@ -631,21 +651,33 @@ Ox.Dialog = function(options, self) {
|
||||||
self.maxTop = window.innerHeight - 24;
|
self.maxTop = window.innerHeight - 24;
|
||||||
self.minLeft = 24 - self.options.width;
|
self.minLeft = 24 - self.options.width;
|
||||||
self.minTop = self.hasButtons ? 24 - self.options.height : 0;
|
self.minTop = self.hasButtons ? 24 - self.options.height : 0;
|
||||||
self.options.maxHeight = Ox.limit(self.initialMaxHeight, 64, window.innerHeight - self.barsHeight);
|
self.options.maxHeight = Ox.limit(
|
||||||
self.options.maxWidth = Ox.limit(self.initialMaxWidth, 128, window.innerWidth);
|
self.initialMaxHeight, 64, window.innerHeight - self.barsHeight
|
||||||
|
);
|
||||||
|
self.options.maxWidth = Ox.limit(
|
||||||
|
self.initialMaxWidth, 128, window.innerWidth
|
||||||
|
);
|
||||||
if (self.options.fixedRatio) {
|
if (self.options.fixedRatio) {
|
||||||
ratio = self.options.width / self.options.height;
|
ratio = self.options.width / self.options.height;
|
||||||
maxRatio = self.options.maxWidth / self.options.maxHeight;
|
maxRatio = self.options.maxWidth / self.options.maxHeight;
|
||||||
minRatio = self.options.minWidth / self.options.minHeight;
|
minRatio = self.options.minWidth / self.options.minHeight;
|
||||||
if (maxRatio > ratio) {
|
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) {
|
} 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) {
|
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) {
|
} else if (minRatio < ratio) {
|
||||||
self.options.minHeight = Math.round(self.options.minWidth / ratio);
|
self.options.minHeight = Math.round(
|
||||||
|
self.options.minWidth / ratio
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue