Team:UCL/Template:SCJtooltip.js

From 2014.igem.org

(Difference between revisions)
Line 1: Line 1:
-
(function($){$.fn.tipr=function(options){var set=$.extend({"speed":200,"mode":"bottom"},options);return this.each(function(){var tipr_cont=".tipr_container_"+set.mode;$(this).hover(function(){var out='<div class="tipr_container_'+set.mode+'"><div class="tipr_point_'+set.mode+'"><div class="tipr_content">'+$(this).attr("data-tip")+"</div></div></div>";$(this).append(out);var w_t=$(tipr_cont).outerWidth();var w_e=$(this).width();var m_l=w_e/2-w_t/2;$(tipr_cont).css("margin-left",m_l+"px");$(this).removeAttr("title");
+
(function($) {
-
$(tipr_cont).fadeIn(set.speed)},function(){$(tipr_cont).remove()})})}})(jQuery);
+
 
 +
    $.fn.tipr = function(options) {
 +
   
 +
          var set = $.extend( {
 +
         
 +
              'speed'        : 200,
 +
              'mode'        : 'bottom'
 +
         
 +
          }, options);
 +
 
 +
          return this.each(function() {
 +
         
 +
              var tipr_cont = '.tipr_container_' + set.mode;
 +
 
 +
              $(this).hover(
 +
                    function ()
 +
                    {
 +
                        var out = '<div class="tipr_container_' + set.mode + '"><div class="tipr_point_' + set.mode + '"><div class="tipr_content">' + $(this).attr('data-tip') + '</div></div></div>';
 +
                       
 +
                        $(this).append(out);
 +
                   
 +
                        var w_t = $(tipr_cont).outerWidth();
 +
                        var w_e = $(this).width();
 +
                        var m_l = (w_e / 2) - (w_t / 2);
 +
                   
 +
                        $(tipr_cont).css('margin-left', m_l + 'px');
 +
                        $(this).removeAttr('title');
 +
                        $(tipr_cont).fadeIn(set.speed);             
 +
                    },
 +
                    function ()
 +
                    {  
 +
                        $(tipr_cont).remove();   
 +
                    }    
 +
              );
 +
                             
 +
          });
 +
    };
 +
   
 +
})(jQuery);

Revision as of 22:10, 9 October 2014

(function($) {

    $.fn.tipr = function(options) {
    
         var set = $.extend( {
         
              'speed'        : 200,
              'mode'         : 'bottom'
         
         }, options);
         return this.each(function() {
         
              var tipr_cont = '.tipr_container_' + set.mode;
              $(this).hover(
                   function ()
                   {
var out = '
' + $(this).attr('data-tip') + '
';
                        $(this).append(out);
                   
                        var w_t = $(tipr_cont).outerWidth();
                        var w_e = $(this).width();
                        var m_l = (w_e / 2) - (w_t / 2);
                   
                        $(tipr_cont).css('margin-left', m_l + 'px');
                        $(this).removeAttr('title');
                        $(tipr_cont).fadeIn(set.speed);              
                   },
                   function ()
                   {   
                        $(tipr_cont).remove();    
                   }     
              );
                             
         });
    };
    

})(jQuery);