/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

  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
  9. Ext.grid.SplitDragZone = Ext.extend(Ext.dd.DDProxy, {
  10. fly: Ext.Element.fly,
  11. constructor : function(grid, hd, hd2){
  12. this.grid = grid;
  13. this.view = grid.getView();
  14. this.proxy = this.view.resizeProxy;
  15. Ext.grid.SplitDragZone.superclass.constructor.call(this, hd,
  16. "gridSplitters" + this.grid.getGridEl().id, {
  17. dragElId : Ext.id(this.proxy.dom), resizeFrame:false
  18. });
  19. this.setHandleElId(Ext.id(hd));
  20. this.setOuterHandleElId(Ext.id(hd2));
  21. this.scroll = false;
  22. },
  23. b4StartDrag : function(x, y){
  24. this.view.headersDisabled = true;
  25. this.proxy.setHeight(this.view.mainWrap.getHeight());
  26. var w = this.cm.getColumnWidth(this.cellIndex);
  27. var minw = Math.max(w-this.grid.minColumnWidth, 0);
  28. this.resetConstraints();
  29. this.setXConstraint(minw, 1000);
  30. this.setYConstraint(0, 0);
  31. this.minX = x - minw;
  32. this.maxX = x + 1000;
  33. this.startPos = x;
  34. Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
  35. },
  36. handleMouseDown : function(e){
  37. var ev = Ext.EventObject.setEvent(e);
  38. var t = this.fly(ev.getTarget());
  39. if(t.hasClass("x-grid-split")){
  40. this.cellIndex = this.view.getCellIndex(t.dom);
  41. this.split = t.dom;
  42. this.cm = this.grid.colModel;
  43. if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
  44. Ext.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
  45. }
  46. }
  47. },
  48. endDrag : function(e){
  49. this.view.headersDisabled = false;
  50. var endX = Math.max(this.minX, Ext.lib.Event.getPageX(e));
  51. var diff = endX - this.startPos;
  52. this.view.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
  53. },
  54. autoOffset : function(){
  55. this.setDelta(0,0);
  56. }
  57. });