Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
434 jpm 1
/**
2
 * jQuery lightBox plugin
3
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
4
 * and adapted to me for use like a plugin from jQuery.
5
 * @name jquery-lightbox-0.4.js
6
 * @author Leandro Vieira Pinho - http://leandrovieira.com
7
 * @version 0.4
8
 * @date November 17, 2007
9
 * @category jQuery plugin
10
 * @copyright (c) 2007 Leandro Vieira Pinho (leandrovieira.com)
11
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
12
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
13
 */
14
 
15
// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
16
(function($) {
17
	/**
18
	 * $ is an alias to jQuery object
19
	 *
20
	 */
21
	$.fn.lightBox = function(settings) {
22
		// Settings to configure the jQuery lightBox plugin how you like
23
		settings = jQuery.extend({
24
			// Configuration related to overlay
25
			overlayBgColor: 		'#000',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
26
			overlayOpacity:			0.8,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
27
			// Configuration related to images
28
			imageLoading:			'actions/galerie/presentation/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
29
			imageBtnPrev:			'actions/galerie/presentation/images/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
30
			imageBtnNext:			'actions/galerie/presentation/images/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
31
			imageBtnClose:			'actions/galerie/presentation/images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
32
			imageBlank:				'actions/galerie/presentation/images/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
33
			// Configuration related to container image box
34
			containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
35
			containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
36
			// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
37
			txtImage:				'Image',	// (string) Specify text "Image"
38
			txtOf:					'of',		// (string) Specify text "of"
39
			// Configuration related to keyboard navigation
40
			keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
41
			keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
42
			keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
43
			// Don´t alter these variables in any way
44
			imageArray:				[],
45
			activeImage:			0
46
		},settings);
47
		// Caching the jQuery object with all elements matched
48
		var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
49
		/**
50
		 * Initializing the plugin calling the start function
51
		 *
52
		 * @return boolean false
53
		 */
54
		function _initialize() {
55
			_start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
56
			return false; // Avoid the browser following the link
57
		}
58
		/**
59
		 * Start the jQuery lightBox plugin
60
		 *
61
		 * @param object objClicked The object (link) whick the user have clicked
62
		 * @param object jQueryMatchedObj The jQuery object with all elements matched
63
		 */
64
		function _start(objClicked,jQueryMatchedObj) {
65
			// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
66
			$('embed, object, select').css({ 'visibility' : 'hidden' });
67
			// Call the function to create the markup structure; style some elements; assign events in some elements.
68
			_set_interface();
69
			// Unset total images in imageArray
70
			settings.imageArray.length = 0;
71
			// Unset image active information
72
			settings.activeImage = 0;
73
			// We have an image set? Or just an image? Let´s see it.
74
			if ( jQueryMatchedObj.length == 1 ) {
75
				settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
76
			} else {
77
				// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references
78
				for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
79
					settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
80
				}
81
			}
82
			while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
83
				settings.activeImage++;
84
			}
85
			// Call the function that prepares image exibition
86
			_set_image_to_view();
87
		}
88
		/**
89
		 * Create the jQuery lightBox plugin interface
90
		 *
91
		 * The HTML markup will be like that:
92
			<div id="jquery-overlay"></div>
93
			<div id="jquery-lightbox">
94
				<div id="lightbox-container-image-box">
95
					<div id="lightbox-container-image">
96
						<img src="../fotos/XX.jpg" id="lightbox-image">
97
						<div id="lightbox-nav">
98
							<a href="#" id="lightbox-nav-btnPrev"></a>
99
							<a href="#" id="lightbox-nav-btnNext"></a>
100
						</div>
101
						<div id="lightbox-loading">
102
							<a href="#" id="lightbox-loading-link">
103
								<img src="../images/lightbox-ico-loading.gif">
104
							</a>
105
						</div>
106
					</div>
107
				</div>
108
				<div id="lightbox-container-image-data-box">
109
					<div id="lightbox-container-image-data">
110
						<div id="lightbox-image-details">
111
							<span id="lightbox-image-details-caption"></span>
112
							<span id="lightbox-image-details-currentNumber"></span>
113
						</div>
114
						<div id="lightbox-secNav">
115
							<a href="#" id="lightbox-secNav-btnClose">
116
								<img src="../images/lightbox-btn-close.gif">
117
							</a>
118
						</div>
119
					</div>
120
				</div>
121
			</div>
122
		 *
123
		 */
124
		function _set_interface() {
125
			// Apply the HTML markup into body tag
126
			$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');
127
			// Get page sizes
128
			var arrPageSizes = ___getPageSize();
129
			// Style overlay and show it
130
			$('#jquery-overlay').css({
131
				backgroundColor:	settings.overlayBgColor,
132
				opacity:			settings.overlayOpacity,
133
				width:				arrPageSizes[0],
134
				height:				arrPageSizes[1]
135
			}).fadeIn();
136
			// Get page scroll
137
			var arrPageScroll = ___getPageScroll();
138
			// Calculate top and left offset for the jquery-lightbox div object and show it
139
			$('#jquery-lightbox').css({
140
				top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
141
				left:	arrPageScroll[0]
142
			}).show();
143
			// Assigning click events in elements to close overlay
144
			$('#jquery-overlay,#jquery-lightbox').click(function() {
145
				_finish();
146
			});
147
			// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
148
			$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
149
				_finish();
150
				return false;
151
			});
152
			// If window was resized, calculate the new overlay dimensions
153
			$(window).resize(function() {
154
				// Get page sizes
155
				var arrPageSizes = ___getPageSize();
156
				// Style overlay and show it
157
				$('#jquery-overlay').css({
158
					width:		arrPageSizes[0],
159
					height:		arrPageSizes[1]
160
				});
161
				// Get page scroll
162
				var arrPageScroll = ___getPageScroll();
163
				// Calculate top and left offset for the jquery-lightbox div object and show it
164
				$('#jquery-lightbox').css({
165
					top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
166
					left:	arrPageScroll[0]
167
				});
168
			});
169
		}
170
		/**
171
		 * Prepares image exibition; doing a image´s preloader to calculate it´s size
172
		 *
173
		 */
174
		function _set_image_to_view() { // show the loading
175
			// Show the loading
176
			$('#lightbox-loading').show();
177
			// Hide some elements
178
			$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
179
			// Image preload process
180
			var objImagePreloader = new Image();
181
			objImagePreloader.onload = function() {
182
				$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
183
				// Perfomance an effect in the image container resizing it
184
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
185
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
186
				objImagePreloader.onload=function(){};
187
			}
188
			objImagePreloader.src = settings.imageArray[settings.activeImage][0];
189
		};
190
		/**
191
		 * Perfomance an effect in the image container resizing it
192
		 *
193
		 * @param integer intImageWidth The image´s width that will be showed
194
		 * @param integer intImageHeight The image´s height that will be showed
195
		 */
