use of gwt.material.design.client.js.JsMaterialElement.$ in project gwt-material by GwtMaterialDesign.
the class MaterialDatePickerTest method testOrientation.
public void testOrientation() {
// UiBinder
// given
MaterialDatePicker datePicker = getWidget(false);
// when / then
datePicker.setOrientation(Orientation.LANDSCAPE);
assertEquals(Orientation.LANDSCAPE, datePicker.getOrientation());
datePicker.setOrientation(Orientation.PORTRAIT);
assertEquals(Orientation.PORTRAIT, datePicker.getOrientation());
// Standard
// given
attachWidget();
// when / then
JsMaterialElement element = $(datePicker.pickatizedDateInput).pickadate("picker");
datePicker.setOrientation(Orientation.LANDSCAPE);
assertTrue(element.root.hasClass(Orientation.LANDSCAPE.getCssName()));
datePicker.setOrientation(Orientation.PORTRAIT);
assertTrue(element.root.hasClass(Orientation.PORTRAIT.getCssName()));
}
use of gwt.material.design.client.js.JsMaterialElement.$ in project gwt-material by GwtMaterialDesign.
the class MaterialDatePicker method setOrientation.
@Override
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
JsMaterialElement picker = getPicker();
if (picker != null && orientation != null) {
picker.root.removeClass(orientation.getCssName());
}
if (picker != null && orientation != null) {
picker.root.addClass(orientation.getCssName());
}
}
use of gwt.material.design.client.js.JsMaterialElement.$ in project gwt-material by GwtMaterialDesign.
the class MaterialDatePicker method unload.
@Override
public void unload() {
JsMaterialElement picker = getPicker();
if (picker != null) {
picker.off("set");
picker.off("open");
picker.off("close");
}
}
use of gwt.material.design.client.js.JsMaterialElement.$ in project gwt-material by GwtMaterialDesign.
the class AbstractSideNav method load.
protected void load(boolean strict) {
try {
activator = DOMHelper.getElementByAttribute("data-activates", getId());
getNavMenu().setShowOn(ShowOn.SHOW_ON_MED_DOWN);
if (alwaysShowActivator && !getTypeMixin().getStyle().equals(SideNavType.FIXED.getCssName())) {
getNavMenu().setShowOn(ShowOn.SHOW_ON_LARGE);
} else {
getNavMenu().setHideOn(HideOn.HIDE_ON_LARGE);
}
getNavMenu().removeStyleName(CssName.NAVMENU_PERMANENT);
} catch (Exception ex) {
if (strict) {
throw new IllegalArgumentException("Could not setup MaterialSideNav please ensure you have " + "MaterialNavBar with an activator setup to match this widgets id.", ex);
}
}
setup();
JsSideNavOptions options = new JsSideNavOptions();
options.menuWidth = width;
options.edge = edge != null ? edge.getCssName() : null;
options.closeOnClick = closeOnClick;
JsMaterialElement element = $(activator);
element.sideNav(options);
element.off("side-nav-closing");
element.on("side-nav-closing", e1 -> {
onClosing();
return true;
});
element.off("side-nav-closed");
element.on("side-nav-closed", e1 -> {
onClosed();
return true;
});
element.off("side-nav-opening");
element.on("side-nav-opening", e1 -> {
onOpening();
return true;
});
element.off("side-nav-opened");
element.on("side-nav-opened", e1 -> {
onOpened();
return true;
});
}
use of gwt.material.design.client.js.JsMaterialElement.$ in project gwt-material by GwtMaterialDesign.
the class MaterialAnimation method animate.
public void animate(Widget widget, Functions.Func callback) {
if (widget != null) {
this.widget = widget;
} else {
throw new NullPointerException("Cannot animate on a null widget.");
}
if (startTimer != null) {
// Exit early since we are already animating.
return;
}
final JsMaterialElement element = $(widget.getElement());
element.css("animation-duration", duration + "ms");
element.css("-webkit-animation-duration", duration + "ms");
switch(transition) {
case SHOW_STAGGERED_LIST:
if (widget instanceof UnorderedList) {
UnorderedList ul = (UnorderedList) widget;
for (Widget li : ul) {
if (li instanceof ListItem) {
li.getElement().getStyle().setOpacity(0);
}
}
}
break;
case SHOW_GRID:
widget.getElement().getStyle().setOpacity(0);
break;
default:
break;
}
startTimer = new Timer() {
@Override
public void run() {
switch(transition) {
case SHOW_STAGGERED_LIST:
JsMaterialElement.showStaggeredList(element);
break;
case FADE_IN_IMAGE:
JsMaterialElement.fadeInImage(element);
break;
case SHOW_GRID:
widget.addStyleName(CssName.DISPLAY_ANIMATION);
JsMaterialElement.showGrid(element);
break;
case CLOSE_GRID:
widget.addStyleName(CssName.DISPLAY_ANIMATION);
JsMaterialElement.closeGrid(element);
break;
default:
// For core animation components
if (infinite) {
widget.addStyleName(CssName.INFINITE);
}
widget.addStyleName("animated " + transition.getCssName());
// Only start the end timer if its not already active.
if (endTimer == null) {
endTimer = new Timer() {
@Override
public void run() {
if (callback != null) {
callback.call();
}
if (!infinite) {
$(element).removeClass("animated " + transition.getCssName());
}
endTimer = null;
startTimer = null;
}
};
endTimer.schedule(duration);
}
break;
}
}
};
if (delay < 1) {
startTimer.run();
} else {
startTimer.schedule(delay);
}
widget.removeStyleName(CssName.MATERIALIZE_CSS);
}
Aggregations