mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
parent
750a8fd0c2
commit
7c8790dcc8
@ -299,6 +299,26 @@ test( "grid - Resizable: can be moved when grid option is set (#9611)", function
|
|||||||
equal( target.position().left, oldPosition.left, "compare left" );
|
equal( target.position().left, oldPosition.left, "compare left" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "grid - maintains grid with padding and border when approaching no dimensions", function() {
|
||||||
|
expect( 2 );
|
||||||
|
|
||||||
|
// http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong
|
||||||
|
var handle = ".ui-resizable-nw",
|
||||||
|
target = $( "#resizable1" ).css({
|
||||||
|
padding: 5,
|
||||||
|
borderWidth: 5,
|
||||||
|
width: 80,
|
||||||
|
height: 80
|
||||||
|
}).resizable({
|
||||||
|
handles: "all",
|
||||||
|
grid: 50
|
||||||
|
});
|
||||||
|
|
||||||
|
TestHelpers.resizable.drag( handle, 50, 50 );
|
||||||
|
equal( target.outerWidth(), 50, "compare width" );
|
||||||
|
equal( target.outerHeight(), 50, "compare height" );
|
||||||
|
});
|
||||||
|
|
||||||
test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
|
test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
|
@ -555,32 +555,56 @@ $.widget("ui.resizable", $.ui.mouse, {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getPaddingPlusBorderDimensions: function( element ) {
|
||||||
|
var i = 0,
|
||||||
|
widths = [],
|
||||||
|
borders = [
|
||||||
|
element.css( "borderTopWidth" ),
|
||||||
|
element.css( "borderRightWidth" ),
|
||||||
|
element.css( "borderBottomWidth" ),
|
||||||
|
element.css( "borderLeftWidth" )
|
||||||
|
],
|
||||||
|
paddings = [
|
||||||
|
element.css( "paddingTop" ),
|
||||||
|
element.css( "paddingRight" ),
|
||||||
|
element.css( "paddingBottom" ),
|
||||||
|
element.css( "paddingLeft" )
|
||||||
|
];
|
||||||
|
|
||||||
|
for ( ; i < 4; i++ ) {
|
||||||
|
widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
|
||||||
|
widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
height: widths[ 0 ] + widths[ 2 ],
|
||||||
|
width: widths[ 1 ] + widths[ 3 ]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
_proportionallyResize: function() {
|
_proportionallyResize: function() {
|
||||||
|
|
||||||
if (!this._proportionallyResizeElements.length) {
|
if (!this._proportionallyResizeElements.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var i, j, borders, paddings, prel,
|
var prel,
|
||||||
|
i = 0,
|
||||||
element = this.helper || this.element;
|
element = this.helper || this.element;
|
||||||
|
|
||||||
for ( i=0; i < this._proportionallyResizeElements.length; i++) {
|
for ( ; i < this._proportionallyResizeElements.length; i++) {
|
||||||
|
|
||||||
prel = this._proportionallyResizeElements[i];
|
prel = this._proportionallyResizeElements[i];
|
||||||
|
|
||||||
if (!this.borderDif) {
|
// TODO: Seems like a bug to cache this.outerDimensions
|
||||||
this.borderDif = [];
|
// considering that we are in a loop.
|
||||||
borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
|
if (!this.outerDimensions) {
|
||||||
paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
|
this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
|
||||||
|
|
||||||
for ( j = 0; j < borders.length; j++ ) {
|
|
||||||
this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prel.css({
|
prel.css({
|
||||||
height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
|
height: (element.height() - this.outerDimensions.height) || 0,
|
||||||
width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
|
width: (element.width() - this.outerDimensions.width) || 0
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -972,7 +996,8 @@ $.ui.plugin.add("resizable", "ghost", {
|
|||||||
$.ui.plugin.add("resizable", "grid", {
|
$.ui.plugin.add("resizable", "grid", {
|
||||||
|
|
||||||
resize: function() {
|
resize: function() {
|
||||||
var that = $(this).resizable( "instance" ),
|
var outerDimensions,
|
||||||
|
that = $(this).resizable( "instance" ),
|
||||||
o = that.options,
|
o = that.options,
|
||||||
cs = that.size,
|
cs = that.size,
|
||||||
os = that.originalSize,
|
os = that.originalSize,
|
||||||
@ -993,16 +1018,16 @@ $.ui.plugin.add("resizable", "grid", {
|
|||||||
o.grid = grid;
|
o.grid = grid;
|
||||||
|
|
||||||
if (isMinWidth) {
|
if (isMinWidth) {
|
||||||
newWidth = newWidth + gridX;
|
newWidth += gridX;
|
||||||
}
|
}
|
||||||
if (isMinHeight) {
|
if (isMinHeight) {
|
||||||
newHeight = newHeight + gridY;
|
newHeight += gridY;
|
||||||
}
|
}
|
||||||
if (isMaxWidth) {
|
if (isMaxWidth) {
|
||||||
newWidth = newWidth - gridX;
|
newWidth -= gridX;
|
||||||
}
|
}
|
||||||
if (isMaxHeight) {
|
if (isMaxHeight) {
|
||||||
newHeight = newHeight - gridY;
|
newHeight -= gridY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/^(se|s|e)$/.test(a)) {
|
if (/^(se|s|e)$/.test(a)) {
|
||||||
@ -1017,19 +1042,25 @@ $.ui.plugin.add("resizable", "grid", {
|
|||||||
that.size.height = newHeight;
|
that.size.height = newHeight;
|
||||||
that.position.left = op.left - ox;
|
that.position.left = op.left - ox;
|
||||||
} else {
|
} else {
|
||||||
|
if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
|
||||||
|
outerDimensions = that._getPaddingPlusBorderDimensions( this );
|
||||||
|
}
|
||||||
|
|
||||||
if ( newHeight - gridY > 0 ) {
|
if ( newHeight - gridY > 0 ) {
|
||||||
that.size.height = newHeight;
|
that.size.height = newHeight;
|
||||||
that.position.top = op.top - oy;
|
that.position.top = op.top - oy;
|
||||||
} else {
|
} else {
|
||||||
that.size.height = gridY;
|
newHeight = gridY - outerDimensions.height;
|
||||||
that.position.top = op.top + os.height - gridY;
|
that.size.height = newHeight;
|
||||||
|
that.position.top = op.top + os.height - newHeight;
|
||||||
}
|
}
|
||||||
if ( newWidth - gridX > 0 ) {
|
if ( newWidth - gridX > 0 ) {
|
||||||
that.size.width = newWidth;
|
that.size.width = newWidth;
|
||||||
that.position.left = op.left - ox;
|
that.position.left = op.left - ox;
|
||||||
} else {
|
} else {
|
||||||
that.size.width = gridX;
|
newWidth = gridY - outerDimensions.height;
|
||||||
that.position.left = op.left + os.width - gridX;
|
that.size.width = newWidth;
|
||||||
|
that.position.left = op.left + os.width - newWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user