3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 Ext.ux.Portal = Ext.extend(Ext.Panel, {
19 defaultType : 'portalcolumn',
21 initComponent : function(){
22 Ext.ux.Portal.superclass.initComponent.call(this);
32 initEvents : function(){
33 Ext.ux.Portal.superclass.initEvents.call(this);
34 this.dd = new Ext.ux.Portal.DropZone(this, this.dropConfig);
37 beforeDestroy : function() {
41 Ext.ux.Portal.superclass.beforeDestroy.call(this);
45 Ext.reg('portal', Ext.ux.Portal);
47 Ext.ux.Portal.DropZone = Ext.extend(Ext.dd.DropTarget, {
49 constructor : function(portal, cfg){
51 Ext.dd.ScrollManager.register(portal.body);
52 Ext.ux.Portal.DropZone.superclass.constructor.call(this, portal.bwrap.dom, cfg);
53 portal.body.ddScrollConfig = this.ddScrollConfig;
63 createEvent : function(dd, e, data, col, c, pos){
73 status: this.dropAllowed
77 notifyOver : function(dd, e, data){
78 var xy = e.getXY(), portal = this.portal, px = dd.proxy;
82 this.grid = this.getGrid();
85 // handle case scroll where scrollbars appear during drag
86 var cw = portal.body.dom.clientWidth;
89 }else if(this.lastCW != cw){
92 this.grid = this.getGrid();
96 var col = 0, xs = this.grid.columnX, cmatch = false;
97 for(var len = xs.length; col < len; col++){
98 if(xy[0] < (xs[col].x + xs[col].w)){
103 // no match, fix last index
108 // find insert position
109 var p, match = false, pos = 0,
110 c = portal.items.itemAt(col),
111 items = c.items.items, overSelf = false;
113 for(var len = items.length; pos < len; pos++){
115 var h = p.el.getHeight();
119 else if((p.el.getY()+(h/2)) > xy[1]){
125 pos = (match && p ? pos : c.items.getCount()) + (overSelf ? -1 : 0);
126 var overEvent = this.createEvent(dd, e, data, col, c, pos);
128 if(portal.fireEvent('validatedrop', overEvent) !== false &&
129 portal.fireEvent('beforedragover', overEvent) !== false){
131 // make sure proxy width is fluid
132 px.getProxy().setWidth('auto');
135 px.moveProxy(p.el.dom.parentNode, match ? p.el.dom : null);
137 px.moveProxy(c.el.dom, null);
140 this.lastPos = {c: c, col: col, p: overSelf || (match && p) ? pos : false};
141 this.scrollPos = portal.body.getScroll();
143 portal.fireEvent('dragover', overEvent);
145 return overEvent.status;
147 return overEvent.status;
152 notifyOut : function(){
156 notifyDrop : function(dd, e, data){
161 var c = this.lastPos.c,
162 col = this.lastPos.col,
163 pos = this.lastPos.p,
165 dropEvent = this.createEvent(dd, e, data, col, c,
166 pos !== false ? pos : c.items.getCount());
168 if(this.portal.fireEvent('validatedrop', dropEvent) !== false &&
169 this.portal.fireEvent('beforedrop', dropEvent) !== false){
171 dd.proxy.getProxy().remove();
172 panel.el.dom.parentNode.removeChild(dd.panel.el.dom);
175 c.insert(pos, panel);
182 this.portal.fireEvent('drop', dropEvent);
184 // scroll position is lost on drop, fix it
185 var st = this.scrollPos.top;
187 var d = this.portal.body.dom;
188 setTimeout(function(){
197 // internal cache of body and column coords
198 getGrid : function(){
199 var box = this.portal.bwrap.getBox();
201 this.portal.items.each(function(c){
202 box.columnX.push({x: c.el.getX(), w: c.el.getWidth()});
207 // unregister the dropzone from ScrollManager
209 Ext.dd.ScrollManager.unregister(this.portal.body);
210 Ext.ux.Portal.DropZone.superclass.unreg.call(this);