Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dijit / _PaletteMixin.js @ 12

History | View | Annotate | Download (2.86 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._PaletteMixin"]){
9
dojo._hasResource["dijit._PaletteMixin"]=true;
10
dojo.provide("dijit._PaletteMixin");
11
dojo.require("dijit._CssStateMixin");
12
dojo.declare("dijit._PaletteMixin",[dijit._CssStateMixin],{defaultTimeout:500,timeoutChangeRate:0.9,value:null,_selectedCell:-1,tabIndex:"0",cellClass:"dijitPaletteCell",dyeClass:"",_preparePalette:function(_1,_2){
13
this._cells=[];
14
var _3=this._blankGif;
15
var _4=dojo.getObject(this.dyeClass);
16
for(var _5=0;_5<_1.length;_5++){
17
var _6=dojo.create("tr",{tabIndex:"-1"},this.gridNode);
18
for(var _7=0;_7<_1[_5].length;_7++){
19
var _8=_1[_5][_7];
20
if(_8){
21
var _9=new _4(_8);
22
var _a=dojo.create("td",{"class":this.cellClass,tabIndex:"-1",title:_2[_8]});
23
_9.fillCell(_a,_3);
24
this.connect(_a,"ondijitclick","_onCellClick");
25
this._trackMouseState(_a,this.cellClass);
26
dojo.place(_a,_6);
27
_a.index=this._cells.length;
28
this._cells.push({node:_a,dye:_9});
29
}
30
}
31
}
32
this._xDim=_1[0].length;
33
this._yDim=_1.length;
34
var _b={UP_ARROW:-this._xDim,DOWN_ARROW:this._xDim,RIGHT_ARROW:this.isLeftToRight()?1:-1,LEFT_ARROW:this.isLeftToRight()?-1:1};
35
for(var _c in _b){
36
this._connects.push(dijit.typematic.addKeyListener(this.domNode,{charOrCode:dojo.keys[_c],ctrlKey:false,altKey:false,shiftKey:false},this,function(){
37
var _d=_b[_c];
38
return function(_e){
39
this._navigateByKey(_d,_e);
40
};
41
}(),this.timeoutChangeRate,this.defaultTimeout));
42
}
43
},postCreate:function(){
44
this.inherited(arguments);
45
this._setCurrent(this._cells[0].node);
46
},focus:function(){
47
dijit.focus(this._currentFocus);
48
},_onCellClick:function(_f){
49
var _10=_f.currentTarget,_11=this._getDye(_10).getValue();
50
this._setCurrent(_10);
51
setTimeout(dojo.hitch(this,function(){
52
dijit.focus(_10);
53
this._setValueAttr(_11,true);
54
}));
55
dojo.removeClass(_10,"dijitPaletteCellHover");
56
dojo.stopEvent(_f);
57
},_setCurrent:function(_12){
58
if("_currentFocus" in this){
59
dojo.attr(this._currentFocus,"tabIndex","-1");
60
}
61
this._currentFocus=_12;
62
if(_12){
63
dojo.attr(_12,"tabIndex",this.tabIndex);
64
}
65
},_setValueAttr:function(_13,_14){
66
this.value=null;
67
if(this._selectedCell>=0){
68
dojo.removeClass(this._cells[this._selectedCell].node,"dijitPaletteCellSelected");
69
}
70
this._selectedCell=-1;
71
if(_13){
72
for(var i=0;i<this._cells.length;i++){
73
if(_13==this._cells[i].dye.getValue()){
74
this._selectedCell=i;
75
this.value=_13;
76
dojo.addClass(this._cells[i].node,"dijitPaletteCellSelected");
77
if(_14||_14===undefined){
78
this.onChange(_13);
79
}
80
break;
81
}
82
}
83
}
84
},onChange:function(_15){
85
},_navigateByKey:function(_16,_17){
86
if(_17==-1){
87
return;
88
}
89
var _18=this._currentFocus.index+_16;
90
if(_18<this._cells.length&&_18>-1){
91
var _19=this._cells[_18].node;
92
this._setCurrent(_19);
93
setTimeout(dojo.hitch(dijit,"focus",_19),0);
94
}
95
},_getDye:function(_1a){
96
return this._cells[_1a.index].dye;
97
}});
98
}