From e8868a225504dd90dbecaceb1d6eb9df40116355 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Sun, 23 Nov 2014 14:16:02 +0200 Subject: Fix opacity for disabled links in Valo. (#15253) Change-Id: I865526499a6d55a835758f0194a977c36c10304a --- WebContent/VAADIN/themes/valo/components/_link.scss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'WebContent') diff --git a/WebContent/VAADIN/themes/valo/components/_link.scss b/WebContent/VAADIN/themes/valo/components/_link.scss index b568df1d7b..270de1aace 100644 --- a/WebContent/VAADIN/themes/valo/components/_link.scss +++ b/WebContent/VAADIN/themes/valo/components/_link.scss @@ -20,8 +20,8 @@ $v-link-cursor: pointer !default; /** * * - * @param {string} $primary-stylename (v-link) - - * @param {bool} $include-additional-styles - + * @param {string} $primary-stylename (v-link) - + * @param {bool} $include-additional-styles - * * @group link */ @@ -74,4 +74,8 @@ $v-link-cursor: pointer !default; &:hover { color: lighten($v-link-font-color, 10%); } + + &.v-disabled { + @include opacity($v-disabled-opacity); + } } -- cgit v1.2.3 From 285b4bc21f85a4570b5f3b45fc4fd120104b4d11 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Thu, 4 Dec 2014 15:58:07 +0200 Subject: Fix opacity for disabled checkboxes and option groups. (#15239) Change-Id: I2d09a116d07621053f2fc9524f95e47bf7fc834e --- .../VAADIN/themes/valo/components/_checkbox.scss | 36 ++++++++++------------ .../com/vaadin/tests/themes/valo/CheckBoxes.java | 16 ++++++++++ .../vaadin/tests/themes/valo/ValoThemeUITest.java | 2 +- 3 files changed, 34 insertions(+), 20 deletions(-) (limited to 'WebContent') diff --git a/WebContent/VAADIN/themes/valo/components/_checkbox.scss b/WebContent/VAADIN/themes/valo/components/_checkbox.scss index 3c418ec9b7..7283c4cbbf 100644 --- a/WebContent/VAADIN/themes/valo/components/_checkbox.scss +++ b/WebContent/VAADIN/themes/valo/components/_checkbox.scss @@ -99,7 +99,7 @@ } & ~ label:before { - @include valo-button-style($background-color: $background-color, $unit-size: $size, $border-radius: min(round($size/3), $v-border-radius)); + @include valo-button-style($background-color: $background-color, $unit-size: $size, $border-radius: min(round($size/3), $v-border-radius), $states: normal); padding: 0; height: round($size); } @@ -119,24 +119,6 @@ &:checked ~ label:after { color: $selection-color; } - - &[disabled] { - ~ label, - ~ label .v-icon, - ~ .v-icon { - cursor: default; - } - - ~ label:before, - ~ label:after { - @include opacity($v-disabled-opacity); - } - - &:active ~ label:after { - background: transparent; - } - } - } & > .v-icon, @@ -146,4 +128,20 @@ cursor: pointer; } + &.v-disabled { + > label, + > .v-icon { + cursor: default; + @include opacity($v-disabled-opacity); + } + + > label > .v-icon { + cursor: default; + } + + :root & > input:active ~ label:after { + background: transparent; + } + } + } diff --git a/uitest/src/com/vaadin/tests/themes/valo/CheckBoxes.java b/uitest/src/com/vaadin/tests/themes/valo/CheckBoxes.java index c7a2610a21..c79447bd86 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/CheckBoxes.java +++ b/uitest/src/com/vaadin/tests/themes/valo/CheckBoxes.java @@ -79,6 +79,11 @@ public class CheckBoxes extends VerticalLayout implements View { check.addStyleName("large"); row.addComponent(check); + check = new CheckBox("Disabled", true); + check.setEnabled(false); + check.setIcon(testIcon.get()); + row.addComponent(check); + h1 = new Label("Option Groups"); h1.addStyleName("h1"); addComponent(h1); @@ -184,6 +189,17 @@ public class CheckBoxes extends VerticalLayout implements View { options.setItemIcon(two, testIcon.get()); options.setItemIcon("Option Three", testIcon.get()); row.addComponent(options); + + options = new OptionGroup("Disabled items"); + options.setEnabled(false); + options.addItem("Option One"); + options.addItem("Option Two"); + options.addItem("Option Three"); + options.select("Option One"); + options.setItemIcon("Option One", testIcon.get()); + options.setItemIcon("Option Two", testIcon.get()); + options.setItemIcon("Option Three", testIcon.get(true)); + row.addComponent(options); } @Override diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java index a826d9a8f2..13b0c7144c 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java @@ -85,7 +85,7 @@ public class ValoThemeUITest extends MultiBrowserTest { public void checkboxes() throws Exception { openTestURL("test"); open("Check Boxes & Option Groups", "Check Boxes"); - compareScreen("checkboxes"); + compareScreen("checkboxes_with_disabled"); } @Test -- cgit v1.2.3 From 8ce89592362226d6687e1267632a75d85774b67d Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Thu, 6 Nov 2014 09:15:15 +0200 Subject: Position calendar popup on the left side if there is no space (#14757). Change-Id: I83836bbf077033712a569c8eff52576b012b4dee --- .../VAADIN/themes/valo/components/_datefield.scss | 2 + .../src/com/vaadin/client/ui/VPopupCalendar.java | 165 ++++++++++++++------- .../datefield/DateFieldPopupPosition.java | 52 +++++++ .../datefield/DateFieldPopupPositionTest.java | 68 +++++++++ .../datefield/DefaultDateFieldPopupPosition.java | 27 ++++ .../DefaultDateFieldPopupPositionTest.java | 43 ++++++ .../datefield/ValoDateFieldPopupPosition.java | 30 ++++ .../datefield/ValoDateFieldPopupPositionTest.java | 43 ++++++ 8 files changed, 376 insertions(+), 54 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java create mode 100644 uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java create mode 100644 uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java (limited to 'WebContent') diff --git a/WebContent/VAADIN/themes/valo/components/_datefield.scss b/WebContent/VAADIN/themes/valo/components/_datefield.scss index 3201288120..6d36ade43a 100644 --- a/WebContent/VAADIN/themes/valo/components/_datefield.scss +++ b/WebContent/VAADIN/themes/valo/components/_datefield.scss @@ -276,6 +276,8 @@ @include valo-overlay-style; margin-top: ceil($v-unit-size/8) !important; + margin-bottom: ceil($v-unit-size/8) !important; + margin-right: ceil($v-unit-size/8) !important; cursor: default; width: auto; diff --git a/client/src/com/vaadin/client/ui/VPopupCalendar.java b/client/src/com/vaadin/client/ui/VPopupCalendar.java index 51b2ee22ec..15302f0784 100644 --- a/client/src/com/vaadin/client/ui/VPopupCalendar.java +++ b/client/src/com/vaadin/client/ui/VPopupCalendar.java @@ -42,6 +42,7 @@ import com.google.gwt.user.client.ui.PopupPanel.PositionCallback; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.BrowserInfo; +import com.vaadin.client.ComputedStyle; import com.vaadin.client.VConsole; import com.vaadin.client.ui.VCalendarPanel.FocusOutListener; import com.vaadin.client.ui.VCalendarPanel.SubmitListener; @@ -372,60 +373,7 @@ public class VPopupCalendar extends VTextualDate implements Field, // clear previous values popup.setWidth(""); popup.setHeight(""); - popup.setPopupPositionAndShow(new PositionCallback() { - @Override - public void setPosition(int offsetWidth, int offsetHeight) { - final int w = offsetWidth; - final int h = offsetHeight; - final int browserWindowWidth = Window.getClientWidth() - + Window.getScrollLeft(); - final int browserWindowHeight = Window.getClientHeight() - + Window.getScrollTop(); - int t = calendarToggle.getAbsoluteTop(); - int l = calendarToggle.getAbsoluteLeft(); - - // Add a little extra space to the right to avoid - // problems with IE7 scrollbars and to make it look - // nicer. - int extraSpace = 30; - - boolean overflowRight = false; - if (l + +w + extraSpace > browserWindowWidth) { - overflowRight = true; - // Part of the popup is outside the browser window - // (to the right) - l = browserWindowWidth - w - extraSpace; - } - - if (t + h + calendarToggle.getOffsetHeight() + 30 > browserWindowHeight) { - // Part of the popup is outside the browser window - // (below) - t = browserWindowHeight - h - - calendarToggle.getOffsetHeight() - 30; - if (!overflowRight) { - // Show to the right of the popup button unless we - // are in the lower right corner of the screen - l += calendarToggle.getOffsetWidth(); - } - } - - popup.setPopupPosition(l, - t + calendarToggle.getOffsetHeight() + 2); - - /* - * We have to wait a while before focusing since the popup - * needs to be opened before we can focus - */ - Timer focusTimer = new Timer() { - @Override - public void run() { - setFocus(true); - } - }; - - focusTimer.schedule(100); - } - }); + popup.setPopupPositionAndShow(new PopupPositionCallback()); } else { VConsole.error("Cannot reopen popup, it is already open!"); } @@ -642,4 +590,113 @@ public class VPopupCalendar extends VTextualDate implements Field, calendar.setRangeEnd(rangeEnd); } + private class PopupPositionCallback implements PositionCallback { + + @Override + public void setPosition(int offsetWidth, int offsetHeight) { + final int width = offsetWidth; + final int height = offsetHeight; + final int browserWindowWidth = Window.getClientWidth() + + Window.getScrollLeft(); + final int windowHeight = Window.getClientHeight() + + Window.getScrollTop(); + int left = calendarToggle.getAbsoluteLeft(); + + // Add a little extra space to the right to avoid + // problems with IE7 scrollbars and to make it look + // nicer. + int extraSpace = 30; + + boolean overflow = left + width + extraSpace > browserWindowWidth; + if (overflow) { + // Part of the popup is outside the browser window + // (to the right) + left = browserWindowWidth - width - extraSpace; + } + + int top = calendarToggle.getAbsoluteTop(); + int extraHeight = 2; + boolean verticallyRepositioned = false; + ComputedStyle style = new ComputedStyle(popup.getElement()); + int[] margins = style.getMargin(); + int desiredPopupBottom = top + height + + calendarToggle.getOffsetHeight() + margins[0] + + margins[2]; + + if (desiredPopupBottom > windowHeight) { + int updatedLeft = left; + left = getLeftPosition(left, width, style, overflow); + + // if position has not been changed then it means there is no + // space to make popup fully visible + if (updatedLeft == left) { + // let's try to show popup on the top of the field + int updatedTop = top - extraHeight - height - margins[0] + - margins[2]; + verticallyRepositioned = updatedTop >= 0; + if (verticallyRepositioned) { + top = updatedTop; + } + } + // Part of the popup is outside the browser window + // (below) + if (!verticallyRepositioned) { + verticallyRepositioned = true; + top = windowHeight - height - extraSpace + extraHeight; + } + } + if (verticallyRepositioned) { + popup.setPopupPosition(left, top); + } else { + popup.setPopupPosition(left, + top + calendarToggle.getOffsetHeight() + extraHeight); + } + doSetFocus(); + } + + private int getLeftPosition(int left, int width, ComputedStyle style, + boolean overflow) { + if (positionRightSide()) { + // Show to the right of the popup button unless we + // are in the lower right corner of the screen + if (overflow) { + return left; + } else { + return left + calendarToggle.getOffsetWidth(); + } + } else { + int[] margins = style.getMargin(); + int desiredLeftPosition = calendarToggle.getAbsoluteLeft() + - width - margins[1] - margins[3]; + if (desiredLeftPosition >= 0) { + return desiredLeftPosition; + } else { + return left; + } + } + } + + private boolean positionRightSide() { + int buttonRightSide = calendarToggle.getAbsoluteLeft() + + calendarToggle.getOffsetWidth(); + int textRightSide = text.getAbsoluteLeft() + text.getOffsetWidth(); + return buttonRightSide >= textRightSide; + } + + private void doSetFocus() { + /* + * We have to wait a while before focusing since the popup needs to + * be opened before we can focus + */ + Timer focusTimer = new Timer() { + @Override + public void run() { + setFocus(true); + } + }; + + focusTimer.schedule(100); + } + } + } diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java new file mode 100644 index 0000000000..4469ad3b1a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.datefield; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.PopupDateField; + +/** + * Test UI for date field Popup calendar. + * + * @author Vaadin Ltd + */ +public abstract class DateFieldPopupPosition extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + HorizontalLayout layout = new HorizontalLayout(); + addComponent(layout); + Label gap = new Label(); + gap.setWidth(250, Unit.PIXELS); + layout.addComponent(gap); + PopupDateField field = new PopupDateField(); + layout.addComponent(field); + } + + @Override + protected Integer getTicketNumber() { + return 14757; + } + + @Override + protected String getTestDescription() { + return "Calendar popup should not placed on the top of text field when " + + "there is no space on bottom."; + } +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java new file mode 100644 index 0000000000..f896519aae --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.datefield; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.DateFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for date field popup calendar position. + * + * @author Vaadin Ltd + */ +public abstract class DateFieldPopupPositionTest extends MultiBrowserTest { + + @Test + public void testPopupPosition() { + openTestURL(); + + int height = getFieldBottom() + 150; + adjustBrowserWindow(height); + + openPopup(); + + checkPopupPosition(); + } + + protected abstract void checkPopupPosition(); + + protected WebElement getPopup() { + return findElement(By.className("v-datefield-popup")); + } + + private void adjustBrowserWindow(int height) { + Dimension size = getDriver().manage().window().getSize(); + getDriver().manage().window() + .setSize(new Dimension(size.getWidth(), height)); + } + + private int getFieldBottom() { + DateFieldElement dateField = $(DateFieldElement.class).first(); + return dateField.getLocation().getY() + dateField.getSize().getHeight(); + } + + private void openPopup() { + findElement(By.className("v-datefield-button")).click(); + if (!isElementPresent(By.className("v-datefield-popup"))) { + findElement(By.className("v-datefield-button")).click(); + } + } +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java new file mode 100644 index 0000000000..8e4de77837 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.datefield; + +/** + * Test UI for date field Popup calendar in default theme. + * + * All UI initialization is defined in super class. + * + * @author Vaadin Ltd + */ +public class DefaultDateFieldPopupPosition extends DateFieldPopupPosition { + +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java new file mode 100644 index 0000000000..61cc876a3f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.datefield; + +import org.junit.Assert; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.DateFieldElement; + +/** + * Test for date field popup calendar position in default theme. + * + * Test method is defined in super class. + * + * @author Vaadin Ltd + */ +public class DefaultDateFieldPopupPositionTest extends + DateFieldPopupPositionTest { + + @Override + protected void checkPopupPosition() { + DateFieldElement field = $(DateFieldElement.class).first(); + int right = field.getLocation().getX() + field.getSize().getWidth(); + WebElement popup = getPopup(); + + Assert.assertTrue("Calendar popup has wrong X coordinate=" + + popup.getLocation().getX() + " , right side of the field is " + + right, popup.getLocation().getX() >= right); + } +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java new file mode 100644 index 0000000000..59ff6aa9e8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.datefield; + +import com.vaadin.annotations.Theme; + +/** + * Test UI for date field Popup calendar in Valo theme. + * + * All UI initialization is defined in super class. + * + * @author Vaadin Ltd + */ +@Theme("valo") +public class ValoDateFieldPopupPosition extends DateFieldPopupPosition { + +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java new file mode 100644 index 0000000000..4009b9d991 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.datefield; + +import org.junit.Assert; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.DateFieldElement; + +/** + * Test for date field popup calendar position in Valo theme. + * + * Test method is defined in super class. + * + * @author Vaadin Ltd + */ +public class ValoDateFieldPopupPositionTest extends DateFieldPopupPositionTest { + + @Override + protected void checkPopupPosition() { + DateFieldElement field = $(DateFieldElement.class).first(); + WebElement popup = getPopup(); + int left = field.getLocation().getX(); + int popupRight = popup.getLocation().getX() + + popup.getSize().getWidth(); + + Assert.assertTrue("Calendar popup has wrong X coordinate=" + popupRight + + " , left side of the field is " + left, popupRight <= left); + } +} -- cgit v1.2.3 From 98d0eec7bb50e4af342358d2aa2ed80fe4564c85 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Wed, 10 Dec 2014 10:42:37 +0200 Subject: MenuBar submenus close unexpectedly if use Valo theme (#15255) This fix is for animation-in and animation-out. Fix was done in VMenuBar. VOverlay provides now hide() method with possibility to enable/disable the animations via parameters boolean animateIn, boolean animateOut. By default they are true (not to break animate-in, animate-out for VWindow and VNotification) Change-Id: I49981952c7c18a02edd7fa9e6d247bb18f660207 --- .../VAADIN/themes/valo/components/_menubar.scss | 4 - client/src/com/vaadin/client/ui/VMenuBar.java | 28 +++++-- client/src/com/vaadin/client/ui/VOverlay.java | 91 ++++++++++++++-------- .../menubar/MenuBarSubmenusClosingValo.java | 60 ++++++++++++++ .../menubar/MenuBarSubmenusClosingValoTest.java | 72 +++++++++++++++++ 5 files changed, 212 insertions(+), 43 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValo.java create mode 100644 uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java (limited to 'WebContent') diff --git a/WebContent/VAADIN/themes/valo/components/_menubar.scss b/WebContent/VAADIN/themes/valo/components/_menubar.scss index 9075eb7ba8..0f9c61d2ce 100644 --- a/WebContent/VAADIN/themes/valo/components/_menubar.scss +++ b/WebContent/VAADIN/themes/valo/components/_menubar.scss @@ -70,10 +70,6 @@ .#{$primary-stylename}-popup { @include valo-menubar-popup-style($primary-stylename); - - &.#{$primary-stylename}-popup-animate-out { - @include animation(none); - } } diff --git a/client/src/com/vaadin/client/ui/VMenuBar.java b/client/src/com/vaadin/client/ui/VMenuBar.java index 5102e6faea..66160e691d 100644 --- a/client/src/com/vaadin/client/ui/VMenuBar.java +++ b/client/src/com/vaadin/client/ui/VMenuBar.java @@ -476,7 +476,8 @@ public class VMenuBar extends SimpleFocusablePanel implements if (menuVisible && visibleChildMenu != item.getSubMenu() && popup != null) { - popup.hide(); + // #15255 - disable animation-in/out when hide in this case + popup.hide(false, false, false); } if (menuVisible && item.getSubMenu() != null @@ -707,9 +708,22 @@ public class VMenuBar extends SimpleFocusablePanel implements * Recursively hide all child menus */ public void hideChildren() { + hideChildren(true, true); + } + + /** + * + * Recursively hide all child menus + * + * @param animateIn + * enable/disable animate-in animation when hide popup + * @param animateOut + * enable/disable animate-out animation when hide popup + */ + public void hideChildren(boolean animateIn, boolean animateOut) { if (visibleChildMenu != null) { - visibleChildMenu.hideChildren(); - popup.hide(); + visibleChildMenu.hideChildren(animateIn, animateOut); + popup.hide(false, animateIn, animateOut); } } @@ -1326,7 +1340,8 @@ public class VMenuBar extends SimpleFocusablePanel implements VMenuBar root = getParentMenu(); root.getSelected().getSubMenu().setSelected(null); - root.hideChildren(); + // #15255 - disable animate-in/out when hide popup + root.hideChildren(false, false); // Get the root menus items and select the previous one int idx = root.getItems().indexOf(root.getSelected()); @@ -1383,8 +1398,9 @@ public class VMenuBar extends SimpleFocusablePanel implements root = root.getParentMenu(); } - // Hide the submenu - root.hideChildren(); + // Hide the submenu (#15255 - disable animate-in/out when hide + // popup) + root.hideChildren(false, false); // Get the root menus items and select the next one int idx = root.getItems().indexOf(root.getSelected()); diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java index dfd81faf94..9071b6ee47 100644 --- a/client/src/com/vaadin/client/ui/VOverlay.java +++ b/client/src/com/vaadin/client/ui/VOverlay.java @@ -51,7 +51,7 @@ import com.vaadin.client.Util; * temporary float over other components like context menus etc. This is to deal * stacking order correctly with VWindow objects. *

- * + * *

Shadow

*

* The separate shadow element underneath the main overlay element is @@ -62,7 +62,7 @@ import com.vaadin.client.Util; * supports, add -webkit-box-shadow and the standard * box-shadow properties. *

- * + * *

* For IE8, which doesn't support CSS box-shadow, you can use the proprietary * DropShadow filter. It doesn't provide the exact same features as box-shadow, @@ -70,7 +70,7 @@ import com.vaadin.client.Util; * border or a pseudo-element underneath the overlay which mimics a shadow, or * any combination of these. *

- * + * *

* Read more about the DropShadow filter from { * Shadow element style. If an extending class wishes to use a different * style of shadow, it can use setShadowStyle(String) to give the shadow * element a new style name. - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -187,9 +187,9 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * The shadow element for this overlay. - * + * * @deprecated See main JavaDoc for VOverlay - * + * */ @Deprecated private Element shadow; @@ -218,7 +218,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * The HTML snippet that is used to render the actual shadow. In consists of * nine different DIV-elements with the following class names: - * + * *

      *   .v-shadow[-stylename]
      *   ----------------------------------------------
@@ -231,9 +231,9 @@ public class VOverlay extends PopupPanel implements CloseHandler {
      *   | .bottom-left  |  .bottom  |  .bottom-right |
      *   ----------------------------------------------
      * 
- * + * * See default theme 'shadow.css' for implementation example. - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -280,7 +280,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { * Return true if a separate shadow div should be used. Since Vaadin 7.3, * shadows are implemented with CSS box-shadow. Thus, a shadow div is only * used for IE8 by default. - * + * * @deprecated See main JavaDoc for VOverlay * @since 7.3 * @return true to use a shadow div @@ -294,10 +294,10 @@ public class VOverlay extends PopupPanel implements CloseHandler { * Method to control whether DOM elements for shadow are added. With this * method subclasses can control displaying of shadow also after the * constructor. - * + * * @param enabled * true if shadow should be displayed - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -361,7 +361,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Set the z-index (visual stack position) for this overlay. - * + * * @param zIndex * The new z-index */ @@ -574,12 +574,12 @@ public class VOverlay extends PopupPanel implements CloseHandler { * Sets the shadow style for this overlay. Will override any previous style * for the shadow. The default style name is defined by CLASSNAME_SHADOW. * The given style will be prefixed with CLASSNAME_SHADOW. - * + * * @param style * The new style name for the shadow element. Will be prefixed by * CLASSNAME_SHADOW, e.g. style=='foobar' -> actual style * name=='v-shadow-foobar'. - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -593,7 +593,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { * Extending classes should always call this method after they change the * size of overlay without using normal 'setWidth(String)' and * 'setHeight(String)' methods (if not calling super.setWidth/Height). - * + * */ public void positionOrSizeUpdated() { positionOrSizeUpdated(1.0); @@ -612,7 +612,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { * elements. Can be used to animate the related elements, using the * 'progress' parameter (used to animate the shadow in sync with GWT * PopupPanel's default animation 'PopupPanel.AnimationType.CENTER'). - * + * * @param progress * A value between 0.0 and 1.0, indicating the progress of the * animation (0=start, 1=end). @@ -721,7 +721,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { * Returns true if we should add a shim iframe below the overlay to deal * with zindex issues with PDFs and applets. Can be overriden to disable * shim iframes if they are not needed. - * + * * @return true if a shim iframe should be added, false otherwise */ protected boolean needsShimElement() { @@ -783,13 +783,13 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Enables or disables sinking the events of the shadow to the same * onBrowserEvent as events to the actual overlay goes. - * + * * Please note, that if you enable this, you can't assume that e.g. * event.getEventTarget returns an element inside the DOM structure of the * overlay - * + * * @param sinkShadowEvents - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -813,7 +813,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Get owner (Widget that made this VOverlay, not the layout parent) of * VOverlay - * + * * @return Owner (creator) or null if not defined */ public Widget getOwner() { @@ -823,7 +823,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Set owner (Widget that made this VOverlay, not the layout parent) of * VOverlay - * + * * @param owner * Owner (creator) of VOverlay */ @@ -834,7 +834,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Get the {@link ApplicationConnection} that this overlay belongs to. If * it's not set, {@link #getOwner()} is used to figure it out. - * + * * @return */ protected ApplicationConnection getApplicationConnection() { @@ -854,7 +854,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Gets the 'overlay container' element. Tries to find the current * {@link ApplicationConnection} using {@link #getApplicationConnection()}. - * + * * @return the overlay container element for the current * {@link ApplicationConnection} or another element if the current * {@link ApplicationConnection} cannot be determined. @@ -878,7 +878,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { * {@link ApplicationConnection}. Each overlay should be created in a * overlay container element, so that the correct theme and styles can be * applied. - * + * * @param ac * A reference to {@link ApplicationConnection} * @return The overlay container @@ -905,7 +905,7 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Set the label of the container element, where tooltip, notification and * dialgs are added to. - * + * * @param applicationConnection * the application connection for which to change the label * @param overlayContainerLabel @@ -938,10 +938,10 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Gets the visual viewport width, which is useful for e.g iOS where the * view can be zoomed in while keeping the layout viewport intact. - * + * * Falls back to layout viewport; for those browsers/devices the difference * is that the scrollbar with is included (if there is a scrollbar). - * + * * @since 7.0.7 * @return */ @@ -957,10 +957,10 @@ public class VOverlay extends PopupPanel implements CloseHandler { /** * Gets the visual viewport height, which is useful for e.g iOS where the * view can be zoomed in while keeping the layout viewport intact. - * + * * Falls back to layout viewport; for those browsers/devices the difference * is that the scrollbar with is included (if there is a scrollbar). - * + * * @since 7.0.7 * @return */ @@ -1000,10 +1000,33 @@ public class VOverlay extends PopupPanel implements CloseHandler { */ @Override public void hide(final boolean autoClosed) { + hide(autoClosed, true, true); + } + + /** + * + * Hides the popup and detaches it from the page. This has no effect if it + * is not currently showing. Animation-in, animation-out can be + * enable/disabled for different use cases. + * + * @see com.google.gwt.user.client.ui.PopupPanel#hide(boolean) + * + * @param autoClosed + * the value that will be passed to + * {@link CloseHandler#onClose(CloseEvent)} when the popup is + * closed + * @param animateIn + * enable/disable animate-in animation + * @param animateOut + * enable/disable animate-out animation + */ + public void hide(final boolean autoClosed, final boolean animateIn, + final boolean animateOut) { if (BrowserInfo.get().isIE8() || BrowserInfo.get().isIE9()) { super.hide(autoClosed); } else { - if (getStyleName().contains(ADDITIONAL_CLASSNAME_ANIMATE_IN)) { + if (animateIn + && getStyleName().contains(ADDITIONAL_CLASSNAME_ANIMATE_IN)) { AnimationUtil.addAnimationEndListener(getElement(), new AnimationEndListener() { @Override @@ -1029,7 +1052,9 @@ public class VOverlay extends PopupPanel implements CloseHandler { animationName = ""; } - if (animationName.contains(ADDITIONAL_CLASSNAME_ANIMATE_OUT)) { + if (animateOut + && animationName + .contains(ADDITIONAL_CLASSNAME_ANIMATE_OUT)) { // Disable GWT PopupPanel closing animation if used setAnimationEnabled(false); diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValo.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValo.java new file mode 100644 index 0000000000..88d89abbf4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValo.java @@ -0,0 +1,60 @@ +package com.vaadin.tests.components.menubar; + +import com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.MenuItem; + +@Theme("valo") +public class MenuBarSubmenusClosingValo extends AbstractTestUI { + + private MenuItem edit; + private MenuItem file; + private MenuItem help; + + @Override + protected String getTestDescription() { + return "Tests that when moving mouse fast over menu items " + + "previous submenu popup closes before new submenu popup opens"; + } + + @Override + protected Integer getTicketNumber() { + return 15255; + } + + @Override + protected void setup(VaadinRequest request) { + // here we increase animation time to 1 second for to do auto testing + // possible + getPage().getStyles().add( + ".valo .v-menubar-popup[class*=\"animate-in\"] {" + + "-webkit-animation: valo-overlay-animate-in 1000ms; " + + "-moz-animation: valo-overlay-animate-in 1000ms; " + + "animation: valo-overlay-animate-in 1000ms;};"); + + getPage().getStyles().add( + ".valo .v-menubar-popup[class*=\"animate-out\"] {" + + "-webkit-animation: valo-animate-out-fade 1000ms; " + + "-moz-animation: valo-animate-out-fade 1000ms; " + + "animation: valo-animate-out-fade 1000ms;};"); + + MenuBar mb = new MenuBar(); + file = mb.addItem("File", null); + file.addItem("File1", null); + file.addItem("File2", null); + file.addItem("File3", null); + edit = mb.addItem("Edit", null); + edit.addItem("Edit1", null); + edit.addItem("Edit2", null); + edit.addItem("Edit3", null); + help = mb.addItem("Help", null); + help.addItem("Help1", null); + help.addItem("Help2", null); + MenuItem helpMenuItem = help.addItem("Help3", null); + helpMenuItem.addItem("SubHelp3", null); + + addComponent(mb); + } +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java new file mode 100644 index 0000000000..b7ed88c9ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.menubar; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.internal.Locatable; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.MenuBarElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class MenuBarSubmenusClosingValoTest extends MultiBrowserTest { + + @Test + public void testEnableParentLayoutControlByKeyboard() { + openTestURL(); + + MenuBarElement menu = $(MenuBarElement.class).get(0); + menu.focus(); + menu.sendKeys(Keys.SPACE); + menu.sendKeys(Keys.DOWN); + + waitForElementPresent(By.className("v-menubar-popup")); + + menu.sendKeys(Keys.ARROW_RIGHT); + menu.sendKeys(Keys.ARROW_RIGHT); + + int count = driver.findElements(By.className("v-menubar-popup")).size(); + Assert.assertTrue("The count of open popups should be one", count == 1); + } + + @Test + public void testEnableParentLayoutControlByMouse() { + openTestURL(); + + Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); + + List menuItemList = driver.findElements(By + .className("v-menubar-menuitem")); + + mouse.click(((Locatable) menuItemList.get(0)).getCoordinates()); + waitForElementPresent(By.className("v-menubar-popup")); + + mouse.mouseMove(((Locatable) menuItemList.get(1)).getCoordinates()); + mouse.mouseMove(((Locatable) menuItemList.get(2)).getCoordinates()); + + waitForElementPresent(By.className("v-menubar-popup")); + + int count = driver.findElements(By.className("v-menubar-popup")).size(); + Assert.assertTrue("The count of open popups should be one", count == 1); + } +} -- cgit v1.2.3 From 10fa4e4236ed049ef6eac337d23701bc381763ce Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Thu, 11 Dec 2014 23:12:12 +0200 Subject: Fix gradient path for notifications in Chameleon. (#15351) Change-Id: Ie1e2726613033ad321e15f7f58e098080d4d9a5f --- .../components/notification/notification.scss | 4 +-- .../themes/chameleon/ChameleonNotification.java | 30 ++++++++++++++++++++++ .../chameleon/ChameleonNotificationTest.java | 25 ++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/themes/chameleon/ChameleonNotification.java create mode 100644 uitest/src/com/vaadin/tests/themes/chameleon/ChameleonNotificationTest.java (limited to 'WebContent') diff --git a/WebContent/VAADIN/themes/chameleon/components/notification/notification.scss b/WebContent/VAADIN/themes/chameleon/components/notification/notification.scss index 85fbb3295f..c1a8d119c7 100644 --- a/WebContent/VAADIN/themes/chameleon/components/notification/notification.scss +++ b/WebContent/VAADIN/themes/chameleon/components/notification/notification.scss @@ -9,8 +9,8 @@ div.#{$primaryStyleName} { -moz-box-shadow: 0 2px 5px rgba(0,0,0,.7); box-shadow: 0 2px 5px rgba(0,0,0,.7); //IE8 does not support rgba, using just rgb - background:rgb(255,255,255) url(../img/grad-light-top.png) repeat-x; - background:rgba(255,255,255,.90) url(../img/grad-light-top.png) repeat-x; + background:rgb(255,255,255) url(../../img/grad-light-top.png) repeat-x; + background:rgba(255,255,255,.90) url(../../img/grad-light-top.png) repeat-x; } .#{$primaryStyleName} p { diff --git a/uitest/src/com/vaadin/tests/themes/chameleon/ChameleonNotification.java b/uitest/src/com/vaadin/tests/themes/chameleon/ChameleonNotification.java new file mode 100644 index 0000000000..efb953530c --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/chameleon/ChameleonNotification.java @@ -0,0 +1,30 @@ +package com.vaadin.tests.themes.chameleon; + +import com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Notification; +import com.vaadin.ui.themes.ChameleonTheme; + +@Theme(ChameleonTheme.THEME_NAME) +public class ChameleonNotification extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + + + addButton("Notification", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + Notification notification = new Notification("Notification"); + notification.setDelayMsec(30000); + notification.show(getUI().getPage()); + } + }); + } + + @Override + protected Integer getTicketNumber() { + return 15351; + } +} diff --git a/uitest/src/com/vaadin/tests/themes/chameleon/ChameleonNotificationTest.java b/uitest/src/com/vaadin/tests/themes/chameleon/ChameleonNotificationTest.java new file mode 100644 index 0000000000..ef41ef3df9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/chameleon/ChameleonNotificationTest.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.themes.chameleon; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.NotificationElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; + +import java.io.IOException; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; + +public class ChameleonNotificationTest extends MultiBrowserTest { + @Test + public void gradientPathIsCorrect() throws IOException { + openTestURL(); + $(ButtonElement.class).first().click(); + + NotificationElement notificationElement + = $(NotificationElement.class).first(); + + assertThat(notificationElement.getCssValue("background-image"), + containsString("chameleon/img/grad")); + } +} \ No newline at end of file -- cgit v1.2.3