01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.user.client.ui.impl;
17:
18: import com.google.gwt.user.client.Element;
19:
20: /**
21: * Internet Explorer 6 implementation of
22: * {@link com.google.gwt.user.client.ui.impl.PopupImpl}.
23: */
24: public class PopupImplIE6 extends PopupImpl {
25:
26: @Override
27: public native void onHide(Element popup) /*-{
28: var frame = popup.__frame;
29: frame.parentElement.removeChild(frame);
30: popup.__frame = null;
31: frame.__popup = null;
32: }-*/;
33:
34: @Override
35: public native void onShow(Element popup) /*-{
36: // TODO: make this more Java and less JSNI?
37: var frame = $doc.createElement('iframe');
38:
39: // Setting a src prevents mixed-content warnings.
40: // http://weblogs.asp.net/bleroy/archive/2005/08/09/how-to-put-a-div-over-a-select-in-ie.aspx
41: frame.src = "javascript:''";
42:
43: frame.scrolling = 'no';
44: frame.frameBorder = 0;
45:
46: popup.__frame = frame;
47: frame.__popup = popup;
48:
49: // Make the frame shadow the popup
50: var style = frame.style;
51: style.position = 'absolute';
52:
53: // Don't get in the way of transparency effects
54: style.filter = 'alpha(opacity=0)';
55:
56: // Visibility of frame should match visiblity of popup element.
57: style.visibility = popup.style.visibility;
58:
59: // takes effect immediately
60: style.left = popup.offsetLeft;
61: style.top = popup.offsetTop;
62: style.width = popup.offsetWidth;
63: style.height = popup.offsetHeight;
64:
65: // updates position and dimensions as popup is moved & resized
66: style.setExpression('left', 'this.__popup.offsetLeft');
67: style.setExpression('top', 'this.__popup.offsetTop');
68: style.setExpression('width', 'this.__popup.offsetWidth');
69: style.setExpression('height', 'this.__popup.offsetHeight');
70: popup.parentElement.insertBefore(frame, popup);
71: }-*/;
72:
73: @Override
74: public native void setVisible(Element popup, boolean visible) /*-{
75: if (popup.__frame) {
76: popup.__frame.style.visibility = visible ? 'visible' : 'hidden';
77: }
78: }-*/;
79: }
|