196
		function _resize_container_image_box(intImageWidth,intImageHeight) {
197
			// Get current width and height
198
			var intCurrentWidth = $('#lightbox-container-image-box').width();
199
			var intCurrentHeight = $('#lightbox-container-image-box').height();
200
			// Get the width and height of the selected image plus the padding
201
			var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image´s width and the left and right padding value
202
			var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image´s height and the left and right padding value
203
			// Diferences
204
			var intDiffW = intCurrentWidth - intWidth;
205
			var intDiffH = intCurrentHeight - intHeight;
206
			// Perfomance the effect
207
			$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
208
			if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
209
				if ( $.browser.msie ) {
210
					___pause(250);
211
				} else {
212
					___pause(100);
213
				}
214
			}
215
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
216
			$('#lightbox-container-image-data-box').css({ width: intImageWidth });
217
		};
218
		/**
219
		 * Show the prepared image
220
		 *
221
		 */
222
		function _show_image() {
223
			$('#lightbox-loading').hide();
224
			$('#lightbox-image').fadeIn(function() {
225
				_show_image_data();
226
				_set_navigation();
227
			});
228
			_preload_neighbor_images();
229
		};
230
		/**
231
		 * Show the image information
232
		 *
233
		 */
234
		function _show_image_data() {
235
			$('#lightbox-container-image-data-box').slideDown('fast');
236
			$('#lightbox-image-details-caption').hide();
237
			if ( settings.imageArray[settings.activeImage][1] ) {
238
				$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
239
			}
240
			// If we have a image set, display 'Image X of X'
241
			if ( settings.imageArray.length > 1 ) {
242
				$('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
243
			}
244
		}
245
		/**
246
		 * Display the button navigations
247
		 *
248
		 */
249
		function _set_navigation() {
250
			$('#lightbox-nav').show();
251
 
252
			// Instead to define this configuration in CSS file, we define here. And it´s need to IE. Just.
253
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
254
 
255
			// Show the prev button, if not the first image in set
256
			if ( settings.activeImage != 0 ) {
257
				// Show the images button for Next buttons
258
				$('#lightbox-nav-btnPrev').unbind().hover(function() {
259
					$(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
260
				},function() {
261
					$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
262
				}).show().bind('click',function() {
263
					settings.activeImage = settings.activeImage - 1;
264
					_set_image_to_view();
265
					return false;
266
				});
267
			}
268
 
269
			// Show the next button, if not the last image in set
270
			if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
271
				// Show the images button for Next buttons
272
				$('#lightbox-nav-btnNext').unbind().hover(function() {
273
					$(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
274
				},function() {
275
					$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
276
				}).show().bind('click',function() {
277
					settings.activeImage = settings.activeImage + 1;
278
					_set_image_to_view();
279
					return false;
280
				});
281
			}
282
			// Enable keyboard navigation
283
			_enable_keyboard_navigation();
284
		}
285
		/**
286
		 * Enable a support to keyboard navigation
287
		 *
288
		 */
289
		function _enable_keyboard_navigation() {
290
			$(document).keydown(function(objEvent) {
291
				_keyboard_action(objEvent);
292
			});
293
		}
294
		/**
295
		 * Disable the support to keyboard navigation
296
		 *
297
		 */
298
		function _disable_keyboard_navigation() {
299
			$(document).unbind();
300
		}
301
		/**
302
		 * Perform the keyboard actions
303
		 *
304
		 */
305
		function _keyboard_action(objEvent) {
306
			// To ie
307
			if ( objEvent == null ) {
308
				keycode = event.keyCode;
309
				escapeKey = 27;
310
			// To Mozilla
311
			} else {
312
				keycode = objEvent.keyCode;
313
				escapeKey = objEvent.DOM_VK_ESCAPE;
314
			}
315
			// Get the key in lower case form
316
			key = String.fromCharCode(keycode).toLowerCase();
317
			// Verify the keys to close the ligthBox
318
			if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
319
				_finish();
320
			}
321
			// Verify the key to show the previous image
322
			if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
323
				// If we´re not showing the first image, call the previous
324
				if ( settings.activeImage != 0 ) {
325
					settings.activeImage = settings.activeImage - 1;
326
					_set_image_to_view();
327
					_disable_keyboard_navigation();
328
				}
329
			}
330
			// Verify the key to show the next image
331
			if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
332
				// If we´re not showing the last image, call the next
333
				if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
334
					settings.activeImage = settings.activeImage + 1;
335
					_set_image_to_view();
336
					_disable_keyboard_navigation();
337
				}
338
			}
339
		}
340
		/**
341
		 * Preload prev and next images being showed
342
		 *
343
		 */
344
		function _preload_neighbor_images() {
345
			if ( (settings.imageArray.length -1) > settings.activeImage ) {
346
				objNext = new Image();
347
				objNext.src = settings.imageArray[settings.activeImage + 1][0];
348
			}
349
			if ( settings.activeImage > 0 ) {
350
				objPrev = new Image();
351
				objPrev.src = settings.imageArray[settings.activeImage -1][0];
352
			}
353
		}
354
		/**
355
		 * Remove jQuery lightBox plugin HTML markup
356
		 *
357
		 */
358
		function _finish() {
359
			$('#jquery-lightbox').remove();
360
			$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
361
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
362
			$('embed, object, select').css({ 'visibility' : 'visible' });
363
		}
364
		/**
365
		 / THIRD FUNCTION
366
		 * getPageSize() by quirksmode.com
367
		 *
368
		 * @return Array Return an array with page width, height and window width, height
369
		 */
370
		function ___getPageSize() {
371
			var xScroll, yScroll;
372
			if (window.innerHeight && window.scrollMaxY) {
373
				xScroll = window.innerWidth + window.scrollMaxX;
374
				yScroll = window.innerHeight + window.scrollMaxY;
375
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
376
				xScroll = document.body.scrollWidth;
377
				yScroll = document.body.scrollHeight;
378
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
379
				xScroll = document.body.offsetWidth;
380
				yScroll = document.body.offsetHeight;
381
			}
382
			var windowWidth, windowHeight;
383
			if (self.innerHeight) {	// all except Explorer
384
				if(document.documentElement.clientWidth){
385
					windowWidth = document.documentElement.clientWidth;
386
				} else {
387
					windowWidth = self.innerWidth;
388
				}
389
				windowHeight = self.innerHeight;
390
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
391
				windowWidth = document.documentElement.clientWidth;
392
				windowHeight = document.documentElement.clientHeight;
393
			} else if (document.body) { // other Explorers
394
				windowWidth = document.body.clientWidth;
395
				windowHeight = document.body.clientHeight;
396
			}
397
			// for small pages with total height less then height of the viewport
398
			if(yScroll < windowHeight){
399
				pageHeight = windowHeight;
400
			} else {
401
				pageHeight = yScroll;
402
			}
403
			// for small pages with total width less then width of the viewport
404
			if(xScroll < windowWidth){
405
				pageWidth = xScroll;
406
			} else {
407
				pageWidth = windowWidth;
408
			}
409
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
410
			return arrayPageSize;
411
		};
