Advertisement
Guest User

Untitled

a guest
Jul 7th, 2011
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     _open: function( event, target, content ) {
  2.         if ( !content ) {
  3.             return;
  4.         }
  5.  
  6.         // if we have a title, clear it to prevent the native tooltip
  7.         // we have to check first to avoid defining a title if none exists
  8.         // (we don't want to cause an element to start matching [title])
  9.         // TODO: document why we don't use .removeAttr()
  10.         if ( target.is( "[title]" ) ) {
  11.             target.attr( "title", "" );
  12.         }
  13.  
  14.         // ajaxy tooltip can update an existing one
  15.         var tooltip = this._find( target );
  16.         if ( !tooltip.length ) {
  17.             tooltip = this._tooltip( target );
  18.             target.attr( "aria-describedby", tooltip.attr( "id" ) );
  19.         }
  20.        
  21.         // attach the target to the tooltip
  22.         tooltip.data( 'target', target );
  23.        
  24.         tooltip.addClass( this.options.tooltipClass || "" )
  25.        
  26.         tooltip.find( ".ui-tooltip-content" ).html( content );
  27.         tooltip
  28.             .stop( true )
  29.             .position( $.extend({
  30.                 of: target
  31.             }, this.options.position ) )
  32.             .hide();
  33.  
  34.         this._show( tooltip, this.options.show );
  35.  
  36.         this._trigger( "open", event, { tooltip: tooltip } );
  37.  
  38.         this._bind( target, {
  39.             mouseleave: "close",
  40.             blur: "close"
  41.         });
  42.     }
  43.  
  44.     _tooltip: function( element ) {
  45.         var id = "ui-tooltip-" + increments++,
  46.             tooltip = $( "<div>" )
  47.                 .attr({
  48.                     id: id,
  49.                     role: "tooltip"
  50.                 })
  51.                 .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " );
  52.         $( "<div>" )
  53.             .addClass( "ui-tooltip-content" )
  54.             .appendTo( tooltip );
  55.         tooltip.appendTo( document.body );
  56.         if ( $.fn.bgiframe ) {
  57.             tooltip.bgiframe();
  58.         }
  59.         this.tooltips[ id ] = element;
  60.         return tooltip;
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement