]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/behavior.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / behavior.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(!dojo._hasResource["dojo.behavior"]){
9 dojo._hasResource["dojo.behavior"]=true;
10 dojo.provide("dojo.behavior");
11 dojo.behavior=new function(){
12 function _1(_2,_3){
13 if(!_2[_3]){
14 _2[_3]=[];
15 }
16 return _2[_3];
17 };
18 var _4=0;
19 function _5(_6,_7,_8){
20 var _9={};
21 for(var x in _6){
22 if(typeof _9[x]=="undefined"){
23 if(!_8){
24 _7(_6[x],x);
25 }else{
26 _8.call(_7,_6[x],x);
27 }
28 }
29 }
30 };
31 this._behaviors={};
32 this.add=function(_a){
33 var _b={};
34 _5(_a,this,function(_c,_d){
35 var _e=_1(this._behaviors,_d);
36 if(typeof _e["id"]!="number"){
37 _e.id=_4++;
38 }
39 var _f=[];
40 _e.push(_f);
41 if((dojo.isString(_c))||(dojo.isFunction(_c))){
42 _c={found:_c};
43 }
44 _5(_c,function(_10,_11){
45 _1(_f,_11).push(_10);
46 });
47 });
48 };
49 var _12=function(_13,_14,_15){
50 if(dojo.isString(_14)){
51 if(_15=="found"){
52 dojo.publish(_14,[_13]);
53 }else{
54 dojo.connect(_13,_15,function(){
55 dojo.publish(_14,arguments);
56 });
57 }
58 }else{
59 if(dojo.isFunction(_14)){
60 if(_15=="found"){
61 _14(_13);
62 }else{
63 dojo.connect(_13,_15,_14);
64 }
65 }
66 }
67 };
68 this.apply=function(){
69 _5(this._behaviors,function(_16,id){
70 dojo.query(id).forEach(function(_17){
71 var _18=0;
72 var bid="_dj_behavior_"+_16.id;
73 if(typeof _17[bid]=="number"){
74 _18=_17[bid];
75 if(_18==(_16.length)){
76 return;
77 }
78 }
79 for(var x=_18,_19;_19=_16[x];x++){
80 _5(_19,function(_1a,_1b){
81 if(dojo.isArray(_1a)){
82 dojo.forEach(_1a,function(_1c){
83 _12(_17,_1c,_1b);
84 });
85 }
86 });
87 }
88 _17[bid]=_16.length;
89 });
90 });
91 };
92 };
93 dojo.addOnLoad(dojo.behavior,"apply");
94 }