diff --git a/beautytips.module b/beautytips.module index 2d09ece..2f6e3c4 100644 --- a/beautytips.module +++ b/beautytips.module @@ -115,7 +115,7 @@ function beautytips_add_beautytips($options = NULL) { $style = isset($content['style']) ? $content['style'] : 'default'; unset($content['style']); $settings['beautytips'][$beautytip] = array_merge(beautytips_get_style($style), $content); - $keys_no_add = array('cssSelect', 'style', 'list', 'text', 'preEval', 'ajaxDisableLink', 'animate'); + $keys_no_add = array('cssSelect', 'style', 'list', 'text', 'preEval', 'ajaxDisableLink', 'animate', 'keepOpenWhenHovering'); foreach ($settings['beautytips'][$beautytip] as $key => $value) { // Ensure that numeric options are not passed as strings. $settings['beautytips'][$beautytip][$key] = is_numeric($value) ? (int) $value : $value; diff --git a/js/beautytips.js b/js/beautytips.js index f044bdb..fe70b4b 100644 --- a/js/beautytips.js +++ b/js/beautytips.js @@ -52,6 +52,33 @@ if (beautytips[key]['animate']) { btOptions = beautytipsAddAnimations(beautytips[key]['animate'], btOptions); } + if (beautytips[key]['keepOpenWhenHovering']) { + btOptions['trigger'] = 'hoverIntent'; + btOptions['hoverIntentOpts'] = { + interval: 0, + timeout: 500, + } + // from: http://stackoverflow.com/questions/4034671/how-to-make-jquery-beauty-tip-stay-open-as-long-as-the-cursor-is-over-the-toolti + btOptions['postShow'] = function(box) { + $(box).hoverIntent({ + over: function() { + $(this).data('hasmouse', true); + }, + out: function() { + $(this).data('hasmouse', false); + $(box).hide(); + }, + timeout: 300, + }); + } + btOptions['hideTip'] = function(box, callback) { + if ($(box).data('hasmouse')) { + return; + } + $(box).hide(); + callback(); + } + } // Run any java script that needs to be run when the page loads if (beautytips[key]['contentSelector'] && beautytips[key]['preEval']) { $(beautytips[key]['cssSelect']).each(function() { diff --git a/js/beautytips.min.js b/js/beautytips.min.js index 459d8d0..5dbf352 100644 --- a/js/beautytips.min.js +++ b/js/beautytips.min.js @@ -1 +1 @@ -(function($){Drupal.behaviors.beautytips={attach:function(context,settings){if(typeof(jQuery.bt)=="undefined"&&jQuery.bt==null){return}jQuery.bt.options.closeWhenOthersOpen=true;var beautytips=Drupal.settings.beautytips;function fixArray(originalArray,count){for(var key in originalArray){if(key=="cssStyles"){originalArray[key]=fixArray(originalArray[key],count)}else{if(originalArray[key].length==count){originalArray[key]=originalArray[key][0]}else{length=Math.round(originalArray[key].length/count);originalArray[key]=originalArray[key].slice(0,length)}}}return originalArray}for(var key in beautytips){if(typeof(Drupal.settings.beautytips[key]["cssSelect"])=="object"){var count=Drupal.settings.beautytips[key]["cssSelect"].length;beautytips[key]=fixArray(beautytips[key],count);Drupal.settings.beautytips[key]=beautytips[key]}var btOptions=new Array();if(beautytips[key]["list"]){for(var k=0;k