Example usage for com.google.gwt.query.client GQuery data

List of usage examples for com.google.gwt.query.client GQuery data

Introduction

In this page you can find the example usage for com.google.gwt.query.client GQuery data.

Prototype

public GQuery data(String name, Object value) 

Source Link

Document

Stores the value in the named spot with desired return type.

Usage

From source file:com.arcbees.gquery.elastic.client.Elastic.java

License:Apache License

public Elastic elastic(ElasticOption options) {
    for (Element e : elements()) {
        GQuery $e = $(e);
        if (isSupported() && getImpl(e) == null) {
            ElasticImpl impl = new ElasticImpl(e, options);
            $e.data(ELASTIC_DATA_KEY, impl);
        }/*  ww  w.  j  a va2s.  co  m*/
    }
    return this;
}

From source file:com.arcbees.gquery.elastic.client.ElasticImpl.java

License:Apache License

private StyleInfo initItem(Element e) {
    int span = getSpan(e);
    Integer floatColumn = null;/*from   www.  ja  v a 2 s.c  o m*/

    String floatValue = e.getAttribute(Elastic.COLUMN_ATTRIBUTE);
    if (FIRST.equalsIgnoreCase(floatValue)) {
        floatColumn = 0;
    } else if (LAST.equalsIgnoreCase(floatValue)) {
        floatColumn = -span;
    } else {
        try {
            floatColumn = Integer.parseInt(floatValue) - 1;
        } catch (NumberFormatException ignored) {
        }
    }

    GQuery $e = $(e);

    StyleInfo styleInfo = new StyleInfo();
    styleInfo.span = getSpan(e);
    styleInfo.rowSpanAll = "all".equals(e.getAttribute(Elastic.ROW_SPAN_ATTRIBUTE));
    styleInfo.floatColumn = floatColumn;
    styleInfo.marginRight = $e.cur("marginRight", true);
    styleInfo.marginLeft = $e.cur("marginLeft", true);
    styleInfo.borderTopWidth = $e.cur("borderTopWidth", true);
    styleInfo.borderBottomWidth = $e.cur("borderBottomWidth", true);
    styleInfo.marginTop = $e.cur("marginTop", true);
    styleInfo.marginBottom = $e.cur("marginBottom", true);

    $e.data(STYLE_INFO_KEY, styleInfo);
    $e.css("position", "absolute");

    // TODO Ease next width computation but check the impact of this in the content of the item
    if (GQuery.browser.mozilla) {
        $e.css("moz-box-sizing", "border-box");
    } else {
        $e.css("box-sizing", "border-box");
    }

    return styleInfo;
}

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 ww w  . j  a va 2s  . c  o 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:gwtquery.plugins.draggable.client.plugins.CursorPlugin.java

License:Apache License

public void onStart(DraggableHandler handler, DragContext ctx, GqEvent e) {

    if (ctx.getInitialDraggable() == ctx.getDraggable() && !isStarting) {
        isStarting = true;//from  w ww  .j  a  v a  2  s .c o m
        GQuery $body = $(body);
        String oldCursor = $body.css(CURSOR_CSS);
        if (oldCursor != null) {
            $body.data(OLD_CURSOR_KEY, oldCursor);
        }
        $body.css(CURSOR_CSS, handler.getOptions().getCursor().getCssName());
    }

}

From source file:gwtquery.plugins.draggable.client.plugins.CursorPlugin.java

License:Apache License

public void onStop(DraggableHandler handler, DragContext ctx, GqEvent e) {
    if (ctx.getInitialDraggable() != ctx.getDraggable()) {
        return;/* w ww.j av  a 2 s  .  co  m*/
    }
    GQuery $body = $(body);
    String oldCursor = $body.data(OLD_CURSOR_KEY, String.class);
    $body.css(CURSOR_CSS, oldCursor);
    isStarting = false;
}

From source file:gwtquery.plugins.draggable.client.plugins.GroupSelectedPlugin.java

License:Apache License

