3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
10 Ext.Element.addMethods(
12 var VISIBILITY = "visibility",
17 XMASKEDRELATIVE = "x-masked-relative",
18 data = Ext.Element.data;
22 * Checks whether the element is currently visible using both visibility and display properties.
23 * @param {Boolean} deep (optional) True to walk the dom and see if parent elements are hidden (defaults to false)
24 * @return {Boolean} True if the element is currently visible, else false
26 isVisible : function(deep) {
27 var vis = !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE),
28 p = this.dom.parentNode;
30 if (deep !== true || !vis) {
34 while (p && !(/^body/i.test(p.tagName))) {
35 if (!Ext.fly(p, '_isVisible').isVisible()) {
44 * Returns true if display is not "none"
47 isDisplayed : function() {
48 return !this.isStyle(DISPLAY, NONE);
52 * Convenience method for setVisibilityMode(Element.DISPLAY)
53 * @param {String} display (optional) What to set display to when visible
54 * @return {Ext.Element} this
56 enableDisplayMode : function(display) {
57 this.setVisibilityMode(Ext.Element.DISPLAY);
59 if (!Ext.isEmpty(display)) {
60 data(this.dom, 'originalDisplay', display);
67 * Puts a mask over this element to disable user interaction. Requires core.css.
68 * This method can only be applied to elements which accept child nodes.
69 * @param {String} msg (optional) A message to display in the mask
70 * @param {String} msgCls (optional) A css class to apply to the msg element
71 * @return {Element} The mask element
73 mask : function(msg, msgCls) {
77 EXTELMASKMSG = "ext-el-mask-msg",
81 if (!(/^body/i.test(dom.tagName) && me.getStyle('position') == 'static')) {
82 me.addClass(XMASKEDRELATIVE);
84 if (el = data(dom, 'maskMsg')) {
87 if (el = data(dom, 'mask')) {
91 mask = dh.append(dom, {cls : "ext-el-mask"}, true);
92 data(dom, 'mask', mask);
95 mask.setDisplayed(true);
97 if (typeof msg == 'string') {
98 var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
99 data(dom, 'maskMsg', mm);
100 mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
101 mm.dom.firstChild.innerHTML = msg;
102 mm.setDisplayed(true);
106 // ie will not expand full height automatically
107 if (Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto') {
108 mask.setSize(undefined, me.getHeight());
115 * Removes a previously applied mask.
117 unmask : function() {
120 mask = data(dom, 'mask'),
121 maskMsg = data(dom, 'maskMsg');
126 data(dom, 'maskMsg', undefined);
130 data(dom, 'mask', undefined);
131 me.removeClass([XMASKED, XMASKEDRELATIVE]);
136 * Returns true if this element is masked
139 isMasked : function() {
140 var m = data(this.dom, 'mask');
141 return m && m.isVisible();
145 * Creates an iframe shim for this element to keep selects and other windowed objects from
147 * @return {Ext.Element} The new shim element
149 createShim : function() {
150 var el = document.createElement('iframe'),
153 el.frameBorder = '0';
154 el.className = 'ext-shim';
155 el.src = Ext.SSL_SECURE_URL;
156 shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
157 shim.autoBoxAdjust = false;