dijit/MenuItem.js

  • Provides:

    • dijit.MenuItem
  • dijit.MenuItem

    • type
      Function
    • chains:
      • dijit._Widget: (prototype)
      • dijit._Widget: (call)
      • dijit._Templated: (call)
      • dijit._Contained: (call)
      • dijit._CssStateMixin: (call)
    • mixins:
      • dijit._Templated.prototype: (prototype)
      • dijit._Contained.prototype: (prototype)
      • dijit._CssStateMixin.prototype: (prototype)
    • summary
  • dijit.MenuItem.templateString

    • summary
  • dijit.MenuItem.attributeMap

    • summary
  • dijit.MenuItem.baseClass

    • summary
  • dijit.MenuItem.label

    • type
      String
    • summary
      Menu text
  • dijit.MenuItem.iconClass

    • type
      String
    • summary
      Class to apply to DOMNode to make it display an icon.
  • dijit.MenuItem.accelKey

    • type
      String
    • summary
      Text for the accelerator (shortcut) key combination.
      Note that although Menu can display accelerator keys there
      is no infrastructure to actually catch and execute these
      accelerators.
  • dijit.MenuItem.disabled

    • type
      Boolean
    • summary
      If true, the menu item is disabled.
      If false, the menu item is enabled.
  • dijit.MenuItem._fillContent

    • type
      Function
    • parameters:
      • source: (typeof DomNode)
    • source: [view]
      define("dijit/MenuItem", ["dojo", "dijit", "text!dijit/templates/MenuItem.html", "dijit/_Widget", "dijit/_Templated", "dijit/_Contained", "dijit/_CssStateMixin"], function(dojo, dijit) {


      dojo.declare("dijit.MenuItem",
        [dijit._Widget, dijit._Templated, dijit._Contained, dijit._CssStateMixin],
        {
        // summary:
        //  A line item in a Menu Widget


        // Make 3 columns
        // icon, label, and expand arrow (BiDi-dependent) indicating sub-menu
        templateString: dojo.cache("dijit", "templates/MenuItem.html"),


        attributeMap: dojo.delegate(dijit._Widget.prototype.attributeMap, {
         label: { node: "containerNode", type: "innerHTML" },
         iconClass: { node: "iconNode", type: "class" }
        }),


        baseClass: "dijitMenuItem",


        // label: String
        //  Menu text
        label: '',


        // iconClass: String
        //  Class to apply to DOMNode to make it display an icon.
        iconClass: "",


        // accelKey: String
        //  Text for the accelerator (shortcut) key combination.
        //  Note that although Menu can display accelerator keys there
        //  is no infrastructure to actually catch and execute these
        //  accelerators.
        accelKey: "",


        // disabled: Boolean
        //  If true, the menu item is disabled.
        //  If false, the menu item is enabled.
        disabled: false,


        _fillContent: function(/*DomNode*/ source){
         // If button label is specified as srcNodeRef.innerHTML rather than
         // this.params.label, handle it here.
         if(source && !("label" in this.params)){
          this.set('label', source.innerHTML);
         }
    • summary
  • dijit.MenuItem.buildRendering

    • type
      Function
    • source: [view]
         this.inherited(arguments);
         var label = this.id+"_text";
         dojo.attr(this.containerNode, "id", label);
         if(this.accelKeyNode){
          dojo.attr(this.accelKeyNode, "id", this.id + "_accel");
          label += " " + this.id + "_accel";
         }
         dijit.setWaiState(this.domNode, "labelledby", label);
         dojo.setSelectable(this.domNode, false);
    • summary
  • dijit.MenuItem._onHover

    • type
      Function
    • source: [view]
         this.getParent().onItemHover(this);
    • summary
      Handler when mouse is moved onto menu item
    • tags:
  • dijit.MenuItem._onUnhover

    • type
      Function
    • source: [view]
      define("dijit/MenuItem", ["dojo", "dijit", "text!dijit/templates/MenuItem.html", "dijit/_Widget", "dijit/_Templated", "dijit/_Contained", "dijit/_CssStateMixin"], function(dojo, dijit) {


      dojo.declare("dijit.MenuItem",
        [dijit._Widget, dijit._Templated, dijit._Contained, dijit._CssStateMixin],
        {
        // summary:
        //  A line item in a Menu Widget


        // Make 3 columns
        // icon, label, and expand arrow (BiDi-dependent) indicating sub-menu
        templateString: dojo.cache("dijit", "templates/MenuItem.html"),


        attributeMap: dojo.delegate(dijit._Widget.prototype.attributeMap, {
         label: { node: "containerNode", type: "innerHTML" },
         iconClass: { node: "iconNode", type: "class" }
        }),


        baseClass: "dijitMenuItem",


        // label: String
        //  Menu text
        label: '',


        // iconClass: String
        //  Class to apply to DOMNode to make it display an icon.
        iconClass: "",


        // accelKey: String
        //  Text for the accelerator (shortcut) key combination.
        //  Note that although Menu can display accelerator keys there
        //  is no infrastructure to actually catch and execute these
        //  accelerators.
        accelKey: "",


        // disabled: Boolean
        //  If true, the menu item is disabled.
        //  If false, the menu item is enabled.
        disabled: false,


        _fillContent: function(/*DomNode*/ source){
         // If button label is specified as srcNodeRef.innerHTML rather than
         // this.params.label, handle it here.
         if(source && !("label" in this.params)){
          this.set('label', source.innerHTML);
         }
        },


        buildRendering: function(){
         this.inherited(arguments);
         var label = this.id+"_text";
         dojo.attr(this.containerNode, "id", label);
         if(this.accelKeyNode){
          dojo.attr(this.accelKeyNode, "id", this.id + "_accel");
          label += " " + this.id + "_accel";
         }
         dijit.setWaiState(this.domNode, "labelledby", label);
         dojo.setSelectable(this.domNode, false);
        },


        _onHover: function(){
         // summary:
         //  Handler when mouse is moved onto menu item
         // tags:
         //  protected
         this.getParent().onItemHover(this);
        },


        _onUnhover: function(){
         // summary:
         //  Handler when mouse is moved off of menu item,
         //  possibly to a child menu, or maybe to a sibling
         //  menuitem or somewhere else entirely.
         // tags:
         //  protected


         // if we are unhovering the currently selected item
         // then unselect it
         this.getParent().onItemUnhover(this);


         // When menu is hidden (collapsed) due to clicking a MenuItem and having it execute,
         // FF and IE don't generate an onmouseout event for the MenuItem.
         // So, help out _CssStateMixin in this case.
         this._set("hovering", false);
    • summary
      Handler when mouse is moved off of menu item,
      possibly to a child menu, or maybe to a sibling
      menuitem or somewhere else entirely.
  • dijit.MenuItem._onClick

    • type
      Function
    • parameters:
      • evt: (typeof )
    • source: [view]
         this.getParent().onItemClick(this, evt);
         dojo.stopEvent(evt);
    • summary
      Internal handler for click events on MenuItem.
    • tags:
  • dijit.MenuItem.onClick

    • type
      Function
    • parameters:
      • evt: (typeof Event)
    • source: [view]
         // summary:
         //  User defined function to handle clicks
         // tags:
         //  callback
    • summary
      User defined function to handle clicks
    • tags:
  • dijit.MenuItem.focus

    • type
      Function
    • source: [view]
         try{
          if(dojo.isIE == 8){
           // needed for IE8 which won't scroll TR tags into view on focus yet calling scrollIntoView creates flicker (#10275)
           this.containerNode.focus();
          }
          dijit.focus(this.focusNode);
         }catch(e){
          // this throws on IE (at least) in some scenarios
         }
    • summary
      Focus on this MenuItem
  • dijit.MenuItem._onFocus

    • type
      Function
    • source: [view]
         this._setSelected(true);
         this.getParent()._onItemFocus(this);


         this.inherited(arguments);
    • summary
      This is called by the focus manager when focus
      goes to this MenuItem or a child menu.
    • tags:
  • dijit.MenuItem._setSelected

    • type
      Function
    • parameters:
      • selected: (typeof )
    • source: [view]
      define("dijit/MenuItem", ["dojo", "dijit", "text!dijit/templates/MenuItem.html", "dijit/_Widget", "dijit/_Templated", "dijit/_Contained", "dijit/_CssStateMixin"], function(dojo, dijit) {


      dojo.declare("dijit.MenuItem",
        [dijit._Widget, dijit._Templated, dijit._Contained, dijit._CssStateMixin],
        {
        // summary:
        //  A line item in a Menu Widget


        // Make 3 columns
        // icon, label, and expand arrow (BiDi-dependent) indicating sub-menu
        templateString: dojo.cache("dijit", "templates/MenuItem.html"),


        attributeMap: dojo.delegate(dijit._Widget.prototype.attributeMap, {
         label: { node: "containerNode", type: "innerHTML" },
         iconClass: { node: "iconNode", type: "class" }
        }),


        baseClass: "dijitMenuItem",


        // label: String
        //  Menu text
        label: '',


        // iconClass: String
        //  Class to apply to DOMNode to make it display an icon.
        iconClass: "",


        // accelKey: String
        //  Text for the accelerator (shortcut) key combination.
        //  Note that although Menu can display accelerator keys there
        //  is no infrastructure to actually catch and execute these
        //  accelerators.
        accelKey: "",


        // disabled: Boolean
        //  If true, the menu item is disabled.
        //  If false, the menu item is enabled.
        disabled: false,


        _fillContent: function(/*DomNode*/ source){
         // If button label is specified as srcNodeRef.innerHTML rather than
         // this.params.label, handle it here.
         if(source && !("label" in this.params)){
          this.set('label', source.innerHTML);
         }
        },


        buildRendering: function(){
         this.inherited(arguments);
         var label = this.id+"_text";
         dojo.attr(this.containerNode, "id", label);
         if(this.accelKeyNode){
          dojo.attr(this.accelKeyNode, "id", this.id + "_accel");
          label += " " + this.id + "_accel";
         }
         dijit.setWaiState(this.domNode, "labelledby", label);
         dojo.setSelectable(this.domNode, false);
        },


        _onHover: function(){
         // summary:
         //  Handler when mouse is moved onto menu item
         // tags:
         //  protected
         this.getParent().onItemHover(this);
        },


        _onUnhover: function(){
         // summary:
         //  Handler when mouse is moved off of menu item,
         //  possibly to a child menu, or maybe to a sibling
         //  menuitem or somewhere else entirely.
         // tags:
         //  protected


         // if we are unhovering the currently selected item
         // then unselect it
         this.getParent().onItemUnhover(this);


         // When menu is hidden (collapsed) due to clicking a MenuItem and having it execute,
         // FF and IE don't generate an onmouseout event for the MenuItem.
         // So, help out _CssStateMixin in this case.
         this._set("hovering", false);
        },


        _onClick: function(evt){
         // summary:
         //  Internal handler for click events on MenuItem.
         // tags:
         //  private
         this.getParent().onItemClick(this, evt);
         dojo.stopEvent(evt);
        },


        onClick: function(/*Event*/ evt){
         // summary:
         //  User defined function to handle clicks
         // tags:
         //  callback
        },


        focus: function(){
         // summary:
         //  Focus on this MenuItem
         try{
          if(dojo.isIE == 8){
           // needed for IE8 which won't scroll TR tags into view on focus yet calling scrollIntoView creates flicker (#10275)
           this.containerNode.focus();
          }
          dijit.focus(this.focusNode);
         }catch(e){
          // this throws on IE (at least) in some scenarios
         }
        },


        _onFocus: function(){
         // summary:
         //  This is called by the focus manager when focus
         //  goes to this MenuItem or a child menu.
         // tags:
         //  protected
         this._setSelected(true);
         this.getParent()._onItemFocus(this);


         this.inherited(arguments);
        },


        _setSelected: function(selected){
         // summary:
         //  Indicate that this node is the currently selected one
         // tags:
         //  private


         /***
          * TODO: remove this method and calls to it, when _onBlur() is working for MenuItem.
          * Currently _onBlur() gets called when focus is moved from the MenuItem to a child menu.
          * That's not supposed to happen, but the problem is:
          * In order to allow dijit.popup's getTopPopup() to work,a sub menu's popupParent
          * points to the parent Menu, bypassing the parent MenuItem... thus the
          * MenuItem is not in the chain of active widgets and gets a premature call to
          * _onBlur()
          */


         dojo.toggleClass(this.domNode, "dijitMenuItemSelected", selected);
    • summary
      Indicate that this node is the currently selected one
  • dijit.MenuItem.setLabel

    • type
      Function
    • parameters:
      • content: (typeof String)
    • source: [view]
         dojo.deprecated("dijit.MenuItem.setLabel() is deprecated. Use set('label', ...) instead.", "", "2.0");
         this.set("label", content);
    • summary
      Deprecated.   Use set('label', ...) instead.
    • tags:
  • dijit.MenuItem.setDisabled

    • type
      Function
    • parameters:
      • disabled: (typeof Boolean)
    • source: [view]
         dojo.deprecated("dijit.Menu.setDisabled() is deprecated. Use set('disabled', bool) instead.", "", "2.0");
         this.set('disabled', disabled);
    • summary
      Deprecated.   Use set('disabled', bool) instead.
    • tags:
  • dijit.MenuItem._setDisabledAttr

    • type
      Function
    • parameters:
      • value: (typeof Boolean)
    • source: [view]
         dijit.setWaiState(this.focusNode, 'disabled', value ? 'true' : 'false');
         this._set("disabled", value);
    • summary
      Hook for attr('disabled', ...) to work.
      Enable or disable this menu item.
  • dijit.MenuItem._setAccelKeyAttr

    • type
      Function
    • parameters:
      • value: (typeof String)
    • source: [view]
         this.accelKeyNode.style.display=value?"":"none";
         this.accelKeyNode.innerHTML=value;
         //have to use colSpan to make it work in IE
         dojo.attr(this.containerNode,'colSpan',value?"1":"2");

         
         this._set("accelKey", value);
    • summary
      Hook for attr('accelKey', ...) to work.
      Set accelKey on this menu item.
  • dijit.MenuItem.accelKeyNode.style.display

    • summary
  • dijit.MenuItem.accelKeyNode.innerHTML

    • summary
  • dijit

    • type
      Object
    • summary