-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimplemented-new-replacebookmar.patch
executable file
·152 lines (146 loc) · 5.2 KB
/
implemented-new-replacebookmar.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
implemented new 'replaceBookmark' command
From: Chanwit Kaewkasi <[email protected]>
---
zk/src/archive/web/js/zk/html/au.js | 3 ++
zk/src/archive/web/js/zk/html/common.js | 13 +++++++-
zk/src/org/zkoss/zk/au/out/AuBookmark.java | 0
zk/src/org/zkoss/zk/au/out/AuReplaceBookmark.java | 36 +++++++++++++++++++++
zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java | 19 ++++++++++-
5 files changed, 68 insertions(+), 3 deletions(-)
mode change 100644 => 100755 zk/src/archive/web/js/zk/html/au.js
mode change 100644 => 100755 zk/src/archive/web/js/zk/html/common.js
mode change 100644 => 100755 zk/src/org/zkoss/zk/au/out/AuBookmark.java
create mode 100755 zk/src/org/zkoss/zk/au/out/AuReplaceBookmark.java
mode change 100644 => 100755 zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java
diff --git a/zk/src/archive/web/js/zk/html/au.js b/zk/src/archive/web/js/zk/html/au.js
old mode 100644
new mode 100755
index 8ab9b13..ee6f4d7
--- a/zk/src/archive/web/js/zk/html/au.js
+++ b/zk/src/archive/web/js/zk/html/au.js
@@ -2336,6 +2336,9 @@ zkau.history = new zk.History();
//Commands//
zkau.cmd0 = { //no uuid at all
+ replaceBookmark: function (dt0) {
+ zkau.history.replaceBookmark(dt0);
+ },
bookmark: function (dt0) {
zkau.history.bookmark(dt0);
},
diff --git a/zk/src/archive/web/js/zk/html/common.js b/zk/src/archive/web/js/zk/html/common.js
old mode 100644
new mode 100755
index c2df929..abfd884
--- a/zk/src/archive/web/js/zk/html/common.js
+++ b/zk/src/archive/web/js/zk/html/common.js
@@ -2614,11 +2614,22 @@ zk.History.prototype = {
//Though IE use history.html, timer is still required
//because user might specify URL directly
},
+ /** New version of setting a bookmark, use replace rather than creating a new history */
+ replaceBookmark: function (nm) {
+ if (this.curbk != nm) {
+ this.curbk = nm; //to avoid loop back the server
+ var encnm = nm;
+ var _hash = zk.safari || !encnm ? encnm: '#' + encnm;
+ location.replace(location.href.replace(/#.*/, "") + _hash);
+ this._bkIframe(nm);
+ zkau.onURLChange();
+ }
+ },
/** Sets a bookmark that user can use forward and back buttons */
bookmark: function (nm) {
if (this.curbk != nm) {
this.curbk = nm; //to avoid loop back the server
- var encnm = encodeURIComponent(nm);
+ var encnm = nm;
location.hash = zk.safari || !encnm ? encnm: '#' + encnm;
this._bkIframe(nm);
zkau.onURLChange();
diff --git a/zk/src/org/zkoss/zk/au/out/AuBookmark.java b/zk/src/org/zkoss/zk/au/out/AuBookmark.java
old mode 100644
new mode 100755
diff --git a/zk/src/org/zkoss/zk/au/out/AuReplaceBookmark.java b/zk/src/org/zkoss/zk/au/out/AuReplaceBookmark.java
new file mode 100755
index 0000000..c906f82
--- /dev/null
+++ b/zk/src/org/zkoss/zk/au/out/AuReplaceBookmark.java
@@ -0,0 +1,36 @@
+/* AuBookmark.java
+
+{{IS_NOTE
+ Purpose:
+
+ Description:
+
+ History:
+ Mon May 29 18:50:13 2006, Created by tomyeh
+}}IS_NOTE
+
+Copyright (C) 2006 Potix Corporation. All Rights Reserved.
+
+{{IS_RIGHT
+}}IS_RIGHT
+*/
+package org.zkoss.zk.au.out;
+
+import org.zkoss.zk.au.AuResponse;
+
+/**
+ * A response to ask the client to bookmark the desktop.
+ *
+ * <p>data[0]: the name of the bookmark.
+ *
+ * @author tomyeh
+ * @since 3.0.0
+ */
+public class AuReplaceBookmark extends AuResponse {
+ /**
+ * @param name the bookmark name.
+ */
+ public AuReplaceBookmark(String name) {
+ super("replaceBookmark", name); //component-independent
+ }
+}
diff --git a/zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java b/zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java
old mode 100644
new mode 100755
index 3e4e469..6cebca5
--- a/zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java
+++ b/zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java
@@ -76,6 +76,7 @@ import org.zkoss.zk.ui.sys.UiEngine;
import org.zkoss.zk.ui.sys.Visualizer;
import org.zkoss.zk.ui.impl.EventInterceptors;
import org.zkoss.zk.au.out.AuBookmark;
+import org.zkoss.zk.au.out.AuReplaceBookmark;
import org.zkoss.zk.device.Device;
import org.zkoss.zk.device.Devices;
import org.zkoss.zk.device.DeviceNotFoundException;
@@ -397,12 +398,26 @@ public class DesktopImpl implements Desktop, DesktopCtrl, java.io.Serializable {
public void setBookmark(String name) {
if (_exec == null)
throw new IllegalStateException("Not the current desktop: "+this);
- if (name.indexOf('#') >= 0 || name.indexOf('?') >= 0)
- throw new IllegalArgumentException("Illegal character: # ?");
+ //if (name.indexOf('#') >= 0 || name.indexOf('?') >= 0)
+ // throw new IllegalArgumentException("Illegal character: # ?");
_bookmark = name;
((WebAppCtrl)_wapp).getUiEngine()
.addResponse("bookmark", new AuBookmark(name));
}
+ public void setBookmark(String name, boolean replace) {
+ if (_exec == null)
+ throw new IllegalStateException("Not the current desktop: "+this);
+ //if (name.indexOf('#') >= 0 || name.indexOf('?') >= 0)
+ // throw new IllegalArgumentException("Illegal character: # ?");
+ _bookmark = name;
+ if(replace == true) {
+ ((WebAppCtrl)_wapp).getUiEngine()
+ .addResponse("replaceBookmark", new AuReplaceBookmark(name));
+ } else {
+ ((WebAppCtrl)_wapp).getUiEngine()
+ .addResponse("bookmark", new AuBookmark(name));
+ }
+ }
public Collection getComponents() {
return _comps.values();