List of usage examples for com.google.gwt.dom.client NodeList getLength
public int getLength()
From source file:com.sencha.gxt.widget.core.client.grid.GroupingView.java
License:sencha.com license
/** * Toggles all groups./*from w w w .j a v a 2 s . c om*/ * * @param expanded true to expand */ public void toggleAllGroups(boolean expanded) { NodeList<Element> groups = getGroups(); List<GroupingData<M>> groupData = createGroupingData(); for (int i = 0; i < groups.getLength(); i++) { toggleGroup(groups.getItem(i), expanded); GroupingData<M> groupingData = groupData.get(i); if (expanded) { fireEvent(new ExpandItemEvent<List<M>>(groupingData.getItems())); } else { fireEvent(new CollapseItemEvent<List<M>>(groupingData.getItems())); } } }
From source file:com.sencha.gxt.widget.core.client.menu.Menu.java
License:sencha.com license
protected void constrainScroll(int y) { ul.getStyle().setProperty("height", "auto"); int full = ul.getOffsetHeight(); int max = maxHeight != Style.DEFAULT ? maxHeight : (XDOM.getViewHeight(false) - y); if (full > max && max > 0) { activeMax = max - 10 - scrollerHeight * 2; ul.setHeight(activeMax, true);/* ww w . j av a2 s . c o m*/ createScrollers(); } else { ul.setHeight(full, true); NodeList<Element> nodes = appearance.getScrollers(getElement()); for (int i = 0; i < nodes.getLength(); i++) { nodes.getItem(i).getStyle().setDisplay(Display.NONE); } } ul.setScrollTop(0); }
From source file:com.sencha.gxt.widget.core.client.TabPanel.java
License:sencha.com license
protected int itemIndex(Element item) { NodeList<Element> items = appearance.getStripWrap(getElement()).select(appearance.getItemSelector()); for (int i = 0; i < items.getLength(); i++) { if (items.getItem(i) == item) { return i; }/*from w w w. jav a2s. co m*/ } return -1; }
From source file:com.smartgwt.mobile.client.SmartGwtMobileEntryPoint.java
License:Open Source License
public void onModuleLoad() { // Added boolean init check flag because GWT for some reason invokes this entry point class twice in hosted mode // even though it appears only once in the load hierarchy. Check with GWT team. if (initialized) return;// ww w. ja v a 2 s. com initialized = true; assert (assertionsEnabled = true) == true; // Intentional side effect. if (!assertionsEnabled) { SC.logWarn("WARNING: Assertions are not enabled. It is recommended to develop with assertions " + "enabled because both GWT and SmartGWT.mobile use them to help find bugs in application code. " + "To enable assertions, if using GWT 2.6.0 or later, recompile the application with the " + "-checkAssertions option passed to the GWT compiler. If using GWT 2.5.1 or earlier, recompile with the " + "-ea option passed to the GWT compiler."); } _init(); // Delete all current viewport <meta> tags. We will create a new one to work around two // issues: // - In an iOS 7 UIWebView, we need to set the viewport height to fix the issue that the // TabSet tabBar stays above the virtual keyboard when a text <input> has keyboard focus // (http://forums.smartclient.com/showthread.php?t=29005). // - On iPhone and iPad (iOS v7.0.4), we need to set the height to device-width to work // around a bug. If height is set to device-height, then in landscape orientation, // the <body>'s dimensions are 1024x1024, causing pickers to fail to appear. // - iOS 6.1 also has this problem, but if we use height = device-width, then there // are severe display issues when the orientation is changed, so we don't specify the // height. // - Don't want to do this unless in a UIWebView, however, because if we set the // viewport height then pickers get cut off when Showcase is viewed in Mobile Safari. // - In an iOS 7 UIWebView, we also need a viewport height to fix a different issue, namely // that if an input is tapped, but the virtual keyboard appears on top of the input, then // that input element is not focused, and the ScrollablePanel fails to scroll the tapped // input into view: // http://stackoverflow.com/questions/19110144/ios7-issues-with-webview-focus-when-using-keyboard-html // - This is not an issue on iOS 6.1. // - Firefox for Android does not support updating the content of an existing viewport // <meta> tag. However, if a new viewport <meta> tag is added, then the viewport settings // are updated: https://bugzilla.mozilla.org/show_bug.cgi?id=714737 final NodeList<Element> metaElems = Document.get().getElementsByTagName("meta"); for (int ri = metaElems.getLength(); ri > 0; --ri) { final MetaElement metaElem = metaElems.getItem(ri - 1).cast(); if ("viewport".equals(metaElem.getName())) { metaElem.removeFromParent(); } } String width = "device-width"; String height = null; if (CANVAS_STATIC_IMPL.isIOSMin7_0() && CANVAS_STATIC_IMPL.isUIWebView()) { height = Page.getOrientation() == PageOrientation.LANDSCAPE ? "device-width" : "device-height"; Page.addOrientationChangeHandler(new OrientationChangeHandler() { @Override public void onOrientationChange(OrientationChangeEvent event) { final String newHeight = Page.getOrientation() == PageOrientation.LANDSCAPE ? "device-width" : "device-height"; Page._updateViewport(Float.valueOf(1.0f), "device-width", newHeight, Boolean.FALSE, "minimal-ui"); } }); } Page._updateViewport(Float.valueOf(1.0f), width, height, Boolean.FALSE, "minimal-ui"); // Inject default styles. // // Because `CssResource' does not have support for at rules, CSS3 animations @keyframes // and @media rules must be added separately. // http://code.google.com/p/google-web-toolkit/issues/detail?id=4911 final StringBuilder cssText = new StringBuilder(); final String translateXStart = Canvas.isAndroid() ? "translateX(" : "translate3d(", translateXEnd = Canvas.isAndroid() ? ")" : ",0,0)", translateYStart = Canvas.isAndroid() ? "translateY(" : "translate3d(0,", translateYEnd = Canvas.isAndroid() ? ")" : ",0)"; // base cssText.append(Canvas._CSS.getText()); cssText.append(ThemeResources.INSTANCE.otherBaseCSS().getText()); cssText.append("@media all and (orientation:landscape){" + ThemeResources.INSTANCE.baseCSSLandscape().getText() + "}"); // activityindicator cssText.append(ActivityIndicator._CSS.getText()); if (ActivityIndicator._CSS instanceof ActivityIndicatorCssResourceIOS) { final ActivityIndicatorCssResourceIOS CSS = (ActivityIndicatorCssResourceIOS) ActivityIndicator._CSS; // Android 2.3.3 Browser has a bug where attempting to animate from transform:rotate(0deg) // to transform:rotate(360deg) results in no animation because its angle calculations // are mod 360, so 0 = 360 mod 360 and it thinks that there is no change in the transform // from start to end. A work-around is to add a 50% keyframe of transform:rotate(180deg). cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.spinAnimationName() + "{" + "0%{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":rotate(0deg)}" + "50%{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":rotate(180deg)}" + "to{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":rotate(360deg)}" + "}" + "@keyframes " + CSS.spinAnimationName() + "{" + "0%{transform:rotate(0deg)}" + "50%{transform:rotate(180deg)}" + "to{transform:rotate(360deg)}" + "}"); } // layout cssText.append(ThemeResources.INSTANCE.layoutCSS().getText()); // panel cssText.append(ThemeResources.INSTANCE.panelCSS().getText()); // headings cssText.append(Header1._CSS.getText()); // buttons cssText.append(BaseButton._CSS.getText()); // form cssText.append(DynamicForm._CSS.getText()); // Note: GWT's CssResource does not currently support CSS3 @media queries. // https://code.google.com/p/google-web-toolkit/issues/detail?id=8162 // One work-around is to add the CSS text within the media query: // https://code.google.com/p/google-web-toolkit/issues/detail?id=4911#c6 cssText.append("@media all and (orientation:landscape){" + // The space after the 'and' keyword is important. Without this space, the styles are not applied on iPad in landscape orientation. ThemeResources.INSTANCE.formCSSLandscape().getText() + "}"); // menu cssText.append(Menu._CSS.getText()); if (Menu._CSS instanceof MenuCssResourceIPhone) { final MenuCssResourceIPhone CSS = (MenuCssResourceIPhone) Menu._CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.menuFadeInAnimationName() + "{" + "0%{opacity:0}" + "to{opacity:1}" + "}" + "@keyframes " + CSS.menuFadeInAnimationName() + "{" + "0%{opacity:0}" + "to{opacity:1}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.menuFadeOutAnimationName() + "{" + "0%{opacity:1}" + "50%{opacity:1}" + "to{opacity:0}" + "}" + "@keyframes " + CSS.menuFadeOutAnimationName() + "{" + "0%{opacity:1}" + "50%{opacity:1}" + "to{opacity:0}" + "}"); } // navigationbar cssText.append(NavigationBar._CSS.getText()); if (NavigationBar._CSS instanceof NavigationBarCssResourceIOS) { final NavigationBarCssResourceIOS CSS = (NavigationBarCssResourceIOS) NavigationBar._CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarFadeInAnimationName() + "{" + "0%{opacity:0}" + "to{opacity:1}" + "}" + "@keyframes " + CSS.navbarFadeInAnimationName() + "{" + "0%{opacity:0}" + "to{opacity:1}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarFadeOutAnimationName() + "{" + "0%{opacity:1}" + "to{opacity:0}" + "}" + "@keyframes " + CSS.navbarFadeOutAnimationName() + "{" + "0%{opacity:1}" + "to{opacity:0}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarSlideInFromRightAnimationName() + "{" + "0%{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "90px" + translateXEnd + "}" + "to{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "0" + translateXEnd + "}" + "}" + "@keyframes " + CSS.navbarSlideInFromRightAnimationName() + "{" + "0%{opacity:0;transform:translateX(90px)}" + "to{opacity:1;transform:translateX(0)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarHeadingSlideInFromRightAnimationName() + "{" + "0%{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "60%" + translateXEnd + "}" + "to{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "0" + translateXEnd + "}" + "}" + "@keyframes " + CSS.navbarHeadingSlideInFromRightAnimationName() + "{" + "0%{opacity:0;transform:translateX(60%)}" + "to{opacity:1;transform:translateX(0)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarSlideInFromLeftAnimationName() + "{" + "0%{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "-90px" + translateXEnd + "}" + "to{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "0" + translateXEnd + "}" + "}" + "@keyframes " + CSS.navbarSlideInFromLeftAnimationName() + "{" + "0%{opacity:0;transform:translateX(-90px)}" + "to{opacity:1;transform:translateX(0)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarHeadingSlideInFromLeftAnimationName() + "{" + "0%{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "-60%" + translateXEnd + "}" + "to{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "0" + translateXEnd + "}" + "}" + "@keyframes " + CSS.navbarHeadingSlideInFromLeftAnimationName() + "{" + "0%{opacity:0;transform:translateX(-60%)}" + "to{opacity:1;transform:translateX(0)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarSlideOutRightAnimationName() + "{" + "0%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "0" + translateXEnd + "}" + "to{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "90px" + translateXEnd + "}" + "}" + "@keyframes " + CSS.navbarSlideOutRightAnimationName() + "{" + "0%{opacity:1;transform:translateX(0)}" + "to{opacity:0;transform:translateX(90px)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarHeadingSlideOutRightAnimationName() + "{" + "0%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "0" + translateXEnd + "}" + "to{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "60%" + translateXEnd + "}" + "}" + "@keyframes " + CSS.navbarHeadingSlideOutRightAnimationName() + "{" + "0%{opacity:1;transform:translateX(0)}" + "to{opacity:0;transform:translateX(60%)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarSlideOutLeftAnimationName() + "{" + "0%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "0" + translateXEnd + "}" + "to{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "-90px" + translateXEnd + "}" + "}" + "@keyframes " + CSS.navbarSlideOutLeftAnimationName() + "{" + "0%{opacity:1;transform:translateX(0)}" + "to{opacity:0;transform:translateX(-90px)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.navbarHeadingSlideOutLeftAnimationName() + "{" + "0%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "0" + translateXEnd + "}" + "to{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateXStart + "-60%" + translateXEnd + "}" + "}" + "@keyframes " + CSS.navbarHeadingSlideOutLeftAnimationName() + "{" + "0%{opacity:1;transform:translateX(0)}" + "to{opacity:0;transform:translateX(-60%)}" + "}"); } // popup cssText.append(Popup._CSS.getText()); // picker2 cssText.append(Picker2.CSS.getText()); if (Picker2.CSS instanceof PickerCssResourceIOS) { final PickerCssResourceIOS CSS = (PickerCssResourceIOS) Picker2.CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.pickerFadeInAnimationName() + "{" + "0%{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "100%" + translateYEnd + "}" + "to{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "0" + translateYEnd + "}" + "}" + "@keyframes " + CSS.pickerFadeInAnimationName() + "{" + "0%{transform:translateY(100%)}" + "to{transform:translateY(0)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.pickerFadeOutAnimationName() + "{" + "0%{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "0" + translateYEnd + "}" + "to{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "100%" + translateYEnd + "}" + "}" + "@keyframes " + CSS.pickerFadeOutAnimationName() + "{" + "0%{transform:translateY(0)}" + "to{transform:translateY(100%)}" + "}"); } // progressbar cssText.append(Progressbar._CSS.getText()); // scrollable cssText.append(ScrollablePanel._CSS.getText()); // slider cssText.append(SliderItem._CSS.getText()); // switchitem cssText.append(SwitchItem._CSS.getText()); // tableview // Don't use `TableView._CSS.ensureInjected()' because the way that CssResource.ensureInjected() // is implemented, the CSS rules are scheduled to be added in a timeout, which may mean // that the DOM elements for the first `TableView' are added to the document before // the `TableView' CSS styles are added. If this first `TableView' has a parent `NavStack', // then the browser considers the background color of the LIs to have changed when // the `TableView' CSS is added, meaning that the background-color transition effect // kicks in. // http://jsfiddle.net/A4QDd/ // // GWT 2.5 introduces the StyleInjector.flush() function which would solve this problem, // but for GWT 2.4, we can simulate the same effect by always using StyleInjector.injectAtEnd() // (immediate = true) at the small price of more <style> elements being added to the document. cssText.append(TableView._CSS.getText()); cssText.append("@media all and (orientation:landscape){" + ThemeResources.INSTANCE.tableViewCSSLandscape().getText() + "}"); // tabs cssText.append(TabSet._CSS.getText()); if (TabSet._CSS instanceof TabSetCssResourceIOS) { final TabSetCssResourceIOS CSS = (TabSetCssResourceIOS) TabSet._CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.tabBarSlideOutAnimationName() + "{" + "0%{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "0" + translateYEnd + "}" + "to{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "100%" + translateYEnd + "}" + "}" + "@keyframes " + CSS.tabBarSlideOutAnimationName() + "{" + "0%{transform:translateY(0)}" + "to{transform:translateY(100%)}" + "}"); } cssText.append("@media all and (orientation:landscape){" + ThemeResources.INSTANCE.tabsCSSLandscape().getText() + "}"); // toolbar cssText.append(ToolStrip._CSS.getText()); // window if (Window._CSS instanceof WindowCssResourceIOS) { final WindowCssResourceIOS CSS = (WindowCssResourceIOS) Window._CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.modalMaskFadeInAnimationName() + "{" + "0%{opacity:0}" + "to{opacity:1}" + "}" + "@keyframes " + CSS.modalMaskFadeInAnimationName() + "{" + "0%{opacity:0}" + "to{opacity:1}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.modalMaskFadeOutAnimationName() + "{" + "0%{opacity:1}" + "to{opacity:0}" + "}" + "@keyframes " + CSS.modalMaskFadeOutAnimationName() + "{" + "0%{opacity:1}" + "to{opacity:0}" + "}"); } // On iPad, windows look like alertviews. if (Window._CSS instanceof WindowCssResourceIPad) { final WindowCssResourceIPad CSS = (WindowCssResourceIPad) Window._CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.windowBackgroundFadeInAnimationName() + "{" + "0%{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(1)}" + "50%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(.95)}" + "to{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(1)}" + "}" + "@keyframes " + CSS.windowBackgroundFadeInAnimationName() + "{" + "0%{opacity:0;transform:scale(1)}" + "50%{opacity:1;transform:scale(.95)}" + "to{transform:scale(1)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.windowBackgroundFadeOutAnimationName() + "{" + "0%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(1)}" + "to{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(.95)}" + "}" + "@keyframes " + CSS.windowBackgroundFadeOutAnimationName() + "{" + "0%{opacity:1;transform:scale(1)}" + "to{opacity:0;transform:scale(.95)}" + "}"); // Otherwise, windows look like action sheets. } else { assert Window._CSS instanceof WindowCssResourceIPhone; final WindowCssResourceIPhone CSS = (WindowCssResourceIPhone) Window._CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.windowBackgroundSlideInAnimationName() + "{" + "0%{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "100%" + translateYEnd + "}" + "to{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "0" + translateYEnd + "}" + "}" + "@keyframes " + CSS.windowBackgroundSlideInAnimationName() + "{" + "0%{transform:translateY(100%)}" + "to{transform:translateY(0)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.windowBackgroundSlideOutAnimationName() + "{" + "0%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "0" + translateYEnd + "}" + "to{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":" + translateYStart + "100%" + translateYEnd + "}" + "}" + "@keyframes " + CSS.windowBackgroundSlideOutAnimationName() + "{" + "0%{opacity:1;transform:translateY(0)}" + "to{opacity:1;transform:translateY(100%)}" + "}"); } cssText.append(Window._CSS.getText()); cssText.append("@media all and (orientation:landscape){" + ThemeResources.INSTANCE.windowCSSLandscape().getText() + "}"); // dialog cssText.append(Dialog._CSS.getText()); // alertview if (AlertView._CSS instanceof AlertViewCssResourceIOS) { final AlertViewCssResourceIOS CSS = (AlertViewCssResourceIOS) AlertView._CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.alertViewScreenCoverFadeInAnimationName() + "{" + "0%{opacity:0}" + "to{opacity:1}" + "}" + "@keyframes " + CSS.alertViewScreenCoverFadeInAnimationName() + "{" + "0%{opacity:0}" + "to{opacity:1}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.alertViewScreenCoverFadeOutAnimationName() + "{" + "0%{opacity:1}" + "to{opacity:0}" + "}" + "@keyframes " + CSS.alertViewScreenCoverFadeOutAnimationName() + "{" + "0%{opacity:1}" + "to{opacity:0}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.alertViewFadeInAnimationName() + "{" + "0%{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(1)}" + "50%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(.95)}" + "to{" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(1)}" + "}" + "@keyframes " + CSS.alertViewFadeInAnimationName() + "{" + "0%{opacity:0;transform:scale(1)}" + "50%{opacity:1;transform:scale(.95)}" + "to{transform:scale(1)}" + "}" + DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.alertViewFadeOutAnimationName() + "{" + "0%{opacity:1;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(1)}" + "to{opacity:0;" + DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + ":scale(.95)}" + "}" + "@keyframes " + CSS.alertViewFadeOutAnimationName() + "{" + "0%{opacity:1;transform:scale(1)}" + "to{opacity:0;transform:scale(.95)}" + "}"); } cssText.append(AlertView._CSS.getText()); // popover cssText.append(Popover._CSS.getText()); if (Popover._CSS instanceof PopoverCssResourceIPhone) { final PopoverCssResourceIPhone CSS = (PopoverCssResourceIPhone) Popover._CSS; cssText.append(DOMConstants.INSTANCE.getAtKeyframesText() + " " + CSS.popoverFadeOutAnimationName() + "{" + "0%{opacity:1}" + "to{opacity:0}" + "}" + "@keyframes " + CSS.popoverFadeOutAnimationName() + "{" + "0%{opacity:1}" + "to{opacity:0}" + "}"); } StyleInjector.injectAtEnd(CSSUtil.fixNotSelectors(cssText.toString()), true); }
From source file:com.smartgwt.mobile.client.util.Page.java
License:Open Source License
@SGWTInternal public static void _updateViewport(Float scale, String width, String height, Boolean scalable, String extraViewportParams) { final StringBuilder sb = new StringBuilder(); if (scale != null) { sb.append("initial-scale=").append(scale.floatValue()); }/*from w w w .j a v a 2 s . c om*/ if (width != null) { if (sb.length() != 0) sb.append(", "); sb.append("width=").append(width); } if (height != null) { if (sb.length() != 0) sb.append(", "); sb.append("height=").append(height); } if (scalable != null) { if (sb.length() != 0) sb.append(", "); sb.append("user-scalable=").append(scalable.booleanValue() ? "yes" : "no"); // setting user-scalable to 'no' seems to reliably disable pinch zooming // However on pivot the iPhone zooms by default and this seems to still occur // with user-scalable set to 'no'. If a desired 'scale' was specified, // setting the min/max scale to it appears to really disable scale on pivot if (scalable == false && scale != null) { sb.append(", minimum-scale=").append(scale.floatValue()).append(", maximum-scale=") .append(scale.floatValue()); } } if (extraViewportParams != null && !extraViewportParams.isEmpty()) { if (sb.length() > 0) sb.append(", "); sb.append(extraViewportParams); } final NodeList<Element> metaTags = Document.get().getElementsByTagName("meta"); MetaElement vpTag = null; // remove all but the last viewport <meta> tag and select the last one for (int i = 0; i < metaTags.getLength(); /*empty*/) { if ("viewport".equals(metaTags.getItem(i).<MetaElement>cast().getName())) { if (vpTag != null) { vpTag.getParentNode().removeChild(vpTag); vpTag = metaTags.getItem(i - 1).cast(); } else { vpTag = metaTags.getItem(i).cast(); ++i; } } else ++i; } if (vpTag != null) { vpTag.setContent(sb.toString()); } else { vpTag = Document.get().createMetaElement(); vpTag.setName("viewport"); vpTag.setContent(sb.toString()); Document.get().getElementsByTagName("head").getItem(0).appendChild(vpTag); } }
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
private Element findElementByRowFieldConfigObj(Map<String, String> configObj) { final String title = configObj.get("title"); if (title != null && elementMap != null) { for (final Element rowElem : elementMap.values()) { final NodeList<Node> children = rowElem.getChildNodes(); final int children_length = children.getLength(); for (int i = 0; i < children_length; ++i) { final Element titleElem = getChildElementHavingClass(rowElem, RECORD_TITLE_CLASS_NAME); if (titleElem != null && titleElem.getInnerText().equals(title)) { return rowElem; }/*from w w w . j a va 2 s . c o m*/ } } } final String valueOnly = configObj.get(AutoTest.FALLBACK_VALUE_ONLY_FIELD); if (valueOnly != null) { int i = -1; try { i = Integer.parseInt(valueOnly, 10); } catch (NumberFormatException ex) { } if (i >= 0) { final RecordList data = _getData(); if (data != null && i < data.size()) { final Record record = data.get(i); return elementMap.get(getRecordId(record)); } } } return null; }
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
private Element findLoadMoreRecordsElement() { if (_ul != null) { final NodeList<Node> children = _ul.getChildNodes(); for (int ri = children.getLength(); ri > 0; --ri) { final Node child = children.getItem(ri - 1); if (child.getNodeType() != Node.ELEMENT_NODE) continue; final Element childElem = (Element) child; if (childElem.hasAttribute(IS_LOAD_MORE_RECORDS_ATTRIBUTE_NAME)) { return childElem; }// w w w.j a va2 s . c om } } return null; }
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
@SGWTInternal protected Integer _findRecordIndex(Element element) { if (element == null) { return null; }/* w w w . j a v a 2 s . c o m*/ while (!element.hasAttribute(RECORD_INDEX_ATTRIBUTE_NAME)) { element = element.getParentElement(); if (element == null) { break; } } boolean found = false; if (element != null) { if (element.getTagName().equalsIgnoreCase("li")) { Element parent = element.getParentElement(); Element thisElement = this.getElement(); while (parent != null) { if (parent == thisElement) { found = true; break; } parent = parent.getParentElement(); } } else { NodeList<Node> nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.getItem(i); if (element == node) { found = true; break; } } } } if (found) { assert element != null; return Integer.valueOf(element.getAttribute(RECORD_INDEX_ATTRIBUTE_NAME)); } return null; }
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
@Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); if (!isEnabled()) return;/*from www . j a v a 2s.c o m*/ final Element targetElem = EventUtil.getTargetElem(event); if (targetElem != null) { final Element element; final JsArray<Touch> touches; final int clientX, clientY; final boolean wasContextClickFired; switch (event.getTypeInt()) { case Event.ONMOUSEDOWN: onStart(event, null); break; case Event.ONTOUCHSTART: touches = event.getTouches(); if (touches.length() == 1 && touchIdentifier == null) { onStart(event, touches.get(0)); } else { // Another finger is touching the screen. onEnd(event); } break; case Event.ONMOUSEMOVE: if (touchActive) { clientX = event.getClientX(); clientY = event.getClientY(); if (Math.abs(touchPointX - clientX) >= 10 || Math.abs(touchPointY - clientY) >= 10) { onEnd(event); } } break; case Event.ONTOUCHMOVE: if (touchActive) { touches = event.getTouches(); if (touches.length() == 1 && touchIdentifier != null) { final Touch touch = touches.get(0); if (touch.getIdentifier() == touchIdentifier.intValue()) { clientX = touch.getClientX(); clientY = touch.getClientY(); if (Math.abs(touchPointX - clientX) >= 10 || Math.abs(touchPointY - clientY) >= 10) { onEnd(event); } } } } break; case Event.ONMOUSEUP: case Event.ONMOUSEOUT: case Event.ONTOUCHEND: case Event.ONTOUCHCANCEL: element = activeElement; wasContextClickFired = contextClickFired; onEnd(event); if (element != null && wasContextClickFired) { onClick(element, null); } break; case Event.ONCLICK: if (!isEnabled()) return; element = _findElement(event); onClick(element, targetElem); break; case Event.ONCONTEXTMENU: if (!isEnabled()) return; element = _findElement(event); if (element != null) { // Find the "context clickable element". // The context clickable element is the title element, unless there // is no title element, in which case it is the <li>. Element contextClickableElement = element; final NodeList<Node> children = element.getChildNodes(); final int children_length = children.getLength(); for (int i = 0; i < children_length; ++i) { final Node child = children.getItem(i); if (child.getNodeType() != Node.ELEMENT_NODE) continue; final Element childElem = (Element) child; if (ElementUtil.hasClassName(childElem, TableView.RECORD_TITLE_CLASS_NAME)) { contextClickableElement = childElem; if (touchActive) contextClickFired = true; break; } } if (contextClickableElement.isOrHasChild(targetElem)) { final Integer recordIndex = _findRecordIndex(element); if (recordIndex != null) { final Record record = _getData().get(recordIndex.intValue()); final boolean cancelled = RowContextClickEvent._fire(this, -1, record, recordIndex.intValue()); if (!cancelled) { final Menu contextMenu = getContextMenu(); if (contextMenu != null) { contextClickableElement.addClassName(_CSS.contextClickedElementClass()); final Object recordID = getRecordId(record); final Element li = elementMap.get(recordID); assert li != null; final Element finalContextClickableElement = contextClickableElement; new BeforeMenuHiddenHandler() { private HandlerRegistration beforeMenuHiddenRegistration = contextMenu ._addBeforeMenuHiddenHandler(this); @Override public void _onBeforeMenuHidden(BeforeMenuHiddenEvent event) { beforeMenuHiddenRegistration.removeHandler(); finalContextClickableElement .removeClassName(_CSS.contextClickedElementClass()); } }; contextMenu._showAt(this, event.getClientX(), event.getClientY(), contextClickableElement.getAbsoluteLeft(), contextClickableElement.getAbsoluteRight(), contextClickableElement.getAbsoluteTop(), contextClickableElement.getAbsoluteBottom()); if (touchActive) contextClickFired = true; break; } } } } } break; } } }
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
@SGWTInternal protected void _setSelected(Element element) { final SelectionStyle selectionType = getSelectionType(); assert selectionType != null && selectionType != SelectionStyle.NONE; if (!hasClassName(element, _CSS.selectedTableViewRowClass()) && !hasClassName(element, _CSS.selectedTableViewRowHasIconClass())) { if (showSelectedIcon) { element.addClassName(_CSS.selectedTableViewRowHasIconClass()); if (selectionType == SelectionStyle.SINGLE || selectedIcon != null) { SpanElement span = Document.get().createSpanElement(); span.addClassName(_CSS.selectedClass()); Image image = selectedIcon != null ? new Image(selectedIcon) : impl.getDefaultSingleSelectionIcon(); image.getElement().addClassName(_CSS.selectedClass()); span.setInnerHTML(image.toString()); element.insertFirst(span); } else { assert selectionType != SelectionStyle.SINGLE; assert selectionType == SelectionStyle.MULTIPLE; // Find the .selection-disclosure element and add class `CSS.checkedSelectionOrDeleteDisclosureClass()'. NodeList<Node> children = element.getChildNodes(); final int children_length = children.getLength(); int i = 0; for (; i < children_length; ++i) { final Node n = children.getItem(i); if (n.getNodeType() != Node.ELEMENT_NODE) { continue; }/*from w ww. j a va 2s.c om*/ final Element child = Element.as(n); if (hasClassName(child, _CSS.recordSelectionDisclosureClass())) { child.addClassName(_CSS.checkedSelectionOrDeleteDisclosureClass()); break; } } assert i < children_length; } } else { element.removeClassName(_CSS.clearingTemporaryTableViewRowSelectionClass()); element.addClassName(_CSS.selectedTableViewRowClass()); } } }