root / trunk / web / dojo / dijit / MenuItem.js @ 10
History | View | Annotate | Download (3.28 KB)
| 1 | 9 | andrej.cim | /*
|
|---|---|---|---|
| 2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
| 3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
| 4 | see: http://dojotoolkit.org/license for details
|
||
| 5 | */
|
||
| 6 | |||
| 7 | |||
| 8 | if(!dojo._hasResource["dijit.MenuItem"]){ |
||
| 9 | dojo._hasResource["dijit.MenuItem"]=true; |
||
| 10 | dojo.provide("dijit.MenuItem");
|
||
| 11 | dojo.require("dijit._Widget");
|
||
| 12 | dojo.require("dijit._Templated");
|
||
| 13 | dojo.require("dijit._Contained");
|
||
| 14 | dojo.require("dijit._CssStateMixin");
|
||
| 15 | dojo.declare("dijit.MenuItem",[dijit._Widget,dijit._Templated,dijit._Contained,dijit._CssStateMixin],{templateString:dojo.cache("dijit","templates/MenuItem.html","<tr class=\"dijitReset dijitMenuItem\" dojoAttachPoint=\"focusNode\" waiRole=\"menuitem\" tabIndex=\"-1\"\n\t\tdojoAttachEvent=\"onmouseenter:_onHover,onmouseleave:_onUnhover,ondijitclick:_onClick\">\n\t<td class=\"dijitReset dijitMenuItemIconCell\" waiRole=\"presentation\">\n\t\t<img src=\"${_blankGif}\" alt=\"\" class=\"dijitIcon dijitMenuItemIcon\" dojoAttachPoint=\"iconNode\"/>\n\t</td>\n\t<td class=\"dijitReset dijitMenuItemLabel\" colspan=\"2\" dojoAttachPoint=\"containerNode\"></td>\n\t<td class=\"dijitReset dijitMenuItemAccelKey\" style=\"display: none\" dojoAttachPoint=\"accelKeyNode\"></td>\n\t<td class=\"dijitReset dijitMenuArrowCell\" waiRole=\"presentation\">\n\t\t<div dojoAttachPoint=\"arrowWrapper\" style=\"visibility: hidden\">\n\t\t\t<img src=\"${_blankGif}\" alt=\"\" class=\"dijitMenuExpand\"/>\n\t\t\t<span class=\"dijitMenuExpandA11y\">+</span>\n\t\t</div>\n\t</td>\n</tr>\n"),attributeMap:dojo.delegate(dijit._Widget.prototype.attributeMap,{label:{node:"containerNode",type:"innerHTML"},iconClass:{node:"iconNode",type:"class"}}),baseClass:"dijitMenuItem",label:"",iconClass:"",accelKey:"",disabled:false,_fillContent:function(_1){ |
||
| 16 | if(_1&&!("label" in this.params)){ |
||
| 17 | this.set("label",_1.innerHTML); |
||
| 18 | } |
||
| 19 | },postCreate:function(){ |
||
| 20 | this.inherited(arguments); |
||
| 21 | dojo.setSelectable(this.domNode,false); |
||
| 22 | var _2=this.id+"_text"; |
||
| 23 | dojo.attr(this.containerNode,"id",_2); |
||
| 24 | if(this.accelKeyNode){ |
||
| 25 | dojo.attr(this.accelKeyNode,"id",this.id+"_accel"); |
||
| 26 | _2+=" "+this.id+"_accel"; |
||
| 27 | } |
||
| 28 | dijit.setWaiState(this.domNode,"labelledby",_2); |
||
| 29 | },_onHover:function(){ |
||
| 30 | this.getParent().onItemHover(this); |
||
| 31 | },_onUnhover:function(){ |
||
| 32 | this.getParent().onItemUnhover(this); |
||
| 33 | this._hovering=false; |
||
| 34 | this._setStateClass();
|
||
| 35 | },_onClick:function(_3){ |
||
| 36 | this.getParent().onItemClick(this,_3); |
||
| 37 | dojo.stopEvent(_3); |
||
| 38 | },onClick:function(_4){ |
||
| 39 | },focus:function(){ |
||
| 40 | try{
|
||
| 41 | if(dojo.isIE==8){ |
||
| 42 | this.containerNode.focus();
|
||
| 43 | } |
||
| 44 | dijit.focus(this.focusNode);
|
||
| 45 | } |
||
| 46 | catch(e){
|
||
| 47 | } |
||
| 48 | },_onFocus:function(){ |
||
| 49 | this._setSelected(true); |
||
| 50 | this.getParent()._onItemFocus(this); |
||
| 51 | this.inherited(arguments); |
||
| 52 | },_setSelected:function(_5){ |
||
| 53 | dojo.toggleClass(this.domNode,"dijitMenuItemSelected",_5); |
||
| 54 | },setLabel:function(_6){ |
||
| 55 | dojo.deprecated("dijit.MenuItem.setLabel() is deprecated. Use set('label', ...) instead.","","2.0"); |
||
| 56 | this.set("label",_6); |
||
| 57 | },setDisabled:function(_7){ |
||
| 58 | dojo.deprecated("dijit.Menu.setDisabled() is deprecated. Use set('disabled', bool) instead.","","2.0"); |
||
| 59 | this.set("disabled",_7); |
||
| 60 | },_setDisabledAttr:function(_8){ |
||
| 61 | this.disabled=_8;
|
||
| 62 | dijit.setWaiState(this.focusNode,"disabled",_8?"true":"false"); |
||
| 63 | },_setAccelKeyAttr:function(_9){ |
||
| 64 | this.accelKey=_9;
|
||
| 65 | this.accelKeyNode.style.display=_9?"":"none"; |
||
| 66 | this.accelKeyNode.innerHTML=_9;
|
||
| 67 | dojo.attr(this.containerNode,"colSpan",_9?"1":"2"); |
||
| 68 | }}); |
||
| 69 | } |