wp/wp-includes/js/jquery/ui/resizable.js
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     1 /*!
     1 /*!
     2  * jQuery UI Resizable 1.13.1
     2  * jQuery UI Resizable 1.13.3
     3  * http://jqueryui.com
     3  * https://jqueryui.com
     4  *
     4  *
     5  * Copyright jQuery Foundation and other contributors
     5  * Copyright OpenJS Foundation and other contributors
     6  * Released under the MIT license.
     6  * Released under the MIT license.
     7  * http://jquery.org/license
     7  * https://jquery.org/license
     8  */
     8  */
     9 
     9 
    10 //>>label: Resizable
    10 //>>label: Resizable
    11 //>>group: Interactions
    11 //>>group: Interactions
    12 //>>description: Enables resize functionality for any element.
    12 //>>description: Enables resize functionality for any element.
    13 //>>docs: http://api.jqueryui.com/resizable/
    13 //>>docs: https://api.jqueryui.com/resizable/
    14 //>>demos: http://jqueryui.com/resizable/
    14 //>>demos: https://jqueryui.com/resizable/
    15 //>>css.structure: ../../themes/base/core.css
    15 //>>css.structure: ../../themes/base/core.css
    16 //>>css.structure: ../../themes/base/resizable.css
    16 //>>css.structure: ../../themes/base/resizable.css
    17 //>>css.theme: ../../themes/base/theme.css
    17 //>>css.theme: ../../themes/base/theme.css
    18 
    18 
    19 ( function( factory ) {
    19 ( function( factory ) {
    23 
    23 
    24 		// AMD. Register as an anonymous module.
    24 		// AMD. Register as an anonymous module.
    25 		define( [
    25 		define( [
    26 			"jquery",
    26 			"jquery",
    27 			"./mouse",
    27 			"./mouse",
    28 			"./core"
    28 			"../disable-selection",
       
    29 			"../plugin",
       
    30 			"../version",
       
    31 			"../widget"
    29 		], factory );
    32 		], factory );
    30 	} else {
    33 	} else {
    31 
    34 
    32 		// Browser globals
    35 		// Browser globals
    33 		factory( jQuery );
    36 		factory( jQuery );
    34 	}
    37 	}
    35 } )( function( $ ) {
    38 } )( function( $ ) {
    36 "use strict";
    39 "use strict";
    37 
    40 
    38 $.widget( "ui.resizable", $.ui.mouse, {
    41 $.widget( "ui.resizable", $.ui.mouse, {
    39 	version: "1.13.1",
    42 	version: "1.13.3",
    40 	widgetEventPrefix: "resize",
    43 	widgetEventPrefix: "resize",
    41 	options: {
    44 	options: {
    42 		alsoResize: false,
    45 		alsoResize: false,
    43 		animate: false,
    46 		animate: false,
    44 		animateDuration: "slow",
    47 		animateDuration: "slow",
   226 
   229 
   227 	_setOption: function( key, value ) {
   230 	_setOption: function( key, value ) {
   228 		this._super( key, value );
   231 		this._super( key, value );
   229 
   232 
   230 		switch ( key ) {
   233 		switch ( key ) {
   231 			case "handles":
   234 		case "handles":
   232 				this._removeHandles();
   235 			this._removeHandles();
   233 				this._setupHandles();
   236 			this._setupHandles();
   234 				break;
   237 			break;
   235 			case "aspectRatio":
   238 		case "aspectRatio":
   236 				this._aspectRatio = !!value;
   239 			this._aspectRatio = !!value;
   237 				break;
   240 			break;
   238 			default:
   241 		default:
   239 				break;
   242 			break;
   240 		}
   243 		}
   241 	},
   244 	},
   242 
   245 
   243 	_setupHandles: function() {
   246 	_setupHandles: function() {
   244 		var o = this.options, handle, i, n, hname, axis, that = this;
   247 		var o = this.options, handle, i, n, hname, axis, that = this;
   298 					this.handles[ i ] = $( this.handles[ i ] );
   301 					this.handles[ i ] = $( this.handles[ i ] );
   299 					this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
   302 					this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
   300 				}
   303 				}
   301 
   304 
   302 				if ( this.elementIsWrapper &&
   305 				if ( this.elementIsWrapper &&
   303 					this.originalElement[ 0 ]
   306 						this.originalElement[ 0 ]
   304 						.nodeName
   307 							.nodeName
   305 						.match( /^(textarea|input|select|button)$/i ) ) {
   308 							.match( /^(textarea|input|select|button)$/i ) ) {
   306 					axis = $( this.handles[ i ], this.element );
   309 					axis = $( this.handles[ i ], this.element );
   307 
   310 
   308 					padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
   311 					padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
   309 						axis.outerHeight() :
   312 						axis.outerHeight() :
   310 						axis.outerWidth();
   313 						axis.outerWidth();
   311 
   314 
   312 					padPos = [ "padding",
   315 					padPos = [ "padding",
   313 						/ne|nw|n/.test( i ) ? "Top" :
   316 						/ne|nw|n/.test( i ) ? "Top" :
   314 							/se|sw|s/.test( i ) ? "Bottom" :
   317 						/se|sw|s/.test( i ) ? "Bottom" :
   315 								/^e$/.test( i ) ? "Right" : "Left" ].join( "" );
   318 						/^e$/.test( i ) ? "Right" : "Left" ].join( "" );
   316 
   319 
   317 					target.css( padPos, padWrapper );
   320 					target.css( padPos, padWrapper );
   318 
   321 
   319 					this._proportionallyResize();
   322 					this._proportionallyResize();
   320 				}
   323 				}
   382 
   385 
   383 		this.offset = this.helper.offset();
   386 		this.offset = this.helper.offset();
   384 		this.position = { left: curleft, top: curtop };
   387 		this.position = { left: curleft, top: curtop };
   385 
   388 
   386 		this.size = this._helper ? {
   389 		this.size = this._helper ? {
   387 			width: this.helper.width(),
   390 				width: this.helper.width(),
   388 			height: this.helper.height()
   391 				height: this.helper.height()
   389 		} : {
   392 			} : {
   390 			width: el.width(),
   393 				width: el.width(),
   391 			height: el.height()
   394 				height: el.height()
   392 		};
   395 			};
   393 
   396 
   394 		this.originalSize = this._helper ? {
   397 		this.originalSize = this._helper ? {
   395 			width: el.outerWidth(),
   398 				width: el.outerWidth(),
   396 			height: el.outerHeight()
   399 				height: el.outerHeight()
   397 		} : {
   400 			} : {
   398 			width: el.width(),
   401 				width: el.width(),
   399 			height: el.height()
   402 				height: el.height()
   400 		};
   403 			};
   401 
   404 
   402 		this.sizeDiff = {
   405 		this.sizeDiff = {
   403 			width: el.outerWidth() - el.width(),
   406 			width: el.outerWidth() - el.width(),
   404 			height: el.outerHeight() - el.height()
   407 			height: el.outerHeight() - el.height()
   405 		};
   408 		};
   528 			props.top = this.position.top + "px";
   531 			props.top = this.position.top + "px";
   529 		}
   532 		}
   530 		if ( this.position.left !== this.prevPosition.left ) {
   533 		if ( this.position.left !== this.prevPosition.left ) {
   531 			props.left = this.position.left + "px";
   534 			props.left = this.position.left + "px";
   532 		}
   535 		}
       
   536 
       
   537 		this.helper.css( props );
       
   538 
   533 		if ( this.size.width !== this.prevSize.width ) {
   539 		if ( this.size.width !== this.prevSize.width ) {
   534 			props.width = this.size.width + "px";
   540 			props.width = this.size.width + "px";
       
   541 			this.helper.width( props.width );
   535 		}
   542 		}
   536 		if ( this.size.height !== this.prevSize.height ) {
   543 		if ( this.size.height !== this.prevSize.height ) {
   537 			props.height = this.size.height + "px";
   544 			props.height = this.size.height + "px";
   538 		}
   545 			this.helper.height( props.height );
   539 
   546 		}
   540 		this.helper.css( props );
       
   541 
   547 
   542 		return props;
   548 		return props;
   543 	},
   549 	},
   544 
   550 
   545 	_updateVirtualBoundaries: function( forceAspectRatio ) {
   551 	_updateVirtualBoundaries: function( forceAspectRatio ) {
  1043 			o = that.options;
  1049 			o = that.options;
  1044 
  1050 
  1045 		$( o.alsoResize ).each( function() {
  1051 		$( o.alsoResize ).each( function() {
  1046 			var el = $( this );
  1052 			var el = $( this );
  1047 			el.data( "ui-resizable-alsoresize", {
  1053 			el.data( "ui-resizable-alsoresize", {
  1048 				width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  1054 				width: parseFloat( el.css( "width" ) ), height: parseFloat( el.css( "height" ) ),
  1049 				left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  1055 				left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  1050 			} );
  1056 			} );
  1051 		} );
  1057 		} );
  1052 	},
  1058 	},
  1053 
  1059 
  1061 				width: ( that.size.width - os.width ) || 0,
  1067 				width: ( that.size.width - os.width ) || 0,
  1062 				top: ( that.position.top - op.top ) || 0,
  1068 				top: ( that.position.top - op.top ) || 0,
  1063 				left: ( that.position.left - op.left ) || 0
  1069 				left: ( that.position.left - op.left ) || 0
  1064 			};
  1070 			};
  1065 
  1071 
  1066 		$( o.alsoResize ).each( function() {
  1072 			$( o.alsoResize ).each( function() {
  1067 			var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  1073 				var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  1068 				css = el.parents( ui.originalElement[ 0 ] ).length ?
  1074 					css = el.parents( ui.originalElement[ 0 ] ).length ?
  1069 					[ "width", "height" ] :
  1075 							[ "width", "height" ] :
  1070 					[ "width", "height", "top", "left" ];
  1076 							[ "width", "height", "top", "left" ];
  1071 
  1077 
  1072 			$.each( css, function( i, prop ) {
  1078 				$.each( css, function( i, prop ) {
  1073 				var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  1079 					var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  1074 				if ( sum && sum >= 0 ) {
  1080 					if ( sum && sum >= 0 ) {
  1075 					style[ prop ] = sum || null;
  1081 						style[ prop ] = sum || null;
  1076 				}
  1082 					}
       
  1083 				} );
       
  1084 
       
  1085 				el.css( style );
  1077 			} );
  1086 			} );
  1078 
       
  1079 			el.css( style );
       
  1080 		} );
       
  1081 	},
  1087 	},
  1082 
  1088 
  1083 	stop: function() {
  1089 	stop: function() {
  1084 		$( this ).removeData( "ui-resizable-alsoresize" );
  1090 		$( this ).removeData( "ui-resizable-alsoresize" );
  1085 	}
  1091 	}