2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
Code licensed under the BSD License:
4
http://developer.yahoo.com/yui/license.html
8
YUI.add('resize-proxy', function(Y) {
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);
25
function ResizeProxy() {
26
ResizeProxy.superclass.constructor.apply(this, arguments);
36
* The Resize proxy element.
38
* @attribute proxyNode
39
* @default Generated using an internal HTML markup
45
return Y.Node.create(this.PROXY_TEMPLATE);
51
Y.extend(ResizeProxy, Y.Plugin.Base, {
53
* Template used to create the resize proxy.
55
* @property PROXY_TEMPLATE
58
PROXY_TEMPLATE: '<div class="'+CSS_RESIZE_PROXY+'"></div>',
60
initializer: function() {
63
instance.afterHostEvent('resize:start', instance._afterResizeStart);
64
instance.beforeHostMethod('_resize', instance._beforeHostResize);
65
instance.afterHostMethod('_resizeEnd', instance._afterHostResizeEnd);
68
destructor: function() {
71
instance.get(PROXY_NODE).remove(true);
74
_afterHostResizeEnd: function(event) {
76
drag = event.dragEvent.target;
78
// reseting actXY from drag when drag end
81
// if proxy is true, hide it on resize end
82
instance._syncProxyUI();
84
instance.get(PROXY_NODE).hide();
87
_afterResizeStart: function(event) {
90
instance._renderProxy();
93
_beforeHostResize: function(event) {
95
host = this.get(HOST);
97
host._handleResizeAlignEvent(event.dragEvent);
99
// if proxy is true _syncProxyUI instead of _syncUI
100
instance._syncProxyUI();
102
return new Y.Do.Prevent();
106
* Render the <a href="ResizeProxy.html#config_proxyNode">proxyNode</a> element and
107
* make it sibling of the <a href="Resize.html#config_node">node</a>.
109
* @method _renderProxy
112
_renderProxy: function() {
114
host = this.get(HOST),
115
proxyNode = instance.get(PROXY_NODE);
117
if (!proxyNode.inDoc()) {
118
host.get(WRAPPER).get(PARENT_NODE).append(
125
* Sync the proxy UI with internal values from
126
* <a href="ResizeProxy.html#property_info">info</a>.
128
* @method _syncProxyUI
131
_syncProxyUI: function() {
133
host = this.get(HOST),
135
activeHandleNode = host.get(ACTIVE_HANDLE_NODE),
136
proxyNode = instance.get(PROXY_NODE),
137
cursor = activeHandleNode.getStyle(CURSOR);
139
proxyNode.show().setStyle(CURSOR, cursor);
141
host.delegate.dd.set(DRAG_CURSOR, cursor);
143
proxyNode.sizeTo(info.offsetWidth, info.offsetHeight);
145
proxyNode.setXY([ info.left, info.top ]);
149
Y.namespace('Plugin');
150
Y.Plugin.ResizeProxy = ResizeProxy;
153
}, '3.3.0' ,{requires:['resize-base', 'plugin'], skinnable:false});