Changeset 9553 for trunk/themes/default/js/plugins/jquery.cluetip.js
- Timestamp:
- Mar 6, 2011, 10:46:00 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/themes/default/js/plugins/jquery.cluetip.js
r3282 r9553 1 1 /* 2 2 * jQuery clueTip plugin 3 * Version 0.9.8 (05/22/2008) 4 * @requires jQuery v1.1.4+ 5 * @requires Dimensions plugin (for jQuery versions < 1.2.5) 3 * Version 1.0.7 (January 28, 2010) 4 * @requires jQuery v1.3+ 6 5 * 7 6 * Dual licensed under the MIT and GPL licenses: … … 10 9 * 11 10 */ 11 12 /* 13 * 14 * Full list of options/settings can be found at the bottom of this file and at http://plugins.learningjquery.com/cluetip/ 15 * 16 * Examples can be found at http://plugins.learningjquery.com/cluetip/demo/ 17 * 18 */ 19 12 20 ;(function($) { 13 /* 14 * @name clueTip 15 * @type jQuery 16 * @cat Plugins/tooltip 17 * @return jQuery 18 * @author Karl Swedberg 19 * 20 * @credit Inspired by Cody Lindley's jTip (http://www.codylindley.com) 21 * @credit Thanks to the following people for their many and varied contributions: 22 Shelane Enos, Glen Lipka, Hector Santos, Torben Schreiter, Dan G. Switzer, Jörn Zaefferer 23 * @credit Thanks to Jonathan Chaffer, as always, for help with the hard parts. :-) 24 */ 25 26 /** 27 * 28 * Displays a highly customizable tooltip when the user hovers (default) or clicks (optional) the matched element. 29 * By default, the clueTip plugin loads a page indicated by the "rel" attribute via ajax and displays its contents. 30 * If a "title" attribute is specified, its value is used as the clueTip's heading. 31 * The attribute to be used for both the body and the heading of the clueTip is user-configurable. 32 * Optionally, the clueTip's body can display content from an element on the same page. 33 * * Just indicate the element's id (e.g. "#some-id") in the rel attribute. 34 * Optionally, the clueTip's body can display content from the title attribute, when a delimiter is indicated. 35 * * The string before the first instance of the delimiter is set as the clueTip's heading. 36 * * All subsequent strings are wrapped in separate DIVs and placed in the clueTip's body. 37 * The clueTip plugin allows for many, many more options. Pleasee see the examples and the option descriptions below... 38 * 39 * 40 * @example $('#tip).cluetip(); 41 * @desc This is the most basic clueTip. It displays a 275px-wide clueTip on mouseover of the element with an ID of "tip." On mouseout of the element, the clueTip is hidden. 42 * 43 * 44 * @example $('a.clue').cluetip({ 45 * hoverClass: 'highlight', 46 * sticky: true, 47 * closePosition: 'bottom', 48 * closeText: '<img src="cross.png" alt="close" />', 49 * truncate: 60, 50 * ajaxSettings: { 51 * type: 'POST' 52 * } 53 * }); 54 * @desc Displays a clueTip on mouseover of all <a> elements with class="clue". The hovered element gets a class of "highlight" added to it (so that it can be styled appropriately. This is esp. useful for non-anchor elements.). The clueTip is "sticky," which means that it will not be hidden until the user either clicks on its "close" text/graphic or displays another clueTip. The "close" text/graphic is set to diplay at the bottom of the clueTip (default is top) and display an image rather than the default "Close" text. Moreover, the body of the clueTip is truncated to the first 60 characters, which are followed by an ellipsis (...). Finally, the clueTip retrieves the content using POST rather than the $.ajax method's default "GET." 55 * 56 * More examples can be found at http://plugins.learningjquery.com/cluetip/demo/ 57 * 58 * Full list of options/settings can be found at the bottom of this file and at http://plugins.learningjquery.com/cluetip/ 59 */ 60 61 var $cluetip, $cluetipInner, $cluetipOuter, $cluetipTitle, $cluetipArrows, $dropShadow, imgCount; 21 $.cluetip = {version: '1.0.6'}; 22 var $cluetip, $cluetipInner, $cluetipOuter, $cluetipTitle, $cluetipArrows, $cluetipWait, $dropShadow, imgCount; 23 62 24 $.fn.cluetip = function(js, options) { 63 25 if (typeof js == 'object') { … … 65 27 js = null; 66 28 } 29 if (js == 'destroy') { 30 return this.removeData('thisInfo').unbind('.cluetip'); 31 } 67 32 return this.each(function(index) { 68 var $this = $(this);33 var link = this, $this = $(this); 69 34 70 35 // support metadata plugin (v1.0 and 2.0) 71 var opts = $.extend( false, {}, $.fn.cluetip.defaults, options || {}, $.metadata ? $this.metadata() : $.meta ? $this.data() : {});36 var opts = $.extend(true, {}, $.fn.cluetip.defaults, options || {}, $.metadata ? $this.metadata() : $.meta ? $this.data() : {}); 72 37 73 38 // start out with no contents (for ajax activation) 74 39 var cluetipContents = false; 75 var cluezIndex = parseInt(opts.cluezIndex, 10)-1; 40 var cluezIndex = +opts.cluezIndex; 41 $this.data('thisInfo', {title: link.title, zIndex: cluezIndex}); 76 42 var isActive = false, closeOnDelay = 0; 77 43 78 44 // create the cluetip divs 79 45 if (!$('#cluetip').length) { 80 $cluetipInner = $('<div id="cluetip-inner"></div>'); 81 $cluetipTitle = $('<h3 id="cluetip-title"></h3>'); 82 $cluetipOuter = $('<div id="cluetip-outer"></div>').append($cluetipInner).prepend($cluetipTitle); 83 $cluetip = $('<div id="cluetip"></div>').css({zIndex: opts.cluezIndex}) 84 .append($cluetipOuter).append('<div id="cluetip-extra"></div>')[insertionType](insertionElement).hide(); 85 $('<div id="cluetip-waitimage"></div>').css({position: 'absolute', zIndex: cluezIndex-1}) 86 .insertBefore('#cluetip').hide(); 87 $cluetip.css({position: 'absolute', zIndex: cluezIndex}); 88 $cluetipOuter.css({position: 'relative', zIndex: cluezIndex+1}); 89 $cluetipArrows = $('<div id="cluetip-arrows" class="cluetip-arrows"></div>').css({zIndex: cluezIndex+1}).appendTo('#cluetip'); 46 $(['<div id="cluetip">', 47 '<div id="cluetip-outer">', 48 '<h3 id="cluetip-title"></h3>', 49 '<div id="cluetip-inner"></div>', 50 '</div>', 51 '<div id="cluetip-extra"></div>', 52 '<div id="cluetip-arrows" class="cluetip-arrows"></div>', 53 '</div>'].join('')) 54 [insertionType](insertionElement).hide(); 55 56 $cluetip = $('#cluetip').css({position: 'absolute'}); 57 $cluetipOuter = $('#cluetip-outer').css({position: 'relative', zIndex: cluezIndex}); 58 $cluetipInner = $('#cluetip-inner'); 59 $cluetipTitle = $('#cluetip-title'); 60 $cluetipArrows = $('#cluetip-arrows'); 61 $cluetipWait = $('<div id="cluetip-waitimage"></div>') 62 .css({position: 'absolute'}).insertBefore($cluetip).hide(); 90 63 } 91 64 var dropShadowSteps = (opts.dropShadow) ? +opts.dropShadowSteps : 0; … … 93 66 $dropShadow = $([]); 94 67 for (var i=0; i < dropShadowSteps; i++) { 95 $dropShadow = $dropShadow.add($('<div></div>').css({zIndex: cluezIndex- i-1, opacity:.1, top: 1+i, left: 1+i}));96 } ;68 $dropShadow = $dropShadow.add($('<div></div>').css({zIndex: cluezIndex-1, opacity:.1, top: 1+i, left: 1+i})); 69 } 97 70 $dropShadow.css({position: 'absolute', backgroundColor: '#000'}) 98 71 .prependTo($cluetip); 99 72 } 100 73 var tipAttribute = $this.attr(opts.attribute), ctClass = opts.cluetipClass; 101 if (!tipAttribute && !opts.splitTitle && !js) return true; 102 // if hideLocal is set to true, on DOM ready hide the local content that will be displayed in the clueTip 74 if (!tipAttribute && !opts.splitTitle && !js) { 75 return true; 76 } 77 // if hideLocal is set to true, on DOM ready hide the local content that will be displayed in the clueTip 78 if (opts.local && opts.localPrefix) {tipAttribute = opts.localPrefix + tipAttribute;} 103 79 if (opts.local && opts.hideLocal) { $(tipAttribute + ':first').hide(); } 104 80 var tOffset = parseInt(opts.topOffset, 10), lOffset = parseInt(opts.leftOffset, 10); 105 81 // vertical measurement variables 106 var tipHeight, wHeight ;107 vardefHeight = isNaN(parseInt(opts.height, 10)) ? 'auto' : (/\D/g).test(opts.height) ? opts.height : opts.height + 'px';82 var tipHeight, wHeight, 83 defHeight = isNaN(parseInt(opts.height, 10)) ? 'auto' : (/\D/g).test(opts.height) ? opts.height : opts.height + 'px'; 108 84 var sTop, linkTop, posY, tipY, mouseY, baseline; 109 85 // horizontal measurement variables 110 var tipInnerWidth = isNaN(parseInt(opts.width, 10)) ? 275 : parseInt(opts.width, 10);111 var tipWidth = tipInnerWidth + (parseInt($cluetip.css('paddingLeft'))||0) + (parseInt($cluetip.css('paddingRight'))||0) + dropShadowSteps;112 var linkWidth = this.offsetWidth;113 varlinkLeft, posX, tipX, mouseX, winWidth;86 var tipInnerWidth = parseInt(opts.width, 10) || 275, 87 tipWidth = tipInnerWidth + (parseInt($cluetip.css('paddingLeft'),10)||0) + (parseInt($cluetip.css('paddingRight'),10)||0) + dropShadowSteps, 88 linkWidth = this.offsetWidth, 89 linkLeft, posX, tipX, mouseX, winWidth; 114 90 115 91 // parse the title … … 117 93 var tipTitle = (opts.attribute != 'title') ? $this.attr(opts.titleAttribute) : ''; 118 94 if (opts.splitTitle) { 119 if (tipTitle == undefined) {tipTitle = '';}95 if (tipTitle == undefined) {tipTitle = '';} 120 96 tipParts = tipTitle.split(opts.splitTitle); 121 97 tipTitle = tipParts.shift(); 122 98 } 99 if (opts.escapeTitle) { 100 tipTitle = tipTitle.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<'); 101 } 102 123 103 var localContent; 104 function returnFalse() { return false; } 124 105 125 106 /*************************************** … … 137 118 $this.css('cursor', opts.cursor); 138 119 } 139 $this.attr('title','');140 120 if (opts.hoverClass) { 141 121 $this.addClass(opts.hoverClass); … … 145 125 mouseX = event.pageX; 146 126 mouseY = event.pageY; 147 if ( $this[0].tagName.toLowerCase() != 'area') {127 if (link.tagName.toLowerCase() != 'area') { 148 128 sTop = $(document).scrollTop(); 149 129 winWidth = $(window).width(); … … 158 138 ? linkLeft - tipWidth - lOffset 159 139 : linkWidth + linkLeft + lOffset; 160 if ( $this[0].tagName.toLowerCase() == 'area' || opts.positionBy == 'mouse' || linkWidth + tipWidth > winWidth) { // position by mouse140 if (link.tagName.toLowerCase() == 'area' || opts.positionBy == 'mouse' || linkWidth + tipWidth > winWidth) { // position by mouse 161 141 if (mouseX + 20 + tipWidth > winWidth) { 162 142 $cluetip.addClass(' cluetip-' + ctClass); … … 167 147 } 168 148 var pY = posX < 0 ? event.pageY + tOffset : event.pageY; 169 $cluetip.css({left: (posX > 0 && opts.positionBy != 'bottomTop') ? posX : (mouseX + (tipWidth/2) > winWidth) ? winWidth/2 - tipWidth/2 : Math.max(mouseX - (tipWidth/2),0)}); 149 $cluetip.css({ 150 left: (posX > 0 && opts.positionBy != 'bottomTop') ? posX : (mouseX + (tipWidth/2) > winWidth) ? winWidth/2 - tipWidth/2 : Math.max(mouseX - (tipWidth/2),0), 151 zIndex: $this.data('thisInfo').zIndex 152 }); 153 $cluetipArrows.css({zIndex: $this.data('thisInfo').zIndex+1}); 170 154 } 171 155 wHeight = $(window).height(); … … 175 159 ***************************************/ 176 160 if (js) { 161 if (typeof js == 'function') { 162 js = js.call(link); 163 } 177 164 $cluetipInner.html(js); 178 165 cluetipShow(pY); … … 186 173 else if (tipParts) { 187 174 var tpl = tipParts.length; 188 for (var i=0; i < tpl; i++){ 189 if (i == 0) { 190 $cluetipInner.html(tipParts[i]); 191 } else { 175 $cluetipInner.html(tpl ? tipParts[0] : ''); 176 if (tpl > 1) { 177 for (var i=1; i < tpl; i++){ 192 178 $cluetipInner.append('<div class="split-body">' + tipParts[i] + '</div>'); 193 } 194 } ;179 } 180 } 195 181 cluetipShow(pY); 196 182 } … … 199 185 ***************************************/ 200 186 201 else if (!opts.local && tipAttribute.indexOf('#') != 0) { 202 if (cluetipContents && opts.ajaxCache) { 187 else if (!opts.local && tipAttribute.indexOf('#') !== 0) { 188 if (/\.(jpe?g|tiff?|gif|png)$/i.test(tipAttribute)) { 189 $cluetipInner.html('<img src="' + tipAttribute + '" alt="' + tipTitle + '" />'); 190 cluetipShow(pY); 191 } else if (cluetipContents && opts.ajaxCache) { 203 192 $cluetipInner.html(cluetipContents); 204 193 cluetipShow(pY); 205 } 206 else { 207 var ajaxSettings = opts.ajaxSettings; 208 ajaxSettings.url = tipAttribute; 209 ajaxSettings.beforeSend = function() { 210 $cluetipOuter.children().empty(); 211 if (opts.waitImage) { 212 $('#cluetip-waitimage') 213 .css({top: mouseY+20, left: mouseX+20}) 214 .show(); 194 } else { 195 var optionBeforeSend = opts.ajaxSettings.beforeSend, 196 optionError = opts.ajaxSettings.error, 197 optionSuccess = opts.ajaxSettings.success, 198 optionComplete = opts.ajaxSettings.complete; 199 var ajaxSettings = { 200 cache: false, // force requested page not to be cached by browser 201 url: tipAttribute, 202 beforeSend: function(xhr) { 203 if (optionBeforeSend) {optionBeforeSend.call(link, xhr, $cluetip, $cluetipInner);} 204 $cluetipOuter.children().empty(); 205 if (opts.waitImage) { 206 $cluetipWait 207 .css({top: mouseY+20, left: mouseX+20, zIndex: $this.data('thisInfo').zIndex-1}) 208 .show(); 209 } 210 }, 211 error: function(xhr, textStatus) { 212 if (isActive) { 213 if (optionError) { 214 optionError.call(link, xhr, textStatus, $cluetip, $cluetipInner); 215 } else { 216 $cluetipInner.html('<i>sorry, the contents could not be loaded</i>'); 217 } 218 } 219 }, 220 success: function(data, textStatus) { 221 cluetipContents = opts.ajaxProcess.call(link, data); 222 if (isActive) { 223 if (optionSuccess) {optionSuccess.call(link, data, textStatus, $cluetip, $cluetipInner);} 224 $cluetipInner.html(cluetipContents); 225 } 226 }, 227 complete: function(xhr, textStatus) { 228 if (optionComplete) {optionComplete.call(link, xhr, textStatus, $cluetip, $cluetipInner);} 229 var imgs = $cluetipInner[0].getElementsByTagName('img'); 230 imgCount = imgs.length; 231 for (var i=0, l = imgs.length; i < l; i++) { 232 if (imgs[i].complete) { 233 imgCount--; 234 } 235 } 236 if (imgCount && !$.browser.opera) { 237 $(imgs).bind('load error', function() { 238 imgCount--; 239 if (imgCount<1) { 240 $cluetipWait.hide(); 241 if (isActive) { cluetipShow(pY); } 242 } 243 }); 244 } else { 245 $cluetipWait.hide(); 246 if (isActive) { cluetipShow(pY); } 247 } 215 248 } 216 249 }; 217 ajaxSettings.error = function() { 218 if (isActive) { 219 $cluetipInner.html('<i>sorry, the contents could not be loaded</i>'); 220 } 221 }; 222 ajaxSettings.success = function(data) { 223 cluetipContents = opts.ajaxProcess(data); 224 if (isActive) { 225 $cluetipInner.html(cluetipContents); 226 } 227 }; 228 ajaxSettings.complete = function() { 229 imgCount = $('#cluetip-inner img').length; 230 if (imgCount && !$.browser.opera) { 231 $('#cluetip-inner img').load(function() { 232 imgCount--; 233 if (imgCount<1) { 234 $('#cluetip-waitimage').hide(); 235 if (isActive) cluetipShow(pY); 236 } 237 }); 238 } else { 239 $('#cluetip-waitimage').hide(); 240 if (isActive) cluetipShow(pY); 241 } 242 }; 243 $.ajax(ajaxSettings); 250 var ajaxMergedSettings = $.extend(true, {}, opts.ajaxSettings, ajaxSettings); 251 252 $.ajax(ajaxMergedSettings); 244 253 } 245 254 … … 247 256 * load an element from the same page 248 257 ***************************************/ 249 } else if (opts.local) {250 var $localContent = $(tipAttribute + ':first');251 var localCluetip = $.fn.wrapInner ? $localContent.wrapInner('<div></div>').children().clone(true) : $localContent.html();252 $ .fn.wrapInner ? $cluetipInner.empty().append(localCluetip) : $cluetipInner.html(localCluetip);258 } else if (opts.local) { 259 260 var $localContent = $(tipAttribute + (/#\S+$/.test(tipAttribute) ? '' : ':eq(' + index + ')')).clone(true).show(); 261 $cluetipInner.html($localContent); 253 262 cluetipShow(pY); 254 263 } … … 258 267 var cluetipShow = function(bpY) { 259 268 $cluetip.addClass('cluetip-' + ctClass); 260 261 269 if (opts.truncate) { 262 270 var $truncloaded = $cluetipInner.text().slice(0,opts.truncate) + '...'; … … 268 276 var $closeLink = $('<div id="cluetip-close"><a href="#">' + opts.closeText + '</a></div>'); 269 277 (opts.closePosition == 'bottom') ? $closeLink.appendTo($cluetipInner) : (opts.closePosition == 'title') ? $closeLink.prependTo($cluetipTitle) : $closeLink.prependTo($cluetipInner); 270 $closeLink. click(function() {278 $closeLink.bind('click.cluetip', function() { 271 279 cluetipClose(); 272 280 return false; 273 281 }); 274 282 if (opts.mouseOutClose) { 275 if ($.fn.hoverIntent && opts.hoverIntent) { 276 $cluetip.hoverIntent({ 277 over: doNothing, 278 timeout: opts.hoverIntent.timeout, 279 out: function() { $closeLink.trigger('click'); } 280 }); 281 } else { 282 $cluetip.hover(doNothing, 283 function() {$closeLink.trigger('click'); }); 284 } 283 $cluetip.bind('mouseleave.cluetip', function() { 284 cluetipClose(); 285 }); 285 286 } else { 286 $cluetip.unbind('mouse out');287 $cluetip.unbind('mouseleave.cluetip'); 287 288 } 288 289 } 289 290 // now that content is loaded, finish the positioning 290 291 var direction = ''; 291 $cluetipOuter.css({ overflow: defHeight == 'auto' ? 'visible' : 'auto', height: defHeight});292 $cluetipOuter.css({zIndex: $this.data('thisInfo').zIndex, overflow: defHeight == 'auto' ? 'visible' : 'auto', height: defHeight}); 292 293 tipHeight = defHeight == 'auto' ? Math.max($cluetip.outerHeight(),$cluetip.height()) : parseInt(defHeight,10); 293 294 tipY = posY; … … 305 306 } else if ( posY + tipHeight + tOffset > baseline ) { 306 307 tipY = (tipHeight >= wHeight) ? sTop : baseline - tipHeight - tOffset; 307 } else if ($this.css('display') == 'block' || $this[0].tagName.toLowerCase() == 'area' || opts.positionBy == "mouse") {308 } else if ($this.css('display') == 'block' || link.tagName.toLowerCase() == 'area' || opts.positionBy == "mouse") { 308 309 tipY = bpY - tOffset; 309 310 } else { … … 323 324 // (first hide, then) ***SHOW THE CLUETIP*** 324 325 $dropShadow.hide(); 325 $cluetip.hide()[opts.fx.open](opts.fx.open != 'show' && opts.fx.openSpeed);326 if (opts.dropShadow) $dropShadow.css({height: tipHeight, width: tipInnerWidth}).show();326 $cluetip.hide()[opts.fx.open](opts.fx.openSpeed || 0); 327 if (opts.dropShadow) { $dropShadow.css({height: tipHeight, width: tipInnerWidth, zIndex: $this.data('thisInfo').zIndex-1}).show(); } 327 328 if ($.fn.bgiframe) { $cluetip.bgiframe(); } 328 // trigger the optional onShow function329 // delayed close (not fully tested) 329 330 if (opts.delayedClose > 0) { 330 331 closeOnDelay = setTimeout(cluetipClose, opts.delayedClose); 331 332 } 332 opts.onShow($cluetip, $cluetipInner);333 333 // trigger the optional onShow function 334 opts.onShow.call(link, $cluetip, $cluetipInner); 334 335 }; 335 336 … … 337 338 =INACTIVATION 338 339 -------------------------------------- */ 339 var inactivate = function( ) {340 var inactivate = function(event) { 340 341 isActive = false; 341 $ ('#cluetip-waitimage').hide();342 $cluetipWait.hide(); 342 343 if (!opts.sticky || (/click|toggle/).test(opts.activation) ) { 343 344 cluetipClose(); 344 clearTimeout(closeOnDelay);345 } ;345 clearTimeout(closeOnDelay); 346 } 346 347 if (opts.hoverClass) { 347 348 $this.removeClass(opts.hoverClass); 348 349 } 349 $('.cluetip-clicked').removeClass('cluetip-clicked');350 350 }; 351 351 // close cluetip and reset some things 352 352 var cluetipClose = function() { 353 353 $cluetipOuter 354 .parent().hide().removeClass().end() 355 .children().empty(); 354 .parent().hide().removeClass(); 355 opts.onHide.call(link, $cluetip, $cluetipInner); 356 $this.removeClass('cluetip-clicked'); 356 357 if (tipTitle) { 357 358 $this.attr(opts.titleAttribute, tipTitle); 358 359 } 359 360 $this.css('cursor',''); 360 if (opts.arrows) $cluetipArrows.css({top: ''}); 361 if (opts.arrows) { 362 $cluetipArrows.css({top: ''}); 363 } 361 364 }; 362 365 366 $(document).bind('hideCluetip', function(e) { 367 cluetipClose(); 368 }); 363 369 /*************************************** 364 370 =BIND EVENTS … … 366 372 // activate by click 367 373 if ( (/click|toggle/).test(opts.activation) ) { 368 $this. click(function(event) {374 $this.bind('click.cluetip', function(event) { 369 375 if ($cluetip.is(':hidden') || !$this.is('.cluetip-clicked')) { 370 376 activate(event); 371 377 $('.cluetip-clicked').removeClass('cluetip-clicked'); 372 378 $this.addClass('cluetip-clicked'); 373 374 379 } else { 375 380 inactivate(event); 376 377 381 } 378 382 this.blur(); … … 381 385 // activate by focus; inactivate by blur 382 386 } else if (opts.activation == 'focus') { 383 $this. focus(function(event) {387 $this.bind('focus.cluetip', function(event) { 384 388 activate(event); 385 389 }); 386 $this.b lur(function(event) {390 $this.bind('blur.cluetip', function(event) { 387 391 inactivate(event); 388 392 }); 389 393 // activate by hover 390 // clicking is returned false if cluetip url is same as href url391 394 } else { 392 $this.click(function() { 393 if ($this.attr('href') && $this.attr('href') == tipAttribute && !opts.clickThrough) { 394 return false; 395 } 396 }); 395 // clicking is returned false if clickThrough option is set to false 396 $this[opts.clickThrough ? 'unbind' : 'bind']('click', returnFalse); 397 397 //set up mouse tracking 398 398 var mouseTracks = function(evt) { … … 400 400 var trackX = posX - evt.pageX; 401 401 var trackY = tipY ? tipY - evt.pageY : posY - evt.pageY; 402 $this. mousemove(function(evt) {402 $this.bind('mousemove.cluetip', function(evt) { 403 403 $cluetip.css({left: evt.pageX + trackX, top: evt.pageY + trackY }); 404 404 }); … … 406 406 }; 407 407 if ($.fn.hoverIntent && opts.hoverIntent) { 408 $this.mouseover(function() {$this.attr('title',''); }) 409 .hoverIntent({ 408 $this.hoverIntent({ 410 409 sensitivity: opts.hoverIntent.sensitivity, 411 410 interval: opts.hoverIntent.interval, … … 415 414 }, 416 415 timeout: opts.hoverIntent.timeout, 417 out: function(event) {inactivate(event); $this.unbind('mousemove ');}416 out: function(event) {inactivate(event); $this.unbind('mousemove.cluetip');} 418 417 }); 419 418 } else { 420 $this. hover(function(event) {419 $this.bind('mouseenter.cluetip', function(event) { 421 420 activate(event); 422 421 mouseTracks(event); 423 }, function(event) { 422 }) 423 .bind('mouseleave.cluetip', function(event) { 424 424 inactivate(event); 425 $this.unbind('mousemove ');425 $this.unbind('mousemove.cluetip'); 426 426 }); 427 427 } 428 $this.bind('mouseover.cluetip', function(event) { 429 $this.attr('title',''); 430 }).bind('mouseleave.cluetip', function(event) { 431 $this.attr('title', $this.data('thisInfo').title); 432 }); 428 433 } 429 434 }); … … 451 456 leftOffset: 15, // Number of px to offset clueTip from left of invoking element 452 457 local: false, // Whether to use content from the same page for the clueTip's body 458 localPrefix: null, // string to be prepended to the tip attribute if local is true 453 459 hideLocal: true, // If local option is set to true, this determines whether local content 454 460 // to be shown in clueTip should be hidden at its original location … … 457 463 splitTitle: '', // A character used to split the title attribute into the clueTip title and divs 458 464 // within the clueTip body. more info below [6] 465 escapeTitle: false, // whether to html escape the title attribute 459 466 showTitle: true, // show title bar of the clueTip, even if title attribute not set 460 467 cluetipClass: 'default',// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass. … … 476 483 closeText: 'Close', // text (or HTML) to to be clicked to close sticky clueTips 477 484 truncate: 0, // number of characters to truncate clueTip's contents. if 0, no truncation occurs 478 485 479 486 // effect and speed for opening clueTips 480 487 fx: { … … 490 497 }, 491 498 492 // function to run just before clueTip is shown.499 // short-circuit function to run just before clueTip is shown. 493 500 onActivate: function(e) {return true;}, 494 495 // function to run just after clueTip is shown.496 onShow: function(ct, c){},497 501 // function to run just after clueTip is shown. 502 onShow: function(ct, ci){}, 503 // function to run just after clueTip is hidden. 504 onHide: function(ct, ci){}, 498 505 // whether to cache results of ajax request to avoid unnecessary hits to server 499 506 ajaxCache: true, … … 501 508 // process data retrieved via xhr before it's displayed 502 509 ajaxProcess: function(data) { 503 data = data.replace(/< s(cript|tyle)(.|\s)*?\/s(cript|tyle)>/g, '').replace(/<(link|title)(.|\s)*?\/(link|title)>/g,'');510 data = data.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm, '').replace(/<(link|meta)[^>]+>/g,''); 504 511 return data; 505 512 }, 506 513 507 // can pass in standard $.ajax() parameters, not including error, complete, success, and url 508 ajaxSettings: { 514 // can pass in standard $.ajax() parameters. Callback functions, such as beforeSend, 515 // will be queued first within the default callbacks. 516 // The only exception is error, which overrides the default 517 ajaxSettings: { 518 // error: function(ct, ci) { /* override default error callback */ } 519 // beforeSend: function(ct, ci) { /* called first within default beforeSend callback } 509 520 dataType: 'html' 510 521 }, … … 531 542 532 543 var insertionType = 'appendTo', insertionElement = 'body'; 533 $.cluetip = {}; 544 534 545 $.cluetip.setup = function(options) { 535 546 if (options && options.insertionType && (options.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)) {
Note: See TracChangeset
for help on using the changeset viewer.