PageRenderTime 29ms CodeModel.GetById 20ms app.highlight 7ms RepoModel.GetById 0ms app.codeStats 0ms

/javascripts/lib/src/widgets/grid/ColumnSplitDD.js

https://bitbucket.org/ksokmesa/sina-asian
JavaScript | 63 lines | 49 code | 6 blank | 8 comment | 3 complexity | cef63b2812272abc6e50711e3b9051bd MD5 | raw file
Possible License(s): GPL-3.0
 1/*!
 2 * Ext JS Library 3.2.1
 3 * Copyright(c) 2006-2010 Ext JS, Inc.
 4 * licensing@extjs.com
 5 * http://www.extjs.com/license
 6 */
 7// private
 8// This is a support class used internally by the Grid components
 9Ext.grid.SplitDragZone = Ext.extend(Ext.dd.DDProxy, {
10    fly: Ext.Element.fly,
11    
12    constructor : function(grid, hd, hd2){
13        this.grid = grid;
14        this.view = grid.getView();
15        this.proxy = this.view.resizeProxy;
16        Ext.grid.SplitDragZone.superclass.constructor.call(this, hd,
17            "gridSplitters" + this.grid.getGridEl().id, {
18            dragElId : Ext.id(this.proxy.dom), resizeFrame:false
19        });
20        this.setHandleElId(Ext.id(hd));
21        this.setOuterHandleElId(Ext.id(hd2));
22        this.scroll = false;
23    },
24
25    b4StartDrag : function(x, y){
26        this.view.headersDisabled = true;
27        this.proxy.setHeight(this.view.mainWrap.getHeight());
28        var w = this.cm.getColumnWidth(this.cellIndex);
29        var minw = Math.max(w-this.grid.minColumnWidth, 0);
30        this.resetConstraints();
31        this.setXConstraint(minw, 1000);
32        this.setYConstraint(0, 0);
33        this.minX = x - minw;
34        this.maxX = x + 1000;
35        this.startPos = x;
36        Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
37    },
38
39
40    handleMouseDown : function(e){
41        var ev = Ext.EventObject.setEvent(e);
42        var t = this.fly(ev.getTarget());
43        if(t.hasClass("x-grid-split")){
44            this.cellIndex = this.view.getCellIndex(t.dom);
45            this.split = t.dom;
46            this.cm = this.grid.colModel;
47            if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
48                Ext.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
49            }
50        }
51    },
52
53    endDrag : function(e){
54        this.view.headersDisabled = false;
55        var endX = Math.max(this.minX, Ext.lib.Event.getPageX(e));
56        var diff = endX - this.startPos;
57        this.view.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
58    },
59
60    autoOffset : function(){
61        this.setDelta(0,0);
62    }
63});