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>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
18 <div id="prop-Ext.Element-VISIBILITY"></div>/**
19 * Visibility mode constant for use with {@link #setVisibilityMode}. Use visibility to hide element
23 Ext.Element.VISIBILITY = 1;
24 <div id="prop-Ext.Element-DISPLAY"></div>/**
25 * Visibility mode constant for use with {@link #setVisibilityMode}. Use display to hide element
29 Ext.Element.DISPLAY = 2;
31 Ext.Element.addMethods(function(){
32 var VISIBILITY = "visibility",
37 ORIGINALDISPLAY = 'originalDisplay',
38 VISMODE = 'visibilityMode',
39 ELDISPLAY = Ext.Element.DISPLAY,
40 data = Ext.Element.data,
41 getDisplay = function(dom){
42 var d = data(dom, ORIGINALDISPLAY);
44 data(dom, ORIGINALDISPLAY, d = '');
48 getVisMode = function(dom){
49 var m = data(dom, VISMODE);
51 data(dom, VISMODE, m = 1);
57 <div id="prop-Ext.Element-originalDisplay"></div>/**
58 * The element's default display mode (defaults to "")
64 <div id="method-Ext.Element-setVisibilityMode"></div>/**
65 * Sets the element's visibility mode. When setVisible() is called it
66 * will use this to determine whether to set the visibility or the display property.
67 * @param {Number} visMode Ext.Element.VISIBILITY or Ext.Element.DISPLAY
68 * @return {Ext.Element} this
70 setVisibilityMode : function(visMode){
71 data(this.dom, VISMODE, visMode);
75 <div id="method-Ext.Element-animate"></div>/**
76 * Perform custom animation on this element.
77 * <div><ul class="mdetail-params">
78 * <li><u>Animation Properties</u></li>
80 * <p>The Animation Control Object enables gradual transitions for any member of an
81 * element's style object that takes a numeric value including but not limited to
82 * these properties:</p><div><ul class="mdetail-params">
83 * <li><tt>bottom, top, left, right</tt></li>
84 * <li><tt>height, width</tt></li>
85 * <li><tt>margin, padding</tt></li>
86 * <li><tt>borderWidth</tt></li>
87 * <li><tt>opacity</tt></li>
88 * <li><tt>fontSize</tt></li>
89 * <li><tt>lineHeight</tt></li>
93 * <li><u>Animation Property Attributes</u></li>
95 * <p>Each Animation Property is a config object with optional properties:</p>
96 * <div><ul class="mdetail-params">
97 * <li><tt>by</tt>* : relative change - start at current value, change by this value</li>
98 * <li><tt>from</tt> : ignore current value, start from this value</li>
99 * <li><tt>to</tt>* : start at current value, go to this value</li>
100 * <li><tt>unit</tt> : any allowable unit specification</li>
101 * <p>* do not specify both <tt>to</tt> and <tt>by</tt> for an animation property</p>
104 * <li><u>Animation Types</u></li>
106 * <p>The supported animation types:</p><div><ul class="mdetail-params">
107 * <li><tt>'run'</tt> : Default
109 var el = Ext.get('complexEl');
111 // animation control object
113 borderWidth: {to: 3, from: 0},
114 opacity: {to: .3, from: 1},
115 height: {to: 50, from: el.getHeight()},
116 width: {to: 300, from: el.getWidth()},
117 top : {by: - 100, unit: 'px'},
119 0.35, // animation duration
121 'easeOut', // easing method
122 'run' // animation type ('run','color','motion','scroll')
126 * <li><tt>'color'</tt>
127 * <p>Animates transition of background, text, or border colors.</p>
130 // animation control object
132 color: { to: '#06e' },
133 backgroundColor: { to: '#e06' }
135 0.35, // animation duration
137 'easeOut', // easing method
138 'color' // animation type ('run','color','motion','scroll')
143 * <li><tt>'motion'</tt>
144 * <p>Animates the motion of an element to/from specific points using optional bezier
145 * way points during transit.</p>
148 // animation control object
150 borderWidth: {to: 3, from: 0},
151 opacity: {to: .3, from: 1},
152 height: {to: 50, from: el.getHeight()},
153 width: {to: 300, from: el.getWidth()},
154 top : {by: - 100, unit: 'px'},
156 to: [50, 100], // go to this point
157 control: [ // optional bezier way points
163 3000, // animation duration (milliseconds!)
165 'easeOut', // easing method
166 'motion' // animation type ('run','color','motion','scroll')
170 * <li><tt>'scroll'</tt>
171 * <p>Animate horizontal or vertical scrolling of an overflowing page element.</p>
174 // animation control object
176 scroll: {to: [400, 300]}
178 0.35, // animation duration
180 'easeOut', // easing method
181 'scroll' // animation type ('run','color','motion','scroll')
189 * @param {Object} args The animation control args
190 * @param {Float} duration (optional) How long the animation lasts in seconds (defaults to <tt>.35</tt>)
191 * @param {Function} onComplete (optional) Function to call when animation completes
192 * @param {String} easing (optional) {@link Ext.Fx#easing} method to use (defaults to <tt>'easeOut'</tt>)
193 * @param {String} animType (optional) <tt>'run'</tt> is the default. Can also be <tt>'color'</tt>,
194 * <tt>'motion'</tt>, or <tt>'scroll'</tt>
195 * @return {Ext.Element} this
197 animate : function(args, duration, onComplete, easing, animType){
198 this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
203 * @private Internal animation call
205 anim : function(args, opt, animType, defaultDur, defaultEase, cb){
206 animType = animType || 'run';
209 anim = Ext.lib.Anim[animType](
212 (opt.duration || defaultDur) || .35,
213 (opt.easing || defaultEase) || 'easeOut',
216 if(opt.callback) opt.callback.call(opt.scope || me, me, opt);
224 // private legacy anim prep
225 preanim : function(a, i){
226 return !a[i] ? false : (Ext.isObject(a[i]) ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
229 <div id="method-Ext.Element-isVisible"></div>/**
230 * Checks whether the element is currently visible using both visibility and display properties.
231 * @return {Boolean} True if the element is currently visible, else false
233 isVisible : function() {
234 return !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE);
237 <div id="method-Ext.Element-setVisible"></div>/**
238 * Sets the visibility of the element (see details). If the visibilityMode is set to Element.DISPLAY, it will use
239 * the display property to hide the element, otherwise it uses visibility. The default is to hide and show using the visibility property.
240 * @param {Boolean} visible Whether the element is visible
241 * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
242 * @return {Ext.Element} this
244 setVisible : function(visible, animate){
245 var me = this, isDisplay, isVisible, isOffsets,
248 // hideMode string override
249 if (Ext.isString(animate)){
250 isDisplay = animate == DISPLAY;
251 isVisible = animate == VISIBILITY;
252 isOffsets = animate == OFFSETS;
255 isDisplay = getVisMode(this.dom) == ELDISPLAY;
256 isVisible = !isDisplay;
259 if (!animate || !me.anim) {
261 me.setDisplayed(visible);
262 } else if (isOffsets){
264 me.hideModeStyles = {
265 position: me.getStyle('position'),
266 top: me.getStyle('top'),
267 left: me.getStyle('left')
270 me.applyStyles({position: 'absolute', top: '-10000px', left: '-10000px'});
272 me.applyStyles(me.hideModeStyles || {position: '', top: '', left: ''});
276 dom.style.visibility = visible ? "visible" : HIDDEN;
279 // closure for composites
284 me.anim({opacity: { to: (visible?1:0) }},
285 me.preanim(arguments, 1),
291 dom.style[isDisplay ? DISPLAY : VISIBILITY] = (isDisplay) ? NONE : HIDDEN;
292 Ext.fly(dom).setOpacity(1);
299 <div id="method-Ext.Element-toggle"></div>/**
300 * Toggles the element's visibility or display, depending on visibility mode.
301 * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
302 * @return {Ext.Element} this
304 toggle : function(animate){
306 me.setVisible(!me.isVisible(), me.preanim(arguments, 0));
310 <div id="method-Ext.Element-setDisplayed"></div>/**
311 * Sets the CSS display property. Uses originalDisplay if the specified value is a boolean true.
312 * @param {Mixed} value Boolean value to display the element using its default display, or a string to set the display directly.
313 * @return {Ext.Element} this
315 setDisplayed : function(value) {
316 if(typeof value == "boolean"){
317 value = value ? getDisplay(this.dom) : NONE;
319 this.setStyle(DISPLAY, value);
324 fixDisplay : function(){
326 if(me.isStyle(DISPLAY, NONE)){
327 me.setStyle(VISIBILITY, HIDDEN);
328 me.setStyle(DISPLAY, getDisplay(this.dom)); // first try reverting to default
329 if(me.isStyle(DISPLAY, NONE)){ // if that fails, default to block
330 me.setStyle(DISPLAY, "block");
335 <div id="method-Ext.Element-hide"></div>/**
336 * Hide this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.
337 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
338 * @return {Ext.Element} this
340 hide : function(animate){
342 if (Ext.isString(animate)){
343 this.setVisible(false, animate);
346 this.setVisible(false, this.preanim(arguments, 0));
350 <div id="method-Ext.Element-show"></div>/**
351 * Show this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.
352 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
353 * @return {Ext.Element} this
355 show : function(animate){
357 if (Ext.isString(animate)){
358 this.setVisible(true, animate);
361 this.setVisible(true, this.preanim(arguments, 0));