412
		/**
413
		 / THIRD FUNCTION
414
		 * getPageScroll() by quirksmode.com
415
		 *
416
		 * @return Array Return an array with x,y page scroll values.
417
		 */
418
		function ___getPageScroll() {
419
			var xScroll, yScroll;
420
			if (self.pageYOffset) {
421
				yScroll = self.pageYOffset;
422
				xScroll = self.pageXOffset;
423
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
424
				yScroll = document.documentElement.scrollTop;
425
				xScroll = document.documentElement.scrollLeft;
426
			} else if (document.body) {// all other Explorers
427
				yScroll = document.body.scrollTop;
428
				xScroll = document.body.scrollLeft;
429
			}
430
			arrayPageScroll = new Array(xScroll,yScroll)
431
			return arrayPageScroll;
432
		};
433
		 /**
434
		  * Stop the code execution from a escified time in milisecond
435
		  *
436
		  */
437
		 function ___pause(ms) {
438
			var date = new Date();
439
			curDate = null;
440
			do { var curDate = new Date(); }
441
			while ( curDate - date < ms);
442
		 };
443
		// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
444
		return this.unbind('click').click(_initialize);
445
	};
446
})(jQuery); // Call and execute the function immediately passing the jQuery object
447
 
448
/**
449
 * jQuery SliderViewer Plugin
450
 * @name jquery.slideviewer.1.1.js
451
 * @author Gian Carlo Mingati - http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html
452
 * @version 1.1
453
 * @date October 6, 2007
454
 * @category jQuery plugin
455
 * @copyright (c) 2007 Gian Carlo Mingati (gcmingati.net)
456
 * @license ?
457
 * @example Visit http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html for more informations about this jQuery plugin
458
 */
459
 
460
jQuery(function(){
461
	// Nous cachons les images si le javascript est activé!
462
	jQuery("div.svw").removeClass("galerie");
463
	jQuery("div.svw").css({
464
		'width' : '50px',
465
		'height' : '20px',
466
		'background' : '#fff'
467
		});
468
	jQuery("div.svw ul").css({
469
		'position' : 'relative',
470
		'left' : '-999em'
471
		});
472
	jQuery("div.svw").prepend("<img src='http://www.gcmingati.net/wordpress/wp-content/uploads/svwloader.gif' class='ldrgif' alt='loading...'/ >");
473
});
474
var j = 0;
475
jQuery.fn.slideView = function(settings) {
476
	  settings = jQuery.extend({
477
     easeFunc: "easeInOutExpo", /* <-- easing function names changed in jquery.easing.1.2.js */
478
     easeTime: 750,
479
     toolTip: false
480
  }, settings);
481
	return this.each(function(){
482
		var container = jQuery(this);
483
		container.find("img.ldrgif").remove(); // removes the preloader gif
484
		container.removeClass("svw").addClass("stripViewer");
485
		var pictWidth = container.find("li").find("img").width();
486
		var pictHeight = container.find("li").find("img").height();
487
		var pictEls = container.find("li").size();
488
		var stripViewerWidth = pictWidth*pictEls;
489
		container.find("ul").css("width" , stripViewerWidth); //assegnamo la larghezza alla lista UL
490
		container.css("width" , pictWidth);
491
		container.css("height" , pictHeight);
492
		container.each(function(i) {
493
			jQuery(this).after("<div class='stripTransmitter' id='stripTransmitter" + j + "'><ul><\/ul><\/div>");
494
			jQuery(this).find("li").each(function(n) {
495
						jQuery("div#stripTransmitter" + j + " ul").append("<li><a title='" + jQuery(this).find("img").attr("alt") + "' href='#'>"+(n+1)+"<\/a><\/li>");
496
				});
497
			jQuery("div#stripTransmitter" + j + " a").each(function(z) {
498
				jQuery(this).bind("click", function(){
499
				jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current"); // wow!
500
				var cnt = - (pictWidth*z);
501
				jQuery(this).parent().parent().parent().prev().find("ul").animate({ left: cnt}, settings.easeTime, settings.easeFunc);
502
				return false;
503
				   });
504
				});
505
			jQuery("div#stripTransmitter" + j).css("width" , pictWidth);
506
			jQuery("div#stripTransmitter" + j + " a:eq(0)").addClass("current");
507
			if(settings.toolTip){
508
			container.next(".stripTransmitter ul").find("a").Tooltip({
509
				track: true,
510
				delay: 0,
511
				showURL: false,
512
				showBody: false
513
				});
514
			}
515
			});
516
		j++;
517
  });
518
};
519
 
520
/**
521
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
522
 *
523
 * Uses the built In easIng capabilities added In jQuery 1.1
524
 * to offer multiple easIng options
525
 *
526
 * @copyright (c) 2007 George Smith
527
 * @license Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
528
 */
529
 
530
// t: current time, b: begInnIng value, c: change In value, d: duration
531
jQuery.easing['jswing'] = jQuery.easing['swing'];
532
 
