dijit/form/_FormWidget.js

  • Provides:

    • dijit.form._FormWidget
  • dijit.form._FormWidget

    • type
      Function
    • chains:
      • dijit._Widget: (prototype)
      • dijit._Widget: (call)
      • dijit._Templated: (call)
      • dijit._CssStateMixin: (call)
    • mixins:
      • dijit._Templated.prototype: (prototype)
      • dijit._CssStateMixin.prototype: (prototype)
    • summary
      Base class for widgets corresponding to native HTML elements such as <checkbox> or <button>,
      which can be children of a <form> node or a `dijit.form.Form` widget.
    • description
      Represents a single HTML element.
      All these widgets should have these attributes just like native HTML input elements.
      You can set them during widget construction or afterwards, via `dijit._Widget.attr`.
      
      They also share some common methods.
  • dijit.form._FormWidget.name

    • tags: const
    • type
      String
    • summary
      Name used when submitting form; same as "name" attribute or plain HTML elements
  • dijit.form._FormWidget.alt

    • type
      String
    • summary
      Corresponds to the native HTML <input> element's attribute.
  • dijit.form._FormWidget.value

    • type
      String
    • summary
      Corresponds to the native HTML <input> element's attribute.
  • dijit.form._FormWidget.type

    • type
      String
    • summary
      Corresponds to the native HTML <input> element's attribute.
  • dijit.form._FormWidget.tabIndex

    • type
      Integer
    • summary
      Order fields are traversed when user hits the tab key
  • dijit.form._FormWidget.disabled

    • type
      Boolean
    • summary
      Should this widget respond to user input?
      In markup, this is specified as "disabled='disabled'", or just "disabled".
  • dijit.form._FormWidget.intermediateChanges

    • type
      Boolean
    • summary
      Fires onChange for each value change or only on demand
  • dijit.form._FormWidget.scrollOnFocus

    • type
      Boolean
    • summary
      On focus, should this widget scroll into view?
  • dijit.form._FormWidget.attributeMap

    • summary
  • dijit.form._FormWidget.postMixInProperties

    • type
      Function
    • source: [view]
      define("dijit/form/_FormWidget", ["dojo", "dijit", "dojo/window", "dijit/_Widget", "dijit/_Templated", "dijit/_CssStateMixin"], function(dojo, dijit) {


      dojo.declare("dijit.form._FormWidget", [dijit._Widget, dijit._Templated, dijit._CssStateMixin],
       {
       // summary:
       //  Base class for widgets corresponding to native HTML elements such as or
    • summary
  • dijit.form._FormWidget.postCreate

    • type
      Function
    • source: [view]
        this.inherited(arguments);
        this.connect(this.domNode, "onmousedown", "_onMouseDown");
    • summary
  • dijit.form._FormWidget._setDisabledAttr

    • type
      Function
    • parameters:
      • value: (typeof Boolean)
    • source: [view]
        this._set("disabled", value);
        dojo.attr(this.focusNode, 'disabled', value);
        if(this.valueNode){
         dojo.attr(this.valueNode, 'disabled', value);
        }
        dijit.setWaiState(this.focusNode, "disabled", value);


        if(value){
         // reset these, because after the domNode is disabled, we can no longer receive
         // mouse related events, see #4200
         this._set("hovering", false);
         this._set("active", false);


         // clear tab stop(s) on this widget's focusable node(s) (ComboBox has two focusable nodes)
         var attachPointNames = "tabIndex" in this.attributeMap ? this.attributeMap.tabIndex : "focusNode";
         dojo.forEach(dojo.isArray(attachPointNames) ? attachPointNames : [attachPointNames], function(attachPointName){
          var node = this[attachPointName];
          // complex code because tabIndex=-1 on a
      doesn't work on FF
          if(dojo.isWebKit || dijit.hasDefaultTabStop(node)){ // see #11064 about webkit bug
           node.setAttribute('tabIndex', "-1");
          }else{
           node.removeAttribute('tabIndex');
          }
         }, this);
        }else{
         if(this.tabIndex != ""){
          this.focusNode.setAttribute('tabIndex', this.tabIndex);
         }
        }
    • summary
  • dijit.form._FormWidget.setDisabled

    • type
      Function
    • parameters:
      • disabled: (typeof Boolean)
    • source: [view]
        dojo.deprecated("setDisabled("+disabled+") is deprecated. Use set('disabled',"+disabled+") instead.", "", "2.0");
        this.set('disabled', disabled);
    • summary
      Deprecated.  Use set('disabled', ...) instead.
  • dijit.form._FormWidget._onFocus

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
        if(this.scrollOnFocus){
         dojo.window.scrollIntoView(this.domNode);
        }
        this.inherited(arguments);
    • summary
  • dijit.form._FormWidget.isFocusable

    • type
      Function
    • source: [view]
        return !this.disabled && this.focusNode && (dojo.style(this.domNode, "display") != "none");
    • summary
      Tells if this widget is focusable or not.  Used internally by dijit.
    • tags:
  • dijit.form._FormWidget.focus

    • type
      Function
    • source: [view]
        if(!this.disabled){
         dijit.focus(this.focusNode);
        }
    • summary
      Put focus on this widget
  • dijit.form._FormWidget.compare

    • type
      Function
    • parameters:
      • val1: (typeof anything)
      • val2: (typeof anything)
    • source: [view]
        if(typeof val1 == "number" && typeof val2 == "number"){
         return (isNaN(val1) && isNaN(val2)) ? 0 : val1 - val2;
        }else if(val1 > val2){
         return 1;
        }else if(val1 < val2){
         return -1;
        }else{
         return 0;
        }
    • summary
      Compare 2 values (as returned by get('value') for this widget).
    • tags:
  • dijit.form._FormWidget.onChange

    • type
      Function
    • parameters:
      • newValue: (typeof )
    • source: [view]
        // summary:
        //  Callback when this widget's value is changed.
        // tags:
        //  callback
    • summary
      Callback when this widget's value is changed.
    • tags:
  • dijit.form._FormWidget._onChangeActive

    • tags: private
    • type
      Boolean
    • summary
      Indicates that changes to the value should call onChange() callback.
      This is false during widget initialization, to avoid calling onChange()
      when the initial value is set.
  • dijit.form._FormWidget._handleOnChange

    • type
      Function
    • parameters:
      • newValue: (typeof anything)
        the new value
      • priorityChange: (typeof Boolean)
        For a slider, for example, dragging the slider is priorityChange==false,
        but on mouse up, it's priorityChange==true.  If intermediateChanges==false,
        onChange is only called form priorityChange=true events.
    • source: [view]
        if(this._lastValueReported == undefined && (priorityChange === null || !this._onChangeActive)){
         // this block executes not for a change, but during initialization,
         // and is used to store away the original value (or for ToggleButton, the original checked state)
         this._resetValue = this._lastValueReported = newValue;
        }
        this._pendingOnChange = this._pendingOnChange
         || (typeof newValue != typeof this._lastValueReported)
         || (this.compare(newValue, this._lastValueReported) != 0);
        if((this.intermediateChanges || priorityChange || priorityChange === undefined) && this._pendingOnChange){
         this._lastValueReported = newValue;
         this._pendingOnChange = false;
         if(this._onChangeActive){
          if(this._onChangeHandle){
           clearTimeout(this._onChangeHandle);
          }
          // setTimout allows hidden value processing to run and
          // also the onChange handler can safely adjust focus, etc
          this._onChangeHandle = setTimeout(dojo.hitch(this,
           function(){
            this._onChangeHandle = null;
            this.onChange(newValue);
           }), 0); // try to collapse multiple onChange's fired faster than can be processed
         }
        }
    • summary
      Called when the value of the widget is set.  Calls onChange() if appropriate
    • tags:
  • dijit.form._FormWidget.create

    • type
      Function
    • source: [view]
      define("dijit/form/_FormWidget", ["dojo", "dijit", "dojo/window", "dijit/_Widget", "dijit/_Templated", "dijit/_CssStateMixin"], function(dojo, dijit) {


      dojo.declare("dijit.form._FormWidget", [dijit._Widget, dijit._Templated, dijit._CssStateMixin],
       {
       // summary:
       //  Base class for widgets corresponding to native HTML elements such as or
  • dijit.form._FormWidget.destroy

    • type
      Function
    • source: [view]
        if(this._onChangeHandle){ // destroy called before last onChange has fired
         clearTimeout(this._onChangeHandle);
         this.onChange(this._lastValueReported);
        }
        this.inherited(arguments);
    • summary
  • dijit.form._FormWidget.setValue

    • type
      Function
    • parameters:
      • value: (typeof String)
    • source: [view]
        dojo.deprecated("dijit.form._FormWidget:setValue("+value+") is deprecated. Use set('value',"+value+") instead.", "", "2.0");
        this.set('value', value);
    • summary
      Deprecated.  Use set('value', ...) instead.
  • dijit.form._FormWidget.getValue

    • type
      Function
    • source: [view]
        dojo.deprecated(this.declaredClass+"::getValue() is deprecated. Use get('value') instead.", "", "2.0");
        return this.get('value');
    • summary
      Deprecated.  Use get('value') instead.
  • dijit.form._FormWidget._onMouseDown

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
      define("dijit/form/_FormWidget", ["dojo", "dijit", "dojo/window", "dijit/_Widget", "dijit/_Templated", "dijit/_CssStateMixin"], function(dojo, dijit) {


      dojo.declare("dijit.form._FormWidget", [dijit._Widget, dijit._Templated, dijit._CssStateMixin],
       {
       // summary:
       //  Base class for widgets corresponding to native HTML elements such as or
  • dijit.form._FormWidget.nameAttrSetting

    • summary
  • dijit.form._FormWidget._lastValueReported

    • summary
  • dijit.form._FormWidget._resetValue

    • summary
  • dijit.form._FormWidget._pendingOnChange

    • summary
  • dijit.form._FormWidget._onChangeHandle

    • summary
  • dijit.form._FormValueWidget

    • type
      Function
    • chains:
      • dijit.form._FormWidget: (prototype)
      • dijit.form._FormWidget: (call)
    • summary
      Base class for widgets corresponding to native HTML elements such as &lt;input&gt; or &lt;select&gt; that have user changeable values.
  • dijit.form._FormValueWidget.readOnly

    • summary
  • dijit.form._FormValueWidget.attributeMap

    • summary
  • dijit.form._FormValueWidget._setReadOnlyAttr

    • type
      Function
    • parameters:
      • value: (typeof Boolean)
    • source: [view]
        dojo.attr(this.focusNode, 'readOnly', value);
        dijit.setWaiState(this.focusNode, "readonly", value);
        this._set("readOnly", value);
    • summary
  • dijit.form._FormValueWidget.postCreate

    • type
      Function
    • source: [view]
        this.inherited(arguments);


        if(dojo.isIE < 9 || (dojo.isIE && dojo.isQuirks)){ // IE won't stop the event with keypress
         this.connect(this.focusNode || this.domNode, "onkeydown", this._onKeyDown);
        }
        // Update our reset value if it hasn't yet been set (because this.set()
        // is only called when there *is* a value)
        if(this._resetValue === undefined){
         this._lastValueReported = this._resetValue = this.value;
        }
    • summary
  • dijit.form._FormValueWidget._setValueAttr

    • type
      Function
    • parameters:
      • newValue: (typeof anything)
      • priorityChange: (typeof Boolean)
    • source: [view]
        this._handleOnChange(newValue, priorityChange);
    • summary
      Hook so set('value', value) works.
    • description
      Sets the value of the widget.
      If the value has changed, then fire onChange event, unless priorityChange
      is specified as null (or false?)
  • dijit.form._FormValueWidget._handleOnChange

    • type
      Function
    • parameters:
      • newValue: (typeof anything)
      • priorityChange: (typeof Boolean)
    • source: [view]
        this._set("value", newValue);
        this.inherited(arguments);
    • summary
      Called when the value of the widget has changed.  Saves the new value in this.value,
      and calls onChange() if appropriate.   See _FormWidget._handleOnChange() for details.
  • dijit.form._FormValueWidget.undo

    • type
      Function
    • source: [view]
        this._setValueAttr(this._lastValueReported, false);
    • summary
      Restore the value to the last value passed to onChange
  • dijit.form._FormValueWidget.reset

    • type
      Function
    • source: [view]
        this._hasBeenBlurred = false;
        this._setValueAttr(this._resetValue, true);
    • summary
      Reset the widget's value to what it was at initialization time
  • dijit.form._FormValueWidget._onKeyDown

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
        if(e.keyCode == dojo.keys.ESCAPE && !(e.ctrlKey || e.altKey || e.metaKey)){
         var te;
         if(dojo.isIE){
          e.preventDefault(); // default behavior needs to be stopped here since keypress is too late
          te = document.createEventObject();
          te.keyCode = dojo.keys.ESCAPE;
          te.shiftKey = e.shiftKey;
          e.srcElement.fireEvent('onkeypress', te);
         }
        }
    • summary
  • dijit.form._FormValueWidget._layoutHackIE7

    • type
      Function
    • source: [view]
        if(dojo.isIE == 7){ // fix IE7 layout bug when the widget is scrolled out of sight
         var domNode = this.domNode;
         var parent = domNode.parentNode;
         var pingNode = domNode.firstChild || domNode; // target node most unlikely to have a custom filter
         var origFilter = pingNode.style.filter; // save custom filter, most likely nothing
         var _this = this;
         while(parent && parent.clientHeight == 0){ // search for parents that haven't rendered yet
          (function ping(){
           var disconnectHandle = _this.connect(parent, "onscroll",
            function(e){
             _this.disconnect(disconnectHandle); // only call once
             pingNode.style.filter = (new Date()).getMilliseconds(); // set to anything that's unique
             setTimeout(function(){ pingNode.style.filter = origFilter }, 0); // restore custom filter, if any
            }
           );
          })();
          parent = parent.parentNode;
         }
        }
    • summary
      Work around table sizing bugs on IE7 by forcing redraw
  • dijit.form._FormValueWidget._resetValue

    • summary
  • dijit.form._FormValueWidget._lastValueReported

    • summary
  • dijit.form._FormValueWidget._hasBeenBlurred

    • summary
  • dijit.form

    • type
      Object
    • summary
  • dijit

    • type
      Object
    • summary