Skip to content

Commit 2acfde9

Browse files
committed
Position: Created center variable for better minification. Fixes #5964 - Combine horizontalDefault and verticalDefault to one variable - possibly named center.
1 parent 4400632 commit 2acfde9

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

ui/jquery.ui.position.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
$.ui = $.ui || {};
1313

1414
var horizontalPositions = /left|center|right/,
15-
horizontalDefault = "center",
1615
verticalPositions = /top|center|bottom/,
17-
verticalDefault = "center",
16+
center = "center",
1817
_position = $.fn.position,
1918
_offset = $.fn.offset;
2019

@@ -58,13 +57,13 @@ $.fn.position = function( options ) {
5857
var pos = ( options[this] || "" ).split( " " );
5958
if ( pos.length === 1) {
6059
pos = horizontalPositions.test( pos[0] ) ?
61-
pos.concat( [verticalDefault] ) :
60+
pos.concat( [center] ) :
6261
verticalPositions.test( pos[0] ) ?
63-
[ horizontalDefault ].concat( pos ) :
64-
[ horizontalDefault, verticalDefault ];
62+
[ center ].concat( pos ) :
63+
[ center, center ];
6564
}
66-
pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : horizontalDefault;
67-
pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : verticalDefault;
65+
pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
66+
pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
6867
options[ this ] = pos;
6968
});
7069

@@ -82,13 +81,13 @@ $.fn.position = function( options ) {
8281

8382
if ( options.at[0] === "right" ) {
8483
basePosition.left += targetWidth;
85-
} else if (options.at[0] === horizontalDefault ) {
84+
} else if (options.at[0] === center ) {
8685
basePosition.left += targetWidth / 2;
8786
}
8887

8988
if ( options.at[1] === "bottom" ) {
9089
basePosition.top += targetHeight;
91-
} else if ( options.at[1] === verticalDefault ) {
90+
} else if ( options.at[1] === center ) {
9291
basePosition.top += targetHeight / 2;
9392
}
9493

@@ -103,13 +102,13 @@ $.fn.position = function( options ) {
103102

104103
if ( options.my[0] === "right" ) {
105104
position.left -= elemWidth;
106-
} else if ( options.my[0] === horizontalDefault ) {
105+
} else if ( options.my[0] === center ) {
107106
position.left -= elemWidth / 2;
108107
}
109108

110109
if ( options.my[1] === "bottom" ) {
111110
position.top -= elemHeight;
112-
} else if ( options.my[1] === verticalDefault ) {
111+
} else if ( options.my[1] === center ) {
113112
position.top -= elemHeight / 2;
114113
}
115114

@@ -154,7 +153,7 @@ $.ui.position = {
154153

155154
flip: {
156155
left: function( position, data ) {
157-
if ( data.at[0] === "center" ) {
156+
if ( data.at[0] === center ) {
158157
return;
159158
}
160159
var win = $( window ),
@@ -175,7 +174,7 @@ $.ui.position = {
175174
0;
176175
},
177176
top: function( position, data ) {
178-
if ( data.at[1] === "center" ) {
177+
if ( data.at[1] === center ) {
179178
return;
180179
}
181180
var win = $( window ),

0 commit comments

Comments
 (0)