Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
6.4 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  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>
  7. </head>
  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
  14. */
  15. // private
  16. // This is a support class used internally by the Grid components
  17. Ext.grid.HeaderDragZone = Ext.extend(Ext.dd.DragZone, {
  18. maxDragWidth: 120,
  19. constructor : function(grid, hd, hd2){
  20. this.grid = grid;
  21. this.view = grid.getView();
  22. this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
  23. Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
  24. if(hd2){
  25. this.setHandleElId(Ext.id(hd));
  26. this.setOuterHandleElId(Ext.id(hd2));
  27. }
  28. this.scroll = false;
  29. },
  30. getDragData : function(e){
  31. var t = Ext.lib.Event.getTarget(e),
  32. h = this.view.findHeaderCell(t);
  33. if(h){
  34. return {ddel: h.firstChild, header:h};
  35. }
  36. return false;
  37. },
  38. onInitDrag : function(e){
  39. // keep the value here so we can restore it;
  40. this.dragHeadersDisabled = this.view.headersDisabled;
  41. this.view.headersDisabled = true;
  42. var clone = this.dragData.ddel.cloneNode(true);
  43. clone.id = Ext.id();
  44. clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
  45. this.proxy.update(clone);
  46. return true;
  47. },
  48. afterValidDrop : function(){
  49. this.completeDrop();
  50. },
  51. afterInvalidDrop : function(){
  52. this.completeDrop();
  53. },
  54. completeDrop: function(){
  55. var v = this.view,
  56. disabled = this.dragHeadersDisabled;
  57. setTimeout(function(){
  58. v.headersDisabled = disabled;
  59. }, 50);
  60. }
  61. });
  62. // private
  63. // This is a support class used internally by the Grid components
  64. Ext.grid.HeaderDropZone = Ext.extend(Ext.dd.DropZone, {
  65. proxyOffsets : [-4, -9],
  66. fly: Ext.Element.fly,
  67. constructor : function(grid, hd, hd2){
  68. this.grid = grid;
  69. this.view = grid.getView();
  70. // split the proxies so they don't interfere with mouse events
  71. this.proxyTop = Ext.DomHelper.append(document.body, {
  72. cls:"col-move-top", html:"&#160;"
  73. }, true);
  74. this.proxyBottom = Ext.DomHelper.append(document.body, {
  75. cls:"col-move-bottom", html:"&#160;"
  76. }, true);
  77. this.proxyTop.hide = this.proxyBottom.hide = function(){
  78. this.setLeftTop(-100,-100);
  79. this.setStyle("visibility", "hidden");
  80. };
  81. this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
  82. // temporarily disabled
  83. //Ext.dd.ScrollManager.register(this.view.scroller.dom);
  84. Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
  85. },
  86. getTargetFromEvent : function(e){
  87. var t = Ext.lib.Event.getTarget(e),
  88. cindex = this.view.findCellIndex(t);
  89. if(cindex !== false){
  90. return this.view.getHeaderCell(cindex);
  91. }
  92. },
  93. nextVisible : function(h){
  94. var v = this.view, cm = this.grid.colModel;
  95. h = h.nextSibling;
  96. while(h){
  97. if(!cm.isHidden(v.getCellIndex(h))){
  98. return h;
  99. }
  100. h = h.nextSibling;
  101. }
  102. return null;
  103. },
  104. prevVisible : function(h){
  105. var v = this.view, cm = this.grid.colModel;
  106. h = h.prevSibling;
  107. while(h){
  108. if(!cm.isHidden(v.getCellIndex(h))){
  109. return h;
  110. }
  111. h = h.prevSibling;
  112. }
  113. return null;
  114. },
  115. positionIndicator : function(h, n, e){
  116. var x = Ext.lib.Event.getPageX(e),
  117. r = Ext.lib.Dom.getRegion(n.firstChild),
  118. px,
  119. pt,
  120. py = r.top + this.proxyOffsets[1];
  121. if((r.right - x) <= (r.right-r.left)/2){
  122. px = r.right+this.view.borderWidth;
  123. pt = "after";
  124. }else{
  125. px = r.left;
  126. pt = "before";
  127. }
  128. if(this.grid.colModel.isFixed(this.view.getCellIndex(n))){
  129. return false;
  130. }
  131. px += this.proxyOffsets[0];
  132. this.proxyTop.setLeftTop(px, py);
  133. this.proxyTop.show();
  134. if(!this.bottomOffset){
  135. this.bottomOffset = this.view.mainHd.getHeight();
  136. }
  137. this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
  138. this.proxyBottom.show();
  139. return pt;
  140. },
  141. onNodeEnter : function(n, dd, e, data){
  142. if(data.header != n){
  143. this.positionIndicator(data.header, n, e);
  144. }
  145. },
  146. onNodeOver : function(n, dd, e, data){
  147. var result = false;
  148. if(data.header != n){
  149. result = this.positionIndicator(data.header, n, e);
  150. }
  151. if(!result){
  152. this.proxyTop.hide();
  153. this.proxyBottom.hide();
  154. }
  155. return result ? this.dropAllowed : this.dropNotAllowed;
  156. },
  157. onNodeOut : function(n, dd, e, data){
  158. this.proxyTop.hide();
  159. this.proxyBottom.hide();
  160. },
  161. onNodeDrop : function(n, dd, e, data){
  162. var h = data.header;
  163. if(h != n){
  164. var cm = this.grid.colModel,
  165. x = Ext.lib.Event.getPageX(e),
  166. r = Ext.lib.Dom.getRegion(n.firstChild),
  167. pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before",
  168. oldIndex = this.view.getCellIndex(h),
  169. newIndex = this.view.getCellIndex(n);
  170. if(pt == "after"){
  171. newIndex++;
  172. }
  173. if(oldIndex < newIndex){
  174. newIndex--;
  175. }
  176. cm.moveColumn(oldIndex, newIndex);
  177. return true;
  178. }
  179. return false;
  180. }
  181. });
  182. Ext.grid.GridView.ColumnDragZone = Ext.extend(Ext.grid.HeaderDragZone, {
  183. constructor : function(grid, hd){
  184. Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
  185. this.proxy.el.addClass('x-grid3-col-dd');
  186. },
  187. handleMouseDown : function(e){
  188. },
  189. callHandleMouseDown : function(e){
  190. Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
  191. }
  192. });</pre>
  193. </body>
  194. </html>