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.

186 lines
6.5 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. <div id="cls-Ext.tree.TreeEditor"></div>/**
  16. * @class Ext.tree.TreeEditor
  17. * @extends Ext.Editor
  18. * Provides editor functionality for inline tree node editing. Any valid {@link Ext.form.Field} subclass can be used
  19. * as the editor field.
  20. * @constructor
  21. * @param {TreePanel} tree
  22. * @param {Object} fieldConfig (optional) Either a prebuilt {@link Ext.form.Field} instance or a Field config object
  23. * that will be applied to the default field instance (defaults to a {@link Ext.form.TextField}).
  24. * @param {Object} config (optional) A TreeEditor config object
  25. */
  26. Ext.tree.TreeEditor = function(tree, fc, config){
  27. fc = fc || {};
  28. var field = fc.events ? fc : new Ext.form.TextField(fc);
  29. Ext.tree.TreeEditor.superclass.constructor.call(this, field, config);
  30. this.tree = tree;
  31. if(!tree.rendered){
  32. tree.on('render', this.initEditor, this);
  33. }else{
  34. this.initEditor(tree);
  35. }
  36. };
  37. Ext.extend(Ext.tree.TreeEditor, Ext.Editor, {
  38. <div id="cfg-Ext.tree.TreeEditor-alignment"></div>/**
  39. * @cfg {String} alignment
  40. * The position to align to (see {@link Ext.Element#alignTo} for more details, defaults to "l-l").
  41. */
  42. alignment: "l-l",
  43. // inherit
  44. autoSize: false,
  45. <div id="cfg-Ext.tree.TreeEditor-hideEl"></div>/**
  46. * @cfg {Boolean} hideEl
  47. * True to hide the bound element while the editor is displayed (defaults to false)
  48. */
  49. hideEl : false,
  50. <div id="cfg-Ext.tree.TreeEditor-cls"></div>/**
  51. * @cfg {String} cls
  52. * CSS class to apply to the editor (defaults to "x-small-editor x-tree-editor")
  53. */
  54. cls: "x-small-editor x-tree-editor",
  55. <div id="cfg-Ext.tree.TreeEditor-shim"></div>/**
  56. * @cfg {Boolean} shim
  57. * True to shim the editor if selects/iframes could be displayed beneath it (defaults to false)
  58. */
  59. shim:false,
  60. // inherit
  61. shadow:"frame",
  62. <div id="cfg-Ext.tree.TreeEditor-maxWidth"></div>/**
  63. * @cfg {Number} maxWidth
  64. * The maximum width in pixels of the editor field (defaults to 250). Note that if the maxWidth would exceed
  65. * the containing tree element's size, it will be automatically limited for you to the container width, taking
  66. * scroll and client offsets into account prior to each edit.
  67. */
  68. maxWidth: 250,
  69. <div id="cfg-Ext.tree.TreeEditor-editDelay"></div>/**
  70. * @cfg {Number} editDelay The number of milliseconds between clicks to register a double-click that will trigger
  71. * editing on the current node (defaults to 350). If two clicks occur on the same node within this time span,
  72. * the editor for the node will display, otherwise it will be processed as a regular click.
  73. */
  74. editDelay : 350,
  75. initEditor : function(tree){
  76. tree.on({
  77. scope : this,
  78. beforeclick: this.beforeNodeClick,
  79. dblclick : this.onNodeDblClick
  80. });
  81. this.on({
  82. scope : this,
  83. complete : this.updateNode,
  84. beforestartedit: this.fitToTree,
  85. specialkey : this.onSpecialKey
  86. });
  87. this.on('startedit', this.bindScroll, this, {delay:10});
  88. },
  89. // private
  90. fitToTree : function(ed, el){
  91. var td = this.tree.getTreeEl().dom, nd = el.dom;
  92. if(td.scrollLeft > nd.offsetLeft){ // ensure the node left point is visible
  93. td.scrollLeft = nd.offsetLeft;
  94. }
  95. var w = Math.min(
  96. this.maxWidth,
  97. (td.clientWidth > 20 ? td.clientWidth : td.offsetWidth) - Math.max(0, nd.offsetLeft-td.scrollLeft) - /*cushion*/5);
  98. this.setSize(w, '');
  99. },
  100. <div id="method-Ext.tree.TreeEditor-triggerEdit"></div>/**
  101. * Edit the text of the passed {@link Ext.tree.TreeNode TreeNode}.
  102. * @param node {Ext.tree.TreeNode} The TreeNode to edit. The TreeNode must be {@link Ext.tree.TreeNode#editable editable}.
  103. */
  104. triggerEdit : function(node, defer){
  105. this.completeEdit();
  106. if(node.attributes.editable !== false){
  107. <div id="prop-Ext.tree.TreeEditor-editNode"></div>/**
  108. * The {@link Ext.tree.TreeNode TreeNode} this editor is bound to. Read-only.
  109. * @type Ext.tree.TreeNode
  110. * @property editNode
  111. */
  112. this.editNode = node;
  113. if(this.tree.autoScroll){
  114. Ext.fly(node.ui.getEl()).scrollIntoView(this.tree.body);
  115. }
  116. var value = node.text || '';
  117. if (!Ext.isGecko && Ext.isEmpty(node.text)){
  118. node.setText('&#160;');
  119. }
  120. this.autoEditTimer = this.startEdit.defer(this.editDelay, this, [node.ui.textNode, value]);
  121. return false;
  122. }
  123. },
  124. // private
  125. bindScroll : function(){
  126. this.tree.getTreeEl().on('scroll', this.cancelEdit, this);
  127. },
  128. // private
  129. beforeNodeClick : function(node, e){
  130. clearTimeout(this.autoEditTimer);
  131. if(this.tree.getSelectionModel().isSelected(node)){
  132. e.stopEvent();
  133. return this.triggerEdit(node);
  134. }
  135. },
  136. onNodeDblClick : function(node, e){
  137. clearTimeout(this.autoEditTimer);
  138. },
  139. // private
  140. updateNode : function(ed, value){
  141. this.tree.getTreeEl().un('scroll', this.cancelEdit, this);
  142. this.editNode.setText(value);
  143. },
  144. // private
  145. onHide : function(){
  146. Ext.tree.TreeEditor.superclass.onHide.call(this);
  147. if(this.editNode){
  148. this.editNode.ui.focus.defer(50, this.editNode.ui);
  149. }
  150. },
  151. // private
  152. onSpecialKey : function(field, e){
  153. var k = e.getKey();
  154. if(k == e.ESC){
  155. e.stopEvent();
  156. this.cancelEdit();
  157. }else if(k == e.ENTER && !e.hasModifier()){
  158. e.stopEvent();
  159. this.completeEdit();
  160. }
  161. },
  162. onDestroy : function(){
  163. clearTimeout(this.autoEditTimer);
  164. Ext.tree.TreeEditor.superclass.onDestroy.call(this);
  165. var tree = this.tree;
  166. tree.un('beforeclick', this.beforeNodeClick, this);
  167. tree.un('dblclick', this.onNodeDblClick, this);
  168. }
  169. });</pre>
  170. </body>
  171. </html>