resize-debug.js revision 10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85
/**
* The Resize Utility allows you to make an HTML element resizable.
* @module resize
* @main resize
*/
YArray = Y.Array,
COMMA = ',',
DOT = '.',
EMPTY_STR = '',
HANDLE_SUB = '{handle}',
SPACE = ' ',
ACTIVE = 'active',
ACTIVE_HANDLE = 'activeHandle',
ACTIVE_HANDLE_NODE = 'activeHandleNode',
ALL = 'all',
AUTO_HIDE = 'autoHide',
BORDER = 'border',
BOTTOM = 'bottom',
CLASS_NAME = 'className',
COLOR = 'color',
DEF_MIN_HEIGHT = 'defMinHeight',
DEF_MIN_WIDTH = 'defMinWidth',
HANDLE = 'handle',
HANDLES = 'handles',
HANDLES_WRAPPER = 'handlesWrapper',
HIDDEN = 'hidden',
INNER = 'inner',
LEFT = 'left',
MARGIN = 'margin',
NODE = 'node',
NODE_NAME = 'nodeName',
NONE = 'none',
OFFSET_HEIGHT = 'offsetHeight',
OFFSET_WIDTH = 'offsetWidth',
PADDING = 'padding',
PARENT_NODE = 'parentNode',
POSITION = 'position',
RELATIVE = 'relative',
RESIZE = 'resize',
RESIZING = 'resizing',
RIGHT = 'right',
STATIC = 'static',
STYLE = 'style',
TOP = 'top',
WIDTH = 'width',
WRAP = 'wrap',
WRAPPER = 'wrapper',
WRAP_TYPES = 'wrapTypes',
EV_MOUSE_UP = 'resize:mouseUp',
EV_RESIZE = 'resize:resize',
EV_RESIZE_ALIGN = 'resize:align',
EV_RESIZE_END = 'resize:end',
EV_RESIZE_START = 'resize:start',
T = 't',
TR = 'tr',
R = 'r',
BR = 'br',
B = 'b',
BL = 'bl',
L = 'l',
TL = 'tl',
concat = function() {
},
// round the passed number to get rid of pixel-flickering
toRoundNumber = function(num) {
},
},
handleAttrName = function(handle) {
},
isNode = function(v) {
return (v instanceof Y.Node);
},
toInitialCap = Y.cached(
function(str) {
}
),
capitalize = Y.cached(function() {
var out = [],
if (i > 0) {
}
});
}),
/**
A base class for Resize, providing:
* Basic Lifecycle (initializer, renderUI, bindUI, syncUI, destructor)
* Applies drag handles to an element to make it resizable
* Here is the list of valid resize handles:
`[ 't', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl' ]`. You can
read this list as top, top-right, right, bottom-right, bottom,
bottom-left, left, top-left.
* The drag handles are inserted into the element and positioned
absolute. Some elements, such as a textarea or image, don't support
children. To overcome that, set wrap:true in your config and the
element willbe wrapped for you automatically.
Quick Example:
var instance = new Y.Resize({
node: '#resize1',
preserveRatio: true,
wrap: true,
maxHeight: 170,
maxWidth: 400,
handles: 't, tr, r, br, b, bl, l, tl'
});
Check the list of <a href="Resize.html#configattributes">Configuration Attributes</a> available for
Resize.
@class Resize
@param config {Object} Object literal specifying widget configuration properties.
@constructor
@extends Base
*/
function Resize() {
}
/**
* Static property provides a string to identify the class.
*
* @property NAME
* @type String
* @static
*/
/**
* Static property used to define the default attribute
* configuration for the Resize.
*
* @property ATTRS
* @type Object
* @static
*/
ATTRS: {
/**
* Stores the active handle during the resize.
*
* @attribute activeHandle
* @default null
* @private
* @type String
*/
activeHandle: {
value: null,
validator: function(v) {
}
},
/**
* Stores the active handle element during the resize.
*
* @attribute activeHandleNode
* @default null
* @private
* @type Node
*/
value: null,
},
/**
* False to ensure that the resize handles are always visible, true to
* display them only when the user mouses over the resizable borders.
*
* @attribute autoHide
* @default false
* @type boolean
*/
autoHide: {
value: false,
},
/**
* The default minimum height of the element. Only used when
* ResizeConstrained is not plugged.
*
* @attribute defMinHeight
* @default 15
* @type Number
*/
defMinHeight: {
value: 15,
},
/**
* The default minimum width of the element. Only used when
* ResizeConstrained is not plugged.
*
* @attribute defMinWidth
* @default 15
* @type Number
*/
defMinWidth: {
value: 15,
},
/**
* The handles to use (any combination of): 't', 'b', 'r', 'l', 'bl',
* 'br', 'tl', 'tr'. Can use a shortcut of All.
*
* @attribute handles
* @default all
* @type Array | String
*/
handles: {
setter: '_setHandles',
},
/**
* Node to wrap the resize handles.
*
* @attribute handlesWrapper
* @type Node
*/
readOnly: true,
valueFn: '_valueHandlesWrapper'
},
/**
* The selector or element to resize. Required.
*
* @attribute node
* @type Node
*/
node: {
},
/**
* True when the element is being Resized.
*
* @attribute resizing
* @default false
* @type boolean
*/
resizing: {
value: false,
},
/**
* True to wrap an element with a div if needed (required for textareas
* and images, defaults to false) in favor of the handles config option.
* The wrapper element type (default div) could be over-riden passing the
* <code>wrapper</code> attribute.
*
* @attribute wrap
* @default false
* @type boolean
*/
wrap: {
setter: '_setWrap',
value: false,
},
/**
* Elements that requires a wrapper by default. Normally are elements
* which cannot have children elements.
*
* @attribute wrapTypes
* @default /canvas|textarea|input|select|button|img/i
* @readOnly
* @type Regex
*/
wrapTypes: {
readOnly: true,
},
/**
* Element to wrap the <code>wrapTypes</code>. This element will house
* the handles elements.
*
* @attribute wrapper
* @default div
* @type String | Node
* @writeOnce
*/
wrapper: {
readOnly: true,
valueFn: '_valueWrapper',
writeOnce: true
}
},
RULES: {
},
},
},
},
},
},
},
}
},
});
Y.Base,
{
/**
* Array containing all possible resizable handles.
*
* @property ALL_HANDLES
* @type {String}
*/
/**
* Regex which matches with the handles that could change the height of
* the resizable element.
*
* @property REGEX_CHANGE_HEIGHT
* @type {String}
*/
/**
* Regex which matches with the handles that could change the left of
* the resizable element.
*
* @property REGEX_CHANGE_LEFT
* @type {String}
*/
/**
* Regex which matches with the handles that could change the top of
* the resizable element.
*
* @property REGEX_CHANGE_TOP
* @type {String}
*/
/**
* Regex which matches with the handles that could change the width of
* the resizable element.
*
* @property REGEX_CHANGE_WIDTH
* @type {String}
*/
/**
* Template used to create the resize wrapper for the handles.
*
* @property HANDLES_WRAP_TEMPLATE
* @type {String}
*/
/**
* Template used to create the resize wrapper node when needed.
*
* @property WRAP_TEMPLATE
* @type {String}
*/
/**
* Template used to create each resize handle.
*
* @property HANDLE_TEMPLATE
* @type {String}
*/
'<div class="'+concat(CSS_RESIZE_HANDLE_INNER, CSS_RESIZE_HANDLE_INNER_PLACEHOLDER)+'"> </div>' +
'</div>',
/**
* Each box has a content area and optional surrounding padding and
* border areas. This property stores the sum of all horizontal
* surrounding * information needed to adjust the node height.
*
* @property totalHSurrounding
* @default 0
* @type number
*/
/**
* Each box has a content area and optional surrounding padding and
* border areas. This property stores the sum of all vertical
* surrounding * information needed to adjust the node height.
*
* @property totalVSurrounding
* @default 0
* @type number
*/
/**
* Stores the <a href="Resize.html#config_node">node</a>
* surrounding information retrieved from
* <a href="Resize.html#method__getBoxSurroundingInfo">_getBoxSurroundingInfo</a>.
*
* @property nodeSurrounding
* @type Object
* @default null
*/
nodeSurrounding: null,
/**
* Stores the <a href="Resize.html#config_wrapper">wrapper</a>
* surrounding information retrieved from
* <a href="Resize.html#method__getBoxSurroundingInfo">_getBoxSurroundingInfo</a>.
*
* @property wrapperSurrounding
* @type Object
* @default null
*/
wrapperSurrounding: null,
/**
* Whether the handle being dragged can change the height.
*
* @property changeHeightHandles
* @default false
* @type boolean
*/
changeHeightHandles: false,
/**
* Whether the handle being dragged can change the left.
*
* @property changeLeftHandles
* @default false
* @type boolean
*/
changeLeftHandles: false,
/**
* Whether the handle being dragged can change the top.
*
* @property changeTopHandles
* @default false
* @type boolean
*/
changeTopHandles: false,
/**
* Whether the handle being dragged can change the width.
*
* @property changeWidthHandles
* @default false
* @type boolean
*/
changeWidthHandles: false,
/**
* Store DD.Delegate reference for the respective Resize instance.
*
* @property delegate
* @default null
* @type Object
*/
delegate: null,
/**
* Stores the current values for the height, width, top and left. You are
* able to manipulate these values on resize in order to change the resize
* behavior.
*
* @property info
* @type Object
* @protected
*/
info: null,
/**
* Stores the last values for the height, width, top and left.
*
* @property lastInfo
* @type Object
* @protected
*/
lastInfo: null,
/**
* Stores the original values for the height, width, top and left, stored
* on resize start.
*
* @property originalInfo
* @type Object
* @protected
*/
originalInfo: null,
/**
* Construction logic executed during Resize instantiation. Lifecycle.
*
* @method initializer
* @protected
*/
initializer: function() {
this.renderer();
},
/**
* Create the DOM structure for the Resize. Lifecycle.
*
* @method renderUI
* @protected
*/
renderUI: function() {
var instance = this;
},
/**
* Bind the events on the Resize UI. Lifecycle.
*
* @method bindUI
* @protected
*/
bindUI: function() {
var instance = this;
},
/**
* Sync the Resize UI.
*
* @method syncUI
* @protected
*/
syncUI: function() {
var instance = this;
// hide handles if AUTO_HIDE is true
);
},
/**
* Descructor lifecycle implementation for the Resize class. Purges events attached
* to the node (and all child nodes) and removes the Resize handles.
*
* @method destructor
* @protected
*/
destructor: function() {
var instance = this,
// purgeElements on boundingBox
// destroy handles dd and remove them from the dom
// remove handle
});
// unwrap node
if (pNode) {
}
}
},
/**
* Creates DOM (or manipulates DOM for progressive enhancement)
* This method is invoked by initializer(). It's chained automatically for
* subclasses if required.
*
* @method renderer
* @protected
*/
renderer: function() {
this.renderUI();
this.bindUI();
this.syncUI();
},
/**
* <p>Loop through each handle which is being used and executes a callback.</p>
* <p>Example:</p>
* <pre><code>instance.eachHandle(
* function(handleName, index) { ... }
* );</code></pre>
*
* @method eachHandle
* @param {function} fn Callback function to be executed for each handle.
*/
eachHandle: function(fn) {
var instance = this;
Y.each(
function(handle, i) {
);
}
);
},
/**
* Bind the handles DragDrop events to the Resize instance.
*
* @method _bindDD
* @private
*/
_bindDD: function() {
var instance = this;
{
dragConfig: {
clickPixelThresh: 0,
clickTimeThresh: 0,
useShim: true,
move: false
},
target: false
}
);
},
/**
* Bind the events related to the handles (_onHandleMouseEnter, _onHandleMouseLeave).
*
* @method _bindHandle
* @private
*/
_bindHandle: function() {
var instance = this,
wrapper.delegate('mouseenter', Y.bind(instance._onHandleMouseEnter, instance), DOT+CSS_RESIZE_HANDLE);
wrapper.delegate('mouseleave', Y.bind(instance._onHandleMouseLeave, instance), DOT+CSS_RESIZE_HANDLE);
},
/**
* Create the custom events used on the Resize.
*
* @method _createEvents
* @private
*/
_createEvents: function() {
var instance = this,
// create publish function for kweight optimization
queuable: false,
emitFacade: true,
bubbles: true,
});
};
/**
* Handles the resize start event. Fired when a handle starts to be
* dragged.
*
* @event resize:start
* @preventable _defResizeStartFn
* @param {Event.Facade} event The resize start event.
* @bubbles Resize
* @type {Event.Custom}
*/
/**
* Handles the resize event. Fired on each pixel when the handle is
* being dragged.
*
* @event resize:resize
* @preventable _defResizeFn
* @param {Event.Facade} event The resize event.
* @bubbles Resize
* @type {Event.Custom}
*/
/**
* Handles the resize align event.
*
* @event resize:align
* @preventable _defResizeAlignFn
* @param {Event.Facade} event The resize align event.
* @bubbles Resize
* @type {Event.Custom}
*/
/**
* Handles the resize end event. Fired when a handle stop to be
* dragged.
*
* @event resize:end
* @preventable _defResizeEndFn
* @param {Event.Facade} event The resize end event.
* @bubbles Resize
* @type {Event.Custom}
*/
/**
* Handles the resize mouseUp event. Fired when a mouseUp event happens on a
* handle.
*
* @event resize:mouseUp
* @preventable _defMouseUpFn
* @param {Event.Facade} event The resize mouseUp event.
* @bubbles Resize
* @type {Event.Custom}
*/
},
/**
* Responsible for loop each handle element and append to the wrapper.
*
* @method _renderHandles
* @protected
*/
_renderHandles: function() {
var instance = this,
});
},
/**
* Creates the handle element based on the handle name and initialize the
* DragDrop on it.
*
* @method _buildHandle
* @param {String} handle Handle name ('t', 'tr', 'b', ...).
* @protected
*/
_buildHandle: function(handle) {
var instance = this;
})
);
},
/**
* Basic resize calculations.
*
* @method _calcResize
* @protected
*/
_calcResize: function() {
var instance = this,
}
else {
}
},
/**
* Helper method to update the current size value on
* <a href="Resize.html#property_info">info</a> to respect the
*
* @method _checkSize
* @param {String} offset 'offsetHeight' or 'offsetWidth'
* @param {number} size Size to restrict the offset
* @protected
*/
var instance = this,
// forcing the offsetHeight/offsetWidth to be the passed size
// predicting, based on the original information, the last left valid in case of reach the min/max dimension
// this calculation avoid browser event leaks when user interact very fast
}
},
/**
* Copy relevant styles of the <a href="Resize.html#config_node">node</a>
* to the <a href="Resize.html#config_wrapper">wrapper</a>.
*
* @method _copyStyles
* @param {Node} node Node from.
* @param {Node} wrapper Node to.
* @protected
*/
// resizable wrapper should be positioned
}
wrapperStyle = {
};
// remove margin and border from the internal node
);
},
// extract handle name from a string
// using Y.cached to memoize the function for performance
function(node) {
new RegExp(
)
);
}
),
/**
* <p>Generates metadata to the <a href="Resize.html#property_info">info</a>
* and <a href="Resize.html#property_originalInfo">originalInfo</a></p>
* <pre><code>bottom, actXY, left, top, offsetHeight, offsetWidth, right</code></pre>
*
* @method _getInfo
* @param {Node} node
* @param {EventFacade} event
* @private
*/
if (event) {
// the xy that the node will be set to. Changing this will alter the position as it's dragged.
}
return {
};
},
/**
* Each box has a content area and optional surrounding margin,
* padding and * border areas. This method get all this information from
* the passed node. For more reference see
* <a href="http://www.w3.org/TR/CSS21/box.html#box-dimensions">
* http://www.w3.org/TR/CSS21/box.html#box-dimensions</a>.
*
* @method _getBoxSurroundingInfo
* @param {Node} node
* @private
* @return {Object}
*/
_getBoxSurroundingInfo: function(node) {
var info = {
padding: {},
margin: {},
border: {}
};
});
}
info.totalHBorder = (toRoundNumber(info.border.borderLeftWidth) + toRoundNumber(info.border.borderRightWidth));
info.totalHPadding = (toRoundNumber(info.padding.paddingLeft) + toRoundNumber(info.padding.paddingRight));
info.totalVBorder = (toRoundNumber(info.border.borderBottomWidth) + toRoundNumber(info.border.borderTopWidth));
info.totalVPadding = (toRoundNumber(info.padding.paddingBottom) + toRoundNumber(info.padding.paddingTop));
return info;
},
/**
* Sync the Resize UI with internal values from
* <a href="Resize.html#property_info">info</a>.
*
* @method _syncUI
* @protected
*/
_syncUI: function() {
var instance = this,
}
// if a wrap node is being used
// the original internal node borders were copied to the wrapper on _copyStyles, to compensate that subtract the borders from the internal node
);
}
// prevent webkit textarea resize
}
},
/**
* Update <code>instance.changeHeightHandles,
* instance.changeLeftHandles, instance.changeTopHandles,
* instance.changeWidthHandles</code> information.
*
* @method _updateChangeHandleInfo
* @private
*/
_updateChangeHandleInfo: function(handle) {
var instance = this;
},
/**
* Update <a href="Resize.html#property_info">info</a> values (bottom, actXY, left, top, offsetHeight, offsetWidth, right).
*
* @method _updateInfo
* @private
*/
_updateInfo: function(event) {
var instance = this;
},
/**
* Update properties
* <a href="Resize.html#property_nodeSurrounding">nodeSurrounding</a>,
* <a href="Resize.html#property_nodeSurrounding">wrapperSurrounding</a>,
* <a href="Resize.html#property_nodeSurrounding">totalVSurrounding</a>,
* <a href="Resize.html#property_nodeSurrounding">totalHSurrounding</a>.
*
* @method _updateSurroundingInfo
* @private
*/
_updateSurroundingInfo: function() {
var instance = this,
},
/**
* Set the active state of the handles.
*
* @method _setActiveHandlesUI
* @param {boolean} val True to activate the handles, false to deactivate.
* @protected
*/
_setActiveHandlesUI: function(val) {
var instance = this,
if (activeHandleNode) {
if (val) {
// remove CSS_RESIZE_HANDLE_ACTIVE from all handles before addClass on the active
function(handleEl) {
}
);
}
else {
}
}
},
/**
* Setter for the handles attribute
*
* @method _setHandles
* @protected
* @param {String} val
*/
_setHandles: function(val) {
var instance = this,
handles = [];
// handles attr accepts both array or string
}
// if the handles attr passed in is an ALL string...
}
// otherwise, split the string to extract the handles
else {
Y.each(
function(node, i) {
// if its a valid handle, add it to the handles output
}
}
);
}
}
return handles;
},
/**
* Set the visibility of the handles.
*
* @method _setHideHandlesUI
* @param {boolean} val True to hide the handles, false to show.
* @protected
*/
_setHideHandlesUI: function(val) {
var instance = this,
if (val) {
}
else {
}
}
},
/**
* Setter for the wrap attribute
*
* @method _setWrap
* @protected
* @param {boolean} val
*/
var instance = this,
// if nodeName is listed on WRAP_TYPES force use the wrapper
val = true;
}
return val;
},
/**
* Default resize:mouseUp handler
*
* @method _defMouseUpFn
* @param {EventFacade} event The Event object
* @protected
*/
_defMouseUpFn: function(event) {
var instance = this;
},
/**
* Default resize:resize handler
*
* @method _defResizeFn
* @param {EventFacade} event The Event object
* @protected
*/
_defResizeFn: function(event) {
var instance = this;
},
/**
* Logic method for _defResizeFn. Allow AOP.
*
* @method _resize
* @param {EventFacade} event The Event object
* @protected
*/
var instance = this;
// _syncUI of the wrapper, not using proxy
},
/**
* Default resize:align handler
*
* @method _defResizeAlignFn
* @param {EventFacade} event The Event object
* @protected
*/
_defResizeAlignFn: function(event) {
var instance = this;
},
/**
* Logic method for _defResizeAlignFn. Allow AOP.
*
* @method _resizeAlign
* @param {EventFacade} event The Event object
* @protected
*/
_resizeAlign: function(event) {
var instance = this,
info,
// update the instance.info values
// basic resize calculations
// if Y.Plugin.ResizeConstrained is not plugged, check for min dimension
}
}
}
},
/**
* Default resize:end handler
*
* @method _defResizeEndFn
* @param {EventFacade} event The Event object
* @protected
*/
_defResizeEndFn: function(event) {
var instance = this;
},
/**
* Logic method for _defResizeEndFn. Allow AOP.
*
* @method _resizeEnd
* @param {EventFacade} event The Event object
* @protected
*/
_resizeEnd: function(event) {
var instance = this,
// reseting actXY from drag when drag end
// syncUI when resize end
instance._setActiveHandlesUI(false);
},
/**
* Default resize:start handler
*
* @method _defResizeStartFn
* @param {EventFacade} event The Event object
* @protected
*/
_defResizeStartFn: function(event) {
var instance = this;
},
/**
* Logic method for _defResizeStartFn. Allow AOP.
*
* @method _resizeStart
* @param {EventFacade} event The Event object
* @protected
*/
_resizeStart: function(event) {
var instance = this,
// create an originalInfo information for reference
},
/**
* Fires the resize:mouseUp event.
*
* @method _handleMouseUpEvent
* @param {EventFacade} event resize:mouseUp event facade
* @protected
*/
_handleMouseUpEvent: function(event) {
},
/**
* Fires the resize:resize event.
*
* @method _handleResizeEvent
* @param {EventFacade} event resize:resize event facade
* @protected
*/
_handleResizeEvent: function(event) {
},
/**
* Fires the resize:align event.
*
* @method _handleResizeAlignEvent
* @param {EventFacade} event resize:resize event facade
* @protected
*/
_handleResizeAlignEvent: function(event) {
},
/**
* Fires the resize:end event.
*
* @method _handleResizeEndEvent
* @param {EventFacade} event resize:end event facade
* @protected
*/
_handleResizeEndEvent: function(event) {
},
/**
* Fires the resize:start event.
*
* @method _handleResizeStartEvent
* @param {EventFacade} event resize:start event facade
* @protected
*/
_handleResizeStartEvent: function(event) {
if (!this.get(ACTIVE_HANDLE)) {
//This handles the "touch" case
}
},
/**
* Mouseenter event handler for the <a href="Resize.html#config_wrapper">wrapper</a>.
*
* @method _onWrapperMouseEnter
* @param {EventFacade} event
* @protected
*/
_onWrapperMouseEnter: function(event) {
var instance = this;
instance._setHideHandlesUI(false);
}
},
/**
* Mouseleave event handler for the <a href="Resize.html#config_wrapper">wrapper</a>.
*
* @method _onWrapperMouseLeave
* @param {EventFacade} event
* @protected
*/
_onWrapperMouseLeave: function(event) {
var instance = this;
instance._setHideHandlesUI(true);
}
},
/**
* Handles setting the activeHandle from a node, used from startDrag (for touch) and mouseenter (for mouse).
*
* @method _setHandleFromNode
* @param {Node} node
* @protected
*/
_setHandleFromNode: function(node) {
var instance = this,
instance._setActiveHandlesUI(true);
}
},
/**
* Mouseenter event handler for the handles.
*
* @method _onHandleMouseEnter
* @param {EventFacade} event
* @protected
*/
_onHandleMouseEnter: function(event) {
},
/**
* Mouseout event handler for the handles.
*
* @method _onHandleMouseLeave
* @param {EventFacade} event
* @protected
*/
_onHandleMouseLeave: function(event) {
var instance = this;
instance._setActiveHandlesUI(false);
}
},
/**
* Default value for the wrapper handles node attribute
*
* @method _valueHandlesWrapper
* @protected
* @readOnly
*/
_valueHandlesWrapper: function() {
},
/**
* Default value for the wrapper attribute
*
* @method _valueWrapper
* @protected
* @readOnly
*/
_valueWrapper: function() {
var instance = this,
// by deafult the wrapper is always the node
// if the node is listed on the wrapTypes or wrap is set to true, create another wrapper
if (pNode) {
}
// remove positioning of wrapped node, the WRAPPER take care about positioning
left: 0,
top: 0
});
}
return wrapper;
}
}
);
// creating ATTRS with the handles elements
setter: function() {
return this._buildHandle(handle);
},
value: null,
writeOnce: true
};
});
}, '@VERSION@' ,{requires:['base', 'widget', 'substitute', 'event', 'oop', 'dd-drag', 'dd-delegate', 'dd-drop'], skinnable:true});
var ACTIVE_HANDLE_NODE = 'activeHandleNode',
CURSOR = 'cursor',
DRAG_CURSOR = 'dragCursor',
HOST = 'host',
PARENT_NODE = 'parentNode',
PROXY = 'proxy',
PROXY_NODE = 'proxyNode',
RESIZE = 'resize',
RESIZE_PROXY = 'resize-proxy',
WRAPPER = 'wrapper',
/**
Adds a `proxyNode` attribute and resizes it instead of the actual node. __very similar to DDProxy__
var resize = new Y.Resize({
//Selector of the node to resize
node: '#demo'
});
resize.plug(Y.Plugin.ResizeProxy);
@class ResizeProxy
@module resize
@submodule resize-proxy
@constructor
@extends Plugin.Base
@namespace Plugin
*/
function ResizeProxy() {
}
Y.mix(ResizeProxy, {
ATTRS: {
/**
* The Resize proxy element.
*
* @attribute proxyNode
* @default Generated using an internal HTML markup
* @type String|Node
*/
proxyNode: {
valueFn: function() {
}
}
}
});
/**
* Template used to create the resize proxy.
*
* @property PROXY_TEMPLATE
* @type {String}
*/
initializer: function() {
var instance = this;
},
destructor: function() {
var instance = this;
},
_afterHostResizeEnd: function(event) {
var instance = this,
// reseting actXY from drag when drag end
// if proxy is true, hide it on resize end
},
_afterResizeStart: function(event) {
var instance = this;
},
_beforeHostResize: function(event) {
var instance = this,
// if proxy is true _syncProxyUI instead of _syncUI
},
/**
* Render the <a href="ResizeProxy.html#config_proxyNode">proxyNode</a> element and
* make it sibling of the <a href="Resize.html#config_node">node</a>.
*
* @method _renderProxy
* @protected
*/
_renderProxy: function() {
var instance = this,
);
}
},
/**
* Sync the proxy UI with internal values from
* <a href="ResizeProxy.html#property_info">info</a>.
*
* @method _syncProxyUI
* @protected
*/
_syncProxyUI: function() {
var instance = this,
}
});
Y.namespace('Plugin');
isNode = function(v) {
return (v instanceof Y.Node);
},
},
BORDER_BOTTOM_WIDTH = 'borderBottomWidth',
BORDER_LEFT_WIDTH = 'borderLeftWidth',
BORDER_RIGHT_WIDTH = 'borderRightWidth',
BORDER_TOP_WIDTH = 'borderTopWidth',
BORDER = 'border',
BOTTOM = 'bottom',
CON = 'con',
CONSTRAIN = 'constrain',
HOST = 'host',
LEFT = 'left',
MAX_HEIGHT = 'maxHeight',
MAX_WIDTH = 'maxWidth',
MIN_HEIGHT = 'minHeight',
MIN_WIDTH = 'minWidth',
NODE = 'node',
OFFSET_HEIGHT = 'offsetHeight',
OFFSET_WIDTH = 'offsetWidth',
PRESEVE_RATIO = 'preserveRatio',
REGION = 'region',
RESIZE_CONTRAINED = 'resizeConstrained',
RIGHT = 'right',
TICK_X = 'tickX',
TICK_Y = 'tickY',
TOP = 'top',
WIDTH = 'width',
VIEW = 'view',
VIEWPORT_REGION = 'viewportRegion';
/**
A Resize plugin that will attempt to constrain the resize node to the boundaries.
@module resize
@submodule resize-contrain
@class ResizeConstrained
@param config {Object} Object literal specifying widget configuration properties.
@constructor
@extends Plugin.Base
@namespace Plugin
*/
function ResizeConstrained() {
}
Y.mix(ResizeConstrained, {
ATTRS: {
/**
* Will attempt to constrain the resize node to the boundaries. Arguments:<br>
* 'view': Contrain to Viewport<br>
* '#selector_string': Constrain to this node<br>
* '{Region Object}': An Object Literal containing a valid region (top, right, bottom, left) of page positions
*
* @attribute constrain
* @type {String|Object|Node}
*/
constrain: {
setter: function(v) {
v = Y.one(v);
}
return v;
}
},
/**
* The minimum height of the element
*
* @attribute minHeight
* @default 15
* @type Number
*/
minHeight: {
value: 15,
},
/**
* The minimum width of the element
*
* @attribute minWidth
* @default 15
* @type Number
*/
minWidth: {
value: 15,
},
/**
* The maximum height of the element
*
* @attribute maxHeight
* @default Infinity
* @type Number
*/
maxHeight: {
},
/**
* The maximum width of the element
*
* @attribute maxWidth
* @default Infinity
* @type Number
*/
maxWidth: {
},
/**
* Maintain the element's ratio when resizing.
*
* @attribute preserveRatio
* @default false
* @type boolean
*/
value: false,
},
/**
* The number of x ticks to span the resize to.
*
* @attribute tickX
* @default false
* @type Number | false
*/
tickX: {
value: false
},
/**
* The number of y ticks to span the resize to.
*
* @attribute tickY
* @default false
* @type Number | false
*/
tickY: {
value: false
}
}
});
/**
* Stores the <code>constrain</code>
* surrounding information retrieved from
* <a href="Resize.html#method__getBoxSurroundingInfo">_getBoxSurroundingInfo</a>.
*
* @property constrainSurrounding
* @type Object
* @default null
*/
constrainSurrounding: null,
initializer: function() {
var instance = this,
{
}
);
},
/**
* Helper method to update the current values on
* <a href="Resize.html#property_info">info</a> to respect the
* constrain node.
*
* @method _checkConstrain
* @param {String} axis 'top' or 'left'
* @param {String} axisConstrain 'bottom' or 'right'
* @param {String} offset 'offsetHeight' or 'offsetWidth'
* @protected
*/
var instance = this,
if (region) {
point1Constrain = region[axisConstrain] - toNumber(constrainBorders[capitalize(BORDER, axisConstrain, WIDTH)]);
if (point1 >= point1Constrain) {
}
if (point2 <= point2Constrain) {
}
}
},
/**
* Update the current values on <a href="Resize.html#property_info">info</a>
* to respect the maxHeight and minHeight.
*
* @method _checkHeight
* @protected
*/
_checkHeight: function() {
var instance = this,
}
}
},
/**
* Update the current values on <a href="Resize.html#property_info">info</a>
* calculating the correct ratio for the other values.
*
* @method _checkRatio
* @protected
*/
_checkRatio: function() {
var instance = this,
// wRatio/hRatio functions keep the ratio information always synced with the current info information
wRatio = function() {
},
hRatio = function() {
},
// check whether the resizable node is closest to height or not
}
else if (host.changeLeftHandles) {
}
else if (host.changeTopHandles) {
}
else {
}
}
// when the height of the resizable element touch the border of the constrain first
// force the offsetWidth to be calculated based on the height ratio
if (isClosestToHeight) {
}
else {
}
// fixing the top on handles which are able to change top
// the idea here is change the top based on how much the height has changed instead of follow the dy
if (host.changeTopHandles) {
}
// fixing the left on handles which are able to change left
// the idea here is change the left based on how much the width has changed instead of follow the dx
if (host.changeLeftHandles) {
}
// rounding values to avoid pixel jumpings
}
});
},
/**
* Check whether the resizable node is inside the constrain region.
*
* @method _checkRegion
* @protected
* @return {boolean}
*/
_checkRegion: function() {
var instance = this,
},
/**
* Update the current values on <a href="Resize.html#property_info">info</a>
* to respect the maxWidth and minWidth.
*
* @method _checkWidth
* @protected
*/
_checkWidth: function() {
var instance = this,
}
}
},
/**
* Get the constrain region based on the <code>constrain</code>
* attribute.
*
* @method _getConstrainRegion
* @protected
* @return {Object Region}
*/
_getConstrainRegion: function() {
var instance = this,
region = null;
if (constrain) {
}
}
else {
}
}
return region;
},
_handleResizeAlignEvent: function(event) {
var instance = this,
// calculating the ratio, for proportionally resizing
}
}
},
_handleResizeStartEvent: function(event) {
var instance = this,
}
});
Y.namespace('Plugin');
YUI.add('resize', function(Y){}, '@VERSION@' ,{use:['resize-base', 'resize-proxy', 'resize-constrain']});