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.

1122 lines
38 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. // contants
  17. var NULL = null,
  18. UNDEFINED = undefined,
  19. TRUE = true,
  20. FALSE = false,
  21. SETX = "setX",
  22. SETY = "setY",
  23. SETXY = "setXY",
  24. LEFT = "left",
  25. BOTTOM = "bottom",
  26. TOP = "top",
  27. RIGHT = "right",
  28. HEIGHT = "height",
  29. WIDTH = "width",
  30. POINTS = "points",
  31. HIDDEN = "hidden",
  32. ABSOLUTE = "absolute",
  33. VISIBLE = "visible",
  34. MOTION = "motion",
  35. POSITION = "position",
  36. EASEOUT = "easeOut",
  37. /*
  38. * Use a light flyweight here since we are using so many callbacks and are always assured a DOM element
  39. */
  40. flyEl = new Ext.Element.Flyweight(),
  41. queues = {},
  42. getObject = function(o){
  43. return o || {};
  44. },
  45. fly = function(dom){
  46. flyEl.dom = dom;
  47. flyEl.id = Ext.id(dom);
  48. return flyEl;
  49. },
  50. /*
  51. * Queueing now stored outside of the element due to closure issues
  52. */
  53. getQueue = function(id){
  54. if(!queues[id]){
  55. queues[id] = [];
  56. }
  57. return queues[id];
  58. },
  59. setQueue = function(id, value){
  60. queues[id] = value;
  61. };
  62. //Notifies Element that fx methods are available
  63. Ext.enableFx = TRUE;
  64. <div id="cls-Ext.Fx"></div>/**
  65. * @class Ext.Fx
  66. * <p>A class to provide basic animation and visual effects support. <b>Note:</b> This class is automatically applied
  67. * to the {@link Ext.Element} interface when included, so all effects calls should be performed via {@link Ext.Element}.
  68. * Conversely, since the effects are not actually defined in {@link Ext.Element}, Ext.Fx <b>must</b> be
  69. * {@link Ext#enableFx included} in order for the Element effects to work.</p><br/>
  70. *
  71. * <p><b><u>Method Chaining</u></b></p>
  72. * <p>It is important to note that although the Fx methods and many non-Fx Element methods support "method chaining" in that
  73. * they return the Element object itself as the method return value, it is not always possible to mix the two in a single
  74. * method chain. The Fx methods use an internal effects queue so that each effect can be properly timed and sequenced.
  75. * Non-Fx methods, on the other hand, have no such internal queueing and will always execute immediately. For this reason,
  76. * while it may be possible to mix certain Fx and non-Fx method calls in a single chain, it may not always provide the
  77. * expected results and should be done with care. Also see <tt>{@link #callback}</tt>.</p><br/>
  78. *
  79. * <p><b><u>Anchor Options for Motion Effects</u></b></p>
  80. * <p>Motion effects support 8-way anchoring, meaning that you can choose one of 8 different anchor points on the Element
  81. * that will serve as either the start or end point of the animation. Following are all of the supported anchor positions:</p>
  82. <pre>
  83. Value Description
  84. ----- -----------------------------
  85. tl The top left corner
  86. t The center of the top edge
  87. tr The top right corner
  88. l The center of the left edge
  89. r The center of the right edge
  90. bl The bottom left corner
  91. b The center of the bottom edge
  92. br The bottom right corner
  93. </pre>
  94. * <b>Note</b>: some Fx methods accept specific custom config parameters. The options shown in the Config Options
  95. * section below are common options that can be passed to any Fx method unless otherwise noted.</b>
  96. *
  97. * @cfg {Function} callback A function called when the effect is finished. Note that effects are queued internally by the
  98. * Fx class, so a callback is not required to specify another effect -- effects can simply be chained together
  99. * and called in sequence (see note for <b><u>Method Chaining</u></b> above), for example:<pre><code>
  100. * el.slideIn().highlight();
  101. * </code></pre>
  102. * The callback is intended for any additional code that should run once a particular effect has completed. The Element
  103. * being operated upon is passed as the first parameter.
  104. *
  105. * @cfg {Object} scope The scope (<code>this</code> reference) in which the <tt>{@link #callback}</tt> function is executed. Defaults to the browser window.
  106. *
  107. * @cfg {String} easing A valid Ext.lib.Easing value for the effect:</p><div class="mdetail-params"><ul>
  108. * <li><b><tt>backBoth</tt></b></li>
  109. * <li><b><tt>backIn</tt></b></li>
  110. * <li><b><tt>backOut</tt></b></li>
  111. * <li><b><tt>bounceBoth</tt></b></li>
  112. * <li><b><tt>bounceIn</tt></b></li>
  113. * <li><b><tt>bounceOut</tt></b></li>
  114. * <li><b><tt>easeBoth</tt></b></li>
  115. * <li><b><tt>easeBothStrong</tt></b></li>
  116. * <li><b><tt>easeIn</tt></b></li>
  117. * <li><b><tt>easeInStrong</tt></b></li>
  118. * <li><b><tt>easeNone</tt></b></li>
  119. * <li><b><tt>easeOut</tt></b></li>
  120. * <li><b><tt>easeOutStrong</tt></b></li>
  121. * <li><b><tt>elasticBoth</tt></b></li>
  122. * <li><b><tt>elasticIn</tt></b></li>
  123. * <li><b><tt>elasticOut</tt></b></li>
  124. * </ul></div>
  125. *
  126. * @cfg {String} afterCls A css class to apply after the effect
  127. * @cfg {Number} duration The length of time (in seconds) that the effect should last
  128. *
  129. * @cfg {Number} endOpacity Only applicable for {@link #fadeIn} or {@link #fadeOut}, a number between
  130. * <tt>0</tt> and <tt>1</tt> inclusive to configure the ending opacity value.
  131. *
  132. * @cfg {Boolean} remove Whether the Element should be removed from the DOM and destroyed after the effect finishes
  133. * @cfg {Boolean} useDisplay Whether to use the <i>display</i> CSS property instead of <i>visibility</i> when hiding Elements (only applies to
  134. * effects that end with the element being visually hidden, ignored otherwise)
  135. * @cfg {String/Object/Function} afterStyle A style specification string, e.g. <tt>"width:100px"</tt>, or an object
  136. * in the form <tt>{width:"100px"}</tt>, or a function which returns such a specification that will be applied to the
  137. * Element after the effect finishes.
  138. * @cfg {Boolean} block Whether the effect should block other effects from queueing while it runs
  139. * @cfg {Boolean} concurrent Whether to allow subsequently-queued effects to run at the same time as the current effect, or to ensure that they run in sequence
  140. * @cfg {Boolean} stopFx Whether preceding effects should be stopped and removed before running current effect (only applies to non blocking effects)
  141. */
  142. Ext.Fx = {
  143. // private - calls the function taking arguments from the argHash based on the key. Returns the return value of the function.
  144. // this is useful for replacing switch statements (for example).
  145. switchStatements : function(key, fn, argHash){
  146. return fn.apply(this, argHash[key]);
  147. },
  148. /**
  149. * Slides the element into view. An anchor point can be optionally passed to set the point of
  150. * origin for the slide effect. This function automatically handles wrapping the element with
  151. * a fixed-size container if needed. See the Fx class overview for valid anchor point options.
  152. * Usage:
  153. *<pre><code>
  154. // default: slide the element in from the top
  155. el.slideIn();
  156. // custom: slide the element in from the right with a 2-second duration
  157. el.slideIn('r', { duration: 2 });
  158. // common config options shown with default values
  159. el.slideIn('t', {
  160. easing: 'easeOut',
  161. duration: .5
  162. });
  163. </code></pre>
  164. * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')
  165. * @param {Object} options (optional) Object literal with any of the Fx config options
  166. * @return {Ext.Element} The Element
  167. */
  168. slideIn : function(anchor, o){
  169. o = getObject(o);
  170. var me = this,
  171. dom = me.dom,
  172. st = dom.style,
  173. xy,
  174. r,
  175. b,
  176. wrap,
  177. after,
  178. st,
  179. args,
  180. pt,
  181. bw,
  182. bh;
  183. anchor = anchor || "t";
  184. me.queueFx(o, function(){
  185. xy = fly(dom).getXY();
  186. // fix display to visibility
  187. fly(dom).fixDisplay();
  188. // restore values after effect
  189. r = fly(dom).getFxRestore();
  190. b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
  191. b.right = b.x + b.width;
  192. b.bottom = b.y + b.height;
  193. // fixed size for slide
  194. fly(dom).setWidth(b.width).setHeight(b.height);
  195. // wrap if needed
  196. wrap = fly(dom).fxWrap(r.pos, o, HIDDEN);
  197. st.visibility = VISIBLE;
  198. st.position = ABSOLUTE;
  199. // clear out temp styles after slide and unwrap
  200. function after(){
  201. fly(dom).fxUnwrap(wrap, r.pos, o);
  202. st.width = r.width;
  203. st.height = r.height;
  204. fly(dom).afterFx(o);
  205. }
  206. // time to calculate the positions
  207. pt = {to: [b.x, b.y]};
  208. bw = {to: b.width};
  209. bh = {to: b.height};
  210. function argCalc(wrap, style, ww, wh, sXY, sXYval, s1, s2, w, h, p){
  211. var ret = {};
  212. fly(wrap).setWidth(ww).setHeight(wh);
  213. if(fly(wrap)[sXY]){
  214. fly(wrap)[sXY](sXYval);
  215. }
  216. style[s1] = style[s2] = "0";
  217. if(w){
  218. ret.width = w;
  219. }
  220. if(h){
  221. ret.height = h;
  222. }
  223. if(p){
  224. ret.points = p;
  225. }
  226. return ret;
  227. };
  228. args = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
  229. t : [wrap, st, b.width, 0, NULL, NULL, LEFT, BOTTOM, NULL, bh, NULL],
  230. l : [wrap, st, 0, b.height, NULL, NULL, RIGHT, TOP, bw, NULL, NULL],
  231. r : [wrap, st, b.width, b.height, SETX, b.right, LEFT, TOP, NULL, NULL, pt],
  232. b : [wrap, st, b.width, b.height, SETY, b.bottom, LEFT, TOP, NULL, bh, pt],
  233. tl : [wrap, st, 0, 0, NULL, NULL, RIGHT, BOTTOM, bw, bh, pt],
  234. bl : [wrap, st, 0, 0, SETY, b.y + b.height, RIGHT, TOP, bw, bh, pt],
  235. br : [wrap, st, 0, 0, SETXY, [b.right, b.bottom], LEFT, TOP, bw, bh, pt],
  236. tr : [wrap, st, 0, 0, SETX, b.x + b.width, LEFT, BOTTOM, bw, bh, pt]
  237. });
  238. st.visibility = VISIBLE;
  239. fly(wrap).show();
  240. arguments.callee.anim = fly(wrap).fxanim(args,
  241. o,
  242. MOTION,
  243. .5,
  244. EASEOUT,
  245. after);
  246. });
  247. return me;
  248. },
  249. /**
  250. * Slides the element out of view. An anchor point can be optionally passed to set the end point
  251. * for the slide effect. When the effect is completed, the element will be hidden (visibility =
  252. * 'hidden') but block elements will still take up space in the document. The element must be removed
  253. * from the DOM using the 'remove' config option if desired. This function automatically handles
  254. * wrapping the element with a fixed-size container if needed. See the Fx class overview for valid anchor point options.
  255. * Usage:
  256. *<pre><code>
  257. // default: slide the element out to the top
  258. el.slideOut();
  259. // custom: slide the element out to the right with a 2-second duration
  260. el.slideOut('r', { duration: 2 });
  261. // common config options shown with default values
  262. el.slideOut('t', {
  263. easing: 'easeOut',
  264. duration: .5,
  265. remove: false,
  266. useDisplay: false
  267. });
  268. </code></pre>
  269. * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')
  270. * @param {Object} options (optional) Object literal with any of the Fx config options
  271. * @return {Ext.Element} The Element
  272. */
  273. slideOut : function(anchor, o){
  274. o = getObject(o);
  275. var me = this,
  276. dom = me.dom,
  277. st = dom.style,
  278. xy = me.getXY(),
  279. wrap,
  280. r,
  281. b,
  282. a,
  283. zero = {to: 0};
  284. anchor = anchor || "t";
  285. me.queueFx(o, function(){
  286. // restore values after effect
  287. r = fly(dom).getFxRestore();
  288. b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
  289. b.right = b.x + b.width;
  290. b.bottom = b.y + b.height;
  291. // fixed size for slide
  292. fly(dom).setWidth(b.width).setHeight(b.height);
  293. // wrap if needed
  294. wrap = fly(dom).fxWrap(r.pos, o, VISIBLE);
  295. st.visibility = VISIBLE;
  296. st.position = ABSOLUTE;
  297. fly(wrap).setWidth(b.width).setHeight(b.height);
  298. function after(){
  299. o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
  300. fly(dom).fxUnwrap(wrap, r.pos, o);
  301. st.width = r.width;
  302. st.height = r.height;
  303. fly(dom).afterFx(o);
  304. }
  305. function argCalc(style, s1, s2, p1, v1, p2, v2, p3, v3){
  306. var ret = {};
  307. style[s1] = style[s2] = "0";
  308. ret[p1] = v1;
  309. if(p2){
  310. ret[p2] = v2;
  311. }
  312. if(p3){
  313. ret[p3] = v3;
  314. }
  315. return ret;
  316. };
  317. a = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
  318. t : [st, LEFT, BOTTOM, HEIGHT, zero],
  319. l : [st, RIGHT, TOP, WIDTH, zero],
  320. r : [st, LEFT, TOP, WIDTH, zero, POINTS, {to : [b.right, b.y]}],
  321. b : [st, LEFT, TOP, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
  322. tl : [st, RIGHT, BOTTOM, WIDTH, zero, HEIGHT, zero],
  323. bl : [st, RIGHT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
  324. br : [st, LEFT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x + b.width, b.bottom]}],
  325. tr : [st, LEFT, BOTTOM, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.right, b.y]}]
  326. });
  327. arguments.callee.anim = fly(wrap).fxanim(a,
  328. o,
  329. MOTION,
  330. .5,
  331. EASEOUT,
  332. after);
  333. });
  334. return me;
  335. },
  336. /**
  337. * Fades the element out while slowly expanding it in all directions. When the effect is completed, the
  338. * element will be hidden (visibility = 'hidden') but block elements will still take up space in the document.
  339. * The element must be removed from the DOM using the 'remove' config option if desired.
  340. * Usage:
  341. *<pre><code>
  342. // default
  343. el.puff();
  344. // common config options shown with default values
  345. el.puff({
  346. easing: 'easeOut',
  347. duration: .5,
  348. remove: false,
  349. useDisplay: false
  350. });
  351. </code></pre>
  352. * @param {Object} options (optional) Object literal with any of the Fx config options
  353. * @return {Ext.Element} The Element
  354. */
  355. puff : function(o){
  356. o = getObject(o);
  357. var me = this,
  358. dom = me.dom,
  359. st = dom.style,
  360. width,
  361. height,
  362. r;
  363. me.queueFx(o, function(){
  364. width = fly(dom).getWidth();
  365. height = fly(dom).getHeight();
  366. fly(dom).clearOpacity();
  367. fly(dom).show();
  368. // restore values after effect
  369. r = fly(dom).getFxRestore();
  370. function after(){
  371. o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
  372. fly(dom).clearOpacity();
  373. fly(dom).setPositioning(r.pos);
  374. st.width = r.width;
  375. st.height = r.height;
  376. st.fontSize = '';
  377. fly(dom).afterFx(o);
  378. }
  379. arguments.callee.anim = fly(dom).fxanim({
  380. width : {to : fly(dom).adjustWidth(width * 2)},
  381. height : {to : fly(dom).adjustHeight(height * 2)},
  382. points : {by : [-width * .5, -height * .5]},
  383. opacity : {to : 0},
  384. fontSize: {to : 200, unit: "%"}
  385. },
  386. o,
  387. MOTION,
  388. .5,
  389. EASEOUT,
  390. after);
  391. });
  392. return me;
  393. },
  394. /**
  395. * Blinks the element as if it was clicked and then collapses on its center (similar to switching off a television).
  396. * When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will still
  397. * take up space in the document. The element must be removed from the DOM using the 'remove' config option if desired.
  398. * Usage:
  399. *<pre><code>
  400. // default
  401. el.switchOff();
  402. // all config options shown with default values
  403. el.switchOff({
  404. easing: 'easeIn',
  405. duration: .3,
  406. remove: false,
  407. useDisplay: false
  408. });
  409. </code></pre>
  410. * @param {Object} options (optional) Object literal with any of the Fx config options
  411. * @return {Ext.Element} The Element
  412. */
  413. switchOff : function(o){
  414. o = getObject(o);
  415. var me = this,
  416. dom = me.dom,
  417. st = dom.style,
  418. r;
  419. me.queueFx(o, function(){
  420. fly(dom).clearOpacity();
  421. fly(dom).clip();
  422. // restore values after effect
  423. r = fly(dom).getFxRestore();
  424. function after(){
  425. o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
  426. fly(dom).clearOpacity();
  427. fly(dom).setPositioning(r.pos);
  428. st.width = r.width;
  429. st.height = r.height;
  430. fly(dom).afterFx(o);
  431. };
  432. fly(dom).fxanim({opacity : {to : 0.3}},
  433. NULL,
  434. NULL,
  435. .1,
  436. NULL,
  437. function(){
  438. fly(dom).clearOpacity();
  439. (function(){
  440. fly(dom).fxanim({
  441. height : {to : 1},
  442. points : {by : [0, fly(dom).getHeight() * .5]}
  443. },
  444. o,
  445. MOTION,
  446. 0.3,
  447. 'easeIn',
  448. after);
  449. }).defer(100);
  450. });
  451. });
  452. return me;
  453. },
  454. /**
  455. * Highlights the Element by setting a color (applies to the background-color by default, but can be
  456. * changed using the "attr" config option) and then fading back to the original color. If no original
  457. * color is available, you should provide the "endColor" config option which will be cleared after the animation.
  458. * Usage:
  459. <pre><code>
  460. // default: highlight background to yellow
  461. el.highlight();
  462. // custom: highlight foreground text to blue for 2 seconds
  463. el.highlight("0000ff", { attr: 'color', duration: 2 });
  464. // common config options shown with default values
  465. el.highlight("ffff9c", {
  466. attr: "background-color", //can be any valid CSS property (attribute) that supports a color value
  467. endColor: (current color) or "ffffff",
  468. easing: 'easeIn',
  469. duration: 1
  470. });
  471. </code></pre>
  472. * @param {String} color (optional) The highlight color. Should be a 6 char hex color without the leading # (defaults to yellow: 'ffff9c')
  473. * @param {Object} options (optional) Object literal with any of the Fx config options
  474. * @return {Ext.Element} The Element
  475. */
  476. highlight : function(color, o){
  477. o = getObject(o);
  478. var me = this,
  479. dom = me.dom,
  480. attr = o.attr || "backgroundColor",
  481. a = {},
  482. restore;
  483. me.queueFx(o, function(){
  484. fly(dom).clearOpacity();
  485. fly(dom).show();
  486. function after(){
  487. dom.style[attr] = restore;
  488. fly(dom).afterFx(o);
  489. }
  490. restore = dom.style[attr];
  491. a[attr] = {from: color || "ffff9c", to: o.endColor || fly(dom).getColor(attr) || "ffffff"};
  492. arguments.callee.anim = fly(dom).fxanim(a,
  493. o,
  494. 'color',
  495. 1,
  496. 'easeIn',
  497. after);
  498. });
  499. return me;
  500. },
  501. /**
  502. * Shows a ripple of exploding, attenuating borders to draw attention to an Element.
  503. * Usage:
  504. <pre><code>
  505. // default: a single light blue ripple
  506. el.frame();
  507. // custom: 3 red ripples lasting 3 seconds total
  508. el.frame("ff0000", 3, { duration: 3 });
  509. // common config options shown with default values
  510. el.frame("C3DAF9", 1, {
  511. duration: 1 //duration of each individual ripple.
  512. // Note: Easing is not configurable and will be ignored if included
  513. });
  514. </code></pre>
  515. * @param {String} color (optional) The color of the border. Should be a 6 char hex color without the leading # (defaults to light blue: 'C3DAF9').
  516. * @param {Number} count (optional) The number of ripples to display (defaults to 1)
  517. * @param {Object} options (optional) Object literal with any of the Fx config options
  518. * @return {Ext.Element} The Element
  519. */
  520. frame : function(color, count, o){
  521. o = getObject(o);
  522. var me = this,
  523. dom = me.dom,
  524. proxy,
  525. active;
  526. me.queueFx(o, function(){
  527. color = color || '#C3DAF9';
  528. if(color.length == 6){
  529. color = '#' + color;
  530. }
  531. count = count || 1;
  532. fly(dom).show();
  533. var xy = fly(dom).getXY(),
  534. b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight},
  535. queue = function(){
  536. proxy = fly(document.body || document.documentElement).createChild({
  537. style:{
  538. position : ABSOLUTE,
  539. 'z-index': 35000, // yee haw
  540. border : '0px solid ' + color
  541. }
  542. });
  543. return proxy.queueFx({}, animFn);
  544. };
  545. arguments.callee.anim = {
  546. isAnimated: true,
  547. stop: function() {
  548. count = 0;
  549. proxy.stopFx();
  550. }
  551. };
  552. function animFn(){
  553. var scale = Ext.isBorderBox ? 2 : 1;
  554. active = proxy.anim({
  555. top : {from : b.y, to : b.y - 20},
  556. left : {from : b.x, to : b.x - 20},
  557. borderWidth : {from : 0, to : 10},
  558. opacity : {from : 1, to : 0},
  559. height : {from : b.height, to : b.height + 20 * scale},
  560. width : {from : b.width, to : b.width + 20 * scale}
  561. },{
  562. duration: o.duration || 1,
  563. callback: function() {
  564. proxy.remove();
  565. --count > 0 ? queue() : fly(dom).afterFx(o);
  566. }
  567. });
  568. arguments.callee.anim = {
  569. isAnimated: true,
  570. stop: function(){
  571. active.stop();
  572. }
  573. };
  574. };
  575. queue();
  576. });
  577. return me;
  578. },
  579. /**
  580. * Creates a pause before any subsequent queued effects begin. If there are
  581. * no effects queued after the pause it will have no effect.
  582. * Usage:
  583. <pre><code>
  584. el.pause(1);
  585. </code></pre>
  586. * @param {Number} seconds The length of time to pause (in seconds)
  587. * @return {Ext.Element} The Element
  588. */
  589. pause : function(seconds){
  590. var dom = this.dom,
  591. t;
  592. this.queueFx({}, function(){
  593. t = setTimeout(function(){
  594. fly(dom).afterFx({});
  595. }, seconds * 1000);
  596. arguments.callee.anim = {
  597. isAnimated: true,
  598. stop: function(){
  599. clearTimeout(t);
  600. fly(dom).afterFx({});
  601. }
  602. };
  603. });
  604. return this;
  605. },
  606. /**
  607. * Fade an element in (from transparent to opaque). The ending opacity can be specified
  608. * using the <tt>{@link #endOpacity}</tt> config option.
  609. * Usage:
  610. <pre><code>
  611. // default: fade in from opacity 0 to 100%
  612. el.fadeIn();
  613. // custom: fade in from opacity 0 to 75% over 2 seconds
  614. el.fadeIn({ endOpacity: .75, duration: 2});
  615. // common config options shown with default values
  616. el.fadeIn({
  617. endOpacity: 1, //can be any value between 0 and 1 (e.g. .5)
  618. easing: 'easeOut',
  619. duration: .5
  620. });
  621. </code></pre>
  622. * @param {Object} options (optional) Object literal with any of the Fx config options
  623. * @return {Ext.Element} The Element
  624. */
  625. fadeIn : function(o){
  626. o = getObject(o);
  627. var me = this,
  628. dom = me.dom,
  629. to = o.endOpacity || 1;
  630. me.queueFx(o, function(){
  631. fly(dom).setOpacity(0);
  632. fly(dom).fixDisplay();
  633. dom.style.visibility = VISIBLE;
  634. arguments.callee.anim = fly(dom).fxanim({opacity:{to:to}},
  635. o, NULL, .5, EASEOUT, function(){
  636. if(to == 1){
  637. fly(dom).clearOpacity();
  638. }
  639. fly(dom).afterFx(o);
  640. });
  641. });
  642. return me;
  643. },
  644. /**
  645. * Fade an element out (from opaque to transparent). The ending opacity can be specified
  646. * using the <tt>{@link #endOpacity}</tt> config option. Note that IE may require
  647. * <tt>{@link #useDisplay}:true</tt> in order to redisplay correctly.
  648. * Usage:
  649. <pre><code>
  650. // default: fade out from the element's current opacity to 0
  651. el.fadeOut();
  652. // custom: fade out from the element's current opacity to 25% over 2 seconds
  653. el.fadeOut({ endOpacity: .25, duration: 2});
  654. // common config options shown with default values
  655. el.fadeOut({
  656. endOpacity: 0, //can be any value between 0 and 1 (e.g. .5)
  657. easing: 'easeOut',
  658. duration: .5,
  659. remove: false,
  660. useDisplay: false
  661. });
  662. </code></pre>
  663. * @param {Object} options (optional) Object literal with any of the Fx config options
  664. * @return {Ext.Element} The Element
  665. */
  666. fadeOut : function(o){
  667. o = getObject(o);
  668. var me = this,
  669. dom = me.dom,
  670. style = dom.style,
  671. to = o.endOpacity || 0;
  672. me.queueFx(o, function(){
  673. arguments.callee.anim = fly(dom).fxanim({
  674. opacity : {to : to}},
  675. o,
  676. NULL,
  677. .5,
  678. EASEOUT,
  679. function(){
  680. if(to == 0){
  681. Ext.Element.data(dom, 'visibilityMode') == Ext.Element.DISPLAY || o.useDisplay ?
  682. style.display = "none" :
  683. style.visibility = HIDDEN;
  684. fly(dom).clearOpacity();
  685. }
  686. fly(dom).afterFx(o);
  687. });
  688. });
  689. return me;
  690. },
  691. /**
  692. * Animates the transition of an element's dimensions from a starting height/width
  693. * to an ending height/width. This method is a convenience implementation of {@link shift}.
  694. * Usage:
  695. <pre><code>
  696. // change height and width to 100x100 pixels
  697. el.scale(100, 100);
  698. // common config options shown with default values. The height and width will default to
  699. // the element&#39;s existing values if passed as null.
  700. el.scale(
  701. [element&#39;s width],
  702. [element&#39;s height], {
  703. easing: 'easeOut',
  704. duration: .35
  705. }
  706. );
  707. </code></pre>
  708. * @param {Number} width The new width (pass undefined to keep the original width)
  709. * @param {Number} height The new height (pass undefined to keep the original height)
  710. * @param {Object} options (optional) Object literal with any of the Fx config options
  711. * @return {Ext.Element} The Element
  712. */
  713. scale : function(w, h, o){
  714. this.shift(Ext.apply({}, o, {
  715. width: w,
  716. height: h
  717. }));
  718. return this;
  719. },
  720. /**
  721. * Animates the transition of any combination of an element's dimensions, xy position and/or opacity.
  722. * Any of these properties not specified in the config object will not be changed. This effect
  723. * requires that at least one new dimension, position or opacity setting must be passed in on
  724. * the config object in order for the function to have any effect.
  725. * Usage:
  726. <pre><code>
  727. // slide the element horizontally to x position 200 while changing the height and opacity
  728. el.shift({ x: 200, height: 50, opacity: .8 });
  729. // common config options shown with default values.
  730. el.shift({
  731. width: [element&#39;s width],
  732. height: [element&#39;s height],
  733. x: [element&#39;s x position],
  734. y: [element&#39;s y position],
  735. opacity: [element&#39;s opacity],
  736. easing: 'easeOut',
  737. duration: .35
  738. });
  739. </code></pre>
  740. * @param {Object} options Object literal with any of the Fx config options
  741. * @return {Ext.Element} The Element
  742. */
  743. shift : function(o){
  744. o = getObject(o);
  745. var dom = this.dom,
  746. a = {};
  747. this.queueFx(o, function(){
  748. for (var prop in o) {
  749. if (o[prop] != UNDEFINED) {
  750. a[prop] = {to : o[prop]};
  751. }
  752. }
  753. a.width ? a.width.to = fly(dom).adjustWidth(o.width) : a;
  754. a.height ? a.height.to = fly(dom).adjustWidth(o.height) : a;
  755. if (a.x || a.y || a.xy) {
  756. a.points = a.xy ||
  757. {to : [ a.x ? a.x.to : fly(dom).getX(),
  758. a.y ? a.y.to : fly(dom).getY()]};
  759. }
  760. arguments.callee.anim = fly(dom).fxanim(a,
  761. o,
  762. MOTION,
  763. .35,
  764. EASEOUT,
  765. function(){
  766. fly(dom).afterFx(o);
  767. });
  768. });
  769. return this;
  770. },
  771. /**
  772. * Slides the element while fading it out of view. An anchor point can be optionally passed to set the
  773. * ending point of the effect.
  774. * Usage:
  775. *<pre><code>
  776. // default: slide the element downward while fading out
  777. el.ghost();
  778. // custom: slide the element out to the right with a 2-second duration
  779. el.ghost('r', { duration: 2 });
  780. // common config options shown with default values
  781. el.ghost('b', {
  782. easing: 'easeOut',
  783. duration: .5,
  784. remove: false,
  785. useDisplay: false
  786. });
  787. </code></pre>
  788. * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to bottom: 'b')
  789. * @param {Object} options (optional) Object literal with any of the Fx config options
  790. * @return {Ext.Element} The Element
  791. */
  792. ghost : function(anchor, o){
  793. o = getObject(o);
  794. var me = this,
  795. dom = me.dom,
  796. st = dom.style,
  797. a = {opacity: {to: 0}, points: {}},
  798. pt = a.points,
  799. r,
  800. w,
  801. h;
  802. anchor = anchor || "b";
  803. me.queueFx(o, function(){
  804. // restore values after effect
  805. r = fly(dom).getFxRestore();
  806. w = fly(dom).getWidth();
  807. h = fly(dom).getHeight();
  808. function after(){
  809. o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
  810. fly(dom).clearOpacity();
  811. fly(dom).setPositioning(r.pos);
  812. st.width = r.width;
  813. st.height = r.height;
  814. fly(dom).afterFx(o);
  815. }
  816. pt.by = fly(dom).switchStatements(anchor.toLowerCase(), function(v1,v2){ return [v1, v2];}, {
  817. t : [0, -h],
  818. l : [-w, 0],
  819. r : [w, 0],
  820. b : [0, h],
  821. tl : [-w, -h],
  822. bl : [-w, h],
  823. br : [w, h],
  824. tr : [w, -h]
  825. });
  826. arguments.callee.anim = fly(dom).fxanim(a,
  827. o,
  828. MOTION,
  829. .5,
  830. EASEOUT, after);
  831. });
  832. return me;
  833. },
  834. /**
  835. * Ensures that all effects queued after syncFx is called on the element are
  836. * run concurrently. This is the opposite of {@link #sequenceFx}.
  837. * @return {Ext.Element} The Element
  838. */
  839. syncFx : function(){
  840. var me = this;
  841. me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
  842. block : FALSE,
  843. concurrent : TRUE,
  844. stopFx : FALSE
  845. });
  846. return me;
  847. },
  848. /**
  849. * Ensures that all effects queued after sequenceFx is called on the element are
  850. * run in sequence. This is the opposite of {@link #syncFx}.
  851. * @return {Ext.Element} The Element
  852. */
  853. sequenceFx : function(){
  854. var me = this;
  855. me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
  856. block : FALSE,
  857. concurrent : FALSE,
  858. stopFx : FALSE
  859. });
  860. return me;
  861. },
  862. /* @private */
  863. nextFx : function(){
  864. var ef = getQueue(this.dom.id)[0];
  865. if(ef){
  866. ef.call(this);
  867. }
  868. },
  869. /**
  870. * Returns true if the element has any effects actively running or queued, else returns false.
  871. * @return {Boolean} True if element has active effects, else false
  872. */
  873. hasActiveFx : function(){
  874. return getQueue(this.dom.id)[0];
  875. },
  876. /**
  877. * Stops any running effects and clears the element's internal effects queue if it contains
  878. * any additional effects that haven't started yet.
  879. * @return {Ext.Element} The Element
  880. */
  881. stopFx : function(finish){
  882. var me = this,
  883. id = me.dom.id;
  884. if(me.hasActiveFx()){
  885. var cur = getQueue(id)[0];
  886. if(cur && cur.anim){
  887. if(cur.anim.isAnimated){
  888. setQueue(id, [cur]); //clear
  889. cur.anim.stop(finish !== undefined ? finish : TRUE);
  890. }else{
  891. setQueue(id, []);
  892. }
  893. }
  894. }
  895. return me;
  896. },
  897. /* @private */
  898. beforeFx : function(o){
  899. if(this.hasActiveFx() && !o.concurrent){
  900. if(o.stopFx){
  901. this.stopFx();
  902. return TRUE;
  903. }
  904. return FALSE;
  905. }
  906. return TRUE;
  907. },
  908. /**
  909. * Returns true if the element is currently blocking so that no other effect can be queued
  910. * until this effect is finished, else returns false if blocking is not set. This is commonly
  911. * used to ensure that an effect initiated by a user action runs to completion prior to the
  912. * same effect being restarted (e.g., firing only one effect even if the user clicks several times).
  913. * @return {Boolean} True if blocking, else false
  914. */
  915. hasFxBlock : function(){
  916. var q = getQueue(this.dom.id);
  917. return q && q[0] && q[0].block;
  918. },
  919. /* @private */
  920. queueFx : function(o, fn){
  921. var me = fly(this.dom);
  922. if(!me.hasFxBlock()){
  923. Ext.applyIf(o, me.fxDefaults);
  924. if(!o.concurrent){
  925. var run = me.beforeFx(o);
  926. fn.block = o.block;
  927. getQueue(me.dom.id).push(fn);
  928. if(run){
  929. me.nextFx();
  930. }
  931. }else{
  932. fn.call(me);
  933. }
  934. }
  935. return me;
  936. },
  937. /* @private */
  938. fxWrap : function(pos, o, vis){
  939. var dom = this.dom,
  940. wrap,
  941. wrapXY;
  942. if(!o.wrap || !(wrap = Ext.getDom(o.wrap))){
  943. if(o.fixPosition){
  944. wrapXY = fly(dom).getXY();
  945. }
  946. var div = document.createElement("div");
  947. div.style.visibility = vis;
  948. wrap = dom.parentNode.insertBefore(div, dom);
  949. fly(wrap).setPositioning(pos);
  950. if(fly(wrap).isStyle(POSITION, "static")){
  951. fly(wrap).position("relative");
  952. }
  953. fly(dom).clearPositioning('auto');
  954. fly(wrap).clip();
  955. wrap.appendChild(dom);
  956. if(wrapXY){
  957. fly(wrap).setXY(wrapXY);
  958. }
  959. }
  960. return wrap;
  961. },
  962. /* @private */
  963. fxUnwrap : function(wrap, pos, o){
  964. var dom = this.dom;
  965. fly(dom).clearPositioning();
  966. fly(dom).setPositioning(pos);
  967. if(!o.wrap){
  968. var pn = fly(wrap).dom.parentNode;
  969. pn.insertBefore(dom, wrap);
  970. fly(wrap).remove();
  971. }
  972. },
  973. /* @private */
  974. getFxRestore : function(){
  975. var st = this.dom.style;
  976. return {pos: this.getPositioning(), width: st.width, height : st.height};
  977. },
  978. /* @private */
  979. afterFx : function(o){
  980. var dom = this.dom,
  981. id = dom.id;
  982. if(o.afterStyle){
  983. fly(dom).setStyle(o.afterStyle);
  984. }
  985. if(o.afterCls){
  986. fly(dom).addClass(o.afterCls);
  987. }
  988. if(o.remove == TRUE){
  989. fly(dom).remove();
  990. }
  991. if(o.callback){
  992. o.callback.call(o.scope, fly(dom));
  993. }
  994. if(!o.concurrent){
  995. getQueue(id).shift();
  996. fly(dom).nextFx();
  997. }
  998. },
  999. /* @private */
  1000. fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
  1001. animType = animType || 'run';
  1002. opt = opt || {};
  1003. var anim = Ext.lib.Anim[animType](
  1004. this.dom,
  1005. args,
  1006. (opt.duration || defaultDur) || .35,
  1007. (opt.easing || defaultEase) || EASEOUT,
  1008. cb,
  1009. this
  1010. );
  1011. opt.anim = anim;
  1012. return anim;
  1013. }
  1014. };
  1015. // backwards compat
  1016. Ext.Fx.resize = Ext.Fx.scale;
  1017. //When included, Ext.Fx is automatically applied to Element so that all basic
  1018. //effects are available directly via the Element API
  1019. Ext.Element.addMethods(Ext.Fx);
  1020. })();
  1021. </pre>
  1022. </body>
  1023. </html>