List of usage examples for com.google.gwt.query.client Properties create
public static Properties create(String properties)
From source file:com.pronoiahealth.olhie.client.pages.AbstractPage.java
License:Open Source License
/** * Add full page scrolling. This can only be done before the page is loaded. * //from w w w .j a v a2 s .co m * @param fullPageScrollingActive */ protected void addFullPageScrolling() { // Activate full page scrolling // Get the root div final GQuery gObj = AppSelectors.INSTANCE.getCenterBackground(); // Called when scrolling stops // Timer set in scroll event // Address weird Chrome/Safari (Webkit) issue // Just asking for some data from the element emitting // scroll events seems to refresh the display and // help fix the issue scrollStopTimer = new Timer() { @Override public void run() { int scrollTop = gObj.scrollTop(); // gObj.scrollTop(scrollTop + 3); // gObj.scrollTop(scrollTop); } }; // Make sure its overflow is set to auto gObj.css(CSS.OVERFLOW.with(Overflow.AUTO)); // State of scroll link gObj.data("scrollLinkActive", Boolean.FALSE); // Create the scroll link scrollLink = $("<a href=\"#\" class=\"ph-BulletinBoard-Scrollup\">Scroll</a>"); final Function fadeIn = new Function() { @Override public void f(Element e) { scrollLink.css(Properties.create("opacity: 1.0;")); // super.f(e); } }; final Function fadeOut = new Function() { @Override public void f(Element e) { scrollLink.css(Properties.create("opacity: 0.0;")); // super.f(e); } }; // Append the link to the root div gObj.append(scrollLink); // Bind the scroll event gObj.bind(Event.ONSCROLL, new Function() { @Override public boolean f(Event e) { // GQuery rootDiv = $(e); // int scrollTop = rootDiv.scrollTop(); // Set timer scrollStopTimer.cancel(); scrollStopTimer.schedule(500); // Test scroll top int scrollTop = gObj.scrollTop(); boolean scrollLinkActive = (Boolean) gObj.data("scrollLinkActive"); if (scrollTop >= 100 && scrollLinkActive == false) { gObj.data("scrollLinkActive", Boolean.TRUE); scrollLink.fadeIn(500, fadeIn); } else if (scrollTop < 100 && scrollLinkActive == true) { gObj.data("scrollLinkActive", Boolean.FALSE); scrollLink.fadeOut(500, fadeOut); } // return super.f(e); return false; } }); // Bind to the scrollup link scrollLink.bind(Event.ONCLICK, new Function() { @Override public boolean f(Event e) { gObj.animate("scrollTop: 0", 500, (Function) null); scrollLink.hide(); return false; } }); this.fullPageScrollingActive = true; }
From source file:com.pronoiahealth.olhie.client.widgets.newsdisplay.NewsDisplay.java
License:Open Source License
/** * Set up the fade timer and set the initial item to display. */// w w w . ja v a 2s. c o m @PostConstruct private void postConstruct() { // Set initial news item setCurrentNewsItem(false); fadeTimer = new Timer() { @Override public void run() { if (newsItems != null && newsItems.size() > 0) { $("#fadeNewsDisplay").css(Properties.create("opacity: 1.0;")).show(); $("#fadeNewsDisplay").as(Effects.Effects).fadeOut(newsFadeInterval, new Function() { @Override public void f(Element e) { setCurrentNewsItem(true); $(e).show(); } }); } } }; fadeTimer.scheduleRepeating(newsFadeInterval + 2000); }
From source file:com.pronoiahealth.olhie.client.widgets.newsdisplay.NewsDisplay.java
License:Open Source License
private void stopFadeAnimation() { fadeTimer.cancel(); $("#fadeNewsDisplay").stop(true).css(Properties.create("opacity: 1.0;")); }
From source file:com.pronoiahealth.olhie.client.widgets.newsdisplay.NewsDisplay.java
License:Open Source License
/** * When the mouse moves out of the new item the fade resumes * /*from w w w. j ava 2 s. c o m*/ * @param event */ @EventHandler("fadeNewsItem") public void handleMouseOutEvents(MouseOutEvent event) { $("#fadeNewsDisplay").css(Properties.create("opacity: 1.0;")); fadeTimer.scheduleRepeating(newsFadeInterval + 1000); }
From source file:com.pronoiahealth.olhie.client.widgets.scrolldiv.ScrollDiv.java
License:Open Source License
@PostConstruct protected void postConstruct() { // Activate full page scrolling // Get the root div final GQuery gObj = $(root); // Make sure its overflow is set to auto gObj.css(CSS.OVERFLOW.with(Overflow.AUTO)); // Create the scroll link scrollLink = $("<a href=\"#\" class=\"ph-BulletinBoard-Scrollup\">Scroll</a>"); // Append the link to the root div gObj.append(scrollLink);/*from w w w . ja va2s. c o m*/ // Bind the scroll event gObj.bind(Event.ONSCROLL, new Function() { @Override public boolean f(Event e) { GQuery rootDiv = $(e); int scrollTop = rootDiv.scrollTop(); if (scrollTop > 100) { scrollLink.fadeIn(500, new Function() { @Override public void f(com.google.gwt.dom.client.Element e) { $(e).css(Properties.create("opacity: 1.0;")); // super.f(e); } }); } else { scrollLink.fadeOut(500, new Function() { @Override public void f(com.google.gwt.dom.client.Element e) { $(e).css(Properties.create("opacity: 0.0;")); // super.f(e); } }); } return super.f(e); } }); // Bind to the scrollup link scrollLink.bind(Event.ONCLICK, new Function() { @Override public boolean f(Event e) { gObj.animate("scrollTop: 0", 500, (Function) null); return false; } }); }
From source file:com.watopi.chosen.client.ChosenImpl.java
License:Open Source License
private void setup() { boolean isHidden = false; containerId = buildContainerId();//from w w w . jav a2 s . c om fWidth = $selectElement.outerWidth(); //Temporary fix. IIf the select element is inside a hidden container //GQuery cannot get the size of the select element. if (fWidth == 0) { $("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;" + (isRTL ? "right" : "left") + ":-9000px; visibility:hidden'> </div>"); GQuery tempDiv = $("#gwt_chosen_temp_div"); tempDiv.append($selectElement.clone()); fWidth = tempDiv.children("select").outerWidth(); tempDiv.remove(); isHidden = fWidth > 0; } isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl"); String cssClasses = isRTL ? css.chznContainer() + " " + css.chznRtl() : css.chznContainer(); GQuery containerTemp = $(ChozenTemplate.templates.container(containerId, cssClasses).asString()) .width(fWidth); if (isMultiple) { containerTemp.html(ChozenTemplate.templates.contentMultiple(css.chznChoices(), css.searchField(), defaultText, css.defaultClass(), css.chznDrop(), css.chznResults(), (isRTL ? "right" : "left")) .asString()); } else { containerTemp.html(ChozenTemplate.templates.contentSingle(css.chznSingle(), css.chznDefault(), defaultText, css.chznDrop(), css.chznSearch(), css.chznResults(), (isRTL ? "right" : "left")) .asString()); } // insert container after the select elements $selectElement.hide().after(containerTemp); container = $("#" + containerId); container.addClass(isMultiple ? css.chznContainerMulti() : css.chznContainerSingle()); dropdown = container.find("div." + css.chznDrop()).first(); int ddTop = container.height(); int ddWidth = fWidth - getSideBorderPadding(dropdown, isHidden); dropdown.css(Properties.create("{\"width\": " + ddWidth + "px, \"top\": " + ddTop + "px}")); searchField = container.find("input").first(); searchResults = container.find("ul." + css.chznResults()).first(); searchFieldScale(); if (isMultiple) { searchChoices = container.find("ul." + css.chznChoices()).first(); searchContainer = container.find("li." + css.searchField()).first(); } else { searchContainer = container.find("div." + css.chznSearch()).first(); selectedItem = container.find("." + css.chznSingle()).first(); int searchFieldWidth = ddWidth - getSideBorderPadding(searchContainer, isHidden) - getSideBorderPadding(searchField, isHidden); searchField.css("width", searchFieldWidth + "px"); } resultsBuild(); setTabIndex(); fireEvent(new ReadyEvent(this)); }
From source file:gwtquery.plugins.draggable.client.DraggableHandler.java
License:Apache License
public void revertToOriginalPosition(Function function) { Properties oldPosition = Properties.create("{top:'" + String.valueOf(originalPosition.top) + "px',left:'" + String.valueOf(originalPosition.left) + "px'}"); helper.as(Effects.Effects).animate(oldPosition, options.getRevertDuration(), Easing.LINEAR, function); }
From source file:gwtquery.samples.client.AnimationsSample.java
License:Apache License
private void doMoveAnimation() { $(".foo").animate(Properties.create("{left:'+=1000'}"), 2000, Easing.SWING).delay(500) .animate("left:'-=1000'", 2000).queue(new Function() { @Override//w w w. j a v a2s .c o m public void f() { doMoveAnimation(); $(".foo").dequeue(); } }); }
From source file:org.mindinformatics.gwt.domeo.plugins.persistence.annotopia.src.AnnotopiaPersistenceManager.java
License:Apache License
/** Return the user Annotopia OAuth token if it is enabled. * @return The user Annotopia OAuth token if it is enabled. */ private Properties getAnnotopiaOAuthToken() { if (ApplicationUtils.getAnnotopiaOauthEnabled().equalsIgnoreCase("true")) { return Properties.create("Authorization: Bearer " + ApplicationUtils.getAnnotopiaOauthToken()); } else {/*from w w w . j av a 2 s.c om*/ return Properties.create(); } }
From source file:org.otalo.ao.client.widget.chlist.client.ChosenImpl.java
License:Apache License
private void setup() { boolean isHidden = false; containerId = buildContainerId();/*from w ww. j av a 2 s . c o m*/ fWidth = $selectElement.outerWidth(); //Temporary fix. IIf the select element is inside a hidden container //GQuery cannot get the size of the select element. if (fWidth == 0) { $("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;" + (isRTL ? "right" : "left") + ":-9000px; visibility:hidden'> </div>"); GQuery tempDiv = $("#gwt_chosen_temp_div"); tempDiv.append($selectElement.clone()); fWidth = tempDiv.children("select").outerWidth(); tempDiv.remove(); isHidden = fWidth > 0; } isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl"); String cssClasses = isRTL ? css.chznContainer() + " " + css.chznRtl() : css.chznContainer(); GQuery containerTemp = $(ChozenTemplate.templates.container(containerId, cssClasses).asString()) .width(fWidth); SafeStyles horizontalOffset = isRTL ? SafeStylesUtils.forRight(HORIZONTAL_OFFSET, Style.Unit.PX) : SafeStylesUtils.forLeft(HORIZONTAL_OFFSET, Style.Unit.PX); if (isMultiple) { containerTemp.html( ChozenTemplate.templates.contentMultiple(css.chznChoices(), css.searchField(), defaultText, css.defaultClass(), css.chznDrop(), css.chznResults(), horizontalOffset).asString()); } else { containerTemp.html(ChozenTemplate.templates.contentSingle(css.chznSingle(), css.chznDefault(), defaultText, css.chznDrop(), css.chznSearch(), css.chznResults(), horizontalOffset).asString()); } // insert container after the select elements $selectElement.hide().after(containerTemp); container = $("#" + containerId); container.addClass(isMultiple ? css.chznContainerMulti() : css.chznContainerSingle()); dropdown = container.find("div." + css.chznDrop()).first(); int ddTop = container.height(); int ddWidth = fWidth - getSideBorderPadding(dropdown, isHidden); dropdown.css(Properties.create("{\"width\": " + ddWidth + "px, \"top\": " + ddTop + "px}")); searchField = container.find("input").first(); searchResults = container.find("ul." + css.chznResults()).first(); searchFieldScale(); if (isMultiple) { searchChoices = container.find("ul." + css.chznChoices()).first(); searchContainer = container.find("li." + css.searchField()).first(); } else { searchContainer = container.find("div." + css.chznSearch()).first(); selectedItem = container.find("." + css.chznSingle()).first(); int searchFieldWidth = ddWidth - getSideBorderPadding(searchContainer, isHidden) - getSideBorderPadding(searchField, isHidden); searchField.css("width", searchFieldWidth + "px"); } resultsBuild(); setTabIndex(); fireEvent(new ReadyEvent(this)); }