Skip to content

Commit 7f24523

Browse files
authored
Merge pull request #1001 from GwtMaterialDesign/release_2.5.0_rc1
Release 2.5.0 rc1
2 parents c678b8e + c8915fc commit 7f24523

File tree

113 files changed

+5586
-791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+5586
-791
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cache:
88
- $HOME/.m2
99
before_install:
1010
# install the gwt-material-jquery because it will depends on built in jquery
11-
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
11+
- git clone -b release_2.5.0_rc1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
1212
- cd gwt-material-jquery
1313
- mvn install -DskipTests=true -DdryRun=true
1414
- cd ..

.utility/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -ev
3-
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.4.2" ]; then
3+
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.5.0_rc1" ]; then
44
echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
55
mvn deploy -DskipTests --settings ~/settings.xml
66
fi

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs
2020

2121

2222
## Maven
23-
### Current Version 2.4.2
23+
### Current Version 2.5.0-rc1
2424
```xml
2525
<dependency>
2626
<groupId>com.github.gwtmaterialdesign</groupId>
2727
<artifactId>gwt-material</artifactId>
28-
<version>2.4.2</version>
28+
<version>2.5.0-rc1</version>
2929
</dependency>
3030
```
3131
### Snapshot Version 2.5.0-SNAPSHOT

gwt-material/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>gwt-material-parent</artifactId>
66
<groupId>com.github.gwtmaterialdesign</groupId>
7-
<version>2.4.2</version>
7+
<version>2.5.0-rc1</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010

@@ -137,6 +137,7 @@
137137
<exclude>**/ui/**.java</exclude>
138138
</excludes>
139139
<includes>
140+
<!--<include>**/MixinTestSuite.java</include>-->
140141
<include>**/MaterialWidgetTestSuite.java</include>
141142
</includes>
142143
<!-- disable JVM asserts, but enable JS asserts for tests -->

gwt-material/src/main/java/gwt/material/design/client/MaterialDesignBase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
*/
2222

2323
import com.google.gwt.core.client.GWT;
24+
import com.google.gwt.core.client.JavaScriptObject;
2425
import com.google.gwt.core.client.ScriptInjector;
2526
import com.google.gwt.dom.client.StyleInjector;
2627
import com.google.gwt.resources.client.TextResource;
28+
import gwt.material.design.client.accessibility.AccessibilityControl;
29+
import gwt.material.design.client.resources.MaterialDebugResources;
2730
import gwt.material.design.client.resources.MaterialResources;
2831

2932
import java.util.ArrayList;
@@ -51,7 +54,8 @@ protected void load() {
5154
if(!isMaterializeLoaded()) {
5255
injectJs(MaterialResources.INSTANCE.materializeJs());
5356
injectJs(MaterialResources.INSTANCE.animationJs());
54-
injectJs(MaterialResources.INSTANCE.appInstallerJs());
57+
injectJs(MaterialResources.INSTANCE.clipboardJs());
58+
AccessibilityControl.get().load(false);
5559
}
5660
onModuleLoaded();
5761
}

gwt-material/src/main/java/gwt/material/design/client/MaterialDesignDebugBase.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@
2020
* #L%
2121
*/
2222

23+
import gwt.material.design.client.accessibility.AccessibilityControl;
2324
import gwt.material.design.client.resources.MaterialDebugResources;
2425

