Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / Element.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-fx-target-Element'>/**
19 </span> * @class Ext.fx.target.Element
20  * @extends Ext.fx.target.Target
21  * 
22  * This class represents a animation target for an {@link Ext.Element}. In general this class will not be
23  * created directly, the {@link Ext.Element} will be passed to the animation and
24  * and the appropriate target will be created.
25  */
26 Ext.define('Ext.fx.target.Element', {
27
28     /* Begin Definitions */
29     
30     extend: 'Ext.fx.target.Target',
31     
32     /* End Definitions */
33
34     type: 'element',
35
36     getElVal: function(el, attr, val) {
37         if (val == undefined) {
38             if (attr === 'x') {
39                 val = el.getX();
40             }
41             else if (attr === 'y') {
42                 val = el.getY();
43             }
44             else if (attr === 'scrollTop') {
45                 val = el.getScroll().top;
46             }
47             else if (attr === 'scrollLeft') {
48                 val = el.getScroll().left;
49             }
50             else if (attr === 'height') {
51                 val = el.getHeight();
52             }
53             else if (attr === 'width') {
54                 val = el.getWidth();
55             }
56             else {
57                 val = el.getStyle(attr);
58             }
59         }
60         return val;
61     },
62
63     getAttr: function(attr, val) {
64         var el = this.target;
65         return [[ el, this.getElVal(el, attr, val)]];
66     },
67
68     setAttr: function(targetData) {
69         var target = this.target,
70             ln = targetData.length,
71             attrs, attr, o, i, j, ln2, element, value;
72         for (i = 0; i &lt; ln; i++) {
73             attrs = targetData[i].attrs;
74             for (attr in attrs) {
75                 if (attrs.hasOwnProperty(attr)) {
76                     ln2 = attrs[attr].length;
77                     for (j = 0; j &lt; ln2; j++) {
78                         o = attrs[attr][j];
79                         element = o[0];
80                         value = o[1];
81                         if (attr === 'x') {
82                             element.setX(value);
83                         }
84                         else if (attr === 'y') {
85                             element.setY(value);
86                         }
87                         else if (attr === 'scrollTop') {
88                             element.scrollTo('top', value);
89                         }
90                         else if (attr === 'scrollLeft') {
91                             element.scrollTo('left',value);
92                         }
93                         else {
94                             element.setStyle(attr, value);
95                         }
96                     }
97                 }
98             }
99         }
100     }
101 });
102 </pre>
103 </body>
104 </html>