Skip to content

Commit

Permalink
Merge pull request #449 from GwtMaterialDesign/release_1.6.2
Browse files Browse the repository at this point in the history
Release 1.6.2
  • Loading branch information
kevzlou7979 authored Sep 13, 2016
2 parents ce4f225 + 47c6eb9 commit 6079f7a
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 50 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs


## Maven
### Current Version 1.6.1
### Current Version 1.6.2
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>1.6.1</version>
<version>1.6.2</version>
</dependency>
```
### Snapshot Version 2.0-SNAPSHOT
Expand Down
2 changes: 1 addition & 1 deletion gwt-material/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>1.6.1</version>
<version>1.6.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public OptionElement getOptionElement(int index) {
*/
@Override
public void clear() {
values.clear();
listBox.clear();
if (initialized) {
// reinitialize
Expand Down Expand Up @@ -237,7 +238,6 @@ public void onValueChange(ValueChangeEvent<T> event) {

@Override
public void setAcceptableValues(Collection<T> values) {
this.values.clear();
clear();

for(T value : values) {
Expand Down Expand Up @@ -384,9 +384,9 @@ public void addItem(T item) {
* the item's value, to be submitted if it is part of a
* {@link FormPanel}; cannot be <code>null</code>
*/
public void addItem(T item, String value) {
values.add(item);
listBox.addItem(keyFactory.generateKey(item), value);
public void addItem(String item, T value) {
values.add(value);
listBox.addItem(keyFactory.generateKey(value), item);
if (initialized) {
// reinitialize
initializeMaterial(listBox.getElement());
Expand All @@ -405,9 +405,9 @@ public void addItem(T item, String value) {
* the item's value, to be submitted if it is part of a
* {@link FormPanel}; cannot be <code>null</code>
*/
public void addItem(T item, Direction dir, String value) {
values.add(item);
listBox.addItem(keyFactory.generateKey(item), dir, value);
public void addItem(String item, Direction dir, T value) {
values.add(value);
listBox.addItem(keyFactory.generateKey(value), dir, item);
if (initialized) {
// reinitialize
initializeMaterial(listBox.getElement());
Expand All @@ -427,7 +427,7 @@ public void addItem(T item, Direction dir, String value) {
* the index at which to insert it
*/
public void insertItem(T item, int index) {
values.add(item);
values.add(index, item);
listBox.insertItem(keyFactory.generateKey(item), index);
if (initialized) {
// reinitialize
Expand All @@ -451,7 +451,7 @@ public void insertItem(T item, int index) {
* the index at which to insert it
*/
public void insertItem(T item, Direction dir, int index) {
values.add(item);
values.add(index, item);
listBox.insertItem(keyFactory.generateKey(item), dir, index);
if (initialized) {
// reinitialize
Expand All @@ -475,9 +475,9 @@ public void insertItem(T item, Direction dir, int index) {
* @param index
* the index at which to insert it
*/
public void insertItem(T item, String value, int index) {
values.add(item);
listBox.insertItem(keyFactory.generateKey(item), value, index);
public void insertItem(String item, T value, int index) {
values.add(value);
listBox.insertItem(keyFactory.generateKey(value), item, index);
if (initialized) {
// reinitialize
initializeMaterial(listBox.getElement());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* 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.
Expand All @@ -21,7 +21,6 @@
*/

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
Expand Down Expand Up @@ -77,7 +76,7 @@ public class MaterialSideNav extends MaterialWidget implements HasType<SideNavTy
private boolean closeOnClick = false;
private boolean alwaysShowActivator = false;
private boolean allowBodyScroll = false;
private boolean showOnAttach = false;
private Boolean showOnAttach = null;
private boolean open;

private Element activator;
Expand All @@ -91,6 +90,8 @@ public class MaterialSideNav extends MaterialWidget implements HasType<SideNavTy
*/
public MaterialSideNav() {
super(Document.get().createULElement(), "side-nav");

typeMixin.setType(SideNavType.FIXED);
}

/**
Expand All @@ -116,12 +117,27 @@ public void onLoad() {
// Initialize the side nav
initialize();

if(showOnAttach) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
if(showOnAttach != null) {
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
if(Window.getClientWidth() > 960) {
if (showOnAttach) {
if (Window.getClientWidth() > 960) {
show();
}
} else {
show();
final HandlerRegistration[] openedHandler = new HandlerRegistration[1];
openedHandler[0] = addOpenedHandler(new SideNavOpenedHandler() {
@Override
public void onSideNavOpened(SideNavOpenedEvent event) {
hide();

if (openedHandler[0] != null) {
openedHandler[0].removeHandler();
}
}
});
}
}
});
Expand Down Expand Up @@ -297,7 +313,7 @@ public void run() {
}}.schedule(500);
break;
case PUSH:
applyPushType(getElement(), activator, width);
applyPushType(width);
break;
}
}
Expand All @@ -314,7 +330,7 @@ protected native boolean isSmall() /*-{
/**
* Push the header, footer, and main to the right part when Close type is applied.
*/
protected native void applyPushType(Element element, Element activator, double width) /*-{
protected native void applyPushType(double width) /*-{
var that = this;
$wnd.jQuery($wnd.window).off("resize");
Expand Down Expand Up @@ -373,25 +389,23 @@ protected void initialize() {
}

protected void initialize(boolean strict) {
if(activator == null) {
if (activator == null) {
activator = DOMHelper.getElementByAttribute("data-activates", getId());
if (activator != null) {
SideNavType type = getType();
processType(type);

initialize(activator, width, closeOnClick, edge.getCssName());

if(alwaysShowActivator || !isFixed()) {
if (alwaysShowActivator || !isFixed()) {
String style = activator.getAttribute("style");
activator.setAttribute("style", style + "; display: block !important");
activator.removeClassName("navmenu-permanent");
}
} else if(strict) {
} else if (strict) {
throw new RuntimeException("Cannot find an activator for the MaterialSideNav, " +
"please ensure you have a MaterialNavBar with an activator setup to match " +
"this widgets id.");
}
}

processType(getType());
initialize(activator, width, closeOnClick, edge.getCssName());
}

protected native void initialize(Element e, int width, boolean closeOnClick, String edge)/*-{
Expand Down Expand Up @@ -533,7 +547,7 @@ public void setAlwaysShowActivator(boolean alwaysShowActivator) {
* Will the menu forcefully show on attachment.
*/
public boolean isShowOnAttach() {
return showOnAttach;
return showOnAttach != null && showOnAttach;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,13 @@ public MaterialSwitch(boolean value) {
@Override
protected void onLoad() {
super.onLoad();
if(offLabel.getText() != null && !offLabel.getText().isEmpty()) {
label.add(offLabel);
}
label.add(offLabel);
label.add(input);
label.add(span);
add(label);
add(lblError);
lblError.getElement().getStyle().setMarginTop(16, Unit.PX);

if(onLabel.getText() != null && !onLabel.getText().isEmpty()) {
label.add(onLabel);
}
label.add(onLabel);

// register click handler here in order to have it at first position
// and therefore it will deal with clicks as first and setup the value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,7 @@ $(document).ready(function(){
removeMenu(true);
}
else {
menu_id.removeAttr('style');
//menu_id.removeAttr('style'); GWT MATERIAL MODIFICATION
menu_id.css('width', options.menuWidth);
}
}
Expand Down Expand Up @@ -2077,7 +2077,7 @@ $(document).ready(function(){
complete: function() {
if (restoreNav === true) {
// Restore Fixed sidenav
menu_id.removeAttr('style');
//menu_id.removeAttr('style'); GWT MATERIAL MODIFICATION
menu_id.css('width', options.menuWidth);
}
$this.trigger("side-nav-closed");
Expand All @@ -2095,7 +2095,7 @@ $(document).ready(function(){
complete: function() {
if (restoreNav === true) {
// Restore Fixed sidenav
menu_id.removeAttr('style');
//menu_id.removeAttr('style'); GWT MATERIAL MODIFICATION
menu_id.css('width', options.menuWidth);
}
$this.trigger("side-nav-closed");
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-parent</artifactId>
<packaging>pom</packaging>
<version>1.6.1</version>
<version>1.6.2</version>

<modules>
<module>gwt-material</module>
Expand Down Expand Up @@ -62,7 +62,7 @@
<connection>scm:git:[email protected]:GwtMaterialDesign/gwt-material.git</connection>
<developerConnection>scm:git:[email protected]:GwtMaterialDesign/gwt-material.git</developerConnection>
<url>http://github.com/GwtMaterialDesign/gwt-material</url>
<tag>v1.6.1</tag>
<tag>v1.6.2</tag>
</scm>

<licenses>
Expand Down

0 comments on commit 6079f7a

Please sign in to comment.