_hasScroll: function( el, a ) {
- //If overflow is hidden, the element might have extra content, but the user wants to hide it
if ( $( el ).css( "overflow" ) === "hidden") {
return false;
}
_helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
});
- //Wrap the element if it cannot hold child nodes
+ // Wrap the element if it cannot hold child nodes
if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
- //Create a wrapper element and set the wrapper to the new current internal element
this.element.wrap(
$("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
position: this.element.css("position"),
})
);
- //Overwrite the original this.element
this.element = this.element.parent().data(
"ui-resizable", this.element.resizable( "instance" )
);
this.elementIsWrapper = true;
- //Move margins to the wrapper
this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
-
- //Prevent Safari textarea resize
+ // support: Safari
+ // Prevent Safari textarea resize
this.originalResizeStyle = this.originalElement.css("resize");
this.originalElement.css("resize", "none");
- //Push the actual element to our proportionallyResize internal array
this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
+ // support: IE9
// avoid IE jump (hard set the margin)
this.originalElement.css({ margin: this.originalElement.css("margin") });
- // fix handlers offset
this._proportionallyResize();
-
}
this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" });
hname = "ui-resizable-"+handle;
axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
- // Apply zIndex to all handles - see #7960
axis.css({ zIndex: o.zIndex });
- //TODO : What's going on here?
+ // TODO : What's going on here?
if ("se" === handle) {
axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
}
- //Insert into internal handles object and append to element
this.handles[handle] = ".ui-resizable-"+handle;
this.element.append(axis);
}
this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
}
- //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
axis = $(this.handles[i], this.element);
- //Checking the correct pad and border
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
- //The padding type i have to apply...
padPos = [ "padding",
/ne|nw|n/.test(i) ? "Top" :
/se|sw|s/.test(i) ? "Bottom" :
}
- //TODO: What's that good for? There's not anything to be executed left
+ // TODO: What's that good for? There's not anything to be executed left
if(!$(this.handles[i]).length) {
continue;
}
}
};
- //TODO: make renderAxis a prototype function
+ // TODO: make renderAxis a prototype function
this._renderAxis(this.element);
this._handles = $(".ui-resizable-handle", this.element)
.disableSelection();
- //Matching axis name
this._handles.mouseover(function() {
if (!that.resizing) {
if (this.className) {
axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
}
- //Axis, default = se
that.axis = axis && axis[1] ? axis[1] : "se";
}
});
- //If we want to auto hide the elements
if (o.autoHide) {
this._handles.hide();
$(this.element)
});
}
- //Initialize the mouse interaction
this._mouseInit();
},
.removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
};
- //TODO: Unwrap at same DOM position
+ // TODO: Unwrap at same DOM position
if (this.elementIsWrapper) {
_destroy(this.element);
wrapper = this.element;
this.resizing = true;
- // bugfix for http://dev.jquery.com/ticket/1749
+ // Bugfix for http://bugs.jqueryui.com/ticket/1749
if ( (/absolute/).test( el.css("position") ) ) {
el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
} else if (el.is(".ui-draggable")) {
curtop += $(o.containment).scrollTop() || 0;
}
- //Store needed variables
this.offset = this.helper.offset();
this.position = { left: curleft, top: curtop };
this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
this.originalMousePosition = { left: event.pageX, top: event.pageY };
- //Aspect Ratio
this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
cursor = $(".ui-resizable-" + this.axis).css("cursor");
_mouseDrag: function(event) {
- //Increase performance, avoid regex
var data,
el = this.helper, props = {},
smp = this.originalMousePosition,
return false;
}
- // Calculate the attrs that will be change
data = trigger.apply(this, [event, dx, dy]);
- // Put this in the mouseDrag handler since the user can start pressing shift while resizing
this._updateVirtualBoundaries(event.shiftKey);
if (this._aspectRatio || event.shiftKey) {
data = this._updateRatio(data, event);
this._updateCache(data);
- // plugins callbacks need to be called first
this._propagate("resize", event);
if ( this.position.top !== this.prevPosition.top ) {
if ( this.size.height !== this.prevSize.height ) {
props.height = this.size.height + "px";
}
- el.css(props);
+ el.css( props );
- if (!this._helper && this._proportionallyResizeElements.length) {
+ if ( !this._helper && this._proportionallyResizeElements.length ) {
this._proportionallyResize();
}
- // Call the user callback if the element was resized
- if ( ! $.isEmptyObject(props) ) {
- this._trigger("resize", event, this.ui());
+ if ( !$.isEmptyObject( props ) ) {
+ this._trigger( "resize", event, this.ui() );
}
return false;
};
if(this._aspectRatio || forceAspectRatio) {
- // We want to create an enclosing box whose aspect ration is the requested one
- // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
pMinWidth = b.minHeight * this.aspectRatio;
pMinHeight = b.minWidth / this.aspectRatio;
pMaxWidth = b.maxHeight * this.aspectRatio;
data.top = dh - o.maxHeight;
}
- // fixing jump error on top/left - bug #2330
+ // Fixing jump error on top/left - bug #2330
if (!data.width && !data.height && !data.left && data.top) {
data.top = null;
} else if (!data.width && !data.height && !data.top && data.left) {
width: $( document ).width(),
height: $( document ).height() || document.body.parentNode.scrollHeight
};
- }
-
- // i'm a node, so compute top, left, right, bottom
- else {
+ } else {
element = $( ce );
p = [];
$([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {