List of usage examples for com.google.gwt.query.client GQuery as
@SuppressWarnings("unchecked") public <T extends GQuery> T as(Class<T> plugin)
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. *//* w w w . ja va 2s . c o m*/ 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
/** * Clears book item widgets/*from w w w . ja v a 2s .c o m*/ */ private void disposeBookCaseDraggableBookWidgets() { if (sortableContainer != null && sortableContainer.hasChildNodes()) { GQuery sortableContainerQry = $(sortableContainer); // Unbind the click events GQuery sortableQry = sortableContainerQry.find(".bookCase-Detail-Button"); sortableQry.each(new Function() { @Override public void f(com.google.gwt.dom.client.Element e) { $(e).unbind(Event.ONCLICK); } }); // Unbind the sortable sortableContainerQry.as(Ui).sortable().unbind("sortupdate"); sortableContainerQry.as(Ui).sortable().destroy(); // Remove all the widgets int cnt = DOM.getChildCount(sortableContainer); for (int i = 0; i < cnt; i++) { Element e = DOM.getChild(sortableContainer, i); EventListener listener = DOM.getEventListener((com.google.gwt.user.client.Element) e); // No listener attached to the element, so no widget exist for // this element if (listener != null && listener instanceof BookCaseDraggableBookWidget) { bookCaseDraggableBookWidgetDisposer.dispose((BookCaseDraggableBookWidget) listener); } } } // Destroy physical Node node = null; while ((node = sortableContainer.getFirstChild()) != null) { sortableContainer.removeChild(node); } }
From source file:com.vaadin.addons.sliderlayout.gwt.client.VSliderLayout.java
License:Apache License
private void rollTo(String id, final int slideTo, String animation, int duration) { GQuery panel = $(SLIDE_DEFAULT_CLASS_NAME + "-" + uidlId); if (panel == null) return;// w ww .j a v a2s.c o m if (panel.widgets().size() == 0) panel.css(CSS.LEFT, "0"); // animate slide to number panel.as(Effects) //.delay(1000) //.animate("left: -" + Integer.toString(100 * slideTo) + "%", 1000, EasingExt.EASE_OUT_BOUNCE, new Function() { // don't use 0% (only compatible with webkit browsers) for left property use 0px to be compatible with firefox and IE and opera !!! .animate("left: -" + Integer.toString(panel.outerWidth() * slideTo), duration, getEasing(animation), new Function() { boolean fistEvent = true; public void f(Element e) { // only send the first event from all slides movement if (fistEvent) { client.updateVariable(uidlId, "fromSlideName", lastSlideName, false); client.updateVariable(uidlId, "toSlideName", "v-slide-" + slideTo, true); // save the last Slide name lastSlideName = "v-slide-" + slideTo; fistEvent = false; } } }); }
From source file:gwtquery.plugins.droppable.client.gwt.DragAndDropCellWidgetUtils.java
License:Apache License
void cleanCell(Element cell) { if (cell == null) { return;/*from ww w. j a v a 2 s . c o m*/ } GQuery $cell = $(cell); if (DraggableHandler.getInstance(cell) != null) { $cell.as(Draggable).destroy(); } if (DroppableHandler.getInstance(cell) != null) { $cell.as(Droppable).destroy(); } $cell.removeData(VALUE_KEY); }
From source file:gwtquery.plugins.droppable.client.gwt.DragAndDropCellWidgetUtils.java
License:Apache License
<C> void maybeMakeDraggableOrDroppable(Element cell, C value, CellDragAndDropBehaviour<C> cellDragAndDropBehaviour, DraggableOptions draggableOptions, DroppableOptions droppableOptions, EventBus eventBus) { GQuery $cell = $(cell); if ((cellDragAndDropBehaviour == null || cellDragAndDropBehaviour.isDraggable(value)) && DraggableHandler.getInstance(cell) == null) { $cell.as(Draggable).draggable(draggableOptions, eventBus); }/*from w w w . ja v a 2s . c om*/ if ((cellDragAndDropBehaviour == null || cellDragAndDropBehaviour.isDroppable(value)) && DroppableHandler.getInstance(cell) == null) { $cell.as(Droppable).droppable(droppableOptions, eventBus); } $cell.data(VALUE_KEY, value); }