4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../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-core-Element'>/**
19 </span> * @class Ext.core.Element
21 Ext.core.Element.addMethods(
23 var VISIBILITY = "visibility",
24 DISPLAY = "display",
25 HIDDEN = "hidden",
26 NONE = "none",
27 XMASKED = Ext.baseCSSPrefix + "masked",
28 XMASKEDRELATIVE = Ext.baseCSSPrefix + "masked-relative",
29 data = Ext.core.Element.data;
32 <span id='Ext-core-Element-method-isVisible'> /**
33 </span> * Checks whether the element is currently visible using both visibility and display properties.
34 * @param {Boolean} deep (optional) True to walk the dom and see if parent elements are hidden (defaults to false)
35 * @return {Boolean} True if the element is currently visible, else false
37 isVisible : function(deep) {
38 var vis = !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE),
39 p = this.dom.parentNode;
41 if (deep !== true || !vis) {
45 while (p && !(/^body/i.test(p.tagName))) {
46 if (!Ext.fly(p, '_isVisible').isVisible()) {
54 <span id='Ext-core-Element-method-isDisplayed'> /**
55 </span> * Returns true if display is not "none"
58 isDisplayed : function() {
59 return !this.isStyle(DISPLAY, NONE);
62 <span id='Ext-core-Element-method-enableDisplayMode'> /**
63 </span> * Convenience method for setVisibilityMode(Element.DISPLAY)
64 * @param {String} display (optional) What to set display to when visible
65 * @return {Ext.core.Element} this
67 enableDisplayMode : function(display) {
68 this.setVisibilityMode(Ext.core.Element.DISPLAY);
70 if (!Ext.isEmpty(display)) {
71 data(this.dom, 'originalDisplay', display);
77 <span id='Ext-core-Element-method-mask'> /**
78 </span> * Puts a mask over this element to disable user interaction. Requires core.css.
79 * This method can only be applied to elements which accept child nodes.
80 * @param {String} msg (optional) A message to display in the mask
81 * @param {String} msgCls (optional) A css class to apply to the msg element
82 * @return {Element} The mask element
84 mask : function(msg, msgCls) {
87 setExpression = dom.style.setExpression,
88 dh = Ext.core.DomHelper,
89 EXTELMASKMSG = Ext.baseCSSPrefix + "mask-msg",
93 if (!(/^body/i.test(dom.tagName) && me.getStyle('position') == 'static')) {
94 me.addCls(XMASKEDRELATIVE);
96 el = data(dom, 'maskMsg');
100 el = data(dom, 'mask');
105 mask = dh.append(dom, {cls : Ext.baseCSSPrefix + "mask"}, true);
106 data(dom, 'mask', mask);
109 mask.setDisplayed(true);
111 if (typeof msg == 'string') {
112 var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
113 data(dom, 'maskMsg', mm);
114 mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
115 mm.dom.firstChild.innerHTML = msg;
116 mm.setDisplayed(true);
119 // NOTE: CSS expressions are resource intensive and to be used only as a last resort
120 // These expressions are removed as soon as they are no longer necessary - in the unmask method.
121 // In normal use cases an element will be masked for a limited period of time.
122 // Fix for https://sencha.jira.com/browse/EXTJSIV-19.
123 // IE6 strict mode and IE6-9 quirks mode takes off left+right padding when calculating width!
124 if (!Ext.supports.IncludePaddingInWidthCalculation && setExpression) {
125 mask.dom.style.setExpression('width', 'this.parentNode.offsetWidth + "px"');
128 // Some versions and modes of IE subtract top+bottom padding when calculating height.
129 // Different versions from those which make the same error for width!
130 if (!Ext.supports.IncludePaddingInHeightCalculation && setExpression) {
131 mask.dom.style.setExpression('height', 'this.parentNode.offsetHeight + "px"');
133 // ie will not expand full height automatically
134 else if (Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto') {
135 mask.setSize(undefined, me.getHeight());
140 <span id='Ext-core-Element-method-unmask'> /**
141 </span> * Removes a previously applied mask.
143 unmask : function() {
146 mask = data(dom, 'mask'),
147 maskMsg = data(dom, 'maskMsg');
150 // Remove resource-intensive CSS expressions as soon as they are not required.
151 if (mask.dom.style.clearExpression) {
152 mask.dom.style.clearExpression('width');
153 mask.dom.style.clearExpression('height');
157 data(dom, 'maskMsg', undefined);
161 data(dom, 'mask', undefined);
162 me.removeCls([XMASKED, XMASKEDRELATIVE]);
165 <span id='Ext-core-Element-method-isMasked'> /**
166 </span> * Returns true if this element is masked. Also re-centers any displayed message within the mask.
169 isMasked : function() {
171 mask = data(me.dom, 'mask'),
172 maskMsg = data(me.dom, 'maskMsg');
174 if (mask && mask.isVisible()) {
183 <span id='Ext-core-Element-method-createShim'> /**
184 </span> * Creates an iframe shim for this element to keep selects and other windowed objects from
186 * @return {Ext.core.Element} The new shim element
188 createShim : function() {
189 var el = document.createElement('iframe'),
192 el.frameBorder = '0';
193 el.className = Ext.baseCSSPrefix + 'shim';
194 el.src = Ext.SSL_SECURE_URL;
195 shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
196 shim.autoBoxAdjust = false;