]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/OpenAjax.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / OpenAjax.js
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(!window["OpenAjax"]){
9 OpenAjax=new function(){
10 var t=true;
11 var f=false;
12 var g=window;
13 var _1;
14 var _2="org.openajax.hub.";
15 var h={};
16 this.hub=h;
17 h.implementer="http://openajax.org";
18 h.implVersion="0.6";
19 h.specVersion="0.6";
20 h.implExtraData={};
21 var _1={};
22 h.libraries=_1;
23 h.registerLibrary=function(_3,_4,_5,_6){
24 _1[_3]={prefix:_3,namespaceURI:_4,version:_5,extraData:_6};
25 this.publish(_2+"registerLibrary",_1[_3]);
26 };
27 h.unregisterLibrary=function(_7){
28 this.publish(_2+"unregisterLibrary",_1[_7]);
29 delete _1[_7];
30 };
31 h._subscriptions={c:{},s:[]};
32 h._cleanup=[];
33 h._subIndex=0;
34 h._pubDepth=0;
35 h.subscribe=function(_8,_9,_a,_b,_c){
36 if(!_a){
37 _a=window;
38 }
39 var _d=_8+"."+this._subIndex;
40 var _e={scope:_a,cb:_9,fcb:_c,data:_b,sid:this._subIndex++,hdl:_d};
41 var _f=_8.split(".");
42 this._subscribe(this._subscriptions,_f,0,_e);
43 return _d;
44 };
45 h.publish=function(_10,_11){
46 var _12=_10.split(".");
47 this._pubDepth++;
48 this._publish(this._subscriptions,_12,0,_10,_11);
49 this._pubDepth--;
50 if((this._cleanup.length>0)&&(this._pubDepth==0)){
51 for(var i=0;i<this._cleanup.length;i++){
52 this.unsubscribe(this._cleanup[i].hdl);
53 }
54 delete (this._cleanup);
55 this._cleanup=[];
56 }
57 };
58 h.unsubscribe=function(sub){
59 var _13=sub.split(".");
60 var sid=_13.pop();
61 this._unsubscribe(this._subscriptions,_13,0,sid);
62 };
63 h._subscribe=function(_14,_15,_16,sub){
64 var _17=_15[_16];
65 if(_16==_15.length){
66 _14.s.push(sub);
67 }else{
68 if(typeof _14.c=="undefined"){
69 _14.c={};
70 }
71 if(typeof _14.c[_17]=="undefined"){
72 _14.c[_17]={c:{},s:[]};
73 this._subscribe(_14.c[_17],_15,_16+1,sub);
74 }else{
75 this._subscribe(_14.c[_17],_15,_16+1,sub);
76 }
77 }
78 };
79 h._publish=function(_18,_19,_1a,_1b,msg){
80 if(typeof _18!="undefined"){
81 var _1c;
82 if(_1a==_19.length){
83 _1c=_18;
84 }else{
85 this._publish(_18.c[_19[_1a]],_19,_1a+1,_1b,msg);
86 this._publish(_18.c["*"],_19,_1a+1,_1b,msg);
87 _1c=_18.c["**"];
88 }
89 if(typeof _1c!="undefined"){
90 var _1d=_1c.s;
91 var max=_1d.length;
92 for(var i=0;i<max;i++){
93 if(_1d[i].cb){
94 var sc=_1d[i].scope;
95 var cb=_1d[i].cb;
96 var fcb=_1d[i].fcb;
97 var d=_1d[i].data;
98 if(typeof cb=="string"){
99 cb=sc[cb];
100 }
101 if(typeof fcb=="string"){
102 fcb=sc[fcb];
103 }
104 if((!fcb)||(fcb.call(sc,_1b,msg,d))){
105 cb.call(sc,_1b,msg,d);
106 }
107 }
108 }
109 }
110 }
111 };
112 h._unsubscribe=function(_1e,_1f,_20,sid){
113 if(typeof _1e!="undefined"){
114 if(_20<_1f.length){
115 var _21=_1e.c[_1f[_20]];
116 this._unsubscribe(_21,_1f,_20+1,sid);
117 if(_21.s.length==0){
118 for(var x in _21.c){
119 return;
120 }
121 delete _1e.c[_1f[_20]];
122 }
123 return;
124 }else{
125 var _22=_1e.s;
126 var max=_22.length;
127 for(var i=0;i<max;i++){
128 if(sid==_22[i].sid){
129 if(this._pubDepth>0){
130 _22[i].cb=null;
131 this._cleanup.push(_22[i]);
132 }else{
133 _22.splice(i,1);
134 }
135 return;
136 }
137 }
138 }
139 }
140 };
141 h.reinit=function(){
142 for(var lib in OpenAjax.hub.libraries){
143 delete OpenAjax.hub.libraries[lib];
144 }
145 OpenAjax.hub.registerLibrary("OpenAjax","http://openajax.org/hub","0.6",{});
146 delete OpenAjax._subscriptions;
147 OpenAjax._subscriptions={c:{},s:[]};
148 delete OpenAjax._cleanup;
149 OpenAjax._cleanup=[];
150 OpenAjax._subIndex=0;
151 OpenAjax._pubDepth=0;
152 };
153 };
154 OpenAjax.hub.registerLibrary("OpenAjax","http://openajax.org/hub","0.6",{});
155 }