| 1 | 
           efrain | 
           1 | 
           YUI.add('resize-proxy', function (Y, NAME) {
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           var ACTIVE_HANDLE_NODE = 'activeHandleNode',
  | 
        
        
            | 
            | 
           4 | 
               CURSOR = 'cursor',
  | 
        
        
            | 
            | 
           5 | 
               DRAG_CURSOR = 'dragCursor',
  | 
        
        
            | 
            | 
           6 | 
               HOST = 'host',
  | 
        
        
            | 
            | 
           7 | 
               PARENT_NODE = 'parentNode',
  | 
        
        
            | 
            | 
           8 | 
               PROXY = 'proxy',
  | 
        
        
            | 
            | 
           9 | 
               PROXY_NODE = 'proxyNode',
  | 
        
        
            | 
            | 
           10 | 
               RESIZE = 'resize',
  | 
        
        
            | 
            | 
           11 | 
               RESIZE_PROXY = 'resize-proxy',
  | 
        
        
            | 
            | 
           12 | 
               WRAPPER = 'wrapper',
  | 
        
        
            | 
            | 
           13 | 
              | 
        
        
            | 
            | 
           14 | 
               getCN = Y.ClassNameManager.getClassName,
  | 
        
        
            | 
            | 
           15 | 
              | 
        
        
            | 
            | 
           16 | 
               CSS_RESIZE_PROXY = getCN(RESIZE, PROXY);
  | 
        
        
            | 
            | 
           17 | 
              | 
        
        
            | 
            | 
           18 | 
              | 
        
        
            | 
            | 
           19 | 
           /**
  | 
        
        
            | 
            | 
           20 | 
           Adds a `proxyNode` attribute and resizes it instead of the actual node. __very similar to DDProxy__
  | 
        
        
            | 
            | 
           21 | 
              | 
        
        
            | 
            | 
           22 | 
               var resize = new Y.Resize({
  | 
        
        
            | 
            | 
           23 | 
                   //Selector of the node to resize
  | 
        
        
            | 
            | 
           24 | 
                   node: '#demo'
  | 
        
        
            | 
            | 
           25 | 
               });
  | 
        
        
            | 
            | 
           26 | 
               resize.plug(Y.Plugin.ResizeProxy);
  | 
        
        
            | 
            | 
           27 | 
              | 
        
        
            | 
            | 
           28 | 
              | 
        
        
            | 
            | 
           29 | 
           @class ResizeProxy
  | 
        
        
            | 
            | 
           30 | 
           @module resize
  | 
        
        
            | 
            | 
           31 | 
           @submodule resize-proxy
  | 
        
        
            | 
            | 
           32 | 
           @constructor
  | 
        
        
            | 
            | 
           33 | 
           @extends Plugin.Base
  | 
        
        
            | 
            | 
           34 | 
           @namespace Plugin
  | 
        
        
            | 
            | 
           35 | 
           */
  | 
        
        
            | 
            | 
           36 | 
              | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
           function ResizeProxy() {
  | 
        
        
            | 
            | 
           39 | 
               ResizeProxy.superclass.constructor.apply(this, arguments);
  | 
        
        
            | 
            | 
           40 | 
           }
  | 
        
        
            | 
            | 
           41 | 
              | 
        
        
            | 
            | 
           42 | 
           Y.mix(ResizeProxy, {
  | 
        
        
            | 
            | 
           43 | 
               NAME: RESIZE_PROXY,
  | 
        
        
            | 
            | 
           44 | 
              | 
        
        
            | 
            | 
           45 | 
               NS: PROXY,
  | 
        
        
            | 
            | 
           46 | 
              | 
        
        
            | 
            | 
           47 | 
               ATTRS: {
  | 
        
        
            | 
            | 
           48 | 
                   /**
  | 
        
        
            | 
            | 
           49 | 
                    * The Resize proxy element.
  | 
        
        
            | 
            | 
           50 | 
                    *
  | 
        
        
            | 
            | 
           51 | 
                    * @attribute proxyNode
  | 
        
        
            | 
            | 
           52 | 
                    * @default Generated using an internal HTML markup
  | 
        
        
            | 
            | 
           53 | 
                    * @type String|Node
  | 
        
        
            | 
            | 
           54 | 
                    */
  | 
        
        
            | 
            | 
           55 | 
                   proxyNode: {
  | 
        
        
            | 
            | 
           56 | 
                       setter: Y.one,
  | 
        
        
            | 
            | 
           57 | 
                       valueFn: function() {
  | 
        
        
            | 
            | 
           58 | 
                           return Y.Node.create(this.PROXY_TEMPLATE);
  | 
        
        
            | 
            | 
           59 | 
                       }
  | 
        
        
            | 
            | 
           60 | 
                   }
  | 
        
        
            | 
            | 
           61 | 
               }
  | 
        
        
            | 
            | 
           62 | 
           });
  | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
           Y.extend(ResizeProxy, Y.Plugin.Base, {
  | 
        
        
            | 
            | 
           65 | 
               /**
  | 
        
        
            | 
            | 
           66 | 
                * Template used to create the resize proxy.
  | 
        
        
            | 
            | 
           67 | 
                *
  | 
        
        
            | 
            | 
           68 | 
                * @property PROXY_TEMPLATE
  | 
        
        
            | 
            | 
           69 | 
                * @type {String}
  | 
        
        
            | 
            | 
           70 | 
                */
  | 
        
        
            | 
            | 
           71 | 
               PROXY_TEMPLATE: '<div class="'+CSS_RESIZE_PROXY+'"></div>',
  | 
        
        
            | 
            | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
               initializer: function() {
  | 
        
        
            | 
            | 
           74 | 
                   var instance = this;
  | 
        
        
            | 
            | 
           75 | 
              | 
        
        
            | 
            | 
           76 | 
                   instance.afterHostEvent('resize:start', instance._afterResizeStart);
  | 
        
        
            | 
            | 
           77 | 
                   instance.beforeHostMethod('_resize', instance._beforeHostResize);
  | 
        
        
            | 
            | 
           78 | 
                   instance.afterHostMethod('_resizeEnd', instance._afterHostResizeEnd);
  | 
        
        
            | 
            | 
           79 | 
               },
  | 
        
        
            | 
            | 
           80 | 
              | 
        
        
            | 
            | 
           81 | 
               destructor: function() {
  | 
        
        
            | 
            | 
           82 | 
                   var instance = this;
  | 
        
        
            | 
            | 
           83 | 
              | 
        
        
            | 
            | 
           84 | 
                   instance.get(PROXY_NODE).remove(true);
  | 
        
        
            | 
            | 
           85 | 
               },
  | 
        
        
            | 
            | 
           86 | 
              | 
        
        
            | 
            | 
           87 | 
               _afterHostResizeEnd: function(event) {
  | 
        
        
            | 
            | 
           88 | 
                   var instance = this,
  | 
        
        
            | 
            | 
           89 | 
                       drag = event.dragEvent.target;
  | 
        
        
            | 
            | 
           90 | 
              | 
        
        
            | 
            | 
           91 | 
                   // reseting actXY from drag when drag end
  | 
        
        
            | 
            | 
           92 | 
                   drag.actXY = [];
  | 
        
        
            | 
            | 
           93 | 
              | 
        
        
            | 
            | 
           94 | 
                   // if proxy is true, hide it on resize end
  | 
        
        
            | 
            | 
           95 | 
                   instance._syncProxyUI();
  | 
        
        
            | 
            | 
           96 | 
              | 
        
        
            | 
            | 
           97 | 
                   instance.get(PROXY_NODE).hide();
  | 
        
        
            | 
            | 
           98 | 
               },
  | 
        
        
            | 
            | 
           99 | 
              | 
        
        
            | 
            | 
           100 | 
               _afterResizeStart: function() {
  | 
        
        
            | 
            | 
           101 | 
                   var instance = this;
  | 
        
        
            | 
            | 
           102 | 
              | 
        
        
            | 
            | 
           103 | 
                   instance._renderProxy();
  | 
        
        
            | 
            | 
           104 | 
               },
  | 
        
        
            | 
            | 
           105 | 
              | 
        
        
            | 
            | 
           106 | 
               _beforeHostResize: function(event) {
  | 
        
        
            | 
            | 
           107 | 
                   var instance = this,
  | 
        
        
            | 
            | 
           108 | 
                       host = this.get(HOST);
  | 
        
        
            | 
            | 
           109 | 
              | 
        
        
            | 
            | 
           110 | 
                   host._handleResizeAlignEvent(event.dragEvent);
  | 
        
        
            | 
            | 
           111 | 
              | 
        
        
            | 
            | 
           112 | 
                   // if proxy is true _syncProxyUI instead of _syncUI
  | 
        
        
            | 
            | 
           113 | 
                   instance._syncProxyUI();
  | 
        
        
            | 
            | 
           114 | 
              | 
        
        
            | 
            | 
           115 | 
                   return new Y.Do.Prevent();
  | 
        
        
            | 
            | 
           116 | 
               },
  | 
        
        
            | 
            | 
           117 | 
              | 
        
        
            | 
            | 
           118 | 
               /**
  | 
        
        
            | 
            | 
           119 | 
                 * Render the <a href="ResizeProxy.html#attr_proxyNode">proxyNode</a> element and
  | 
        
        
            | 
            | 
           120 | 
                 * make it sibling of the <a href="Resize.html#attr_node">node</a>.
  | 
        
        
            | 
            | 
           121 | 
                 *
  | 
        
        
            | 
            | 
           122 | 
                 * @method _renderProxy
  | 
        
        
            | 
            | 
           123 | 
                 * @protected
  | 
        
        
            | 
            | 
           124 | 
                 */
  | 
        
        
            | 
            | 
           125 | 
               _renderProxy: function() {
  | 
        
        
            | 
            | 
           126 | 
                   var instance = this,
  | 
        
        
            | 
            | 
           127 | 
                       host = this.get(HOST),
  | 
        
        
            | 
            | 
           128 | 
                       proxyNode = instance.get(PROXY_NODE);
  | 
        
        
            | 
            | 
           129 | 
              | 
        
        
            | 
            | 
           130 | 
                   if (!proxyNode.inDoc()) {
  | 
        
        
            | 
            | 
           131 | 
                       host.get(WRAPPER).get(PARENT_NODE).append(
  | 
        
        
            | 
            | 
           132 | 
                           proxyNode.hide()
  | 
        
        
            | 
            | 
           133 | 
                       );
  | 
        
        
            | 
            | 
           134 | 
                   }
  | 
        
        
            | 
            | 
           135 | 
               },
  | 
        
        
            | 
            | 
           136 | 
              | 
        
        
            | 
            | 
           137 | 
               /**
  | 
        
        
            | 
            | 
           138 | 
                * Sync the proxy UI with internal values from
  | 
        
        
            | 
            | 
           139 | 
                * <a href="ResizeProxy.html#property_info">info</a>.
  | 
        
        
            | 
            | 
           140 | 
                *
  | 
        
        
            | 
            | 
           141 | 
                * @method _syncProxyUI
  | 
        
        
            | 
            | 
           142 | 
                * @protected
  | 
        
        
            | 
            | 
           143 | 
                */
  | 
        
        
            | 
            | 
           144 | 
               _syncProxyUI: function() {
  | 
        
        
            | 
            | 
           145 | 
                   var instance = this,
  | 
        
        
            | 
            | 
           146 | 
                       host = this.get(HOST),
  | 
        
        
            | 
            | 
           147 | 
                       info = host.info,
  | 
        
        
            | 
            | 
           148 | 
                       activeHandleNode = host.get(ACTIVE_HANDLE_NODE),
  | 
        
        
            | 
            | 
           149 | 
                       proxyNode = instance.get(PROXY_NODE),
  | 
        
        
            | 
            | 
           150 | 
                       cursor = activeHandleNode.getStyle(CURSOR);
  | 
        
        
            | 
            | 
           151 | 
              | 
        
        
            | 
            | 
           152 | 
                   proxyNode.show().setStyle(CURSOR, cursor);
  | 
        
        
            | 
            | 
           153 | 
              | 
        
        
            | 
            | 
           154 | 
                   host.delegate.dd.set(DRAG_CURSOR, cursor);
  | 
        
        
            | 
            | 
           155 | 
              | 
        
        
            | 
            | 
           156 | 
                   proxyNode.sizeTo(info.offsetWidth, info.offsetHeight);
  | 
        
        
            | 
            | 
           157 | 
              | 
        
        
            | 
            | 
           158 | 
                   proxyNode.setXY([ info.left, info.top ]);
  | 
        
        
            | 
            | 
           159 | 
               }
  | 
        
        
            | 
            | 
           160 | 
           });
  | 
        
        
            | 
            | 
           161 | 
              | 
        
        
            | 
            | 
           162 | 
           Y.namespace('Plugin');
  | 
        
        
            | 
            | 
           163 | 
           Y.Plugin.ResizeProxy = ResizeProxy;
  | 
        
        
            | 
            | 
           164 | 
              | 
        
        
            | 
            | 
           165 | 
              | 
        
        
            | 
            | 
           166 | 
           }, '3.18.1', {"requires": ["plugin", "resize-base"]});
  |