6 |
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 |
*/
|
|
|
19 |
$.fn.lightBox = function(settings) {
|
|
|
20 |
// Settings to configure the jQuery lightBox plugin how you like
|
|
|
21 |
settings = jQuery.extend({
|
|
|
22 |
// Configuration related to overlay
|
|
|
23 |
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.
|
|
|
24 |
overlayOpacity: 0.8, // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
|
|
|
25 |
// Configuration related to images
|
|
|
26 |
imageLoading: 'tools/galerie/actions/galerie/presentation/images/lightbox-ico-loading.gif', // (string) Path and the name of the loading icon
|
|
|
27 |
imageBtnPrev: 'tools/galerie/actions/galerie/presentation/images/lightbox-btn-prev.fr.gif', // (string) Path and the name of the prev button image
|
|
|
28 |
imageBtnNext: 'tools/galerie/actions/galerie/presentation/images/lightbox-btn-next.fr.gif', // (string) Path and the name of the next button image
|
|
|
29 |
imageBtnClose: 'tools/galerie/actions/galerie/presentation/images/lightbox-btn-close.fr.gif', // (string) Path and the name of the close btn
|
|
|
30 |
imageBlank: 'tools/galerie/actions/galerie/presentation/images/lightbox-blank.gif', // (string) Path and the name of a blank image (one pixel)
|
|
|
31 |
// Configuration related to container image box
|
|
|
32 |
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
|
|
|
33 |
containerResizeSpeed: 400, // (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
|
|
|
34 |
// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
|
|
|
35 |
txtImage: 'Image', // (string) Specify text "Image"
|
|
|
36 |
txtOf: 'de', // (string) Specify text "of"
|
|
|
37 |
// Configuration related to keyboard navigation
|
|
|
38 |
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.
|
|
|
39 |
keyToPrev: 'p', // (string) (p = previous) Letter to show the previous image
|
|
|
40 |
keyToNext: 'n', // (string) (n = next) Letter to show the next image.
|
|
|
41 |
// Don´t alter these variables in any way
|
|
|
42 |
imageArray: [],
|
|
|
43 |
activeImage: 0
|
|
|
44 |
},settings);
|
|
|
45 |
// Caching the jQuery object with all elements matched
|
|
|
46 |
var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
|
|
|
47 |
/**
|
|
|
48 |
*/
|
|
|
49 |
function _initialize() {
|
|
|
50 |
_start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
|
|
|
51 |
return false; // Avoid the browser following the link
|
|
|
52 |
};
|
|
|
53 |
/**
|
|
|
54 |
*/
|
|
|
55 |
function _start(objClicked,jQueryMatchedObj) {
|
|
|
56 |
// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
|
|
|
57 |
$('embed, object, select').css({ 'visibility' : 'hidden' });
|
|
|
58 |
// Call the function to create the markup structure; style some elements; assign events in some elements.
|
|
|
59 |
_set_interface();
|
|
|
60 |
// Unset total images in imageArray
|
|
|
61 |
settings.imageArray.length = 0;
|
|
|
62 |
// Unset image active information
|
|
|
63 |
settings.activeImage = 0;
|
|
|
64 |
// We have an image set? Or just an image? Let´s see it.
|
|
|
65 |
if ( jQueryMatchedObj.length == 1 ) {
|
|
|
66 |
settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
|
|
|
67 |
} else {
|
|
|
68 |
// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references
|
|
|
69 |
for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
|
|
|
70 |
settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
|
|
|
74 |
settings.activeImage++;
|
|
|
75 |
}
|
|
|
76 |
// Call the function that prepares image exibition
|
|
|
77 |
_set_image_to_view();
|
|
|
78 |
};
|
|
|
79 |
/**
|
|
|
80 |
*/
|
|
|
81 |
function _set_interface() {
|
|
|
82 |
// Apply the HTML markup into body tag
|
|
|
83 |
$('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>');
|
|
|
84 |
// Get page sizes
|
|
|
85 |
var arrPageSizes = ___getPageSize();
|
|
|
86 |
// Style overlay and show it
|
|
|
87 |
$('#jquery-overlay').css({
|
|
|
88 |
backgroundColor: settings.overlayBgColor,
|
|
|
89 |
opacity: settings.overlayOpacity,
|
|
|
90 |
width: arrPageSizes[0],
|
|
|
91 |
height: arrPageSizes[1]
|
|
|
92 |
}).fadeIn();
|
|
|
93 |
// Get page scroll
|
|
|
94 |
var arrPageScroll = ___getPageScroll();
|
|
|
95 |
// Calculate top and left offset for the jquery-lightbox div object and show it
|
|
|
96 |
$('#jquery-lightbox').css({
|
|
|
97 |
top: arrPageScroll[1] + (arrPageSizes[3] / 10),
|
|
|
98 |
left: arrPageScroll[0]
|
|
|
99 |
}).show();
|
|
|
100 |
// Assigning click events in elements to close overlay
|
|
|
101 |
$('#jquery-overlay,#jquery-lightbox').click(function() {
|
|
|
102 |
_finish();
|
|
|
103 |
});
|
|
|
104 |
// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
|
|
|
105 |
$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
|
|
|
106 |
_finish();
|
|
|
107 |
return false;
|
|
|
108 |
});
|
|
|
109 |
// If window was resized, calculate the new overlay dimensions
|
|
|
110 |
$(window).resize(function() {
|
|
|
111 |
// Get page sizes
|
|
|
112 |
var arrPageSizes = ___getPageSize();
|
|
|
113 |
// Style overlay and show it
|
|
|
114 |
$('#jquery-overlay').css({
|
|
|
115 |
width: arrPageSizes[0],
|
|
|
116 |
height: arrPageSizes[1]
|
|
|
117 |
});
|
|
|
118 |
// Get page scroll
|
|
|
119 |
var arrPageScroll = ___getPageScroll();
|
|
|
120 |
// Calculate top and left offset for the jquery-lightbox div object and show it
|
|
|
121 |
$('#jquery-lightbox').css({
|
|
|
122 |
top: arrPageScroll[1] + (arrPageSizes[3] / 10),
|
|
|
123 |
left: arrPageScroll[0]
|
|
|
124 |
});
|
|
|
125 |
});
|
|
|
126 |
};
|
|
|
127 |
/**
|
|
|
128 |
*/
|
|
|
129 |
function _set_image_to_view() { // show the loading
|
|
|
130 |
// Show the loading
|
|
|
131 |
$('#lightbox-loading').show();
|
|
|
132 |
// Hide some elements
|
|
|
133 |
$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
|
|
|
134 |
// Image preload process
|
|
|
135 |
var objImagePreloader = new Image();
|
|
|
136 |
objImagePreloader.onload = function() {
|
|
|
137 |
$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
|
|
|
138 |
// Perfomance an effect in the image container resizing it
|
|
|
139 |
_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
|
|
|
140 |
// clear onLoad, IE behaves irratically with animated gifs otherwise
|
|
|
141 |
objImagePreloader.onload=function(){};
|
|
|
142 |
};
|
|
|
143 |
objImagePreloader.src = settings.imageArray[settings.activeImage][0];
|
|
|
144 |
};
|
|
|
145 |
/**
|
|
|
146 |
*/
|
|
|
147 |
function _resize_container_image_box(intImageWidth,intImageHeight) {
|
|
|
148 |
// Get current width and height
|
|
|
149 |
var intCurrentWidth = $('#lightbox-container-image-box').width();
|
|
|
150 |
var intCurrentHeight = $('#lightbox-container-image-box').height();
|
|
|
151 |
// Get the width and height of the selected image plus the padding
|
|
|
152 |
var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image´s width and the left and right padding value
|
|
|
153 |
var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image´s height and the left and right padding value
|
|
|
154 |
// Diferences
|
|
|
155 |
var intDiffW = intCurrentWidth - intWidth;
|
|
|
156 |
var intDiffH = intCurrentHeight - intHeight;
|
|
|
157 |
// Perfomance the effect
|
|
|
158 |
$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
|
|
|
159 |
if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
|
|
|
160 |
if ( $.browser.msie ) {
|
|
|
161 |
___pause(250);
|
|
|
162 |
} else {
|
|
|
163 |
___pause(100);
|
|
|
164 |
}
|
|
|
165 |
}
|
|
|
166 |
$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
|
|
|
167 |
$('#lightbox-container-image-data-box').css({ width: intImageWidth });
|
|
|
168 |
};
|
|
|
169 |
/**
|
|
|
170 |
*/
|
|
|
171 |
function _show_image() {
|
|
|
172 |
$('#lightbox-loading').hide();
|
|
|
173 |
$('#lightbox-image').fadeIn(function() {
|
|
|
174 |
_show_image_data();
|
|
|
175 |
_set_navigation();
|
|
|
176 |
});
|
|
|
177 |
_preload_neighbor_images();
|
|
|
178 |
};
|
|
|
179 |
/**
|
|
|
180 |
*/
|
|
|
181 |
function _show_image_data() {
|
|
|
182 |
$('#lightbox-container-image-data-box').slideDown('fast');
|
|
|
183 |
$('#lightbox-image-details-caption').hide();
|
|
|
184 |
if ( settings.imageArray[settings.activeImage][1] ) {
|
|
|
185 |
$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
|
|
|
186 |
}
|
|
|
187 |
// If we have a image set, display 'Image X of X'
|
|
|
188 |
if ( settings.imageArray.length > 1 ) {
|
|
|
189 |
$('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
|
|
|
190 |
}
|
|
|
191 |
};
|
|
|
192 |
/**
|
|
|
193 |
*/
|
|
|
194 |
function _set_navigation() {
|
|
|
195 |
$('#lightbox-nav').show();
|
|
|
196 |
|
|
|
197 |
// Instead to define this configuration in CSS file, we define here. And it´s need to IE. Just.
|
|
|
198 |
$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
|
|
|
199 |
|
|
|
200 |
// Show the prev button, if not the first image in set
|
|
|
201 |
if ( settings.activeImage != 0 ) {
|
|
|
202 |
// Show the images button for Next buttons
|
|
|
203 |
$('#lightbox-nav-btnPrev').unbind().hover(function() {
|
|
|
204 |
$(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
|
|
|
205 |
},function() {
|
|
|
206 |
$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
|
|
|
207 |
}).show().bind('click',function() {
|
|
|
208 |
settings.activeImage = settings.activeImage - 1;
|
|
|
209 |
_set_image_to_view();
|
|
|
210 |
return false;
|
|
|
211 |
});
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
// Show the next button, if not the last image in set
|
|
|
215 |
if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
|
|
|
216 |
// Show the images button for Next buttons
|
|
|
217 |
$('#lightbox-nav-btnNext').unbind().hover(function() {
|
|
|
218 |
$(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
|
|
|
219 |
},function() {
|
|
|
220 |
$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
|
|
|
221 |
}).show().bind('click',function() {
|
|
|
222 |
settings.activeImage = settings.activeImage + 1;
|
|
|
223 |
_set_image_to_view();
|
|
|
224 |
return false;
|
|
|
225 |
});
|
|
|
226 |
}
|
|
|
227 |
// Enable keyboard navigation
|
|
|
228 |
_enable_keyboard_navigation();
|
|
|
229 |
};
|
|
|
230 |
/**
|
|
|
231 |
*/
|
|
|
232 |
function _enable_keyboard_navigation() {
|
|
|
233 |
$(document).keydown(function(objEvent) {
|
|
|
234 |
_keyboard_action(objEvent);
|
|
|
235 |
});
|
|
|
236 |
};
|
|
|
237 |
/**
|
|
|
238 |
*/
|
|
|
239 |
function _disable_keyboard_navigation() {
|
|
|
240 |
$(document).unbind();
|
|
|
241 |
};
|
|
|
242 |
/**
|
|
|
243 |
*/
|
|
|
244 |
function _keyboard_action(objEvent) {
|
|
|
245 |
// To ie
|
|
|
246 |
if ( objEvent == null ) {
|
|
|
247 |
keycode = event.keyCode;
|
|
|
248 |
escapeKey = 27;
|
|
|
249 |
// To Mozilla
|
|
|
250 |
} else {
|
|
|
251 |
keycode = objEvent.keyCode;
|
|
|
252 |
escapeKey = objEvent.DOM_VK_ESCAPE;
|
|
|
253 |
}
|
|
|
254 |
// Get the key in lower case form
|
|
|
255 |
key = String.fromCharCode(keycode).toLowerCase();
|
|
|
256 |
// Verify the keys to close the ligthBox
|
|
|
257 |
if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
|
|
|
258 |
_finish();
|
|
|
259 |
}
|
|
|
260 |
// Verify the key to show the previous image
|
|
|
261 |
if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
|
|
|
262 |
// If we´re not showing the first image, call the previous
|
|
|
263 |
if ( settings.activeImage != 0 ) {
|
|
|
264 |
settings.activeImage = settings.activeImage - 1;
|
|
|
265 |
_set_image_to_view();
|
|
|
266 |
_disable_keyboard_navigation();
|
|
|
267 |
}
|
|
|
268 |
}
|
|
|
269 |
// Verify the key to show the next image
|
|
|
270 |
if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
|
|
|
271 |
// If we´re not showing the last image, call the next
|
|
|
272 |
if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
|
|
|
273 |
settings.activeImage = settings.activeImage + 1;
|
|
|
274 |
_set_image_to_view();
|
|
|
275 |
_disable_keyboard_navigation();
|
|
|
276 |
}
|
|
|
277 |
}
|
|
|
278 |
};
|
|
|
279 |
/**
|
|
|
280 |
*/
|
|
|
281 |
function _preload_neighbor_images() {
|
|
|
282 |
if ( (settings.imageArray.length -1) > settings.activeImage ) {
|
|
|
283 |
objNext = new Image();
|
|
|
284 |
objNext.src = settings.imageArray[settings.activeImage + 1][0];
|
|
|
285 |
}
|
|
|
286 |
if ( settings.activeImage > 0 ) {
|
|
|
287 |
objPrev = new Image();
|
|
|
288 |
objPrev.src = settings.imageArray[settings.activeImage -1][0];
|
|
|
289 |
}
|
|
|
290 |
};
|
|
|
291 |
/**
|
|
|
292 |
*/
|
|
|
293 |
function _finish() {
|
|
|
294 |
$('#jquery-lightbox').remove();
|
|
|
295 |
$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
|
|
|
296 |
// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
|
|
|
297 |
$('embed, object, select').css({ 'visibility' : 'visible' });
|
|
|
298 |
};
|
|
|
299 |
/**
|
|
|
300 |
*/
|
|
|
301 |
function ___getPageSize() {
|
|
|
302 |
var xScroll, yScroll;
|
|
|
303 |
if (window.innerHeight && window.scrollMaxY) {
|
|
|
304 |
xScroll = window.innerWidth + window.scrollMaxX;
|
|
|
305 |
yScroll = window.innerHeight + window.scrollMaxY;
|
|
|
306 |
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
|
|
|
307 |
xScroll = document.body.scrollWidth;
|
|
|
308 |
yScroll = document.body.scrollHeight;
|
|
|
309 |
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
|
|
|
310 |
xScroll = document.body.offsetWidth;
|
|
|
311 |
yScroll = document.body.offsetHeight;
|
|
|
312 |
}
|
|
|
313 |
var windowWidth, windowHeight;
|
|
|
314 |
if (self.innerHeight) { // all except Explorer
|
|
|
315 |
if(document.documentElement.clientWidth){
|
|
|
316 |
windowWidth = document.documentElement.clientWidth;
|
|
|
317 |
} else {
|
|
|
318 |
windowWidth = self.innerWidth;
|
|
|
319 |
}
|
|
|
320 |
windowHeight = self.innerHeight;
|
|
|
321 |
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
|
|
|
322 |
windowWidth = document.documentElement.clientWidth;
|
|
|
323 |
windowHeight = document.documentElement.clientHeight;
|
|
|
324 |
} else if (document.body) { // other Explorers
|
|
|
325 |
windowWidth = document.body.clientWidth;
|
|
|
326 |
windowHeight = document.body.clientHeight;
|
|
|
327 |
}
|
|
|
328 |
// for small pages with total height less then height of the viewport
|
|
|
329 |
if(yScroll < windowHeight){
|
|
|
330 |
pageHeight = windowHeight;
|
|
|
331 |
} else {
|
|
|
332 |
pageHeight = yScroll;
|
|
|
333 |
}
|
|
|
334 |
// for small pages with total width less then width of the viewport
|
|
|
335 |
if(xScroll < windowWidth){
|
|
|
336 |
pageWidth = xScroll;
|
|
|
337 |
} else {
|
|
|
338 |
pageWidth = windowWidth;
|
|
|
339 |
}
|
|
|
340 |
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
|
|
|
341 |
return arrayPageSize;
|
|
|
342 |
};
|
|
|
343 |
/**
|
|
|
344 |
*/
|
|
|
345 |
function ___getPageScroll() {
|
|
|
346 |
var xScroll, yScroll;
|
|
|
347 |
if (self.pageYOffset) {
|
|
|
348 |
yScroll = self.pageYOffset;
|
|
|
349 |
xScroll = self.pageXOffset;
|
|
|
350 |
} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
|
|
|
351 |
yScroll = document.documentElement.scrollTop;
|
|
|
352 |
xScroll = document.documentElement.scrollLeft;
|
|
|
353 |
} else if (document.body) {// all other Explorers
|
|
|
354 |
yScroll = document.body.scrollTop;
|
|
|
355 |
xScroll = document.body.scrollLeft;
|
|
|
356 |
}
|
|
|
357 |
arrayPageScroll = new Array(xScroll,yScroll)
|
|
|
358 |
return arrayPageScroll;
|
|
|
359 |
};
|
|
|
360 |
/**
|
|
|
361 |
*/
|
|
|
362 |
function ___pause(ms) {
|
|
|
363 |
var date = new Date();
|
|
|
364 |
curDate = null;
|
|
|
365 |
do { var curDate = new Date(); }
|
|
|
366 |
while ( curDate - date < ms);
|
|
|
367 |
};
|
|
|
368 |
// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
|
|
|
369 |
return this.unbind('click').click(_initialize);
|
|
|
370 |
};
|
|
|
371 |
})(jQuery); // Call and execute the function immediately passing the jQuery object
|
|
|
372 |
|
|
|
373 |
/**
|
|
|
374 |
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
|
|
375 |
*
|
|
|
376 |
* Uses the built In easIng capabilities added In jQuery 1.1
|
|
|
377 |
* to offer multiple easIng options
|
|
|
378 |
*
|
|
|
379 |
* @copyright (c) 2007 George Smith
|
|
|
380 |
* @license Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
|
|
|
381 |
*/
|
|
|
382 |
|
|
|
383 |
// t: current time, b: begInnIng value, c: change In value, d: duration
|
|
|
384 |
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
|
|
385 |
|
|
|
386 |
jQuery.extend( jQuery.easing,
|
|
|
387 |
{
|
|
|
388 |
def: 'easeOutQuad',
|
|
|
389 |
swing: function (x, t, b, c, d) {
|
|
|
390 |
//alert(jQuery.easing.default);
|
|
|
391 |
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
|
|
392 |
},
|
|
|
393 |
easeInQuad: function (x, t, b, c, d) {
|
|
|
394 |
return c*(t/=d)*t + b;
|
|
|
395 |
},
|
|
|
396 |
easeOutQuad: function (x, t, b, c, d) {
|
|
|
397 |
return -c *(t/=d)*(t-2) + b;
|
|
|
398 |
},
|
|
|
399 |
easeInOutQuad: function (x, t, b, c, d) {
|
|
|
400 |
if ((t/=d/2) < 1) return c/2*t*t + b;
|
|
|
401 |
return -c/2 * ((--t)*(t-2) - 1) + b;
|
|
|
402 |
},
|
|
|
403 |
easeInCubic: function (x, t, b, c, d) {
|
|
|
404 |
return c*(t/=d)*t*t + b;
|
|
|
405 |
},
|
|
|
406 |
easeOutCubic: function (x, t, b, c, d) {
|
|
|
407 |
return c*((t=t/d-1)*t*t + 1) + b;
|
|
|
408 |
},
|
|
|
409 |
easeInOutCubic: function (x, t, b, c, d) {
|
|
|
410 |
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
|
|
411 |
return c/2*((t-=2)*t*t + 2) + b;
|
|
|
412 |
},
|
|
|
413 |
easeInQuart: function (x, t, b, c, d) {
|
|
|
414 |
return c*(t/=d)*t*t*t + b;
|
|
|
415 |
},
|
|
|
416 |
easeOutQuart: function (x, t, b, c, d) {
|
|
|
417 |
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
|
|
418 |
},
|
|
|
419 |
easeInOutQuart: function (x, t, b, c, d) {
|
|
|
420 |
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
|
|
421 |
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
|
|
422 |
},
|
|
|
423 |
easeInQuint: function (x, t, b, c, d) {
|
|
|
424 |
return c*(t/=d)*t*t*t*t + b;
|
|
|
425 |
},
|
|
|
426 |
easeOutQuint: function (x, t, b, c, d) {
|
|
|
427 |
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
|
|
428 |
},
|
|
|
429 |
easeInOutQuint: function (x, t, b, c, d) {
|
|
|
430 |
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
|
|
431 |
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
|
|
432 |
},
|
|
|
433 |
easeInSine: function (x, t, b, c, d) {
|
|
|
434 |
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
|
|
435 |
},
|
|
|
436 |
easeOutSine: function (x, t, b, c, d) {
|
|
|
437 |
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
|
|
438 |
},
|
|
|
439 |
easeInOutSine: function (x, t, b, c, d) {
|
|
|
440 |
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
|
|
441 |
},
|
|
|
442 |
easeInExpo: function (x, t, b, c, d) {
|
|
|
443 |
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
|
|
444 |
},
|
|
|
445 |
easeOutExpo: function (x, t, b, c, d) {
|
|
|
446 |
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
|
|
447 |
},
|
|
|
448 |
easeInOutExpo: function (x, t, b, c, d) {
|
|
|
449 |
if (t==0) return b;
|
|
|
450 |
if (t==d) return b+c;
|
|
|
451 |
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
|
|
452 |
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
|
|
453 |
},
|
|
|
454 |
easeInCirc: function (x, t, b, c, d) {
|
|
|
455 |
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
|
|
456 |
},
|
|
|
457 |
easeOutCirc: function (x, t, b, c, d) {
|
|
|
458 |
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
|
|
459 |
},
|
|
|
460 |
easeInOutCirc: function (x, t, b, c, d) {
|
|
|
461 |
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
|
|
462 |
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
|
|
463 |
},
|
|
|
464 |
easeInElastic: function (x, t, b, c, d) {
|
|
|
465 |
var s=1.70158;var p=0;var a=c;
|
|
|
466 |
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
|
|
467 |
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
|
|
468 |
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
|
|
469 |
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
|
|
470 |
},
|
|
|
471 |
easeOutElastic: function (x, t, b, c, d) {
|
|
|
472 |
var s=1.70158;var p=0;var a=c;
|
|
|
473 |
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
|
|
474 |
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
|
|
475 |
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
|
|
476 |
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
|
|
477 |
},
|
|
|
478 |
easeInOutElastic: function (x, t, b, c, d) {
|
|
|
479 |
var s=1.70158;var p=0;var a=c;
|
|
|
480 |
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
|
|
481 |
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
|
|
482 |
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
|
|
483 |
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
|
|
484 |
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
|
|
485 |
},
|
|
|
486 |
easeInBack: function (x, t, b, c, d, s) {
|
|
|
487 |
if (s == undefined) s = 1.70158;
|
|
|
488 |
return c*(t/=d)*t*((s+1)*t - s) + b;
|
|
|
489 |
},
|
|
|
490 |
easeOutBack: function (x, t, b, c, d, s) {
|
|
|
491 |
if (s == undefined) s = 1.70158;
|
|
|
492 |
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
|
|
493 |
},
|
|
|
494 |
easeInOutBack: function (x, t, b, c, d, s) {
|
|
|
495 |
if (s == undefined) s = 1.70158;
|
|
|
496 |
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
|
|
497 |
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
|
|
498 |
},
|
|
|
499 |
easeInBounce: function (x, t, b, c, d) {
|
|
|
500 |
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
|
|
501 |
},
|
|
|
502 |
easeOutBounce: function (x, t, b, c, d) {
|
|
|
503 |
if ((t/=d) < (1/2.75)) {
|
|
|
504 |
return c*(7.5625*t*t) + b;
|
|
|
505 |
} else if (t < (2/2.75)) {
|
|
|
506 |
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
|
|
507 |
} else if (t < (2.5/2.75)) {
|
|
|
508 |
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
|
|
509 |
} else {
|
|
|
510 |
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
|
|
511 |
}
|
|
|
512 |
},
|
|
|
513 |
easeInOutBounce: function (x, t, b, c, d) {
|
|
|
514 |
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
|
|
515 |
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
|
|
516 |
}
|
|
|
517 |
});
|
|
|
518 |
|
|
|
519 |
/**
|
|
|
520 |
* jQuery SliderViewer Plugin
|
|
|
521 |
* @name jquery.slideviewer.1.1.js
|
|
|
522 |
* @author Gian Carlo Mingati - http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html
|
|
|
523 |
* @version 1.1
|
|
|
524 |
* @date October 6, 2007
|
|
|
525 |
* @category jQuery plugin
|
|
|
526 |
* @copyright (c) 2007 Gian Carlo Mingati (gcmingati.net)
|
|
|
527 |
* @license ?
|
|
|
528 |
* @example Visit http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html for more informations about this jQuery plugin
|
|
|
529 |
*/
|
|
|
530 |
|
|
|
531 |
jQuery(function(){
|
|
|
532 |
jQuery("div.svw").prepend("<img src='http://www.gcmingati.net/wordpress/wp-content/uploads/svwloader.gif' class='ldrgif' alt='loading...'/ >");
|
|
|
533 |
});
|
|
|
534 |
var j = 0;
|
|
|
535 |
jQuery.fn.slideView = function(settings) {
|
|
|
536 |
settings = jQuery.extend({
|
|
|
537 |
easeFunc: "easeInOutExpo", /* <-- easing function names changed in jquery.easing.1.2.js */
|
|
|
538 |
easeTime: 750,
|
|
|
539 |
largeur: 0,
|
|
|
540 |
toolTip: true
|
|
|
541 |
}, settings);
|
|
|
542 |
return this.each(function(){
|
|
|
543 |
var container = jQuery(this);
|
|
|
544 |
container.find("img.ldrgif").remove(); // removes the preloader gif
|
|
|
545 |
container.removeClass("svw").addClass("stripViewer");
|
|
|
546 |
var pictWidth = container.find("img").width();
|
|
|
547 |
if (settings.largeur != 0) {
|
|
|
548 |
// Comme IE 6 et 7 pose problème nous utilisons une largeur spécifié par le squelette...
|
|
|
549 |
pictWidth = settings.largeur;
|
|
|
550 |
}
|
|
|
551 |
var pictHeight = container.find("img").height();
|
|
|
552 |
var pictEls = container.find("li").size();
|
|
|
553 |
var stripViewerWidth = pictWidth*pictEls;
|
|
|
554 |
container.find("ul").css("width" , stripViewerWidth); //assegnamo la larghezza alla lista UL
|
|
|
555 |
container.css("width" , pictWidth);
|
|
|
556 |
container.css("height" , pictHeight);
|
|
|
557 |
container.each(function(i) {
|
|
|
558 |
jQuery(this).after("<div id='stripTransmitter" + j + "' class='stripTransmitter'><ul><\/ul><\/div>");
|
|
|
559 |
jQuery(this).find("li").each(function(n) {
|
|
|
560 |
// Si l'image n'a pas de commentaire, on laisse vide. Sinon, on met le commentaire dans le title.
|
|
|
561 |
if (jQuery(this).find("img").attr("title") == undefined) {
|
|
|
562 |
jQuery("div#stripTransmitter" + j + " ul").append("<li><a title=' ' href='#'>"+(n+1)+"<\/a><\/li>");
|
|
|
563 |
} else {
|
|
|
564 |
jQuery("div#stripTransmitter" + j + " ul").append("<li><a title='" + jQuery(this).find("img").attr("title") + "' href='#'>"+(n+1)+"<\/a><\/li>");
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
});
|
|
|
568 |
// Insertion de l'emplacement des commentaires.
|
|
|
569 |
jQuery("div#stripTransmitter" + j).after("<p id='galerieCommentaire" + j + "' class='galerieCommentaire'><\/p>");
|
|
|
570 |
jQuery("p#galerieCommentaire"+j).css("width", pictWidth);
|
|
|
571 |
jQuery("div#stripTransmitter" + j + " a").each(function(z) {
|
|
|
572 |
jQuery(this).bind("click", function(){
|
|
|
573 |
jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current"); // wow!
|
|
|
574 |
var cnt = - (pictWidth*z);
|
|
|
575 |
// Originale : jQuery(this).parent().parent().parent().prev('.stripViewer').find("ul").animate({ left: cnt}, settings.easeTime, settings.easeFunc);
|
|
|
576 |
jQuery(this).parent().parent().parent().prevAll('.stripViewer').find("ul").animate({ left: cnt}, settings.easeTime, settings.easeFunc);
|
|
|
577 |
// Sur clic d'un numéro d'image, affichage de la valeur du title de l'image dans l'espace commentaire
|
|
|
578 |
jQuery(this).parent().parent().parent().next(".galerieCommentaire").html(jQuery(this).attr("title"));
|
|
|
579 |
return false;
|
|
|
580 |
});
|
|
|
581 |
});
|
|
|
582 |
jQuery("div#stripTransmitter" + j).css("width" , pictWidth);
|
|
|
583 |
jQuery("div#stripTransmitter" + j + " a:firsts").addClass("current");
|
|
|
584 |
|
|
|
585 |
// Quand la galerie est chargée, avant les clics sur les numéros d'image, on affiche l'attribut title du premier élément
|
|
|
586 |
jQuery("p#galerieCommentaire" + j).html(jQuery("div#stripTransmitter" + j + " a:eq(0)").attr("title"));
|
|
|
587 |
|
|
|
588 |
if(settings.toolTip){
|
|
|
589 |
container.next(".stripTransmitter ul").find("a").tooltip();
|
|
|
590 |
}
|
|
|
591 |
|
|
|
592 |
});
|
|
|
593 |
j++;
|
|
|
594 |
});
|
|
|
595 |
};
|
|
|
596 |
|
|
|
597 |
/*
|
|
|
598 |
* jQuery Tooltip plugin 1.2
|
|
|
599 |
*
|
|
|
600 |
* http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
|
|
|
601 |
* http://docs.jquery.com/Plugins/Tooltip
|
|
|
602 |
*
|
|
|
603 |
* Copyright (c) 2006 - 2008 Jörn Zaefferer
|
|
|
604 |
*
|
|
|
605 |
* $Id: jquery.tooltip.js 4569 2008-01-31 19:36:35Z joern.zaefferer $
|
|
|
606 |
*
|
|
|
607 |
* Dual licensed under the MIT and GPL licenses:
|
|
|
608 |
* http://www.opensource.org/licenses/mit-license.php
|
|
|
609 |
* http://www.gnu.org/licenses/gpl.html
|
|
|
610 |
*/
|
|
|
611 |
|
|
|
612 |
;(function($) {
|
|
|
613 |
|
|
|
614 |
// the tooltip element
|
|
|
615 |
var helper = {},
|
|
|
616 |
// the current tooltipped element
|
|
|
617 |
current,
|
|
|
618 |
// the title of the current element, used for restoring
|
|
|
619 |
title,
|
|
|
620 |
// timeout id for delayed tooltips
|
|
|
621 |
tID,
|
|
|
622 |
// IE 5.5 or 6
|
|
|
623 |
IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
|
|
|
624 |
// flag for mouse tracking
|
|
|
625 |
track = false;
|
|
|
626 |
|
|
|
627 |
$.tooltip = {
|
|
|
628 |
blocked: false,
|
|
|
629 |
defaults: {
|
|
|
630 |
delay: 200,
|
|
|
631 |
showURL: true,
|
|
|
632 |
extraClass: "",
|
|
|
633 |
top: 15,
|
|
|
634 |
left: 15,
|
|
|
635 |
id: "tooltip"
|
|
|
636 |
},
|
|
|
637 |
block: function() {
|
|
|
638 |
$.tooltip.blocked = !$.tooltip.blocked;
|
|
|
639 |
}
|
|
|
640 |
};
|
|
|
641 |
|
|
|
642 |
$.fn.extend({
|
|
|
643 |
tooltip: function(settings) {
|
|
|
644 |
settings = $.extend({}, $.tooltip.defaults, settings);
|
|
|
645 |
createHelper(settings);
|
|
|
646 |
return this.each(function() {
|
|
|
647 |
$.data(this, "tooltip-settings", settings);
|
|
|
648 |
// copy tooltip into its own expando and remove the title
|
|
|
649 |
this.tooltipText = this.title;
|
|
|
650 |
$(this).removeAttr("title");
|
|
|
651 |
// also remove alt attribute to prevent default tooltip in IE
|
|
|
652 |
this.alt = "";
|
|
|
653 |
})
|
|
|
654 |
.hover(save, hide)
|
|
|
655 |
.click(hide);
|
|
|
656 |
},
|
|
|
657 |
fixPNG: IE ? function() {
|
|
|
658 |
return this.each(function () {
|
|
|
659 |
var image = $(this).css('backgroundImage');
|
|
|
660 |
if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
|
|
|
661 |
image = RegExp.$1;
|
|
|
662 |
$(this).css({
|
|
|
663 |
'backgroundImage': 'none',
|
|
|
664 |
'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
|
|
|
665 |
}).each(function () {
|
|
|
666 |
var position = $(this).css('position');
|
|
|
667 |
if (position != 'absolute' && position != 'relative')
|
|
|
668 |
$(this).css('position', 'relative');
|
|
|
669 |
});
|
|
|
670 |
}
|
|
|
671 |
});
|
|
|
672 |
} : function() { return this; },
|
|
|
673 |
unfixPNG: IE ? function() {
|
|
|
674 |
return this.each(function () {
|
|
|
675 |
$(this).css({'filter': '', backgroundImage: ''});
|
|
|
676 |
});
|
|
|
677 |
} : function() { return this; },
|
|
|
678 |
hideWhenEmpty: function() {
|
|
|
679 |
return this.each(function() {
|
|
|
680 |
$(this)[ $(this).html() ? "show" : "hide" ]();
|
|
|
681 |
});
|
|
|
682 |
},
|
|
|
683 |
url: function() {
|
|
|
684 |
return this.attr('href') || this.attr('src');
|
|
|
685 |
}
|
|
|
686 |
});
|
|
|
687 |
|
|
|
688 |
function createHelper(settings) {
|
|
|
689 |
// there can be only one tooltip helper
|
|
|
690 |
if( helper.parent )
|
|
|
691 |
return;
|
|
|
692 |
// create the helper, h3 for title, div for url
|
|
|
693 |
helper.parent = $('<div id="' + settings.id + '"><h3></h3><div class="body"></div><div class="url"></div></div>')
|
|
|
694 |
// add to document
|
|
|
695 |
.appendTo(document.body)
|
|
|
696 |
// hide it at first
|
|
|
697 |
.hide();
|
|
|
698 |
|
|
|
699 |
// apply bgiframe if available
|
|
|
700 |
if ( $.fn.bgiframe )
|
|
|
701 |
helper.parent.bgiframe();
|
|
|
702 |
|
|
|
703 |
// save references to title and url elements
|
|
|
704 |
helper.title = $('h3', helper.parent);
|
|
|
705 |
helper.body = $('div.body', helper.parent);
|
|
|
706 |
helper.url = $('div.url', helper.parent);
|
|
|
707 |
}
|
|
|
708 |
|
|
|
709 |
function settings(element) {
|
|
|
710 |
return $.data(element, "tooltip-settings");
|
|
|
711 |
}
|
|
|
712 |
|
|
|
713 |
// main event handler to start showing tooltips
|
|
|
714 |
function handle(event) {
|
|
|
715 |
// show helper, either with timeout or on instant
|
|
|
716 |
if( settings(this).delay )
|
|
|
717 |
tID = setTimeout(show, settings(this).delay);
|
|
|
718 |
else
|
|
|
719 |
show();
|
|
|
720 |
|
|
|
721 |
// if selected, update the helper position when the mouse moves
|
|
|
722 |
track = !!settings(this).track;
|
|
|
723 |
$(document.body).bind('mousemove', update);
|
|
|
724 |
|
|
|
725 |
// update at least once
|
|
|
726 |
update(event);
|
|
|
727 |
}
|
|
|
728 |
|
|
|
729 |
// save elements title before the tooltip is displayed
|
|
|
730 |
function save() {
|
|
|
731 |
// if this is the current source, or it has no title (occurs with click event), stop
|
|
|
732 |
if ( $.tooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler) )
|
|
|
733 |
return;
|
|
|
734 |
|
|
|
735 |
// save current
|
|
|
736 |
current = this;
|
|
|
737 |
title = this.tooltipText;
|
|
|
738 |
|
|
|
739 |
if ( settings(this).bodyHandler ) {
|
|
|
740 |
helper.title.hide();
|
|
|
741 |
var bodyContent = settings(this).bodyHandler.call(this);
|
|
|
742 |
if (bodyContent.nodeType || bodyContent.jquery) {
|
|
|
743 |
helper.body.empty().append(bodyContent)
|
|
|
744 |
} else {
|
|
|
745 |
helper.body.html( bodyContent );
|
|
|
746 |
}
|
|
|
747 |
helper.body.show();
|
|
|
748 |
} else if ( settings(this).showBody ) {
|
|
|
749 |
var parts = title.split(settings(this).showBody);
|
|
|
750 |
helper.title.html(parts.shift()).show();
|
|
|
751 |
helper.body.empty();
|
|
|
752 |
for(var i = 0, part; part = parts[i]; i++) {
|
|
|
753 |
if(i > 0)
|
|
|
754 |
helper.body.append("<br/>");
|
|
|
755 |
helper.body.append(part);
|
|
|
756 |
}
|
|
|
757 |
helper.body.hideWhenEmpty();
|
|
|
758 |
} else {
|
|
|
759 |
helper.title.html(title).show();
|
|
|
760 |
helper.body.hide();
|
|
|
761 |
}
|
|
|
762 |
|
|
|
763 |
// if element has href or src, add and show it, otherwise hide it
|
|
|
764 |
if( settings(this).showURL && $(this).url() )
|
|
|
765 |
helper.url.html( $(this).url().replace('http://', '') ).show();
|
|
|
766 |
else
|
|
|
767 |
helper.url.hide();
|
|
|
768 |
|
|
|
769 |
// add an optional class for this tip
|
|
|
770 |
helper.parent.addClass(settings(this).extraClass);
|
|
|
771 |
|
|
|
772 |
// fix PNG background for IE
|
|
|
773 |
if (settings(this).fixPNG )
|
|
|
774 |
helper.parent.fixPNG();
|
|
|
775 |
|
|
|
776 |
handle.apply(this, arguments);
|
|
|
777 |
}
|
|
|
778 |
|
|
|
779 |
// delete timeout and show helper
|
|
|
780 |
function show() {
|
|
|
781 |
tID = null;
|
|
|
782 |
helper.parent.show();
|
|
|
783 |
update();
|
|
|
784 |
}
|
|
|
785 |
|
|
|
786 |
/**
|
|
|
787 |
* callback for mousemove
|
|
|
788 |
* updates the helper position
|
|
|
789 |
* removes itself when no current element
|
|
|
790 |
*/
|
|
|
791 |
function update(event) {
|
|
|
792 |
if($.tooltip.blocked)
|
|
|
793 |
return;
|
|
|
794 |
|
|
|
795 |
// stop updating when tracking is disabled and the tooltip is visible
|
|
|
796 |
if ( !track && helper.parent.is(":visible")) {
|
|
|
797 |
$(document.body).unbind('mousemove', update)
|
|
|
798 |
}
|
|
|
799 |
|
|
|
800 |
// if no current element is available, remove this listener
|
|
|
801 |
if( current == null ) {
|
|
|
802 |
$(document.body).unbind('mousemove', update);
|
|
|
803 |
return;
|
|
|
804 |
}
|
|
|
805 |
|
|
|
806 |
// remove position helper classes
|
|
|
807 |
helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");
|
|
|
808 |
|
|
|
809 |
var left = helper.parent[0].offsetLeft;
|
|
|
810 |
var top = helper.parent[0].offsetTop;
|
|
|
811 |
if(event) {
|
|
|
812 |
// position the helper 15 pixel to bottom right, starting from mouse position
|
|
|
813 |
left = event.pageX + settings(current).left;
|
|
|
814 |
top = event.pageY + settings(current).top;
|
|
|
815 |
helper.parent.css({
|
|
|
816 |
left: left + 'px',
|
|
|
817 |
top: top + 'px'
|
|
|
818 |
});
|
|
|
819 |
}
|
|
|
820 |
|
|
|
821 |
var v = viewport(),
|
|
|
822 |
h = helper.parent[0];
|
|
|
823 |
// check horizontal position
|
|
|
824 |
if(v.x + v.cx < h.offsetLeft + h.offsetWidth) {
|
|
|
825 |
left -= h.offsetWidth + 20 + settings(current).left;
|
|
|
826 |
helper.parent.css({left: left + 'px'}).addClass("viewport-right");
|
|
|
827 |
}
|
|
|
828 |
// check vertical position
|
|
|
829 |
if(v.y + v.cy < h.offsetTop + h.offsetHeight) {
|
|
|
830 |
top -= h.offsetHeight + 20 + settings(current).top;
|
|
|
831 |
helper.parent.css({top: top + 'px'}).addClass("viewport-bottom");
|
|
|
832 |
}
|
|
|
833 |
}
|
|
|
834 |
|
|
|
835 |
function viewport() {
|
|
|
836 |
return {
|
|
|
837 |
x: $(window).scrollLeft(),
|
|
|
838 |
y: $(window).scrollTop(),
|
|
|
839 |
cx: $(window).width(),
|
|
|
840 |
cy: $(window).height()
|
|
|
841 |
};
|
|
|
842 |
}
|
|
|
843 |
|
|
|
844 |
// hide helper and restore added classes and the title
|
|
|
845 |
function hide(event) {
|
|
|
846 |
if($.tooltip.blocked)
|
|
|
847 |
return;
|
|
|
848 |
// clear timeout if possible
|
|
|
849 |
if(tID)
|
|
|
850 |
clearTimeout(tID);
|
|
|
851 |
// no more current element
|
|
|
852 |
current = null;
|
|
|
853 |
|
|
|
854 |
helper.parent.hide().removeClass( settings(this).extraClass );
|
|
|
855 |
|
|
|
856 |
if( settings(this).fixPNG )
|
|
|
857 |
helper.parent.unfixPNG();
|
|
|
858 |
}
|
|
|
859 |
|
|
|
860 |
$.fn.Tooltip = $.fn.tooltip;
|
|
|
861 |
|
|
|
862 |
})(jQuery);
|