コード例 #1
0
ファイル: HomePage.java プロジェクト: b-cuts/blogs
    private static void replace(AjaxRequestTarget target, Component component) {
      component.add(new DisplayNoneBehavior());

      target.prependJavaScript(
          "notify|jQuery('#" + component.getMarkupId() + "').slideUp(1000, notify);");
      target.add(component);
      target.appendJavaScript("jQuery('#" + component.getMarkupId() + "').slideDown(1000);");
    }
コード例 #2
0
  /**
   * helper method
   *
   * @param marker
   */
  public void clickAndOpenPopup(Marker marker, AjaxRequestTarget target) {
    String mapId = getOpenLayerMap().getJSInstance();
    String jsToRun =
        "if ("
            + mapId
            + ".popup != null) {"
            + "		"
            + mapId
            + ".map.removePopup("
            + mapId
            + ".popup);"
            + "		"
            + mapId
            + ".popup.destroy();"
            + "		"
            + mapId
            + ".popup = null;"
            + "}";

    target.prependJavaScript(jsToRun);

    // Currently only support clicking on markers!
    getOpenLayerMap().getInfoWindow().getContent().replaceWith(marker.getPopup());
    getOpenLayerMap().getInfoWindow().setContent(marker.getPopup());
    target.add(marker.getPopup());
    jsToRun =
        mapId
            + ".popup = new OpenLayers.Popup('map', "
            + new LonLat(marker.getLonLat().getLng(), marker.getLonLat().getLat())
            + ", "
            + new Size(195, 250).getJSconstructor()
            + ", document.getElementById("
            + mapId
            + ".popupId).innerHTML, true);"
            + mapId
            + ".popup.setBackgroundColor('white');"
            + mapId
            + ".map.addPopup("
            + mapId
            + ".popup);";

    // open info window
    target.appendJavaScript(jsToRun);
  }
コード例 #3
0
  @Override
  public void onEvent(IEvent<?> event) {
    super.onEvent(event);

    if (event.getPayload() instanceof AjaxRequestTarget) {

      AjaxRequestTarget target = (AjaxRequestTarget) event.getPayload();

      if (target.getComponents().contains(this)) {

        // if this component is being repainted by ajax, directly, we must destroy Select2 so it
        // removes
        // its elements from DOM

        target.prependJavaScript(
            JQuery.execute("$('#%s').select2('destroy');", getJquerySafeMarkupId()));
      }
    }
  }