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; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-Element'>/**
19 </span> * @class Ext.Element
21 Ext.applyIf(Ext.Element.prototype, {
22 // @private override base Ext.util.Animate mixin for animate for backwards compatibility
23 animate: function(config) {
28 if (Ext.fx.Manager.hasFxBlock(me.id)) {
31 Ext.fx.Manager.queueFx(Ext.create('Ext.fx.Anim', me.anim(config)));
35 // @private override base Ext.util.Animate mixin for animate for backwards compatibility
36 anim: function(config) {
37 if (!Ext.isObject(config)) {
38 return (config) ? {} : false;
42 duration = config.duration || Ext.fx.Anim.prototype.duration,
43 easing = config.easing || 'ease',
46 if (config.stopAnimation) {
50 Ext.applyIf(config, Ext.fx.Manager.getFxDefaults(me.id));
52 // Clear any 'paused' defaults.
53 Ext.fx.Manager.setFxDefaults(me.id, {
59 remove: config.remove,
60 alternate: config.alternate || false,
63 callback: config.callback,
64 listeners: config.listeners,
65 iterations: config.iterations || 1,
68 concurrent: config.concurrent,
69 delay: config.delay || 0,
71 keyframes: config.keyframes,
72 from: config.from || {},
73 to: Ext.apply({}, config)
75 Ext.apply(animConfig.to, config.to);
77 // Anim API properties - backward compat
78 delete animConfig.to.to;
79 delete animConfig.to.from;
80 delete animConfig.to.remove;
81 delete animConfig.to.alternate;
82 delete animConfig.to.keyframes;
83 delete animConfig.to.iterations;
84 delete animConfig.to.listeners;
85 delete animConfig.to.target;
86 delete animConfig.to.paused;
87 delete animConfig.to.callback;
88 delete animConfig.to.scope;
89 delete animConfig.to.duration;
90 delete animConfig.to.easing;
91 delete animConfig.to.concurrent;
92 delete animConfig.to.block;
93 delete animConfig.to.stopAnimation;
94 delete animConfig.to.delay;
98 <span id='Ext-Element-method-slideIn'> /**
99 </span> * Slides the element into view. An anchor point can be optionally passed to set the point of origin for the slide
100 * effect. This function automatically handles wrapping the element with a fixed-size container if needed. See the
101 * Fx class overview for valid anchor point options. Usage:
103 * // default: slide the element in from the top
106 * // custom: slide the element in from the right with a 2-second duration
107 * el.slideIn('r', { duration: 2000 });
109 * // common config options shown with default values
115 * @param {String} [anchor='t'] One of the valid Fx anchor positions
116 * @param {Object} [options] Object literal with any of the Fx config options
117 * @return {Ext.Element} The Element
119 slideIn: function(anchor, obj, slideOut) {
121 elStyle = me.dom.style,
122 beforeAnim, wrapAnim;
124 anchor = anchor || "t";
127 beforeAnim = function() {
128 var animScope = this,
129 listeners = obj.listeners,
130 box, position, restoreSize, wrap, anim;
137 if ((anchor == 't' || anchor == 'b') && box.height === 0) {
138 box.height = me.dom.scrollHeight;
140 else if ((anchor == 'l' || anchor == 'r') && box.width === 0) {
141 box.width = me.dom.scrollWidth;
144 position = me.getPositioning();
145 me.setSize(box.width, box.height);
149 visibility: slideOut ? 'visible' : 'hidden'
152 wrap.setPositioning(position);
153 if (wrap.isStyle('position', 'static')) {
154 wrap.position('relative');
156 me.clearPositioning('auto');
159 // This element is temporarily positioned absolute within its wrapper.
160 // Restore to its default, CSS-inherited visibility setting.
161 // We cannot explicitly poke visibility:visible into its style because that overrides the visibility of the wrap.
167 wrap.setSize(box.width, box.height);
174 width: box.width + 'px',
178 width: box.width + 'px',
179 height: box.height + 'px'
182 elStyle.bottom = '0px';
188 height: box.height + 'px'
191 width: box.width + 'px',
192 height: box.height + 'px'
195 elStyle.right = '0px';
200 x: box.x + box.width,
202 height: box.height + 'px'
206 width: box.width + 'px',
207 height: box.height + 'px'
214 y: box.y + box.height,
215 width: box.width + 'px',
220 width: box.width + 'px',
221 height: box.height + 'px'
234 width: box.width + 'px',
235 height: box.height + 'px'
238 elStyle.bottom = '0px';
239 elStyle.right = '0px';
244 x: box.x + box.width,
250 width: box.width + 'px',
251 height: box.height + 'px'
254 elStyle.right = '0px';
259 x: box.x + box.width,
260 y: box.y + box.height,
267 width: box.width + 'px',
268 height: box.height + 'px'
275 y: box.y + box.height,
281 width: box.width + 'px',
282 height: box.height + 'px'
285 elStyle.bottom = '0px';
290 wrapAnim = Ext.apply({}, obj);
291 delete wrapAnim.listeners;
292 wrapAnim = Ext.create('Ext.fx.Anim', Ext.applyIf(wrapAnim, {
296 from: slideOut ? anim.to : anim.from,
297 to: slideOut ? anim.from : anim.to
300 // In the absence of a callback, this listener MUST be added first
301 wrapAnim.on('afteranimate', function() {
303 me.setPositioning(position);
304 if (obj.useDisplay) {
305 me.setDisplayed(false);
311 me.clearPositioning();
312 me.setPositioning(position);
315 wrap.dom.parentNode.insertBefore(me.dom, wrap.dom);
318 me.setSize(box.width, box.height);
321 // Add configured listeners after
323 wrapAnim.on(listeners);
328 duration: obj.duration ? obj.duration * 2 : 1000,
335 if (wrapAnim && wrapAnim.running) {
346 <span id='Ext-Element-method-slideOut'> /**
347 </span> * Slides the element out of view. An anchor point can be optionally passed to set the end point for the slide
348 * effect. When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will
349 * still take up space in the document. The element must be removed from the DOM using the 'remove' config option if
350 * desired. This function automatically handles wrapping the element with a fixed-size container if needed. See the
351 * Fx class overview for valid anchor point options. Usage:
353 * // default: slide the element out to the top
356 * // custom: slide the element out to the right with a 2-second duration
357 * el.slideOut('r', { duration: 2000 });
359 * // common config options shown with default values
367 * @param {String} [anchor='t'] One of the valid Fx anchor positions
368 * @param {Object} [options] Object literal with any of the Fx config options
369 * @return {Ext.Element} The Element
371 slideOut: function(anchor, o) {
372 return this.slideIn(anchor, o, true);
375 <span id='Ext-Element-method-puff'> /**
376 </span> * Fades the element out while slowly expanding it in all directions. When the effect is completed, the element will
377 * be hidden (visibility = 'hidden') but block elements will still take up space in the document. Usage:
382 * // common config options shown with default values
389 * @param {Object} options (optional) Object literal with any of the Fx config options
390 * @return {Ext.Element} The Element
392 puff: function(obj) {
395 obj = Ext.applyIf(obj || {}, {
401 beforeAnim = function() {
405 var box = me.getBox(),
406 fontSize = me.getStyle('fontSize'),
407 position = me.getPositioning();
409 width: box.width * 2,
410 height: box.height * 2,
411 x: box.x - (box.width / 2),
412 y: box.y - (box.height /2),
416 this.on('afteranimate',function() {
418 if (obj.useDisplay) {
419 me.setDisplayed(false);
424 me.setPositioning(position);
425 me.setStyle({fontSize: fontSize});
431 duration: obj.duration,
442 <span id='Ext-Element-method-switchOff'> /**
443 </span> * Blinks the element as if it was clicked and then collapses on its center (similar to switching off a television).
444 * When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will still
445 * take up space in the document. The element must be removed from the DOM using the 'remove' config option if
451 * // all config options shown with default values
459 * @param {Object} options (optional) Object literal with any of the Fx config options
460 * @return {Ext.Element} The Element
462 switchOff: function(obj) {
466 obj = Ext.applyIf(obj || {}, {
473 beforeAnim = function() {
474 var animScope = this,
480 position = me.getPositioning();
482 keyframe = Ext.create('Ext.fx.Animator', {
484 duration: obj.duration,
492 y: xy[1] + size.height / 2
496 x: xy[0] + size.width / 2
500 keyframe.on('afteranimate', function() {
501 if (obj.useDisplay) {
502 me.setDisplayed(false);
507 me.setPositioning(position);
513 duration: (obj.duration * 2),
523 <span id='Ext-Element-method-frame'> /**
524 </span> * Shows a ripple of exploding, attenuating borders to draw attention to an Element. Usage:
526 * // default: a single light blue ripple
529 * // custom: 3 red ripples lasting 3 seconds total
530 * el.frame("#ff0000", 3, { duration: 3 });
532 * // common config options shown with default values
533 * el.frame("#C3DAF9", 1, {
534 * duration: 1 //duration of each individual ripple.
535 * // Note: Easing is not configurable and will be ignored if included
538 * @param {String} [color='C3DAF9'] The color of the border. Should be a 6 char hex color without the leading #
539 * (defaults to light blue).
540 * @param {Number} [count=1] The number of ripples to display
541 * @param {Object} [options] Object literal with any of the Fx config options
542 * @return {Ext.Element} The Element
544 frame : function(color, count, obj){
548 color = color || '#C3DAF9';
552 beforeAnim = function() {
554 var animScope = this,
556 proxy = Ext.getBody().createChild({
558 position : 'absolute',
559 'pointer-events': 'none',
561 border : '0px solid ' + color
565 proxyAnim = Ext.create('Ext.fx.Anim', {
567 duration: obj.duration || 1000,
582 height: box.height + 40,
583 width: box.width + 40
586 proxyAnim.on('afteranimate', function() {
593 duration: (obj.duration * 2) || 2000,
603 <span id='Ext-Element-method-ghost'> /**
604 </span> * Slides the element while fading it out of view. An anchor point can be optionally passed to set the ending point
605 * of the effect. Usage:
607 * // default: slide the element downward while fading out
610 * // custom: slide the element out to the right with a 2-second duration
611 * el.ghost('r', { duration: 2000 });
613 * // common config options shown with default values
619 * @param {String} [anchor='b'] One of the valid Fx anchor positions
620 * @param {Object} [options] Object literal with any of the Fx config options
621 * @return {Ext.Element} The Element
623 ghost: function(anchor, obj) {
627 anchor = anchor || "b";
628 beforeAnim = function() {
629 var width = me.getWidth(),
630 height = me.getHeight(),
632 position = me.getPositioning(),
638 to.y = xy[1] - height;
641 to.x = xy[0] - width;
644 to.x = xy[0] + width;
647 to.y = xy[1] + height;
650 to.x = xy[0] - width;
651 to.y = xy[1] - height;
654 to.x = xy[0] - width;
655 to.y = xy[1] + height;
658 to.x = xy[0] + width;
659 to.y = xy[1] + height;
662 to.x = xy[0] + width;
663 to.y = xy[1] - height;
667 this.on('afteranimate', function () {
671 me.setPositioning(position);
676 me.animate(Ext.applyIf(obj || {}, {
688 <span id='Ext-Element-method-highlight'> /**
689 </span> * Highlights the Element by setting a color (applies to the background-color by default, but can be changed using
690 * the "attr" config option) and then fading back to the original color. If no original color is available, you
691 * should provide the "endColor" config option which will be cleared after the animation. Usage:
693 * // default: highlight background to yellow
696 * // custom: highlight foreground text to blue for 2 seconds
697 * el.highlight("0000ff", { attr: 'color', duration: 2000 });
699 * // common config options shown with default values
700 * el.highlight("ffff9c", {
701 * attr: "backgroundColor", //can be any valid CSS property (attribute) that supports a color value
702 * endColor: (current color) or "ffffff",
707 * @param {String} [color='ffff9c'] The highlight color. Should be a 6 char hex color without the leading #
708 * @param {Object} [options] Object literal with any of the Fx config options
709 * @return {Ext.Element} The Element
711 highlight: function(color, o) {
715 restore, to, attr, lns, event, fn;
718 lns = o.listeners || {};
719 attr = o.attr || 'backgroundColor';
720 from[attr] = color || 'ffff9c';
724 to[attr] = o.endColor || me.getColor(attr, 'ffffff', '');
730 // Don't apply directly on lns, since we reference it in our own callbacks below
731 o.listeners = Ext.apply(Ext.apply({}, lns), {
732 beforeanimate: function() {
733 restore = dom.style[attr];
737 event = lns.beforeanimate;
739 fn = event.fn || event;
740 return fn.apply(event.scope || lns.scope || window, arguments);
743 afteranimate: function() {
745 dom.style[attr] = restore;
748 event = lns.afteranimate;
750 fn = event.fn || event;
751 fn.apply(event.scope || lns.scope || window, arguments);
756 me.animate(Ext.apply({}, o, {
765 <span id='Ext-Element-method-pause'> /**
766 </span> * @deprecated 4.0
767 * Creates a pause before any subsequent queued effects begin. If there are no effects queued after the pause it will
768 * have no effect. Usage:
772 * @param {Number} seconds The length of time to pause (in seconds)
773 * @return {Ext.Element} The Element
775 pause: function(ms) {
777 Ext.fx.Manager.setFxDefaults(me.id, {
783 <span id='Ext-Element-method-fadeIn'> /**
784 </span> * Fade an element in (from transparent to opaque). The ending opacity can be specified using the `opacity`
785 * config option. Usage:
787 * // default: fade in from opacity 0 to 100%
790 * // custom: fade in from opacity 0 to 75% over 2 seconds
791 * el.fadeIn({ opacity: .75, duration: 2000});
793 * // common config options shown with default values
795 * opacity: 1, //can be any value between 0 and 1 (e.g. .5)
800 * @param {Object} options (optional) Object literal with any of the Fx config options
801 * @return {Ext.Element} The Element
803 fadeIn: function(o) {
804 this.animate(Ext.apply({}, o, {
810 <span id='Ext-Element-method-fadeOut'> /**
811 </span> * Fade an element out (from opaque to transparent). The ending opacity can be specified using the `opacity`
812 * config option. Note that IE may require `useDisplay:true` in order to redisplay correctly.
815 * // default: fade out from the element's current opacity to 0
818 * // custom: fade out from the element's current opacity to 25% over 2 seconds
819 * el.fadeOut({ opacity: .25, duration: 2000});
821 * // common config options shown with default values
823 * opacity: 0, //can be any value between 0 and 1 (e.g. .5)
830 * @param {Object} options (optional) Object literal with any of the Fx config options
831 * @return {Ext.Element} The Element
833 fadeOut: function(o) {
834 this.animate(Ext.apply({}, o, {
840 <span id='Ext-Element-method-scale'> /**
841 </span> * @deprecated 4.0
842 * Animates the transition of an element's dimensions from a starting height/width to an ending height/width. This
843 * method is a convenience implementation of {@link #shift}. Usage:
845 * // change height and width to 100x100 pixels
846 * el.scale(100, 100);
848 * // common config options shown with default values. The height and width will default to
849 * // the element's existing values if passed as null.
852 * [element's height], {
858 * @param {Number} width The new width (pass undefined to keep the original width)
859 * @param {Number} height The new height (pass undefined to keep the original height)
860 * @param {Object} options (optional) Object literal with any of the Fx config options
861 * @return {Ext.Element} The Element
863 scale: function(w, h, o) {
864 this.animate(Ext.apply({}, o, {
871 <span id='Ext-Element-method-shift'> /**
872 </span> * @deprecated 4.0
873 * Animates the transition of any combination of an element's dimensions, xy position and/or opacity. Any of these
874 * properties not specified in the config object will not be changed. This effect requires that at least one new
875 * dimension, position or opacity setting must be passed in on the config object in order for the function to have
878 * // slide the element horizontally to x position 200 while changing the height and opacity
879 * el.shift({ x: 200, height: 50, opacity: .8 });
881 * // common config options shown with default values.
883 * width: [element's width],
884 * height: [element's height],
885 * x: [element's x position],
886 * y: [element's y position],
887 * opacity: [element's opacity],
892 * @param {Object} options Object literal with any of the Fx config options
893 * @return {Ext.Element} The Element
895 shift: function(config) {
896 this.animate(config);