Skip to content

Commit

Permalink
Merge pull request #1001 from GwtMaterialDesign/release_2.5.0_rc1
Browse files Browse the repository at this point in the history
Release 2.5.0 rc1
  • Loading branch information
kevzlou7979 committed Feb 24, 2021
2 parents c678b8e + c8915fc commit 7f24523
Show file tree
Hide file tree
Showing 113 changed files with 5,586 additions and 791 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -8,7 +8,7 @@ cache:
- $HOME/.m2
before_install:
# install the gwt-material-jquery because it will depends on built in jquery
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
- git clone -b release_2.5.0_rc1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
- cd gwt-material-jquery
- mvn install -DskipTests=true -DdryRun=true
- cd ..
Expand Down
2 changes: 1 addition & 1 deletion .utility/deploy.sh
@@ -1,6 +1,6 @@
#!/bin/bash
set -ev
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.4.2" ]; then
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.5.0_rc1" ]; then
echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
mvn deploy -DskipTests --settings ~/settings.xml
fi
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -20,12 +20,12 @@ We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs


## Maven
### Current Version 2.4.2
### Current Version 2.5.0-rc1
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>2.4.2</version>
<version>2.5.0-rc1</version>
</dependency>
```
### Snapshot Version 2.5.0-SNAPSHOT
Expand Down
3 changes: 2 additions & 1 deletion gwt-material/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.4.2</version>
<version>2.5.0-rc1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -137,6 +137,7 @@
<exclude>**/ui/**.java</exclude>
</excludes>
<includes>
<!--<include>**/MixinTestSuite.java</include>-->
<include>**/MaterialWidgetTestSuite.java</include>
</includes>
<!-- disable JVM asserts, but enable JS asserts for tests -->
Expand Down
Expand Up @@ -21,9 +21,12 @@
*/

import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.ScriptInjector;
import com.google.gwt.dom.client.StyleInjector;
import com.google.gwt.resources.client.TextResource;
import gwt.material.design.client.accessibility.AccessibilityControl;
import gwt.material.design.client.resources.MaterialDebugResources;
import gwt.material.design.client.resources.MaterialResources;

import java.util.ArrayList;
Expand Down Expand Up @@ -51,7 +54,8 @@ protected void load() {
if(!isMaterializeLoaded()) {
injectJs(MaterialResources.INSTANCE.materializeJs());
injectJs(MaterialResources.INSTANCE.animationJs());
injectJs(MaterialResources.INSTANCE.appInstallerJs());
injectJs(MaterialResources.INSTANCE.clipboardJs());
AccessibilityControl.get().load(false);
}
onModuleLoaded();
}
Expand Down
Expand Up @@ -20,17 +20,20 @@
* #L%
*/

import gwt.material.design.client.accessibility.AccessibilityControl;
import gwt.material.design.client.resources.MaterialDebugResources;

public class MaterialDesignDebugBase extends MaterialDesignBase {

@Override
public void load() {
checkJQuery(true);
if(!isMaterializeLoaded()) {
if (!isMaterializeLoaded()) {
injectDebugJs(MaterialDebugResources.INSTANCE.materializeJsDebug());
injectDebugJs(MaterialDebugResources.INSTANCE.animationJsDebug());
injectDebugJs(MaterialDebugResources.INSTANCE.appInstallerJsDebug());
injectDebugJs(MaterialDebugResources.INSTANCE.clipboardJs());
AccessibilityControl.get().load(true);
}
onModuleLoaded();
}
Expand Down
@@ -0,0 +1,30 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2021 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client;

import com.google.gwt.core.client.EntryPoint;

public class MaterialWithoutResources implements EntryPoint {

@Override
public void onModuleLoad() {

}
}
@@ -0,0 +1,178 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2020 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client.accessibility;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.ScriptInjector;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.resources.client.TextResource;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.MaterialWidget;
import gwt.material.design.client.js.JsMaterialElement;
import gwt.material.design.client.resources.MaterialDebugResources;
import gwt.material.design.client.resources.MaterialResources;
import gwt.material.design.client.ui.MaterialToast;
import gwt.material.design.jquery.client.api.JQuery;
import gwt.material.design.jscore.client.api.core.Element;

import java.util.HashMap;
import java.util.Map;

import static gwt.material.design.client.js.JsMaterialElement.$;

public class AccessibilityControl {

protected static final String FOCUS_VISIBILITY_CLASSNAME = "js-focus-visible";
protected static final String FOCUS_VISIBILITY_ATTRIBUTE = "data-js-focus-visible";
protected static final String FOCUS_VISIBLE_WIDGET = "focus-visible";
protected static final String DATA_FOCUS_ADDED_ATTRIBUTE = "data-focus-visible-added";
public static AccessibilityControl instance;
protected JavaScriptObject resourceUrlObject;
protected Map<HandlerRegistration, Widget> accessibilityHandlerRegistration;
protected boolean enabled = true;
protected boolean loaded;

public AccessibilityControl() {
accessibilityHandlerRegistration = new HashMap<>();
}

public void load(boolean debug) {
TextResource resource;
if (!loaded) {
if (debug) {
resource = MaterialDebugResources.INSTANCE.focusVisibleJsDebug();
} else {
resource = MaterialResources.INSTANCE.focusVisibleJs();
}
injectJs(resource);
loaded = true;
}
}

protected void injectJs(TextResource resource) {
String text = resource.getText() + ("//# sourceURL=" + resource.getName() + ".js");

// Inject the script resource
resourceUrlObject = ScriptInjector.fromString(text)
.setWindow(ScriptInjector.TOP_WINDOW)
.inject();
}

/**
* This will register the accessibility control for a widget provided with keycodes
*/
public void registerWidget(MaterialWidget widget, int key) {
registerWidget(widget, key, null);
}

/**
* This will register the accessibility control for a widget provided with default KeyCodes.ENTER
*/
public void registerWidget(MaterialWidget widget) {
registerWidget(widget, KeyCodes.KEY_ENTER);
}

public void registerWidget(MaterialWidget widget, TriggerCallback callback) {
registerWidget(widget, KeyCodes.KEY_ENTER, callback);
}

/**
* This will register the accessibility control for a widget provided with keycodes and
* TriggerCallback
*/
public void registerWidget(MaterialWidget widget, int key, TriggerCallback callback) {
if (widget != null) {
HandlerRegistration handlerRegistration = widget.registerHandler(widget.addKeyUpHandler(event -> {
if (isEnabled() && event.getNativeKeyCode() == key) {
if (callback != null) {
callback.call(event);
} else {
triggerClick(widget);
}
}
}));
if (enabled) {
widget.setTabIndex(0);
} else {
widget.getElement().removeAttribute("tabIndex");
}
accessibilityHandlerRegistration.put(handlerRegistration, widget);
}
}

/**
* This will unregister any accessibility control to a widget
* @param widget
*/
public void unregisterWidget(Widget widget) {
if (widget != null) {
if (widget.getElement().hasClassName(FOCUS_VISIBLE_WIDGET)) {
widget.removeStyleName(FOCUS_VISIBLE_WIDGET);
}

if (widget.getElement().hasAttribute(DATA_FOCUS_ADDED_ATTRIBUTE)) {
widget.getElement().removeAttribute(DATA_FOCUS_ADDED_ATTRIBUTE);
}
accessibilityHandlerRegistration.forEach((handlerRegistration, currentWidget) -> {
if (widget == currentWidget) {
handlerRegistration.removeHandler();
}
});
}
}

public void unload() {
JsMaterialElement html = $("html");
if (html != null) {
if (html.hasClass(FOCUS_VISIBILITY_CLASSNAME)) {
html.removeClass(FOCUS_VISIBILITY_CLASSNAME);
}
html.removeAttr(FOCUS_VISIBILITY_ATTRIBUTE);
}

if (resourceUrlObject != null) {
JsMaterialElement scriptTag = $(resourceUrlObject.cast());
scriptTag.remove();
}
loaded = false;
}

public void triggerClick(Widget widget) {
if (widget != null) {
JQuery.$(widget.getElement()).click();
}
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public static AccessibilityControl get() {
if (instance == null) {
instance = new AccessibilityControl();
}
return instance;
}
}
@@ -0,0 +1,27 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2020 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client.accessibility;

import com.google.gwt.event.dom.client.KeyUpEvent;

public interface TriggerCallback {

void call(KeyUpEvent event);
}
Expand Up @@ -28,6 +28,7 @@
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.accessibility.AccessibilityControl;
import gwt.material.design.client.base.density.Density;
import gwt.material.design.client.base.helper.DOMHelper;
import gwt.material.design.client.base.mixin.DensityMixin;
Expand Down Expand Up @@ -281,6 +282,9 @@ protected void load(boolean strict) {
navMenu.setHideOn(HideOn.HIDE_ON_LARGE);
}
navMenu.removeStyleName(CssName.NAVMENU_PERMANENT);

// Register Nav Menu Accessibility
AccessibilityControl.get().registerWidget(navMenu);
}
} catch (Exception ex) {
if (strict) {
Expand Down

0 comments on commit 7f24523

Please sign in to comment.