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.

484 lines
15 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. (function(){
  16. var EXTLIB = Ext.lib,
  17. noNegatives = /width|height|opacity|padding/i,
  18. offsetAttribute = /^((width|height)|(top|left))$/,
  19. defaultUnit = /width|height|top$|bottom$|left$|right$/i,
  20. offsetUnit = /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i,
  21. isset = function(v){
  22. return typeof v !== 'undefined';
  23. },
  24. now = function(){
  25. return new Date();
  26. };
  27. EXTLIB.Anim = {
  28. motion : function(el, args, duration, easing, cb, scope) {
  29. return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
  30. },
  31. run : function(el, args, duration, easing, cb, scope, type) {
  32. type = type || Ext.lib.AnimBase;
  33. if (typeof easing == "string") {
  34. easing = Ext.lib.Easing[easing];
  35. }
  36. var anim = new type(el, args, duration, easing);
  37. anim.animateX(function() {
  38. if(Ext.isFunction(cb)){
  39. cb.call(scope);
  40. }
  41. });
  42. return anim;
  43. }
  44. };
  45. EXTLIB.AnimBase = function(el, attributes, duration, method) {
  46. if (el) {
  47. this.init(el, attributes, duration, method);
  48. }
  49. };
  50. EXTLIB.AnimBase.prototype = {
  51. doMethod: function(attr, start, end) {
  52. var me = this;
  53. return me.method(me.curFrame, start, end - start, me.totalFrames);
  54. },
  55. setAttr: function(attr, val, unit) {
  56. if (noNegatives.test(attr) && val < 0) {
  57. val = 0;
  58. }
  59. Ext.fly(this.el, '_anim').setStyle(attr, val + unit);
  60. },
  61. getAttr: function(attr) {
  62. var el = Ext.fly(this.el),
  63. val = el.getStyle(attr),
  64. a = offsetAttribute.exec(attr) || [];
  65. if (val !== 'auto' && !offsetUnit.test(val)) {
  66. return parseFloat(val);
  67. }
  68. return (!!(a[2]) || (el.getStyle('position') == 'absolute' && !!(a[3]))) ? el.dom['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)] : 0;
  69. },
  70. getDefaultUnit: function(attr) {
  71. return defaultUnit.test(attr) ? 'px' : '';
  72. },
  73. animateX : function(callback, scope) {
  74. var me = this,
  75. f = function() {
  76. me.onComplete.removeListener(f);
  77. if (Ext.isFunction(callback)) {
  78. callback.call(scope || me, me);
  79. }
  80. };
  81. me.onComplete.addListener(f, me);
  82. me.animate();
  83. },
  84. setRunAttr: function(attr) {
  85. var me = this,
  86. a = this.attributes[attr],
  87. to = a.to,
  88. by = a.by,
  89. from = a.from,
  90. unit = a.unit,
  91. ra = (this.runAttrs[attr] = {}),
  92. end;
  93. if (!isset(to) && !isset(by)){
  94. return false;
  95. }
  96. var start = isset(from) ? from : me.getAttr(attr);
  97. if (isset(to)) {
  98. end = to;
  99. }else if(isset(by)) {
  100. if (Ext.isArray(start)){
  101. end = [];
  102. for(var i=0,len=start.length; i<len; i++) {
  103. end[i] = start[i] + by[i];
  104. }
  105. }else{
  106. end = start + by;
  107. }
  108. }
  109. Ext.apply(ra, {
  110. start: start,
  111. end: end,
  112. unit: isset(unit) ? unit : me.getDefaultUnit(attr)
  113. });
  114. },
  115. init: function(el, attributes, duration, method) {
  116. var me = this,
  117. actualFrames = 0,
  118. mgr = EXTLIB.AnimMgr;
  119. Ext.apply(me, {
  120. isAnimated: false,
  121. startTime: null,
  122. el: Ext.getDom(el),
  123. attributes: attributes || {},
  124. duration: duration || 1,
  125. method: method || EXTLIB.Easing.easeNone,
  126. useSec: true,
  127. curFrame: 0,
  128. totalFrames: mgr.fps,
  129. runAttrs: {},
  130. animate: function(){
  131. var me = this,
  132. d = me.duration;
  133. if(me.isAnimated){
  134. return false;
  135. }
  136. me.curFrame = 0;
  137. me.totalFrames = me.useSec ? Math.ceil(mgr.fps * d) : d;
  138. mgr.registerElement(me);
  139. },
  140. stop: function(finish){
  141. var me = this;
  142. if(finish){
  143. me.curFrame = me.totalFrames;
  144. me._onTween.fire();
  145. }
  146. mgr.stop(me);
  147. }
  148. });
  149. var onStart = function(){
  150. var me = this,
  151. attr;
  152. me.onStart.fire();
  153. me.runAttrs = {};
  154. for(attr in this.attributes){
  155. this.setRunAttr(attr);
  156. }
  157. me.isAnimated = true;
  158. me.startTime = now();
  159. actualFrames = 0;
  160. };
  161. var onTween = function(){
  162. var me = this;
  163. me.onTween.fire({
  164. duration: now() - me.startTime,
  165. curFrame: me.curFrame
  166. });
  167. var ra = me.runAttrs;
  168. for (var attr in ra) {
  169. this.setAttr(attr, me.doMethod(attr, ra[attr].start, ra[attr].end), ra[attr].unit);
  170. }
  171. ++actualFrames;
  172. };
  173. var onComplete = function() {
  174. var me = this,
  175. actual = (now() - me.startTime) / 1000,
  176. data = {
  177. duration: actual,
  178. frames: actualFrames,
  179. fps: actualFrames / actual
  180. };
  181. me.isAnimated = false;
  182. actualFrames = 0;
  183. me.onComplete.fire(data);
  184. };
  185. me.onStart = new Ext.util.Event(me);
  186. me.onTween = new Ext.util.Event(me);
  187. me.onComplete = new Ext.util.Event(me);
  188. (me._onStart = new Ext.util.Event(me)).addListener(onStart);
  189. (me._onTween = new Ext.util.Event(me)).addListener(onTween);
  190. (me._onComplete = new Ext.util.Event(me)).addListener(onComplete);
  191. }
  192. };
  193. Ext.lib.AnimMgr = new function() {
  194. var me = this,
  195. thread = null,
  196. queue = [],
  197. tweenCount = 0;
  198. Ext.apply(me, {
  199. fps: 1000,
  200. delay: 1,
  201. registerElement: function(tween){
  202. queue.push(tween);
  203. ++tweenCount;
  204. tween._onStart.fire();
  205. me.start();
  206. },
  207. unRegister: function(tween, index){
  208. tween._onComplete.fire();
  209. index = index || getIndex(tween);
  210. if (index != -1) {
  211. queue.splice(index, 1);
  212. }
  213. if (--tweenCount <= 0) {
  214. me.stop();
  215. }
  216. },
  217. start: function(){
  218. if(thread === null){
  219. thread = setInterval(me.run, me.delay);
  220. }
  221. },
  222. stop: function(tween){
  223. if(!tween){
  224. clearInterval(thread);
  225. for(var i = 0, len = queue.length; i < len; ++i){
  226. if(queue[0].isAnimated){
  227. me.unRegister(queue[0], 0);
  228. }
  229. }
  230. queue = [];
  231. thread = null;
  232. tweenCount = 0;
  233. }else{
  234. me.unRegister(tween);
  235. }
  236. },
  237. run: function(){
  238. var tf, i, len, tween;
  239. for(i = 0, len = queue.length; i<len; i++) {
  240. tween = queue[i];
  241. if(tween && tween.isAnimated){
  242. tf = tween.totalFrames;
  243. if(tween.curFrame < tf || tf === null){
  244. ++tween.curFrame;
  245. if(tween.useSec){
  246. correctFrame(tween);
  247. }
  248. tween._onTween.fire();
  249. }else{
  250. me.stop(tween);
  251. }
  252. }
  253. }
  254. }
  255. });
  256. var getIndex = function(anim) {
  257. var i, len;
  258. for(i = 0, len = queue.length; i<len; i++) {
  259. if(queue[i] === anim) {
  260. return i;
  261. }
  262. }
  263. return -1;
  264. };
  265. var correctFrame = function(tween) {
  266. var frames = tween.totalFrames,
  267. frame = tween.curFrame,
  268. duration = tween.duration,
  269. expected = (frame * duration * 1000 / frames),
  270. elapsed = (now() - tween.startTime),
  271. tweak = 0;
  272. if(elapsed < duration * 1000){
  273. tweak = Math.round((elapsed / expected - 1) * frame);
  274. }else{
  275. tweak = frames - (frame + 1);
  276. }
  277. if(tweak > 0 && isFinite(tweak)){
  278. if(tween.curFrame + tweak >= frames){
  279. tweak = frames - (frame + 1);
  280. }
  281. tween.curFrame += tweak;
  282. }
  283. };
  284. };
  285. EXTLIB.Bezier = new function() {
  286. this.getPosition = function(points, t) {
  287. var n = points.length,
  288. tmp = [],
  289. c = 1 - t,
  290. i,
  291. j;
  292. for (i = 0; i < n; ++i) {
  293. tmp[i] = [points[i][0], points[i][1]];
  294. }
  295. for (j = 1; j < n; ++j) {
  296. for (i = 0; i < n - j; ++i) {
  297. tmp[i][0] = c * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
  298. tmp[i][1] = c * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
  299. }
  300. }
  301. return [ tmp[0][0], tmp[0][1] ];
  302. };
  303. };
  304. EXTLIB.Easing = {
  305. easeNone: function (t, b, c, d) {
  306. return c * t / d + b;
  307. },
  308. easeIn: function (t, b, c, d) {
  309. return c * (t /= d) * t + b;
  310. },
  311. easeOut: function (t, b, c, d) {
  312. return -c * (t /= d) * (t - 2) + b;
  313. }
  314. };
  315. (function() {
  316. EXTLIB.Motion = function(el, attributes, duration, method) {
  317. if (el) {
  318. EXTLIB.Motion.superclass.constructor.call(this, el, attributes, duration, method);
  319. }
  320. };
  321. Ext.extend(EXTLIB.Motion, Ext.lib.AnimBase);
  322. var superclass = EXTLIB.Motion.superclass,
  323. pointsRe = /^points$/i;
  324. Ext.apply(EXTLIB.Motion.prototype, {
  325. setAttr: function(attr, val, unit){
  326. var me = this,
  327. setAttr = superclass.setAttr;
  328. if (pointsRe.test(attr)) {
  329. unit = unit || 'px';
  330. setAttr.call(me, 'left', val[0], unit);
  331. setAttr.call(me, 'top', val[1], unit);
  332. } else {
  333. setAttr.call(me, attr, val, unit);
  334. }
  335. },
  336. getAttr: function(attr){
  337. var me = this,
  338. getAttr = superclass.getAttr;
  339. return pointsRe.test(attr) ? [getAttr.call(me, 'left'), getAttr.call(me, 'top')] : getAttr.call(me, attr);
  340. },
  341. doMethod: function(attr, start, end){
  342. var me = this;
  343. return pointsRe.test(attr)
  344. ? EXTLIB.Bezier.getPosition(me.runAttrs[attr], me.method(me.curFrame, 0, 100, me.totalFrames) / 100)
  345. : superclass.doMethod.call(me, attr, start, end);
  346. },
  347. setRunAttr: function(attr){
  348. if(pointsRe.test(attr)){
  349. var me = this,
  350. el = this.el,
  351. points = this.attributes.points,
  352. control = points.control || [],
  353. from = points.from,
  354. to = points.to,
  355. by = points.by,
  356. DOM = EXTLIB.Dom,
  357. start,
  358. i,
  359. end,
  360. len,
  361. ra;
  362. if(control.length > 0 && !Ext.isArray(control[0])){
  363. control = [control];
  364. }else{
  365. /*
  366. var tmp = [];
  367. for (i = 0,len = control.length; i < len; ++i) {
  368. tmp[i] = control[i];
  369. }
  370. control = tmp;
  371. */
  372. }
  373. Ext.fly(el, '_anim').position();
  374. DOM.setXY(el, isset(from) ? from : DOM.getXY(el));
  375. start = me.getAttr('points');
  376. if(isset(to)){
  377. end = translateValues.call(me, to, start);
  378. for (i = 0,len = control.length; i < len; ++i) {
  379. control[i] = translateValues.call(me, control[i], start);
  380. }
  381. } else if (isset(by)) {
  382. end = [start[0] + by[0], start[1] + by[1]];
  383. for (i = 0,len = control.length; i < len; ++i) {
  384. control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
  385. }
  386. }
  387. ra = this.runAttrs[attr] = [start];
  388. if (control.length > 0) {
  389. ra = ra.concat(control);
  390. }
  391. ra[ra.length] = end;
  392. }else{
  393. superclass.setRunAttr.call(this, attr);
  394. }
  395. }
  396. });
  397. var translateValues = function(val, start) {
  398. var pageXY = EXTLIB.Dom.getXY(this.el);
  399. return [val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1]];
  400. };
  401. })();
  402. })();</pre>
  403. </body>
  404. </html>