2763 |
daniel |
1 |
/*!
|
|
|
2 |
* clueTip - v1.2.9 - 2013-06-02
|
|
|
3 |
* http://plugins.learningjquery.com/cluetip/
|
|
|
4 |
* Copyright (c) 2013 Karl Swedberg
|
|
|
5 |
* Licensed MIT (http://www.opensource.org/licenses/mit-license.php)
|
|
|
6 |
*/
|
|
|
7 |
|
|
|
8 |
(function($) {
|
|
|
9 |
|
|
|
10 |
$.cluetip = {
|
|
|
11 |
version: '1.2.9',
|
|
|
12 |
|
|
|
13 |
// the HTML that will be used for the tooltip
|
|
|
14 |
template: ['<div>',
|
|
|
15 |
'<div class="cluetip-outer">',
|
|
|
16 |
'<h3 class="cluetip-title ui-widget-header ui-cluetip-header"></h3>',
|
|
|
17 |
'<div class="cluetip-inner ui-widget-content ui-cluetip-content"></div>',
|
|
|
18 |
'</div>',
|
|
|
19 |
'<div class="cluetip-extra"></div>',
|
|
|
20 |
'</div>'].join(''),
|
|
|
21 |
|
|
|
22 |
/* clueTip setup
|
|
|
23 |
* the setup options are applied each time .cluetip() is called,
|
|
|
24 |
* BUT only if <div id="cluetip"> is not already in the document
|
|
|
25 |
*/
|
|
|
26 |
setup: {
|
|
|
27 |
// method to be used for inserting the clueTip into the DOM.
|
|
|
28 |
// Permitted values are 'appendTo', 'prependTo', 'insertBefore', and 'insertAfter'
|
|
|
29 |
insertionType: 'appendTo',
|
|
|
30 |
// element in the DOM the plugin will reference when inserting the clueTip.
|
|
|
31 |
insertionElement: 'body'
|
|
|
32 |
},
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
* clueTip options
|
|
|
36 |
*
|
|
|
37 |
* each one can be explicitly overridden by changing its value.
|
|
|
38 |
* for example: $.cluetip.defaults.width = 200;
|
|
|
39 |
* or: $.fn.cluetip.defaults.width = 200; // for compatibility with previous clueTip versions
|
|
|
40 |
* would change the default width for all clueTips to 200.
|
|
|
41 |
*
|
|
|
42 |
* each one can also be overridden by passing an options map to the cluetip method.
|
|
|
43 |
* for example: $('a.example').cluetip({width: 200});
|
|
|
44 |
* would change the default width to 200 for clueTips invoked by a link with class of "example"
|
|
|
45 |
*
|
|
|
46 |
*/
|
|
|
47 |
defaults: {
|
|
|
48 |
multiple: false, // Allow a new tooltip to be created for each .cluetip() call
|
|
|
49 |
width: 275, // The width of the clueTip
|
|
|
50 |
height: 'auto', // The height of the clueTip
|
|
|
51 |
cluezIndex: 97, // Sets the z-index style property of the clueTip
|
|
|
52 |
positionBy: 'auto', // Sets the type of positioning: 'auto', 'mouse','bottomTop', 'topBottom', fixed'
|
|
|
53 |
topOffset: 15, // Number of px to offset clueTip from top of invoking element
|
|
|
54 |
leftOffset: 15, // Number of px to offset clueTip from left of invoking element
|
|
|
55 |
snapToEdge: false, // For bottomTop and topBottom, snap to the top or bottom of the element.
|
|
|
56 |
local: false, // Whether to use content from the same page for the clueTip's body
|
|
|
57 |
localPrefix: null, // string to be prepended to the tip attribute if local is true
|
|
|
58 |
localIdSuffix: null, // string to be appended to the cluetip content element's id if local is true
|
|
|
59 |
hideLocal: true, // If local option is set to true, this determines whether local content
|
|
|
60 |
// to be shown in clueTip should be hidden at its original location
|
|
|
61 |
attribute: 'rel', // the attribute to be used for fetching the clueTip's body content
|
|
|
62 |
titleAttribute: 'title', // the attribute to be used for fetching the clueTip's title
|
|
|
63 |
splitTitle: '', // A character used to split the title attribute into the clueTip title and divs
|
|
|
64 |
// within the clueTip body. more info below [6]
|
|
|
65 |
escapeTitle: false, // whether to html escape the title attribute
|
|
|
66 |
showTitle: true, // show title bar of the clueTip, even if title attribute not set
|
|
|
67 |
cluetipClass: 'default',// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass.
|
|
|
68 |
hoverClass: '', // class applied to the invoking element onmouseover and removed onmouseout
|
|
|
69 |
waitImage: true, // whether to show a "loading" img, which is set in jquery.cluetip.css
|
|
|
70 |
cursor: 'help',
|
|
|
71 |
arrows: false, // if true, displays arrow on appropriate side of clueTip
|
|
|
72 |
dropShadow: true, // set to false if you don't want the drop-shadow effect on the clueTip
|
|
|
73 |
dropShadowSteps: 6, // adjusts the size of the drop shadow
|
|
|
74 |
sticky: false, // keep visible until manually closed
|
|
|
75 |
mouseOutClose: false, // close when clueTip is moused out: false, 'cluetip', 'link', 'both'
|
|
|
76 |
delayedClose: 50, // close clueTip on a timed delay
|
|
|
77 |
activation: 'hover', // set to 'click' to force user to click to show clueTip
|
|
|
78 |
// set to 'focus' to show on focus of a form element and hide on blur
|
|
|
79 |
clickThrough: true, // if true, and activation is not 'click', then clicking on link will take user to the link's href,
|
|
|
80 |
// even if href and tipAttribute are equal
|
|
|
81 |
tracking: false, // if true, clueTip will track mouse movement (experimental)
|
|
|
82 |
closePosition: 'top', // location of close text for sticky cluetips; can be 'top', 'bottom', 'title' or 'none'
|
|
|
83 |
closeText: 'Close', // text (or HTML) to to be clicked to close sticky clueTips
|
|
|
84 |
truncate: 0, // number of characters to truncate clueTip's contents. if 0, no truncation occurs
|
|
|
85 |
|
|
|
86 |
// effect and speed for opening clueTips
|
|
|
87 |
fx: {
|
|
|
88 |
open: 'show', // can be 'show' or 'slideDown' or 'fadeIn'
|
|
|
89 |
openSpeed: ''
|
|
|
90 |
},
|
|
|
91 |
|
|
|
92 |
// settings for when hoverIntent plugin is used
|
|
|
93 |
hoverIntent: {
|
|
|
94 |
sensitivity: 3,
|
|
|
95 |
interval: 50,
|
|
|
96 |
timeout: 0
|
|
|
97 |
},
|
|
|
98 |
|
|
|
99 |
// short-circuit function to run just before clueTip is shown.
|
|
|
100 |
onActivate: function(e) {return true;},
|
|
|
101 |
// function to run just after clueTip is shown.
|
|
|
102 |
onShow: function(ct, ci){},
|
|
|
103 |
// function to run just after clueTip is hidden.
|
|
|
104 |
onHide: function(ct, ci){},
|
|
|
105 |
// whether to cache results of ajax request to avoid unnecessary hits to server
|
|
|
106 |
ajaxCache: true,
|
|
|
107 |
|
|
|
108 |
// process data retrieved via xhr before it's displayed
|
|
|
109 |
ajaxProcess: function(data) {
|
|
|
110 |
data = data.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm, '').replace(/<(link|meta)[^>]+>/g,'');
|
|
|
111 |
return data;
|
|
|
112 |
},
|
|
|
113 |
|
|
|
114 |
// can pass in standard $.ajax() parameters. Callback functions, such as beforeSend,
|
|
|
115 |
// will be queued first within the default callbacks.
|
|
|
116 |
// The only exception is error, which overrides the default
|
|
|
117 |
ajaxSettings: {
|
|
|
118 |
// error: function(ct, ci) { /* override default error callback */ },
|
|
|
119 |
// beforeSend: function(ct, ci) { /* called first within default beforeSend callback */ },
|
|
|
120 |
dataType: 'html'
|
|
|
121 |
},
|
|
|
122 |
debug: false
|
|
|
123 |
|
|
|
124 |
}
|
|
|
125 |
};
|
|
|
126 |
var $cluetipWait,
|
|
|
127 |
standardClasses = 'cluetip ui-widget ui-widget-content ui-cluetip',
|
|
|
128 |
caches = {},
|
|
|
129 |
counter = 0,
|
|
|
130 |
imgCount = 0;
|
|
|
131 |
|
|
|
132 |
// use $.fn.prop() if available (jQuery 1.6+); otherwise, $.fn.attr()
|
|
|
133 |
$.fn.attrProp = $.fn.prop || $.fn.attr;
|
|
|
134 |
|
|
|
135 |
// .cluetip() method
|
|
|
136 |
$.fn.cluetip = function(js, options) {
|
|
|
137 |
var $cluetip, $cluetipInner, $cluetipOuter, $cluetipTitle, $cluetipArrows, $dropShadow;
|
|
|
138 |
if (typeof js == 'object') {
|
|
|
139 |
options = js;
|
|
|
140 |
js = null;
|
|
|
141 |
}
|
|
|
142 |
if (js == 'destroy') {
|
|
|
143 |
this.each(function(index) {
|
|
|
144 |
var $l = $(this),
|
|
|
145 |
data = $l.data('cluetip');
|
|
|
146 |
if ( data ) {
|
|
|
147 |
$(data.selector).remove();
|
|
|
148 |
$.removeData(this, 'title');
|
|
|
149 |
$.removeData(this, 'cluetip');
|
|
|
150 |
}
|
|
|
151 |
if (data.title) {
|
|
|
152 |
$l.attrProp('title', data.title);
|
|
|
153 |
}
|
|
|
154 |
$l.unbind('.cluetip').unbind('cluetipMoc');
|
|
|
155 |
});
|
|
|
156 |
if ( !$('[id^="cluetip"]').length ) {
|
|
|
157 |
$(document).unbind('.cluetip');
|
|
|
158 |
}
|
|
|
159 |
return this;
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
// merge per-call options with defaults
|
|
|
163 |
options = $.extend(true, {}, $.cluetip.defaults, options || {});
|
|
|
164 |
|
|
|
165 |
/** =create cluetip divs **/
|
|
|
166 |
counter++;
|
|
|
167 |
var cluezIndex,
|
|
|
168 |
cluetipId = $.cluetip.backCompat || !options.multiple ? 'cluetip' : 'cluetip-' + counter,
|
|
|
169 |
cluetipSelector = '#' + cluetipId,
|
|
|
170 |
prefix = $.cluetip.backCompat ? '#' : '.',
|
|
|
171 |
insertionType = $.cluetip.setup.insertionType,
|
|
|
172 |
insertionElement = $.cluetip.setup.insertionElement || 'body';
|
|
|
173 |
|
|
|
174 |
insertionType = (/appendTo|prependTo|insertBefore|insertAfter/).test(insertionType) ? insertionType : 'appendTo';
|
|
|
175 |
$cluetip = $(cluetipSelector);
|
|
|
176 |
if (!$cluetip.length) {
|
|
|
177 |
|
|
|
178 |
$cluetip = $($.cluetip.template)
|
|
|
179 |
[insertionType](insertionElement)
|
|
|
180 |
.attr('id', cluetipId)
|
|
|
181 |
.css({position: 'absolute', display: 'none'});
|
|
|
182 |
|
|
|
183 |
cluezIndex = +options.cluezIndex;
|
|
|
184 |
$cluetipOuter = $cluetip.find(prefix + 'cluetip-outer').css({position: 'relative', zIndex: cluezIndex});
|
|
|
185 |
$cluetipInner = $cluetip.find(prefix + 'cluetip-inner');
|
|
|
186 |
$cluetipTitle = $cluetip.find(prefix + 'cluetip-title');
|
|
|
187 |
|
|
|
188 |
$cluetip.bind('mouseenter mouseleave', function(event) {
|
|
|
189 |
$(this).data('entered', event.type === 'mouseenter');
|
|
|
190 |
});
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
$cluetipWait = $('#cluetip-waitimage');
|
|
|
194 |
if (!$cluetipWait.length && options.waitImage) {
|
|
|
195 |
$cluetipWait = $('<div></div>').attr('id', 'cluetip-waitimage').css({position: 'absolute'});
|
|
|
196 |
$cluetipWait.insertBefore($cluetip).hide();
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
var cluetipPadding = (parseInt($cluetip.css('paddingLeft'), 10) || 0) + (parseInt($cluetip.css('paddingRight'), 10) || 0);
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
this.each(function(index) {
|
|
|
204 |
var link = this,
|
|
|
205 |
$link = $(this),
|
|
|
206 |
// support metadata plugin (v1.0 and 2.0)
|
|
|
207 |
opts = $.extend(true, {}, options, $.metadata ? $link.metadata() : $.meta ? $link.data() : $link.data('cluetip') || {}),
|
|
|
208 |
// start out with no contents (for ajax activation)
|
|
|
209 |
cluetipContents = false,
|
|
|
210 |
isActive = false,
|
|
|
211 |
closeOnDelay = null,
|
|
|
212 |
tipAttribute = opts[opts.attribute] ||
|
|
|
213 |
( opts.attribute == 'href' ? $link.attr(opts.attribute) : $link.attrProp(opts.attribute) || $link.attr(opts.attribute) ),
|
|
|
214 |
ctClass = opts.cluetipClass;
|
|
|
215 |
|
|
|
216 |
cluezIndex = +opts.cluezIndex;
|
|
|
217 |
$link.data('cluetip', {title: link.title, zIndex: cluezIndex, selector: cluetipSelector, cursor: link.style.cursor || ''});
|
|
|
218 |
|
|
|
219 |
if (opts.arrows && !$cluetip.find('.cluetip-arrows').length) {
|
|
|
220 |
$cluetip.append('<div class="cluetip-arrows ui-state-default"></div>');
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
if (!tipAttribute && !opts.splitTitle && !js) {
|
|
|
224 |
return true;
|
|
|
225 |
}
|
|
|
226 |
// if hideLocal is set to true, on DOM ready hide the local content that will be displayed in the clueTip
|
|
|
227 |
if (opts.local && opts.localPrefix) {tipAttribute = opts.localPrefix + tipAttribute;}
|
|
|
228 |
if (opts.local && opts.hideLocal && tipAttribute) { $(tipAttribute + ':first').hide(); }
|
|
|
229 |
|
|
|
230 |
var tOffset = parseInt(opts.topOffset, 10), lOffset = parseInt(opts.leftOffset, 10);
|
|
|
231 |
// vertical measurement variables
|
|
|
232 |
var tipHeight, wHeight,
|
|
|
233 |
defHeight = isNaN(parseInt(opts.height, 10)) ? 'auto' : (/\D/g).test(opts.height) ? opts.height : opts.height + 'px';
|
|
|
234 |
var sTop, linkTop, linkBottom, posY, tipY, mouseY, baseline;
|
|
|
235 |
// horizontal measurement variables
|
|
|
236 |
var tipInnerWidth = parseInt(opts.width, 10) || 275,
|
|
|
237 |
tipWidth = tipInnerWidth + cluetipPadding + opts.dropShadowSteps,
|
|
|
238 |
linkWidth = this.offsetWidth,
|
|
|
239 |
linkLeft, posX, tipX, mouseX, winWidth;
|
|
|
240 |
|
|
|
241 |
// parse the title
|
|
|
242 |
var tipParts;
|
|
|
243 |
var tipTitle = (opts.attribute != 'title') ? $link.attr(opts.titleAttribute) || '' : '';
|
|
|
244 |
if (opts.splitTitle) {
|
|
|
245 |
tipParts = tipTitle.split(opts.splitTitle);
|
|
|
246 |
tipTitle = opts.showTitle || tipParts[0] === '' ? tipParts.shift() : '';
|
|
|
247 |
}
|
|
|
248 |
if (opts.escapeTitle) {
|
|
|
249 |
tipTitle = tipTitle.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<');
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
var localContent;
|
|
|
253 |
function returnFalse() { return false; }
|
|
|
254 |
|
|
|
255 |
// Keep track of mouse entered state on link
|
|
|
256 |
$link.bind('mouseenter mouseleave', function(event) {
|
|
|
257 |
var data = $link.data('cluetip');
|
|
|
258 |
data.entered = event.type === 'entered';
|
|
|
259 |
$link.data('cluetip', data);
|
|
|
260 |
});
|
|
|
261 |
|
|
|
262 |
/***************************************
|
|
|
263 |
* ACTIVATION
|
|
|
264 |
****************************************/
|
|
|
265 |
|
|
|
266 |
//activate clueTip
|
|
|
267 |
var activate = function(event) {
|
|
|
268 |
var pY, ajaxMergedSettings, cacheKey,
|
|
|
269 |
continueOn = opts.onActivate.call(link, event);
|
|
|
270 |
|
|
|
271 |
if (continueOn === false) {
|
|
|
272 |
return false;
|
|
|
273 |
}
|
|
|
274 |
|
|
|
275 |
isActive = true;
|
|
|
276 |
|
|
|
277 |
// activate function may get called after an initialization of a
|
|
|
278 |
// different target so need to re-get the Correct Cluetip object here
|
|
|
279 |
$cluetip = $(cluetipSelector).css({position: 'absolute'});
|
|
|
280 |
$cluetipOuter = $cluetip.find(prefix + 'cluetip-outer');
|
|
|
281 |
$cluetipInner = $cluetip.find(prefix + 'cluetip-inner');
|
|
|
282 |
$cluetipTitle = $cluetip.find(prefix + 'cluetip-title');
|
|
|
283 |
$cluetipArrows = $cluetip.find(prefix + 'cluetip-arrows');
|
|
|
284 |
$cluetip.removeClass().css({width: tipInnerWidth});
|
|
|
285 |
if (tipAttribute == $link.attr('href')) {
|
|
|
286 |
$link.css('cursor', opts.cursor);
|
|
|
287 |
}
|
|
|
288 |
if (opts.hoverClass) {
|
|
|
289 |
$link.addClass(opts.hoverClass);
|
|
|
290 |
}
|
|
|
291 |
linkTop = posY = $link.offset().top;
|
|
|
292 |
linkBottom = linkTop + $link.innerHeight();
|
|
|
293 |
linkLeft = $link.offset().left;
|
|
|
294 |
if ( $(insertionElement).css('position') === 'relative' ) {
|
|
|
295 |
linkLeft -= $(insertionElement)[0].getBoundingClientRect().left;
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
// FIX: (bug 4412)
|
|
|
299 |
linkWidth = $link.innerWidth();
|
|
|
300 |
if ( event.type == focus ) {
|
|
|
301 |
// in focus event, no mouse position is available; this is needed with bottomTop:
|
|
|
302 |
mouseX = linkLeft + ( linkWidth / 2 ) + lOffset;
|
|
|
303 |
$cluetip.css({left: posX});
|
|
|
304 |
mouseY = posY + tOffset;
|
|
|
305 |
} else {
|
|
|
306 |
mouseX = event.pageX;
|
|
|
307 |
mouseY = event.pageY;
|
|
|
308 |
}
|
|
|
309 |
//END OF FIX
|
|
|
310 |
|
|
|
311 |
if (link.tagName.toLowerCase() != 'area') {
|
|
|
312 |
sTop = $(document).scrollTop();
|
|
|
313 |
winWidth = $(window).width();
|
|
|
314 |
}
|
|
|
315 |
// position clueTip horizontally
|
|
|
316 |
if (opts.positionBy == 'fixed') {
|
|
|
317 |
posX = linkWidth + linkLeft + lOffset;
|
|
|
318 |
$cluetip.css({left: posX});
|
|
|
319 |
} else {
|
|
|
320 |
posX = (linkWidth > linkLeft && linkLeft > tipWidth) ||
|
|
|
321 |
linkLeft + linkWidth + tipWidth + lOffset > winWidth ?
|
|
|
322 |
linkLeft - tipWidth - lOffset :
|
|
|
323 |
linkWidth + linkLeft + lOffset;
|
|
|
324 |
if (link.tagName.toLowerCase() == 'area' || opts.positionBy == 'mouse' || linkWidth + tipWidth > winWidth) { // position by mouse
|
|
|
325 |
if (mouseX + 20 + tipWidth > winWidth) {
|
|
|
326 |
$cluetip.addClass('cluetip-' + ctClass);
|
|
|
327 |
posX = (mouseX - tipWidth - lOffset) >= 0 ? mouseX - tipWidth - lOffset - parseInt($cluetip.css('marginLeft'),10) + parseInt($cluetipInner.css('marginRight'),10) : mouseX - (tipWidth/2);
|
|
|
328 |
} else {
|
|
|
329 |
posX = mouseX + lOffset;
|
|
|
330 |
}
|
|
|
331 |
}
|
|
|
332 |
pY = posX < 0 ? event.pageY + tOffset : event.pageY;
|
|
|
333 |
if (posX < 0 || opts.positionBy == 'bottomTop' || opts.positionBy == 'topBottom') {
|
|
|
334 |
posX = (mouseX + (tipWidth/2) > winWidth) ? winWidth/2 - tipWidth/2 : Math.max(mouseX - (tipWidth/2),0);
|
|
|
335 |
}
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
$cluetipArrows.css({zIndex: $link.data('cluetip').zIndex+1});
|
|
|
339 |
$cluetip.css({
|
|
|
340 |
left: posX,
|
|
|
341 |
zIndex: $link.data('cluetip').zIndex
|
|
|
342 |
});
|
|
|
343 |
wHeight = $(window).height();
|
|
|
344 |
|
|
|
345 |
/***************************************
|
|
|
346 |
* load a string from cluetip method's first argument
|
|
|
347 |
***************************************/
|
|
|
348 |
if (js) {
|
|
|
349 |
if (typeof js == 'function') {
|
|
|
350 |
js = js.call(link);
|
|
|
351 |
}
|
|
|
352 |
$cluetipInner.html(js);
|
|
|
353 |
cluetipShow(pY);
|
|
|
354 |
}
|
|
|
355 |
/***************************************
|
|
|
356 |
* load the title attribute only (or user-selected attribute).
|
|
|
357 |
* clueTip title is the string before the first delimiter
|
|
|
358 |
* subsequent delimiters place clueTip body text on separate lines
|
|
|
359 |
***************************************/
|
|
|
360 |
|
|
|
361 |
else if (tipParts) {
|
|
|
362 |
var tpl = tipParts.length;
|
|
|
363 |
$cluetipInner.html(tpl ? tipParts[0] : '');
|
|
|
364 |
if (tpl > 1) {
|
|
|
365 |
for (var i=1; i < tpl; i++){
|
|
|
366 |
$cluetipInner.append('<div class="split-body">' + tipParts[i] + '</div>');
|
|
|
367 |
}
|
|
|
368 |
}
|
|
|
369 |
cluetipShow(pY);
|
|
|
370 |
}
|
|
|
371 |
/***************************************
|
|
|
372 |
* load external file via ajax
|
|
|
373 |
***************************************/
|
|
|
374 |
|
|
|
375 |
else if ( !opts.local && tipAttribute.indexOf('#') !== 0 ) {
|
|
|
376 |
if (/\.(jpe?g|tiff?|gif|png)(?:\?.*)?$/i.test(tipAttribute)) {
|
|
|
377 |
$cluetipInner.html('<img src="' + tipAttribute + '" alt="' + tipTitle + '" />');
|
|
|
378 |
cluetipShow(pY);
|
|
|
379 |
} else {
|
|
|
380 |
var optionBeforeSend = opts.ajaxSettings.beforeSend,
|
|
|
381 |
optionError = opts.ajaxSettings.error,
|
|
|
382 |
optionSuccess = opts.ajaxSettings.success,
|
|
|
383 |
optionComplete = opts.ajaxSettings.complete;
|
|
|
384 |
|
|
|
385 |
cacheKey = getCacheKey(tipAttribute, opts.ajaxSettings.data);
|
|
|
386 |
|
|
|
387 |
var ajaxSettings = {
|
|
|
388 |
cache: opts.ajaxCache, // force requested page not to be cached by browser
|
|
|
389 |
url: tipAttribute,
|
|
|
390 |
beforeSend: function(xhr, settings) {
|
|
|
391 |
if (optionBeforeSend) {optionBeforeSend.call(link, xhr, $cluetip, $cluetipInner, settings);}
|
|
|
392 |
$cluetipOuter.children().empty();
|
|
|
393 |
if (opts.waitImage) {
|
|
|
394 |
$cluetipWait
|
|
|
395 |
.css({top: mouseY+20, left: mouseX+20, zIndex: $link.data('cluetip').zIndex-1})
|
|
|
396 |
.show();
|
|
|
397 |
}
|
|
|
398 |
},
|
|
|
399 |
error: function(xhr, textStatus) {
|
|
|
400 |
if ( options.ajaxCache && !caches[cacheKey] ) {
|
|
|
401 |
caches[cacheKey] = {status: 'error', textStatus: textStatus, xhr: xhr};
|
|
|
402 |
}
|
|
|
403 |
|
|
|
404 |
if (isActive) {
|
|
|
405 |
if (optionError) {
|
|
|
406 |
optionError.call(link, xhr, textStatus, $cluetip, $cluetipInner);
|
|
|
407 |
} else {
|
|
|
408 |
$cluetipInner.html('<i>sorry, the contents could not be loaded</i>');
|
|
|
409 |
}
|
|
|
410 |
}
|
|
|
411 |
},
|
|
|
412 |
success: function(data, textStatus, xhr) {
|
|
|
413 |
if ( options.ajaxCache && !caches[cacheKey] ) {
|
|
|
414 |
caches[cacheKey] = {status: 'success', data: data, textStatus: textStatus, xhr: xhr};
|
|
|
415 |
}
|
|
|
416 |
|
|
|
417 |
cluetipContents = opts.ajaxProcess.call(link, data);
|
|
|
418 |
|
|
|
419 |
// allow for changing the title based on data returned by xhr
|
|
|
420 |
if ( typeof cluetipContents == 'object' && cluetipContents !== null ) {
|
|
|
421 |
tipTitle = cluetipContents.title;
|
|
|
422 |
cluetipContents = cluetipContents.content;
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
if (isActive) {
|
|
|
426 |
if (optionSuccess) {
|
|
|
427 |
optionSuccess.call(link, data, textStatus, $cluetip, $cluetipInner);
|
|
|
428 |
}
|
|
|
429 |
$cluetipInner.html(cluetipContents);
|
|
|
430 |
|
|
|
431 |
}
|
|
|
432 |
},
|
|
|
433 |
complete: function(xhr, textStatus) {
|
|
|
434 |
if (optionComplete) {
|
|
|
435 |
optionComplete.call(link, xhr, textStatus, $cluetip, $cluetipInner);
|
|
|
436 |
}
|
|
|
437 |
var imgs = $cluetipInner[0].getElementsByTagName('img');
|
|
|
438 |
imgCount = imgs.length;
|
|
|
439 |
for (var i=0, l = imgs.length; i < l; i++) {
|
|
|
440 |
if (imgs[i].complete) {
|
|
|
441 |
imgCount--;
|
|
|
442 |
}
|
|
|
443 |
}
|
|
|
444 |
if (imgCount) {
|
|
|
445 |
$(imgs).bind('load.ct error.ct', function() {
|
|
|
446 |
imgCount--;
|
|
|
447 |
if (imgCount === 0) {
|
|
|
448 |
$cluetipWait.hide();
|
|
|
449 |
$(imgs).unbind('.ct');
|
|
|
450 |
if (isActive) { cluetipShow(pY); }
|
|
|
451 |
}
|
|
|
452 |
});
|
|
|
453 |
} else {
|
|
|
454 |
$cluetipWait.hide();
|
|
|
455 |
if (isActive) { cluetipShow(pY); }
|
|
|
456 |
}
|
|
|
457 |
}
|
|
|
458 |
};
|
|
|
459 |
|
|
|
460 |
ajaxMergedSettings = $.extend(true, {}, opts.ajaxSettings, ajaxSettings);
|
|
|
461 |
|
|
|
462 |
if ( caches[cacheKey] ) {
|
|
|
463 |
cachedAjax( caches[cacheKey], ajaxMergedSettings );
|
|
|
464 |
} else {
|
|
|
465 |
$.ajax(ajaxMergedSettings);
|
|
|
466 |
}
|
|
|
467 |
}
|
|
|
468 |
}
|
|
|
469 |
/***************************************
|
|
|
470 |
* load an element from the same page
|
|
|
471 |
***************************************/
|
|
|
472 |
else if (opts.local) {
|
|
|
473 |
var $localContent = $(tipAttribute + (/^#\S+$/.test(tipAttribute) ? '' : ':eq(' + index + ')')).clone(true).show();
|
|
|
474 |
if (opts.localIdSuffix) {
|
|
|
475 |
$localContent.attr('id', $localContent[0].id + opts.localIdSuffix);
|
|
|
476 |
}
|
|
|
477 |
$cluetipInner.html($localContent);
|
|
|
478 |
cluetipShow(pY);
|
|
|
479 |
}
|
|
|
480 |
};
|
|
|
481 |
|
|
|
482 |
// get dimensions and options for cluetip and prepare it to be shown
|
|
|
483 |
var cluetipShow = function(bpY) {
|
|
|
484 |
var $closeLink, dynamicClasses, heightDiff,
|
|
|
485 |
titleHTML = tipTitle || opts.showTitle && ' ',
|
|
|
486 |
bgY = '', direction = '', insufficientX = false;
|
|
|
487 |
var stickyClose = {
|
|
|
488 |
bottom: function($cLink) {
|
|
|
489 |
$cLink.appendTo($cluetipInner);
|
|
|
490 |
},
|
|
|
491 |
top: function($cLink) {
|
|
|
492 |
$cLink.prependTo($cluetipInner);
|
|
|
493 |
},
|
|
|
494 |
title: function($cLink) {
|
|
|
495 |
$cLink.prependTo($cluetipTitle);
|
|
|
496 |
}
|
|
|
497 |
};
|
|
|
498 |
|
|
|
499 |
$cluetip.addClass('cluetip-' + ctClass);
|
|
|
500 |
if (opts.truncate) {
|
|
|
501 |
var $truncloaded = $cluetipInner.text().slice(0,opts.truncate) + '...';
|
|
|
502 |
$cluetipInner.html($truncloaded);
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
if (titleHTML) {
|
|
|
506 |
$cluetipTitle.show().html(titleHTML);
|
|
|
507 |
} else {
|
|
|
508 |
$cluetipTitle.hide();
|
|
|
509 |
}
|
|
|
510 |
|
|
|
511 |
if (opts.sticky) {
|
|
|
512 |
if (stickyClose[opts.closePosition]) {
|
|
|
513 |
$closeLink = $('<div class="cluetip-close"><a href="#">' + opts.closeText + '</a></div>');
|
|
|
514 |
stickyClose[opts.closePosition]( $closeLink );
|
|
|
515 |
$closeLink.bind('click.cluetip', function() {
|
|
|
516 |
cluetipClose();
|
|
|
517 |
return false;
|
|
|
518 |
});
|
|
|
519 |
}
|
|
|
520 |
if (opts.mouseOutClose) {
|
|
|
521 |
$link.unbind('mouseleave.cluetipMoc');
|
|
|
522 |
$cluetip.unbind('mouseleave.cluetipMoc');
|
|
|
523 |
if (opts.mouseOutClose == 'both' || opts.mouseOutClose == 'cluetip' || opts.mouseOutClose === true) { // true implies 'cluetip' for backwards compatability
|
|
|
524 |
$cluetip.bind('mouseleave.cluetipMoc', mouseOutClose);
|
|
|
525 |
}
|
|
|
526 |
if (opts.mouseOutClose == 'both' || opts.mouseOutClose == 'link') {
|
|
|
527 |
$link.bind('mouseleave.cluetipMoc', mouseOutClose);
|
|
|
528 |
}
|
|
|
529 |
}
|
|
|
530 |
}
|
|
|
531 |
|
|
|
532 |
// now that content is loaded, finish the positioning
|
|
|
533 |
$cluetipOuter.css({zIndex: $link.data('cluetip').zIndex, overflow: defHeight == 'auto' ? 'visible' : 'auto', height: defHeight});
|
|
|
534 |
tipHeight = defHeight == 'auto' ? Math.max($cluetip.outerHeight(),$cluetip.height()) : parseInt(defHeight,10);
|
|
|
535 |
tipY = posY;
|
|
|
536 |
baseline = sTop + wHeight;
|
|
|
537 |
insufficientX = (posX < mouseX && (Math.max(posX, 0) + tipWidth > mouseX));
|
|
|
538 |
if (opts.positionBy == 'fixed') {
|
|
|
539 |
tipY = posY - opts.dropShadowSteps + tOffset;
|
|
|
540 |
} else if (opts.positionBy == 'topBottom' || opts.positionBy == 'bottomTop' || insufficientX) {
|
|
|
541 |
if (opts.positionBy == 'topBottom') {
|
|
|
542 |
if (posY + tipHeight + tOffset < baseline && mouseY - sTop < tipHeight + tOffset) {
|
|
|
543 |
direction = 'bottom';
|
|
|
544 |
} else {
|
|
|
545 |
direction = 'top';
|
|
|
546 |
}
|
|
|
547 |
} else if (opts.positionBy == 'bottomTop' || insufficientX) {
|
|
|
548 |
if (posY + tipHeight + tOffset > baseline && mouseY - sTop > tipHeight + tOffset) {
|
|
|
549 |
direction = 'top';
|
|
|
550 |
} else {
|
|
|
551 |
direction = 'bottom';
|
|
|
552 |
}
|
|
|
553 |
}
|
|
|
554 |
// We should now have a direction. Compute tipY
|
|
|
555 |
if (opts.snapToEdge) {
|
|
|
556 |
if (direction == 'top') {
|
|
|
557 |
tipY = linkTop - tipHeight - tOffset;
|
|
|
558 |
} else if (direction == 'bottom') {
|
|
|
559 |
tipY = linkBottom + tOffset;
|
|
|
560 |
}
|
|
|
561 |
} else {
|
|
|
562 |
if (direction == 'top') {
|
|
|
563 |
tipY = mouseY - tipHeight - tOffset;
|
|
|
564 |
} else if (direction == 'bottom') {
|
|
|
565 |
tipY = mouseY + tOffset;
|
|
|
566 |
}
|
|
|
567 |
}
|
|
|
568 |
} else if ( posY + tipHeight + tOffset > baseline ) {
|
|
|
569 |
tipY = (tipHeight >= wHeight) ? sTop : baseline - tipHeight - tOffset;
|
|
|
570 |
} else if ($link.css('display') == 'block' || link.tagName.toLowerCase() == 'area' || opts.positionBy == "mouse") {
|
|
|
571 |
tipY = bpY - tOffset;
|
|
|
572 |
} else {
|
|
|
573 |
tipY = posY - opts.dropShadowSteps;
|
|
|
574 |
}
|
|
|
575 |
if (direction === '') {
|
|
|
576 |
direction = posX < linkLeft ? 'left' : 'right';
|
|
|
577 |
}
|
|
|
578 |
// add classes
|
|
|
579 |
dynamicClasses = ' clue-' + direction + '-' + ctClass + ' cluetip-' + ctClass;
|
|
|
580 |
if (ctClass == 'rounded') {
|
|
|
581 |
dynamicClasses += ' ui-corner-all';
|
|
|
582 |
}
|
|
|
583 |
$cluetip.css({top: tipY + 'px'}).attrProp({'className': standardClasses + dynamicClasses});
|
|
|
584 |
// set up arrow positioning to align with element
|
|
|
585 |
if (opts.arrows) {
|
|
|
586 |
if ( /(left|right)/.test(direction) ) {
|
|
|
587 |
heightDiff = $cluetip.height() - $cluetipArrows.height();
|
|
|
588 |
bgY = posX >= 0 && bpY > 0 ? (posY - tipY - opts.dropShadowSteps) : 0;
|
|
|
589 |
bgY = heightDiff > bgY ? bgY : heightDiff;
|
|
|
590 |
bgY += 'px';
|
|
|
591 |
}
|
|
|
592 |
$cluetipArrows.css({top: bgY}).show();
|
|
|
593 |
} else {
|
|
|
594 |
$cluetipArrows.hide();
|
|
|
595 |
}
|
|
|
596 |
|
|
|
597 |
// (first hide, then) ***SHOW THE CLUETIP***
|
|
|
598 |
// handle dropshadow divs first
|
|
|
599 |
$dropShadow = createDropShadows($cluetip, opts);
|
|
|
600 |
if ($dropShadow && $dropShadow.length) {
|
|
|
601 |
$dropShadow.hide().css({height: tipHeight, width: tipInnerWidth, zIndex: $link.data('cluetip').zIndex-1}).show();
|
|
|
602 |
}
|
|
|
603 |
|
|
|
604 |
if (!closeOnDelay) {
|
|
|
605 |
$cluetip.hide();
|
|
|
606 |
}
|
|
|
607 |
clearTimeout(closeOnDelay);
|
|
|
608 |
closeOnDelay = null;
|
|
|
609 |
|
|
|
610 |
// show the cluetip
|
|
|
611 |
$cluetip[opts.fx.open](opts.fx.openSpeed || 0);
|
|
|
612 |
|
|
|
613 |
if ($.fn.bgiframe) { $cluetip.bgiframe(); }
|
|
|
614 |
|
|
|
615 |
// trigger the optional onShow function
|
|
|
616 |
opts.onShow.call(link, $cluetip, $cluetipInner);
|
|
|
617 |
};
|
|
|
618 |
|
|
|
619 |
/***************************************
|
|
|
620 |
=INACTIVATION
|
|
|
621 |
-------------------------------------- */
|
|
|
622 |
var inactivate = function(event) {
|
|
|
623 |
isActive = false;
|
|
|
624 |
$cluetipWait.hide();
|
|
|
625 |
if (!opts.sticky || (/click|toggle/).test(opts.activation) ) {
|
|
|
626 |
// delayed close (not fully tested)
|
|
|
627 |
if (opts.delayedClose > 0) {
|
|
|
628 |
clearTimeout(closeOnDelay);
|
|
|
629 |
closeOnDelay = null;
|
|
|
630 |
closeOnDelay = setTimeout(cluetipClose, opts.delayedClose);
|
|
|
631 |
} else {
|
|
|
632 |
cluetipClose();
|
|
|
633 |
clearTimeout(closeOnDelay);
|
|
|
634 |
}
|
|
|
635 |
}
|
|
|
636 |
|
|
|
637 |
if (opts.hoverClass) {
|
|
|
638 |
$link.removeClass(opts.hoverClass);
|
|
|
639 |
}
|
|
|
640 |
};
|
|
|
641 |
|
|
|
642 |
// close cluetip and reset some things
|
|
|
643 |
var cluetipClose = function(el) {
|
|
|
644 |
var $closer = el && el.data('cluetip') ? el : $link,
|
|
|
645 |
ct = $closer.data('cluetip') && $closer.data('cluetip').selector,
|
|
|
646 |
ctSelector = ct || 'div.cluetip',
|
|
|
647 |
$cluetip = $(ctSelector),
|
|
|
648 |
$cluetipInner = $cluetip.find(prefix + 'cluetip-inner'),
|
|
|
649 |
$cluetipArrows = $cluetip.find(prefix + 'cluetip-arrows');
|
|
|
650 |
|
|
|
651 |
$cluetip.hide().removeClass();
|
|
|
652 |
opts.onHide.call($closer[0], $cluetip, $cluetipInner);
|
|
|
653 |
|
|
|
654 |
if (ct) {
|
|
|
655 |
$closer.removeClass('cluetip-clicked');
|
|
|
656 |
$link.css('cursor', $link.data('cluetip').cursor);
|
|
|
657 |
}
|
|
|
658 |
if (ct && tipTitle) {
|
|
|
659 |
$closer.attrProp(opts.titleAttribute, tipTitle);
|
|
|
660 |
}
|
|
|
661 |
|
|
|
662 |
if (opts.arrows) {
|
|
|
663 |
$cluetipArrows.css({top: ''});
|
|
|
664 |
}
|
|
|
665 |
if ($dropShadow) {
|
|
|
666 |
$dropShadow.hide();
|
|
|
667 |
}
|
|
|
668 |
};
|
|
|
669 |
|
|
|
670 |
// Check to see if we should be closing by checking where the user is hovering.
|
|
|
671 |
// We do a short 50ms delay for two reasons: to prevent flicker, and to allow the user time to hover on other element
|
|
|
672 |
var mouseOutClose = function() {
|
|
|
673 |
var el = this;
|
|
|
674 |
clearTimeout(closeOnDelay);
|
|
|
675 |
closeOnDelay = setTimeout(function() {
|
|
|
676 |
var linkOver = $link.data('cluetip').entered,
|
|
|
677 |
cluetipOver = $cluetip.data('entered'),
|
|
|
678 |
entered = false;
|
|
|
679 |
|
|
|
680 |
if ( opts.mouseOutClose == 'both' && (linkOver || cluetipOver) ) {
|
|
|
681 |
entered = true;
|
|
|
682 |
}
|
|
|
683 |
// true implies 'cluetip' for backwards compatibility
|
|
|
684 |
else if ( (opts.mouseOutClose === true || opts.mouseOutClose == 'cluetip') && cluetipOver) {
|
|
|
685 |
entered = true;
|
|
|
686 |
}
|
|
|
687 |
else if (opts.mouseOutClose == 'link' && linkOver) {
|
|
|
688 |
entered = true;
|
|
|
689 |
}
|
|
|
690 |
|
|
|
691 |
if ( !entered ) {
|
|
|
692 |
// All checks pass, close the cluetip
|
|
|
693 |
cluetipClose.call(el);
|
|
|
694 |
}
|
|
|
695 |
|
|
|
696 |
}, opts.delayedClose);
|
|
|
697 |
};
|
|
|
698 |
|
|
|
699 |
$(document).unbind('hideCluetip.cluetip').bind('hideCluetip.cluetip', function(e) {
|
|
|
700 |
cluetipClose( $(e.target) );
|
|
|
701 |
});
|
|
|
702 |
/***************************************
|
|
|
703 |
=BIND EVENTS
|
|
|
704 |
-------------------------------------- */
|
|
|
705 |
// activate by click
|
|
|
706 |
if ( (/click|toggle/).test(opts.activation) ) {
|
|
|
707 |
$link.bind('click.cluetip', function(event) {
|
|
|
708 |
if ($cluetip.is(':hidden') || !$link.is('.cluetip-clicked')) {
|
|
|
709 |
activate(event);
|
|
|
710 |
$('.cluetip-clicked').removeClass('cluetip-clicked');
|
|
|
711 |
$link.addClass('cluetip-clicked');
|
|
|
712 |
} else {
|
|
|
713 |
inactivate(event);
|
|
|
714 |
}
|
|
|
715 |
return false;
|
|
|
716 |
});
|
|
|
717 |
// activate by focus; inactivate by blur
|
|
|
718 |
} else if (opts.activation == 'focus') {
|
|
|
719 |
$link.bind('focus.cluetip', function(event) {
|
|
|
720 |
$link.attrProp('title','');
|
|
|
721 |
activate(event);
|
|
|
722 |
});
|
|
|
723 |
$link.bind('blur.cluetip', function(event) {
|
|
|
724 |
$link.attrProp('title', $link.data('cluetip').title);
|
|
|
725 |
inactivate(event);
|
|
|
726 |
});
|
|
|
727 |
// activate by hover
|
|
|
728 |
} else {
|
|
|
729 |
|
|
|
730 |
// clicking is returned false if clickThrough option is set to false
|
|
|
731 |
$link[opts.clickThrough ? 'unbind' : 'bind']('click.cluetip', returnFalse);
|
|
|
732 |
|
|
|
733 |
//set up mouse tracking
|
|
|
734 |
var mouseTracks = function(evt) {
|
|
|
735 |
if (opts.tracking) {
|
|
|
736 |
var trackX = posX - evt.pageX;
|
|
|
737 |
var trackY = tipY ? tipY - evt.pageY : posY - evt.pageY;
|
|
|
738 |
$link.bind('mousemove.cluetip', function(evt) {
|
|
|
739 |
$cluetip.css({left: evt.pageX + trackX, top: evt.pageY + trackY });
|
|
|
740 |
});
|
|
|
741 |
}
|
|
|
742 |
};
|
|
|
743 |
|
|
|
744 |
if ($.fn.hoverIntent && opts.hoverIntent) {
|
|
|
745 |
$link.hoverIntent({
|
|
|
746 |
sensitivity: opts.hoverIntent.sensitivity,
|
|
|
747 |
interval: opts.hoverIntent.interval,
|
|
|
748 |
over: function(event) {
|
|
|
749 |
activate(event);
|
|
|
750 |
mouseTracks(event);
|
|
|
751 |
},
|
|
|
752 |
timeout: opts.hoverIntent.timeout,
|
|
|
753 |
out: function(event) {
|
|
|
754 |
inactivate(event);
|
|
|
755 |
$link.unbind('mousemove.cluetip');
|
|
|
756 |
}
|
|
|
757 |
});
|
|
|
758 |
} else {
|
|
|
759 |
$link.bind('mouseenter.cluetip', function(event) {
|
|
|
760 |
activate(event);
|
|
|
761 |
mouseTracks(event);
|
|
|
762 |
})
|
|
|
763 |
.bind('mouseleave.cluetip', function(event) {
|
|
|
764 |
inactivate(event);
|
|
|
765 |
$link.unbind('mousemove.cluetip');
|
|
|
766 |
});
|
|
|
767 |
}
|
|
|
768 |
|
|
|
769 |
$link.bind('mouseover.cluetip', function(event) {
|
|
|
770 |
$link.attrProp('title','');
|
|
|
771 |
}).bind('mouseleave.cluetip', function(event) {
|
|
|
772 |
$link.attrProp('title', $link.data('cluetip').title);
|
|
|
773 |
});
|
|
|
774 |
}
|
|
|
775 |
|
|
|
776 |
// trigger a cached Ajax response
|
|
|
777 |
function cachedAjax(info, settings) {
|
|
|
778 |
var status = info.status;
|
|
|
779 |
settings.beforeSend(info.xhr, settings);
|
|
|
780 |
if ( status == 'error' ) {
|
|
|
781 |
settings[status](info.xhr, info.textStatus);
|
|
|
782 |
} else if (status == 'success') {
|
|
|
783 |
settings[status](info.data, info.textStatus, info.xhr);
|
|
|
784 |
}
|
|
|
785 |
settings.complete(info.xhr, settings.textStatus);
|
|
|
786 |
}
|
|
|
787 |
|
|
|
788 |
}); // end this.each
|
|
|
789 |
|
|
|
790 |
/** =private functions
|
|
|
791 |
************************************************************/
|
|
|
792 |
//empty function
|
|
|
793 |
function doNothing() {}
|
|
|
794 |
|
|
|
795 |
// create a string to be used as an identifier for ajax caches
|
|
|
796 |
function getCacheKey(url, data) {
|
|
|
797 |
var cacheKey = url || '';
|
|
|
798 |
data = data || '';
|
|
|
799 |
|
|
|
800 |
if (typeof data == 'object') {
|
|
|
801 |
$.each(data, function(key, val) {
|
|
|
802 |
cacheKey += '-' + key + '-' + val;
|
|
|
803 |
});
|
|
|
804 |
} else if (typeof data == 'string') {
|
|
|
805 |
cacheKey += data;
|
|
|
806 |
}
|
|
|
807 |
|
|
|
808 |
return cacheKey;
|
|
|
809 |
}
|
|
|
810 |
|
|
|
811 |
/** =create dropshadow divs **/
|
|
|
812 |
|
|
|
813 |
function createDropShadows($cluetip, options, newDropShadow) {
|
|
|
814 |
var dsStyle = '',
|
|
|
815 |
dropShadowSteps = (options.dropShadow && options.dropShadowSteps) ? +options.dropShadowSteps : 0;
|
|
|
816 |
|
|
|
817 |
if ($.support.boxShadow) {
|
|
|
818 |
if ( dropShadowSteps ) {
|
|
|
819 |
dsStyle = '1px 1px ' + dropShadowSteps + 'px rgba(0,0,0,0.5)';
|
|
|
820 |
}
|
|
|
821 |
var dsOffsets = dropShadowSteps === 0 ? '0 0 ' : '1px 1px ';
|
|
|
822 |
$cluetip.css($.support.boxShadow, dsStyle);
|
|
|
823 |
return false;
|
|
|
824 |
}
|
|
|
825 |
var oldDropShadow = $cluetip.find('.cluetip-drop-shadow');
|
|
|
826 |
if (dropShadowSteps == oldDropShadow.length) {
|
|
|
827 |
return oldDropShadow;
|
|
|
828 |
}
|
|
|
829 |
oldDropShadow.remove();
|
|
|
830 |
var dropShadows = [];
|
|
|
831 |
for (var i=0; i < dropShadowSteps;) {
|
|
|
832 |
dropShadows[i++] = '<div style="top:' + i + 'px;left:' + i + 'px;"></div>';
|
|
|
833 |
}
|
|
|
834 |
|
|
|
835 |
newDropShadow = $(dropShadows.join(''))
|
|
|
836 |
.css({
|
|
|
837 |
position: 'absolute',
|
|
|
838 |
backgroundColor: '#000',
|
|
|
839 |
zIndex: cluezIndex -1,
|
|
|
840 |
opacity: 0.1
|
|
|
841 |
})
|
|
|
842 |
.addClass('cluetip-drop-shadow')
|
|
|
843 |
.prependTo($cluetip);
|
|
|
844 |
return newDropShadow;
|
|
|
845 |
|
|
|
846 |
}
|
|
|
847 |
|
|
|
848 |
return this;
|
|
|
849 |
};
|
|
|
850 |
|
|
|
851 |
(function() {
|
|
|
852 |
$.support = $.support || {};
|
|
|
853 |
// check support for CSS3 properties (currently only boxShadow)
|
|
|
854 |
var div = document.createElement('div'),
|
|
|
855 |
divStyle = div.style,
|
|
|
856 |
styleProps = ['boxShadow'],
|
|
|
857 |
prefixes = ['moz', 'Moz', 'webkit', 'o'];
|
|
|
858 |
|
|
|
859 |
for (var i=0, sl = styleProps.length; i < sl; i++) {
|
|
|
860 |
var prop = styleProps[i],
|
|
|
861 |
uProp = prop.charAt(0).toUpperCase() + prop.slice(1);
|
|
|
862 |
|
|
|
863 |
if ( typeof divStyle[ prop ] !== 'undefined' ) {
|
|
|
864 |
$.support[ prop ] = prop;
|
|
|
865 |
} else {
|
|
|
866 |
for (var j=0, pl = prefixes.length; j < pl; j++) {
|
|
|
867 |
|
|
|
868 |
if (typeof divStyle[ prefixes[j] + uProp ] !== 'undefined') {
|
|
|
869 |
$.support[ prop ] = prefixes[j] + uProp;
|
|
|
870 |
break;
|
|
|
871 |
}
|
|
|
872 |
}
|
|
|
873 |
}
|
|
|
874 |
}
|
|
|
875 |
div = null;
|
|
|
876 |
})();
|
|
|
877 |
|
|
|
878 |
$.fn.cluetip.defaults = $.cluetip.defaults;
|
|
|
879 |
|
|
|
880 |
})(jQuery);
|