CallBackery

 view release on metacpan or  search on metacpan

lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/DateTime.js  view on Meta::CPAN

    {
      // get the key identifier
      var iden = e.getKeyIdentifier();
      if (iden == "Down" && e.isAltPressed())
      {
        this.toggle();
        e.stopPropagation();
        return;
      }

      // if the popup is closed, ignore all
      var popup = this.getChildControl("popup");
      if (popup.getVisibility() == "hidden") {
        return;
      }

      // hide the list always on escape
      if (iden == "Escape")
      {
        this.close();
        e.stopPropagation();
        return;
      }

      // Stop navigation keys when popup is open
      if (iden === "Left" || iden === "Right" || iden === "Down" || iden === "Up") {
        e.preventDefault();
      }

      // forward the rest of the events to the date chooser
      this.getChildControl("list").handleKeyPress(e);
    },


    /**
     * Redirects changeVisibility event from the list to this widget.
     *
     * @param e {qx.event.type.Data} Property change event
     */
    _onPopupChangeVisibility : function(e)
    {
      e.getData() == "visible" ? this.addState("popupOpen") : this.removeState("popupOpen");

      // Synchronize the chooser with the current value on every
      // opening of the popup. This is needed when the value has been
      // modified and not saved yet (e.g. no blur)
      var popup = this.getChildControl("popup");
      var chooser = this.getChildControl("list");
      if (popup.isVisible())
      {
          var date = this.getValue();
          if (date != null) {
              chooser.setValue(date);
          }
      }
    },


    /**
     * Reacts on value changes of the text field and syncs the
     * value to the combobox.
     *
     * @param e {qx.event.type.Data} Change event
     */
    _onDateFieldChangeValue : function(e)
    {
      // Apply to popup
      var date = e.getData();
      if (date != null && date != '')
      {

        var timefield = this.getChildControl("timefield");
        var time        = timefield.getValue();
        var defaultTime = timefield.getPlaceholder();
        var today = new Date();
          var dateValue;
        try {
            dateValue = this.getDateFormat().parse(date);
        }
        catch (ex) {
            this.debug('_onDateFieldChangeValue(): Invalid date format');
            dateValue = today;
        }
        this.setValue(dateValue);
        var list = this.getChildControl("list");
        list.setValue(dateValue);
        if (time != null) {
            timefield.setValue(time);
        }
        else if (defaultTime != null) {
            timefield.setValue(defaultTime);
        }

      }

      // Fire event
      this.fireDataEvent("changeValue", this.getValue());
    },


    /**
     * Reacts on value changes of the text field.
     *
     * @param e {qx.event.type.Data} Change event
     */
    _onTimeFieldChangeValue : function(e)
    {
      // Fire event
      this.fireDataEvent("changeValue", this.getValue());
    },


    /**
     * Checks if the textfield of the DateField is empty.
     *
     * @return {Boolean} True, if the textfield of the DateField is empty.
     */
    isEmpty: function()
    {
      var value = this.getChildControl("datefield").getValue();
      return value == null || value == "";



( run in 0.702 second using v1.01-cache-2.11-cpan-2398b32b56e )