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
8 if(!dojo._hasResource["dijit._CssStateMixin"]){
9 dojo._hasResource["dijit._CssStateMixin"]=true;
10 dojo.provide("dijit._CssStateMixin");
11 dojo.declare("dijit._CssStateMixin",[],{cssStateNodes:{},postCreate:function(){
12 this.inherited(arguments);
13 dojo.forEach(["onmouseenter","onmouseleave","onmousedown"],function(e){
14 this.connect(this.domNode,e,"_cssMouseEvent");
16 this.connect(this,"set",function(_1,_2){
17 if(arguments.length>=2&&{disabled:true,readOnly:true,checked:true,selected:true}[_1]){
18 this._setStateClass();
21 dojo.forEach(["_onFocus","_onBlur"],function(ap){
22 this.connect(this,ap,"_setStateClass");
24 for(var ap in this.cssStateNodes){
25 this._trackMouseState(this[ap],this.cssStateNodes[ap]);
27 this._setStateClass();
28 },_cssMouseEvent:function(_3){
34 this._active=this._mouseDown;
44 var _4=this.connect(dojo.body(),"onmouseup",function(){
46 this._mouseDown=false;
47 this._setStateClass();
52 this._setStateClass();
54 },_setStateClass:function(){
55 var _5=this.baseClass.split(" ");
57 _5=_5.concat(dojo.map(_5,function(c){
61 if(!this.isLeftToRight()){
91 var tn=this.stateNode||this.domNode,_8={};
92 dojo.forEach(tn.className.split(" "),function(c){
95 if("_stateClasses" in this){
96 dojo.forEach(this._stateClasses,function(c){
100 dojo.forEach(_5,function(c){
107 tn.className=_9.join(" ");
108 this._stateClasses=_5;
109 },_trackMouseState:function(_a,_b){
110 var _c=false,_d=false,_e=false;
111 var _f=this,cn=dojo.hitch(this,"connect",_a);
113 var _11=("disabled" in _f&&_f.disabled)||("readonly" in _f&&_f.readonly);
114 dojo.toggleClass(_a,_b+"Hover",_c&&!_d&&!_11);
115 dojo.toggleClass(_a,_b+"Active",_d&&!_11);
116 dojo.toggleClass(_a,_b+"Focused",_e&&!_11);
118 cn("onmouseenter",function(){
122 cn("onmouseleave",function(){
127 cn("onmousedown",function(){
131 cn("onmouseup",function(){
135 cn("onfocus",function(){
139 cn("onblur",function(){
143 this.connect(this,"set",function(_12,_13){
144 if(_12=="disabled"||_12=="readOnly"){