3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.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;
29 if(deep !== true || !vis){
32 while(p && !/^body/i.test(p.tagName)){
33 if(!Ext.fly(p, '_isVisible').isVisible()){
42 * Returns true if display is not "none"
45 isDisplayed : function() {
46 return !this.isStyle(DISPLAY, NONE);
50 * Convenience method for setVisibilityMode(Element.DISPLAY)
51 * @param {String} display (optional) What to set display to when visible
52 * @return {Ext.Element} this
54 enableDisplayMode : function(display){
55 this.setVisibilityMode(Ext.Element.DISPLAY);
56 if(!Ext.isEmpty(display)){
57 data(this.dom, 'originalDisplay', display);
63 * Puts a mask over this element to disable user interaction. Requires core.css.
64 * This method can only be applied to elements which accept child nodes.
65 * @param {String} msg (optional) A message to display in the mask
66 * @param {String} msgCls (optional) A css class to apply to the msg element
67 * @return {Element} The mask element
69 mask : function(msg, msgCls){
73 EXTELMASKMSG = "ext-el-mask-msg",
77 if(!/^body/i.test(dom.tagName) && me.getStyle('position') == 'static'){
78 me.addClass(XMASKEDRELATIVE);
80 if((el = data(dom, 'maskMsg'))){
83 if((el = data(dom, 'mask'))){
87 mask = dh.append(dom, {cls : "ext-el-mask"}, true);
88 data(dom, 'mask', mask);
91 mask.setDisplayed(true);
92 if(typeof msg == 'string'){
93 var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
94 data(dom, 'maskMsg', mm);
95 mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
96 mm.dom.firstChild.innerHTML = msg;
97 mm.setDisplayed(true);
100 if(Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto'){ // ie will not expand full height automatically
101 mask.setSize(undefined, me.getHeight());
107 * Removes a previously applied mask.
112 mask = data(dom, 'mask'),
113 maskMsg = data(dom, 'maskMsg');
117 data(dom, 'maskMsg', undefined);
120 data(dom, 'mask', undefined);
122 me.removeClass([XMASKED, XMASKEDRELATIVE]);
126 * Returns true if this element is masked
129 isMasked : function(){
130 var m = data(this.dom, 'mask');
131 return m && m.isVisible();
135 * Creates an iframe shim for this element to keep selects and other windowed objects from
137 * @return {Ext.Element} The new shim element
139 createShim : function(){
140 var el = document.createElement('iframe'),
142 el.frameBorder = '0';
143 el.className = 'ext-shim';
144 el.src = Ext.SSL_SECURE_URL;
145 shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
146 shim.autoBoxAdjust = false;