Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param direction The direction used to shake it.
  * @param times show many time to shake it.
  * @param distance The distance
  * @param duration The duration
  */
 public BounceEffect(
     BounceDirection direction, BounceMode mode, int times, int distance, int duration) {
   super(
       JsUtils.quotes("bounce"),
       "{direction:"
           + JsUtils.quotes(direction.name())
           + ", times: "
           + Integer.toString(times)
           + ", mode: "
           + JsUtils.quotes(mode.name())
           + ", distance:"
           + Integer.toString(distance)
           + "}",
       Integer.toString(duration));
 }
        @Override
        public void renderHead(Component component, IHeaderResponse response) {
          component.setOutputMarkupId(true);

          StringBuilder sb = new StringBuilder();
          sb.append(
                  new JsStatement()
                      .$(component, ".form-group, .form-decorator-error-group")
                      .removeClass(HAS_ERROR_CSS_CLASS)
                      .render())
              .append(
                  new JsStatement()
                      .$(component, ".has-error")
                      .chain(
                          "parentsUntil",
                          JsUtils.quotes("#" + component.getMarkupId()),
                          JsUtils.quotes(".form-group, .form-decorator-error-group"))
                      .addClass(HAS_ERROR_CSS_CLASS)
                      .render())
              // Les .form-decorator-error-reminder doivent prendre une apparence particulière en
              // cas d'erreur,
              // mais sans impacter l'apparence des sous-éléments comme le ferait un .has-error
              .append(
                  new JsStatement()
                      .$(component, ".form-decorator-error-reminder")
                      .removeClass(HAS_ERROR_REMINDER_CSS_CLASS)
                      .render())
              .append(
                  new JsStatement()
                      .$(component, "." + HAS_ERROR_CSS_CLASS)
                      .chain(
                          "parentsUntil",
                          JsUtils.quotes("#" + component.getMarkupId()),
                          JsUtils.quotes(".form-decorator-error-reminder"))
                      .addClass(HAS_ERROR_REMINDER_CSS_CLASS)
                      .render());
          response.render(OnDomReadyHeaderItem.forScript(sb.toString()));
        }