wp/wp-includes/js/jquery/ui/tooltip.js
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
     1 /*!
     1 /*!
     2  * jQuery UI Tooltip 1.12.1
     2  * jQuery UI Tooltip 1.13.1
     3  * http://jqueryui.com
     3  * http://jqueryui.com
     4  *
     4  *
     5  * Copyright jQuery Foundation and other contributors
     5  * Copyright jQuery Foundation and other contributors
     6  * Released under the MIT license.
     6  * Released under the MIT license.
     7  * http://jquery.org/license
     7  * http://jquery.org/license
    15 //>>css.structure: ../../themes/base/core.css
    15 //>>css.structure: ../../themes/base/core.css
    16 //>>css.structure: ../../themes/base/tooltip.css
    16 //>>css.structure: ../../themes/base/tooltip.css
    17 //>>css.theme: ../../themes/base/theme.css
    17 //>>css.theme: ../../themes/base/theme.css
    18 
    18 
    19 ( function( factory ) {
    19 ( function( factory ) {
       
    20 	"use strict";
       
    21 
    20 	if ( typeof define === "function" && define.amd ) {
    22 	if ( typeof define === "function" && define.amd ) {
    21 
    23 
    22 		// AMD. Register as an anonymous module.
    24 		// AMD. Register as an anonymous module.
    23 		define( [
    25 		define( [
    24 			"jquery",
    26 			"jquery",
    27 	} else {
    29 	} else {
    28 
    30 
    29 		// Browser globals
    31 		// Browser globals
    30 		factory( jQuery );
    32 		factory( jQuery );
    31 	}
    33 	}
    32 }( function( $ ) {
    34 } )( function( $ ) {
       
    35 "use strict";
    33 
    36 
    34 $.widget( "ui.tooltip", {
    37 $.widget( "ui.tooltip", {
    35 	version: "1.12.1",
    38 	version: "1.13.1",
    36 	options: {
    39 	options: {
    37 		classes: {
    40 		classes: {
    38 			"ui-tooltip": "ui-corner-all ui-widget-shadow"
    41 			"ui-tooltip": "ui-corner-all ui-widget-shadow"
    39 		},
    42 		},
    40 		content: function() {
    43 		content: function() {
    41 
    44 			var title = $( this ).attr( "title" );
    42 			// support: IE<9, Opera in jQuery <1.7
       
    43 			// .text() can't accept undefined, so coerce to a string
       
    44 			var title = $( this ).attr( "title" ) || "";
       
    45 
    45 
    46 			// Escape title, since we're going from an attribute to raw HTML
    46 			// Escape title, since we're going from an attribute to raw HTML
    47 			return $( "<a>" ).text( title ).html();
    47 			return $( "<a>" ).text( title ).html();
    48 		},
    48 		},
    49 		hide: true,
    49 		hide: true,
    66 	_addDescribedBy: function( elem, id ) {
    66 	_addDescribedBy: function( elem, id ) {
    67 		var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
    67 		var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
    68 		describedby.push( id );
    68 		describedby.push( id );
    69 		elem
    69 		elem
    70 			.data( "ui-tooltip-id", id )
    70 			.data( "ui-tooltip-id", id )
    71 			.attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
    71 			.attr( "aria-describedby", String.prototype.trim.call( describedby.join( " " ) ) );
    72 	},
    72 	},
    73 
    73 
    74 	_removeDescribedBy: function( elem ) {
    74 	_removeDescribedBy: function( elem ) {
    75 		var id = elem.data( "ui-tooltip-id" ),
    75 		var id = elem.data( "ui-tooltip-id" ),
    76 			describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
    76 			describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
    79 		if ( index !== -1 ) {
    79 		if ( index !== -1 ) {
    80 			describedby.splice( index, 1 );
    80 			describedby.splice( index, 1 );
    81 		}
    81 		}
    82 
    82 
    83 		elem.removeData( "ui-tooltip-id" );
    83 		elem.removeData( "ui-tooltip-id" );
    84 		describedby = $.trim( describedby.join( " " ) );
    84 		describedby = String.prototype.trim.call( describedby.join( " " ) );
    85 		if ( describedby ) {
    85 		if ( describedby ) {
    86 			elem.attr( "aria-describedby", describedby );
    86 			elem.attr( "aria-describedby", describedby );
    87 		} else {
    87 		} else {
    88 			elem.removeAttr( "aria-describedby" );
    88 			elem.removeAttr( "aria-describedby" );
    89 		}
    89 		}
   215 			contentOption = this.options.content,
   215 			contentOption = this.options.content,
   216 			that = this,
   216 			that = this,
   217 			eventType = event ? event.type : null;
   217 			eventType = event ? event.type : null;
   218 
   218 
   219 		if ( typeof contentOption === "string" || contentOption.nodeType ||
   219 		if ( typeof contentOption === "string" || contentOption.nodeType ||
   220 				contentOption.jquery ) {
   220 			contentOption.jquery ) {
   221 			return this._open( event, target, contentOption );
   221 			return this._open( event, target, contentOption );
   222 		}
   222 		}
   223 
   223 
   224 		content = contentOption.call( target[ 0 ], function( response ) {
   224 		content = contentOption.call( target[ 0 ], function( response ) {
   225 
   225 
   325 			delayedShow = this.delayedShow = setInterval( function() {
   325 			delayedShow = this.delayedShow = setInterval( function() {
   326 				if ( tooltip.is( ":visible" ) ) {
   326 				if ( tooltip.is( ":visible" ) ) {
   327 					position( positionOption.of );
   327 					position( positionOption.of );
   328 					clearInterval( delayedShow );
   328 					clearInterval( delayedShow );
   329 				}
   329 				}
   330 			}, $.fx.interval );
   330 			}, 13 );
   331 		}
   331 		}
   332 
   332 
   333 		this._trigger( "open", event, { tooltip: tooltip } );
   333 		this._trigger( "open", event, { tooltip: tooltip } );
   334 	},
   334 	},
   335 
   335 
   346 
   346 
   347 		// Only bind remove handler for delegated targets. Non-delegated
   347 		// Only bind remove handler for delegated targets. Non-delegated
   348 		// tooltips will handle this in destroy.
   348 		// tooltips will handle this in destroy.
   349 		if ( target[ 0 ] !== this.element[ 0 ] ) {
   349 		if ( target[ 0 ] !== this.element[ 0 ] ) {
   350 			events.remove = function() {
   350 			events.remove = function() {
   351 				this._removeTooltip( this._find( target ).tooltip );
   351 				var targetElement = this._find( target );
       
   352 				if ( targetElement ) {
       
   353 					this._removeTooltip( targetElement.tooltip );
       
   354 				}
   352 			};
   355 			};
   353 		}
   356 		}
   354 
   357 
   355 		if ( !event || event.type === "mouseover" ) {
   358 		if ( !event || event.type === "mouseover" ) {
   356 			events.mouseleave = "close";
   359 			events.mouseleave = "close";
   446 		var id = target.data( "ui-tooltip-id" );
   449 		var id = target.data( "ui-tooltip-id" );
   447 		return id ? this.tooltips[ id ] : null;
   450 		return id ? this.tooltips[ id ] : null;
   448 	},
   451 	},
   449 
   452 
   450 	_removeTooltip: function( tooltip ) {
   453 	_removeTooltip: function( tooltip ) {
       
   454 
       
   455 		// Clear the interval for delayed tracking tooltips
       
   456 		clearInterval( this.delayedShow );
       
   457 
   451 		tooltip.remove();
   458 		tooltip.remove();
   452 		delete this.tooltips[ tooltip.attr( "id" ) ];
   459 		delete this.tooltips[ tooltip.attr( "id" ) ];
   453 	},
   460 	},
   454 
   461 
   455 	_appendTo: function( target ) {
   462 	_appendTo: function( target ) {
   511 	} );
   518 	} );
   512 }
   519 }
   513 
   520 
   514 return $.ui.tooltip;
   521 return $.ui.tooltip;
   515 
   522 
   516 } ) );
   523 } );