]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/_PaletteMixin.js
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._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
){
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
++){
22 var _a
=dojo
.create("td",{"class":this.cellClass
,tabIndex
:"-1",title
:_2
[_8
]});
24 this.connect(_a
,"ondijitclick","_onCellClick");
25 this._trackMouseState(_a
,this.cellClass
);
27 _a
.index
=this._cells
.length
;
28 this._cells
.push({node
:_a
,dye
:_9
});
32 this._xDim
=_1
[0].length
;
34 var _b
={UP_ARROW
:-this._xDim
,DOWN_ARROW
:this._xDim
,RIGHT_ARROW
:this.isLeftToRight()?1:-1,LEFT_ARROW
:this.isLeftToRight()?-1:1};
36 this._connects
.push(dijit
.typematic
.addKeyListener(this.domNode
,{charOrCode
:dojo
.keys
[_c
],ctrlKey
:false,altKey
:false,shiftKey
:false},this,function(){
39 this._navigateByKey(_d
,_e
);
41 }(),this.timeoutChangeRate
,this.defaultTimeout
));
43 },postCreate:function(){
44 this.inherited(arguments
);
45 this._setCurrent(this._cells
[0].node
);
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(){
53 this._setValueAttr(_11
,true);
55 dojo
.removeClass(_10
,"dijitPaletteCellHover");
57 },_setCurrent:function(_12
){
58 if("_currentFocus" in this){
59 dojo
.attr(this._currentFocus
,"tabIndex","-1");
61 this._currentFocus
=_12
;
63 dojo
.attr(_12
,"tabIndex",this.tabIndex
);
65 },_setValueAttr:function(_13
,_14
){
67 if(this._selectedCell
>=0){
68 dojo
.removeClass(this._cells
[this._selectedCell
].node
,"dijitPaletteCellSelected");
70 this._selectedCell
=-1;
72 for(var i
=0;i
<this._cells
.length
;i
++){
73 if(_13
==this._cells
[i
].dye
.getValue()){
76 dojo
.addClass(this._cells
[i
].node
,"dijitPaletteCellSelected");
77 if(_14
||_14
===undefined){
84 },onChange:function(_15
){
85 },_navigateByKey:function(_16
,_17
){
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);
95 },_getDye:function(_1a
){
96 return this._cells
[_1a
.index
].dye
;