2526
public class MaterialDesignDebugBase extends MaterialDesignBase {
2627

2728
@Override
2829
public void load() {
2930
checkJQuery(true);
30-
if(!isMaterializeLoaded()) {
31+
if (!isMaterializeLoaded()) {
3132
injectDebugJs(MaterialDebugResources.INSTANCE.materializeJsDebug());
3233
injectDebugJs(MaterialDebugResources.INSTANCE.animationJsDebug());
3334
injectDebugJs(MaterialDebugResources.INSTANCE.appInstallerJsDebug());
35+
injectDebugJs(MaterialDebugResources.INSTANCE.clipboardJs());
36+
AccessibilityControl.get().load(true);
3437
}
3538
onModuleLoaded();
3639
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2021 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.client;
21+
22+
import com.google.gwt.core.client.EntryPoint;
23+
24+
public class MaterialWithoutResources implements EntryPoint {
25+
26+
@Override
27+
public void onModuleLoad() {
28+
29+
}
30+
}
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2020 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.client.accessibility;
21+
22+
import com.google.gwt.core.client.JavaScriptObject;
23+
import com.google.gwt.core.client.ScriptInjector;
24+
import com.google.gwt.event.dom.client.KeyCodes;
25+
import com.google.gwt.event.shared.HandlerRegistration;
26+
import com.google.gwt.resources.client.TextResource;
27+
import com.google.gwt.user.client.ui.Widget;
28+
import gwt.material.design.client.base.MaterialWidget;
29+
import gwt.material.design.client.js.JsMaterialElement;
30+
import gwt.material.design.client.resources.MaterialDebugResources;
31+
import gwt.material.design.client.resources.MaterialResources;
32+
import gwt.material.design.client.ui.MaterialToast;
33+
import gwt.material.design.jquery.client.api.JQuery;
34+
import gwt.material.design.jscore.client.api.core.Element;
35+
36+
import java.util.HashMap;
37+
import java.util.Map;
38+
39+
import static gwt.material.design.client.js.JsMaterialElement.$;
40+
41+
public class AccessibilityControl {
42+
43+
protected static final String FOCUS_VISIBILITY_CLASSNAME = "js-focus-visible";
44+
protected static final String FOCUS_VISIBILITY_ATTRIBUTE = "data-js-focus-visible";
45+
protected static final String FOCUS_VISIBLE_WIDGET = "focus-visible";
46+
protected static final String DATA_FOCUS_ADDED_ATTRIBUTE = "data-focus-visible-added";
47+
public static AccessibilityControl instance;
48+
protected JavaScriptObject resourceUrlObject;
49+
protected Map<HandlerRegistration, Widget> accessibilityHandlerRegistration;
50+
protected boolean enabled = true;
51+
protected boolean loaded;
52+
53+
public AccessibilityControl() {
54+
accessibilityHandlerRegistration = new HashMap<>();
55+
}
56+
57+
public void load(boolean debug) {
58+
TextResource resource;
59+
if (!loaded) {
60+
if (debug) {
61+
resource = MaterialDebugResources.INSTANCE.focusVisibleJsDebug();
62+
} else {
63+
resource = MaterialResources.INSTANCE.focusVisibleJs();
64+
}
65+
injectJs(resource);
66+
loaded = true;
67+
}
68+
}
69+
70+
protected void injectJs(TextResource resource) {
71+
String text = resource.getText() + ("//# sourceURL=" + resource.getName() + ".js");
72+
73+
// Inject the script resource
74+
resourceUrlObject = ScriptInjector.fromString(text)
75+
.setWindow(ScriptInjector.TOP_WINDOW)
76+
.inject();
77+
}
78+
79+
/**
80+
* This will register the accessibility control for a widget provided with keycodes
81+
*/
82+
public void registerWidget(MaterialWidget widget, int key) {
83+
registerWidget(widget, key, null);
84+
}
85+
86+
/**
87+
* This will register the accessibility control for a widget provided with default KeyCodes.ENTER
88+
*/
89+
public void registerWidget(MaterialWidget widget) {
90+
registerWidget(widget, KeyCodes.KEY_ENTER);
91+
}
92+
93+
public void registerWidget(MaterialWidget widget, TriggerCallback callback) {
94+
registerWidget(widget, KeyCodes.KEY_ENTER, callback);
95+
}
96+
97+
/**
98+
* This will register the accessibility control for a widget provided with keycodes and
99+
* TriggerCallback
100+
*/
101+
public void registerWidget(MaterialWidget widget, int key, TriggerCallback callback) {
102+
if (widget != null) {
103+
HandlerRegistration handlerRegistration = widget.registerHandler(widget.addKeyUpHandler(event -> {
104+
if (isEnabled() && event.getNativeKeyCode() == key) {
105+
if (callback != null) {
106+
callback.call(event);
107+
} else {
108+
triggerClick(widget);
109+
}
110+
}
111+
}));
112+
if (enabled) {
113+
widget.setTabIndex(0);
114+
} else {
115+
widget.getElement().removeAttribute("tabIndex");
116+
}
117+
accessibilityHandlerRegistration.put(handlerRegistration, widget);
118+
}
119+
}
120+
121+
/**
122+
* This will unregister any accessibility control to a widget
123+
* @param widget
124+
*/
125+
public void unregisterWidget(Widget widget) {
126+
if (widget != null) {
127+
if (widget.getElement().hasClassName(FOCUS_VISIBLE_WIDGET)) {
128+
widget.removeStyleName(FOCUS_VISIBLE_WIDGET);
129+
}
130+
131+
if (widget.getElement().hasAttribute(DATA_FOCUS_ADDED_ATTRIBUTE)) {
132+
widget.getElement().removeAttribute(DATA_FOCUS_ADDED_ATTRIBUTE);
133+
}
134+
accessibilityHandlerRegistration.forEach((handlerRegistration, currentWidget) -> {
135+
if (widget == currentWidget) {
136+
handlerRegistration.removeHandler();
137+
}
138+
});
139+
}
140+
}
141+
142+
public void unload() {
143+
JsMaterialElement html = $("html");
144+
if (html != null) {
145+
if (html.hasClass(FOCUS_VISIBILITY_CLASSNAME)) {
146+
html.removeClass(FOCUS_VISIBILITY_CLASSNAME);
147+
}
148+
html.removeAttr(FOCUS_VISIBILITY_ATTRIBUTE);
149+
}
150+
151+
if (resourceUrlObject != null) {
152+
JsMaterialElement scriptTag = $(resourceUrlObject.cast());
153+
scriptTag.remove();
154+
}
155+
loaded = false;
156+
}
157+
158+
public void triggerClick(Widget widget) {
159+
if (widget != null) {
160+
JQuery.$(widget.getElement()).click();
161+
}
162+
}
163+
164+
public boolean isEnabled() {
165+
return enabled;
166+
}
167+
168+
public void setEnabled(boolean enabled) {
169+
this.enabled = enabled;
170+
}
171+
172+
public static AccessibilityControl get() {
173+
if (instance == null) {
174+
instance = new AccessibilityControl();
175+
}
176+
return instance;
177+
}
178+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2020 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.client.accessibility;
21+
22+
import com.google.gwt.event.dom.client.KeyUpEvent;
23+
24+
public interface TriggerCallback {
25+
26+
void call(KeyUpEvent event);
27+
}

gwt-material/src/main/java/gwt/material/design/client/base/AbstractSideNav.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.gwt.user.client.Window;
2929
import com.google.gwt.user.client.ui.RootPanel;
3030
import com.google.gwt.user.client.ui.Widget;
31+
import gwt.material.design.client.accessibility.AccessibilityControl;
3132
import gwt.material.design.client.base.density.Density;
3233
import gwt.material.design.client.base.helper.DOMHelper;
3334
import gwt.material.design.client.base.mixin.DensityMixin;
@@ -281,6 +282,9 @@ protected void load(boolean strict) {
281282
navMenu.setHideOn(HideOn.HIDE_ON_LARGE);
282283
}
283284
navMenu.removeStyleName(CssName.NAVMENU_PERMANENT);
285+
286+
// Register Nav Menu Accessibility
287+
AccessibilityControl.get().registerWidget(navMenu);
284288
}
285289
} catch (Exception ex) {
286290
if (strict) {

0 commit comments

Comments
 (0)