resize-base.js revision cc1d4edffd5ecfd11d5b68c5d24988d0cfb2371a
1247N/AYUI.add('resize-base', function(Y) {
1247N/A
1247N/A/**
1247N/A * The Resize Utility allows you to make an HTML element resizable.
1247N/A *
1247N/A * @module resize
1247N/A */
1247N/A
1247N/Avar Lang = Y.Lang,
1247N/A isArray = Lang.isArray,
1247N/A isBoolean = Lang.isBoolean,
1247N/A isNumber = Lang.isNumber,
1247N/A isString = Lang.isString,
1247N/A
1247N/A trim = Lang.trim,
1247N/A indexOf = Y.Array.indexOf,
1247N/A
1247N/A DOT = '.',
1247N/A COMMA = ',',
1247N/A SPACE = ' ',
1247N/A HANDLE_SUB = '{handle}',
1247N/A
1247N/A ACTIVE = 'active',
1247N/A ACTIVE_HANDLE = 'activeHandle',
1247N/A ACTIVE_HANDLE_NODE = 'activeHandleNode',
1247N/A ALL = 'all',
1247N/A AUTO_HIDE = 'autoHide',
1247N/A BOTTOM = 'bottom',
1247N/A CLASS_NAME = 'className',
1247N/A CURSOR = 'cursor',
1247N/A DEF_MIN_HEIGHT = 'defMinHeight',
1247N/A DEF_MIN_WIDTH = 'defMinWidth',
1247N/A DRAG_CURSOR = 'dragCursor',
1247N/A HANDLE = 'handle',
1247N/A HANDLES = 'handles',
1247N/A HIDDEN = 'hidden',
1247N/A INNER = 'inner',
1247N/A LEFT = 'left',
1247N/A MARGIN = 'margin',
1247N/A NODE = 'node',
1247N/A NODE_NAME = 'nodeName',
1247N/A NONE = 'none',
1247N/A OFFSET_HEIGHT = 'offsetHeight',
1247N/A OFFSET_WIDTH = 'offsetWidth',
1247N/A PARENT_NODE = 'parentNode',
1247N/A POSITION = 'position',
1247N/A PROXY = 'proxy',
1247N/A PROXY_NODE = 'proxyNode',
1247N/A RELATIVE = 'relative',
1247N/A RESIZE = 'resize',
1247N/A RESIZING = 'resizing',
1247N/A RIGHT = 'right',
1247N/A STATIC = 'static',
1247N/A TOP = 'top',
1247N/A WRAP = 'wrap',
1247N/A WRAPPER = 'wrapper',
1247N/A WRAP_TYPES = 'wrapTypes',
1247N/A
1247N/A EV_MOUSE_UP = 'resize:mouseUp',
1247N/A EV_RESIZE = 'resize:resize',
1247N/A EV_RESIZE_ALIGN = 'resize:align',
1247N/A EV_RESIZE_END = 'resize:end',
1247N/A EV_RESIZE_START = 'resize:start',
1247N/A
1247N/A T = 't',
1247N/A TR = 'tr',
1247N/A R = 'r',
1247N/A BR = 'br',
1247N/A B = 'b',
1247N/A BL = 'bl',
1247N/A L = 'l',
1247N/A TL = 'tl',
1247N/A
1247N/A isNode = function(v) {
1247N/A return (v instanceof Y.Node);
1247N/A },
1247N/A
1247N/A handleAttrName = function(handle) {
1247N/A return HANDLE + handle.toUpperCase();
1247N/A },
1247N/A
1247N/A concat = function() {
1247N/A return Array.prototype.slice.call(arguments).join(SPACE);
1247N/A },
1247N/A
1247N/A toInitialCap = Y.cached(
1247N/A function(str) {
1247N/A return str.substring(0, 1).toUpperCase() + str.substring(1);
1247N/A }
1247N/A ),
1247N/A
1247N/A getCN = Y.ClassNameManager.getClassName,
1247N/A
1247N/A CSS_RESIZE = getCN(RESIZE),
1247N/A CSS_RESIZE_HANDLE = getCN(RESIZE, HANDLE),
1247N/A CSS_RESIZE_HANDLE_ACTIVE = getCN(RESIZE, HANDLE, ACTIVE),
1247N/A CSS_RESIZE_HANDLE_INNER = getCN(RESIZE, HANDLE, INNER),
1247N/A CSS_RESIZE_HANDLE_INNER_PLACEHOLDER = getCN(RESIZE, HANDLE, INNER, HANDLE_SUB),
1247N/A CSS_RESIZE_HANDLE_PLACEHOLDER = getCN(RESIZE, HANDLE, HANDLE_SUB),
1247N/A CSS_RESIZE_HIDDEN_HANDLES = getCN(RESIZE, HIDDEN, HANDLES),
1247N/A CSS_RESIZE_PROXY = getCN(RESIZE, PROXY),
1247N/A CSS_RESIZE_WRAPPER = getCN(RESIZE, WRAPPER);
1247N/A
1247N/A/**
1247N/A * A base class for Resize, providing:
1247N/A * <ul>
1247N/A * <li>Basic Lifecycle (initializer, renderUI, bindUI, syncUI, destructor)</li>
1247N/A * <li>Applies drag handles to an element to make it resizable</li>
1247N/A * <li>Here is the list of valid resize handles:
1247N/A * <code>[ 't', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl' ]</code>. You can
1247N/A * read this list as top, top-right, right, bottom-right, bottom,
1247N/A * bottom-left, left, top-left.</li>
1247N/A * <li>The drag handles are inserted into the element and positioned
1247N/A * absolute. Some elements, such as a textarea or image, don't support
1247N/A * children. To overcome that, set wrap:true in your config and the
1247N/A * element willbe wrapped for you automatically.</li>
1247N/A * </ul>
1247N/A *
1247N/A * Quick Example:
1247N/A *
1247N/A * <pre><code>var instance = new Y.Resize({
1247N/A * node: '#resize1',
1247N/A * proxy: true,
1247N/A * preserveRatio: true,
1247N/A * wrap: true,
1247N/A * maxHeight: 170,
1247N/A * maxWidth: 400,
1247N/A * handles: 't, tr, r, br, b, bl, l, tl'
1247N/A * });
1247N/A * </code></pre>
1247N/A *
1247N/A * Check the list of <a href="Resize.html#configattributes">Configuration Attributes</a> available for
1247N/A * Resize.
1247N/A *
1247N/A * @class Resize
1247N/A * @param config {Object} Object literal specifying widget configuration properties.
1247N/A * @constructor
1247N/A * @extends Base
1247N/A */
1247N/Afunction Resize() {
1247N/A Resize.superclass.constructor.apply(this, arguments);
1247N/A}
1247N/A
1247N/AY.mix(Resize, {
1247N/A /**
1247N/A * Static property provides a string to identify the class.
1247N/A *
1247N/A * @property Resize.NAME
1247N/A * @type String
1247N/A * @static
1247N/A */
1247N/A NAME: RESIZE,
1247N/A
1247N/A /**
1247N/A * Static property used to define the default attribute
1247N/A * configuration for the Resize.
1247N/A *
1247N/A * @property Resize.ATTRS
1247N/A * @type Object
1247N/A * @static
1247N/A */
1247N/A ATTRS: {
1247N/A /**
1247N/A * Stores the active handle during the resize.
1247N/A *
1247N/A * @attribute activeHandle
1247N/A * @default null
1247N/A * @private
1247N/A * @type String
1247N/A */
1247N/A activeHandle: {
1247N/A value: null,
1247N/A validator: isString
1247N/A },
1247N/A
1247N/A /**
1247N/A * Stores the active handle element during the resize.
1247N/A *
1247N/A * @attribute activeHandleNode
1247N/A * @default null
1247N/A * @private
1247N/A * @type Node
1247N/A */
1247N/A activeHandleNode: {
1247N/A value: null,
1247N/A validator: isNode
1247N/A },
1247N/A
1247N/A /**
1247N/A * False to ensure that the resize handles are always visible, true to
1247N/A * display them only when the user mouses over the resizable borders.
1247N/A *
1247N/A * @attribute autoHide
1247N/A * @default false
1247N/A * @type boolean
1247N/A */
1247N/A autoHide: {
1247N/A value: false,
1247N/A validator: isBoolean
1247N/A },
1247N/A
1247N/A /**
1247N/A * The default minimum height of the element. Only used when
1247N/A * ResizeConstrained is not plugged.
1247N/A *
1247N/A * @attribute defMinHeight
1247N/A * @default 15
1247N/A * @type Number
1247N/A */
1247N/A defMinHeight: {
1247N/A value: 15,
1247N/A validator: isNumber
1247N/A },
1247N/A
1247N/A /**
1247N/A * The default minimum width of the element. Only used when
1247N/A * ResizeConstrained is not plugged.
1247N/A *
1247N/A * @attribute defMinWidth
1247N/A * @default 15
1247N/A * @type Number
1247N/A */
1247N/A defMinWidth: {
1247N/A value: 15,
1247N/A validator: isNumber
1247N/A },
1247N/A
1247N/A /**
1247N/A * The handles to use (any combination of): 't', 'b', 'r', 'l', 'bl',
1247N/A * 'br', 'tl', 'tr'. Can use a shortcut of All.
1247N/A *
1247N/A * @attribute handles
1247N/A * @default all
1247N/A * @type Array | String
1247N/A */
1247N/A handles: {
1247N/A setter: '_setHandles',
1247N/A value: ALL
1247N/A },
1247N/A
1247N/A /**
1247N/A * The selector or element to resize. Required.
1247N/A *
1247N/A * @attribute node
1247N/A * @type Node
1247N/A */
1247N/A node: {
1247N/A setter: Y.one
1247N/A },
1247N/A
1247N/A /**
1247N/A * Resize a proxy element instead of the real element.
1247N/A *
1247N/A * @attribute proxy
1247N/A * @default false
1247N/A * @type boolean
1247N/A */
1247N/A proxy: {
1247N/A value: false,
1247N/A validator: isBoolean
1247N/A },
1247N/A
1247N/A /**
1247N/A * The Resize proxy element.
1247N/A *
1247N/A * @attribute proxyNode
1247N/A * @default Generated using an internal HTML markup
1247N/A * @type String | Node
1247N/A */
1247N/A proxyNode: {
1247N/A setter: Y.one,
1247N/A valueFn: function() {
1247N/A return Y.Node.create(this.PROXY_TEMPLATE);
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * True when the element is being Resized.
1247N/A *
1247N/A * @attribute resizing
1247N/A * @default false
1247N/A * @type boolean
1247N/A */
1247N/A resizing: {
1247N/A value: false,
1247N/A validator: isBoolean
1247N/A },
1247N/A
1247N/A /**
1247N/A * True to wrap an element with a div if needed (required for textareas
1247N/A * and images, defaults to false) in favor of the handles config option.
1247N/A * The wrapper element type (default div) could be over-riden passing the
1247N/A * <code>wrapper</code> attribute.
1247N/A *
1247N/A * @attribute wrap
1247N/A * @default false
1247N/A * @type boolean
1247N/A */
1247N/A wrap: {
1247N/A setter: '_setWrap',
1247N/A value: false,
1247N/A validator: isBoolean
1247N/A },
1247N/A
1247N/A /**
1247N/A * Elements that requires a wrapper by default. Normally are elements
1247N/A * which cannot have children elements.
1247N/A *
1247N/A * @attribute wrapTypes
1247N/A * @default /canvas|textarea|input|select|button|img/i
1247N/A * @readOnly
1247N/A * @type Regex
1247N/A */
1247N/A wrapTypes: {
1247N/A readOnly: true,
1247N/A value: /^canvas|textarea|input|select|button|img|iframe|table|embed$/i
1247N/A },
1247N/A
1247N/A /**
1247N/A * Element to wrap the <code>wrapTypes</code>. This element will house
1247N/A * the handles elements.
1247N/A *
1247N/A * @attribute wrapper
1247N/A * @default div
1247N/A * @type String | Node
1247N/A * @writeOnce
1247N/A */
1247N/A wrapper: {
1247N/A readOnly: true,
1247N/A valueFn: '_valueWrapper',
1247N/A writeOnce: true
1247N/A }
1247N/A }
1247N/A});
1247N/A
1247N/AY.Resize = Y.extend(
1247N/A Resize,
1247N/A Y.Base,
1247N/A {
1247N/A /**
1247N/A * Array containing all possible resizable handles.
1247N/A *
1247N/A * @property ALL_HANDLES
1247N/A * @type {String}
1247N/A */
1247N/A ALL_HANDLES: [ T, TR, R, BR, B, BL, L, TL ],
1247N/A
1247N/A /**
1247N/A * Regex which matches with the handles that could change the height of
1247N/A * the resizable element.
1247N/A *
1247N/A * @property REGEX_CHANGE_HEIGHT
1247N/A * @type {String}
1247N/A */
1247N/A REGEX_CHANGE_HEIGHT: /^(t|tr|b|bl|br|tl)$/i,
1247N/A
1247N/A /**
1247N/A * Regex which matches with the handles that could change the left of
1247N/A * the resizable element.
1247N/A *
1247N/A * @property REGEX_CHANGE_LEFT
1247N/A * @type {String}
1247N/A */
1247N/A REGEX_CHANGE_LEFT: /^(tl|l|bl)$/i,
1247N/A
1247N/A /**
1247N/A * Regex which matches with the handles that could change the top of
1247N/A * the resizable element.
1247N/A *
1247N/A * @property REGEX_CHANGE_TOP
1247N/A * @type {String}
1247N/A */
1247N/A REGEX_CHANGE_TOP: /^(tl|t|tr)$/i,
1247N/A
1247N/A /**
1247N/A * Regex which matches with the handles that could change the width of
1247N/A * the resizable element.
1247N/A *
1247N/A * @property REGEX_CHANGE_WIDTH
1247N/A * @type {String}
1247N/A */
1247N/A REGEX_CHANGE_WIDTH: /^(bl|br|l|r|tl|tr)$/i,
1247N/A
1247N/A /**
1247N/A * Template used to create the resize wrapper node when needed.
1247N/A *
1247N/A * @property WRAP_TEMPLATE
1247N/A * @type {String}
1247N/A */
1247N/A WRAP_TEMPLATE: '<div class="'+CSS_RESIZE_WRAPPER+'"></div>',
1247N/A
1247N/A /**
1247N/A * Template used to create the resize proxy.
1247N/A *
1247N/A * @property PROXY_TEMPLATE
1247N/A * @type {String}
1247N/A */
1247N/A PROXY_TEMPLATE: '<div class="'+CSS_RESIZE_PROXY+'"></div>',
1247N/A
1247N/A /**
1247N/A * Template used to create each resize handle.
1247N/A *
1247N/A * @property HANDLE_TEMPLATE
1247N/A * @type {String}
1247N/A */
1247N/A HANDLE_TEMPLATE: '<div class="'+concat(CSS_RESIZE_HANDLE, CSS_RESIZE_HANDLE_PLACEHOLDER)+'">' +
1247N/A '<div class="'+concat(CSS_RESIZE_HANDLE_INNER, CSS_RESIZE_HANDLE_INNER_PLACEHOLDER)+'">&nbsp;</div>' +
1247N/A '</div>',
1247N/A
1247N/A /**
1247N/A * Whether the handle being dragged can change the height.
1247N/A *
1247N/A * @property changeHeightHandles
1247N/A * @default false
1247N/A * @type boolean
1247N/A */
1247N/A changeHeightHandles: false,
1247N/A
1247N/A /**
1247N/A * Whether the handle being dragged can change the left.
1247N/A *
1247N/A * @property changeLeftHandles
1247N/A * @default false
1247N/A * @type boolean
1247N/A */
1247N/A changeLeftHandles: false,
1247N/A
1247N/A /**
1247N/A * Whether the handle being dragged can change the top.
1247N/A *
1247N/A * @property changeTopHandles
1247N/A * @default false
1247N/A * @type boolean
1247N/A */
1247N/A changeTopHandles: false,
1247N/A
1247N/A /**
1247N/A * Whether the handle being dragged can change the width.
1247N/A *
1247N/A * @property changeWidthHandles
1247N/A * @default false
1247N/A * @type boolean
1247N/A */
1247N/A changeWidthHandles: false,
1247N/A
1247N/A /**
1247N/A * Store DD.Delegate reference for the respective Resize instance.
1247N/A *
1247N/A * @property delegate
1247N/A * @default null
1247N/A * @type Object
1247N/A */
1247N/A delegate: null,
1247N/A
1247N/A /**
1247N/A * Stores the current values for the height, width, top and left. You are
1247N/A * able to manipulate these values on resize in order to change the resize
1247N/A * behavior.
1247N/A *
1247N/A * @property info
1247N/A * @type Object
1247N/A * @protected
1247N/A */
1247N/A info: null,
1247N/A
1247N/A /**
1247N/A * Stores the last values for the height, width, top and left.
1247N/A *
1247N/A * @property lastInfo
1247N/A * @type Object
1247N/A * @protected
1247N/A */
1247N/A lastInfo: null,
1247N/A
1247N/A /**
1247N/A * Stores the original values for the height, width, top and left, stored
1247N/A * on resize start.
1247N/A *
1247N/A * @property originalInfo
1247N/A * @type Object
1247N/A * @protected
1247N/A */
1247N/A originalInfo: null,
1247N/A
1247N/A /**
1247N/A * Construction logic executed during Resize instantiation. Lifecycle.
1247N/A *
1247N/A * @method initializer
1247N/A * @protected
1247N/A */
1247N/A initializer: function() {
1247N/A var instance = this;
1247N/A
1247N/A instance.info = {};
1247N/A
1247N/A instance.originalInfo = {};
1247N/A
1247N/A instance.get(NODE).addClass(CSS_RESIZE);
1247N/A
1247N/A instance.renderer();
1247N/A },
1247N/A
1247N/A /**
1247N/A * Create the DOM structure for the Resize. Lifecycle.
1247N/A *
1247N/A * @method renderUI
1247N/A * @protected
1247N/A */
1247N/A renderUI: function() {
1247N/A var instance = this;
1247N/A
1247N/A instance._renderHandles();
1247N/A },
1247N/A
1247N/A /**
1247N/A * Bind the events on the Resize UI. Lifecycle.
1247N/A *
1247N/A * @method bindUI
1247N/A * @protected
1247N/A */
1247N/A bindUI: function() {
1247N/A var instance = this;
1247N/A
1247N/A instance._createEvents();
1247N/A instance._bindDD();
1247N/A instance._bindHandle();
1247N/A },
1247N/A
1247N/A /**
1247N/A * Sync the Resize UI.
1247N/A *
1247N/A * @method syncUI
1247N/A * @protected
1247N/A */
1247N/A syncUI: function() {
1247N/A var instance = this;
1247N/A
1247N/A // hide handles if AUTO_HIDE is true
1247N/A instance._setHideHandlesUI(
1247N/A instance.get(AUTO_HIDE)
1247N/A );
1247N/A },
1247N/A
1247N/A /**
1247N/A * Descructor lifecycle implementation for the Resize class. Purges events attached
1247N/A * to the node (and all child nodes) and removes the Resize handles.
1247N/A *
1247N/A * @method destructor
1247N/A * @protected
1247N/A */
1247N/A destructor: function() {
1247N/A var instance = this,
1247N/A node = instance.get(NODE),
1247N/A wrapper = instance.get(WRAPPER),
1247N/A pNode = wrapper.get(PARENT_NODE);
1247N/A
1247N/A // purgeElements on boundingBox
1247N/A Y.Event.purgeElement(wrapper, true);
1247N/A
1247N/A // destroy handles dd and remove them from the dom
1247N/A instance.eachHandle(function(handleEl) {
1247N/A instance.delegate.dd.destroy();
1247N/A
1247N/A // remove handle
1247N/A handleEl.remove(true);
1247N/A });
1247N/A
1247N/A // unwrap node
1247N/A if (instance.get(WRAP)) {
1247N/A instance._copyStyles(wrapper, node);
1247N/A
1247N/A if (pNode) {
1247N/A pNode.insertBefore(node, wrapper);
1247N/A }
1247N/A
1247N/A wrapper.remove(true);
1247N/A }
1247N/A
1247N/A node.removeClass(CSS_RESIZE);
1247N/A node.removeClass(CSS_RESIZE_HIDDEN_HANDLES);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Creates DOM (or manipulates DOM for progressive enhancement)
1247N/A * This method is invoked by initializer(). It's chained automatically for
1247N/A * subclasses if required.
1247N/A *
1247N/A * @method renderer
1247N/A * @protected
1247N/A */
1247N/A renderer: function() {
1247N/A this.renderUI();
1247N/A this.bindUI();
1247N/A this.syncUI();
1247N/A },
1247N/A
1247N/A /**
1247N/A * <p>Loop through each handle which is being used and executes a callback.</p>
1247N/A * <p>Example:</p>
1247N/A * <pre><code>instance.eachHandle(
1247N/A * function(handleName, index) { ... }
1247N/A * );</code></pre>
1247N/A *
1247N/A * @method eachHandle
1247N/A * @param {function} fn Callback function to be executed for each handle.
1247N/A */
1247N/A eachHandle: function(fn) {
1247N/A var instance = this;
1247N/A
1247N/A Y.each(
1247N/A instance.get(HANDLES),
1247N/A function(handle, i) {
1247N/A var handleEl = instance.get(
1247N/A handleAttrName(handle)
1247N/A );
1247N/A
1247N/A fn.apply(instance, [handleEl, handle, i]);
1247N/A }
1247N/A );
1247N/A },
1247N/A
1247N/A /**
1247N/A * Bind the handles DragDrop events to the Resize instance.
1247N/A *
1247N/A * @method _bindDD
1247N/A * @private
1247N/A */
1247N/A _bindDD: function() {
1247N/A var instance = this;
1247N/A
1247N/A instance.delegate = new Y.DD.Delegate(
1247N/A {
1247N/A bubbleTargets: instance,
1247N/A container: instance.get(WRAPPER),
1247N/A dragConfig: {
1247N/A clickPixelThresh: 0,
1247N/A clickTimeThresh: 0,
1247N/A useShim: true,
1247N/A move: false
1247N/A },
1247N/A nodes: DOT+CSS_RESIZE_HANDLE,
1247N/A target: false
1247N/A }
1247N/A );
1247N/A
1247N/A instance.on('drag:drag', instance._handleResizeEvent);
1247N/A instance.on('drag:dropmiss', instance._handleMouseUpEvent);
1247N/A instance.on('drag:end', instance._handleResizeEndEvent);
1247N/A instance.on('drag:start', instance._handleResizeStartEvent);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Bind the events related to the handles (_onHandleMouseEnter, _onHandleMouseLeave).
1247N/A *
1247N/A * @method _bindHandle
1247N/A * @private
1247N/A */
1247N/A _bindHandle: function() {
1247N/A var instance = this,
1247N/A wrapper = instance.get(WRAPPER);
1247N/A
1247N/A wrapper.on('mouseenter', Y.bind(instance._onWrapperMouseEnter, instance));
1247N/A wrapper.on('mouseleave', Y.bind(instance._onWrapperMouseLeave, instance));
1247N/A wrapper.delegate('mouseenter', Y.bind(instance._onHandleMouseEnter, instance), DOT+CSS_RESIZE_HANDLE);
1247N/A wrapper.delegate('mouseleave', Y.bind(instance._onHandleMouseLeave, instance), DOT+CSS_RESIZE_HANDLE);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Create the custom events used on the Resize.
1247N/A *
1247N/A * @method _createEvents
1247N/A * @private
1247N/A */
1247N/A _createEvents: function() {
1247N/A var instance = this,
1247N/A // create publish function for kweight optimization
1247N/A publish = function(name, fn) {
1247N/A instance.publish(name, {
1247N/A defaultFn: fn,
1247N/A queuable: false,
1247N/A emitFacade: true,
1247N/A bubbles: true,
1247N/A prefix: RESIZE
1247N/A });
1247N/A };
1247N/A
1247N/A /**
1247N/A * Handles the resize start event. Fired when a handle starts to be
1247N/A * dragged.
1247N/A *
1247N/A * @event resize:start
1247N/A * @preventable _defResizeStartFn
1247N/A * @param {Event.Facade} event The resize start event.
1247N/A * @bubbles Resize
1247N/A * @type {Event.Custom}
1247N/A */
1247N/A publish(EV_RESIZE_START, this._defResizeStartFn);
1247N/A
1247N/A /**
1247N/A * Handles the resize event. Fired on each pixel when the handle is
1247N/A * being dragged.
1247N/A *
1247N/A * @event resize:resize
1247N/A * @preventable _defResizeFn
1247N/A * @param {Event.Facade} event The resize event.
1247N/A * @bubbles Resize
1247N/A * @type {Event.Custom}
1247N/A */
1247N/A publish(EV_RESIZE, this._defResizeFn);
1247N/A
1247N/A /**
1247N/A * Handles the resize align event.
1247N/A *
1247N/A * @event resize:align
1247N/A * @preventable _defResizeAlignFn
1247N/A * @param {Event.Facade} event The resize align event.
1247N/A * @bubbles Resize
1247N/A * @type {Event.Custom}
1247N/A */
1247N/A publish(EV_RESIZE_ALIGN, this._defResizeAlignFn);
1247N/A
1247N/A /**
1247N/A * Handles the resize end event. Fired when a handle stop to be
1247N/A * dragged.
1247N/A *
1247N/A * @event resize:end
1247N/A * @preventable _defResizeEndFn
1247N/A * @param {Event.Facade} event The resize end event.
1247N/A * @bubbles Resize
1247N/A * @type {Event.Custom}
1247N/A */
1247N/A publish(EV_RESIZE_END, this._defResizeEndFn);
1247N/A
1247N/A /**
1247N/A * Handles the resize mouseUp event. Fired when a mouseUp event happens on a
1247N/A * handle.
1247N/A *
1247N/A * @event resize:mouseUp
1247N/A * @preventable _defMouseUpFn
1247N/A * @param {Event.Facade} event The resize mouseUp event.
1247N/A * @bubbles Resize
1247N/A * @type {Event.Custom}
1247N/A */
1247N/A publish(EV_MOUSE_UP, this._defMouseUpFn);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Responsible for loop each handle element and append to the wrapper.
1247N/A *
1247N/A * @method _renderHandles
1247N/A * @protected
1247N/A */
1247N/A _renderHandles: function() {
1247N/A var instance = this,
1247N/A wrapper = instance.get(WRAPPER);
1247N/A
1247N/A instance.eachHandle(function(handleEl) {
1247N/A wrapper.append(handleEl);
1247N/A });
1247N/A },
1247N/A
1247N/A /**
1247N/A * Render the <a href="Resize.html#config_proxyNode">proxyNode</a> element and
1247N/A * make it sibling of the <a href="Resize.html#config_node">node</a>.
1247N/A *
1247N/A * @method _renderProxy
1247N/A * @protected
1247N/A */
1247N/A _renderProxy: function() {
1247N/A var instance = this,
1247N/A proxyNode = instance.get(PROXY_NODE);
1247N/A
1247N/A if (!proxyNode.inDoc()) {
1247N/A instance.get(WRAPPER).get(PARENT_NODE).append(
1247N/A proxyNode.hide()
1247N/A );
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Creates the handle element based on the handle name and initialize the
1247N/A * DragDrop on it.
1247N/A *
1247N/A * @method _buildHandle
1247N/A * @param {String} handle Handle name ('t', 'tr', 'b', ...).
1247N/A * @protected
1247N/A */
1247N/A _buildHandle: function(handle) {
1247N/A var instance = this;
1247N/A
1247N/A return Y.Node.create(
1247N/A Y.substitute(instance.HANDLE_TEMPLATE, {
1247N/A handle: handle
1247N/A })
1247N/A );
1247N/A },
1247N/A
1247N/A /**
1247N/A * Helper method to update the current size value on
1247N/A * <a href="Resize.html#property_info">info</a> to respect the
1247N/A * min/max values and fix the top/left calculations.
1247N/A *
1247N/A * @method _checkSize
1247N/A * @param {String} offset 'offsetHeight' or 'offsetWidth'
1247N/A * @param {number} size Size to restrict the offset
1247N/A * @protected
1247N/A */
1247N/A _checkSize: function(offset, size) {
1247N/A var instance = this,
1247N/A info = instance.info,
1247N/A originalInfo = instance.originalInfo,
1247N/A axis = (offset == OFFSET_HEIGHT) ? TOP : LEFT;
1247N/A
1247N/A // forcing the offsetHeight/offsetWidth to be the passed size
1247N/A info[offset] = size;
1247N/A
1247N/A // predicting, based on the original information, the last left valid in case of reach the min/max dimension
1247N/A // this calculation avoid browser event leaks when user interact very fast with their mouse
1247N/A if (((axis == LEFT) && instance.changeLeftHandles) ||
1247N/A ((axis == TOP) && instance.changeTopHandles)) {
1247N/A
1247N/A info[axis] = originalInfo[axis] + originalInfo[offset] - size;
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Copy relevant styles of the <a href="Resize.html#config_node">node</a>
1247N/A * to the <a href="Resize.html#config_wrapper">wrapper</a>.
1247N/A *
1247N/A * @method _copyStyles
1247N/A * @param {Node} node Node from.
1247N/A * @param {Node} wrapper Node to.
1247N/A * @protected
1247N/A */
1247N/A _copyStyles: function(node, wrapper) {
1247N/A var position = node.getStyle(POSITION).toLowerCase(),
1247N/A nodeStyle = {},
1247N/A wrapperStyle;
1247N/A
1247N/A // resizable wrapper should be positioned
1247N/A if (position == STATIC) {
1247N/A position = RELATIVE;
1247N/A }
1247N/A
1247N/A // copy margin, padding, position styles from the node to wrapper
1247N/A wrapperStyle = {
1247N/A position: position
1247N/A };
1247N/A
1247N/A // store top/left from the nodes involved
1247N/A // apply top/left from node to the wrapper
1247N/A Y.each([ TOP, LEFT ], function(name) {
1247N/A nodeStyle[name] = wrapper.getStyle(name);
1247N/A wrapperStyle[name] = node.getStyle(name);
1247N/A });
1247N/A
1247N/A // store margin(Top,Right,Bottom,Left) from the nodes involved
1247N/A // apply margin from node to the wrapper
1247N/A Y.each([ TOP, RIGHT, BOTTOM, LEFT ], function(dir) {
1247N/A var name = MARGIN + toInitialCap(dir);
1247N/A
1247N/A nodeStyle[name] = wrapper.getStyle(name);
1247N/A wrapperStyle[name] = node.getStyle(name);
1247N/A });
1247N/A
1247N/A wrapper.setStyles(wrapperStyle);
1247N/A node.setStyles(nodeStyle);
1247N/A
1247N/A // force remove margin from the internal node
1247N/A node.setStyles({ margin: 0 });
1247N/A
1247N/A wrapper.set(
1247N/A OFFSET_HEIGHT,
1247N/A node.get(OFFSET_HEIGHT)
1247N/A );
1247N/A
1247N/A wrapper.set(
1247N/A OFFSET_WIDTH,
1247N/A node.get(OFFSET_WIDTH)
1247N/A );
1247N/A },
1247N/A
1247N/A // extract handle name from a string
1247N/A // using Y.cached to memoize the function for performance
1247N/A _extractHandleName: Y.cached(
1247N/A function(node) {
1247N/A var className = node.get(CLASS_NAME),
1247N/A
1247N/A match = className.match(
1247N/A new RegExp(
1247N/A getCN(RESIZE, HANDLE, '(\\w{1,2})\\b')
1247N/A )
1247N/A );
1247N/A
1247N/A return match ? match[1] : null;
1247N/A }
1247N/A ),
1247N/A
1247N/A /**
1247N/A * <p>Generates metadata to the <a href="Resize.html#property_info">info</a>
1247N/A * and <a href="Resize.html#property_originalInfo">originalInfo</a></p>
1247N/A * <pre><code>bottom, actXY, left, top, offsetHeight, offsetWidth, right</code></pre>
1247N/A *
1247N/A * @method _getInfo
1247N/A * @param {Node} node
1247N/A * @param {EventFacade} event
1247N/A * @private
1247N/A */
1247N/A _getInfo: function(node, event) {
1247N/A var actXY,
1247N/A drag = event.dragEvent.target,
1247N/A nodeXY = node.getXY(),
1247N/A nodeX = nodeXY[0],
1247N/A nodeY = nodeXY[1],
1247N/A offsetHeight = node.get(OFFSET_HEIGHT),
1247N/A offsetWidth = node.get(OFFSET_WIDTH);
1247N/A
1247N/A if (event) {
1247N/A // the xy that the node will be set to. Changing this will alter the position as it's dragged.
1247N/A actXY = (drag.actXY.length ? drag.actXY : drag.lastXY);
1247N/A }
1247N/A
1247N/A return {
1247N/A actXY: actXY,
1247N/A bottom: (nodeY + offsetHeight),
1247N/A left: nodeX,
1247N/A offsetHeight: offsetHeight,
1247N/A offsetWidth: offsetWidth,
1247N/A right: (nodeX + offsetWidth),
1247N/A top: nodeY
1247N/A };
1247N/A },
1247N/A
1247N/A /**
1247N/A * Basic resize calculations.
1247N/A *
1247N/A * @method _resize
1247N/A * @protected
1247N/A */
1247N/A _resize: function() {
1247N/A var instance = this,
1247N/A handle = instance.get(ACTIVE_HANDLE),
1247N/A info = instance.info,
1247N/A originalInfo = instance.originalInfo,
1247N/A
1247N/A dx = info.actXY[0] - originalInfo.actXY[0],
1247N/A dy = info.actXY[1] - originalInfo.actXY[1],
1247N/A
1247N/A rules = {
1247N/A t: function() {
1247N/A info.top = originalInfo.top + dy;
1247N/A info.offsetHeight = originalInfo.offsetHeight - dy;
1247N/A },
1247N/A r: function() {
1247N/A info.offsetWidth = originalInfo.offsetWidth + dx;
1247N/A },
1247N/A l: function() {
1247N/A info.left = originalInfo.left + dx;
1247N/A info.offsetWidth = originalInfo.offsetWidth - dx;
1247N/A },
1247N/A b: function() {
1247N/A info.offsetHeight = originalInfo.offsetHeight + dy;
1247N/A },
1247N/A tr: function() {
1247N/A this.t();
1247N/A this.r();
1247N/A },
1247N/A br: function() {
1247N/A this.b();
1247N/A this.r();
1247N/A },
1247N/A tl: function() {
1247N/A this.t();
1247N/A this.l();
1247N/A },
1247N/A bl: function() {
1247N/A this.b();
1247N/A this.l();
1247N/A }
1247N/A };
1247N/A
1247N/A rules[handle](dx, dy);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Set offsetWidth and offsetHeight of the passed node.
1247N/A *
1247N/A * @method _setOffset
1247N/A * @param {Node} node Node
1247N/A * @param {number} offsetWidth
1247N/A * @param {number} offsetHeight
1247N/A * @protected
1247N/A */
1247N/A _setOffset: function(node, offsetWidth, offsetHeight) {
1247N/A node.set(OFFSET_WIDTH, offsetWidth);
1247N/A node.set(OFFSET_HEIGHT, offsetHeight);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Sync the Resize UI with internal values from
1247N/A * <a href="Resize.html#property_info">info</a>.
1247N/A *
1247N/A * @method _syncUI
1247N/A * @protected
1247N/A */
1247N/A _syncUI: function() {
1247N/A var instance = this,
1247N/A info = instance.info,
1247N/A wrapper = instance.get(WRAPPER),
1247N/A node = instance.get(NODE);
1247N/A
1247N/A instance._setOffset(wrapper, info.offsetWidth, info.offsetHeight);
1247N/A
1247N/A if (instance.changeLeftHandles || instance.changeTopHandles) {
1247N/A wrapper.setXY([info.left, info.top]);
1247N/A }
1247N/A
1247N/A // if wrapper is different from node
1247N/A if (!wrapper.compareTo(node)) {
1247N/A instance._setOffset(node, info.offsetWidth, info.offsetHeight);
1247N/A }
1247N/A
1247N/A // prevent webkit textarea resize
1247N/A if (Y.UA.webkit) {
1247N/A node.setStyle(RESIZE, NONE);
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Sync the proxy UI with internal values from
1247N/A * <a href="Resize.html#property_info">info</a>.
1247N/A *
1247N/A * @method _syncProxyUI
1247N/A * @protected
1247N/A */
1247N/A _syncProxyUI: function() {
1247N/A var instance = this,
1247N/A info = instance.info,
1247N/A activeHandleNode = instance.get(ACTIVE_HANDLE_NODE),
1247N/A proxyNode = instance.get(PROXY_NODE),
1247N/A cursor = activeHandleNode.getStyle(CURSOR);
1247N/A
1247N/A proxyNode.show().setStyle(CURSOR, cursor);
1247N/A
1247N/A instance.delegate.dd.set(DRAG_CURSOR, cursor);
1247N/A
1247N/A instance._setOffset(proxyNode, info.offsetWidth, info.offsetHeight);
1247N/A
1247N/A proxyNode.setXY([ info.left, info.top ]);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Update <code>instance.changeHeightHandles,
1247N/A * instance.changeLeftHandles, instance.changeTopHandles,
1247N/A * instance.changeWidthHandles</code> information.
1247N/A *
1247N/A * @method _updateChangeHandleInfo
1247N/A * @private
1247N/A */
1247N/A _updateChangeHandleInfo: function(handle) {
1247N/A var instance = this;
1247N/A
1247N/A instance.changeHeightHandles = instance.REGEX_CHANGE_HEIGHT.test(handle);
1247N/A instance.changeLeftHandles = instance.REGEX_CHANGE_LEFT.test(handle);
1247N/A instance.changeTopHandles = instance.REGEX_CHANGE_TOP.test(handle);
1247N/A instance.changeWidthHandles = instance.REGEX_CHANGE_WIDTH.test(handle);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Update <a href="Resize.html#property_info">info</a> values (bottom, actXY, left, top, offsetHeight, offsetWidth, right).
1247N/A *
1247N/A * @method _updateInfo
1247N/A * @private
1247N/A */
1247N/A _updateInfo: function(event) {
1247N/A var instance = this;
1247N/A
1247N/A instance.info = instance._getInfo(instance.get(WRAPPER), event);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Set the active state of the handles.
1247N/A *
1247N/A * @method _setActiveHandlesUI
1247N/A * @param {boolean} val True to activate the handles, false to deactivate.
1247N/A * @protected
1247N/A */
1247N/A _setActiveHandlesUI: function(val) {
1247N/A var instance = this,
1247N/A activeHandleNode = instance.get(ACTIVE_HANDLE_NODE);
1247N/A
1247N/A if (activeHandleNode) {
1247N/A if (val) {
1247N/A // remove CSS_RESIZE_HANDLE_ACTIVE from all handles before addClass on the active
1247N/A instance.eachHandle(
1247N/A function(handleEl) {
1247N/A handleEl.removeClass(CSS_RESIZE_HANDLE_ACTIVE);
1247N/A }
1247N/A );
1247N/A
1247N/A activeHandleNode.addClass(CSS_RESIZE_HANDLE_ACTIVE);
1247N/A }
1247N/A else {
1247N/A activeHandleNode.removeClass(CSS_RESIZE_HANDLE_ACTIVE);
1247N/A }
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Setter for the handles attribute
1247N/A *
1247N/A * @method _setHandles
1247N/A * @protected
1247N/A * @param {String} val
1247N/A */
1247N/A _setHandles: function(val) {
1247N/A var instance = this,
1247N/A handles = [];
1247N/A
1247N/A // handles attr accepts both array or string
1247N/A if (isArray(val)) {
1247N/A handles = val;
1247N/A }
1247N/A else if (isString(val)) {
1247N/A // if the handles attr passed in is an ALL string...
1247N/A if (val.toLowerCase() == ALL) {
1247N/A handles = instance.ALL_HANDLES;
1247N/A }
1247N/A // otherwise, split the string to extract the handles
1247N/A else {
1247N/A Y.each(
1247N/A val.split(COMMA),
1247N/A function(node, i) {
1247N/A var handle = trim(node);
1247N/A
1247N/A // if its a valid handle, add it to the handles output
1247N/A if (indexOf(instance.ALL_HANDLES, handle) > -1) {
1247N/A handles.push(handle);
1247N/A }
1247N/A }
1247N/A );
1247N/A }
1247N/A }
1247N/A
1247N/A return handles;
1247N/A },
1247N/A
1247N/A /**
1247N/A * Set the visibility of the handles.
1247N/A *
1247N/A * @method _setHideHandlesUI
1247N/A * @param {boolean} val True to hide the handles, false to show.
1247N/A * @protected
1247N/A */
1247N/A _setHideHandlesUI: function(val) {
1247N/A var instance = this,
1247N/A wrapper = instance.get(WRAPPER);
1247N/A
1247N/A if (!instance.get(RESIZING)) {
1247N/A if (val) {
1247N/A wrapper.addClass(CSS_RESIZE_HIDDEN_HANDLES);
1247N/A }
1247N/A else {
1247N/A wrapper.removeClass(CSS_RESIZE_HIDDEN_HANDLES);
1247N/A }
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Setter for the wrap attribute
1247N/A *
1247N/A * @method _setWrap
1247N/A * @protected
1247N/A * @param {boolean} val
1247N/A */
1247N/A _setWrap: function(val) {
1247N/A var instance = this,
1247N/A node = instance.get(NODE),
1247N/A nodeName = node.get(NODE_NAME),
1247N/A typeRegex = instance.get(WRAP_TYPES);
1247N/A
1247N/A // if nodeName is listed on WRAP_TYPES force use the wrapper
1247N/A if (typeRegex.test(nodeName)) {
1247N/A val = true;
1247N/A }
1247N/A
1247N/A return val;
1247N/A },
1247N/A
1247N/A /**
1247N/A * Default resize:mouseUp handler
1247N/A *
1247N/A * @method _defMouseUpFn
1247N/A * @param {EventFacade} event The Event object
1247N/A * @protected
1247N/A */
1247N/A _defMouseUpFn: function(event) {
1247N/A var instance = this;
1247N/A
1247N/A instance.set(RESIZING, false);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Default resize:resize handler
1247N/A *
1247N/A * @method _defResizeFn
1247N/A * @param {EventFacade} event The Event object
1247N/A * @protected
1247N/A */
1247N/A _defResizeFn: function(event) {
1247N/A var instance = this;
1247N/A
1247N/A instance._handleResizeAlignEvent(event.dragEvent);
1247N/A
1247N/A // if proxy is true _syncProxyUI instead of _syncUI
1247N/A if (instance.get(PROXY)) {
1247N/A instance._syncProxyUI();
1247N/A }
1247N/A else {
1247N/A // _syncUI of the wrapper, not using proxy
1247N/A instance._syncUI();
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Default resize:align handler
1247N/A *
1247N/A * @method _defResizeAlignFn
1247N/A * @param {EventFacade} event The Event object
1247N/A * @protected
1247N/A */
1247N/A _defResizeAlignFn: function(event) {
1247N/A var instance = this, info;
1247N/A
1247N/A instance.lastInfo = instance.info;
1247N/A
1247N/A // update the instance.info values
1247N/A instance._updateInfo(event);
1247N/A
1247N/A info = instance.info;
1247N/A
1247N/A // basic resize calculations
1247N/A instance._resize();
1247N/A
1247N/A // if Y.Plugin.ResizeConstrained is not plugged, check for min dimension
1247N/A if (!instance.con) {
1247N/A var defMinHeight = instance.get(DEF_MIN_HEIGHT),
1247N/A defMinWidth = instance.get(DEF_MIN_WIDTH);
1247N/A
1247N/A if (info.offsetHeight <= defMinHeight) {
1247N/A instance._checkSize(OFFSET_HEIGHT, defMinHeight);
1247N/A }
1247N/A
1247N/A if (info.offsetWidth <= defMinWidth) {
1247N/A instance._checkSize(OFFSET_WIDTH, defMinWidth);
1247N/A }
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Default resize:end handler
1247N/A *
1247N/A * @method _defResizeEndFn
1247N/A * @param {EventFacade} event The Event object
1247N/A * @protected
1247N/A */
1247N/A _defResizeEndFn: function(event) {
1247N/A var instance = this,
1247N/A drag = event.dragEvent.target;
1247N/A
1247N/A // reseting actXY from drag when drag end
1247N/A drag.actXY = [];
1247N/A
1247N/A // if proxy is true, hide it on resize end
1247N/A if (instance.get(PROXY)) {
1247N/A instance._syncProxyUI();
1247N/A
1247N/A instance.get(PROXY_NODE).hide();
1247N/A }
1247N/A
1247N/A // syncUI when resize end
1247N/A instance._syncUI();
1247N/A
1247N/A instance.set(ACTIVE_HANDLE, null);
1247N/A instance.set(ACTIVE_HANDLE_NODE, null);
1247N/A
1247N/A instance._setActiveHandlesUI(false);
1247N/A },
1247N/A
1247N/A /**
1247N/A * Default resize:start handler
1247N/A *
1247N/A * @method _defResizeStartFn
1247N/A * @param {EventFacade} event The Event object
1247N/A * @protected
1247N/A */
1247N/A _defResizeStartFn: function(event) {
1247N/A var instance = this;
1247N/A
1247N/A instance.set(RESIZING, true);
1247N/A
1247N/A // create an originalInfo information for reference
1247N/A instance.originalInfo = instance._getInfo(instance.get(WRAPPER), event);
1247N/A
1247N/A instance._updateInfo(event);
1247N/A
1247N/A if (instance.get(PROXY)) {
1247N/A instance._renderProxy();
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Fires the resize:mouseUp event.
1247N/A *
1247N/A * @method _handleMouseUpEvent
1247N/A * @param {EventFacade} event resize:mouseUp event facade
1247N/A * @protected
1247N/A */
1247N/A _handleMouseUpEvent: function(event) {
1247N/A this.fire(EV_MOUSE_UP, { dragEvent: event, info: this.info });
1247N/A },
1247N/A
1247N/A /**
1247N/A * Fires the resize:resize event.
1247N/A *
1247N/A * @method _handleResizeEvent
1247N/A * @param {EventFacade} event resize:resize event facade
1247N/A * @protected
1247N/A */
1247N/A _handleResizeEvent: function(event) {
1247N/A this.fire(EV_RESIZE, { dragEvent: event, info: this.info });
1247N/A },
1247N/A
1247N/A /**
1247N/A * Fires the resize:align event.
1247N/A *
1247N/A * @method _handleResizeAlignEvent
1247N/A * @param {EventFacade} event resize:resize event facade
1247N/A * @protected
1247N/A */
1247N/A _handleResizeAlignEvent: function(event) {
1247N/A this.fire(EV_RESIZE_ALIGN, { dragEvent: event, info: this.info });
1247N/A },
1247N/A
1247N/A /**
1247N/A * Fires the resize:end event.
1247N/A *
1247N/A * @method _handleResizeEndEvent
1247N/A * @param {EventFacade} event resize:end event facade
1247N/A * @protected
1247N/A */
1247N/A _handleResizeEndEvent: function(event) {
1247N/A this.fire(EV_RESIZE_END, { dragEvent: event, info: this.info });
1247N/A },
1247N/A
1247N/A /**
1247N/A * Fires the resize:start event.
1247N/A *
1247N/A * @method _handleResizeStartEvent
1247N/A * @param {EventFacade} event resize:start event facade
1247N/A * @protected
1247N/A */
1247N/A _handleResizeStartEvent: function(event) {
1247N/A this.fire(EV_RESIZE_START, { dragEvent: event, info: this.info });
1247N/A },
1247N/A
1247N/A /**
1247N/A * Mouseenter event handler for the <a href="Resize.html#config_wrapper">wrapper</a>.
1247N/A *
1247N/A * @method _onWrapperMouseEnter
1247N/A * @param {EventFacade} event
1247N/A * @protected
1247N/A */
1247N/A _onWrapperMouseEnter: function(event) {
1247N/A var instance = this;
1247N/A
1247N/A if (instance.get(AUTO_HIDE)) {
1247N/A instance._setHideHandlesUI(false);
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Mouseleave event handler for the <a href="Resize.html#config_wrapper">wrapper</a>.
1247N/A *
1247N/A * @method _onWrapperMouseLeave
1247N/A * @param {EventFacade} event
1247N/A * @protected
1247N/A */
1247N/A _onWrapperMouseLeave: function(event) {
1247N/A var instance = this;
1247N/A
1247N/A if (instance.get(AUTO_HIDE)) {
1247N/A instance._setHideHandlesUI(true);
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Mouseover event handler for the handles.
1247N/A *
1247N/A * @method _onHandleMouseEnter
1247N/A * @param {EventFacade} event
1247N/A * @protected
1247N/A */
1247N/A _onHandleMouseEnter: function(event) {
1247N/A var instance = this,
1247N/A node = event.currentTarget,
1247N/A handle = instance._extractHandleName(node);
1247N/A
1247N/A if (!instance.get(RESIZING)) {
1247N/A instance.set(ACTIVE_HANDLE, handle);
1247N/A instance.set(ACTIVE_HANDLE_NODE, node);
1247N/A
1247N/A instance._setActiveHandlesUI(true);
1247N/A instance._updateChangeHandleInfo(handle);
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Mouseout event handler for the handles.
1247N/A *
1247N/A * @method _onHandleMouseLeave
1247N/A * @param {EventFacade} event
1247N/A * @protected
1247N/A */
1247N/A _onHandleMouseLeave: function(event) {
1247N/A var instance = this;
1247N/A
1247N/A if (!instance.get(RESIZING)) {
1247N/A instance._setActiveHandlesUI(false);
1247N/A }
1247N/A },
1247N/A
1247N/A /**
1247N/A * Default value for the wrapper attribute
1247N/A *
1247N/A * @method _valueWrapper
1247N/A * @protected
1247N/A * @readOnly
1247N/A */
1247N/A _valueWrapper: function() {
1247N/A var instance = this,
1247N/A node = instance.get(NODE),
1247N/A pNode = node.get(PARENT_NODE),
1247N/A // by deafult the wrapper is always the node
1247N/A wrapper = node;
1247N/A
1247N/A // if the node is listed on the wrapTypes or wrap is set to true, create another wrapper
1247N/A if (instance.get(WRAP)) {
1247N/A wrapper = Y.Node.create(instance.WRAP_TEMPLATE);
1247N/A
1247N/A if (pNode) {
1247N/A pNode.insertBefore(wrapper, node);
1247N/A }
1247N/A
1247N/A wrapper.append(node);
1247N/A
1247N/A instance._copyStyles(node, wrapper);
1247N/A
1247N/A // remove positioning of wrapped node, the WRAPPER take care about positioning
1247N/A node.setStyles({
1247N/A position: STATIC,
1247N/A left: 0,
1247N/A top: 0
1247N/A });
1247N/A }
1247N/A
1247N/A return wrapper;
1247N/A }
1247N/A }
1247N/A);
1247N/A
1247N/AY.each(Y.Resize.prototype.ALL_HANDLES, function(handle, i) {
1247N/A // creating ATTRS with the handles elements
1247N/A Y.Resize.ATTRS[handleAttrName(handle)] = {
1247N/A setter: function() {
1247N/A return this._buildHandle(handle);
1247N/A },
1247N/A value: null,
1247N/A writeOnce: true
1247N/A };
1247N/A});
1247N/A
1247N/A
1247N/A}, '@VERSION@' ,{skinnable:true, requires:['base', 'widget', 'substitute', 'event', 'oop', 'dd-drag', 'dd-delegate', 'dd-drop']});
1247N/A