2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('resize-proxy', function (Y, NAME) {
10 var ACTIVE_HANDLE_NODE = 'activeHandleNode',
12 DRAG_CURSOR = 'dragCursor',
14 PARENT_NODE = 'parentNode',
16 PROXY_NODE = 'proxyNode',
18 RESIZE_PROXY = 'resize-proxy',
21 getCN = Y.ClassNameManager.getClassName,
23 CSS_RESIZE_PROXY = getCN(RESIZE, PROXY);
27 Adds a `proxyNode` attribute and resizes it instead of the actual node. __very similar to DDProxy__
29 var resize = new Y.Resize({
30 //Selector of the node to resize
33 resize.plug(Y.Plugin.ResizeProxy);
38 @submodule resize-proxy
45 function ResizeProxy() {
46 ResizeProxy.superclass.constructor.apply(this, arguments);
56 * The Resize proxy element.
58 * @attribute proxyNode
59 * @default Generated using an internal HTML markup
65 return Y.Node.create(this.PROXY_TEMPLATE);
71 Y.extend(ResizeProxy, Y.Plugin.Base, {
73 * Template used to create the resize proxy.
75 * @property PROXY_TEMPLATE
78 PROXY_TEMPLATE: '<div class="'+CSS_RESIZE_PROXY+'"></div>',
80 initializer: function() {
83 instance.afterHostEvent('resize:start', instance._afterResizeStart);
84 instance.beforeHostMethod('_resize', instance._beforeHostResize);
85 instance.afterHostMethod('_resizeEnd', instance._afterHostResizeEnd);
88 destructor: function() {
91 instance.get(PROXY_NODE).remove(true);
94 _afterHostResizeEnd: function(event) {
96 drag = event.dragEvent.target;
98 // reseting actXY from drag when drag end
101 // if proxy is true, hide it on resize end
102 instance._syncProxyUI();
104 instance.get(PROXY_NODE).hide();
107 _afterResizeStart: function() {
110 instance._renderProxy();
113 _beforeHostResize: function(event) {
115 host = this.get(HOST);
117 host._handleResizeAlignEvent(event.dragEvent);
119 // if proxy is true _syncProxyUI instead of _syncUI
120 instance._syncProxyUI();
122 return new Y.Do.Prevent();
126 * Render the <a href="ResizeProxy.html#attr_proxyNode">proxyNode</a> element and
127 * make it sibling of the <a href="Resize.html#attr_node">node</a>.
129 * @method _renderProxy
132 _renderProxy: function() {
134 host = this.get(HOST),
135 proxyNode = instance.get(PROXY_NODE);
137 if (!proxyNode.inDoc()) {
138 host.get(WRAPPER).get(PARENT_NODE).append(
145 * Sync the proxy UI with internal values from
146 * <a href="ResizeProxy.html#property_info">info</a>.
148 * @method _syncProxyUI
151 _syncProxyUI: function() {
153 host = this.get(HOST),
155 activeHandleNode = host.get(ACTIVE_HANDLE_NODE),
156 proxyNode = instance.get(PROXY_NODE),
157 cursor = activeHandleNode.getStyle(CURSOR);
159 proxyNode.show().setStyle(CURSOR, cursor);
161 host.delegate.dd.set(DRAG_CURSOR, cursor);
163 proxyNode.sizeTo(info.offsetWidth, info.offsetHeight);
165 proxyNode.setXY([ info.left, info.top ]);
169 Y.namespace('Plugin');
170 Y.Plugin.ResizeProxy = ResizeProxy;
173 }, '3.13.0', {"requires": ["plugin", "resize-base"]});