Web Interface For Lite Argus Control modules
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.

310 lines
12 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. (function(){
  19. var D = Ext.lib.Dom,
  20. LEFT = "left",
  21. RIGHT = "right",
  22. TOP = "top",
  23. BOTTOM = "bottom",
  24. POSITION = "position",
  25. STATIC = "static",
  26. RELATIVE = "relative",
  27. AUTO = "auto",
  28. ZINDEX = "z-index";
  29. Ext.Element.addMethods({
  30. <div id="method-Ext.Element-getX"></div>/**
  31. * Gets the current X position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  32. * @return {Number} The X position of the element
  33. */
  34. getX : function(){
  35. return D.getX(this.dom);
  36. },
  37. <div id="method-Ext.Element-getY"></div>/**
  38. * Gets the current Y position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  39. * @return {Number} The Y position of the element
  40. */
  41. getY : function(){
  42. return D.getY(this.dom);
  43. },
  44. <div id="method-Ext.Element-getXY"></div>/**
  45. * Gets the current position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  46. * @return {Array} The XY position of the element
  47. */
  48. getXY : function(){
  49. return D.getXY(this.dom);
  50. },
  51. <div id="method-Ext.Element-getOffsetsTo"></div>/**
  52. * Returns the offsets of this element from the passed element. Both element must be part of the DOM tree and not have display:none to have page coordinates.
  53. * @param {Mixed} element The element to get the offsets from.
  54. * @return {Array} The XY page offsets (e.g. [100, -200])
  55. */
  56. getOffsetsTo : function(el){
  57. var o = this.getXY(),
  58. e = Ext.fly(el, '_internal').getXY();
  59. return [o[0]-e[0],o[1]-e[1]];
  60. },
  61. <div id="method-Ext.Element-setX"></div>/**
  62. * Sets the X position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  63. * @param {Number} The X position of the element
  64. * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
  65. * @return {Ext.Element} this
  66. */
  67. setX : function(x, animate){
  68. return this.setXY([x, this.getY()], this.animTest(arguments, animate, 1));
  69. },
  70. <div id="method-Ext.Element-setY"></div>/**
  71. * Sets the Y position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  72. * @param {Number} The Y position of the element
  73. * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
  74. * @return {Ext.Element} this
  75. */
  76. setY : function(y, animate){
  77. return this.setXY([this.getX(), y], this.animTest(arguments, animate, 1));
  78. },
  79. <div id="method-Ext.Element-setLeft"></div>/**
  80. * Sets the element's left position directly using CSS style (instead of {@link #setX}).
  81. * @param {String} left The left CSS property value
  82. * @return {Ext.Element} this
  83. */
  84. setLeft : function(left){
  85. this.setStyle(LEFT, this.addUnits(left));
  86. return this;
  87. },
  88. <div id="method-Ext.Element-setTop"></div>/**
  89. * Sets the element's top position directly using CSS style (instead of {@link #setY}).
  90. * @param {String} top The top CSS property value
  91. * @return {Ext.Element} this
  92. */
  93. setTop : function(top){
  94. this.setStyle(TOP, this.addUnits(top));
  95. return this;
  96. },
  97. <div id="method-Ext.Element-setRight"></div>/**
  98. * Sets the element's CSS right style.
  99. * @param {String} right The right CSS property value
  100. * @return {Ext.Element} this
  101. */
  102. setRight : function(right){
  103. this.setStyle(RIGHT, this.addUnits(right));
  104. return this;
  105. },
  106. <div id="method-Ext.Element-setBottom"></div>/**
  107. * Sets the element's CSS bottom style.
  108. * @param {String} bottom The bottom CSS property value
  109. * @return {Ext.Element} this
  110. */
  111. setBottom : function(bottom){
  112. this.setStyle(BOTTOM, this.addUnits(bottom));
  113. return this;
  114. },
  115. <div id="method-Ext.Element-setXY"></div>/**
  116. * Sets the position of the element in page coordinates, regardless of how the element is positioned.
  117. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  118. * @param {Array} pos Contains X & Y [x, y] values for new position (coordinates are page-based)
  119. * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
  120. * @return {Ext.Element} this
  121. */
  122. setXY : function(pos, animate){
  123. var me = this;
  124. if(!animate || !me.anim){
  125. D.setXY(me.dom, pos);
  126. }else{
  127. me.anim({points: {to: pos}}, me.preanim(arguments, 1), 'motion');
  128. }
  129. return me;
  130. },
  131. <div id="method-Ext.Element-setLocation"></div>/**
  132. * Sets the position of the element in page coordinates, regardless of how the element is positioned.
  133. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  134. * @param {Number} x X value for new position (coordinates are page-based)
  135. * @param {Number} y Y value for new position (coordinates are page-based)
  136. * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
  137. * @return {Ext.Element} this
  138. */
  139. setLocation : function(x, y, animate){
  140. return this.setXY([x, y], this.animTest(arguments, animate, 2));
  141. },
  142. <div id="method-Ext.Element-moveTo"></div>/**
  143. * Sets the position of the element in page coordinates, regardless of how the element is positioned.
  144. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  145. * @param {Number} x X value for new position (coordinates are page-based)
  146. * @param {Number} y Y value for new position (coordinates are page-based)
  147. * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
  148. * @return {Ext.Element} this
  149. */
  150. moveTo : function(x, y, animate){
  151. return this.setXY([x, y], this.animTest(arguments, animate, 2));
  152. },
  153. <div id="method-Ext.Element-getLeft"></div>/**
  154. * Gets the left X coordinate
  155. * @param {Boolean} local True to get the local css position instead of page coordinate
  156. * @return {Number}
  157. */
  158. getLeft : function(local){
  159. return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0;
  160. },
  161. <div id="method-Ext.Element-getRight"></div>/**
  162. * Gets the right X coordinate of the element (element X position + element width)
  163. * @param {Boolean} local True to get the local css position instead of page coordinate
  164. * @return {Number}
  165. */
  166. getRight : function(local){
  167. var me = this;
  168. return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;
  169. },
  170. <div id="method-Ext.Element-getTop"></div>/**
  171. * Gets the top Y coordinate
  172. * @param {Boolean} local True to get the local css position instead of page coordinate
  173. * @return {Number}
  174. */
  175. getTop : function(local) {
  176. return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;
  177. },
  178. <div id="method-Ext.Element-getBottom"></div>/**
  179. * Gets the bottom Y coordinate of the element (element Y position + element height)
  180. * @param {Boolean} local True to get the local css position instead of page coordinate
  181. * @return {Number}
  182. */
  183. getBottom : function(local){
  184. var me = this;
  185. return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;
  186. },
  187. <div id="method-Ext.Element-position"></div>/**
  188. * Initializes positioning on this element. If a desired position is not passed, it will make the
  189. * the element positioned relative IF it is not already positioned.
  190. * @param {String} pos (optional) Positioning to use "relative", "absolute" or "fixed"
  191. * @param {Number} zIndex (optional) The zIndex to apply
  192. * @param {Number} x (optional) Set the page X position
  193. * @param {Number} y (optional) Set the page Y position
  194. */
  195. position : function(pos, zIndex, x, y){
  196. var me = this;
  197. if(!pos && me.isStyle(POSITION, STATIC)){
  198. me.setStyle(POSITION, RELATIVE);
  199. } else if(pos) {
  200. me.setStyle(POSITION, pos);
  201. }
  202. if(zIndex){
  203. me.setStyle(ZINDEX, zIndex);
  204. }
  205. if(x || y) me.setXY([x || false, y || false]);
  206. },
  207. <div id="method-Ext.Element-clearPositioning"></div>/**
  208. * Clear positioning back to the default when the document was loaded
  209. * @param {String} value (optional) The value to use for the left,right,top,bottom, defaults to '' (empty string). You could use 'auto'.
  210. * @return {Ext.Element} this
  211. */
  212. clearPositioning : function(value){
  213. value = value || '';
  214. this.setStyle({
  215. left : value,
  216. right : value,
  217. top : value,
  218. bottom : value,
  219. "z-index" : "",
  220. position : STATIC
  221. });
  222. return this;
  223. },
  224. <div id="method-Ext.Element-getPositioning"></div>/**
  225. * Gets an object with all CSS positioning properties. Useful along with setPostioning to get
  226. * snapshot before performing an update and then restoring the element.
  227. * @return {Object}
  228. */
  229. getPositioning : function(){
  230. var l = this.getStyle(LEFT);
  231. var t = this.getStyle(TOP);
  232. return {
  233. "position" : this.getStyle(POSITION),
  234. "left" : l,
  235. "right" : l ? "" : this.getStyle(RIGHT),
  236. "top" : t,
  237. "bottom" : t ? "" : this.getStyle(BOTTOM),
  238. "z-index" : this.getStyle(ZINDEX)
  239. };
  240. },
  241. <div id="method-Ext.Element-setPositioning"></div>/**
  242. * Set positioning with an object returned by getPositioning().
  243. * @param {Object} posCfg
  244. * @return {Ext.Element} this
  245. */
  246. setPositioning : function(pc){
  247. var me = this,
  248. style = me.dom.style;
  249. me.setStyle(pc);
  250. if(pc.right == AUTO){
  251. style.right = "";
  252. }
  253. if(pc.bottom == AUTO){
  254. style.bottom = "";
  255. }
  256. return me;
  257. },
  258. <div id="method-Ext.Element-translatePoints"></div>/**
  259. * Translates the passed page coordinates into left/top css values for this element
  260. * @param {Number/Array} x The page x or an array containing [x, y]
  261. * @param {Number} y (optional) The page y, required if x is not an array
  262. * @return {Object} An object with left and top properties. e.g. {left: (value), top: (value)}
  263. */
  264. translatePoints : function(x, y){
  265. y = isNaN(x[1]) ? y : x[1];
  266. x = isNaN(x[0]) ? x : x[0];
  267. var me = this,
  268. relative = me.isStyle(POSITION, RELATIVE),
  269. o = me.getXY(),
  270. l = parseInt(me.getStyle(LEFT), 10),
  271. t = parseInt(me.getStyle(TOP), 10);
  272. l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);
  273. t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);
  274. return {left: (x - o[0] + l), top: (y - o[1] + t)};
  275. },
  276. animTest : function(args, animate, i) {
  277. return !!animate && this.preanim ? this.preanim(args, i) : false;
  278. }
  279. });
  280. })();</pre>
  281. </body>
  282. </html>