Built files accidentally included.
[jquery.git] / plugins / center / center.js
1 /**
2  * Takes all matched elements and centers them, absolutely, 
3  * within the context of their parent element. Great for 
4  * doing slideshows.
5  *   $("div img").center();
6  */
7 $.fn.center = function(f) {
8         return this.each(function(){
9                 if ( !f && this.nodeName == 'IMG' &&
10                                  !this.offsetWidth && !this.offsetHeight ) {
11                         var self = this;
12                         setTimeout(function(){
13                                 $(self).center(true);
14                         }, 13);
15                 } else {
16                         var s = this.style;
17                         var p = this.parentNode;
18                         if ( $.css(p,"position") == 'static' ) {
19                                 p.style.position = 'relative';
20                         }
21                         s.position = 'absolute';
22                         s.left = (($.css(p,"width") - $.css(this,"width"))/2) + "px";
23                         s.top = (($.css(p,"height") - $.css(this,"height"))/2) + "px";
24                 }
25   });
26 };