3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
15 * @class Ext.Element
\r
17 Ext.Element.addMethods(
\r
19 var VISIBILITY = "visibility",
\r
20 DISPLAY = "display",
\r
23 XMASKED = "x-masked",
\r
24 XMASKEDRELATIVE = "x-masked-relative",
\r
25 data = Ext.Element.data;
\r
28 <div id="method-Ext.Element-isVisible"></div>/**
\r
29 * Checks whether the element is currently visible using both visibility and display properties.
\r
30 * @param {Boolean} deep (optional) True to walk the dom and see if parent elements are hidden (defaults to false)
\r
31 * @return {Boolean} True if the element is currently visible, else false
\r
33 isVisible : function(deep) {
\r
34 var vis = !this.isStyle(VISIBILITY,HIDDEN) && !this.isStyle(DISPLAY,NONE),
\r
35 p = this.dom.parentNode;
\r
36 if(deep !== true || !vis){
\r
39 while(p && !/body/i.test(p.tagName)){
\r
40 if(!Ext.fly(p, '_isVisible').isVisible()){
\r
48 <div id="method-Ext.Element-isDisplayed"></div>/**
\r
49 * Returns true if display is not "none"
\r
52 isDisplayed : function() {
\r
53 return !this.isStyle(DISPLAY, NONE);
\r
56 <div id="method-Ext.Element-enableDisplayMode"></div>/**
\r
57 * Convenience method for setVisibilityMode(Element.DISPLAY)
\r
58 * @param {String} display (optional) What to set display to when visible
\r
59 * @return {Ext.Element} this
\r
61 enableDisplayMode : function(display){
\r
62 this.setVisibilityMode(Ext.Element.DISPLAY);
\r
63 if(!Ext.isEmpty(display)){
\r
64 data(this.dom, 'originalDisplay', display);
\r
69 <div id="method-Ext.Element-mask"></div>/**
\r
70 * Puts a mask over this element to disable user interaction. Requires core.css.
\r
71 * This method can only be applied to elements which accept child nodes.
\r
72 * @param {String} msg (optional) A message to display in the mask
\r
73 * @param {String} msgCls (optional) A css class to apply to the msg element
\r
74 * @return {Element} The mask element
\r
76 mask : function(msg, msgCls){
\r
80 EXTELMASKMSG = "ext-el-mask-msg",
\r
84 if(me.getStyle("position") == "static"){
\r
85 me.addClass(XMASKEDRELATIVE);
\r
87 if((el = data(dom, 'maskMsg'))){
\r
90 if((el = data(dom, 'mask'))){
\r
94 mask = dh.append(dom, {cls : "ext-el-mask"}, true);
\r
95 data(dom, 'mask', mask);
\r
97 me.addClass(XMASKED);
\r
98 mask.setDisplayed(true);
\r
99 if(typeof msg == 'string'){
\r
100 var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
\r
101 data(dom, 'maskMsg', mm);
\r
102 mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
\r
103 mm.dom.firstChild.innerHTML = msg;
\r
104 mm.setDisplayed(true);
\r
107 if(Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto'){ // ie will not expand full height automatically
\r
108 mask.setSize(undefined, me.getHeight());
\r
113 <div id="method-Ext.Element-unmask"></div>/**
\r
114 * Removes a previously applied mask.
\r
116 unmask : function(){
\r
119 mask = data(dom, 'mask'),
\r
120 maskMsg = data(dom, 'maskMsg');
\r
124 data(dom, 'maskMsg', undefined);
\r
127 data(dom, 'mask', undefined);
\r
129 me.removeClass([XMASKED, XMASKEDRELATIVE]);
\r
132 <div id="method-Ext.Element-isMasked"></div>/**
\r
133 * Returns true if this element is masked
\r
134 * @return {Boolean}
\r
136 isMasked : function(){
\r
137 var m = data(this.dom, 'mask');
\r
138 return m && m.isVisible();
\r
141 <div id="method-Ext.Element-createShim"></div>/**
\r
142 * Creates an iframe shim for this element to keep selects and other windowed objects from
\r
144 * @return {Ext.Element} The new shim element
\r
146 createShim : function(){
\r
147 var el = document.createElement('iframe'),
\r
149 el.frameBorder = '0';
\r
150 el.className = 'ext-shim';
\r
151 el.src = Ext.SSL_SECURE_URL;
\r
152 shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
\r
153 shim.autoBoxAdjust = false;
\r