Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / data / CssClassStore.js @ 12

History | View | Annotate | Download (2.42 KB)

1
/*
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["dojox.data.CssClassStore"]){
9
dojo._hasResource["dojox.data.CssClassStore"]=true;
10
dojo.provide("dojox.data.CssClassStore");
11
dojo.require("dojox.data.CssRuleStore");
12
dojo.declare("dojox.data.CssClassStore",dojox.data.CssRuleStore,{_labelAttribute:"class",_idAttribute:"class",_cName:"dojox.data.CssClassStore",getFeatures:function(){
13
return {"dojo.data.api.Read":true,"dojo.data.api.Identity":true};
14
},getAttributes:function(_1){
15
this._assertIsItem(_1);
16
return ["class","classSans"];
17
},getValue:function(_2,_3,_4){
18
var _5=this.getValues(_2,_3);
19
if(_5&&_5.length>0){
20
return _5[0];
21
}
22
return _4;
23
},getValues:function(_6,_7){
24
this._assertIsItem(_6);
25
this._assertIsAttribute(_7);
26
var _8=[];
27
if(_7==="class"){
28
_8=[_6.className];
29
}else{
30
if(_7==="classSans"){
31
_8=[_6.className.replace(/\./g,"")];
32
}
33
}
34
return _8;
35
},_handleRule:function(_9,_a,_b){
36
var _c={};
37
var s=_9["selectorText"].split(" ");
38
for(var j=0;j<s.length;j++){
39
var _d=s[j];
40
var _e=_d.indexOf(".");
41
if(_d&&_d.length>0&&_e!==-1){
42
var _f=_d.indexOf(",")||_d.indexOf("[");
43
_d=_d.substring(_e,((_f!==-1&&_f>_e)?_f:_d.length));
44
_c[_d]=true;
45
}
46
}
47
for(var key in _c){
48
if(!this._allItems[key]){
49
var _10={};
50
_10.className=key;
51
_10[this._storeRef]=this;
52
this._allItems[key]=_10;
53
}
54
}
55
},_handleReturn:function(){
56
var _11=[];
57
var _12={};
58
for(var i in this._allItems){
59
_12[i]=this._allItems[i];
60
}
61
var _13;
62
while(this._pending.length){
63
_13=this._pending.pop();
64
_13.request._items=_12;
65
_11.push(_13);
66
}
67
while(_11.length){
68
_13=_11.pop();
69
if(_13.fetch){
70
this._handleFetchReturn(_13.request);
71
}else{
72
this._handleFetchByIdentityReturn(_13.request);
73
}
74
}
75
},_handleFetchByIdentityReturn:function(_14){
76
var _15=_14._items;
77
var _16=_15[(dojo.isWebKit?_14.identity.toLowerCase():_14.identity)];
78
if(!this.isItem(_16)){
79
_16=null;
80
}
81
if(_14.onItem){
82
var _17=_14.scope||dojo.global;
83
_14.onItem.call(_17,_16);
84
}
85
},getIdentity:function(_18){
86
this._assertIsItem(_18);
87
return this.getValue(_18,this._idAttribute);
88
},getIdentityAttributes:function(_19){
89
this._assertIsItem(_19);
90
return [this._idAttribute];
91
},fetchItemByIdentity:function(_1a){
92
_1a=_1a||{};
93
if(!_1a.store){
94
_1a.store=this;
95
}
96
if(this._pending&&this._pending.length>0){
97
this._pending.push({request:_1a});
98
}else{
99
this._pending=[{request:_1a}];
100
this._fetch(_1a);
101
}
102
return _1a;
103
}});
104
}