533
jQuery.extend( jQuery.easing,
534
{
535
	def: 'easeOutQuad',
536
	swing: function (x, t, b, c, d) {
537
		//alert(jQuery.easing.default);
538
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
539
	},
540
	easeInQuad: function (x, t, b, c, d) {
541
		return c*(t/=d)*t + b;
542
	},
543
	easeOutQuad: function (x, t, b, c, d) {
544
		return -c *(t/=d)*(t-2) + b;
545
	},
546
	easeInOutQuad: function (x, t, b, c, d) {
547
		if ((t/=d/2) < 1) return c/2*t*t + b;
548
		return -c/2 * ((--t)*(t-2) - 1) + b;
549
	},
550
	easeInCubic: function (x, t, b, c, d) {
551
		return c*(t/=d)*t*t + b;
552
	},
553
	easeOutCubic: function (x, t, b, c, d) {
554
		return c*((t=t/d-1)*t*t + 1) + b;
555
	},
556
	easeInOutCubic: function (x, t, b, c, d) {
557
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
558
		return c/2*((t-=2)*t*t + 2) + b;
559
	},
560
	easeInQuart: function (x, t, b, c, d) {
561
		return c*(t/=d)*t*t*t + b;
562
	},
563
	easeOutQuart: function (x, t, b, c, d) {
564
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
565
	},
566
	easeInOutQuart: function (x, t, b, c, d) {
567
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
568
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
569
	},
570
	easeInQuint: function (x, t, b, c, d) {
571
		return c*(t/=d)*t*t*t*t + b;
572
	},
573
	easeOutQuint: function (x, t, b, c, d) {
574
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
575
	},
576
	easeInOutQuint: function (x, t, b, c, d) {
577
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
578
		return c/2*((t-=2)*t*t*t*t + 2) + b;
579
	},
580
	easeInSine: function (x, t, b, c, d) {
581
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
582
	},
583
	easeOutSine: function (x, t, b, c, d) {
584
		return c * Math.sin(t/d * (Math.PI/2)) + b;
585
	},
586
	easeInOutSine: function (x, t, b, c, d) {
587
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
588
	},
589
	easeInExpo: function (x, t, b, c, d) {
590
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
591
	},
592
	easeOutExpo: function (x, t, b, c, d) {
593
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
594
	},
595
	easeInOutExpo: function (x, t, b, c, d) {
596
		if (t==0) return b;
597
		if (t==d) return b+c;
598
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
599
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
600
	},
601
	easeInCirc: function (x, t, b, c, d) {
602
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
603
	},
604
	easeOutCirc: function (x, t, b, c, d) {
605
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
606
	},
607
	easeInOutCirc: function (x, t, b, c, d) {
608
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
609
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
610
	},
611
	easeInElastic: function (x, t, b, c, d) {
612
		var s=1.70158;var p=0;var a=c;
613
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
614
		if (a < Math.abs(c)) { a=c; var s=p/4; }
615
		else var s = p/(2*Math.PI) * Math.asin (c/a);
616
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
617
	},
618
	easeOutElastic: function (x, t, b, c, d) {
619
		var s=1.70158;var p=0;var a=c;
620
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
621
		if (a < Math.abs(c)) { a=c; var s=p/4; }
622
		else var s = p/(2*Math.PI) * Math.asin (c/a);
623
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
624
	},
625
	easeInOutElastic: function (x, t, b, c, d) {
626
		var s=1.70158;var p=0;var a=c;
627
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
628
		if (a < Math.abs(c)) { a=c; var s=p/4; }
629
		else var s = p/(2*Math.PI) * Math.asin (c/a);
630
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
631
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
632
	},
633
	easeInBack: function (x, t, b, c, d, s) {
634
		if (s == undefined) s = 1.70158;
635
		return c*(t/=d)*t*((s+1)*t - s) + b;
636
	},
637
	easeOutBack: function (x, t, b, c, d, s) {
638
		if (s == undefined) s = 1.70158;
639
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
640
	},
641
	easeInOutBack: function (x, t, b, c, d, s) {
642
		if (s == undefined) s = 1.70158;
643
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
644
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
645
	},
646
	easeInBounce: function (x, t, b, c, d) {
647
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
648
	},
649
	easeOutBounce: function (x, t, b, c, d) {
650
		if ((t/=d) < (1/2.75)) {
651
			return c*(7.5625*t*t) + b;
652
		} else if (t < (2/2.75)) {
653
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
654
		} else if (t < (2.5/2.75)) {
655
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
656
		} else {
657
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
658
		}
659
	},
660
	easeInOutBounce: function (x, t, b, c, d) {
661
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
662
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
663
	}
664
});
665
/*
666
 * jQuery Tooltip plugin 1.1
667
 *
668
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
669
 *
670
 * Copyright (c) 2006 Jörn Zaefferer, Stefan Petre
671
 *
672
 * Dual licensed under the MIT and GPL licenses:
673
 *   http://www.opensource.org/licenses/mit-license.php
674
 *   http://www.gnu.org/licenses/gpl.html
675
 *
676
 * Revision: $Id: jquery.tooltip.js 2237 2007-07-04 19:11:15Z joern.zaefferer $
677
 *
678
 */
679
 
680
/**
681
 * Display a customized tooltip instead of the default one
682
 * for every selected element. The tooltip behaviour mimics
683
 * the default one, but lets you style the tooltip and
684
 * specify the delay before displaying it. In addition, it displays the
685
 * href value, if it is available.
686
 *
687
 * Requires dimensions plugin.
688
 *
689
 * When used on a page with select elements, include the bgiframe plugin. It is used if present.
690
 *
691
 * To style the tooltip, use these selectors in your stylesheet:
692
 *
693
 * #tooltip - The tooltip container
694
 *
695
 * #tooltip h3 - The tooltip title
696
 *
697
 * #tooltip div.body - The tooltip body, shown when using showBody
698
 *
699
 * #tooltip div.url - The tooltip url, shown when using showURL
700
 *
701
 *
702
 * @example $('a, input, img').Tooltip();
703
 * @desc Shows tooltips for anchors, inputs and images, if they have a title
704
 *
705
 * @example $('label').Tooltip({
706
 *   delay: 0,
707
 *   track: true,
708
 *   event: "click"
709
 * });
710
 * @desc Shows tooltips for labels with no delay, tracking mousemovement, displaying the tooltip when the label is clicked.
711
 *
712
 * @example // modify global settings
713
 * $.extend($.fn.Tooltip.defaults, {
714
 * 	track: true,
715
 * 	delay: 0,
716
 * 	showURL: false,
717
 * 	showBody: " - ",
718
 *  fixPNG: true
719
 * });
720
 * // setup fancy tooltips
721
 * $('a.pretty').Tooltip({
722
 * 	 extraClass: "fancy"
723
 * });
724
 $('img.pretty').Tooltip({
725
 * 	 extraClass: "fancy-img",
726
 * });
727
 * @desc This example starts with modifying the global settings, applying them to all following Tooltips; Afterwards, Tooltips for anchors with class pretty are created with an extra class for the Tooltip: "fancy" for anchors, "fancy-img" for images
728
 *
729
 * @param Object settings (optional) Customize your Tooltips
730
 * @option Number delay The number of milliseconds before a tooltip is display. Default: 250
731
 * @option Boolean track If true, let the tooltip track the mousemovement. Default: false
732
 * @option Boolean showURL If true, shows the href or src attribute within p.url. Defaul: true
733
 * @option String showBody If specified, uses the String to split the title, displaying the first part in the h3 tag, all following in the p.body tag, separated with <br/>s. Default: null
734
 * @option String extraClass If specified, adds the class to the tooltip helper. Default: null
735
 * @option Boolean fixPNG If true, fixes transparent PNGs in IE. Default: false
736
 * @option Function bodyHandler If specified its called to format the tooltip-body, hiding the title-part. Default: none
737
 * @option Number top The top-offset for the tooltip position. Default: 15
738
 * @option Number left The left-offset for the tooltip position. Default: 15
739
 *
740
 * @name Tooltip
741
 * @type jQuery
742
 * @cat Plugins/Tooltip
743
 * @author Jörn Zaefferer (http://bassistance.de)
744
 */
745
 
746
/**
747
 * A global flag to disable all tooltips.
748
 *
749
 * @example $("button.openModal").click(function() {
750
 *   $.Tooltip.blocked = true;
751
 *   // do some other stuff, eg. showing a modal dialog
752
 *   $.Tooltip.blocked = false;
753
 * });
754
 *
755
 * @property
756
 * @name $.Tooltip.blocked
757
 * @type Boolean
758
 * @cat Plugins/Tooltip
759
 */
760
 
761
/**
762
 * Global defaults for tooltips. Apply to all calls to the Tooltip plugin after modifying  the defaults.
763
 *
764
 * @example $.extend($.Tooltip.defaults, {
765
 *   track: true,
766
 *   delay: 0
767
 * });
768
 *
769
 * @property
770
 * @name $.Tooltip.defaults
771
 * @type Map
772
 * @cat Plugins/Tooltip
773
 */
