Package com.google.gwt.query.client

Examples of com.google.gwt.query.client.Function


  public void setupDemoElement(final Element demo) {
    final GQuery tab_title_input = $("#tab_title");
    final GQuery tab_content_input = $("#tab_content");
    tab_counter = 2;

    final Function removeTab = new Function() {
      public boolean f(Event close) {
        // Find the tab's index
        int index = $("#tabs li").index($(close).parent().get(0));
        $("#tabs").as(Ui).tabs().remove(index);
        return false;
      };
    };

    // tabs init with a custom tab template and an "add" callback filling in the content
    final Tabs tabs = $("#tabs").as(Ui).tabs( //
    Tabs.Options.create().tabTemplate("<li><a href=\"#{href}\">#{label}</a> <span class=\"ui-icon ui-icon-close\">Remove Tab</span></li>")) //
    .bind(Tabs.Event.add, new Function() {
      @Override
      public boolean f(Event e, Object data) {
        final Tabs.Event event = ((JavaScriptObject) data).cast();
        String tab_content = tab_content_input.val();
        if(tab_content == null || tab_content.isEmpty()) {
          tab_content = "Tab " + tab_counter + " content.";
        }
        $(event.panel()).append("<p>" + tab_content + "</p>");

        // close icon: removing the tab on click
        // note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
        $("span.ui-icon-close", event.tab().getParentElement()).click(removeTab);
        return false;
      }
    });

    $("#tabs span.ui-icon-close").click(removeTab);

    final Function addTab = new Function() {
      @Override
      public void f(Element e) {
        String tab_title = tab_title_input.val();
        if(tab_title == null || tab_title.isEmpty()) {
          tab_title = "Tab " + tab_counter;
        }
        tabs.add("#tabs-" + tab_counter, tab_title);
        tab_counter++;
      }
    };

    // modal dialog init: custom buttons and a "close" callback reseting the form inside
    final Dialog dialog = $("#dialog").as(Ui).dialog(Dialog.Options.create().autoOpen(false).modal(true)//
    .buttons(Buttons.create() //
    .define("Add", new Function() {
      public boolean f(Event e) {
        addTab.f((Element) null);
        $("#dialog").as(Ui).dialog().close();
        return false;
      }
    }) //
    .define("Cancel", new Function() {
      public boolean f(Event e) {
        $("#dialog").as(Ui).dialog().close();
        return false;
      }
    })));

    dialog.bind(Dialog.Event.open, new Function() {
      public void f(Element e) {
        tab_title_input.focus();
      };
    })//
    .bind(Dialog.Event.close, new Function() {
      public void f(Element e) {
        FormElement form = $("form", dialog.elements()[0]).elements()[0].cast();
        form.reset();
      };
    });

    // addTab button: just opens the dialog
    $("#add_tab").as(Ui).button().click(new Function() {
      public boolean f(Event e) {
        dialog.open();
        return false;
      };
    });
View Full Code Here


  public DemoPanel(String title, final HasWidgets demo, Demo... demos) {
    initWidget(uiBinder.createAndBindUi(this));
    $("h3", html.getElement()).text(title);
    for(final Demo d : demos) {
      $("ul", html.getElement()).append($("<li><a href=\"#\">" + d.getName() + "</a></li>").click(new Function() {
        @Override
        public boolean f(Event e) {
          demo.clear();
          fetchHtml(d, new RequestCallback() {
View Full Code Here

  public void setupDemoElement(final Element demo) {

    final Icons icons = Icons.create().header("ui-icon-circle-arrow-e").headerSelected("ui-icon-circle-arrow-s");
    $("#accordion", demo).as(Ui).accordion(Options.create().icons(icons));

    $("#toggle", demo).as(Ui).button().toggle(new Function() {
      @Override
      public boolean f(Event e) {
        $("#accordion").as(Ui).accordion().option("icons", false);
        return true;
      }

    }, new Function() {
      @Override
      public boolean f(Event e) {
        $("#accordion").as(Ui).accordion().option("icons", icons);
        return true;
      }
View Full Code Here

  public String getName() {
    return "Serialize";
  }

  public void setupDemoElement(Element demo) {
    $("#selectable").as(Ui).selectable().bind(Selectable.Event.stop, new Function() {
      @Override
      public boolean f(Event e, Object o) {
        final GQuery result = $("#select-result").empty();
        $(".ui-selected").each(new Function() {
          @Override
          public void f(Element e) {
            int index = $("#selectable li").index(e);
            result.append(" #" + (index + 1));
          }
View Full Code Here

    final GQuery start_counter = $("#event-start");
    final GQuery drag_counter = $("#event-drag");
    final GQuery stop_counter = $("#event-stop");
    final int[] counts = new int[] { 0, 0, 0 };

    $("#draggable").as(Ui).draggable().bind(Draggable.Event.start, new Function() {
      @Override
      public boolean f(com.google.gwt.user.client.Event e, Object data) {
        counts[0]++;
        updateCounterStatus(start_counter, counts[0]);
        return false;
      }
    }).bind(Draggable.Event.drag, new Function() {
      @Override
      public boolean f(com.google.gwt.user.client.Event e, Object data) {
        counts[1]++;
        updateCounterStatus(drag_counter, counts[1]);
        return false;
      }
    }).bind(Draggable.Event.stop, new Function() {
      @Override
      public boolean f(com.google.gwt.user.client.Event e, Object data) {
        counts[2]++;
        updateCounterStatus(stop_counter, counts[2]);
        return false;
View Full Code Here

    final Stop stop = new Stop();

    // Note: the interaction between the sortable "stop" event and the accordion click event is currently not working.
    // Not sure why. Maybe due to missing stopImmediatePropagation() (see below).

    $("#accordion h3", demo).click(new Function() {
      @Override
      public boolean f(Event event) {
        if(stop.stop) {
          // TODO: there's no stopImmediatePropagation in GQuery. Is it necessary?
          event.stopPropagation();
          event.preventDefault();
          stop.stop = false;
        }
        return false;
      }
    });
    $("#accordion", demo).as(Ui).accordion("{header: \"> div > h3\"}").sortable("{axis: \"y\", handle: \"h3\"}").bind("sortstop", new Function() {
      @Override
      public boolean f(Event e, Object data) {
        stop.stop = true;
        return false;
      }
View Full Code Here

    $("#catalog").as(Ui).accordion();
    $("#catalog li").as(Ui).draggable("{appendTo: 'body', helper: 'clone'}");
    $("#cart ol").as(Ui).droppable(Droppable.Options.create()//
    .activeClass("ui-state-default")//
    .hoverClass("ui-state-hover")//
    .accept(":not(.ui-sortable-helper)")).bind(Droppable.Event.drop, new Function() {
      public boolean f(Event e, Object ui) {
        Droppable.Event dropevent = (Droppable.Event) ui;
        $(e).find(".placeholder").remove();
        $("<li></li>").text($(dropevent.draggable()).text()).appendTo($(e));
        return false;
View Full Code Here

  }

  public void setupDemoElement(Element demo) {
    $("#draggable").as(Ui).draggable();
    $("#droppable").as(Ui).droppable(Droppable.Options.create().accept("#draggable").hoverClass("ui-state-active"))//
    .bind(Droppable.Event.drop, new Function() {
      @Override
      public void f(Element e) {
        $(e).addClass("ui-state-highlight").find("p").html("Dropped!");
      }
    });

    $("#draggable2").as(Ui).draggable();
    $("#droppable2").as(Ui).droppable(Droppable.Options.create().accept("#draggable2").activeClass("ui-state-hover"))//
    .bind(Droppable.Event.drop, new Function() {
      @Override
      public void f(Element e) {
        $(e).addClass("ui-state-highlight").find("p").html("Dropped!");
      }
    });
View Full Code Here

  }

  public void setupDemoElement(Element demo) {
    $("#draggable, #draggable-nonvalid").as(Ui).draggable();
    $("#droppable").as(Ui).droppable(Droppable.Options.create().accept("#draggable").activeClass("ui-state-hover").hoverClass("ui-state-active"))//
    .bind(Droppable.Event.drop, new Function() {
      @Override
      public void f(Element e) {
        $(e).addClass("ui-state-highlight").find("p").html("Dropped!");
      }
    });
View Full Code Here

    return "Default Functionality";
  }

  public void setupDemoElement(Element demo) {
    $("#draggable").as(Ui).draggable();
    $("#droppable").as(Ui).droppable().bind(Droppable.Event.drop, new Function() {
      @Override
      public void f(Element e) {
        $(e).addClass("ui-state-highlight").find("p").html("Dropped!");
      }
    });
View Full Code Here

TOP

Related Classes of com.google.gwt.query.client.Function

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.