Skip to content

Commit bae1a25

Browse files
dekajpmikesherov
authored andcommitted
Resizable: fix whitespace on containment plugin
1 parent c03cb80 commit bae1a25

File tree

1 file changed

+71
-41
lines changed

1 file changed

+71
-41
lines changed

ui/jquery.ui.resizable.js

Lines changed: 71 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -713,129 +713,159 @@ $.ui.plugin.add("resizable", "animate", {
713713

714714
});
715715

716-
$.ui.plugin.add("resizable", "containment", {
716+
$.ui.plugin.add( "resizable", "containment", {
717717

718718
start: function() {
719719
var element, p, co, ch, cw, width, height,
720-
that = $(this).resizable( "instance" ),
720+
that = $( this ).resizable( "instance" ),
721721
o = that.options,
722722
el = that.element,
723723
oc = o.containment,
724-
ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
724+
ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
725725

726-
if (!ce) {
726+
if ( !ce ) {
727727
return;
728728
}
729729

730-
that.containerElement = $(ce);
730+
that.containerElement = $( ce );
731731

732-
if (/document/.test(oc) || oc === document) {
733-
that.containerOffset = { left: 0, top: 0 };
734-
that.containerPosition = { left: 0, top: 0 };
732+
if ( / document/.test( oc ) || oc === document ) {
733+
that.containerOffset = {
734+
left: 0,
735+
top: 0
736+
};
737+
that.containerPosition = {
738+
left: 0,
739+
top: 0
740+
};
735741

736742
that.parentData = {
737-
element: $(document), left: 0, top: 0,
738-
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
743+
element: $( document ),
744+
left: 0,
745+
top: 0,
746+
width: $( document ).width(),
747+
height: $( document ).height() || document.body.parentNode.scrollHeight
739748
};
740749
}
741750

742751
// i'm a node, so compute top, left, right, bottom
743752
else {
744-
element = $(ce);
753+
element = $( ce );
745754
p = [];
746-
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = that._num(element.css("padding" + name)); });
755+
$([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
756+
p[ i ] = that._num( element.css( "padding" + name ) );
757+
});
747758

748759
that.containerOffset = element.offset();
749760
that.containerPosition = element.position();
750-
that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
761+
that.containerSize = {
762+
height: ( element.innerHeight() - p[ 3 ] ),
763+
width: ( element.innerWidth() - p[ 1 ] )
764+
};
751765

752766
co = that.containerOffset;
753767
ch = that.containerSize.height;
754768
cw = that.containerSize.width;
755-
width = (that._hasScroll(ce, "left") ? ce.scrollWidth : cw );
756-
height = (that._hasScroll(ce) ? ce.scrollHeight : ch);
769+
width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
770+
height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
757771

758772
that.parentData = {
759-
element: ce, left: co.left, top: co.top, width: width, height: height
773+
element: ce,
774+
left: co.left,
775+
top: co.top,
776+
width: width,
777+
height: height
760778
};
761779
}
762780
},
763781

764782
resize: function( event ) {
765783
var woset, hoset, isParent, isOffsetRelative,
766-
that = $(this).resizable( "instance" ),
784+
that = $( this ).resizable( "instance" ),
767785
o = that.options,
768-
co = that.containerOffset, cp = that.position,
786+
co = that.containerOffset,
787+
cp = that.position,
769788
pRatio = that._aspectRatio || event.shiftKey,
770-
cop = { top:0, left:0 }, ce = that.containerElement;
789+
cop = {
790+
top: 0,
791+
left: 0
792+
},
793+
ce = that.containerElement;
771794

772-
if (ce[0] !== document && (/static/).test(ce.css("position"))) {
795+
if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
773796
cop = co;
774797
}
775798

776-
if (cp.left < (that._helper ? co.left : 0)) {
777-
that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
778-
if (pRatio) {
799+
if ( cp.left < ( that._helper ? co.left : 0 ) ) {
800+
that.size.width = that.size.width + ( that._helper ? ( that.position.left - co.left ) : ( that.position.left - cop.left ) );
801+
if ( pRatio ) {
779802
that.size.height = that.size.width / that.aspectRatio;
780803
}
781804
that.position.left = o.helper ? co.left : 0;
782805
}
783806

784-
if (cp.top < (that._helper ? co.top : 0)) {
785-
that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
786-
if (pRatio) {
807+
if ( cp.top < ( that._helper ? co.top : 0 ) ) {
808+
that.size.height = that.size.height + ( that._helper ? ( that.position.top - co.top ) : that.position.top );
809+
if ( pRatio ) {
787810
that.size.width = that.size.height * that.aspectRatio;
788811
}
789812
that.position.top = that._helper ? co.top : 0;
790813
}
791814

792-
that.offset.left = that.parentData.left+that.position.left;
793-
that.offset.top = that.parentData.top+that.position.top;
815+
that.offset.left = that.parentData.left + that.position.left;
816+
that.offset.top = that.parentData.top + that.position.top;
794817

795818
woset = Math.abs( ( that._helper ? that.offset.left - cop.left : ( that.offset.left - co.left ) ) + that.sizeDiff.width );
796819
hoset = Math.abs( ( that._helper ? that.offset.top - cop.top : ( that.offset.top - co.top ) ) + that.sizeDiff.height );
797820

798-
isParent = that.containerElement.get(0) === that.element.parent().get(0);
799-
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
821+
isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
822+
isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
800823

801824
if ( isParent && isOffsetRelative ) {
802825
woset -= Math.abs( that.parentData.left );
803826
}
804827

805-
if (woset + that.size.width >= that.parentData.width) {
828+
if ( woset + that.size.width >= that.parentData.width ) {
806829
that.size.width = that.parentData.width - woset;
807-
if (pRatio) {
830+
if ( pRatio ) {
808831
that.size.height = that.size.width / that.aspectRatio;
809832
}
810833
}
811834

812-
if (hoset + that.size.height >= that.parentData.height) {
835+
if ( hoset + that.size.height >= that.parentData.height ) {
813836
that.size.height = that.parentData.height - hoset;
814-
if (pRatio) {
837+
if ( pRatio ) {
815838
that.size.width = that.size.height * that.aspectRatio;
816839
}
817840
}
818841
},
819842

820843
stop: function(){
821-
var that = $(this).resizable( "instance" ),
844+
var that = $( this ).resizable( "instance" ),
822845
o = that.options,
823846
co = that.containerOffset,
824847
cop = that.containerPosition,
825848
ce = that.containerElement,
826-
helper = $(that.helper),
849+
helper = $( that.helper ),
827850
ho = helper.offset(),
828851
w = helper.outerWidth() - that.sizeDiff.width,
829852
h = helper.outerHeight() - that.sizeDiff.height;
830853

831-
if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
832-
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
854+
if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
855+
$( this ).css({
856+
left: ho.left - cop.left - co.left,
857+
width: w,
858+
height: h
859+
});
833860
}
834861

835-
if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
836-
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
862+
if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
863+
$( this ).css({
864+
left: ho.left - cop.left - co.left,
865+
width: w,
866+
height: h
867+
});
837868
}
838-
839869
}
840870
});
841871

0 commit comments

Comments
 (0)