774
(function($) {
775
 
776
	// the tooltip element
777
	var helper = {},
778
		// the current tooltipped element
779
		current,
780
		// the title of the current element, used for restoring
781
		title,
782
		// timeout id for delayed tooltips
783
		tID,
784
		// IE 5.5 or 6
785
		IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
786
		// flag for mouse tracking
787
		track = false;
788
 
789
	$.Tooltip = {
790
		blocked: false,
791
		defaults: {
792
			delay: 200,
793
			showURL: true,
794
			extraClass: "",
795
			top: 15,
796
			left: 15
797
		},
798
		block: function() {
799
			$.Tooltip.blocked = !$.Tooltip.blocked;
800
		}
801
	};
802
 
803
	$.fn.extend({
804
		Tooltip: function(settings) {
805
			settings = $.extend({}, $.Tooltip.defaults, settings);
806
			createHelper();
807
			return this.each(function() {
808
					this.tSettings = settings;
809
					// copy tooltip into its own expando and remove the title
810
					this.tooltipText = this.title;
811
					$(this).removeAttr("title");
812
					// also remove alt attribute to prevent default tooltip in IE
813
					this.alt = "";
814
				})
815
				.hover(save, hide)
816
				.click(hide);
817
		},
818
		fixPNG: IE ? function() {
819
			return this.each(function () {
820
				var image = $(this).css('backgroundImage');
821
				if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
822
					image = RegExp.$1;
823
					$(this).css({
824
						'backgroundImage': 'none',
825
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
826
					}).each(function () {
827
						var position = $(this).css('position');
828
						if (position != 'absolute' && position != 'relative')
829
							$(this).css('position', 'relative');
830
					});
831
				}
832
			});
833
		} : function() { return this; },
834
		unfixPNG: IE ? function() {
835
			return this.each(function () {
836
				$(this).css({'filter': '', backgroundImage: ''});
837
			});
838
		} : function() { return this; },
839
		hideWhenEmpty: function() {
840
			return this.each(function() {
841
				$(this)[ $(this).html() ? "show" : "hide" ]();
842
			});
843
		},
844
		url: function() {
845
			return this.attr('href') || this.attr('src');
846
		}
847
	});
848
 
849
	function createHelper() {
850
		// there can be only one tooltip helper
851
		if( helper.parent )
852
			return;
853
		// create the helper, h3 for title, div for url
854
		helper.parent = $('<div id="tooltip"><h3></h3><div class="body"></div><div class="url"></div></div>')
855
			// hide it at first
856
			.hide()
857
			// add to document
858
			.appendTo('body');
859
 
860
		// apply bgiframe if available
861
		if ( $.fn.bgiframe )
862
			helper.parent.bgiframe();
863
 
864
		// save references to title and url elements
865
		helper.title = $('h3', helper.parent);
866
		helper.body = $('div.body', helper.parent);
867
		helper.url = $('div.url', helper.parent);
868
	}
869
 
870
	// main event handler to start showing tooltips
871
	function handle(event) {
872
		// show helper, either with timeout or on instant
873
		if( this.tSettings.delay )
874
			tID = setTimeout(show, this.tSettings.delay);
875
		else
876
			show();
877
 
878
		// if selected, update the helper position when the mouse moves
879
		track = !!this.tSettings.track;
880
		$('body').bind('mousemove', update);
881
 
882
		// update at least once
883
		update(event);
884
	}
885
 
886
	// save elements title before the tooltip is displayed
887
	function save() {
888
		// if this is the current source, or it has no title (occurs with click event), stop
889
		if ( $.Tooltip.blocked || this == current || !this.tooltipText )
890
			return;
891
 
892
		// save current
893
		current = this;
894
		title = this.tooltipText;
895
 
896
		if ( this.tSettings.bodyHandler ) {
897
			helper.title.hide();
898
			helper.body.html( this.tSettings.bodyHandler.call(this) ).show();
899
		} else if ( this.tSettings.showBody ) {
900
			var parts = title.split(this.tSettings.showBody);
901
			helper.title.html(parts.shift()).show();
902
			helper.body.empty();
903
			for(var i = 0, part; part = parts[i]; i++) {
904
				if(i > 0)
905
					helper.body.append("<br/>");
906
				helper.body.append(part);
907
			}
908
			helper.body.hideWhenEmpty();
909
		} else {
910
			helper.title.html(title).show();
911
			helper.body.hide();
912
		}
913
 
914
		// if element has href or src, add and show it, otherwise hide it
915
		if( this.tSettings.showURL && $(this).url() )
916
			helper.url.html( $(this).url().replace('http://', '') ).show();
917
		else
918
			helper.url.hide();
919
 
920
		// add an optional class for this tip
921
		helper.parent.addClass(this.tSettings.extraClass);
922
 
923
		// fix PNG background for IE
924
		if (this.tSettings.fixPNG )
925
			helper.parent.fixPNG();
926
 
927
		handle.apply(this, arguments);
928
	}
929
 
930
	// delete timeout and show helper
931
	function show() {
932
		tID = null;
933
		helper.parent.show();
934
		update();
935
	}
936
 
937
	/**
938
	 * callback for mousemove
939
	 * updates the helper position
940
	 * removes itself when no current element
941
	 */
942
	function update(event)	{
943
		if($.Tooltip.blocked)
944
			return;
945
 
946
		// stop updating when tracking is disabled and the tooltip is visible
947
		if ( !track && helper.parent.is(":visible")) {
948
			$('body').unbind('mousemove', update)
949
		}
950
 
951
		// if no current element is available, remove this listener
952
		if( current == null ) {
953
			$('body').unbind('mousemove', update);
954
			return;
955
		}
956
		var left = helper.parent[0].offsetLeft;
957
		var top = helper.parent[0].offsetTop;
958
		if(event) {
959
			// position the helper 15 pixel to bottom right, starting from mouse position
960
			left = event.pageX + current.tSettings.left;
961
			top = event.pageY + current.tSettings.top;
962
			helper.parent.css({
963
				left: left + 'px',
964
				top: top + 'px'
965
			});
966
		}
967
		var v = viewport(),
968
			h = helper.parent[0];
969
		// check horizontal position
970
		if(v.x + v.cx < h.offsetLeft + h.offsetWidth) {
971
			left -= h.offsetWidth + 20 + current.tSettings.left;
972
			helper.parent.css({left: left + 'px'});
973
		}
974
		// check vertical position
975
		if(v.y + v.cy < h.offsetTop + h.offsetHeight) {
976
			top -= h.offsetHeight + 20 + current.tSettings.top;
977
			helper.parent.css({top: top + 'px'});
978
		}
979
	}
980
 
981
	function viewport() {
982
		return {
983
			x: $(window).scrollLeft(),
984
			y: $(window).scrollTop(),
985
			cx: $(window).width(),
986
			cy: $(window).height()
987
		};
988
	}
989
 
990
	// hide helper and restore added classes and the title
991
	function hide(event) {
992
		if($.Tooltip.blocked)
993
			return;
994
		// clear timeout if possible
995
		if(tID)
996
			clearTimeout(tID);
997
		// no more current element
998
		current = null;
999
 
1000
		helper.parent.hide().removeClass( this.tSettings.extraClass );
1001
 
1002
		if( this.tSettings.fixPNG )
1003
			helper.parent.unfixPNG();
1004
	}
1005
 
1006
})(jQuery);
1007
 
