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.

185 lines
7.8 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. /**
  16. * @class Ext.Element
  17. */
  18. Ext.Element.addMethods({
  19. <div id="method-Ext.Element-setBox"></div>/**
  20. * Sets the element's box. Use getBox() on another element to get a box obj. If animate is true then width, height, x and y will be animated concurrently.
  21. * @param {Object} box The box to fill {x, y, width, height}
  22. * @param {Boolean} adjust (optional) Whether to adjust for box-model issues automatically
  23. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  24. * @return {Ext.Element} this
  25. */
  26. setBox : function(box, adjust, animate){
  27. var me = this,
  28. w = box.width,
  29. h = box.height;
  30. if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){
  31. w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
  32. h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
  33. }
  34. me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));
  35. return me;
  36. },
  37. <div id="method-Ext.Element-getBox"></div>/**
  38. * Return an object defining the area of this Element which can be passed to {@link #setBox} to
  39. * set another Element's size/location to match this element.
  40. * @param {Boolean} contentBox (optional) If true a box for the content of the element is returned.
  41. * @param {Boolean} local (optional) If true the element's left and top are returned instead of page x/y.
  42. * @return {Object} box An object in the format<pre><code>
  43. {
  44. x: &lt;Element's X position>,
  45. y: &lt;Element's Y position>,
  46. width: &lt;Element's width>,
  47. height: &lt;Element's height>,
  48. bottom: &lt;Element's lower bound>,
  49. right: &lt;Element's rightmost bound>
  50. }
  51. </code></pre>
  52. * The returned object may also be addressed as an Array where index 0 contains the X position
  53. * and index 1 contains the Y position. So the result may also be used for {@link #setXY}
  54. */
  55. getBox : function(contentBox, local) {
  56. var me = this,
  57. xy,
  58. left,
  59. top,
  60. getBorderWidth = me.getBorderWidth,
  61. getPadding = me.getPadding,
  62. l,
  63. r,
  64. t,
  65. b;
  66. if(!local){
  67. xy = me.getXY();
  68. }else{
  69. left = parseInt(me.getStyle("left"), 10) || 0;
  70. top = parseInt(me.getStyle("top"), 10) || 0;
  71. xy = [left, top];
  72. }
  73. var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
  74. if(!contentBox){
  75. bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
  76. }else{
  77. l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
  78. r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
  79. t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
  80. b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
  81. bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
  82. }
  83. bx.right = bx.x + bx.width;
  84. bx.bottom = bx.y + bx.height;
  85. return bx;
  86. },
  87. <div id="method-Ext.Element-move"></div>/**
  88. * Move this element relative to its current position.
  89. * @param {String} direction Possible values are: "l" (or "left"), "r" (or "right"), "t" (or "top", or "up"), "b" (or "bottom", or "down").
  90. * @param {Number} distance How far to move the element in pixels
  91. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  92. * @return {Ext.Element} this
  93. */
  94. move : function(direction, distance, animate){
  95. var me = this,
  96. xy = me.getXY(),
  97. x = xy[0],
  98. y = xy[1],
  99. left = [x - distance, y],
  100. right = [x + distance, y],
  101. top = [x, y - distance],
  102. bottom = [x, y + distance],
  103. hash = {
  104. l : left,
  105. left : left,
  106. r : right,
  107. right : right,
  108. t : top,
  109. top : top,
  110. up : top,
  111. b : bottom,
  112. bottom : bottom,
  113. down : bottom
  114. };
  115. direction = direction.toLowerCase();
  116. me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
  117. },
  118. <div id="method-Ext.Element-setLeftTop"></div>/**
  119. * Quick set left and top adding default units
  120. * @param {String} left The left CSS property value
  121. * @param {String} top The top CSS property value
  122. * @return {Ext.Element} this
  123. */
  124. setLeftTop : function(left, top){
  125. var me = this,
  126. style = me.dom.style;
  127. style.left = me.addUnits(left);
  128. style.top = me.addUnits(top);
  129. return me;
  130. },
  131. <div id="method-Ext.Element-getRegion"></div>/**
  132. * Returns the region of the given element.
  133. * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
  134. * @return {Region} A Ext.lib.Region containing "top, left, bottom, right" member data.
  135. */
  136. getRegion : function(){
  137. return Ext.lib.Dom.getRegion(this.dom);
  138. },
  139. <div id="method-Ext.Element-setBounds"></div>/**
  140. * Sets the element's position and size in one shot. If animation is true then width, height, x and y will be animated concurrently.
  141. * @param {Number} x X value for new position (coordinates are page-based)
  142. * @param {Number} y Y value for new position (coordinates are page-based)
  143. * @param {Mixed} width The new width. This may be one of:<div class="mdetail-params"><ul>
  144. * <li>A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels)</li>
  145. * <li>A String used to set the CSS width style. Animation may <b>not</b> be used.
  146. * </ul></div>
  147. * @param {Mixed} height The new height. This may be one of:<div class="mdetail-params"><ul>
  148. * <li>A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels)</li>
  149. * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>
  150. * </ul></div>
  151. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  152. * @return {Ext.Element} this
  153. */
  154. setBounds : function(x, y, width, height, animate){
  155. var me = this;
  156. if (!animate || !me.anim) {
  157. me.setSize(width, height);
  158. me.setLocation(x, y);
  159. } else {
  160. me.anim({points: {to: [x, y]},
  161. width: {to: me.adjustWidth(width)},
  162. height: {to: me.adjustHeight(height)}},
  163. me.preanim(arguments, 4),
  164. 'motion');
  165. }
  166. return me;
  167. },
  168. <div id="method-Ext.Element-setRegion"></div>/**
  169. * Sets the element's position and size the specified region. If animation is true then width, height, x and y will be animated concurrently.
  170. * @param {Ext.lib.Region} region The region to fill
  171. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  172. * @return {Ext.Element} this
  173. */
  174. setRegion : function(region, animate) {
  175. return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));
  176. }
  177. });</pre>
  178. </body>
  179. </html>