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.

513 lines
20 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. Ext.Element.addMethods(function(){
  19. // local style camelizing for speed
  20. var supports = Ext.supports,
  21. propCache = {},
  22. camelRe = /(-[a-z])/gi,
  23. view = document.defaultView,
  24. opacityRe = /alpha\(opacity=(.*)\)/i,
  25. trimRe = /^\s+|\s+$/g,
  26. EL = Ext.Element,
  27. spacesRe = /\s+/,
  28. wordsRe = /\w/g,
  29. PADDING = "padding",
  30. MARGIN = "margin",
  31. BORDER = "border",
  32. LEFT = "-left",
  33. RIGHT = "-right",
  34. TOP = "-top",
  35. BOTTOM = "-bottom",
  36. WIDTH = "-width",
  37. MATH = Math,
  38. HIDDEN = 'hidden',
  39. ISCLIPPED = 'isClipped',
  40. OVERFLOW = 'overflow',
  41. OVERFLOWX = 'overflow-x',
  42. OVERFLOWY = 'overflow-y',
  43. ORIGINALCLIP = 'originalClip',
  44. // special markup used throughout Ext when box wrapping elements
  45. borders = {l: BORDER + LEFT + WIDTH, r: BORDER + RIGHT + WIDTH, t: BORDER + TOP + WIDTH, b: BORDER + BOTTOM + WIDTH},
  46. paddings = {l: PADDING + LEFT, r: PADDING + RIGHT, t: PADDING + TOP, b: PADDING + BOTTOM},
  47. margins = {l: MARGIN + LEFT, r: MARGIN + RIGHT, t: MARGIN + TOP, b: MARGIN + BOTTOM},
  48. data = Ext.Element.data;
  49. // private
  50. function camelFn(m, a) {
  51. return a.charAt(1).toUpperCase();
  52. }
  53. function chkCache(prop) {
  54. return propCache[prop] || (propCache[prop] = prop == 'float' ? (supports.cssFloat ? 'cssFloat' : 'styleFloat') : prop.replace(camelRe, camelFn));
  55. }
  56. return {
  57. // private ==> used by Fx
  58. adjustWidth : function(width) {
  59. var me = this;
  60. var isNum = (typeof width == "number");
  61. if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
  62. width -= (me.getBorderWidth("lr") + me.getPadding("lr"));
  63. }
  64. return (isNum && width < 0) ? 0 : width;
  65. },
  66. // private ==> used by Fx
  67. adjustHeight : function(height) {
  68. var me = this;
  69. var isNum = (typeof height == "number");
  70. if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
  71. height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
  72. }
  73. return (isNum && height < 0) ? 0 : height;
  74. },
  75. <div id="method-Ext.Element-addClass"></div>/**
  76. * Adds one or more CSS classes to the element. Duplicate classes are automatically filtered out.
  77. * @param {String/Array} className The CSS class to add, or an array of classes
  78. * @return {Ext.Element} this
  79. */
  80. addClass : function(className){
  81. var me = this,
  82. i,
  83. len,
  84. v,
  85. cls = [];
  86. // Separate case is for speed
  87. if (!Ext.isArray(className)) {
  88. if (typeof className == 'string' && !this.hasClass(className)) {
  89. me.dom.className += " " + className;
  90. }
  91. }
  92. else {
  93. for (i = 0, len = className.length; i < len; i++) {
  94. v = className[i];
  95. if (typeof v == 'string' && (' ' + me.dom.className + ' ').indexOf(' ' + v + ' ') == -1) {
  96. cls.push(v);
  97. }
  98. }
  99. if (cls.length) {
  100. me.dom.className += " " + cls.join(" ");
  101. }
  102. }
  103. return me;
  104. },
  105. <div id="method-Ext.Element-removeClass"></div>/**
  106. * Removes one or more CSS classes from the element.
  107. * @param {String/Array} className The CSS class to remove, or an array of classes
  108. * @return {Ext.Element} this
  109. */
  110. removeClass : function(className){
  111. var me = this,
  112. i,
  113. idx,
  114. len,
  115. cls,
  116. elClasses;
  117. if (!Ext.isArray(className)){
  118. className = [className];
  119. }
  120. if (me.dom && me.dom.className) {
  121. elClasses = me.dom.className.replace(trimRe, '').split(spacesRe);
  122. for (i = 0, len = className.length; i < len; i++) {
  123. cls = className[i];
  124. if (typeof cls == 'string') {
  125. cls = cls.replace(trimRe, '');
  126. idx = elClasses.indexOf(cls);
  127. if (idx != -1) {
  128. elClasses.splice(idx, 1);
  129. }
  130. }
  131. }
  132. me.dom.className = elClasses.join(" ");
  133. }
  134. return me;
  135. },
  136. <div id="method-Ext.Element-radioClass"></div>/**
  137. * Adds one or more CSS classes to this element and removes the same class(es) from all siblings.
  138. * @param {String/Array} className The CSS class to add, or an array of classes
  139. * @return {Ext.Element} this
  140. */
  141. radioClass : function(className){
  142. var cn = this.dom.parentNode.childNodes,
  143. v,
  144. i,
  145. len;
  146. className = Ext.isArray(className) ? className : [className];
  147. for (i = 0, len = cn.length; i < len; i++) {
  148. v = cn[i];
  149. if (v && v.nodeType == 1) {
  150. Ext.fly(v, '_internal').removeClass(className);
  151. }
  152. };
  153. return this.addClass(className);
  154. },
  155. <div id="method-Ext.Element-toggleClass"></div>/**
  156. * Toggles the specified CSS class on this element (removes it if it already exists, otherwise adds it).
  157. * @param {String} className The CSS class to toggle
  158. * @return {Ext.Element} this
  159. */
  160. toggleClass : function(className){
  161. return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
  162. },
  163. <div id="method-Ext.Element-hasClass"></div>/**
  164. * Checks if the specified CSS class exists on this element's DOM node.
  165. * @param {String} className The CSS class to check for
  166. * @return {Boolean} True if the class exists, else false
  167. */
  168. hasClass : function(className){
  169. return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;
  170. },
  171. <div id="method-Ext.Element-replaceClass"></div>/**
  172. * Replaces a CSS class on the element with another. If the old name does not exist, the new name will simply be added.
  173. * @param {String} oldClassName The CSS class to replace
  174. * @param {String} newClassName The replacement CSS class
  175. * @return {Ext.Element} this
  176. */
  177. replaceClass : function(oldClassName, newClassName){
  178. return this.removeClass(oldClassName).addClass(newClassName);
  179. },
  180. isStyle : function(style, val) {
  181. return this.getStyle(style) == val;
  182. },
  183. <div id="method-Ext.Element-getStyle"></div>/**
  184. * Normalizes currentStyle and computedStyle.
  185. * @param {String} property The style property whose value is returned.
  186. * @return {String} The current value of the style property for this element.
  187. */
  188. getStyle : function(){
  189. return view && view.getComputedStyle ?
  190. function(prop){
  191. var el = this.dom,
  192. v,
  193. cs,
  194. out,
  195. display;
  196. if(el == document){
  197. return null;
  198. }
  199. prop = chkCache(prop);
  200. out = (v = el.style[prop]) ? v :
  201. (cs = view.getComputedStyle(el, "")) ? cs[prop] : null;
  202. // Ignore cases when the margin is correctly reported as 0, the bug only shows
  203. // numbers larger.
  204. if(prop == 'marginRight' && out != '0px' && !supports.correctRightMargin){
  205. display = el.style.display;
  206. el.style.display = 'inline-block';
  207. out = view.getComputedStyle(el, '').marginRight;
  208. el.style.display = display;
  209. }
  210. if(prop == 'backgroundColor' && out == 'rgba(0, 0, 0, 0)' && !supports.correctTransparentColor){
  211. out = 'transparent';
  212. }
  213. return out;
  214. } :
  215. function(prop){
  216. var el = this.dom,
  217. m,
  218. cs;
  219. if(el == document) return null;
  220. if (prop == 'opacity') {
  221. if (el.style.filter.match) {
  222. if(m = el.style.filter.match(opacityRe)){
  223. var fv = parseFloat(m[1]);
  224. if(!isNaN(fv)){
  225. return fv ? fv / 100 : 0;
  226. }
  227. }
  228. }
  229. return 1;
  230. }
  231. prop = chkCache(prop);
  232. return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null);
  233. };
  234. }(),
  235. <div id="method-Ext.Element-getColor"></div>/**
  236. * Return the CSS color for the specified CSS attribute. rgb, 3 digit (like #fff) and valid values
  237. * are convert to standard 6 digit hex color.
  238. * @param {String} attr The css attribute
  239. * @param {String} defaultValue The default value to use when a valid color isn't found
  240. * @param {String} prefix (optional) defaults to #. Use an empty string when working with
  241. * color anims.
  242. */
  243. getColor : function(attr, defaultValue, prefix){
  244. var v = this.getStyle(attr),
  245. color = (typeof prefix != 'undefined') ? prefix : '#',
  246. h;
  247. if(!v || (/transparent|inherit/.test(v))) {
  248. return defaultValue;
  249. }
  250. if(/^r/.test(v)){
  251. Ext.each(v.slice(4, v.length -1).split(','), function(s){
  252. h = parseInt(s, 10);
  253. color += (h < 16 ? '0' : '') + h.toString(16);
  254. });
  255. }else{
  256. v = v.replace('#', '');
  257. color += v.length == 3 ? v.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3') : v;
  258. }
  259. return(color.length > 5 ? color.toLowerCase() : defaultValue);
  260. },
  261. <div id="method-Ext.Element-setStyle"></div>/**
  262. * Wrapper for setting style properties, also takes single object parameter of multiple styles.
  263. * @param {String/Object} property The style property to be set, or an object of multiple styles.
  264. * @param {String} value (optional) The value to apply to the given property, or null if an object was passed.
  265. * @return {Ext.Element} this
  266. */
  267. setStyle : function(prop, value){
  268. var tmp, style;
  269. if (typeof prop != 'object') {
  270. tmp = {};
  271. tmp[prop] = value;
  272. prop = tmp;
  273. }
  274. for (style in prop) {
  275. value = prop[style];
  276. style == 'opacity' ?
  277. this.setOpacity(value) :
  278. this.dom.style[chkCache(style)] = value;
  279. }
  280. return this;
  281. },
  282. <div id="method-Ext.Element-setOpacity"></div>/**
  283. * Set the opacity of the element
  284. * @param {Float} opacity The new opacity. 0 = transparent, .5 = 50% visibile, 1 = fully visible, etc
  285. * @param {Boolean/Object} animate (optional) a standard Element animation config object or <tt>true</tt> for
  286. * the default animation (<tt>{duration: .35, easing: 'easeIn'}</tt>)
  287. * @return {Ext.Element} this
  288. */
  289. setOpacity : function(opacity, animate){
  290. var me = this,
  291. s = me.dom.style;
  292. if(!animate || !me.anim){
  293. if(Ext.isIE){
  294. var opac = opacity < 1 ? 'alpha(opacity=' + opacity * 100 + ')' : '',
  295. val = s.filter.replace(opacityRe, '').replace(trimRe, '');
  296. s.zoom = 1;
  297. s.filter = val + (val.length > 0 ? ' ' : '') + opac;
  298. }else{
  299. s.opacity = opacity;
  300. }
  301. }else{
  302. me.anim({opacity: {to: opacity}}, me.preanim(arguments, 1), null, .35, 'easeIn');
  303. }
  304. return me;
  305. },
  306. <div id="method-Ext.Element-clearOpacity"></div>/**
  307. * Clears any opacity settings from this element. Required in some cases for IE.
  308. * @return {Ext.Element} this
  309. */
  310. clearOpacity : function(){
  311. var style = this.dom.style;
  312. if(Ext.isIE){
  313. if(!Ext.isEmpty(style.filter)){
  314. style.filter = style.filter.replace(opacityRe, '').replace(trimRe, '');
  315. }
  316. }else{
  317. style.opacity = style['-moz-opacity'] = style['-khtml-opacity'] = '';
  318. }
  319. return this;
  320. },
  321. <div id="method-Ext.Element-getHeight"></div>/**
  322. * Returns the offset height of the element
  323. * @param {Boolean} contentHeight (optional) true to get the height minus borders and padding
  324. * @return {Number} The element's height
  325. */
  326. getHeight : function(contentHeight){
  327. var me = this,
  328. dom = me.dom,
  329. hidden = Ext.isIE && me.isStyle('display', 'none'),
  330. h = MATH.max(dom.offsetHeight, hidden ? 0 : dom.clientHeight) || 0;
  331. h = !contentHeight ? h : h - me.getBorderWidth("tb") - me.getPadding("tb");
  332. return h < 0 ? 0 : h;
  333. },
  334. <div id="method-Ext.Element-getWidth"></div>/**
  335. * Returns the offset width of the element
  336. * @param {Boolean} contentWidth (optional) true to get the width minus borders and padding
  337. * @return {Number} The element's width
  338. */
  339. getWidth : function(contentWidth){
  340. var me = this,
  341. dom = me.dom,
  342. hidden = Ext.isIE && me.isStyle('display', 'none'),
  343. w = MATH.max(dom.offsetWidth, hidden ? 0 : dom.clientWidth) || 0;
  344. w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr");
  345. return w < 0 ? 0 : w;
  346. },
  347. <div id="method-Ext.Element-setWidth"></div>/**
  348. * Set the width of this Element.
  349. * @param {Mixed} width The new width. This may be one of:<div class="mdetail-params"><ul>
  350. * <li>A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels).</li>
  351. * <li>A String used to set the CSS width style. Animation may <b>not</b> be used.
  352. * </ul></div>
  353. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  354. * @return {Ext.Element} this
  355. */
  356. setWidth : function(width, animate){
  357. var me = this;
  358. width = me.adjustWidth(width);
  359. !animate || !me.anim ?
  360. me.dom.style.width = me.addUnits(width) :
  361. me.anim({width : {to : width}}, me.preanim(arguments, 1));
  362. return me;
  363. },
  364. <div id="method-Ext.Element-setHeight"></div>/**
  365. * Set the height of this Element.
  366. * <pre><code>
  367. // change the height to 200px and animate with default configuration
  368. Ext.fly('elementId').setHeight(200, true);
  369. // change the height to 150px and animate with a custom configuration
  370. Ext.fly('elId').setHeight(150, {
  371. duration : .5, // animation will have a duration of .5 seconds
  372. // will change the content to "finished"
  373. callback: function(){ this.{@link #update}("finished"); }
  374. });
  375. * </code></pre>
  376. * @param {Mixed} height The new height. This may be one of:<div class="mdetail-params"><ul>
  377. * <li>A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels.)</li>
  378. * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>
  379. * </ul></div>
  380. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  381. * @return {Ext.Element} this
  382. */
  383. setHeight : function(height, animate){
  384. var me = this;
  385. height = me.adjustHeight(height);
  386. !animate || !me.anim ?
  387. me.dom.style.height = me.addUnits(height) :
  388. me.anim({height : {to : height}}, me.preanim(arguments, 1));
  389. return me;
  390. },
  391. <div id="method-Ext.Element-getBorderWidth"></div>/**
  392. * Gets the width of the border(s) for the specified side(s)
  393. * @param {String} side Can be t, l, r, b or any combination of those to add multiple values. For example,
  394. * passing <tt>'lr'</tt> would get the border <b><u>l</u></b>eft width + the border <b><u>r</u></b>ight width.
  395. * @return {Number} The width of the sides passed added together
  396. */
  397. getBorderWidth : function(side){
  398. return this.addStyles(side, borders);
  399. },
  400. <div id="method-Ext.Element-getPadding"></div>/**
  401. * Gets the width of the padding(s) for the specified side(s)
  402. * @param {String} side Can be t, l, r, b or any combination of those to add multiple values. For example,
  403. * passing <tt>'lr'</tt> would get the padding <b><u>l</u></b>eft + the padding <b><u>r</u></b>ight.
  404. * @return {Number} The padding of the sides passed added together
  405. */
  406. getPadding : function(side){
  407. return this.addStyles(side, paddings);
  408. },
  409. <div id="method-Ext.Element-clip"></div>/**
  410. * Store the current overflow setting and clip overflow on the element - use <tt>{@link #unclip}</tt> to remove
  411. * @return {Ext.Element} this
  412. */
  413. clip : function(){
  414. var me = this,
  415. dom = me.dom;
  416. if(!data(dom, ISCLIPPED)){
  417. data(dom, ISCLIPPED, true);
  418. data(dom, ORIGINALCLIP, {
  419. o: me.getStyle(OVERFLOW),
  420. x: me.getStyle(OVERFLOWX),
  421. y: me.getStyle(OVERFLOWY)
  422. });
  423. me.setStyle(OVERFLOW, HIDDEN);
  424. me.setStyle(OVERFLOWX, HIDDEN);
  425. me.setStyle(OVERFLOWY, HIDDEN);
  426. }
  427. return me;
  428. },
  429. <div id="method-Ext.Element-unclip"></div>/**
  430. * Return clipping (overflow) to original clipping before <tt>{@link #clip}</tt> was called
  431. * @return {Ext.Element} this
  432. */
  433. unclip : function(){
  434. var me = this,
  435. dom = me.dom;
  436. if(data(dom, ISCLIPPED)){
  437. data(dom, ISCLIPPED, false);
  438. var o = data(dom, ORIGINALCLIP);
  439. if(o.o){
  440. me.setStyle(OVERFLOW, o.o);
  441. }
  442. if(o.x){
  443. me.setStyle(OVERFLOWX, o.x);
  444. }
  445. if(o.y){
  446. me.setStyle(OVERFLOWY, o.y);
  447. }
  448. }
  449. return me;
  450. },
  451. // private
  452. addStyles : function(sides, styles){
  453. var ttlSize = 0,
  454. sidesArr = sides.match(wordsRe),
  455. side,
  456. size,
  457. i,
  458. len = sidesArr.length;
  459. for (i = 0; i < len; i++) {
  460. side = sidesArr[i];
  461. size = side && parseInt(this.getStyle(styles[side]), 10);
  462. if (size) {
  463. ttlSize += MATH.abs(size);
  464. }
  465. }
  466. return ttlSize;
  467. },
  468. margins : margins
  469. };
  470. }()
  471. );
  472. </pre>
  473. </body>
  474. </html>