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: /**
19: * Mozilla-specific implementation of rich-text editing.
20: */
21: public class RichTextAreaImplMozilla extends RichTextAreaImplStandard {
22:
23: @Override
24: public native void initElement() /*-{
25: // Mozilla doesn't allow designMode to be set reliably until the iframe is
26: // fully loaded.
27: var _this = this;
28: var iframe = _this.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem;
29:
30: iframe.onload = function() {
31: // Some Mozillae have the nasty habit of calling onload again when you set
32: // designMode, so let's avoid doing it more than once.
33: iframe.onload = null;
34:
35: // Send notification that the iframe has finished loading.
36: _this.@com.google.gwt.user.client.ui.impl.RichTextAreaImplStandard::onElementInitialized()();
37:
38: // Don't set designMode until the RTA actually gets focused. This is
39: // necessary because editing won't work on Mozilla if the iframe is
40: // *hidden, but attached*. Waiting for focus gets around this issue.
41: //
42: // Note: This onfocus will not conflict with the addEventListener('focus',
43: // ...) // in RichTextAreaImplStandard.
44: iframe.contentWindow.onfocus = function() {
45: iframe.contentWindow.onfocus = null;
46: iframe.contentWindow.document.designMode = 'On';
47: };
48: };
49: }-*/;
50:
51: @Override
52: public void setBackColor(String color) {
53: // Gecko uses 'BackColor' for the *entire area's* background. 'HiliteColor'
54: // does what we actually want.
55: execCommand("HiliteColor", color);
56: }
57: }
|