public void onStart(DraggableHandler handler, DragContext ctx, GqEvent e) {

    Element initialDraggable = ctx.getInitialDraggable();

    if (initialDraggable == ctx.getDraggable()) {
        return;// w w  w. j  a  va 2s  .co m
    }

    DraggableHandler initialDragHandler = DraggableHandler.getInstance(initialDraggable);
    GQuery $initialDraggable = $(initialDraggable);

    GroupingMode groupingMode = handler.getOptions().getGroupingMode();
    int groupSpacing = handler.getOptions().getGroupSpacing();

    Offset newPosition = null;

    switch (groupingMode) {
    case DOWN:
        HelperInfo lastDown = $initialDraggable.data(LAST_DOWN, HelperInfo.class);
        if (lastDown == null) {
            lastDown = new HelperInfo(initialDragHandler.getAbsolutePosition(), initialDragHandler.getHelper());
        }

        newPosition = lastDown.offset.add(0, lastDown.height + groupSpacing);
        HelperInfo newLastDown = new HelperInfo(newPosition, handler.getHelper());
        $initialDraggable.data(LAST_DOWN, newLastDown);

        break;

    case UP:
        HelperInfo lastUp = $initialDraggable.data(LAST_UP, HelperInfo.class);
        if (lastUp == null) {
            lastUp = new HelperInfo(initialDragHandler.getAbsolutePosition(), initialDragHandler.getHelper());
        }

        newPosition = lastUp.offset.add(0, -handler.getHelperDimension().getHeight() - groupSpacing);
        HelperInfo newLastUp = new HelperInfo(newPosition, handler.getHelper());
        $initialDraggable.data(LAST_UP, newLastUp);
        break;
    case LEFT:
        HelperInfo lastLeft = $initialDraggable.data(LAST_LEFT, HelperInfo.class);
        if (lastLeft == null) {
            lastLeft = new HelperInfo(initialDragHandler.getAbsolutePosition(), initialDragHandler.getHelper());
        }

        newPosition = lastLeft.offset.add(-handler.getHelperDimension().getWidth() - groupSpacing, 0);
        HelperInfo newLastLeft = new HelperInfo(newPosition, handler.getHelper());
        $initialDraggable.data(LAST_LEFT, newLastLeft);

        break;

    case RIGHT:
        HelperInfo lastRight = $initialDraggable.data(LAST_RIGHT, HelperInfo.class);
        if (lastRight == null) {
            lastRight = new HelperInfo(initialDragHandler.getAbsolutePosition(),
                    initialDragHandler.getHelper());
        }

        newPosition = lastRight.offset.add(lastRight.width + groupSpacing, 0);
        HelperInfo newLastRight = new HelperInfo(newPosition, handler.getHelper());
        $initialDraggable.data(LAST_RIGHT, newLastRight);

        break;

    default:
        break;
    }

    if (newPosition != null) {

        Offset actualPosition = handler.getAbsolutePosition();
        Offset clickOffset = handler.getOffsetClick();
        Offset newClickOffset = clickOffset.add(actualPosition.left - newPosition.left,
                actualPosition.top - newPosition.top);
        handler.setOffsetClick(newClickOffset);
    }

}

From source file:gwtquery.plugins.draggable.client.plugins.OpacityPlugin.java

License:Apache License

public void onStart(DraggableHandler handler, DragContext ctx, GqEvent e) {
    Float opacity = handler.getOptions().getOpacity();

    GQuery $helper = handler.getHelper();

    double oldOpacity = $helper.cur(OPACITY_CSS_KEY, true);
    $helper.data(OLD_OPACITY_KEY, new Double(oldOpacity));

    $helper.css(OPACITY_CSS_KEY, opacity.toString());

}

From source file:gwtquery.plugins.draggable.client.plugins.ZIndexPlugin.java

License:Apache License

public void onStart(DraggableHandler handler, DragContext ctx, GqEvent e) {
    GQuery $element = (handler.getOptions().getHelperType() == HelperType.ORIGINAL) ? $(ctx.getDraggable())
            : handler.getHelper();/*from  ww  w .jav a2  s .  c o  m*/
    if ($element == null || $element.length() == 0) {
        return;
    }
    //String oldZIndex = $element.css(ZINDEX_CSS);
    String oldZIndex = getZIndex($element.get(0).getStyle());
    if (oldZIndex != null) {
        $element.data(OLD_ZINDEX_KEY, oldZIndex);
    }
    $element.css(ZINDEX_CSS, handler.getOptions().getZIndex().toString());

}

From source file:gwtquery.plugins.draggable.client.plugins.ZIndexPlugin.java

License:Apache License

public void onStop(DraggableHandler handler, DragContext ctx, GqEvent e) {
    //helper can be null if the draggableElement was unloaded and after loaded
    GQuery $element = (handler.getOptions().getHelperType() == HelperType.ORIGINAL) ? handler.getHelper()
            : $(ctx.getDraggable());/*  w w w.j av a  2 s.c  o m*/
    if ($element == null || $element.length() == 0) {
        return;
    }
    String oldZIndex = $element.data(OLD_ZINDEX_KEY, String.class);
    $element.css(ZINDEX_CSS, oldZIndex);
}

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);

    }//  w w w .j av a2s  . c o m

    if ((cellDragAndDropBehaviour == null || cellDragAndDropBehaviour.isDroppable(value))
            && DroppableHandler.getInstance(cell) == null) {

        $cell.as(Droppable).droppable(droppableOptions, eventBus);

    }

    $cell.data(VALUE_KEY, value);
}