KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > impl > HistoryImplSafari


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.impl;
17
18 import com.google.gwt.user.client.Element;
19
20 /**
21  * Safari implementation of
22  * {@link com.google.gwt.user.client.impl.HistoryImplFrame}.
23  */

24 class HistoryImplSafari extends HistoryImplFrame {
25
26   protected native String JavaDoc getTokenElementContent(Element tokenElement) /*-{
27     return tokenElement.value;
28   }-*/
;
29
30   protected native void initHistoryToken() /*-{
31     // Get the initial token from the url's hash component.
32     var hash = $wnd.location.hash;
33     if (hash.length > 0)
34       $wnd.__gwt_historyToken = decodeURIComponent(hash.substring(1));
35     else
36       $wnd.__gwt_historyToken = '';
37   }-*/
;
38
39   protected native void injectGlobalHandler() /*-{
40     $wnd.__gwt_onHistoryLoad = function(token) {
41       token = decodeURIComponent(token);
42
43       // Change the URL and notify the application that its history frame
44       // is changing.
45       if (token != $wnd.__gwt_historyToken) {
46         $wnd.__gwt_historyToken = token;
47
48 // TODO(jgw): can't actually do this on Safari without screwing everything up.
49 // $wnd.location.hash = encodeURIComponent(token);
50
51         // Fire the event.
52         @com.google.gwt.user.client.impl.HistoryImpl::onHistoryChanged(Ljava/lang/String;)(token);
53       }
54     };
55   }-*/
;
56
57   protected native void newItemImpl(Element historyFrame, String JavaDoc historyToken,
58       boolean forceAdd) /*-{
59     // Ignore 'forceAdd'. It's only needed on IE.
60
61     // The history frame's contentWindow can be null when backing into an
62     // application. For some reason, the history frame will finish loading
63     // *after* the application itself, which is a bit of a race condition.
64     if (historyFrame.contentWindow) {
65       historyToken = historyToken || "";
66
67       var base = @com.google.gwt.core.client.GWT::getModuleBaseURL()();
68       historyFrame.contentWindow.location.href = base + 'history.html?' + historyToken;
69     }
70   }-*/
;
71 }
72
Popular Tags