1008
/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
1009
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
1010
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
1011
 *
1012
 * $LastChangedDate: 2007-06-22 04:38:37 +0200 (Fr, 22 Jun 2007) $
1013
 * $Rev: 2141 $
1014
 *
1015
 * Version: 1.0b2
1016
 */
1017
 
1018
(function($){
1019
 
1020
// store a copy of the core height and width methods
1021
var height = $.fn.height,
1022
    width  = $.fn.width;
1023
 
1024
$.fn.extend({
1025
	/**
1026
	 * If used on document, returns the document's height (innerHeight)
1027
	 * If used on window, returns the viewport's (window) height
1028
	 * See core docs on height() to see what happens when used on an element.
1029
	 *
1030
	 * @example $("#testdiv").height()
1031
	 * @result 200
1032
	 *
1033
	 * @example $(document).height()
1034
	 * @result 800
1035
	 *
1036
	 * @example $(window).height()
1037
	 * @result 400
1038
	 *
1039
	 * @name height
1040
	 * @type Object
1041
	 * @cat Plugins/Dimensions
1042
	 */
1043
	height: function() {
1044
		if ( this[0] == window )
1045
			return self.innerHeight ||
1046
				$.boxModel && document.documentElement.clientHeight ||
1047
				document.body.clientHeight;
1048
 
1049
		if ( this[0] == document )
1050
			return Math.max( document.body.scrollHeight, document.body.offsetHeight );
1051
 
1052
		return height.apply(this, arguments);
1053
	},
1054
 
1055
	/**
1056
	 * If used on document, returns the document's width (innerWidth)
1057
	 * If used on window, returns the viewport's (window) width
1058
	 * See core docs on height() to see what happens when used on an element.
1059
	 *
1060
	 * @example $("#testdiv").width()
1061
	 * @result 200
1062
	 *
1063
	 * @example $(document).width()
1064
	 * @result 800
1065
	 *
1066
	 * @example $(window).width()
1067
	 * @result 400
1068
	 *
1069
	 * @name width
1070
	 * @type Object
1071
	 * @cat Plugins/Dimensions
1072
	 */
1073
	width: function() {
1074
		if ( this[0] == window )
1075
			return self.innerWidth ||
1076
				$.boxModel && document.documentElement.clientWidth ||
1077
				document.body.clientWidth;
1078
 
1079
		if ( this[0] == document )
1080
			return Math.max( document.body.scrollWidth, document.body.offsetWidth );
1081
 
1082
		return width.apply(this, arguments);
1083
	},
1084
 
1085
	/**
1086
	 * Returns the inner height value (without border) for the first matched element.
1087
	 * If used on document, returns the document's height (innerHeight)
1088
	 * If used on window, returns the viewport's (window) height
1089
	 *
1090
	 * @example $("#testdiv").innerHeight()
1091
	 * @result 800
1092
	 *
1093
	 * @name innerHeight
1094
	 * @type Number
1095
	 * @cat Plugins/Dimensions
1096
	 */
1097
	innerHeight: function() {
1098
		return this[0] == window || this[0] == document ?
1099
			this.height() :
1100
			this.is(':visible') ?
1101
				this[0].offsetHeight - num(this, 'borderTopWidth') - num(this, 'borderBottomWidth') :
1102
				this.height() + num(this, 'paddingTop') + num(this, 'paddingBottom');
1103
	},
1104
 
1105
	/**
1106
	 * Returns the inner width value (without border) for the first matched element.
1107
	 * If used on document, returns the document's Width (innerWidth)
1108
	 * If used on window, returns the viewport's (window) width
1109
	 *
1110
	 * @example $("#testdiv").innerWidth()
1111
	 * @result 1000
1112
	 *
1113
	 * @name innerWidth
1114
	 * @type Number
1115
	 * @cat Plugins/Dimensions
1116
	 */
1117
	innerWidth: function() {
1118
		return this[0] == window || this[0] == document ?
1119
			this.width() :
1120
			this.is(':visible') ?
1121
				this[0].offsetWidth - num(this, 'borderLeftWidth') - num(this, 'borderRightWidth') :
1122
				this.width() + num(this, 'paddingLeft') + num(this, 'paddingRight');
1123
	},
1124
 
1125
	/**
1126
	 * Returns the outer height value (including border) for the first matched element.
1127
	 * Cannot be used on document or window.
1128
	 *
1129
	 * @example $("#testdiv").outerHeight()
1130
	 * @result 1000
1131
	 *
1132
	 * @name outerHeight
1133
	 * @type Number
1134
	 * @cat Plugins/Dimensions
1135
	 */
1136
	outerHeight: function() {
1137
		return this[0] == window || this[0] == document ?
1138
			this.height() :
1139
			this.is(':visible') ?
1140
				this[0].offsetHeight :
1141
				this.height() + num(this,'borderTopWidth') + num(this, 'borderBottomWidth') + num(this, 'paddingTop') + num(this, 'paddingBottom');
1142
	},
1143
 
1144
	/**
1145
	 * Returns the outer width value (including border) for the first matched element.
1146
	 * Cannot be used on document or window.
1147
	 *
1148
	 * @example $("#testdiv").outerHeight()
1149
	 * @result 1000
1150
	 *
1151
	 * @name outerHeight
1152
	 * @type Number
1153
	 * @cat Plugins/Dimensions
1154
	 */
1155
	outerWidth: function() {
1156
		return this[0] == window || this[0] == document ?
1157
			this.width() :
1158
			this.is(':visible') ?
1159
				this[0].offsetWidth :
1160
				this.width() + num(this, 'borderLeftWidth') + num(this, 'borderRightWidth') + num(this, 'paddingLeft') + num(this, 'paddingRight');
1161
	},
1162
 
1163
	/**
1164
	 * Returns how many pixels the user has scrolled to the right (scrollLeft).
1165
	 * Works on containers with overflow: auto and window/document.
1166
	 *
1167
	 * @example $("#testdiv").scrollLeft()
1168
	 * @result 100
1169
	 *
1170
	 * @name scrollLeft
1171
	 * @type Number
1172
	 * @cat Plugins/Dimensions
1173
	 */
1174
	/**
1175
	 * Sets the scrollLeft property and continues the chain.
1176
	 * Works on containers with overflow: auto and window/document.
1177
	 *
1178
	 * @example $("#testdiv").scrollLeft(10).scrollLeft()
1179
	 * @result 10
1180
	 *
1181
	 * @name scrollLeft
1182
	 * @param Number value A positive number representing the desired scrollLeft.
1183
	 * @type jQuery
1184
	 * @cat Plugins/Dimensions
1185
	 */
1186
	scrollLeft: function(val) {
1187
		if ( val != undefined )
1188
			// set the scroll left
1189
			return this.each(function() {
1190
				if (this == window || this == document)
1191
					window.scrollTo( val, $(window).scrollTop() );
1192
				else
1193
					this.scrollLeft = val;
1194
			});
1195
 
1196
		// return the scroll left offest in pixels
1197
		if ( this[0] == window || this[0] == document )
1198
			return self.pageXOffset ||
1199
				$.boxModel && document.documentElement.scrollLeft ||
1200
				document.body.scrollLeft;
1201
 
1202
		return this[0].scrollLeft;
1203
	},
1204
 
1205
	/**
1206
	 * Returns how many pixels the user has scrolled to the bottom (scrollTop).
1207
	 * Works on containers with overflow: auto and window/document.
1208
	 *
1209
	 * @example $("#testdiv").scrollTop()
1210
	 * @result 100
1211
	 *
1212
	 * @name scrollTop
1213
	 * @type Number
1214
	 * @cat Plugins/Dimensions
1215
	 */
1216
	/**
1217
	 * Sets the scrollTop property and continues the chain.
1218
	 * Works on containers with overflow: auto and window/document.
1219
	 *
1220
	 * @example $("#testdiv").scrollTop(10).scrollTop()
1221
	 * @result 10
1222
	 *
1223
	 * @name scrollTop
1224
	 * @param Number value A positive number representing the desired scrollTop.
1225
	 * @type jQuery
1226
	 * @cat Plugins/Dimensions
1227
	 */
1228
	scrollTop: function(val) {
1229
		if ( val != undefined )
1230
			// set the scroll top
1231
			return this.each(function() {
1232
				if (this == window || this == document)
1233
					window.scrollTo( $(window).scrollLeft(), val );
1234
				else
1235
					this.scrollTop = val;
1236
			});
1237
 
1238
		// return the scroll top offset in pixels
1239
		if ( this[0] == window || this[0] == document )
1240
			return self.pageYOffset ||
1241
				$.boxModel && document.documentElement.scrollTop ||
1242
				document.body.scrollTop;
1243
 
1244
		return this[0].scrollTop;
1245
	},
1246
 
1247
	/**
1248
	 * Returns the top and left positioned offset in pixels.
1249
	 * The positioned offset is the offset between a positioned
1250
	 * parent and the element itself.
1251
	 *
1252
	 * @example $("#testdiv").position()
1253
	 * @result { top: 100, left: 100 }
1254
	 *
1255
	 * @name position
1256
	 * @param Map options Optional settings to configure the way the offset is calculated.
1257
	 * @option Boolean margin Should the margin of the element be included in the calculations? False by default.
1258
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
1259
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
1260
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
1261
	 *                            chain will not be broken and the result will be assigned to this object.
1262
	 * @type Object
1263
	 * @cat Plugins/Dimensions
1264
	 */
1265
	position: function(options, returnObject) {
1266
		var elem = this[0], parent = elem.parentNode, op = elem.offsetParent,
1267
		    options = $.extend({ margin: false, border: false, padding: false, scroll: false }, options || {}),
1268
			x = elem.offsetLeft,
1269
			y = elem.offsetTop,
1270
			sl = elem.scrollLeft,
1271
			st = elem.scrollTop;
1272
 
1273
		// Mozilla and IE do not add the border
1274
		if ($.browser.mozilla || $.browser.msie) {
1275
			// add borders to offset
1276
			x += num(elem, 'borderLeftWidth');
1277
			y += num(elem, 'borderTopWidth');
1278
		}
1279
 
1280
		if ($.browser.mozilla) {
1281
			do {
1282
				// Mozilla does not add the border for a parent that has overflow set to anything but visible
1283
				if ($.browser.mozilla && parent != elem && $.css(parent, 'overflow') != 'visible') {
1284
					x += num(parent, 'borderLeftWidth');
1285
					y += num(parent, 'borderTopWidth');
1286
				}
1287
 
1288
				if (parent == op) break; // break if we are already at the offestParent
1289
			} while ((parent = parent.parentNode) && (parent.tagName.toLowerCase() != 'body' || parent.tagName.toLowerCase() != 'html'));
1290
		}
1291
 
1292
		var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);
1293
 
1294
		if (returnObject) { $.extend(returnObject, returnValue); return this; }
1295
		else              { return returnValue; }
1296
	},
1297
 
1298
	/**
1299
	 * Returns the location of the element in pixels from the top left corner of the viewport.
1300
	 *
1301
	 * For accurate readings make sure to use pixel values for margins, borders and padding.
1302
	 *
1303
	 * Known issues:
1304
	 *  - Issue: A div positioned relative or static without any content before it and its parent will report an offsetTop of 0 in Safari
1305
	 *    Workaround: Place content before the relative div ... and set height and width to 0 and overflow to hidden
1306
	 *
1307
	 * @example $("#testdiv").offset()
1308
	 * @result { top: 100, left: 100, scrollTop: 10, scrollLeft: 10 }
1309
	 *
1310
	 * @example $("#testdiv").offset({ scroll: false })
1311
	 * @result { top: 90, left: 90 }
1312
	 *
1313
	 * @example var offset = {}
1314
	 * $("#testdiv").offset({ scroll: false }, offset)
1315
	 * @result offset = { top: 90, left: 90 }
1316
	 *
1317
	 * @name offset
1318
	 * @param Map options Optional settings to configure the way the offset is calculated.
1319
	 * @option Boolean margin Should the margin of the element be included in the calculations? True by default.
1320
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
1321
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
1322
	 * @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default.
1323
	 *                        When true it adds the totla scroll offets of all parents to the total offset and also adds two properties
1324
	 *                        to the returned object, scrollTop and scrollLeft.
1325
	 * @options Boolean lite Will use offsetLite instead of offset when set to true. False by default.
1326
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
1327
	 *                            chain will not be broken and the result will be assigned to this object.
1328
	 * @type Object
1329
	 * @cat Plugins/Dimensions
1330
	 */
1331
	offset: function(options, returnObject) {
1332
		var x = 0, y = 0, sl = 0, st = 0,
1333
		    elem = this[0], parent = this[0], op, parPos, elemPos = $.css(elem, 'position'),
1334
		    mo = $.browser.mozilla, ie = $.browser.msie, sf = $.browser.safari, oa = $.browser.opera,
1335
		    absparent = false, relparent = false,
1336
		    options = $.extend({ margin: true, border: false, padding: false, scroll: true, lite: false }, options || {});
1337
 
1338
		// Use offsetLite if lite option is true
1339
		if (options.lite) return this.offsetLite(options, returnObject);
1340
 
1341
		if (elem.tagName.toLowerCase() == 'body') {
1342
			// Safari is the only one to get offsetLeft and offsetTop properties of the body "correct"
1343
			// Except they all mess up when the body is positioned absolute or relative
1344
			x = elem.offsetLeft;
1345
			y = elem.offsetTop;
1346
			// Mozilla ignores margin and subtracts border from body element
1347
			if (mo) {
1348
				x += num(elem, 'marginLeft') + (num(elem, 'borderLeftWidth')*2);
1349
				y += num(elem, 'marginTop')  + (num(elem, 'borderTopWidth') *2);
1350
			} else
1351
			// Opera ignores margin
1352
			if (oa) {
1353
				x += num(elem, 'marginLeft');
1354
				y += num(elem, 'marginTop');
1355
			} else
1356
			// IE does not add the border in Standards Mode
1357
			if (ie && jQuery.boxModel) {
1358
				x += num(elem, 'borderLeftWidth');
1359
				y += num(elem, 'borderTopWidth');
1360
			}
1361
		} else {
1362
			do {
1363
				parPos = $.css(parent, 'position');
1364
 
1365
				x += parent.offsetLeft;
1366
				y += parent.offsetTop;
1367
 
1368
				// Mozilla and IE do not add the border
1369
				if (mo || ie) {
1370
					// add borders to offset
1371
					x += num(parent, 'borderLeftWidth');
1372
					y += num(parent, 'borderTopWidth');
1373
 
1374
					// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
1375
					if (mo && parPos == 'absolute') absparent = true;
1376
					// IE does not include the border on the body if an element is position static and without an absolute or relative parent
1377
					if (ie && parPos == 'relative') relparent = true;
1378
				}
1379
 
1380
				op = parent.offsetParent;
1381
				if (options.scroll || mo) {
1382
					do {
1383
						if (options.scroll) {
1384
							// get scroll offsets
1385
							sl += parent.scrollLeft;
1386
							st += parent.scrollTop;
1387
						}
1388
 
1389
						// Mozilla does not add the border for a parent that has overflow set to anything but visible
1390
						if (mo && parent != elem && $.css(parent, 'overflow') != 'visible') {
1391
							x += num(parent, 'borderLeftWidth');
1392
							y += num(parent, 'borderTopWidth');
1393
						}
1394
 
1395
						parent = parent.parentNode;
1396
					} while (parent != op);
1397
				}
1398
				parent = op;
1399
 
1400
				if (parent.tagName.toLowerCase() == 'body' || parent.tagName.toLowerCase() == 'html') {
1401
					// Safari and IE Standards Mode doesn't add the body margin for elments positioned with static or relative
1402
					if ((sf || (ie && $.boxModel)) && elemPos != 'absolute' && elemPos != 'fixed') {
1403
						x += num(parent, 'marginLeft');
1404
						y += num(parent, 'marginTop');
1405
					}
1406
					// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
1407
					// IE does not include the border on the body if an element is positioned static and without an absolute or relative parent
1408
					if ( (mo && !absparent && elemPos != 'fixed') ||
1409
					     (ie && elemPos == 'static' && !relparent) ) {
1410
						x += num(parent, 'borderLeftWidth');
1411
						y += num(parent, 'borderTopWidth');
1412
					}
1413
					break; // Exit the loop
1414
				}
1415
			} while (parent);
1416
		}
1417
 
1418
		var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);
1419
 
1420
		if (returnObject) { $.extend(returnObject, returnValue); return this; }
1421
		else              { return returnValue; }
1422
	},
1423
 
1424
	/**
1425
	 * Returns the location of the element in pixels from the top left corner of the viewport.
1426
	 * This method is much faster than offset but not as accurate. This method can be invoked
1427
	 * by setting the lite option to true in the offset method.
1428
	 *
1429
	 * @name offsetLite
1430
	 * @param Map options Optional settings to configure the way the offset is calculated.
1431
	 * @option Boolean margin Should the margin of the element be included in the calculations? True by default.
1432
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
1433
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
1434
	 * @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default.
1435
	 *                        When true it adds the totla scroll offets of all parents to the total offset and also adds two properties
1436
	 *                        to the returned object, scrollTop and scrollLeft.
1437
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
1438
	 *                            chain will not be broken and the result will be assigned to this object.
1439
	 * @type Object
1440
	 * @cat Plugins/Dimensions
1441
	 */
1442
	offsetLite: function(options, returnObject) {
1443
		var x = 0, y = 0, sl = 0, st = 0, parent = this[0], op,
1444
		    options = $.extend({ margin: true, border: false, padding: false, scroll: true }, options || {});
1445
 
1446
		do {
1447
			x += parent.offsetLeft;
1448
			y += parent.offsetTop;
1449
 
1450
			op = parent.offsetParent;
1451
			if (options.scroll) {
1452
				// get scroll offsets
1453
				do {
1454
					sl += parent.scrollLeft;
1455
					st += parent.scrollTop;
1456
					parent = parent.parentNode;
1457
				} while(parent != op);
1458
			}
1459
			parent = op;
1460
		} while (parent && parent.tagName.toLowerCase() != 'body' && parent.tagName.toLowerCase() != 'html');
1461
 
1462
		var returnValue = handleOffsetReturn(this[0], options, x, y, sl, st);
1463
 
1464
		if (returnObject) { $.extend(returnObject, returnValue); return this; }
1465
		else              { return returnValue; }
1466
	}
1467
});
1468
 
