List of usage examples for com.google.gwt.query.client GQuery get
public Element get(int i)
From source file:com.arcbees.beestore.client.application.widget.slider.Slider.java
License:Apache License
Function createAnimation(final GQuery w) { return new Function() { @Override/* w w w. ja v a 2 s.c o m*/ public void f() { final List<Element> elements = Lists.newArrayList(w.get(0), activeItem.get(0)); final String indexOfSelected = w.css("order"); activeAnimation = true; activeItem.bind(TRANSITION_END, new Function() { @Override public void f() { $(this).unbind(TRANSITION_END); activeItem.removeClass(sliderResources.style().activeProduct()); w.addClass(sliderResources.style().activeProduct()); $(elements).attr("style", "transform: scale(1);"); setOrder(w, String.valueOf(ACTIVE_BRAND_INDEX)); setOrder(activeItem, indexOfSelected); activeItem = $(w.get(0)); queueFinishAnimation(); } }); $(elements).css("transform", "scale(0.1)"); } }; }
From source file:com.arcbees.chosen.client.ChosenImpl.java
License:Apache License
protected void containerMouseDownImpl(Event e, GQuery element) { if (!activeField) { $(document).click(clickTestAction); resultsShow();//from w w w.java2 s .c o m } else if (!element.isEmpty() && (element.get(0) == selectedItem.get(0) || element.parents("a." + css.chznSingle()).length() > 0)) { e.preventDefault(); resultsToggle(); } if (!element.hasClass(css.activeResult())) { activateField(); } }
From source file:com.arcbees.chosen.client.ChosenImpl.java
License:Apache License
private boolean containerMouseUp(Event e) { Element target = e.getEventTarget().cast(); GQuery $e = $(target); if (!$e.isEmpty() && "ABBR".equalsIgnoreCase($e.get(0).getNodeName()) && !isDisabled) { resultsReset();//from ww w . ja v a 2 s.c o m return false; } return true; }
From source file:com.arcbees.chosen.client.gwt.ChosenListBox.java
License:Apache License
/** * Inserts an item into a group at the specified location. Additionally, the item can have an extra class name as * well as indent level assigned to it./*from ww w .ja va 2 s.co m*/ * <p/> * <b>NB!</b> It is important to set text into the option after the option has been appended to the DOM * <br/>that's known bug in IE @see <a href="http://bugs.jquery.com/ticket/3041">jQuery bug tracker</a> * <p/> * * @param item the item label to display * @param value the value of the item in the HTML form context * @param className the class name to append to the option (pass {@code null} to append no class name) * @param dir allows specifying an RTL, LTR or inherited direction ({@code null} is LTR) * @param indentLevel the number of times to indent the item from the left (pass 0 for no indentation) * @param groupIndex the index of the group to insert the item into (if out of bounds, the last group will be used) * @param itemIndex the index of the item within a group (if out of bounds, item will be placed last in the group) */ public void insertStyledItemToGroup(String item, String value, String className, Direction dir, int indentLevel, int groupIndex, int itemIndex) { int pos = groupIndex; if (indentLevel < 0) { throw new IllegalArgumentException("[indentLevel] must be non-negative."); } GQuery optgroupList = $(OPTGROUP_TAG, getElement()); int groupCount = optgroupList.size(); if (groupCount == 0) { // simply insert the item to the listbox insertItem(item, dir, value, itemIndex); return; } if (pos < 0 || pos > groupCount - 1) { pos = groupCount - 1; } GQuery optgroup = optgroupList.eq(pos); OptionElement option = Document.get().createOptionElement(); if (!(className == null || className.trim().isEmpty())) { option.addClassName(className); } if (indentLevel > 0) { // Calculate total indentation, not forgetting that being in a group is adding one extra indent step int leftPadding = options.getResources().css().indent() * (indentLevel + 1); option.setAttribute("style", "padding-left: " + leftPadding + "px;"); } Element optGroupElement = optgroup.get(0); int itemCount = optGroupElement.getChildCount(); if (itemIndex < 0 || itemIndex > itemCount - 1) { optgroup.append(option); } else { GQuery before = $(optGroupElement.getChild(itemIndex)); before.before(option); } // setText must be after the element has been appended to the DOM - see javadoc setOptionText(option, item, dir); option.setValue(value); }
From source file:com.arcbees.chosen.client.gwt.ChosenListBox.java
License:Apache License
@Override protected com.google.gwt.user.client.Element getStyleElement() { GQuery chosenElement = getChosenElement(); if (!chosenElement.isEmpty()) { return chosenElement.get(0).cast(); }/* w w w.j a va2 s . c o m*/ return super.getStyleElement(); }
From source file:com.arcbees.gquery.tooltip.client.TooltipImpl.java
License:Apache License
private void doShowTooltip() { GQuery tooltip = getTip(); OffsetInfo oi = OffsetInfo.from($element); long actualWidth = tooltip.get(0).getOffsetWidth(); long actualHeight = tooltip.get(0).getOffsetHeight(); Offset additionalOffset = getAdditionalOffset(); if (additionalOffset != null) { oi.top += additionalOffset.top;/*w w w .j av a 2s. co m*/ oi.left += additionalOffset.left; } long finalTop = 0; long finalLeft = 0; String placementClass = null; switch (getPlacement(oi, actualHeight, actualWidth)) { case BOTTOM: finalTop += oi.top + oi.height; finalLeft = oi.left + oi.width / 2 - actualWidth / 2; placementClass = style.bottom(); break; case TOP: finalTop = oi.top - actualHeight; finalLeft = oi.left + oi.width / 2 - actualWidth / 2; placementClass = style.top(); break; case LEFT: finalTop = oi.top + oi.height / 2 - actualHeight / 2; finalLeft = oi.left - actualWidth; placementClass = style.left(); break; case RIGHT: finalTop = oi.top + oi.height / 2 - actualHeight / 2; finalLeft = oi.left + oi.width; placementClass = style.right(); break; } tooltip.offset((int) finalTop, (int) finalLeft); tooltip.addClass(placementClass).addClass(style.in()); tooltip.css("visibility", "visible"); if (options.getTrigger() != TooltipTrigger.HOVER && options.isAutoClose()) { $(document).delay(1, new Function() { @Override public void f() { $(document).click(autoCloseFunction); } }); } if (options.getClosingPartner() != null) { tooltip.on(CLICK, options.getClosingPartner(), new Function() { @Override public void f() { hide(); } }); } }
From source file:com.pronoiahealth.olhie.client.pages.bookcase.widgets.BookCaseContainerWidget.java
License:Open Source License
/** * Configure the update when a users moves a book in the display and * configure the button click on a book display. *///from ww w . j av a 2 s. c om private void config() { // Configure the sortable container // JSONObject obj = new JSONObject(); // configSortable(this, sortableContainer, obj.getJavaScriptObject()); // Configure sortable GQuery sortableContainerQry = $(sortableContainer); sortableContainerQry.as(Ui).sortable().bind("sortupdate", new Function() { @Override public boolean f(Event e, Object data) { GQuery lstQry = $(sortableContainer).find(".ui-state-default"); int size = lstQry.length(); Map<String, Integer> map = new HashMap<String, Integer>(); for (int i = 0; i < size; i++) { com.google.gwt.dom.client.Element ret = lstQry.get(i); GQuery retQry = $(ret).find(".bookCase-Detail-Button"); String val = retQry.attr("userBookRelationshipId"); map.put(val, Integer.valueOf(i)); } // Tell the server to update the data bookcaseBookWidgetReorderEvent.fire(new BookcaseBookWidgetReorderEvent(map)); // Event propagation stops here return false; } }); // Configure the click events, bind the bookClickFunction to each // element GQuery sortableQry = sortableContainerQry.find(".bookCase-Detail-Button"); sortableQry.each(new Function() { @Override public void f(com.google.gwt.dom.client.Element e) { $(e).bind(Event.ONCLICK, new Function() { @Override public boolean f(Event e) { // Fire the event which will get the clicked book for // display String bookId = $(e).attr("bookId"); if (bookId != null && bookId.length() > 0) { bookListBookSelectedEvent.fire(new BookcaseBookListBookSelectedEvent(bookId)); } return false; } }); } }); }
From source file:com.pronoiahealth.olhie.client.pages.bookcase.widgets.BookCaseContainerWidget.java
License:Open Source License
/** * Receives the Update event from the attached jQuery sortable widget. See * the config method for details.//w w w . j a v a 2s.co m * * @param evt * @param values */ private void fireOnSortableUpdateEvent(com.google.gwt.user.client.Event evt, JavaScriptObject values) { GQuery lstQry = $(sortableContainer).find(".ui-state-default"); int size = lstQry.length(); for (int i = 0; i < size; i++) { com.google.gwt.dom.client.Element ret = lstQry.get(i); GQuery retQry = $(ret); } }
From source file:com.watopi.chosen.client.ChosenImpl.java
License:Open Source License
private boolean containerMouseDown(Event e) { if (isDisabled) { return true; }// w w w.j a v a2s.c om Element target = e.getEventTarget().cast(); GQuery $e = $(target); boolean targetCloseLink = $e.hasClass(css.searchChoiceClose()); if (!resultsShowing) { e.stopPropagation(); } if (!pendingDestroyClick && !targetCloseLink) { if (!activeField) { if (isMultiple) { searchField.val(""); } $(document).click(clickTestAction); resultsShow(); } else if (!isMultiple && !$e.isEmpty() && ($e.get(0) == selectedItem.get(0) || $e.parents("a." + css.chznSingle()).length() > 0)) { e.preventDefault(); resultsToggle(); } activateField(e); } else { pendingDestroyClick = false; } return false; }
From source file:com.watopi.chosen.client.ChosenImpl.java
License:Open Source License
private boolean containerMouseUp(Event e) { Element target = e.getEventTarget().cast(); GQuery $e = $(target); if (!$e.isEmpty() && "ABBR".equalsIgnoreCase($e.get(0).getNodeName()) && !isDisabled) { resultsReset(e);//from www . j a va2 s . co m return false; } return true; }