1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.common.ui.client.util; |
17 |
|
|
18 |
|
import com.google.gwt.dom.client.Element; |
19 |
|
import com.google.gwt.dom.client.Style; |
20 |
|
import com.google.gwt.user.client.Command; |
21 |
|
import com.google.gwt.user.client.DeferredCommand; |
22 |
|
import com.google.gwt.user.client.Timer; |
23 |
|
import com.google.gwt.user.client.ui.UIObject; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
|
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 12 |
Complexity Density: 0.38 |
|
29 |
|
public class Elements { |
30 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
31 |
|
public interface FadeCallback { |
32 |
|
public void onFadeComplete(); |
33 |
|
|
34 |
|
public void onFadeStart(); |
35 |
|
} |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 2 |
Complexity Density: - |
|
37 |
|
public static class EmptyFadeCallback implements FadeCallback { |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
38 |
0
|
public void onFadeComplete() {}... |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
39 |
0
|
public void onFadeStart() {}... |
40 |
|
} |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
|
50 |
|
@param |
51 |
|
|
52 |
|
@param |
53 |
|
|
54 |
|
@param |
55 |
|
|
56 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
0
|
public static void fadeIn(final UIObject target, final int milliseconds, final int maxOpacity,... |
58 |
|
final FadeCallback callback) { |
59 |
0
|
fadeIn(target.getElement(), milliseconds, maxOpacity, callback); |
60 |
|
} |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
61 |
0
|
public static void fadeIn(final Element e, final int milliseconds, final int maxOpacity,... |
62 |
|
final FadeCallback callback) { |
63 |
|
|
64 |
0
|
final int interval = milliseconds / 50; |
65 |
0
|
setOpacity(e, 0); |
66 |
0
|
DeferredCommand.addCommand(new Command() { |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
68 |
0
|
@Override... |
69 |
|
public void execute() { |
70 |
0
|
callback.onFadeStart(); |
71 |
|
|
72 |
0
|
final Timer t = new Timer() { |
73 |
|
int pct = 0; |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
75 |
0
|
@Override... |
76 |
|
public void run() { |
77 |
0
|
pct += 2; |
78 |
0
|
pct = Math.min(pct, maxOpacity); |
79 |
0
|
setOpacity(e, pct); |
80 |
0
|
if (pct == maxOpacity) { |
81 |
0
|
this.cancel(); |
82 |
0
|
callback.onFadeComplete(); |
83 |
|
} |
84 |
|
} |
85 |
|
}; |
86 |
0
|
t.scheduleRepeating(interval); |
87 |
|
|
88 |
|
} |
89 |
|
}); |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
@param |
97 |
|
|
98 |
|
@param |
99 |
|
|
100 |
|
@param |
101 |
|
|
102 |
|
@param |
103 |
|
|
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0
|
public static void fadeOut(final UIObject target, final int milliseconds, final int minOpacity, ... |
106 |
|
final FadeCallback callback) { |
107 |
0
|
fadeOut(target.getElement(), milliseconds, minOpacity, callback); |
108 |
|
} |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
109 |
0
|
public static void fadeOut(final Element e, final int milliseconds, final int minOpacity, ... |
110 |
|
final FadeCallback callback) { |
111 |
|
|
112 |
0
|
final int interval = milliseconds / 50; |
113 |
0
|
DeferredCommand.addCommand(new Command() { |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
115 |
0
|
@Override... |
116 |
|
public void execute() { |
117 |
0
|
callback.onFadeStart(); |
118 |
|
|
119 |
0
|
final Timer t = new Timer() { |
120 |
|
int pct = 100; |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
122 |
0
|
@Override... |
123 |
|
public void run() { |
124 |
0
|
pct -= 2; |
125 |
0
|
pct = Math.max(pct, minOpacity); |
126 |
0
|
setOpacity(e, pct); |
127 |
0
|
if (pct == minOpacity) { |
128 |
0
|
this.cancel(); |
129 |
0
|
callback.onFadeComplete(); |
130 |
|
} |
131 |
|
} |
132 |
|
}; |
133 |
0
|
t.scheduleRepeating(interval); |
134 |
|
|
135 |
|
} |
136 |
|
}); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
@param |
143 |
|
@param |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
145 |
0
|
public static void setOpacity(final UIObject u, final int percent) {... |
146 |
0
|
setOpacity(u.getElement(), percent); |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
@param |
153 |
|
@param |
154 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
155 |
0
|
public static void setOpacity(final Element e, final int percent) {... |
156 |
0
|
final Style s = e.getStyle(); |
157 |
0
|
final double d = ((double) percent / (double) 100); |
158 |
0
|
s.setProperty("opacity", String.valueOf(d)); |
159 |
0
|
s.setProperty("MozOpacity", String.valueOf(d)); |
160 |
0
|
s.setProperty("KhtmlOpacity", String.valueOf(d)); |
161 |
0
|
s.setProperty("filter", "alpha(opacity=" + percent + ")"); |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
@param |
168 |
|
@param |
169 |
|
|
170 |
|
public static native void setTextSelectable(Element e, boolean selectable) |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
; |
181 |
|
} |