1469
/**
1470
 * Handles converting a CSS Style into an Integer.
1471
 * @private
1472
 */
1473
var num = function(el, prop) {
1474
	return parseInt($.css(el.jquery?el[0]:el,prop))||0;
1475
};
1476
 
1477
/**
1478
 * Handles the return value of the offset and offsetLite methods.
1479
 * @private
1480
 */
1481
var handleOffsetReturn = function(elem, options, x, y, sl, st) {
1482
	if ( !options.margin ) {
1483
		x -= num(elem, 'marginLeft');
1484
		y -= num(elem, 'marginTop');
1485
	}
1486
 
1487
	// Safari and Opera do not add the border for the element
1488
	if ( options.border && ($.browser.safari || $.browser.opera) ) {
1489
		x += num(elem, 'borderLeftWidth');
1490
		y += num(elem, 'borderTopWidth');
1491
	} else if ( !options.border && !($.browser.safari || $.browser.opera) ) {
1492
		x -= num(elem, 'borderLeftWidth');
1493
		y -= num(elem, 'borderTopWidth');
1494
	}
1495
 
1496
	if ( options.padding ) {
1497
		x += num(elem, 'paddingLeft');
1498
		y += num(elem, 'paddingTop');
1499
	}
1500
 
1501
	// do not include scroll offset on the element
1502
	if ( options.scroll ) {
1503
		sl -= elem.scrollLeft;
1504
		st -= elem.scrollTop;
1505
	}
1506
 
1507
	return options.scroll ? { top: y - st, left: x - sl, scrollTop:  st, scrollLeft: sl }
1508
	                      : { top: y, left: x };
1509
};
1510
 
1511
})(jQuery);