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.

370 lines
16 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. // special markup used throughout Ext when box wrapping elements
  19. Ext.Element.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
  20. Ext.Element.addMethods(function(){
  21. var INTERNAL = "_internal",
  22. pxMatch = /(\d+\.?\d+)px/;
  23. return {
  24. <div id="method-Ext.Element-applyStyles"></div>/**
  25. * More flexible version of {@link #setStyle} for setting style properties.
  26. * @param {String/Object/Function} styles A style specification string, e.g. "width:100px", or object in the form {width:"100px"}, or
  27. * a function which returns such a specification.
  28. * @return {Ext.Element} this
  29. */
  30. applyStyles : function(style){
  31. Ext.DomHelper.applyStyles(this.dom, style);
  32. return this;
  33. },
  34. <div id="method-Ext.Element-getStyles"></div>/**
  35. * Returns an object with properties matching the styles requested.
  36. * For example, el.getStyles('color', 'font-size', 'width') might return
  37. * {'color': '#FFFFFF', 'font-size': '13px', 'width': '100px'}.
  38. * @param {String} style1 A style name
  39. * @param {String} style2 A style name
  40. * @param {String} etc.
  41. * @return {Object} The style object
  42. */
  43. getStyles : function(){
  44. var ret = {};
  45. Ext.each(arguments, function(v) {
  46. ret[v] = this.getStyle(v);
  47. },
  48. this);
  49. return ret;
  50. },
  51. // private ==> used by ext full
  52. setOverflow : function(v){
  53. var dom = this.dom;
  54. if(v=='auto' && Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
  55. dom.style.overflow = 'hidden';
  56. (function(){dom.style.overflow = 'auto';}).defer(1);
  57. }else{
  58. dom.style.overflow = v;
  59. }
  60. },
  61. <div id="method-Ext.Element-boxWrap"></div>/**
  62. * <p>Wraps the specified element with a special 9 element markup/CSS block that renders by default as
  63. * a gray container with a gradient background, rounded corners and a 4-way shadow.</p>
  64. * <p>This special markup is used throughout Ext when box wrapping elements ({@link Ext.Button},
  65. * {@link Ext.Panel} when <tt>{@link Ext.Panel#frame frame=true}</tt>, {@link Ext.Window}). The markup
  66. * is of this form:</p>
  67. * <pre><code>
  68. Ext.Element.boxMarkup =
  69. &#39;&lt;div class="{0}-tl">&lt;div class="{0}-tr">&lt;div class="{0}-tc">&lt;/div>&lt;/div>&lt;/div>
  70. &lt;div class="{0}-ml">&lt;div class="{0}-mr">&lt;div class="{0}-mc">&lt;/div>&lt;/div>&lt;/div>
  71. &lt;div class="{0}-bl">&lt;div class="{0}-br">&lt;div class="{0}-bc">&lt;/div>&lt;/div>&lt;/div>&#39;;
  72. * </code></pre>
  73. * <p>Example usage:</p>
  74. * <pre><code>
  75. // Basic box wrap
  76. Ext.get("foo").boxWrap();
  77. // You can also add a custom class and use CSS inheritance rules to customize the box look.
  78. // 'x-box-blue' is a built-in alternative -- look at the related CSS definitions as an example
  79. // for how to create a custom box wrap style.
  80. Ext.get("foo").boxWrap().addClass("x-box-blue");
  81. * </code></pre>
  82. * @param {String} class (optional) A base CSS class to apply to the containing wrapper element
  83. * (defaults to <tt>'x-box'</tt>). Note that there are a number of CSS rules that are dependent on
  84. * this name to make the overall effect work, so if you supply an alternate base class, make sure you
  85. * also supply all of the necessary rules.
  86. * @return {Ext.Element} The outermost wrapping element of the created box structure.
  87. */
  88. boxWrap : function(cls){
  89. cls = cls || 'x-box';
  90. var el = Ext.get(this.insertHtml("beforeBegin", "<div class='" + cls + "'>" + String.format(Ext.Element.boxMarkup, cls) + "</div>")); //String.format('<div class="{0}">'+Ext.Element.boxMarkup+'</div>', cls)));
  91. Ext.DomQuery.selectNode('.' + cls + '-mc', el.dom).appendChild(this.dom);
  92. return el;
  93. },
  94. <div id="method-Ext.Element-setSize"></div>/**
  95. * Set the size of this Element. If animation is true, both width and height will be animated concurrently.
  96. * @param {Mixed} width The new width. This may be one of:<div class="mdetail-params"><ul>
  97. * <li>A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels).</li>
  98. * <li>A String used to set the CSS width style. Animation may <b>not</b> be used.
  99. * <li>A size object in the format <code>{width: widthValue, height: heightValue}</code>.</li>
  100. * </ul></div>
  101. * @param {Mixed} height The new height. This may be one of:<div class="mdetail-params"><ul>
  102. * <li>A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels).</li>
  103. * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>
  104. * </ul></div>
  105. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  106. * @return {Ext.Element} this
  107. */
  108. setSize : function(width, height, animate){
  109. var me = this;
  110. if(typeof width == 'object'){ // in case of object from getSize()
  111. height = width.height;
  112. width = width.width;
  113. }
  114. width = me.adjustWidth(width);
  115. height = me.adjustHeight(height);
  116. if(!animate || !me.anim){
  117. me.dom.style.width = me.addUnits(width);
  118. me.dom.style.height = me.addUnits(height);
  119. }else{
  120. me.anim({width: {to: width}, height: {to: height}}, me.preanim(arguments, 2));
  121. }
  122. return me;
  123. },
  124. <div id="method-Ext.Element-getComputedHeight"></div>/**
  125. * Returns either the offsetHeight or the height of this element based on CSS height adjusted by padding or borders
  126. * when needed to simulate offsetHeight when offsets aren't available. This may not work on display:none elements
  127. * if a height has not been set using CSS.
  128. * @return {Number}
  129. */
  130. getComputedHeight : function(){
  131. var me = this,
  132. h = Math.max(me.dom.offsetHeight, me.dom.clientHeight);
  133. if(!h){
  134. h = parseFloat(me.getStyle('height')) || 0;
  135. if(!me.isBorderBox()){
  136. h += me.getFrameWidth('tb');
  137. }
  138. }
  139. return h;
  140. },
  141. <div id="method-Ext.Element-getComputedWidth"></div>/**
  142. * Returns either the offsetWidth or the width of this element based on CSS width adjusted by padding or borders
  143. * when needed to simulate offsetWidth when offsets aren't available. This may not work on display:none elements
  144. * if a width has not been set using CSS.
  145. * @return {Number}
  146. */
  147. getComputedWidth : function(){
  148. var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
  149. if(!w){
  150. w = parseFloat(this.getStyle('width')) || 0;
  151. if(!this.isBorderBox()){
  152. w += this.getFrameWidth('lr');
  153. }
  154. }
  155. return w;
  156. },
  157. <div id="method-Ext.Element-getFrameWidth"></div>/**
  158. * Returns the sum width of the padding and borders for the passed "sides". See getBorderWidth()
  159. for more information about the sides.
  160. * @param {String} sides
  161. * @return {Number}
  162. */
  163. getFrameWidth : function(sides, onlyContentBox){
  164. return onlyContentBox && this.isBorderBox() ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));
  165. },
  166. <div id="method-Ext.Element-addClassOnOver"></div>/**
  167. * Sets up event handlers to add and remove a css class when the mouse is over this element
  168. * @param {String} className
  169. * @return {Ext.Element} this
  170. */
  171. addClassOnOver : function(className){
  172. this.hover(
  173. function(){
  174. Ext.fly(this, INTERNAL).addClass(className);
  175. },
  176. function(){
  177. Ext.fly(this, INTERNAL).removeClass(className);
  178. }
  179. );
  180. return this;
  181. },
  182. <div id="method-Ext.Element-addClassOnFocus"></div>/**
  183. * Sets up event handlers to add and remove a css class when this element has the focus
  184. * @param {String} className
  185. * @return {Ext.Element} this
  186. */
  187. addClassOnFocus : function(className){
  188. this.on("focus", function(){
  189. Ext.fly(this, INTERNAL).addClass(className);
  190. }, this.dom);
  191. this.on("blur", function(){
  192. Ext.fly(this, INTERNAL).removeClass(className);
  193. }, this.dom);
  194. return this;
  195. },
  196. <div id="method-Ext.Element-addClassOnClick"></div>/**
  197. * Sets up event handlers to add and remove a css class when the mouse is down and then up on this element (a click effect)
  198. * @param {String} className
  199. * @return {Ext.Element} this
  200. */
  201. addClassOnClick : function(className){
  202. var dom = this.dom;
  203. this.on("mousedown", function(){
  204. Ext.fly(dom, INTERNAL).addClass(className);
  205. var d = Ext.getDoc(),
  206. fn = function(){
  207. Ext.fly(dom, INTERNAL).removeClass(className);
  208. d.removeListener("mouseup", fn);
  209. };
  210. d.on("mouseup", fn);
  211. });
  212. return this;
  213. },
  214. <div id="method-Ext.Element-getViewSize"></div>/**
  215. * <p>Returns the dimensions of the element available to lay content out in.<p>
  216. * <p>If the element (or any ancestor element) has CSS style <code>display : none</code>, the dimensions will be zero.</p>
  217. * example:<pre><code>
  218. var vpSize = Ext.getBody().getViewSize();
  219. // all Windows created afterwards will have a default value of 90% height and 95% width
  220. Ext.Window.override({
  221. width: vpSize.width * 0.9,
  222. height: vpSize.height * 0.95
  223. });
  224. // To handle window resizing you would have to hook onto onWindowResize.
  225. * </code></pre>
  226. *
  227. * getViewSize utilizes clientHeight/clientWidth which excludes sizing of scrollbars.
  228. * To obtain the size including scrollbars, use getStyleSize
  229. *
  230. * Sizing of the document body is handled at the adapter level which handles special cases for IE and strict modes, etc.
  231. */
  232. getViewSize : function(){
  233. var doc = document,
  234. d = this.dom,
  235. isDoc = (d == doc || d == doc.body);
  236. // If the body, use Ext.lib.Dom
  237. if (isDoc) {
  238. var extdom = Ext.lib.Dom;
  239. return {
  240. width : extdom.getViewWidth(),
  241. height : extdom.getViewHeight()
  242. };
  243. // Else use clientHeight/clientWidth
  244. } else {
  245. return {
  246. width : d.clientWidth,
  247. height : d.clientHeight
  248. };
  249. }
  250. },
  251. <div id="method-Ext.Element-getStyleSize"></div>/**
  252. * <p>Returns the dimensions of the element available to lay content out in.<p>
  253. *
  254. * getStyleSize utilizes prefers style sizing if present, otherwise it chooses the larger of offsetHeight/clientHeight and offsetWidth/clientWidth.
  255. * To obtain the size excluding scrollbars, use getViewSize
  256. *
  257. * Sizing of the document body is handled at the adapter level which handles special cases for IE and strict modes, etc.
  258. */
  259. getStyleSize : function(){
  260. var me = this,
  261. w, h,
  262. doc = document,
  263. d = this.dom,
  264. isDoc = (d == doc || d == doc.body),
  265. s = d.style;
  266. // If the body, use Ext.lib.Dom
  267. if (isDoc) {
  268. var extdom = Ext.lib.Dom;
  269. return {
  270. width : extdom.getViewWidth(),
  271. height : extdom.getViewHeight()
  272. };
  273. }
  274. // Use Styles if they are set
  275. if(s.width && s.width != 'auto'){
  276. w = parseFloat(s.width);
  277. if(me.isBorderBox()){
  278. w -= me.getFrameWidth('lr');
  279. }
  280. }
  281. // Use Styles if they are set
  282. if(s.height && s.height != 'auto'){
  283. h = parseFloat(s.height);
  284. if(me.isBorderBox()){
  285. h -= me.getFrameWidth('tb');
  286. }
  287. }
  288. // Use getWidth/getHeight if style not set.
  289. return {width: w || me.getWidth(true), height: h || me.getHeight(true)};
  290. },
  291. <div id="method-Ext.Element-getSize"></div>/**
  292. * Returns the size of the element.
  293. * @param {Boolean} contentSize (optional) true to get the width/size minus borders and padding
  294. * @return {Object} An object containing the element's size {width: (element width), height: (element height)}
  295. */
  296. getSize : function(contentSize){
  297. return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
  298. },
  299. <div id="method-Ext.Element-repaint"></div>/**
  300. * Forces the browser to repaint this element
  301. * @return {Ext.Element} this
  302. */
  303. repaint : function(){
  304. var dom = this.dom;
  305. this.addClass("x-repaint");
  306. setTimeout(function(){
  307. Ext.fly(dom).removeClass("x-repaint");
  308. }, 1);
  309. return this;
  310. },
  311. <div id="method-Ext.Element-unselectable"></div>/**
  312. * Disables text selection for this element (normalized across browsers)
  313. * @return {Ext.Element} this
  314. */
  315. unselectable : function(){
  316. this.dom.unselectable = "on";
  317. return this.swallowEvent("selectstart", true).
  318. applyStyles("-moz-user-select:none;-khtml-user-select:none;").
  319. addClass("x-unselectable");
  320. },
  321. <div id="method-Ext.Element-getMargins"></div>/**
  322. * Returns an object with properties top, left, right and bottom representing the margins of this element unless sides is passed,
  323. * then it returns the calculated width of the sides (see getPadding)
  324. * @param {String} sides (optional) Any combination of l, r, t, b to get the sum of those sides
  325. * @return {Object/Number}
  326. */
  327. getMargins : function(side){
  328. var me = this,
  329. key,
  330. hash = {t:"top", l:"left", r:"right", b: "bottom"},
  331. o = {};
  332. if (!side) {
  333. for (key in me.margins){
  334. o[hash[key]] = parseFloat(me.getStyle(me.margins[key])) || 0;
  335. }
  336. return o;
  337. } else {
  338. return me.addStyles.call(me, side, me.margins);
  339. }
  340. }
  341. };
  342. }());
  343. </pre>
  344. </body>
  345. </html>