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.3.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 <div id="prop-Ext.Element-OFFSETS"></div>/**
32 * Visibility mode constant for use with {@link #setVisibilityMode}. Use offsets (x and y positioning offscreen)
37 Ext.Element.OFFSETS = 3;
40 Ext.Element.ASCLASS = 4;
42 <div id="prop-Ext.Element-visibilityCls"></div>/**
43 * Defaults to 'x-hide-nosize'
47 Ext.Element.visibilityCls = 'x-hide-nosize';
49 Ext.Element.addMethods(function(){
52 VISIBILITY = "visibility",
59 ORIGINALDISPLAY = 'originalDisplay',
60 VISMODE = 'visibilityMode',
61 ISVISIBLE = 'isVisible',
63 getDisplay = function(dom){
64 var d = data(dom, ORIGINALDISPLAY);
66 data(dom, ORIGINALDISPLAY, d = '');
70 getVisMode = function(dom){
71 var m = data(dom, VISMODE);
73 data(dom, VISMODE, m = 1);
79 <div id="prop-Ext.Element-originalDisplay"></div>/**
80 * The element's default display mode (defaults to "")
86 <div id="method-Ext.Element-setVisibilityMode"></div>/**
87 * Sets the element's visibility mode. When setVisible() is called it
88 * will use this to determine whether to set the visibility or the display property.
89 * @param {Number} visMode Ext.Element.VISIBILITY or Ext.Element.DISPLAY
90 * @return {Ext.Element} this
92 setVisibilityMode : function(visMode){
93 data(this.dom, VISMODE, visMode);
97 <div id="method-Ext.Element-animate"></div>/**
98 * Perform custom animation on this element.
99 * <div><ul class="mdetail-params">
100 * <li><u>Animation Properties</u></li>
102 * <p>The Animation Control Object enables gradual transitions for any member of an
103 * element's style object that takes a numeric value including but not limited to
104 * these properties:</p><div><ul class="mdetail-params">
105 * <li><tt>bottom, top, left, right</tt></li>
106 * <li><tt>height, width</tt></li>
107 * <li><tt>margin, padding</tt></li>
108 * <li><tt>borderWidth</tt></li>
109 * <li><tt>opacity</tt></li>
110 * <li><tt>fontSize</tt></li>
111 * <li><tt>lineHeight</tt></li>
115 * <li><u>Animation Property Attributes</u></li>
117 * <p>Each Animation Property is a config object with optional properties:</p>
118 * <div><ul class="mdetail-params">
119 * <li><tt>by</tt>* : relative change - start at current value, change by this value</li>
120 * <li><tt>from</tt> : ignore current value, start from this value</li>
121 * <li><tt>to</tt>* : start at current value, go to this value</li>
122 * <li><tt>unit</tt> : any allowable unit specification</li>
123 * <p>* do not specify both <tt>to</tt> and <tt>by</tt> for an animation property</p>
126 * <li><u>Animation Types</u></li>
128 * <p>The supported animation types:</p><div><ul class="mdetail-params">
129 * <li><tt>'run'</tt> : Default
131 var el = Ext.get('complexEl');
133 // animation control object
135 borderWidth: {to: 3, from: 0},
136 opacity: {to: .3, from: 1},
137 height: {to: 50, from: el.getHeight()},
138 width: {to: 300, from: el.getWidth()},
139 top : {by: - 100, unit: 'px'},
141 0.35, // animation duration
143 'easeOut', // easing method
144 'run' // animation type ('run','color','motion','scroll')
148 * <li><tt>'color'</tt>
149 * <p>Animates transition of background, text, or border colors.</p>
152 // animation control object
154 color: { to: '#06e' },
155 backgroundColor: { to: '#e06' }
157 0.35, // animation duration
159 'easeOut', // easing method
160 'color' // animation type ('run','color','motion','scroll')
165 * <li><tt>'motion'</tt>
166 * <p>Animates the motion of an element to/from specific points using optional bezier
167 * way points during transit.</p>
170 // animation control object
172 borderWidth: {to: 3, from: 0},
173 opacity: {to: .3, from: 1},
174 height: {to: 50, from: el.getHeight()},
175 width: {to: 300, from: el.getWidth()},
176 top : {by: - 100, unit: 'px'},
178 to: [50, 100], // go to this point
179 control: [ // optional bezier way points
185 3000, // animation duration (milliseconds!)
187 'easeOut', // easing method
188 'motion' // animation type ('run','color','motion','scroll')
192 * <li><tt>'scroll'</tt>
193 * <p>Animate horizontal or vertical scrolling of an overflowing page element.</p>
196 // animation control object
198 scroll: {to: [400, 300]}
200 0.35, // animation duration
202 'easeOut', // easing method
203 'scroll' // animation type ('run','color','motion','scroll')
211 * @param {Object} args The animation control args
212 * @param {Float} duration (optional) How long the animation lasts in seconds (defaults to <tt>.35</tt>)
213 * @param {Function} onComplete (optional) Function to call when animation completes
214 * @param {String} easing (optional) {@link Ext.Fx#easing} method to use (defaults to <tt>'easeOut'</tt>)
215 * @param {String} animType (optional) <tt>'run'</tt> is the default. Can also be <tt>'color'</tt>,
216 * <tt>'motion'</tt>, or <tt>'scroll'</tt>
217 * @return {Ext.Element} this
219 animate : function(args, duration, onComplete, easing, animType){
220 this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
225 * @private Internal animation call
227 anim : function(args, opt, animType, defaultDur, defaultEase, cb){
228 animType = animType || 'run';
231 anim = Ext.lib.Anim[animType](
234 (opt.duration || defaultDur) || .35,
235 (opt.easing || defaultEase) || 'easeOut',
238 if(opt.callback) opt.callback.call(opt.scope || me, me, opt);
246 // private legacy anim prep
247 preanim : function(a, i){
248 return !a[i] ? false : (typeof a[i] == 'object' ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
251 <div id="method-Ext.Element-isVisible"></div>/**
252 * Checks whether the element is currently visible using both visibility and display properties.
253 * @return {Boolean} True if the element is currently visible, else false
255 isVisible : function() {
258 visible = data(dom, ISVISIBLE);
260 if(typeof visible == 'boolean'){ //return the cached value if registered
263 //Determine the current state based on display states
264 visible = !me.isStyle(VISIBILITY, HIDDEN) &&
265 !me.isStyle(DISPLAY, NONE) &&
266 !((getVisMode(dom) == El.ASCLASS) && me.hasClass(me.visibilityCls || El.visibilityCls));
268 data(dom, ISVISIBLE, visible);
272 <div id="method-Ext.Element-setVisible"></div>/**
273 * Sets the visibility of the element (see details). If the visibilityMode is set to Element.DISPLAY, it will use
274 * the display property to hide the element, otherwise it uses visibility. The default is to hide and show using the visibility property.
275 * @param {Boolean} visible Whether the element is visible
276 * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
277 * @return {Ext.Element} this
279 setVisible : function(visible, animate){
280 var me = this, isDisplay, isVisibility, isOffsets, isNosize,
282 visMode = getVisMode(dom);
285 // hideMode string override
286 if (typeof animate == 'string'){
289 visMode = El.DISPLAY;
292 visMode = El.VISIBILITY;
295 visMode = El.OFFSETS;
299 visMode = El.ASCLASS;
302 me.setVisibilityMode(visMode);
306 if (!animate || !me.anim) {
307 if(visMode == El.ASCLASS ){
309 me[visible?'removeClass':'addClass'](me.visibilityCls || El.visibilityCls);
311 } else if (visMode == El.DISPLAY){
313 return me.setDisplayed(visible);
315 } else if (visMode == El.OFFSETS){
318 me.hideModeStyles = {
319 position: me.getStyle('position'),
320 top: me.getStyle('top'),
321 left: me.getStyle('left')
323 me.applyStyles({position: 'absolute', top: '-10000px', left: '-10000px'});
325 me.applyStyles(me.hideModeStyles || {position: '', top: '', left: ''});
326 delete me.hideModeStyles;
331 dom.style.visibility = visible ? "visible" : HIDDEN;
334 // closure for composites
339 me.anim({opacity: { to: (visible?1:0) }},
340 me.preanim(arguments, 1),
345 visible || me.setVisible(false).setOpacity(1);
348 data(dom, ISVISIBLE, visible); //set logical visibility state
355 * Determine if the Element has a relevant height and width available based
356 * upon current logical visibility state
358 hasMetrics : function(){
360 return this.isVisible() || (getVisMode(dom) == El.VISIBILITY);
363 <div id="method-Ext.Element-toggle"></div>/**
364 * Toggles the element's visibility or display, depending on visibility mode.
365 * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
366 * @return {Ext.Element} this
368 toggle : function(animate){
370 me.setVisible(!me.isVisible(), me.preanim(arguments, 0));
374 <div id="method-Ext.Element-setDisplayed"></div>/**
375 * Sets the CSS display property. Uses originalDisplay if the specified value is a boolean true.
376 * @param {Mixed} value Boolean value to display the element using its default display, or a string to set the display directly.
377 * @return {Ext.Element} this
379 setDisplayed : function(value) {
380 if(typeof value == "boolean"){
381 value = value ? getDisplay(this.dom) : NONE;
383 this.setStyle(DISPLAY, value);
388 fixDisplay : function(){
390 if(me.isStyle(DISPLAY, NONE)){
391 me.setStyle(VISIBILITY, HIDDEN);
392 me.setStyle(DISPLAY, getDisplay(this.dom)); // first try reverting to default
393 if(me.isStyle(DISPLAY, NONE)){ // if that fails, default to block
394 me.setStyle(DISPLAY, "block");
399 <div id="method-Ext.Element-hide"></div>/**
400 * Hide this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.
401 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
402 * @return {Ext.Element} this
404 hide : function(animate){
406 if (typeof animate == 'string'){
407 this.setVisible(false, animate);
410 this.setVisible(false, this.preanim(arguments, 0));
414 <div id="method-Ext.Element-show"></div>/**
415 * Show this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.
416 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
417 * @return {Ext.Element} this
419 show : function(animate){
421 if (typeof animate == 'string'){
422 this.setVisible(true, animate);
425 this.setVisible(true, this.preanim(arguments, 0));