/** * Create a new {@link JQMPage} with an automatically assigned page id, * and then add the given widgets serially to the page layout. */ public JQMPage(Collection<Widget> widgets) { this(); withContainerId(); if (widgets != null) add(widgets); }
private void initOrientationChange() { if (orientationChangeInitialized != null) return; orientationChangeInitialized = this.addJQMEventHandler(JQMComponentEvents.ORIENTATIONCHANGE, new JQMOrientationChangeHandler() { @Override public void onEvent(JQMEvent<?> event) { int h = Window.getClientHeight(); int w = Window.getClientWidth(); String s = JQMOrientationChangeHandler.Process.getOrientation(event); // iOS and Android give opposite values (iOS - already rotated, Android - not yet rotated) if (JQMOrientationChangeHandler.LANDSCAPE.equals(s)) { initialWindowHeight = Math.min(w, h); } else if (JQMOrientationChangeHandler.PORTRAIT.equals(s)) { initialWindowHeight = Math.max(w, h); } //Window.alert(s + ", height: " + initialWindowHeight); if (hideFixedToolbarsIfVirtualKeyboard > 0) { refreshPartsPositioning(); } } }); }
/** * @param transparent - needed when this page is shown in dialog mode, * then true means show faded previous page under dialog window * and don't bother prev page with lifecycle events (show, hide, ...). * * <br> See <a href="http://tqcblog.com/2012/04/19/transparent-jquery-mobile-dialogs/">Transparent jQuery mobile dialogs</a> */ public void setDlgTransparent(boolean transparent) { this.transparent = transparent; if (this.transparent) addStyleName(JQM4GWT_DLG_TRANSPARENT); else removeStyleName(JQM4GWT_DLG_TRANSPARENT); }
/** Header, Footer, Content positions will be adjusted according to page properties: * <br> contentCentered, contentHeightPercent, pseudoFixedToolbars, ... **/ public void refreshPartsPositioning() { processFixedToolbars(); recalcContentHeightPercent(); centerContent(); }
onPageHide(); final JQMPage next = findPage(nextPage); JQMPageEvent.fire(this, PageState.HIDE, this, next); prepareTransparentGoing(false/*add*/, getId()); if (transparentPrevPageClearCache) { transparentPrevPage.removeAttribute(DATA_DOM_CACHE); final JQMPage prev = findPage(transparentPrevPage); if (!transparentDoPrevPageLifecycle) { if (prev != null) { JQMPage.bindLifecycleHideEvents(prev, prev.getElement()); Element prevElt = prev.getElement(); JQMPage.unbindLifecycleHideEvents(prevElt); JQMPage.bindLifecycleEvents(prev, prevElt); };
/** * Fixed Header and Footer will be hidden if virtual/on-screen keyboard is activated. * <br> This property is used as threshold(keyboard's height) in pixels * for keyboard detection (to work must be > 0, default is 0). */ public void setHideFixedToolbarsIfVirtualKeyboard(int value) { int oldVal = hideFixedToolbarsIfVirtualKeyboard; hideFixedToolbarsIfVirtualKeyboard = value; if (oldVal != hideFixedToolbarsIfVirtualKeyboard && content != null && content.isAttached()) { processFixedToolbars(); centerContent(); initWindowResize(); if (hideFixedToolbarsIfVirtualKeyboard > 0) initOrientationChange(); } }
onPageHide(); JQMPageEvent.fire(this, PageState.HIDE, this, findPage(nextPage)); final JQMPage prev = findPage(transparentPrevPage); if (prev != null) { JQMPage.bindLifecycleHideEvents(prev, prev.getElement()); Scheduler.get().scheduleFinally(new ScheduledCommand() { @Override
/** * Sets the footer element, overriding an existing footer if any. */ public void setFooter(HasJqmFooter footer) { removeFooter(); this.footer = footer; if (this.footer == null) return; addLogical(footer.getFooterStage()); getElement().appendChild(footer.getJqmFooter().getElement()); }
public void setPanel(JQMPanel panel) { removePanel(); this.panel = panel; addLogical(panel); getElement().insertBefore(panel.getElement(), getElement().getFirstChild()); }
/** * Defines content band's height as percent of available content area's height. */ public void setContentHeightPercent(double contentHeightPercent) { double oldVal = this.contentHeightPercent; this.contentHeightPercent = contentHeightPercent; if (oldVal != this.contentHeightPercent && content != null && content.isAttached()) { recalcContentHeightPercent(); centerContent(); initWindowResize(); } }
/** * Fixed Header and Footer will be hidden if content area height percent is below * than specified percent of window height (default is 50%). * <br> Useful in cases with activated virtual keyboard, especially on Android. */ public void setHideFixedToolbarsIfContentAreaPercentBelow(double value) { double oldVal = hideFixedToolbarsIfContentAreaPercentBelow; hideFixedToolbarsIfContentAreaPercentBelow = value; if (oldVal != hideFixedToolbarsIfContentAreaPercentBelow && content != null && content.isAttached()) { processFixedToolbars(); centerContent(); initWindowResize(); } }
/** * Sets the header element, overriding an existing header if any. */ public void setHeader(HasJqmHeader header) { removeHeader(); this.header = header; if (this.header == null) return; addLogical(header.getHeaderStage()); if (panel == null) { getElement().insertBefore(header.getJqmHeader().getElement(), getElement().getFirstChild()); } else { getElement().insertAfter(header.getJqmHeader().getElement(), panel.getElement()); } }
/** * Content band will be centered between Header and Footer * (they must be defined as fixed="true" OR page.pseudoFixedToolbars="true"). */ public void setContentCentered(boolean contentCentered) { boolean oldVal = this.contentCentered; this.contentCentered = contentCentered; if (oldVal != this.contentCentered && content != null && content.isAttached()) { if (this.contentCentered) { centerContent(); initWindowResize(); } else { clearCenterContent(); } } }
public void bindLifecycleEvents() { bindLifecycleEvents(this, this.getElement()); }
/** * Creates a content container on this page and returns it. Content can * then be added to this secondary container. There is no limit to the * number of secondary content containers that can be created. */ public JQMContent createContent() { JQMContent content = new JQMContent(); Element elt = getElement(); add(content, elt); return content; }
/** * Logical add operation. If you do this you are responsible for adding it * to the DOM yourself. * * @param child * the child widget to be added */ protected void addLogical(Widget child) { // Detach new child. child.removeFromParent(); // Logical attach. getChildren().add(child); // Adopt. adopt(child); }
/** * If content is short or scrollable (see {@link JQMPage#setContentHeightPercent(double)}), * we can get "fixed" header and footer without using CSS position: fixed (it's not working * quite good in mobile browsers). Just setPseudoFixedToolbars(true) and footer's position will * be calculated to be at the bottom of the page. */ public void setPseudoFixedToolbars(boolean value) { boolean oldVal = this.pseudoFixedToolbars; this.pseudoFixedToolbars = value; if (oldVal != this.pseudoFixedToolbars && content != null && content.isAttached()) { if (this.pseudoFixedToolbars) { centerContent(); initWindowResize(); } else { centerContent(); } } }
@Override public void execute() { prev.bindLifecycleEvents(); } });
/** * Content is not centered anymore, i.e. aligned to the top (just once). * <p> Warning! - contentCentered property is not affected, you have to change it manually. </p> */ public void clearCenterContent() { centerContent(); }
public HandlerRegistration addPageHandler(JQMPageEvent.Handler handler) { return addHandler(handler, JQMPageEvent.getType()); }