Skip to content
This repository
Browse code

updating to jQueryUI position v1.10.0

  • Loading branch information...
commit 82e3b5433ba4defd3066a5fb2a84eafca6a7b41a 1 parent cb5fac2
Rodney Rehm authored January 19, 2013

Showing 1 changed file with 40 additions and 60 deletions. Show diff stats Hide diff stats

  1. 100  src/jquery.ui.position.js
100  src/jquery.ui.position.js
... ...
@@ -1,12 +1,12 @@
1 1
 /*!
2  
- * jQuery UI Position 1.9.0-RC1
  2
+ * jQuery UI Position v1.10.0
3 3
  * http://jqueryui.com
4 4
  *
5  
- * Copyright 2012 jQuery Foundation and other contributors
  5
+ * Copyright 2013 jQuery Foundation and other contributors
6 6
  * Released under the MIT license.
7 7
  * http://jquery.org/license
8 8
  *
9  
- * http://docs.jquery.com/UI/Position
  9
+ * http://api.jqueryui.com/position/
10 10
  */
11 11
 (function( $, undefined ) {
12 12
 
@@ -29,10 +29,41 @@ function getOffsets( offsets, width, height ) {
29 29
 		parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
30 30
 	];
31 31
 }
  32
+
32 33
 function parseCss( element, property ) {
33 34
 	return parseInt( $.css( element, property ), 10 ) || 0;
34 35
 }
35 36
 
  37
+function getDimensions( elem ) {
  38
+	var raw = elem[0];
  39
+	if ( raw.nodeType === 9 ) {
  40
+		return {
  41
+			width: elem.width(),
  42
+			height: elem.height(),
  43
+			offset: { top: 0, left: 0 }
  44
+		};
  45
+	}
  46
+	if ( $.isWindow( raw ) ) {
  47
+		return {
  48
+			width: elem.width(),
  49
+			height: elem.height(),
  50
+			offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  51
+		};
  52
+	}
  53
+	if ( raw.preventDefault ) {
  54
+		return {
  55
+			width: 0,
  56
+			height: 0,
  57
+			offset: { top: raw.pageY, left: raw.pageX }
  58
+		};
  59
+	}
  60
+	return {
  61
+		width: elem.outerWidth(),
  62
+		height: elem.outerHeight(),
  63
+		offset: elem.offset()
  64
+	};
  65
+}
  66
+
36 67
 $.position = {
37 68
 	scrollbarWidth: function() {
38 69
 		if ( cachedScrollbarWidth !== undefined ) {
@@ -91,32 +122,21 @@ $.fn.position = function( options ) {
91 122
 	// make a copy, we don't want to modify arguments
92 123
 	options = $.extend( {}, options );
93 124
 
94  
-	var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
  125
+	var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
95 126
 		target = $( options.of ),
96 127
 		within = $.position.getWithinInfo( options.within ),
97 128
 		scrollInfo = $.position.getScrollInfo( within ),
98  
-		targetElem = target[0],
99 129
 		collision = ( options.collision || "flip" ).split( " " ),
100 130
 		offsets = {};
101 131
 
102  
-	if ( targetElem.nodeType === 9 ) {
103  
-		targetWidth = target.width();
104  
-		targetHeight = target.height();
105  
-		targetOffset = { top: 0, left: 0 };
106  
-	} else if ( $.isWindow( targetElem ) ) {
107  
-		targetWidth = target.width();
108  
-		targetHeight = target.height();
109  
-		targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
110  
-	} else if ( targetElem.preventDefault ) {
  132
+	dimensions = getDimensions( target );
  133
+	if ( target[0].preventDefault ) {
111 134
 		// force left top to allow flipping
112 135
 		options.at = "left top";
113  
-		targetWidth = targetHeight = 0;
114  
-		targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
115  
-	} else {
116  
-		targetWidth = target.outerWidth();
117  
-		targetHeight = target.outerHeight();
118  
-		targetOffset = target.offset();
119 136
 	}
  137
+	targetWidth = dimensions.width;
  138
+	targetHeight = dimensions.height;
  139
+	targetOffset = dimensions.offset;
120 140
 	// clone to reuse original targetOffset later
121 141
 	basePosition = $.extend( {}, targetOffset );
122 142
 
@@ -230,10 +250,6 @@ $.fn.position = function( options ) {
230 250
 			}
231 251
 		});
232 252
 
233  
-		if ( $.fn.bgiframe ) {
234  
-			elem.bgiframe();
235  
-		}
236  
-
237 253
 		if ( options.using ) {
238 254
 			// adds feedback as second argument to using callback, if present
239 255
 			using = function( props ) {
@@ -478,40 +494,4 @@ $.ui.position = {
478 494
 	testElementParent.removeChild( testElement );
479 495
 })();
480 496
 
481  
-// DEPRECATED
482  
-if ( $.uiBackCompat !== false ) {
483  
-	// offset option
484  
-	(function( $ ) {
485  
-		var _position = $.fn.position;
486  
-		$.fn.position = function( options ) {
487  
-			if ( !options || !options.offset ) {
488  
-				return _position.call( this, options );
489  
-			}
490  
-			var offset = options.offset.split( " " ),
491  
-				at = options.at.split( " " );
492  
-			if ( offset.length === 1 ) {
493  
-				offset[ 1 ] = offset[ 0 ];
494  
-			}
495  
-			if ( /^\d/.test( offset[ 0 ] ) ) {
496  
-				offset[ 0 ] = "+" + offset[ 0 ];
497  
-			}
498  
-			if ( /^\d/.test( offset[ 1 ] ) ) {
499  
-				offset[ 1 ] = "+" + offset[ 1 ];
500  
-			}
501  
-			if ( at.length === 1 ) {
502  
-				if ( /left|center|right/.test( at[ 0 ] ) ) {
503  
-					at[ 1 ] = "center";
504  
-				} else {
505  
-					at[ 1 ] = at[ 0 ];
506  
-					at[ 0 ] = "center";
507  
-				}
508  
-			}
509  
-			return _position.call( this, $.extend( options, {
510  
-				at: at[ 0 ] + offset[ 0 ] + " " + at[ 1 ] + offset[ 1 ],
511  
-				offset: undefined
512  
-			} ) );
513  
-		};
514  
-	}( jQuery ) );
515  
-}
516  
-
517 497
 }( jQuery ) );

0 notes on commit 82e3b54

Please sign in to comment.
Something went wrong with that request. Please try again.