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.

318 lines
11 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.layout.ContainerLayout"></div>/**
  16. * @class Ext.layout.ContainerLayout
  17. * <p>This class is intended to be extended or created via the <tt><b>{@link Ext.Container#layout layout}</b></tt>
  18. * configuration property. See <tt><b>{@link Ext.Container#layout}</b></tt> for additional details.</p>
  19. */
  20. Ext.layout.ContainerLayout = Ext.extend(Object, {
  21. <div id="cfg-Ext.layout.ContainerLayout-extraCls"></div>/**
  22. * @cfg {String} extraCls
  23. * <p>An optional extra CSS class that will be added to the container. This can be useful for adding
  24. * customized styles to the container or any of its children using standard CSS rules. See
  25. * {@link Ext.Component}.{@link Ext.Component#ctCls ctCls} also.</p>
  26. * <p><b>Note</b>: <tt>extraCls</tt> defaults to <tt>''</tt> except for the following classes
  27. * which assign a value by default:
  28. * <div class="mdetail-params"><ul>
  29. * <li>{@link Ext.layout.AbsoluteLayout Absolute Layout} : <tt>'x-abs-layout-item'</tt></li>
  30. * <li>{@link Ext.layout.Box Box Layout} : <tt>'x-box-item'</tt></li>
  31. * <li>{@link Ext.layout.ColumnLayout Column Layout} : <tt>'x-column'</tt></li>
  32. * </ul></div>
  33. * To configure the above Classes with an extra CSS class append to the default. For example,
  34. * for ColumnLayout:<pre><code>
  35. * extraCls: 'x-column custom-class'
  36. * </code></pre>
  37. * </p>
  38. */
  39. <div id="cfg-Ext.layout.ContainerLayout-renderHidden"></div>/**
  40. * @cfg {Boolean} renderHidden
  41. * True to hide each contained item on render (defaults to false).
  42. */
  43. <div id="prop-Ext.layout.ContainerLayout-activeItem"></div>/**
  44. * A reference to the {@link Ext.Component} that is active. For example, <pre><code>
  45. * if(myPanel.layout.activeItem.id == 'item-1') { ... }
  46. * </code></pre>
  47. * <tt>activeItem</tt> only applies to layout styles that can display items one at a time
  48. * (like {@link Ext.layout.AccordionLayout}, {@link Ext.layout.CardLayout}
  49. * and {@link Ext.layout.FitLayout}). Read-only. Related to {@link Ext.Container#activeItem}.
  50. * @type {Ext.Component}
  51. * @property activeItem
  52. */
  53. // private
  54. monitorResize:false,
  55. // private
  56. activeItem : null,
  57. constructor : function(config){
  58. this.id = Ext.id(null, 'ext-layout-');
  59. Ext.apply(this, config);
  60. },
  61. type: 'container',
  62. /* Workaround for how IE measures autoWidth elements. It prefers bottom-up measurements
  63. whereas other browser prefer top-down. We will hide all target child elements before we measure and
  64. put them back to get an accurate measurement.
  65. */
  66. IEMeasureHack : function(target, viewFlag) {
  67. var tChildren = target.dom.childNodes, tLen = tChildren.length, c, d = [], e, i, ret;
  68. for (i = 0 ; i < tLen ; i++) {
  69. c = tChildren[i];
  70. e = Ext.get(c);
  71. if (e) {
  72. d[i] = e.getStyle('display');
  73. e.setStyle({display: 'none'});
  74. }
  75. }
  76. ret = target ? target.getViewSize(viewFlag) : {};
  77. for (i = 0 ; i < tLen ; i++) {
  78. c = tChildren[i];
  79. e = Ext.get(c);
  80. if (e) {
  81. e.setStyle({display: d[i]});
  82. }
  83. }
  84. return ret;
  85. },
  86. // Placeholder for the derived layouts
  87. getLayoutTargetSize : Ext.EmptyFn,
  88. // private
  89. layout : function(){
  90. var ct = this.container, target = ct.getLayoutTarget();
  91. if(!(this.hasLayout || Ext.isEmpty(this.targetCls))){
  92. target.addClass(this.targetCls);
  93. }
  94. this.onLayout(ct, target);
  95. ct.fireEvent('afterlayout', ct, this);
  96. },
  97. // private
  98. onLayout : function(ct, target){
  99. this.renderAll(ct, target);
  100. },
  101. // private
  102. isValidParent : function(c, target){
  103. return target && c.getPositionEl().dom.parentNode == (target.dom || target);
  104. },
  105. // private
  106. renderAll : function(ct, target){
  107. var items = ct.items.items, i, c, len = items.length;
  108. for(i = 0; i < len; i++) {
  109. c = items[i];
  110. if(c && (!c.rendered || !this.isValidParent(c, target))){
  111. this.renderItem(c, i, target);
  112. }
  113. }
  114. },
  115. /**
  116. * @private
  117. * Renders the given Component into the target Element. If the Component is already rendered,
  118. * it is moved to the provided target instead.
  119. * @param {Ext.Component} c The Component to render
  120. * @param {Number} position The position within the target to render the item to
  121. * @param {Ext.Element} target The target Element
  122. */
  123. renderItem : function(c, position, target){
  124. if (c) {
  125. if (!c.rendered) {
  126. c.render(target, position);
  127. this.configureItem(c);
  128. } else if (!this.isValidParent(c, target)) {
  129. if (Ext.isNumber(position)) {
  130. position = target.dom.childNodes[position];
  131. }
  132. target.dom.insertBefore(c.getPositionEl().dom, position || null);
  133. c.container = target;
  134. this.configureItem(c);
  135. }
  136. }
  137. },
  138. // private.
  139. // Get all rendered items to lay out.
  140. getRenderedItems: function(ct){
  141. var t = ct.getLayoutTarget(), cti = ct.items.items, len = cti.length, i, c, items = [];
  142. for (i = 0; i < len; i++) {
  143. if((c = cti[i]).rendered && this.isValidParent(c, t) && c.shouldLayout !== false){
  144. items.push(c);
  145. }
  146. };
  147. return items;
  148. },
  149. /**
  150. * @private
  151. * Applies extraCls and hides the item if renderHidden is true
  152. */
  153. configureItem: function(c){
  154. if (this.extraCls) {
  155. var t = c.getPositionEl ? c.getPositionEl() : c;
  156. t.addClass(this.extraCls);
  157. }
  158. // If we are forcing a layout, do so *before* we hide so elements have height/width
  159. if (c.doLayout && this.forceLayout) {
  160. c.doLayout();
  161. }
  162. if (this.renderHidden && c != this.activeItem) {
  163. c.hide();
  164. }
  165. },
  166. onRemove: function(c){
  167. if(this.activeItem == c){
  168. delete this.activeItem;
  169. }
  170. if(c.rendered && this.extraCls){
  171. var t = c.getPositionEl ? c.getPositionEl() : c;
  172. t.removeClass(this.extraCls);
  173. }
  174. },
  175. afterRemove: function(c){
  176. if(c.removeRestore){
  177. c.removeMode = 'container';
  178. delete c.removeRestore;
  179. }
  180. },
  181. // private
  182. onResize: function(){
  183. var ct = this.container,
  184. b;
  185. if(ct.collapsed){
  186. return;
  187. }
  188. if(b = ct.bufferResize && ct.shouldBufferLayout()){
  189. if(!this.resizeTask){
  190. this.resizeTask = new Ext.util.DelayedTask(this.runLayout, this);
  191. this.resizeBuffer = Ext.isNumber(b) ? b : 50;
  192. }
  193. ct.layoutPending = true;
  194. this.resizeTask.delay(this.resizeBuffer);
  195. }else{
  196. this.runLayout();
  197. }
  198. },
  199. runLayout: function(){
  200. var ct = this.container;
  201. this.layout();
  202. ct.onLayout();
  203. delete ct.layoutPending;
  204. },
  205. // private
  206. setContainer : function(ct){
  207. <div id="prop-Ext.layout.ContainerLayout-if"></div>/**
  208. * This monitorResize flag will be renamed soon as to avoid confusion
  209. * with the Container version which hooks onWindowResize to doLayout
  210. *
  211. * monitorResize flag in this context attaches the resize event between
  212. * a container and it's layout
  213. */
  214. if(this.monitorResize && ct != this.container){
  215. var old = this.container;
  216. if(old){
  217. old.un(old.resizeEvent, this.onResize, this);
  218. }
  219. if(ct){
  220. ct.on(ct.resizeEvent, this.onResize, this);
  221. }
  222. }
  223. this.container = ct;
  224. },
  225. <div id="method-Ext.layout.ContainerLayout-parseMargins"></div>/**
  226. * Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations
  227. * (e.g. 10, "10", "10 10", "10 10 10" and "10 10 10 10" are all valid options and would return the same result)
  228. * @param {Number|String} v The encoded margins
  229. * @return {Object} An object with margin sizes for top, right, bottom and left
  230. */
  231. parseMargins : function(v){
  232. if (Ext.isNumber(v)) {
  233. v = v.toString();
  234. }
  235. var ms = v.split(' '),
  236. len = ms.length;
  237. if (len == 1) {
  238. ms[1] = ms[2] = ms[3] = ms[0];
  239. } else if(len == 2) {
  240. ms[2] = ms[0];
  241. ms[3] = ms[1];
  242. } else if(len == 3) {
  243. ms[3] = ms[1];
  244. }
  245. return {
  246. top :parseInt(ms[0], 10) || 0,
  247. right :parseInt(ms[1], 10) || 0,
  248. bottom:parseInt(ms[2], 10) || 0,
  249. left :parseInt(ms[3], 10) || 0
  250. };
  251. },
  252. <div id="prop-Ext.layout.ContainerLayout-fieldTpl"></div>/**
  253. * The {@link Ext.Template Ext.Template} used by Field rendering layout classes (such as
  254. * {@link Ext.layout.FormLayout}) to create the DOM structure of a fully wrapped,
  255. * labeled and styled form Field. A default Template is supplied, but this may be
  256. * overriden to create custom field structures. The template processes values returned from
  257. * {@link Ext.layout.FormLayout#getTemplateArgs}.
  258. * @property fieldTpl
  259. * @type Ext.Template
  260. */
  261. fieldTpl: (function() {
  262. var t = new Ext.Template(
  263. '<div class="x-form-item {itemCls}" tabIndex="-1">',
  264. '<label for="{id}" style="{labelStyle}" class="x-form-item-label">{label}{labelSeparator}</label>',
  265. '<div class="x-form-element" id="x-form-el-{id}" style="{elementStyle}">',
  266. '</div><div class="{clearCls}"></div>',
  267. '</div>'
  268. );
  269. t.disableFormats = true;
  270. return t.compile();
  271. })(),
  272. /*
  273. * Destroys this layout. This is a template method that is empty by default, but should be implemented
  274. * by subclasses that require explicit destruction to purge event handlers or remove DOM nodes.
  275. * @protected
  276. */
  277. destroy : function(){
  278. // Stop any buffered layout tasks
  279. if(this.resizeTask && this.resizeTask.cancel){
  280. this.resizeTask.cancel();
  281. }
  282. if(this.container) {
  283. this.container.un(this.container.resizeEvent, this.onResize, this);
  284. }
  285. if(!Ext.isEmpty(this.targetCls)){
  286. var target = this.container.getLayoutTarget();
  287. if(target){
  288. target.removeClass(this.targetCls);
  289. }
  290. }
  291. }
  292. });</pre>
  293. </body>
  294. </html>