3 MochiKit.MochiKit 1.4 : PACKED VERSION
5 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
6 diff against the source tree, not this file.
8 See <http://mochikit.com/> for documentation, downloads, license, etc.
10 (c) 2005 Bob Ippolito. All rights Reserved.
14 if(typeof (dojo
)!="undefined"){
15 dojo
.provide("MochiKit.Base");
17 if(typeof (MochiKit
)=="undefined"){
20 if(typeof (MochiKit
.Base
)=="undefined"){
23 if(typeof (MochiKit
.__export__
)=="undefined"){
24 MochiKit
.__export__
=(MochiKit
.__compat__
||(typeof (JSAN
)=="undefined"&&typeof (dojo
)=="undefined"));
26 MochiKit
.Base
.VERSION
="1.4";
27 MochiKit
.Base
.NAME
="MochiKit.Base";
28 MochiKit
.Base
.update
=function(_1
,_2
){
32 for(var i
=1;i
<arguments
.length
;i
++){
34 if(typeof (o
)!="undefined"&&o
!==null){
42 MochiKit
.Base
.update(MochiKit
.Base
,{__repr__
:function(){
43 return "["+this.NAME
+" "+this.VERSION
+"]";
44 },toString
:function(){
45 return this.__repr__();
46 },camelize
:function(_6
){
49 for(var i
=1;i
<_7
.length
;i
++){
50 cc
+=_7
[i
].charAt(0).toUpperCase()+_7
[i
].substring(1);
53 },counter
:function(n
){
54 if(arguments
.length
===0){
61 var me
=arguments
.callee
;
62 if(arguments
.length
==1){
66 },_flattenArray
:function(_d
,_e
){
67 for(var i
=0;i
<_e
.length
;i
++){
69 if(o
instanceof Array
){
70 arguments
.callee(_d
,o
);
76 },flattenArray
:function(lst
){
77 return MochiKit
.Base
._flattenArray([],lst
);
78 },flattenArguments
:function(lst
){
81 var _15
=m
.extend(null,arguments
);
84 if(o
&&typeof (o
)=="object"&&typeof (o
.length
)=="number"){
85 for(var i
=o
.length
-1;i
>=0;i
--){
93 },extend
:function(_18
,obj
,_1a
){
99 if(typeof (l
)!="number"){
100 if(typeof (MochiKit
.Iter
)!="undefined"){
101 obj
=MochiKit
.Iter
.list(obj
);
104 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
110 for(var i
=_1a
;i
<l
;i
++){
115 },updatetree
:function(_1d
,obj
){
119 for(var i
=1;i
<arguments
.length
;i
++){
121 if(typeof (o
)!="undefined"&&o
!==null){
124 if(typeof (_1d
[k
])=="object"&&typeof (v
)=="object"){
125 arguments
.callee(_1d
[k
],v
);
133 },setdefault
:function(_23
,obj
){
137 for(var i
=1;i
<arguments
.length
;i
++){
146 },keys
:function(obj
){
152 },values
:function(obj
){
158 },items
:function(obj
){
172 },_newNamedError
:function(_33
,_34
,_35
){
173 _35
.prototype=new MochiKit
.Base
.NamedError(_33
.NAME
+"."+_34
);
175 },operator
:{truth
:function(a
){
177 },lognot
:function(a
){
179 },identity
:function(a
){
201 },lshift
:function(a
,b
){
203 },rshift
:function(a
,b
){
205 },zrshift
:function(a
,b
){
224 return MochiKit
.Base
.compare(a
,b
)===0;
226 return MochiKit
.Base
.compare(a
,b
)!==0;
228 return MochiKit
.Base
.compare(a
,b
)==1;
230 return MochiKit
.Base
.compare(a
,b
)!=-1;
232 return MochiKit
.Base
.compare(a
,b
)==-1;
234 return MochiKit
.Base
.compare(a
,b
)!=1;
235 },logand
:function(a
,b
){
237 },logor
:function(a
,b
){
239 },contains
:function(a
,b
){
241 }},forwardCall
:function(_73
){
243 return this[_73
].apply(this,arguments
);
245 },itemgetter
:function(_74
){
246 return function(arg
){
249 },typeMatcher
:function(){
251 for(var i
=0;i
<arguments
.length
;i
++){
252 var typ
=arguments
[i
];
256 for(var i
=0;i
<arguments
.length
;i
++){
257 if(!(typeof (arguments
[i
]) in _76
)){
264 for(var i
=0;i
<arguments
.length
;i
++){
265 if(arguments
[i
]!==null){
270 },isUndefinedOrNull
:function(){
271 for(var i
=0;i
<arguments
.length
;i
++){
273 if(!(typeof (o
)=="undefined"||o
===null)){
278 },isEmpty
:function(obj
){
279 return !MochiKit
.Base
.isNotEmpty
.apply(this,arguments
);
280 },isNotEmpty
:function(obj
){
281 for(var i
=0;i
<arguments
.length
;i
++){
288 },isArrayLike
:function(){
289 for(var i
=0;i
<arguments
.length
;i
++){
292 if((typ
!="object"&&!(typ
=="function"&&typeof (o
.item
)=="function"))||o
===null||typeof (o
.length
)!="number"||o
.nodeType
===3){
297 },isDateLike
:function(){
298 for(var i
=0;i
<arguments
.length
;i
++){
300 if(typeof (o
)!="object"||o
===null||typeof (o
.getTime
)!="function"){
307 return MochiKit
.Base
.extend(null,arguments
,1);
310 for(var i
=1;i
<arguments
.length
;i
++){
311 _87
.push(fn(arguments
[i
]));
314 },map
:function(fn
,lst
){
316 var itr
=MochiKit
.Iter
;
317 var _8d
=m
.isArrayLike
;
318 if(arguments
.length
<=2){
326 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
330 return m
.extend(null,lst
);
333 for(var i
=0;i
<lst
.length
;i
++){
334 _8e
.push(fn(lst
[i
]));
342 for(i
=1;i
<arguments
.length
;i
++){
343 if(!_8d(arguments
[i
])){
345 return itr
.list(itr
.imap
.apply(null,arguments
));
347 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
350 var l
=arguments
[i
].length
;
351 if(_90
===null||_90
>l
){
358 for(var j
=1;j
<arguments
.length
;j
++){
359 _92
.push(arguments
[j
][i
]);
361 _8e
.push(fn
.apply(this,_92
));
365 },xfilter
:function(fn
){
368 fn
=MochiKit
.Base
.operator
.truth
;
370 for(var i
=1;i
<arguments
.length
;i
++){
377 },filter
:function(fn
,lst
,_9a
){
380 if(!m
.isArrayLike(lst
)){
382 lst
=MochiKit
.Iter
.list(lst
);
384 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
390 if(typeof (Array
.prototype.filter
)=="function"){
391 return Array
.prototype.filter
.call(lst
,fn
,_9a
);
393 if(typeof (_9a
)=="undefined"||_9a
===null){
394 for(var i
=0;i
<lst
.length
;i
++){
401 for(i
=0;i
<lst
.length
;i
++){
410 },_wrapDumbFunction
:function(_9f
){
412 switch(arguments
.length
){
416 return _9f(arguments
[0]);
418 return _9f(arguments
[0],arguments
[1]);
420 return _9f(arguments
[0],arguments
[1],arguments
[2]);
423 for(var i
=0;i
<arguments
.length
;i
++){
424 _a0
.push("arguments["+i
+"]");
426 return eval("(func("+_a0
.join(",")+"))");
428 },methodcaller
:function(_a2
){
429 var _a3
=MochiKit
.Base
.extend(null,arguments
,1);
430 if(typeof (_a2
)=="function"){
431 return function(obj
){
432 return _a2
.apply(obj
,_a3
);
435 return function(obj
){
436 return obj
[_a2
].apply(obj
,_a3
);
439 },method
:function(_a6
,_a7
){
441 return m
.bind
.apply(this,m
.extend([_a7
,_a6
],arguments
,2));
442 },compose
:function(f1
,f2
){
445 if(arguments
.length
===0){
446 throw new TypeError("compose() requires at least one argument");
448 for(var i
=0;i
<arguments
.length
;i
++){
450 if(typeof (fn
)!="function"){
451 throw new TypeError(m
.repr(fn
)+" is not a function");
457 for(var i
=_ab
.length
-1;i
>=0;i
--){
458 _af
=[_ab
[i
].apply(this,_af
)];
462 },bind
:function(_b1
,_b2
){
463 if(typeof (_b1
)=="string"){
467 var _b4
=_b1
.im_preargs
;
470 if(typeof (_b1
)=="function"&&typeof (_b1
.apply
)=="undefined"){
471 _b1
=m
._wrapDumbFunction(_b1
);
473 if(typeof (_b3
)!="function"){
476 if(typeof (_b2
)!="undefined"){
479 if(typeof (_b4
)=="undefined"){
484 m
.extend(_b4
,arguments
,2);
487 var me
=arguments
.callee
;
488 if(me
.im_preargs
.length
>0){
489 _b8
=m
.concat(me
.im_preargs
,_b8
);
495 return me
.im_func
.apply(_ba
,_b8
);
501 },bindMethods
:function(_bb
){
502 var _bc
=MochiKit
.Base
.bind
;
505 if(typeof (_be
)=="function"){
509 },registerComparator
:function(_bf
,_c0
,_c1
,_c2
){
510 MochiKit
.Base
.comparatorRegistry
.register(_bf
,_c0
,_c1
,_c2
);
511 },_primitives
:{"boolean":true,"string":true,"number":true},compare
:function(a
,b
){
515 var _c5
=(typeof (a
)=="undefined"||a
===null);
516 var _c6
=(typeof (b
)=="undefined"||b
===null);
529 var _c8
=m
._primitives
;
530 if(!(typeof (a
) in _c8
&&typeof (b
) in _c8
)){
532 return m
.comparatorRegistry
.match(a
,b
);
548 throw new TypeError(_c9(a
)+" and "+_c9(b
)+" can not be compared");
549 },compareDateLike
:function(a
,b
){
550 return MochiKit
.Base
.compare(a
.getTime(),b
.getTime());
551 },compareArrayLike
:function(a
,b
){
552 var _ce
=MochiKit
.Base
.compare
;
563 for(var i
=0;i
<_cf
;i
++){
564 var cmp
=_ce(a
[i
],b
[i
]);
570 },registerRepr
:function(_d3
,_d4
,_d5
,_d6
){
571 MochiKit
.Base
.reprRegistry
.register(_d3
,_d4
,_d5
,_d6
);
573 if(typeof (o
)=="undefined"){
581 if(typeof (o
.__repr__
)=="function"){
584 if(typeof (o
.repr
)=="function"&&o
.repr
!=arguments
.callee
){
588 return MochiKit
.Base
.reprRegistry
.match(o
);
591 if(typeof (o
.NAME
)=="string"&&(o
.toString
==Function
.prototype.toString
||o
.toString
==Object
.prototype.toString
)){
599 return "["+typeof (o
)+"]";
601 if(typeof (o
)=="function"){
602 o
=_d8
.replace(/^\s+/,"");
603 var idx
=o
.indexOf("{");
605 o
=o
.substr(0,idx
)+"{...}";
609 },reprArrayLike
:function(o
){
611 return "["+m
.map(m
.repr
,o
).join(", ")+"]";
612 },reprString
:function(o
){
613 return ("\""+o
.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r");
614 },reprNumber
:function(o
){
616 },registerJSON
:function(_de
,_df
,_e0
,_e1
){
617 MochiKit
.Base
.jsonRegistry
.register(_de
,_df
,_e0
,_e1
);
618 },evalJSON
:function(){
619 return eval("("+arguments
[0]+")");
620 },serializeJSON
:function(o
){
622 if(_e3
=="number"||_e3
=="boolean"){
630 var _e5
=m
.reprString
;
634 var me
=arguments
.callee
;
636 if(typeof (o
.__json__
)=="function"){
642 if(typeof (o
.json
)=="function"){
648 if(_e3
!="function"&&typeof (o
.length
)=="number"){
650 for(var i
=0;i
<o
.length
;i
++){
652 if(typeof (val
)!="string"){
657 return "["+res
.join(", ")+"]";
660 _e7
=m
.jsonRegistry
.match(o
);
670 if(_e3
=="undefined"){
671 throw new TypeError("undefined can not be serialized as JSON");
679 if(typeof (k
)=="number"){
682 if(typeof (k
)=="string"){
689 if(typeof (val
)!="string"){
692 res
.push(_ec
+":"+val
);
694 return "{"+res
.join(", ")+"}";
695 },objEqual
:function(a
,b
){
696 return (MochiKit
.Base
.compare(a
,b
)===0);
697 },arrayEqual
:function(_ef
,arr
){
698 if(_ef
.length
!=arr
.length
){
701 return (MochiKit
.Base
.compare(_ef
,arr
)===0);
704 var _f2
=MochiKit
.Base
.extend
;
705 for(var i
=0;i
<arguments
.length
;i
++){
706 _f2(_f1
,arguments
[i
]);
709 },keyComparator
:function(key
){
712 if(arguments
.length
==1){
713 return function(a
,b
){
714 return _f6(a
[key
],b
[key
]);
717 var _f9
=m
.extend(null,arguments
);
718 return function(a
,b
){
720 for(var i
=0;(_fc
===0)&&(i
<_f9
.length
);i
++){
722 _fc
=_f6(a
[key
],b
[key
]);
726 },reverseKeyComparator
:function(key
){
727 var _100
=MochiKit
.Base
.keyComparator
.apply(this,arguments
);
728 return function(a
,b
){
731 },partial
:function(func
){
733 return m
.bind
.apply(this,m
.extend([func
,undefined
],arguments
,1));
734 },listMinMax
:function(_105
,lst
){
739 var _108
=MochiKit
.Base
.compare
;
740 for(var i
=1;i
<lst
.length
;i
++){
742 if(_108(o
,cur
)==_105
){
748 return MochiKit
.Base
.listMinMax(1,arguments
);
750 return MochiKit
.Base
.listMinMax(-1,arguments
);
751 },findIdentical
:function(lst
,_10c
,_10d
,end
){
752 if(typeof (end
)=="undefined"||end
===null){
755 if(typeof (_10d
)=="undefined"||_10d
===null){
758 for(var i
=_10d
;i
<end
;i
++){
767 var args
=m
.extend(null,arguments
);
768 var _113
=args
.length
;
771 if(o
&&typeof (o
)=="object"&&typeof (o
.length
)=="number"){
773 for(var i
=o
.length
-1;i
>=0;i
--){
781 throw new TypeError("mean() requires at least one argument");
785 var data
=MochiKit
.Base
.flattenArguments(arguments
);
787 throw new TypeError("median() requires at least one argument");
790 if(data
.length
%2==0){
791 var _117
=data
.length
/2;
792 return (data
[_117
]+data
[_117
-1])/2;
794 return data
[(data
.length
-1)/2];
796 },findValue
:function(lst
,_119
,_11a
,end
){
797 if(typeof (end
)=="undefined"||end
===null){
800 if(typeof (_11a
)=="undefined"||_11a
===null){
803 var cmp
=MochiKit
.Base
.compare
;
804 for(var i
=_11a
;i
<end
;i
++){
805 if(cmp(lst
[i
],_119
)===0){
810 },nodeWalk
:function(node
,_11f
){
812 var _121
=MochiKit
.Base
.extend
;
814 var res
=_11f(_120
.shift());
819 },nameFunctions
:function(_123
){
821 if(typeof (base
)=="undefined"){
826 for(var name
in _123
){
828 if(typeof (o
)=="function"&&typeof (o
.NAME
)=="undefined"){
836 },queryString
:function(_127
,_128
){
837 if(typeof (MochiKit
.DOM
)!="undefined"&&arguments
.length
==1&&(typeof (_127
)=="string"||(typeof (_127
.nodeType
)!="undefined"&&_127
.nodeType
>0))){
838 var kv
=MochiKit
.DOM
.formContents(_127
);
842 if(arguments
.length
==1){
843 if(typeof (_127
.length
)=="number"&&_127
.length
==2){
844 return arguments
.callee(_127
[0],_127
[1]);
851 if(typeof (v
)=="function"){
854 if(typeof (v
)!="string"&&typeof (v
.length
)=="number"){
855 for(var i
=0;i
<v
.length
;i
++){
868 var len
=Math
.min(_127
.length
,_128
.length
);
869 var _130
=MochiKit
.Base
.urlEncode
;
870 for(var i
=0;i
<len
;i
++){
872 if(typeof (v
)!="undefined"&&v
!==null){
873 rval
.push(_130(_127
[i
])+"="+_130(v
));
876 return rval
.join("&");
877 },parseQueryString
:function(_131
,_132
){
878 var qstr
=(_131
.charAt(0)=="?")?_131
.substring(1):_131
;
879 var _134
=qstr
.replace(/\+/g,"%20").split(/(\&\;|\&\#38\;|\&|\&)/);
882 if(typeof (decodeURIComponent
)!="undefined"){
883 _136
=decodeURIComponent
;
888 for(var i
=0;i
<_134
.length
;i
++){
889 var pair
=_134
[i
].split("=");
890 var name
=_136(pair
.shift());
895 if(!(arr
instanceof Array
)){
899 arr
.push(_136(pair
.join("=")));
902 for(i
=0;i
<_134
.length
;i
++){
903 pair
=_134
[i
].split("=");
904 var name
=pair
.shift();
908 o
[_136(name
)]=_136(pair
.join("="));
913 MochiKit
.Base
.AdapterRegistry
=function(){
916 MochiKit
.Base
.AdapterRegistry
.prototype={register
:function(name
,_13c
,wrap
,_13e
){
918 this.pairs
.unshift([name
,_13c
,wrap
]);
920 this.pairs
.push([name
,_13c
,wrap
]);
923 for(var i
=0;i
<this.pairs
.length
;i
++){
924 var pair
=this.pairs
[i
];
925 if(pair
[1].apply(this,arguments
)){
926 return pair
[2].apply(this,arguments
);
929 throw MochiKit
.Base
.NotFound
;
930 },unregister
:function(name
){
931 for(var i
=0;i
<this.pairs
.length
;i
++){
932 var pair
=this.pairs
[i
];
934 this.pairs
.splice(i
,1);
940 MochiKit
.Base
.EXPORT
=["flattenArray","noop","camelize","counter","clone","extend","update","updatetree","setdefault","keys","values","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isEmpty","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","methodcaller","compose","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","findValue","findIdentical","flattenArguments","method","average","mean","median"];
941 MochiKit
.Base
.EXPORT_OK
=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"];
942 MochiKit
.Base
._exportSymbols
=function(_144
,_145
){
943 if(!MochiKit
.__export__
){
946 var all
=_145
.EXPORT_TAGS
[":all"];
947 for(var i
=0;i
<all
.length
;i
++){
948 _144
[all
[i
]]=_145
[all
[i
]];
951 MochiKit
.Base
.__new__
=function(){
953 m
.noop
=m
.operator
.identity
;
954 m
.forward
=m
.forwardCall
;
956 if(typeof (encodeURIComponent
)!="undefined"){
957 m
.urlEncode
=function(_149
){
958 return encodeURIComponent(_149
).replace(/\'/g,"%27");
961 m
.urlEncode
=function(_14a
){
962 return escape(_14a
).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval
.replace(/\'/g,"%27");
965 m
.NamedError
=function(name
){
969 m
.NamedError
.prototype=new Error();
970 m
.update(m
.NamedError
.prototype,{repr
:function(){
971 if(this.message
&&this.message
!=this.name
){
972 return this.name
+"("+m
.repr(this.message
)+")";
974 return this.name
+"()";
976 },toString
:m
.forwardCall("repr")});
977 m
.NotFound
=new m
.NamedError("MochiKit.Base.NotFound");
978 m
.listMax
=m
.partial(m
.listMinMax
,1);
979 m
.listMin
=m
.partial(m
.listMinMax
,-1);
980 m
.isCallable
=m
.typeMatcher("function");
981 m
.isUndefined
=m
.typeMatcher("undefined");
982 m
.merge
=m
.partial(m
.update
,null);
983 m
.zip
=m
.partial(m
.map
,null);
985 m
.comparatorRegistry
=new m
.AdapterRegistry();
986 m
.registerComparator("dateLike",m
.isDateLike
,m
.compareDateLike
);
987 m
.registerComparator("arrayLike",m
.isArrayLike
,m
.compareArrayLike
);
988 m
.reprRegistry
=new m
.AdapterRegistry();
989 m
.registerRepr("arrayLike",m
.isArrayLike
,m
.reprArrayLike
);
990 m
.registerRepr("string",m
.typeMatcher("string"),m
.reprString
);
991 m
.registerRepr("numbers",m
.typeMatcher("number","boolean"),m
.reprNumber
);
992 m
.jsonRegistry
=new m
.AdapterRegistry();
993 var all
=m
.concat(m
.EXPORT
,m
.EXPORT_OK
);
994 m
.EXPORT_TAGS
={":common":m
.concat(m
.EXPORT_OK
),":all":all
};
995 m
.nameFunctions(this);
997 MochiKit
.Base
.__new__();
998 if(MochiKit
.__export__
){
999 compare
=MochiKit
.Base
.compare
;
1000 compose
=MochiKit
.Base
.compose
;
1001 serializeJSON
=MochiKit
.Base
.serializeJSON
;
1003 MochiKit
.Base
._exportSymbols(this,MochiKit
.Base
);
1004 if(typeof (dojo
)!="undefined"){
1005 dojo
.provide("MochiKit.Iter");
1006 dojo
.require("MochiKit.Base");
1008 if(typeof (JSAN
)!="undefined"){
1009 JSAN
.use("MochiKit.Base",[]);
1012 if(typeof (MochiKit
.Base
)=="undefined"){
1017 throw "MochiKit.Iter depends on MochiKit.Base!";
1019 if(typeof (MochiKit
.Iter
)=="undefined"){
1022 MochiKit
.Iter
.NAME
="MochiKit.Iter";
1023 MochiKit
.Iter
.VERSION
="1.4";
1024 MochiKit
.Base
.update(MochiKit
.Iter
,{__repr__
:function(){
1025 return "["+this.NAME
+" "+this.VERSION
+"]";
1026 },toString
:function(){
1027 return this.__repr__();
1028 },registerIteratorFactory
:function(name
,_14e
,_14f
,_150
){
1029 MochiKit
.Iter
.iteratorRegistry
.register(name
,_14e
,_14f
,_150
);
1030 },iter
:function(_151
,_152
){
1031 var self
=MochiKit
.Iter
;
1032 if(arguments
.length
==2){
1033 return self
.takewhile(function(a
){
1037 if(typeof (_151
.next
)=="function"){
1040 if(typeof (_151
.iter
)=="function"){
1045 return self
.iteratorRegistry
.match(_151
);
1048 var m
=MochiKit
.Base
;
1050 e
=new TypeError(typeof (_151
)+": "+m
.repr(_151
)+" is not iterable");
1054 },count
:function(n
){
1058 var m
=MochiKit
.Base
;
1059 return {repr
:function(){
1060 return "count("+n
+")";
1061 },toString
:m
.forwardCall("repr"),next
:m
.counter(n
)};
1062 },cycle
:function(p
){
1063 var self
=MochiKit
.Iter
;
1064 var m
=MochiKit
.Base
;
1066 var _15c
=self
.iter(p
);
1067 return {repr
:function(){
1068 return "cycle(...)";
1069 },toString
:m
.forwardCall("repr"),next
:function(){
1071 var rval
=_15c
.next();
1076 if(e
!=self
.StopIteration
){
1080 this.next
=function(){
1081 throw self
.StopIteration
;
1085 this.next
=function(){
1093 },repeat
:function(elem
,n
){
1094 var m
=MochiKit
.Base
;
1095 if(typeof (n
)=="undefined"){
1096 return {repr
:function(){
1097 return "repeat("+m
.repr(elem
)+")";
1098 },toString
:m
.forwardCall("repr"),next
:function(){
1102 return {repr
:function(){
1103 return "repeat("+m
.repr(elem
)+", "+n
+")";
1104 },toString
:m
.forwardCall("repr"),next
:function(){
1106 throw MochiKit
.Iter
.StopIteration
;
1111 },next
:function(_162
){
1113 },izip
:function(p
,q
){
1114 var m
=MochiKit
.Base
;
1115 var self
=MochiKit
.Iter
;
1117 var _168
=m
.map(self
.iter
,arguments
);
1118 return {repr
:function(){
1120 },toString
:m
.forwardCall("repr"),next
:function(){
1121 return m
.map(next
,_168
);
1123 },ifilter
:function(pred
,seq
){
1124 var m
=MochiKit
.Base
;
1125 seq
=MochiKit
.Iter
.iter(seq
);
1127 pred
=m
.operator
.truth
;
1129 return {repr
:function(){
1130 return "ifilter(...)";
1131 },toString
:m
.forwardCall("repr"),next
:function(){
1133 var rval
=seq
.next();
1140 },ifilterfalse
:function(pred
,seq
){
1141 var m
=MochiKit
.Base
;
1142 seq
=MochiKit
.Iter
.iter(seq
);
1144 pred
=m
.operator
.truth
;
1146 return {repr
:function(){
1147 return "ifilterfalse(...)";
1148 },toString
:m
.forwardCall("repr"),next
:function(){
1150 var rval
=seq
.next();
1157 },islice
:function(seq
){
1158 var self
=MochiKit
.Iter
;
1159 var m
=MochiKit
.Base
;
1165 if(arguments
.length
==2){
1168 if(arguments
.length
==3){
1177 return {repr
:function(){
1178 return "islice("+["...",_174
,stop
,step
].join(", ")+")";
1179 },toString
:m
.forwardCall("repr"),next
:function(){
1186 throw self
.StopIteration
;
1191 },imap
:function(fun
,p
,q
){
1192 var m
=MochiKit
.Base
;
1193 var self
=MochiKit
.Iter
;
1194 var _17e
=m
.map(self
.iter
,m
.extend(null,arguments
,1));
1197 return {repr
:function(){
1199 },toString
:m
.forwardCall("repr"),next
:function(){
1200 return fun
.apply(this,map(next
,_17e
));
1202 },applymap
:function(fun
,seq
,self
){
1203 seq
=MochiKit
.Iter
.iter(seq
);
1204 var m
=MochiKit
.Base
;
1205 return {repr
:function(){
1206 return "applymap(...)";
1207 },toString
:m
.forwardCall("repr"),next
:function(){
1208 return fun
.apply(self
,seq
.next());
1210 },chain
:function(p
,q
){
1211 var self
=MochiKit
.Iter
;
1212 var m
=MochiKit
.Base
;
1213 if(arguments
.length
==1){
1214 return self
.iter(arguments
[0]);
1216 var _189
=m
.map(self
.iter
,arguments
);
1217 return {repr
:function(){
1218 return "chain(...)";
1219 },toString
:m
.forwardCall("repr"),next
:function(){
1220 while(_189
.length
>1){
1222 return _189
[0].next();
1225 if(e
!=self
.StopIteration
){
1232 var arg
=_189
.shift();
1233 this.next
=m
.bind("next",arg
);
1236 throw self
.StopIteration
;
1238 },takewhile
:function(pred
,seq
){
1239 var self
=MochiKit
.Iter
;
1241 return {repr
:function(){
1242 return "takewhile(...)";
1243 },toString
:MochiKit
.Base
.forwardCall("repr"),next
:function(){
1244 var rval
=seq
.next();
1246 this.next
=function(){
1247 throw self
.StopIteration
;
1253 },dropwhile
:function(pred
,seq
){
1254 seq
=MochiKit
.Iter
.iter(seq
);
1255 var m
=MochiKit
.Base
;
1257 return {"repr":function(){
1258 return "dropwhile(...)";
1259 },"toString":m
.forwardCall("repr"),"next":function(){
1261 var rval
=seq
.next();
1266 this.next
=bind("next",seq
);
1269 },_tee
:function(_194
,sync
,_196
){
1271 var m
=MochiKit
.Base
;
1273 return {repr
:function(){
1274 return "tee("+_194
+", ...)";
1275 },toString
:m
.forwardCall("repr"),next
:function(){
1277 var i
=sync
.pos
[_194
];
1280 sync
.deque
.push(rval
);
1284 rval
=sync
.deque
[i
-sync
.min
];
1286 if(i
==sync
.min
&&_198(sync
.pos
)!=sync
.min
){
1293 },tee
:function(_19b
,n
){
1295 var sync
={"pos":[],"deque":[],"max":-1,"min":-1};
1296 if(arguments
.length
==1||typeof (n
)=="undefined"||n
===null){
1299 var self
=MochiKit
.Iter
;
1300 _19b
=self
.iter(_19b
);
1302 for(var i
=0;i
<n
;i
++){
1303 rval
.push(_tee(i
,sync
,_19b
));
1306 },list
:function(_1a2
){
1308 if(_1a2
instanceof Array
){
1309 return _1a2
.slice();
1311 if(typeof (_1a2
)=="function"&&!(_1a2
instanceof Function
)&&typeof (_1a2
.length
)=="number"){
1313 for(var i
=0;i
<_1a2
.length
;i
++){
1318 var self
=MochiKit
.Iter
;
1319 _1a2
=self
.iter(_1a2
);
1323 rval
.push(_1a2
.next());
1327 if(e
!=self
.StopIteration
){
1333 },reduce
:function(fn
,_1a7
,_1a8
){
1336 var self
=MochiKit
.Iter
;
1337 _1a7
=self
.iter(_1a7
);
1338 if(arguments
.length
<3){
1343 if(e
==self
.StopIteration
){
1344 e
=new TypeError("reduce() of empty sequence with no initial value");
1352 x
=fn(x
,_1a7
.next());
1356 if(e
!=self
.StopIteration
){
1365 if(arguments
.length
==1){
1368 if(arguments
.length
==2){
1372 if(arguments
.length
==3){
1377 throw new TypeError("range() takes 1, 2, or 3 arguments!");
1382 throw new TypeError("range() step must not be 0");
1384 return {next
:function(){
1385 if((step
>0&&_1ac
>=stop
)||(step
<0&&_1ac
<=stop
)){
1386 throw MochiKit
.Iter
.StopIteration
;
1392 return "range("+[_1ac
,stop
,step
].join(", ")+")";
1393 },toString
:MochiKit
.Base
.forwardCall("repr")};
1394 },sum
:function(_1b0
,_1b1
){
1395 if(typeof (_1b1
)=="undefined"||_1b1
===null){
1399 var self
=MochiKit
.Iter
;
1400 _1b0
=self
.iter(_1b0
);
1407 if(e
!=self
.StopIteration
){
1412 },exhaust
:function(_1b4
){
1413 var self
=MochiKit
.Iter
;
1414 _1b4
=self
.iter(_1b4
);
1421 if(e
!=self
.StopIteration
){
1425 },forEach
:function(_1b6
,func
,self
){
1426 var m
=MochiKit
.Base
;
1427 if(arguments
.length
>2){
1428 func
=m
.bind(func
,self
);
1430 if(m
.isArrayLike(_1b6
)){
1432 for(var i
=0;i
<_1b6
.length
;i
++){
1437 if(e
!=MochiKit
.Iter
.StopIteration
){
1443 self
.exhaust(self
.imap(func
,_1b6
));
1445 },every
:function(_1bb
,func
){
1446 var self
=MochiKit
.Iter
;
1448 self
.ifilterfalse(func
,_1bb
).next();
1452 if(e
!=self
.StopIteration
){
1457 },sorted
:function(_1be
,cmp
){
1458 var rval
=MochiKit
.Iter
.list(_1be
);
1459 if(arguments
.length
==1){
1460 cmp
=MochiKit
.Base
.compare
;
1464 },reversed
:function(_1c1
){
1465 var rval
=MochiKit
.Iter
.list(_1c1
);
1468 },some
:function(_1c3
,func
){
1469 var self
=MochiKit
.Iter
;
1471 self
.ifilter(func
,_1c3
).next();
1475 if(e
!=self
.StopIteration
){
1480 },iextend
:function(lst
,_1c7
){
1481 if(MochiKit
.Base
.isArrayLike(_1c7
)){
1482 for(var i
=0;i
<_1c7
.length
;i
++){
1486 var self
=MochiKit
.Iter
;
1487 _1c7
=self
.iter(_1c7
);
1490 lst
.push(_1c7
.next());
1494 if(e
!=self
.StopIteration
){
1500 },groupby
:function(_1ca
,_1cb
){
1501 var m
=MochiKit
.Base
;
1502 var self
=MochiKit
.Iter
;
1503 if(arguments
.length
<2){
1504 _1cb
=m
.operator
.identity
;
1506 _1ca
=self
.iter(_1ca
);
1521 return {repr
:function(){
1522 return "groupby(...)";
1524 while(_1d3(k
,pk
)===0){
1532 return [k
,{next
:function(){
1537 throw self
.StopIteration
;
1542 },groupby_as_array
:function(_1d4
,_1d5
){
1543 var m
=MochiKit
.Base
;
1544 var self
=MochiKit
.Iter
;
1545 if(arguments
.length
<2){
1546 _1d5
=m
.operator
.identity
;
1548 _1d4
=self
.iter(_1d4
);
1555 var _1dc
=_1d4
.next();
1559 if(e
==self
.StopIteration
){
1564 if(_1d9
||_1db(key
,_1da
)!==0){
1566 _1d8
.push([key
,_1de
]);
1573 },arrayLikeIter
:function(_1df
){
1575 return {repr
:function(){
1576 return "arrayLikeIter(...)";
1577 },toString
:MochiKit
.Base
.forwardCall("repr"),next
:function(){
1579 throw MochiKit
.Iter
.StopIteration
;
1583 },hasIterateNext
:function(_1e1
){
1584 return (_1e1
&&typeof (_1e1
.iterateNext
)=="function");
1585 },iterateNextIter
:function(_1e2
){
1586 return {repr
:function(){
1587 return "iterateNextIter(...)";
1588 },toString
:MochiKit
.Base
.forwardCall("repr"),next
:function(){
1589 var rval
=_1e2
.iterateNext();
1590 if(rval
===null||rval
===undefined
){
1591 throw MochiKit
.Iter
.StopIteration
;
1596 MochiKit
.Iter
.EXPORT_OK
=["iteratorRegistry","arrayLikeIter","hasIterateNext","iterateNextIter",];
1597 MochiKit
.Iter
.EXPORT
=["StopIteration","registerIteratorFactory","iter","count","cycle","repeat","next","izip","ifilter","ifilterfalse","islice","imap","applymap","chain","takewhile","dropwhile","tee","list","reduce","range","sum","exhaust","forEach","every","sorted","reversed","some","iextend","groupby","groupby_as_array"];
1598 MochiKit
.Iter
.__new__
=function(){
1599 var m
=MochiKit
.Base
;
1600 if(typeof (StopIteration
)!="undefined"){
1601 this.StopIteration
=StopIteration
;
1603 this.StopIteration
=new m
.NamedError("StopIteration");
1605 this.iteratorRegistry
=new m
.AdapterRegistry();
1606 this.registerIteratorFactory("arrayLike",m
.isArrayLike
,this.arrayLikeIter
);
1607 this.registerIteratorFactory("iterateNext",this.hasIterateNext
,this.iterateNextIter
);
1608 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
1609 m
.nameFunctions(this);
1611 MochiKit
.Iter
.__new__();
1612 if(MochiKit
.__export__
){
1613 reduce
=MochiKit
.Iter
.reduce
;
1615 MochiKit
.Base
._exportSymbols(this,MochiKit
.Iter
);
1616 if(typeof (dojo
)!="undefined"){
1617 dojo
.provide("MochiKit.Format");
1619 if(typeof (MochiKit
)=="undefined"){
1622 if(typeof (MochiKit
.Format
)=="undefined"){
1625 MochiKit
.Format
.NAME
="MochiKit.Format";
1626 MochiKit
.Format
.VERSION
="1.4";
1627 MochiKit
.Format
.__repr__
=function(){
1628 return "["+this.NAME
+" "+this.VERSION
+"]";
1630 MochiKit
.Format
.toString
=function(){
1631 return this.__repr__();
1633 MochiKit
.Format
._numberFormatter
=function(_1e5
,_1e6
,_1e7
,_1e8
,_1e9
,_1ea
,_1eb
,_1ec
,_1ed
){
1634 return function(num
){
1635 num
=parseFloat(num
);
1636 if(typeof (num
)=="undefined"||num
===null||isNaN(num
)){
1644 _1ef
=_1ef
.replace(/-/,"");
1646 var me
=arguments
.callee
;
1647 var fmt
=MochiKit
.Format
.formatLocale(_1e8
);
1650 _1f0
=fmt
.percent
+_1f0
;
1652 num
=MochiKit
.Format
.roundToFixed(num
,_1ea
);
1653 var _1f3
=num
.split(/\./);
1655 var frac
=(_1f3
.length
==1)?"":_1f3
[1];
1657 while(_1f4
.length
<_1eb
){
1661 while(_1f4
.length
>_1ec
){
1662 var i
=_1f4
.length
-_1ec
;
1663 res
=fmt
.separator
+_1f4
.substring(i
,_1f4
.length
)+res
;
1664 _1f4
=_1f4
.substring(0,i
);
1669 while(frac
.length
<_1ed
){
1672 res
=res
+fmt
.decimal+frac
;
1674 return _1ef
+res
+_1f0
;
1677 MochiKit
.Format
.numberFormatter
=function(_1f8
,_1f9
,_1fa
){
1678 if(typeof (_1f9
)=="undefined"){
1681 var _1fb
=_1f8
.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);
1683 throw TypeError("Invalid pattern");
1685 var _1fc
=_1f8
.substr(0,_1fb
.index
);
1686 var _1fd
=_1f8
.substr(_1fb
.index
+_1fb
[0].length
);
1687 if(_1fc
.search(/-/)==-1){
1691 var frac
=(typeof (_1fb
[2])=="string"&&_1fb
[2]!="")?_1fb
[2]:"";
1692 var _200
=(typeof (_1fb
[3])=="string"&&_1fb
[3]!="");
1693 var tmp
=_1fe
.split(/,/);
1695 if(typeof (_1fa
)=="undefined"){
1703 var _203
=_1fe
.length
-_1fe
.replace(/0/g,"").length
;
1704 var _204
=frac
.length
-frac
.replace(/0/g,"").length
;
1705 var _205
=frac
.length
;
1706 var rval
=MochiKit
.Format
._numberFormatter(_1f9
,_1fc
,_1fd
,_1fa
,_200
,_205
,_203
,_202
,_204
);
1707 var m
=MochiKit
.Base
;
1709 var fn
=arguments
.callee
;
1710 var args
=m
.concat(arguments
);
1711 rval
.repr
=function(){
1712 return [self
.NAME
,"(",map(m
.repr
,args
).join(", "),")"].join("");
1717 MochiKit
.Format
.formatLocale
=function(_20a
){
1718 if(typeof (_20a
)=="undefined"||_20a
===null){
1721 if(typeof (_20a
)=="string"){
1722 var rval
=MochiKit
.Format
.LOCALE
[_20a
];
1723 if(typeof (rval
)=="string"){
1724 rval
=arguments
.callee(rval
);
1725 MochiKit
.Format
.LOCALE
[_20a
]=rval
;
1732 MochiKit
.Format
.twoDigitAverage
=function(_20c
,_20d
){
1736 return MochiKit
.Format
.twoDigitFloat(_20c
/_20d
);
1741 MochiKit
.Format
.twoDigitFloat
=function(_20f
){
1742 var sign
=(_20f
<0?"-":"");
1743 var s
=Math
.floor(Math
.abs(_20f
)*100).toString();
1748 while(s
.charAt(s
.length
-1)=="0"){
1749 s
=s
.substring(0,s
.length
-1);
1753 var head
=sign
+s
.substring(0,s
.length
-2);
1754 var tail
=s
.substring(s
.length
-2,s
.length
);
1758 if(tail
.charAt(1)=="0"){
1759 return head
+"."+tail
.charAt(0);
1761 return head
+"."+tail
;
1765 MochiKit
.Format
.lstrip
=function(str
,_215
){
1767 if(typeof (str
)!="string"){
1771 return str
.replace(/^\s+/,"");
1773 return str
.replace(new RegExp("^["+_215
+"]+"),"");
1776 MochiKit
.Format
.rstrip
=function(str
,_217
){
1778 if(typeof (str
)!="string"){
1782 return str
.replace(/\s+$/,"");
1784 return str
.replace(new RegExp("["+_217
+"]+$"),"");
1787 MochiKit
.Format
.strip
=function(str
,_219
){
1788 var self
=MochiKit
.Format
;
1789 return self
.rstrip(self
.lstrip(str
,_219
),_219
);
1791 MochiKit
.Format
.truncToFixed
=function(_21b
,_21c
){
1792 _21b
=Math
.floor(_21b
*Math
.pow(10,_21c
));
1793 var res
=(_21b
*Math
.pow(10,-_21c
)).toFixed(_21c
);
1794 if(res
.charAt(0)=="."){
1799 MochiKit
.Format
.roundToFixed
=function(_21e
,_21f
){
1800 return MochiKit
.Format
.truncToFixed(_21e
+0.5*Math
.pow(10,-_21f
),_21f
);
1802 MochiKit
.Format
.percentFormat
=function(_220
){
1803 return MochiKit
.Format
.twoDigitFloat(100*_220
)+"%";
1805 MochiKit
.Format
.EXPORT
=["truncToFixed","roundToFixed","numberFormatter","formatLocale","twoDigitAverage","twoDigitFloat","percentFormat","lstrip","rstrip","strip"];
1806 MochiKit
.Format
.LOCALE
={en_US
:{separator
:",",decimal:".",percent
:"%"},de_DE
:{separator
:".",decimal:",",percent
:"%"},fr_FR
:{separator
:" ",decimal:",",percent
:"%"},"default":"en_US"};
1807 MochiKit
.Format
.EXPORT_OK
=[];
1808 MochiKit
.Format
.EXPORT_TAGS
={":all":MochiKit
.Format
.EXPORT
,":common":MochiKit
.Format
.EXPORT
};
1809 MochiKit
.Format
.__new__
=function(){
1810 var base
=this.NAME
+".";
1812 for(k
in this.LOCALE
){
1814 if(typeof (o
)=="object"){
1818 o
.NAME
=base
+"LOCALE."+k
;
1823 if(typeof (o
)=="function"&&typeof (o
.NAME
)=="undefined"){
1832 MochiKit
.Format
.__new__();
1833 if(typeof (MochiKit
.Base
)!="undefined"){
1834 MochiKit
.Base
._exportSymbols(this,MochiKit
.Format
);
1836 (function(_225
,_226
){
1837 if((typeof (JSAN
)=="undefined"&&typeof (dojo
)=="undefined")||(MochiKit
.__export__
===false)){
1838 var all
=_226
.EXPORT_TAGS
[":all"];
1839 for(var i
=0;i
<all
.length
;i
++){
1840 _225
[all
[i
]]=_226
[all
[i
]];
1843 })(this,MochiKit
.Format
);
1845 if(typeof (dojo
)!="undefined"){
1846 dojo
.provide("MochiKit.DOM");
1847 dojo
.require("MochiKit.Base");
1849 if(typeof (JSAN
)!="undefined"){
1850 JSAN
.use("MochiKit.Base",[]);
1853 if(typeof (MochiKit
.Base
)=="undefined"){
1858 throw "MochiKit.DOM depends on MochiKit.Base!";
1860 if(typeof (MochiKit
.DOM
)=="undefined"){
1863 MochiKit
.DOM
.NAME
="MochiKit.DOM";
1864 MochiKit
.DOM
.VERSION
="1.4";
1865 MochiKit
.DOM
.__repr__
=function(){
1866 return "["+this.NAME
+" "+this.VERSION
+"]";
1868 MochiKit
.DOM
.toString
=function(){
1869 return this.__repr__();
1871 MochiKit
.DOM
.EXPORT
=["removeEmptyTextNodes","formContents","currentWindow","currentDocument","withWindow","withDocument","registerDOMConverter","coerceToDOM","createDOM","createDOMFunc","isChildNode","getNodeAttribute","removeNodeAttribute","setNodeAttribute","updateNodeAttributes","appendChildNodes","insertSiblingNodesAfter","insertSiblingNodesBefore","replaceChildNodes","removeElement","swapDOM","BUTTON","TT","PRE","H1","H2","H3","BR","CANVAS","HR","LABEL","TEXTAREA","FORM","STRONG","SELECT","OPTION","OPTGROUP","LEGEND","FIELDSET","P","UL","OL","LI","TD","TR","THEAD","TBODY","TFOOT","TABLE","TH","INPUT","SPAN","A","DIV","IMG","getElement","$","getElementsByTagAndClassName","addToCallStack","addLoadEvent","focusOnLoad","setElementClass","toggleElementClass","addElementClass","removeElementClass","swapElementClass","hasElementClass","escapeHTML","toHTML","emitHTML","scrapeText","isParent","getFirstParentByTagAndClassName","makeClipping","undoClipping","makePositioned","undoPositioned","getFirstElementByTagAndClassName"];
1872 MochiKit
.DOM
.EXPORT_OK
=["domConverters"];
1873 MochiKit
.DOM
.DEPRECATED
=[["computedStyle","MochiKit.Style.getStyle","1.4"],["elementDimensions","MochiKit.Style.getElementDimensions","1.4"],["elementPosition","MochiKit.Style.getElementPosition","1.4"],["hideElement","MochiKit.Style.hideElement","1.4"],["setElementDimensions","MochiKit.Style.setElementDimensions","1.4"],["setElementPosition","MochiKit.Style.setElementPosition","1.4"],["setDisplayForElement","MochiKit.Style.setDisplayForElement","1.4"],["setOpacity","MochiKit.Style.setOpacity","1.4"],["showElement","MochiKit.Style.showElement","1.4"],["Coordinates","MochiKit.Style.Coordinates","1.4"],["Dimensions","MochiKit.Style.Dimensions","1.4"]];
1874 MochiKit
.DOM
.getViewportDimensions
=new Function(""+"if (!MochiKit[\"Style\"]) {"+" throw new Error(\"This function has been deprecated and depends on MochiKit.Style.\");"+"}"+"return MochiKit.Style.getViewportDimensions.apply(this, arguments);");
1875 MochiKit
.Base
.update(MochiKit
.DOM
,{currentWindow
:function(){
1876 return MochiKit
.DOM
._window
;
1877 },currentDocument
:function(){
1878 return MochiKit
.DOM
._document
;
1879 },withWindow
:function(win
,func
){
1880 var self
=MochiKit
.DOM
;
1881 var _22c
=self
._document
;
1882 var _22d
=self
._window
;
1886 self
._document
=win
.document
;
1891 self
._document
=_22c
;
1895 self
._document
=_22c
;
1897 },formContents
:function(elem
){
1900 var m
=MochiKit
.Base
;
1901 var self
=MochiKit
.DOM
;
1902 if(typeof (elem
)=="undefined"||elem
===null){
1903 elem
=self
._document
.body
;
1905 elem
=self
.getElement(elem
);
1907 m
.nodeWalk(elem
,function(elem
){
1909 if(m
.isNotEmpty(name
)){
1910 var _236
=elem
.tagName
.toUpperCase();
1911 if(_236
==="INPUT"&&(elem
.type
=="radio"||elem
.type
=="checkbox")&&!elem
.checked
){
1914 if(_236
==="SELECT"){
1915 if(elem
.type
=="select-one"){
1916 if(elem
.selectedIndex
>=0){
1917 var opt
=elem
.options
[elem
.selectedIndex
];
1920 var h
=opt
.outerHTML
;
1921 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
1933 var opts
=elem
.options
;
1939 for(var i
=0;i
<opts
.length
;i
++){
1946 var h
=opt
.outerHTML
;
1947 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
1957 if(_236
==="FORM"||_236
==="P"||_236
==="SPAN"||_236
==="DIV"){
1958 return elem
.childNodes
;
1961 _231
.push(elem
.value
||"");
1964 return elem
.childNodes
;
1967 },withDocument
:function(doc
,func
){
1968 var self
=MochiKit
.DOM
;
1969 var _23f
=self
._document
;
1976 self
._document
=_23f
;
1979 self
._document
=_23f
;
1981 },registerDOMConverter
:function(name
,_242
,wrap
,_244
){
1982 MochiKit
.DOM
.domConverters
.register(name
,_242
,wrap
,_244
);
1983 },coerceToDOM
:function(node
,ctx
){
1984 var m
=MochiKit
.Base
;
1985 var im
=MochiKit
.Iter
;
1986 var self
=MochiKit
.DOM
;
1992 var _24d
=self
.domConverters
;
1993 var _24e
=arguments
.callee
;
1994 var _24f
=m
.NotFound
;
1996 if(typeof (node
)=="undefined"||node
===null){
1999 if(typeof (node
)=="function"&&typeof (node
.length
)=="number"&&!(node
instanceof Function
)){
2002 if(typeof (node
.nodeType
)!="undefined"&&node
.nodeType
>0){
2005 if(typeof (node
)=="number"||typeof (node
)=="boolean"){
2006 node
=node
.toString();
2008 if(typeof (node
)=="string"){
2009 return self
._document
.createTextNode(node
);
2011 if(typeof (node
.__dom__
)=="function"){
2012 node
=node
.__dom__(ctx
);
2015 if(typeof (node
.dom
)=="function"){
2019 if(typeof (node
)=="function"){
2020 node
=node
.apply(ctx
,[ctx
]);
2031 return map(_24e
,_250
,_24b(ctx
));
2035 node
=_24d
.match(node
,ctx
);
2043 return self
._document
.createTextNode(node
.toString());
2046 },isChildNode
:function(node
,_252
){
2047 var self
=MochiKit
.DOM
;
2048 if(typeof (node
)=="string"){
2049 node
=self
.getElement(node
);
2051 if(typeof (_252
)=="string"){
2052 _252
=self
.getElement(_252
);
2057 while(node
&&node
.tagName
.toUpperCase()!="BODY"){
2058 node
=node
.parentNode
;
2064 },setNodeAttribute
:function(node
,attr
,_256
){
2068 return MochiKit
.DOM
.updateNodeAttributes(node
,o
);
2073 },getNodeAttribute
:function(node
,attr
){
2074 var self
=MochiKit
.DOM
;
2075 var _25b
=self
.attributeArray
.renames
[attr
];
2076 node
=self
.getElement(node
);
2081 return node
.getAttribute(attr
);
2086 },removeNodeAttribute
:function(node
,attr
){
2087 var self
=MochiKit
.DOM
;
2088 var _25f
=self
.attributeArray
.renames
[attr
];
2089 node
=self
.getElement(node
);
2094 return node
.removeAttribute(attr
);
2099 },updateNodeAttributes
:function(node
,_261
){
2101 var self
=MochiKit
.DOM
;
2102 if(typeof (node
)=="string"){
2103 elem
=self
.getElement(node
);
2106 var _264
=MochiKit
.Base
.updatetree
;
2107 if(self
.attributeArray
.compliant
){
2110 if(typeof (v
)=="object"&&typeof (elem
[k
])=="object"){
2111 if(k
=="style"&&MochiKit
.Style
){
2112 MochiKit
.Style
.setStyle(elem
,v
);
2117 if(k
.substring(0,2)=="on"){
2118 if(typeof (v
)=="string"){
2123 elem
.setAttribute(k
,v
);
2128 var _267
=self
.attributeArray
.renames
;
2132 if(k
=="style"&&typeof (v
)=="string"){
2133 elem
.style
.cssText
=v
;
2135 if(typeof (_268
)=="string"){
2138 if(typeof (elem
[k
])=="object"&&typeof (v
)=="object"){
2139 if(k
=="style"&&MochiKit
.Style
){
2140 MochiKit
.Style
.setStyle(elem
,v
);
2145 if(k
.substring(0,2)=="on"){
2146 if(typeof (v
)=="string"){
2151 elem
.setAttribute(k
,v
);
2160 },appendChildNodes
:function(node
){
2162 var self
=MochiKit
.DOM
;
2163 if(typeof (node
)=="string"){
2164 elem
=self
.getElement(node
);
2166 var _26c
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
2167 var _26d
=MochiKit
.Base
.concat
;
2170 if(typeof (n
)=="undefined"||n
===null){
2172 if(typeof (n
.nodeType
)=="number"){
2173 elem
.appendChild(n
);
2180 },insertSiblingNodesBefore
:function(node
){
2182 var self
=MochiKit
.DOM
;
2183 if(typeof (node
)=="string"){
2184 elem
=self
.getElement(node
);
2186 var _272
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
2187 var _273
=elem
.parentNode
;
2188 var _274
=MochiKit
.Base
.concat
;
2191 if(typeof (n
)=="undefined"||n
===null){
2193 if(typeof (n
.nodeType
)=="number"){
2194 _273
.insertBefore(n
,elem
);
2201 },insertSiblingNodesAfter
:function(node
){
2203 var self
=MochiKit
.DOM
;
2204 if(typeof (node
)=="string"){
2205 elem
=self
.getElement(node
);
2207 var _279
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
2208 if(elem
.nextSibling
){
2209 return self
.insertSiblingNodesBefore(elem
.nextSibling
,_279
);
2211 return self
.appendChildNodes(elem
.parentNode
,_279
);
2213 },replaceChildNodes
:function(node
){
2215 var self
=MochiKit
.DOM
;
2216 if(typeof (node
)=="string"){
2217 elem
=self
.getElement(node
);
2221 while((_27d
=elem
.firstChild
)){
2222 elem
.removeChild(_27d
);
2224 if(arguments
.length
<2){
2227 return self
.appendChildNodes
.apply(this,arguments
);
2229 },createDOM
:function(name
,_27f
){
2231 var self
=MochiKit
.DOM
;
2232 var m
=MochiKit
.Base
;
2233 if(typeof (_27f
)=="string"||typeof (_27f
)=="number"){
2234 var args
=m
.extend([name
,null],arguments
,1);
2235 return arguments
.callee
.apply(this,args
);
2237 if(typeof (name
)=="string"){
2238 var _284
=self
._xhtml
;
2239 if(_27f
&&!self
.attributeArray
.compliant
){
2242 _285
+=" name=\""+self
.escapeHTML(_27f
.name
)+"\"";
2244 if(name
=="input"&&"type" in _27f
){
2245 _285
+=" type=\""+self
.escapeHTML(_27f
.type
)+"\"";
2248 name
="<"+name
+_285
+">";
2252 var d
=self
._document
;
2253 if(_284
&&d
===document
){
2254 elem
=d
.createElementNS("http://www.w3.org/1999/xhtml",name
);
2256 elem
=d
.createElement(name
);
2262 self
.updateNodeAttributes(elem
,_27f
);
2264 if(arguments
.length
<=2){
2267 var args
=m
.extend([elem
],arguments
,2);
2268 return self
.appendChildNodes
.apply(this,args
);
2270 },createDOMFunc
:function(){
2271 var m
=MochiKit
.Base
;
2272 return m
.partial
.apply(this,m
.extend([MochiKit
.DOM
.createDOM
],arguments
));
2273 },removeElement
:function(elem
){
2274 var e
=MochiKit
.DOM
.getElement(elem
);
2275 e
.parentNode
.removeChild(e
);
2277 },swapDOM
:function(dest
,src
){
2278 var self
=MochiKit
.DOM
;
2279 dest
=self
.getElement(dest
);
2280 var _28d
=dest
.parentNode
;
2282 src
=self
.getElement(src
);
2283 _28d
.replaceChild(src
,dest
);
2285 _28d
.removeChild(dest
);
2288 },getElement
:function(id
){
2289 var self
=MochiKit
.DOM
;
2290 if(arguments
.length
==1){
2291 return ((typeof (id
)=="string")?self
._document
.getElementById(id
):id
);
2293 return MochiKit
.Base
.map(self
.getElement
,arguments
);
2295 },getElementsByTagAndClassName
:function(_290
,_291
,_292
){
2296 var self
=MochiKit
.DOM
;
2297 if(typeof (_290
)=="undefined"||_290
===null){
2300 if(typeof (_292
)=="undefined"||_292
===null){
2301 _292
=self
._document
;
2303 _292
=self
.getElement(_292
);
2304 var _294
=(_292
.getElementsByTagName(_290
)||self
._document
.all
);
2305 if(typeof (_291
)=="undefined"||_291
===null){
2306 return MochiKit
.Base
.extend(null,_294
);
2309 for(var i
=0;i
<_294
.length
;i
++){
2311 var cls
=_297
.className
;
2315 var _299
=cls
.split(" ");
2316 for(var j
=0;j
<_299
.length
;j
++){
2324 },_newCallStack
:function(path
,once
){
2325 var rval
=function(){
2326 var _29e
=arguments
.callee
.callStack
;
2327 for(var i
=0;i
<_29e
.length
;i
++){
2328 if(_29e
[i
].apply(this,arguments
)===false){
2342 },addToCallStack
:function(_2a0
,path
,func
,once
){
2343 var self
=MochiKit
.DOM
;
2344 var _2a5
=_2a0
[path
];
2346 if(!(typeof (_2a5
)=="function"&&typeof (_2a5
.callStack
)=="object"&&_2a5
.callStack
!==null)){
2347 _2a6
=self
._newCallStack(path
,once
);
2348 if(typeof (_2a5
)=="function"){
2349 _2a6
.callStack
.push(_2a5
);
2353 _2a6
.callStack
.push(func
);
2354 },addLoadEvent
:function(func
){
2355 var self
=MochiKit
.DOM
;
2356 self
.addToCallStack(self
._window
,"onload",func
,true);
2357 },focusOnLoad
:function(_2a9
){
2358 var self
=MochiKit
.DOM
;
2359 self
.addLoadEvent(function(){
2360 _2a9
=self
.getElement(_2a9
);
2365 },setElementClass
:function(_2ab
,_2ac
){
2366 var self
=MochiKit
.DOM
;
2367 var obj
=self
.getElement(_2ab
);
2368 if(self
.attributeArray
.compliant
){
2369 obj
.setAttribute("class",_2ac
);
2371 obj
.setAttribute("className",_2ac
);
2373 },toggleElementClass
:function(_2af
){
2374 var self
=MochiKit
.DOM
;
2375 for(var i
=1;i
<arguments
.length
;i
++){
2376 var obj
=self
.getElement(arguments
[i
]);
2377 if(!self
.addElementClass(obj
,_2af
)){
2378 self
.removeElementClass(obj
,_2af
);
2381 },addElementClass
:function(_2b3
,_2b4
){
2382 var self
=MochiKit
.DOM
;
2383 var obj
=self
.getElement(_2b3
);
2384 var cls
=obj
.className
;
2385 if(cls
==undefined
||cls
.length
===0){
2386 self
.setElementClass(obj
,_2b4
);
2392 var _2b8
=cls
.split(" ");
2393 for(var i
=0;i
<_2b8
.length
;i
++){
2398 self
.setElementClass(obj
,cls
+" "+_2b4
);
2400 },removeElementClass
:function(_2ba
,_2bb
){
2401 var self
=MochiKit
.DOM
;
2402 var obj
=self
.getElement(_2ba
);
2403 var cls
=obj
.className
;
2404 if(cls
==undefined
||cls
.length
===0){
2408 self
.setElementClass(obj
,"");
2411 var _2bf
=cls
.split(" ");
2412 for(var i
=0;i
<_2bf
.length
;i
++){
2415 self
.setElementClass(obj
,_2bf
.join(" "));
2420 },swapElementClass
:function(_2c1
,_2c2
,_2c3
){
2421 var obj
=MochiKit
.DOM
.getElement(_2c1
);
2422 var res
=MochiKit
.DOM
.removeElementClass(obj
,_2c2
);
2424 MochiKit
.DOM
.addElementClass(obj
,_2c3
);
2427 },hasElementClass
:function(_2c6
,_2c7
){
2428 var obj
=MochiKit
.DOM
.getElement(_2c6
);
2429 var cls
=obj
.className
;
2433 var _2ca
=cls
.split(" ");
2434 for(var i
=1;i
<arguments
.length
;i
++){
2436 for(var j
=0;j
<_2ca
.length
;j
++){
2437 if(_2ca
[j
]==arguments
[i
]){
2447 },escapeHTML
:function(s
){
2448 return s
.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");
2449 },toHTML
:function(dom
){
2450 return MochiKit
.DOM
.emitHTML(dom
).join("");
2451 },emitHTML
:function(dom
,lst
){
2452 if(typeof (lst
)=="undefined"||lst
===null){
2456 var self
=MochiKit
.DOM
;
2457 var _2d4
=self
.escapeHTML
;
2458 var _2d5
=self
.attributeArray
;
2461 if(typeof (dom
)=="string"){
2464 if(dom
.nodeType
==1){
2465 lst
.push("<"+dom
.tagName
.toLowerCase());
2468 for(var i
=0;i
<_2d7
.length
;i
++){
2470 _2d6
.push([" ",a
.name
,"=\"",_2d4(a
.value
),"\""]);
2473 for(i
=0;i
<_2d6
.length
;i
++){
2475 for(var j
=0;j
<_2da
.length
;j
++){
2479 if(dom
.hasChildNodes()){
2481 _2d2
.push("</"+dom
.tagName
.toLowerCase()+">");
2482 var _2dc
=dom
.childNodes
;
2483 for(i
=_2dc
.length
-1;i
>=0;i
--){
2490 if(dom
.nodeType
==3){
2491 lst
.push(_2d4(dom
.nodeValue
));
2497 },scrapeText
:function(node
,_2de
){
2500 var cn
=node
.childNodes
;
2502 for(var i
=0;i
<cn
.length
;i
++){
2503 arguments
.callee
.call(this,cn
[i
]);
2506 var _2e3
=node
.nodeValue
;
2507 if(typeof (_2e3
)=="string"){
2510 })(MochiKit
.DOM
.getElement(node
));
2514 return rval
.join("");
2516 },removeEmptyTextNodes
:function(_2e4
){
2517 _2e4
=MochiKit
.DOM
.getElement(_2e4
);
2518 for(var i
=0;i
<_2e4
.childNodes
.length
;i
++){
2519 var node
=_2e4
.childNodes
[i
];
2520 if(node
.nodeType
==3&&!/\S/.test(node
.nodeValue
)){
2521 node
.parentNode
.removeChild(node
);
2524 },makeClipping
:function(_2e7
){
2525 _2e7
=MochiKit
.DOM
.getElement(_2e7
);
2526 var _2e8
=_2e7
.style
.overflow
;
2527 if((MochiKit
.Style
.getStyle(_2e7
,"overflow")||"visible")!="hidden"){
2528 _2e7
.style
.overflow
="hidden";
2531 },undoClipping
:function(_2e9
,_2ea
){
2532 _2e9
=MochiKit
.DOM
.getElement(_2e9
);
2536 _2e9
.style
.overflow
=_2ea
;
2537 },makePositioned
:function(_2eb
){
2538 _2eb
=MochiKit
.DOM
.getElement(_2eb
);
2539 var pos
=MochiKit
.Style
.getStyle(_2eb
,"position");
2540 if(pos
=="static"||!pos
){
2541 _2eb
.style
.position
="relative";
2542 if(/Opera/.test(navigator
.userAgent
)){
2547 },undoPositioned
:function(_2ed
){
2548 _2ed
=MochiKit
.DOM
.getElement(_2ed
);
2549 if(_2ed
.style
.position
=="relative"){
2550 _2ed
.style
.position
=_2ed
.style
.top
=_2ed
.style
.left
=_2ed
.style
.bottom
=_2ed
.style
.right
="";
2552 },getFirstElementByTagAndClassName
:function(_2ee
,_2ef
,_2f0
){
2553 var self
=MochiKit
.DOM
;
2554 if(typeof (_2ee
)=="undefined"||_2ee
===null){
2557 if(typeof (_2f0
)=="undefined"||_2f0
===null){
2558 _2f0
=self
._document
;
2560 _2f0
=self
.getElement(_2f0
);
2561 var _2f2
=(_2f0
.getElementsByTagName(_2ee
)||self
._document
.all
);
2562 if(typeof (_2ef
)=="undefined"||_2ef
===null){
2565 for(var i
=0;i
<_2f2
.length
;i
++){
2567 var _2f5
=_2f4
.className
.split(" ");
2568 for(var j
=0;j
<_2f5
.length
;j
++){
2574 },getFirstParentByTagAndClassName
:function(elem
,_2f8
,_2f9
){
2575 var self
=MochiKit
.DOM
;
2576 elem
=self
.getElement(elem
);
2577 if(typeof (_2f8
)=="undefined"||_2f8
===null){
2580 _2f8
=_2f8
.toUpperCase();
2582 if(typeof (_2f9
)=="undefined"||_2f9
===null){
2587 while(elem
&&elem
.tagName
){
2588 elem
=elem
.parentNode
;
2589 if(_2f8
=="*"&&_2f9
===null){
2592 _2fb
=elem
.className
.split(" ");
2593 _2fc
=elem
.tagName
.toUpperCase();
2594 if(_2f9
===null&&_2f8
==_2fc
){
2598 for(var i
=0;i
<_2fb
.length
;i
++){
2599 if(_2f8
=="*"&&_2fb
[i
]==_2f9
){
2602 if(_2f8
==_2fc
&&_2fb
[i
]==_2f9
){
2611 },isParent
:function(_2fe
,_2ff
){
2612 if(!_2fe
.parentNode
||_2fe
==_2ff
){
2615 if(_2fe
.parentNode
==_2ff
){
2618 return MochiKit
.DOM
.isParent(_2fe
.parentNode
,_2ff
);
2619 },__new__
:function(win
){
2620 var m
=MochiKit
.Base
;
2621 if(typeof (document
)!="undefined"){
2622 this._document
=document
;
2623 var _302
="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
2624 this._xhtml
=(document
.documentElement
&&document
.createElementNS
&&document
.documentElement
.namespaceURI
===_302
);
2626 if(MochiKit
.MockDOM
){
2627 this._document
=MochiKit
.MockDOM
.document
;
2631 this.domConverters
=new m
.AdapterRegistry();
2632 var _303
=this._document
.createElement("span");
2634 if(_303
&&_303
.attributes
&&_303
.attributes
.length
>0){
2636 _304
=function(node
){
2637 return _305(_304
.ignoreAttrFilter
,node
.attributes
);
2640 var _307
=_303
.attributes
;
2641 var _308
=_304
.ignoreAttr
;
2642 for(var i
=0;i
<_307
.length
;i
++){
2644 _308
[a
.name
]=a
.value
;
2646 _304
.ignoreAttrFilter
=function(a
){
2647 return (_304
.ignoreAttr
[a
.name
]!=a
.value
);
2649 _304
.compliant
=false;
2650 _304
.renames
={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"};
2652 _304
=function(node
){
2653 return node
.attributes
;
2655 _304
.compliant
=true;
2658 this.attributeArray
=_304
;
2659 var _30d
=function(_30e
,arr
){
2660 var _310
=arr
[1].split(".");
2663 str
+="if (!MochiKit."+_310
[1]+") { throw new Error(\"";
2664 str
+="This function has been deprecated and depends on MochiKit.";
2665 str
+=_310
[1]+".\");}";
2666 str
+="return MochiKit."+_310
[1]+"."+arr
[0];
2667 str
+=".apply(this, arguments);";
2668 obj
[_310
[2]]=new Function(str
);
2669 MochiKit
.Base
.update(MochiKit
[_30e
],obj
);
2671 for(var i
;i
<MochiKit
.DOM
.DEPRECATED
.length
;i
++){
2672 _30d("DOM",MochiKit
.DOM
.DEPRECATED
[i
]);
2674 var _313
=this.createDOMFunc
;
2680 this.TBODY
=_313("tbody");
2681 this.THEAD
=_313("thead");
2682 this.TFOOT
=_313("tfoot");
2683 this.TABLE
=_313("table");
2685 this.INPUT
=_313("input");
2686 this.SPAN
=_313("span");
2688 this.DIV
=_313("div");
2689 this.IMG
=_313("img");
2690 this.BUTTON
=_313("button");
2692 this.PRE
=_313("pre");
2698 this.LABEL
=_313("label");
2699 this.TEXTAREA
=_313("textarea");
2700 this.FORM
=_313("form");
2702 this.SELECT
=_313("select");
2703 this.OPTION
=_313("option");
2704 this.OPTGROUP
=_313("optgroup");
2705 this.LEGEND
=_313("legend");
2706 this.FIELDSET
=_313("fieldset");
2707 this.STRONG
=_313("strong");
2708 this.CANVAS
=_313("canvas");
2709 this.$=this.getElement
;
2710 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
2711 m
.nameFunctions(this);
2713 MochiKit
.DOM
.__new__(((typeof (window
)=="undefined")?this:window
));
2714 if(MochiKit
.__export__
){
2715 withWindow
=MochiKit
.DOM
.withWindow
;
2716 withDocument
=MochiKit
.DOM
.withDocument
;
2718 MochiKit
.Base
._exportSymbols(this,MochiKit
.DOM
);
2719 if(typeof (dojo
)!="undefined"){
2720 dojo
.provide("MochiKit.Style");
2721 dojo
.require("MochiKit.Base");
2722 dojo
.require("MochiKit.DOM");
2724 if(typeof (JSAN
)!="undefined"){
2725 JSAN
.use("MochiKit.Base",[]);
2726 JSAN
.use("MochiKit.DOM",[]);
2729 if(typeof (MochiKit
.Base
)=="undefined"){
2734 throw "MochiKit.Style depends on MochiKit.Base!";
2737 if(typeof (MochiKit
.DOM
)=="undefined"){
2742 throw "MochiKit.Style depends on MochiKit.DOM!";
2744 if(typeof (MochiKit
.Style
)=="undefined"){
2747 MochiKit
.Style
.NAME
="MochiKit.Style";
2748 MochiKit
.Style
.VERSION
="1.4";
2749 MochiKit
.Style
.__repr__
=function(){
2750 return "["+this.NAME
+" "+this.VERSION
+"]";
2752 MochiKit
.Style
.toString
=function(){
2753 return this.__repr__();
2755 MochiKit
.Style
.EXPORT_OK
=[];
2756 MochiKit
.Style
.EXPORT
=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
2757 MochiKit
.Style
.Dimensions
=function(w
,h
){
2761 MochiKit
.Style
.Dimensions
.prototype.__repr__
=function(){
2762 var repr
=MochiKit
.Base
.repr
;
2763 return "{w: "+repr(this.w
)+", h: "+repr(this.h
)+"}";
2765 MochiKit
.Style
.Dimensions
.prototype.toString
=function(){
2766 return this.__repr__();
2768 MochiKit
.Style
.Coordinates
=function(x
,y
){
2772 MochiKit
.Style
.Coordinates
.prototype.__repr__
=function(){
2773 var repr
=MochiKit
.Base
.repr
;
2774 return "{x: "+repr(this.x
)+", y: "+repr(this.y
)+"}";
2776 MochiKit
.Style
.Coordinates
.prototype.toString
=function(){
2777 return this.__repr__();
2779 MochiKit
.Base
.update(MochiKit
.Style
,{getStyle
:function(elem
,_31b
){
2780 var dom
=MochiKit
.DOM
;
2781 var d
=dom
._document
;
2782 elem
=dom
.getElement(elem
);
2783 _31b
=MochiKit
.Base
.camelize(_31b
);
2787 if(_31b
=="opacity"&&elem
.filters
){
2788 var _31e
=(MochiKit
.Style
.getStyle(elem
,"filter")||"").match(/alpha\(opacity=(.*)\)/);
2790 return parseFloat(_31e
[1])/100;
2794 var _31f
=elem
.style
?elem
.style
[_31b
]:null;
2796 if(d
.defaultView
&&d
.defaultView
.getComputedStyle
){
2797 var css
=d
.defaultView
.getComputedStyle(elem
,null);
2798 _31b
=_31b
.replace(/([A-Z])/g,"-$1").toLowerCase();
2799 _31f
=css
?css
.getPropertyValue(_31b
):null;
2801 if(elem
.currentStyle
){
2802 _31f
=elem
.currentStyle
[_31b
];
2806 if(_31b
=="opacity"){
2807 _31f
=parseFloat(_31f
);
2809 if(/Opera/.test(navigator
.userAgent
)&&(MochiKit
.Base
.find(["left","top","right","bottom"],_31b
)!=-1)){
2810 if(MochiKit
.Style
.getStyle(elem
,"position")=="static"){
2814 return _31f
=="auto"?null:_31f
;
2815 },setStyle
:function(elem
,_322
){
2816 elem
=MochiKit
.DOM
.getElement(elem
);
2817 for(var name
in _322
){
2818 if(name
=="opacity"){
2819 MochiKit
.Style
.setOpacity(elem
,_322
[name
]);
2821 elem
.style
[MochiKit
.Base
.camelize(name
)]=_322
[name
];
2824 },setOpacity
:function(elem
,o
){
2825 elem
=MochiKit
.DOM
.getElement(elem
);
2826 var self
=MochiKit
.Style
;
2828 var _327
=/Gecko/.test(navigator
.userAgent
)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator
.userAgent
));
2829 elem
.style
["opacity"]=_327
?0.999999:1;
2830 if(/MSIE/.test(navigator
.userAgent
)){
2831 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"");
2837 elem
.style
["opacity"]=o
;
2838 if(/MSIE/.test(navigator
.userAgent
)){
2839 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o
*100+")";
2842 },getElementPosition
:function(elem
,_329
){
2843 var self
=MochiKit
.Style
;
2844 var dom
=MochiKit
.DOM
;
2845 elem
=dom
.getElement(elem
);
2846 if(!elem
||(!(elem
.x
&&elem
.y
)&&(!elem
.parentNode
===null||self
.getStyle(elem
,"display")=="none"))){
2849 var c
=new self
.Coordinates(0,0);
2852 var d
=MochiKit
.DOM
._document
;
2853 var de
=d
.documentElement
;
2855 if(!elem
.parentNode
&&elem
.x
&&elem
.y
){
2859 if(elem
.getBoundingClientRect
){
2860 box
=elem
.getBoundingClientRect();
2861 c
.x
+=box
.left
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
2862 c
.y
+=box
.top
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
2864 if(elem
.offsetParent
){
2865 c
.x
+=elem
.offsetLeft
;
2866 c
.y
+=elem
.offsetTop
;
2867 _32e
=elem
.offsetParent
;
2870 c
.x
+=_32e
.offsetLeft
;
2871 c
.y
+=_32e
.offsetTop
;
2872 _32e
=_32e
.offsetParent
;
2875 var ua
=navigator
.userAgent
.toLowerCase();
2876 if((typeof (opera
)!="undefined"&&parseFloat(opera
.version())<9)||(ua
.indexOf("AppleWebKit")!=-1&&self
.getStyle(elem
,"position")=="absolute")){
2883 if(typeof (_329
)!="undefined"){
2884 _329
=arguments
.callee(_329
);
2890 if(elem
.parentNode
){
2891 _32e
=elem
.parentNode
;
2896 var _333
=_32e
.tagName
.toUpperCase();
2897 if(_333
==="BODY"||_333
==="HTML"){
2900 var disp
=self
.getStyle(_32e
,"display");
2901 if(disp
!="inline"&&disp
!="table-row"){
2902 c
.x
-=_32e
.scrollLeft
;
2903 c
.y
-=_32e
.scrollTop
;
2905 if(_32e
.parentNode
){
2906 _32e
=_32e
.parentNode
;
2912 },setElementPosition
:function(elem
,_336
,_337
){
2913 elem
=MochiKit
.DOM
.getElement(elem
);
2914 if(typeof (_337
)=="undefined"){
2918 var _339
=MochiKit
.Base
.isUndefinedOrNull
;
2920 _338
["left"]=_336
.x
+_337
;
2923 _338
["top"]=_336
.y
+_337
;
2925 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_338
});
2926 },getElementDimensions
:function(elem
){
2927 var self
=MochiKit
.Style
;
2928 var dom
=MochiKit
.DOM
;
2929 if(typeof (elem
.w
)=="number"||typeof (elem
.h
)=="number"){
2930 return new self
.Dimensions(elem
.w
||0,elem
.h
||0);
2932 elem
=dom
.getElement(elem
);
2936 var disp
=self
.getStyle(elem
,"display");
2937 if(disp
!="none"&&disp
!==""&&typeof (disp
)!="undefined"){
2938 return new self
.Dimensions(elem
.offsetWidth
||0,elem
.offsetHeight
||0);
2941 var _33f
=s
.visibility
;
2942 var _340
=s
.position
;
2943 s
.visibility
="hidden";
2944 s
.position
="absolute";
2946 var _341
=elem
.offsetWidth
;
2947 var _342
=elem
.offsetHeight
;
2951 return new self
.Dimensions(_341
,_342
);
2952 },setElementDimensions
:function(elem
,_344
,_345
){
2953 elem
=MochiKit
.DOM
.getElement(elem
);
2954 if(typeof (_345
)=="undefined"){
2958 var _347
=MochiKit
.Base
.isUndefinedOrNull
;
2960 _346
["width"]=_344
.w
+_345
;
2963 _346
["height"]=_344
.h
+_345
;
2965 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_346
});
2966 },setDisplayForElement
:function(_348
,_349
){
2967 var _34a
=MochiKit
.Base
.extend(null,arguments
,1);
2968 var _34b
=MochiKit
.DOM
.getElement
;
2969 for(var i
=0;i
<_34a
.length
;i
++){
2972 _349
.style
.display
=_348
;
2975 },getViewportDimensions
:function(){
2976 var d
=new MochiKit
.Style
.Dimensions();
2977 var w
=MochiKit
.DOM
._window
;
2978 var b
=MochiKit
.DOM
._document
.body
;
2983 if(b
.parentElement
.clientWidth
){
2984 d
.w
=b
.parentElement
.clientWidth
;
2985 d
.h
=b
.parentElement
.clientHeight
;
2987 if(b
&&b
.clientWidth
){
2994 },getViewportPosition
:function(){
2995 var c
=new MochiKit
.Style
.Coordinates(0,0);
2996 var d
=MochiKit
.DOM
._document
;
2997 var de
=d
.documentElement
;
2999 if(de
&&(de
.scrollTop
||de
.scrollLeft
)){
3009 },__new__
:function(){
3010 var m
=MochiKit
.Base
;
3011 this.elementPosition
=this.getElementPosition
;
3012 this.elementDimensions
=this.getElementDimensions
;
3013 this.hideElement
=m
.partial(this.setDisplayForElement
,"none");
3014 this.showElement
=m
.partial(this.setDisplayForElement
,"block");
3015 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
3016 m
.nameFunctions(this);
3018 MochiKit
.Style
.__new__();
3019 MochiKit
.Base
._exportSymbols(this,MochiKit
.Style
);
3020 if(typeof (dojo
)!="undefined"){
3021 dojo
.provide("MochiKit.Color");
3022 dojo
.require("MochiKit.Base");
3023 dojo
.require("MochiKit.DOM");
3024 dojo
.require("MochiKit.Style");
3026 if(typeof (JSAN
)!="undefined"){
3027 JSAN
.use("MochiKit.Base",[]);
3028 JSAN
.use("MochiKit.DOM",[]);
3029 JSAN
.use("MochiKit.Style",[]);
3032 if(typeof (MochiKit
.Base
)=="undefined"){
3037 throw "MochiKit.Color depends on MochiKit.Base";
3040 if(typeof (MochiKit
.DOM
)=="undefined"){
3045 throw "MochiKit.Color depends on MochiKit.DOM";
3048 if(typeof (MochiKit
.Style
)=="undefined"){
3053 throw "MochiKit.Color depends on MochiKit.Style";
3055 if(typeof (MochiKit
.Color
)=="undefined"){
3058 MochiKit
.Color
.NAME
="MochiKit.Color";
3059 MochiKit
.Color
.VERSION
="1.4";
3060 MochiKit
.Color
.__repr__
=function(){
3061 return "["+this.NAME
+" "+this.VERSION
+"]";
3063 MochiKit
.Color
.toString
=function(){
3064 return this.__repr__();
3066 MochiKit
.Color
.Color
=function(red
,_356
,blue
,_358
){
3067 if(typeof (_358
)=="undefined"||_358
===null){
3070 this.rgb
={r
:red
,g
:_356
,b
:blue
,a
:_358
};
3072 MochiKit
.Color
.Color
.prototype={__class__
:MochiKit
.Color
.Color
,colorWithAlpha
:function(_359
){
3074 var m
=MochiKit
.Color
;
3075 return m
.Color
.fromRGB(rgb
.r
,rgb
.g
,rgb
.b
,_359
);
3076 },colorWithHue
:function(hue
){
3077 var hsl
=this.asHSL();
3079 var m
=MochiKit
.Color
;
3080 return m
.Color
.fromHSL(hsl
);
3081 },colorWithSaturation
:function(_35f
){
3082 var hsl
=this.asHSL();
3084 var m
=MochiKit
.Color
;
3085 return m
.Color
.fromHSL(hsl
);
3086 },colorWithLightness
:function(_362
){
3087 var hsl
=this.asHSL();
3089 var m
=MochiKit
.Color
;
3090 return m
.Color
.fromHSL(hsl
);
3091 },darkerColorWithLevel
:function(_365
){
3092 var hsl
=this.asHSL();
3093 hsl
.l
=Math
.max(hsl
.l
-_365
,0);
3094 var m
=MochiKit
.Color
;
3095 return m
.Color
.fromHSL(hsl
);
3096 },lighterColorWithLevel
:function(_368
){
3097 var hsl
=this.asHSL();
3098 hsl
.l
=Math
.min(hsl
.l
+_368
,1);
3099 var m
=MochiKit
.Color
;
3100 return m
.Color
.fromHSL(hsl
);
3101 },blendedColor
:function(_36b
,_36c
){
3102 if(typeof (_36c
)=="undefined"||_36c
===null){
3109 return MochiKit
.Color
.Color
.fromRGB((s
.r
*sf
)+(d
.r
*df
),(s
.g
*sf
)+(d
.g
*df
),(s
.b
*sf
)+(d
.b
*df
),(s
.a
*sf
)+(d
.a
*df
));
3110 },compareRGB
:function(_371
){
3113 return MochiKit
.Base
.compare([a
.r
,a
.g
,a
.b
,a
.a
],[b
.r
,b
.g
,b
.b
,b
.a
]);
3114 },isLight
:function(){
3115 return this.asHSL().b
>0.5;
3116 },isDark
:function(){
3117 return (!this.isLight());
3118 },toHSLString
:function(){
3120 var ccc
=MochiKit
.Color
.clampColorComponent
;
3121 var rval
=this._hslString
;
3123 var mid
=(ccc(c
.h
,360).toFixed(0)+","+ccc(c
.s
,100).toPrecision(4)+"%"+","+ccc(c
.l
,100).toPrecision(4)+"%");
3127 rval
="hsl("+mid
+")";
3132 rval
="hsla("+mid
+","+a
+")";
3134 this._hslString
=rval
;
3137 },toRGBString
:function(){
3139 var ccc
=MochiKit
.Color
.clampColorComponent
;
3140 var rval
=this._rgbString
;
3142 var mid
=(ccc(c
.r
,255).toFixed(0)+","+ccc(c
.g
,255).toFixed(0)+","+ccc(c
.b
,255).toFixed(0));
3144 rval
="rgba("+mid
+","+c
.a
+")";
3146 rval
="rgb("+mid
+")";
3148 this._rgbString
=rval
;
3152 return MochiKit
.Base
.clone(this.rgb
);
3153 },toHexString
:function(){
3154 var m
=MochiKit
.Color
;
3156 var ccc
=MochiKit
.Color
.clampColorComponent
;
3157 var rval
=this._hexString
;
3159 rval
=("#"+m
.toColorPart(ccc(c
.r
,255))+m
.toColorPart(ccc(c
.g
,255))+m
.toColorPart(ccc(c
.b
,255)));
3160 this._hexString
=rval
;
3166 if(typeof (hsv
)=="undefined"||hsv
===null){
3167 hsv
=MochiKit
.Color
.rgbToHSV(this.rgb
);
3170 return MochiKit
.Base
.clone(hsv
);
3174 if(typeof (hsl
)=="undefined"||hsl
===null){
3175 hsl
=MochiKit
.Color
.rgbToHSL(this.rgb
);
3178 return MochiKit
.Base
.clone(hsl
);
3179 },toString
:function(){
3180 return this.toRGBString();
3183 var col
=[c
.r
,c
.g
,c
.b
,c
.a
];
3184 return this.__class__
.NAME
+"("+col
.join(", ")+")";
3186 MochiKit
.Base
.update(MochiKit
.Color
.Color
,{fromRGB
:function(red
,_388
,blue
,_38a
){
3187 var _38b
=MochiKit
.Color
.Color
;
3188 if(arguments
.length
==1){
3193 if(typeof (rgb
.a
)=="undefined"){
3199 return new _38b(red
,_388
,blue
,_38a
);
3200 },fromHSL
:function(hue
,_38e
,_38f
,_390
){
3201 var m
=MochiKit
.Color
;
3202 return m
.Color
.fromRGB(m
.hslToRGB
.apply(m
,arguments
));
3203 },fromHSV
:function(hue
,_393
,_394
,_395
){
3204 var m
=MochiKit
.Color
;
3205 return m
.Color
.fromRGB(m
.hsvToRGB
.apply(m
,arguments
));
3206 },fromName
:function(name
){
3207 var _398
=MochiKit
.Color
.Color
;
3208 if(name
.charAt(0)=="\""){
3209 name
=name
.substr(1,name
.length
-2);
3211 var _399
=_398
._namedColors
[name
.toLowerCase()];
3212 if(typeof (_399
)=="string"){
3213 return _398
.fromHexString(_399
);
3215 if(name
=="transparent"){
3216 return _398
.transparentColor();
3220 },fromString
:function(_39a
){
3221 var self
=MochiKit
.Color
.Color
;
3222 var _39c
=_39a
.substr(0,3);
3224 return self
.fromRGBString(_39a
);
3227 return self
.fromHSLString(_39a
);
3229 if(_39a
.charAt(0)=="#"){
3230 return self
.fromHexString(_39a
);
3234 return self
.fromName(_39a
);
3235 },fromHexString
:function(_39d
){
3236 if(_39d
.charAt(0)=="#"){
3237 _39d
=_39d
.substring(1);
3243 hex
=_39d
.substr(i
,1);
3244 _39e
.push(parseInt(hex
+hex
,16)/255);
3248 hex
=_39d
.substr(i
,2);
3249 _39e
.push(parseInt(hex
,16)/255);
3252 var _3a1
=MochiKit
.Color
.Color
;
3253 return _3a1
.fromRGB
.apply(_3a1
,_39e
);
3254 },_fromColorString
:function(pre
,_3a3
,_3a4
,_3a5
){
3255 if(_3a5
.indexOf(pre
)===0){
3256 _3a5
=_3a5
.substring(_3a5
.indexOf("(",3)+1,_3a5
.length
-1);
3258 var _3a6
=_3a5
.split(/\s*,\s*/);
3260 for(var i
=0;i
<_3a6
.length
;i
++){
3263 var _3ab
=c
.substring(c
.length
-3);
3264 if(c
.charAt(c
.length
-1)=="%"){
3265 val
=0.01*parseFloat(c
.substring(0,c
.length
-1));
3268 val
=parseFloat(c
)/360;
3271 val
=parseFloat(c
)/(Math
.PI
*2);
3273 val
=_3a4
[i
]*parseFloat(c
);
3279 return this[_3a3
].apply(this,_3a7
);
3280 },fromComputedStyle
:function(elem
,_3ad
){
3282 var cls
=MochiKit
.Color
.Color
;
3283 for(elem
=d
.getElement(elem
);elem
;elem
=elem
.parentNode
){
3284 var _3b0
=MochiKit
.Style
.getStyle
.apply(d
,arguments
);
3288 var _3b1
=cls
.fromString(_3b0
);
3292 if(_3b1
.asRGB().a
>0){
3297 },fromBackground
:function(elem
){
3298 var cls
=MochiKit
.Color
.Color
;
3299 return cls
.fromComputedStyle(elem
,"backgroundColor","background-color")||cls
.whiteColor();
3300 },fromText
:function(elem
){
3301 var cls
=MochiKit
.Color
.Color
;
3302 return cls
.fromComputedStyle(elem
,"color","color")||cls
.blackColor();
3303 },namedColors
:function(){
3304 return MochiKit
.Base
.clone(MochiKit
.Color
.Color
._namedColors
);
3306 MochiKit
.Base
.update(MochiKit
.Color
,{clampColorComponent
:function(v
,_3b7
){
3317 },_hslValue
:function(n1
,n2
,hue
){
3333 val
=n1
+(n2
-n1
)*(4-hue
);
3340 },hsvToRGB
:function(hue
,_3bd
,_3be
,_3bf
){
3341 if(arguments
.length
==1){
3356 var i
=Math
.floor(hue
*6);
3358 var p
=_3be
*(1-_3bd
);
3359 var q
=_3be
*(1-(_3bd
*f
));
3360 var t
=_3be
*(1-(_3bd
*(1-f
)));
3395 return {r
:red
,g
:_3c2
,b
:blue
,a
:_3bf
};
3396 },hslToRGB
:function(hue
,_3ca
,_3cb
,_3cc
){
3397 if(arguments
.length
==1){
3416 m2
=_3cb
+_3ca
-(_3cb
*_3ca
);
3419 var f
=MochiKit
.Color
._hslValue
;
3425 return {r
:red
,g
:_3cf
,b
:blue
,a
:_3cc
};
3426 },rgbToHSV
:function(red
,_3d6
,blue
,_3d8
){
3427 if(arguments
.length
==1){
3434 var max
=Math
.max(Math
.max(red
,_3d6
),blue
);
3435 var min
=Math
.min(Math
.min(red
,_3d6
),blue
);
3446 hue
=(_3d6
-blue
)/_3df
;
3449 hue
=2+((blue
-red
)/_3df
);
3451 hue
=4+((red
-_3d6
)/_3df
);
3462 return {h
:hue
,s
:_3dd
,v
:_3de
,a
:_3d8
};
3463 },rgbToHSL
:function(red
,_3e1
,blue
,_3e3
){
3464 if(arguments
.length
==1){
3471 var max
=Math
.max(red
,Math
.max(_3e1
,blue
));
3472 var min
=Math
.min(red
,Math
.min(_3e1
,blue
));
3475 var _3e9
=(max
+min
)/2;
3482 _3e8
=_3ea
/(max
+min
);
3484 _3e8
=_3ea
/(2-max
-min
);
3487 hue
=(_3e1
-blue
)/_3ea
;
3490 hue
=2+((blue
-red
)/_3ea
);
3492 hue
=4+((red
-_3e1
)/_3ea
);
3503 return {h
:hue
,s
:_3e8
,l
:_3e9
,a
:_3e3
};
3504 },toColorPart
:function(num
){
3505 num
=Math
.round(num
);
3506 var _3ec
=num
.toString(16);
3511 },__new__
:function(){
3512 var m
=MochiKit
.Base
;
3513 this.Color
.fromRGBString
=m
.bind(this.Color
._fromColorString
,this.Color
,"rgb","fromRGB",[1/255,1/255,1/255,1]);
3514 this.Color
.fromHSLString
=m
.bind(this.Color
._fromColorString
,this.Color
,"hsl","fromHSL",[1/360,0.01,0.01,1]);
3516 var _3ef
={black
:[0,0,0],blue
:[0,0,1],brown
:[0.6,0.4,0.2],cyan
:[0,1,1],darkGray
:[_3ee
,_3ee
,_3ee
],gray
:[0.5,0.5,0.5],green
:[0,1,0],lightGray
:[2*_3ee
,2*_3ee
,2*_3ee
],magenta
:[1,0,1],orange
:[1,0.5,0],purple
:[0.5,0,0.5],red
:[1,0,0],transparent
:[0,0,0,0],white
:[1,1,1],yellow
:[1,1,0]};
3517 var _3f0
=function(name
,r
,g
,b
,a
){
3518 var rval
=this.fromRGB(r
,g
,b
,a
);
3519 this[name
]=function(){
3526 var _3f9
=m
.concat([_3f0
,this.Color
,name
],_3ef
[k
]);
3527 this.Color
[name
]=m
.bind
.apply(null,_3f9
);
3529 var _3fa
=function(){
3530 for(var i
=0;i
<arguments
.length
;i
++){
3531 if(!(arguments
[i
] instanceof Color
)){
3537 var _3fc
=function(a
,b
){
3538 return a
.compareRGB(b
);
3540 m
.nameFunctions(this);
3541 m
.registerComparator(this.Color
.NAME
,_3fa
,_3fc
);
3542 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
3544 MochiKit
.Color
.EXPORT
=["Color"];
3545 MochiKit
.Color
.EXPORT_OK
=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
3546 MochiKit
.Color
.__new__();
3547 MochiKit
.Base
._exportSymbols(this,MochiKit
.Color
);
3548 MochiKit
.Color
.Color
._namedColors
={aliceblue
:"#f0f8ff",antiquewhite
:"#faebd7",aqua
:"#00ffff",aquamarine
:"#7fffd4",azure
:"#f0ffff",beige
:"#f5f5dc",bisque
:"#ffe4c4",black
:"#000000",blanchedalmond
:"#ffebcd",blue
:"#0000ff",blueviolet
:"#8a2be2",brown
:"#a52a2a",burlywood
:"#deb887",cadetblue
:"#5f9ea0",chartreuse
:"#7fff00",chocolate
:"#d2691e",coral
:"#ff7f50",cornflowerblue
:"#6495ed",cornsilk
:"#fff8dc",crimson
:"#dc143c",cyan
:"#00ffff",darkblue
:"#00008b",darkcyan
:"#008b8b",darkgoldenrod
:"#b8860b",darkgray
:"#a9a9a9",darkgreen
:"#006400",darkgrey
:"#a9a9a9",darkkhaki
:"#bdb76b",darkmagenta
:"#8b008b",darkolivegreen
:"#556b2f",darkorange
:"#ff8c00",darkorchid
:"#9932cc",darkred
:"#8b0000",darksalmon
:"#e9967a",darkseagreen
:"#8fbc8f",darkslateblue
:"#483d8b",darkslategray
:"#2f4f4f",darkslategrey
:"#2f4f4f",darkturquoise
:"#00ced1",darkviolet
:"#9400d3",deeppink
:"#ff1493",deepskyblue
:"#00bfff",dimgray
:"#696969",dimgrey
:"#696969",dodgerblue
:"#1e90ff",firebrick
:"#b22222",floralwhite
:"#fffaf0",forestgreen
:"#228b22",fuchsia
:"#ff00ff",gainsboro
:"#dcdcdc",ghostwhite
:"#f8f8ff",gold
:"#ffd700",goldenrod
:"#daa520",gray
:"#808080",green
:"#008000",greenyellow
:"#adff2f",grey
:"#808080",honeydew
:"#f0fff0",hotpink
:"#ff69b4",indianred
:"#cd5c5c",indigo
:"#4b0082",ivory
:"#fffff0",khaki
:"#f0e68c",lavender
:"#e6e6fa",lavenderblush
:"#fff0f5",lawngreen
:"#7cfc00",lemonchiffon
:"#fffacd",lightblue
:"#add8e6",lightcoral
:"#f08080",lightcyan
:"#e0ffff",lightgoldenrodyellow
:"#fafad2",lightgray
:"#d3d3d3",lightgreen
:"#90ee90",lightgrey
:"#d3d3d3",lightpink
:"#ffb6c1",lightsalmon
:"#ffa07a",lightseagreen
:"#20b2aa",lightskyblue
:"#87cefa",lightslategray
:"#778899",lightslategrey
:"#778899",lightsteelblue
:"#b0c4de",lightyellow
:"#ffffe0",lime
:"#00ff00",limegreen
:"#32cd32",linen
:"#faf0e6",magenta
:"#ff00ff",maroon
:"#800000",mediumaquamarine
:"#66cdaa",mediumblue
:"#0000cd",mediumorchid
:"#ba55d3",mediumpurple
:"#9370db",mediumseagreen
:"#3cb371",mediumslateblue
:"#7b68ee",mediumspringgreen
:"#00fa9a",mediumturquoise
:"#48d1cc",mediumvioletred
:"#c71585",midnightblue
:"#191970",mintcream
:"#f5fffa",mistyrose
:"#ffe4e1",moccasin
:"#ffe4b5",navajowhite
:"#ffdead",navy
:"#000080",oldlace
:"#fdf5e6",olive
:"#808000",olivedrab
:"#6b8e23",orange
:"#ffa500",orangered
:"#ff4500",orchid
:"#da70d6",palegoldenrod
:"#eee8aa",palegreen
:"#98fb98",paleturquoise
:"#afeeee",palevioletred
:"#db7093",papayawhip
:"#ffefd5",peachpuff
:"#ffdab9",peru
:"#cd853f",pink
:"#ffc0cb",plum
:"#dda0dd",powderblue
:"#b0e0e6",purple
:"#800080",red
:"#ff0000",rosybrown
:"#bc8f8f",royalblue
:"#4169e1",saddlebrown
:"#8b4513",salmon
:"#fa8072",sandybrown
:"#f4a460",seagreen
:"#2e8b57",seashell
:"#fff5ee",sienna
:"#a0522d",silver
:"#c0c0c0",skyblue
:"#87ceeb",slateblue
:"#6a5acd",slategray
:"#708090",slategrey
:"#708090",snow
:"#fffafa",springgreen
:"#00ff7f",steelblue
:"#4682b4",tan
:"#d2b48c",teal
:"#008080",thistle
:"#d8bfd8",tomato
:"#ff6347",turquoise
:"#40e0d0",violet
:"#ee82ee",wheat
:"#f5deb3",white
:"#ffffff",whitesmoke
:"#f5f5f5",yellow
:"#ffff00",yellowgreen
:"#9acd32"};
3549 if(typeof (dojo
)!="undefined"){
3550 dojo
.provide("MochiKit.Signal");
3551 dojo
.require("MochiKit.Base");
3552 dojo
.require("MochiKit.DOM");
3553 dojo
.require("MochiKit.Style");
3555 if(typeof (JSAN
)!="undefined"){
3556 JSAN
.use("MochiKit.Base",[]);
3557 JSAN
.use("MochiKit.DOM",[]);
3558 JSAN
.use("MochiKit.Style",[]);
3561 if(typeof (MochiKit
.Base
)=="undefined"){
3566 throw "MochiKit.Signal depends on MochiKit.Base!";
3569 if(typeof (MochiKit
.DOM
)=="undefined"){
3574 throw "MochiKit.Signal depends on MochiKit.DOM!";
3577 if(typeof (MochiKit
.Style
)=="undefined"){
3582 throw "MochiKit.Signal depends on MochiKit.Style!";
3584 if(typeof (MochiKit
.Signal
)=="undefined"){
3587 MochiKit
.Signal
.NAME
="MochiKit.Signal";
3588 MochiKit
.Signal
.VERSION
="1.4";
3589 MochiKit
.Signal
._observers
=[];
3590 MochiKit
.Signal
.Event
=function(src
,e
){
3591 this._event
=e
||window
.event
;
3594 MochiKit
.Base
.update(MochiKit
.Signal
.Event
.prototype,{__repr__
:function(){
3595 var repr
=MochiKit
.Base
.repr
;
3596 var str
="{event(): "+repr(this.event())+", src(): "+repr(this.src())+", type(): "+repr(this.type())+", target(): "+repr(this.target());
3597 if(this.type()&&this.type().indexOf("key")===0||this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu"){
3598 str
+=", modifier(): "+"{alt: "+repr(this.modifier().alt
)+", ctrl: "+repr(this.modifier().ctrl
)+", meta: "+repr(this.modifier().meta
)+", shift: "+repr(this.modifier().shift
)+", any: "+repr(this.modifier().any
)+"}";
3600 if(this.type()&&this.type().indexOf("key")===0){
3601 str
+=", key(): {code: "+repr(this.key().code
)+", string: "+repr(this.key().string
)+"}";
3603 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
3604 str
+=", mouse(): {page: "+repr(this.mouse().page
)+", client: "+repr(this.mouse().client
);
3605 if(this.type()!="mousemove"){
3606 str
+=", button: {left: "+repr(this.mouse().button
.left
)+", middle: "+repr(this.mouse().button
.middle
)+", right: "+repr(this.mouse().button
.right
)+"}}";
3611 if(this.type()=="mouseover"||this.type()=="mouseout"){
3612 str
+=", relatedTarget(): "+repr(this.relatedTarget());
3616 },toString
:function(){
3617 return this.__repr__();
3623 return this._event
.type
||undefined
;
3624 },target
:function(){
3625 return this._event
.target
||this._event
.srcElement
;
3626 },_relatedTarget
:null,relatedTarget
:function(){
3627 if(this._relatedTarget
!==null){
3628 return this._relatedTarget
;
3631 if(this.type()=="mouseover"){
3632 elem
=(this._event
.relatedTarget
||this._event
.fromElement
);
3634 if(this.type()=="mouseout"){
3635 elem
=(this._event
.relatedTarget
||this._event
.toElement
);
3639 this._relatedTarget
=elem
;
3643 },_modifier
:null,modifier
:function(){
3644 if(this._modifier
!==null){
3645 return this._modifier
;
3648 m
.alt
=this._event
.altKey
;
3649 m
.ctrl
=this._event
.ctrlKey
;
3650 m
.meta
=this._event
.metaKey
||false;
3651 m
.shift
=this._event
.shiftKey
;
3652 m
.any
=m
.alt
||m
.ctrl
||m
.shift
||m
.meta
;
3655 },_key
:null,key
:function(){
3656 if(this._key
!==null){
3660 if(this.type()&&this.type().indexOf("key")===0){
3661 if(this.type()=="keydown"||this.type()=="keyup"){
3662 k
.code
=this._event
.keyCode
;
3663 k
.string
=(MochiKit
.Signal
._specialKeys
[k
.code
]||"KEY_UNKNOWN");
3667 if(this.type()=="keypress"){
3670 if(typeof (this._event
.charCode
)!="undefined"&&this._event
.charCode
!==0&&!MochiKit
.Signal
._specialMacKeys
[this._event
.charCode
]){
3671 k
.code
=this._event
.charCode
;
3672 k
.string
=String
.fromCharCode(k
.code
);
3674 if(this._event
.keyCode
&&typeof (this._event
.charCode
)=="undefined"){
3675 k
.code
=this._event
.keyCode
;
3676 k
.string
=String
.fromCharCode(k
.code
);
3685 },_mouse
:null,mouse
:function(){
3686 if(this._mouse
!==null){
3691 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
3692 m
.client
=new MochiKit
.Style
.Coordinates(0,0);
3693 if(e
.clientX
||e
.clientY
){
3694 m
.client
.x
=(!e
.clientX
||e
.clientX
<0)?0:e
.clientX
;
3695 m
.client
.y
=(!e
.clientY
||e
.clientY
<0)?0:e
.clientY
;
3697 m
.page
=new MochiKit
.Style
.Coordinates(0,0);
3698 if(e
.pageX
||e
.pageY
){
3699 m
.page
.x
=(!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
3700 m
.page
.y
=(!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
3702 var de
=MochiKit
.DOM
._document
.documentElement
;
3703 var b
=MochiKit
.DOM
._document
.body
;
3704 m
.page
.x
=e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
3705 m
.page
.y
=e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
3707 if(this.type()!="mousemove"){
3709 m
.button
.left
=false;
3710 m
.button
.right
=false;
3711 m
.button
.middle
=false;
3713 m
.button
.left
=(e
.which
==1);
3714 m
.button
.middle
=(e
.which
==2);
3715 m
.button
.right
=(e
.which
==3);
3717 m
.button
.left
=!!(e
.button
&1);
3718 m
.button
.right
=!!(e
.button
&2);
3719 m
.button
.middle
=!!(e
.button
&4);
3727 this.stopPropagation();
3728 this.preventDefault();
3729 },stopPropagation
:function(){
3730 if(this._event
.stopPropagation
){
3731 this._event
.stopPropagation();
3733 this._event
.cancelBubble
=true;
3735 },preventDefault
:function(){
3736 if(this._event
.preventDefault
){
3737 this._event
.preventDefault();
3739 if(this._confirmUnload
===null){
3740 this._event
.returnValue
=false;
3743 },_confirmUnload
:null,confirmUnload
:function(msg
){
3744 if(this.type()=="beforeunload"){
3745 this._confirmUnload
=msg
;
3746 this._event
.returnValue
=msg
;
3749 MochiKit
.Signal
._specialMacKeys
={3:"KEY_ENTER",63289:"KEY_NUM_PAD_CLEAR",63276:"KEY_PAGE_UP",63277:"KEY_PAGE_DOWN",63275:"KEY_END",63273:"KEY_HOME",63234:"KEY_ARROW_LEFT",63232:"KEY_ARROW_UP",63235:"KEY_ARROW_RIGHT",63233:"KEY_ARROW_DOWN",63302:"KEY_INSERT",63272:"KEY_DELETE"};
3751 var _40b
=MochiKit
.Signal
._specialMacKeys
;
3752 for(i
=63236;i
<=63242;i
++){
3753 _40b
[i
]="KEY_F"+(i
-63236+1);
3756 MochiKit
.Signal
._specialKeys
={8:"KEY_BACKSPACE",9:"KEY_TAB",12:"KEY_NUM_PAD_CLEAR",13:"KEY_ENTER",16:"KEY_SHIFT",17:"KEY_CTRL",18:"KEY_ALT",19:"KEY_PAUSE",20:"KEY_CAPS_LOCK",27:"KEY_ESCAPE",32:"KEY_SPACEBAR",33:"KEY_PAGE_UP",34:"KEY_PAGE_DOWN",35:"KEY_END",36:"KEY_HOME",37:"KEY_ARROW_LEFT",38:"KEY_ARROW_UP",39:"KEY_ARROW_RIGHT",40:"KEY_ARROW_DOWN",44:"KEY_PRINT_SCREEN",45:"KEY_INSERT",46:"KEY_DELETE",59:"KEY_SEMICOLON",91:"KEY_WINDOWS_LEFT",92:"KEY_WINDOWS_RIGHT",93:"KEY_SELECT",106:"KEY_NUM_PAD_ASTERISK",107:"KEY_NUM_PAD_PLUS_SIGN",109:"KEY_NUM_PAD_HYPHEN-MINUS",110:"KEY_NUM_PAD_FULL_STOP",111:"KEY_NUM_PAD_SOLIDUS",144:"KEY_NUM_LOCK",145:"KEY_SCROLL_LOCK",186:"KEY_SEMICOLON",187:"KEY_EQUALS_SIGN",188:"KEY_COMMA",189:"KEY_HYPHEN-MINUS",190:"KEY_FULL_STOP",191:"KEY_SOLIDUS",192:"KEY_GRAVE_ACCENT",219:"KEY_LEFT_SQUARE_BRACKET",220:"KEY_REVERSE_SOLIDUS",221:"KEY_RIGHT_SQUARE_BRACKET",222:"KEY_APOSTROPHE"};
3758 var _40c
=MochiKit
.Signal
._specialKeys
;
3759 for(var i
=48;i
<=57;i
++){
3760 _40c
[i
]="KEY_"+(i
-48);
3762 for(i
=65;i
<=90;i
++){
3763 _40c
[i
]="KEY_"+String
.fromCharCode(i
);
3765 for(i
=96;i
<=105;i
++){
3766 _40c
[i
]="KEY_NUM_PAD_"+(i
-96);
3768 for(i
=112;i
<=123;i
++){
3769 _40c
[i
]="KEY_F"+(i
-112+1);
3772 MochiKit
.Signal
.Ident
=function(_40e
){
3773 this.source
=_40e
.source
;
3774 this.signal
=_40e
.signal
;
3775 this.listener
=_40e
.listener
;
3776 this.isDOM
=_40e
.isDOM
;
3777 this.objOrFunc
=_40e
.objOrFunc
;
3778 this.funcOrStr
=_40e
.funcOrStr
;
3779 this.connected
=_40e
.connected
;
3781 MochiKit
.Signal
.Ident
.prototype={};
3782 MochiKit
.Base
.update(MochiKit
.Signal
,{__repr__
:function(){
3783 return "["+this.NAME
+" "+this.VERSION
+"]";
3784 },toString
:function(){
3785 return this.__repr__();
3786 },_unloadCache
:function(){
3787 var self
=MochiKit
.Signal
;
3788 var _410
=self
._observers
;
3789 for(var i
=0;i
<_410
.length
;i
++){
3790 if(_410
[i
].signal
!=="onload"&&_410
[i
].signal
!=="onunload"){
3791 self
._disconnect(_410
[i
]);
3794 },_listener
:function(src
,sig
,func
,obj
,_416
){
3795 var self
=MochiKit
.Signal
;
3798 return MochiKit
.Base
.bind(func
,obj
);
3801 if(typeof (func
)=="string"){
3802 if(sig
==="onload"||sig
==="onunload"){
3803 return function(_419
){
3804 obj
[func
].apply(obj
,[new E(src
,_419
)]);
3805 var _41a
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,objOrFunc
:obj
,funcOrStr
:func
});
3806 MochiKit
.Signal
._disconnect(_41a
);
3809 return function(_41b
){
3810 obj
[func
].apply(obj
,[new E(src
,_41b
)]);
3814 if(sig
==="onload"||sig
==="onunload"){
3815 return function(_41c
){
3816 func
.apply(obj
,[new E(src
,_41c
)]);
3817 MochiKit
.Signal
.disconnect(src
,sig
,func
);
3818 var _41d
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,objOrFunc
:func
});
3819 MochiKit
.Signal
._disconnect(_41d
);
3822 return function(_41e
){
3823 func
.apply(obj
,[new E(src
,_41e
)]);
3827 },_browserAlreadyHasMouseEnterAndLeave
:function(){
3828 return /MSIE/.test(navigator
.userAgent
);
3829 },_mouseEnterListener
:function(src
,sig
,func
,obj
){
3830 var E
=MochiKit
.Signal
.Event
;
3831 return function(_424
){
3832 var e
=new E(src
,_424
);
3834 e
.relatedTarget().nodeName
;
3840 if(MochiKit
.DOM
.isChildNode(e
.relatedTarget(),src
)){
3846 if(typeof (func
)=="string"){
3847 return obj
[func
].apply(obj
,[e
]);
3849 return func
.apply(obj
,[e
]);
3852 },_getDestPair
:function(_426
,_427
){
3855 if(typeof (_427
)!="undefined"){
3858 if(typeof (_427
)=="string"){
3859 if(typeof (_426
[_427
])!="function"){
3860 throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
3863 if(typeof (_427
)!="function"){
3864 throw new Error("'funcOrStr' must be a function or string");
3868 if(typeof (_426
)!="function"){
3869 throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
3875 },connect
:function(src
,sig
,_42c
,_42d
){
3876 src
=MochiKit
.DOM
.getElement(src
);
3877 var self
=MochiKit
.Signal
;
3878 if(typeof (sig
)!="string"){
3879 throw new Error("'sig' must be a string");
3881 var _42f
=self
._getDestPair(_42c
,_42d
);
3884 if(typeof (obj
)=="undefined"||obj
===null){
3887 var _432
=!!(src
.addEventListener
||src
.attachEvent
);
3888 if(_432
&&(sig
==="onmouseenter"||sig
==="onmouseleave")&&!self
._browserAlreadyHasMouseEnterAndLeave()){
3889 var _433
=self
._mouseEnterListener(src
,sig
.substr(2),func
,obj
);
3890 if(sig
==="onmouseenter"){
3896 var _433
=self
._listener(src
,sig
,func
,obj
,_432
);
3898 if(src
.addEventListener
){
3899 src
.addEventListener(sig
.substr(2),_433
,false);
3901 if(src
.attachEvent
){
3902 src
.attachEvent(sig
,_433
);
3905 var _434
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,listener
:_433
,isDOM
:_432
,objOrFunc
:_42c
,funcOrStr
:_42d
,connected
:true});
3906 self
._observers
.push(_434
);
3907 if(!_432
&&typeof (src
.__connect__
)=="function"){
3908 var args
=MochiKit
.Base
.extend([_434
],arguments
,1);
3909 src
.__connect__
.apply(src
,args
);
3912 },_disconnect
:function(_436
){
3913 if(!_436
.connected
){
3916 _436
.connected
=false;
3920 var src
=_436
.source
;
3921 var sig
=_436
.signal
;
3922 var _439
=_436
.listener
;
3923 if(src
.removeEventListener
){
3924 src
.removeEventListener(sig
.substr(2),_439
,false);
3926 if(src
.detachEvent
){
3927 src
.detachEvent(sig
,_439
);
3929 throw new Error("'src' must be a DOM element");
3932 },disconnect
:function(_43a
){
3933 var self
=MochiKit
.Signal
;
3934 var _43c
=self
._observers
;
3935 var m
=MochiKit
.Base
;
3936 if(arguments
.length
>1){
3937 var src
=MochiKit
.DOM
.getElement(arguments
[0]);
3938 var sig
=arguments
[1];
3939 var obj
=arguments
[2];
3940 var func
=arguments
[3];
3941 for(var i
=_43c
.length
-1;i
>=0;i
--){
3943 if(o
.source
===src
&&o
.signal
===sig
&&o
.objOrFunc
===obj
&&o
.funcOrStr
===func
){
3944 self
._disconnect(o
);
3954 var idx
=m
.findIdentical(_43c
,_43a
);
3956 self
._disconnect(_43a
);
3966 },disconnectAllTo
:function(_445
,_446
){
3967 var self
=MochiKit
.Signal
;
3968 var _448
=self
._observers
;
3969 var _449
=self
._disconnect
;
3970 var _44a
=self
._lock
;
3971 var _44b
=self
._dirty
;
3972 if(typeof (_446
)==="undefined"){
3975 for(var i
=_448
.length
-1;i
>=0;i
--){
3977 if(_44d
.objOrFunc
===_445
&&(_446
===null||_44d
.funcOrStr
===_446
)){
3987 },disconnectAll
:function(src
,sig
){
3988 src
=MochiKit
.DOM
.getElement(src
);
3989 var m
=MochiKit
.Base
;
3990 var _451
=m
.flattenArguments(m
.extend(null,arguments
,1));
3991 var self
=MochiKit
.Signal
;
3992 var _453
=self
._disconnect
;
3993 var _454
=self
._observers
;
3995 var _457
=self
._lock
;
3996 var _458
=self
._dirty
;
3997 if(_451
.length
===0){
3998 for(i
=_454
.length
-1;i
>=0;i
--){
4000 if(_456
.source
===src
){
4011 for(i
=0;i
<_451
.length
;i
++){
4014 for(i
=_454
.length
-1;i
>=0;i
--){
4016 if(_456
.source
===src
&&_456
.signal
in sigs
){
4027 },signal
:function(src
,sig
){
4028 var self
=MochiKit
.Signal
;
4029 var _45d
=self
._observers
;
4030 src
=MochiKit
.DOM
.getElement(src
);
4031 var args
=MochiKit
.Base
.extend(null,arguments
,2);
4034 for(var i
=0;i
<_45d
.length
;i
++){
4036 if(_461
.source
===src
&&_461
.signal
===sig
){
4038 _461
.listener
.apply(src
,args
);
4048 for(var i
=_45d
.length
-1;i
>=0;i
--){
4049 if(!_45d
[i
].connected
){
4058 var e
=new Error("Multiple errors thrown in handling 'sig', see errors property");
4064 MochiKit
.Signal
.EXPORT_OK
=[];
4065 MochiKit
.Signal
.EXPORT
=["connect","disconnect","signal","disconnectAll","disconnectAllTo"];
4066 MochiKit
.Signal
.__new__
=function(win
){
4067 var m
=MochiKit
.Base
;
4068 this._document
=document
;
4073 this.connect(window
,"onunload",this._unloadCache
);
4077 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
4078 m
.nameFunctions(this);
4080 MochiKit
.Signal
.__new__(this);
4081 if(MochiKit
.__export__
){
4082 connect
=MochiKit
.Signal
.connect
;
4083 disconnect
=MochiKit
.Signal
.disconnect
;
4084 disconnectAll
=MochiKit
.Signal
.disconnectAll
;
4085 signal
=MochiKit
.Signal
.signal
;
4087 MochiKit
.Base
._exportSymbols(this,MochiKit
.Signal
);
4092 PlotKit.PlotKit 0.9.1 : PACKED VERSION
4094 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
4095 diff against the source tree, not this file.
4097 For more information, <http://www.liquidx.net/plotkit/>.
4099 Copyright (c) 2006. Alastair Tse.
4104 if(typeof (MochiKit
.Base
)=="undefined"||typeof (MochiKit
.DOM
)=="undefined"||typeof (MochiKit
.Color
)=="undefined"||typeof (MochiKit
.Format
)=="undefined"){
4109 throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format}";
4111 MochiKit
.Base
.update(MochiKit
.Color
.Color
.prototype,{asFillColor
:function(){
4112 return this.lighterColorWithLevel(0.3);
4113 },asStrokeColor
:function(){
4114 return this.darkerColorWithLevel(0.1);
4115 },asPointColor
:function(){
4116 return this.lighterColorWithLevel(0.1);
4118 if(typeof (PlotKit
)=="undefined"){
4121 PlotKit
.NAME
="PlotKit";
4122 PlotKit
.VERSION
="0.8";
4123 PlotKit
.__repr__
=function(){
4124 return "["+this.NAME
+" "+this.VERSION
+"]";
4126 PlotKit
.toString
=function(){
4127 return this.__repr__();
4129 if(typeof (PlotKit
.Base
)=="undefined"){
4132 PlotKit
.Base
.NAME
="PlotKit.Base";
4133 PlotKit
.Base
.VERSION
=PlotKit
.VERSION
;
4134 PlotKit
.Base
.__repr__
=function(){
4135 return "["+this.NAME
+" "+this.VERSION
+"]";
4137 PlotKit
.Base
.toString
=function(){
4138 return this.__repr__();
4140 PlotKit
.Base
.usingPrototype
=function(){
4142 return (typeof (Object
.extend
)=="function");
4148 MochiKit
.Base
.update(PlotKit
.Base
,{roundInterval
:function(_1
,_2
,_3
){
4149 var _4
=MochiKit
.Format
.roundToFixed
;
4151 return parseFloat(_4(_5
,_3
));
4152 },collapse
:function(_6
){
4153 var m
=MochiKit
.Base
;
4155 for(var i
=0;i
<_6
.length
;i
++){
4156 _8
=m
.concat(_8
,_6
[i
]);
4158 if(PlotKit
.Base
.usingPrototype()){
4164 },uniq
:function(_10
){
4165 var m
=MochiKit
.Base
;
4166 if(!m
.isArrayLike(_10
)||(_10
.length
<1)){
4169 var _11
=new Array();
4172 for(var i
=1;i
<_10
.length
;i
++){
4173 if(m
.compare(_10
[i
],_12
)!=0){
4179 },palette
:function(_13
,_14
,_15
,_16
){
4180 var _17
=MochiKit
.Base
.isUndefinedOrNull
;
4181 var _18
=new Array();
4196 var _20
=function(_21
,_22
){
4197 return _21
.lighterColorWithLevel(_22
);
4199 return MochiKit
.Base
.map(partial(_20
,_13
),_18
);
4200 },excanvasSupported
:function(){
4201 if(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
){
4205 },findPosX
:function(obj
){
4207 if(obj
.offsetParent
){
4208 while(obj
.offsetParent
){
4209 _24
+=obj
.offsetLeft
;
4210 obj
=obj
.offsetParent
;
4218 },findPosY
:function(obj
){
4220 if(obj
.offsetParent
){
4221 while(obj
.offsetParent
){
4223 obj
=obj
.offsetParent
;
4231 },isFuncLike
:function(obj
){
4232 return (typeof (obj
)=="function");
4234 PlotKit
.Base
.map
=function(fn
,lst
){
4235 if(PlotKit
.Base
.usingPrototype()){
4238 if(typeof (lst
[x
])=="function"){
4241 _28
.push(fn(lst
[x
]));
4245 return MochiKit
.Base
.map(fn
,lst
);
4248 PlotKit
.Base
.items
=function(lst
){
4249 if(PlotKit
.Base
.usingPrototype()){
4252 if(typeof (lst
[x
])=="function"){
4255 _30
.push([x
,lst
[x
]]);
4259 return MochiKit
.Base
.items(lst
);
4262 PlotKit
.Base
.keys
=function(lst
){
4263 if(PlotKit
.Base
.usingPrototype()){
4266 if(typeof (lst
[x
])=="function"){
4273 return MochiKit
.Base
.keys(lst
);
4276 PlotKit
.Base
.baseColors
=function(){
4277 var _32
=MochiKit
.Color
.Color
.fromHexString
;
4278 return [_32("#476fb2"),_32("#be2c2b"),_32("#85b730"),_32("#734a99"),_32("#26a1c5"),_32("#fb8707"),_32("#000000")];
4280 PlotKit
.Base
.EXPORT
=["baseColors","collapse","findPosX","findPosY","roundInterval","uniq","isFuncLike","excanvasSupported"];
4281 PlotKit
.Base
.EXPORT_OK
=[];
4282 PlotKit
.Base
.__new__
=function(){
4283 var m
=MochiKit
.Base
;
4284 m
.nameFunctions(this);
4285 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
4287 PlotKit
.Base
.__new__();
4288 MochiKit
.Base
._exportSymbols(this,PlotKit
.Base
);
4290 if(typeof (PlotKit
.Base
)=="undefined"){
4295 throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Base";
4297 if(typeof (PlotKit
.Layout
)=="undefined"){
4300 PlotKit
.Layout
.NAME
="PlotKit.Layout";
4301 PlotKit
.Layout
.VERSION
=PlotKit
.VERSION
;
4302 PlotKit
.Layout
.__repr__
=function(){
4303 return "["+this.NAME
+" "+this.VERSION
+"]";
4305 PlotKit
.Layout
.toString
=function(){
4306 return this.__repr__();
4308 PlotKit
.Layout
.valid_styles
=["bar","line","pie","point"];
4309 PlotKit
.Layout
=function(_33
,_34
){
4310 this.options
={"barWidthFillFraction":0.75,"barOrientation":"vertical","xOriginIsZero":true,"yOriginIsZero":true,"xAxis":null,"yAxis":null,"xTicks":null,"yTicks":null,"xNumberOfTicks":10,"yNumberOfTicks":5,"xTickPrecision":1,"yTickPrecision":1,"pieRadius":0.4};
4312 MochiKit
.Base
.update(this.options
,_34
?_34
:{});
4313 if(!MochiKit
.Base
.isUndefinedOrNull(this.options
.xAxis
)){
4314 this.minxval
=this.options
.xAxis
[0];
4315 this.maxxval
=this.options
.xAxis
[1];
4316 this.xscale
=this.maxxval
-this.minxval
;
4322 if(!MochiKit
.Base
.isUndefinedOrNull(this.options
.yAxis
)){
4323 this.minyval
=this.options
.yAxis
[0];
4324 this.maxyval
=this.options
.yAxis
[1];
4325 this.yscale
=this.maxyval
-this.minyval
;
4331 this.bars
=new Array();
4332 this.points
=new Array();
4333 this.slices
=new Array();
4334 this.xticks
=new Array();
4335 this.yticks
=new Array();
4336 this.datasets
=new Array();
4340 this.hitTestCache
={x2maxy
:null};
4342 PlotKit
.Layout
.prototype.addDataset
=function(_35
,_36
){
4343 this.datasets
[_35
]=_36
;
4345 PlotKit
.Layout
.prototype.removeDataset
=function(_37
,_38
){
4346 delete this.datasets
[_37
];
4348 PlotKit
.Layout
.prototype.addDatasetFromTable
=function(_39
,_40
,_41
,_42
,_43
){
4349 var _44
=MochiKit
.Base
.isUndefinedOrNull
;
4350 var _45
=MochiKit
.DOM
.scrapeText
;
4351 var _46
=MochiKit
.Format
.strip
;
4361 var _47
=_40
.tBodies
[0].rows
;
4362 var _48
=new Array();
4363 var _49
=new Array();
4365 for(var i
=0;i
<_47
.length
;i
++){
4366 _48
.push([parseFloat(_46(_45(_47
[i
].cells
[_41
]))),parseFloat(_46(_45(_47
[i
].cells
[_42
])))]);
4368 _49
.push({v
:parseFloat(_46(_45(_47
[i
].cells
[_41
]))),label
:_46(_45(_47
[i
].cells
[_43
]))});
4371 this.addDataset(_39
,_48
);
4373 this.options
.xTicks
=_49
;
4379 PlotKit
.Layout
.prototype.evaluate
=function(){
4380 this._evaluateLimits();
4381 this._evaluateScales();
4382 if(this.style
=="line"){
4383 this._evaluateLineCharts();
4384 this._evaluateLineTicks();
4387 PlotKit
.Layout
.prototype._evaluateLimits
=function(){
4388 var map
=PlotKit
.Base
.map
;
4389 var _51
=PlotKit
.Base
.items
;
4390 var _52
=MochiKit
.Base
.itemgetter
;
4391 var _53
=PlotKit
.Base
.collapse
;
4392 var _54
=MochiKit
.Base
.listMin
;
4393 var _55
=MochiKit
.Base
.listMax
;
4394 var _56
=MochiKit
.Base
.isUndefinedOrNull
;
4395 var all
=_53(map(_52(1),_51(this.datasets
)));
4396 if(_56(this.options
.xAxis
)){
4397 if(this.options
.xOriginIsZero
){
4400 this.minxval
=_54(map(parseFloat
,map(_52(0),all
)));
4402 this.maxxval
=_55(map(parseFloat
,map(_52(0),all
)));
4404 this.minxval
=this.options
.xAxis
[0];
4405 this.maxxval
=this.options
.xAxis
[1];
4406 this.xscale
=this.maxval
-this.minxval
;
4408 if(_56(this.options
.yAxis
)){
4409 if(this.options
.yOriginIsZero
){
4412 this.minyval
=_54(map(parseFloat
,map(_52(1),all
)));
4414 this.maxyval
=_55(map(parseFloat
,map(_52(1),all
)));
4416 this.minyval
=this.options
.yAxis
[0];
4417 this.maxyval
=this.options
.yAxis
[1];
4418 this.yscale
=this.maxyval
-this.minyval
;
4421 PlotKit
.Layout
.prototype._evaluateScales
=function(){
4422 var _58
=MochiKit
.Base
.isUndefinedOrNull
;
4423 this.xrange
=this.maxxval
-this.minxval
;
4427 this.xscale
=1/this.xrange
;
4429 this.yrange
=this.maxyval
-this.minyval
;
4433 this.yscale
=1/this.yrange
;
4436 PlotKit
.Layout
.prototype._uniqueXValues
=function(){
4437 var _59
=PlotKit
.Base
.collapse
;
4438 var map
=PlotKit
.Base
.map
;
4439 var _60
=PlotKit
.Base
.uniq
;
4440 var _61
=MochiKit
.Base
.itemgetter
;
4441 var _62
=PlotKit
.Base
.items
;
4442 var _63
=map(parseFloat
,map(_61(0),_59(map(_61(1),_62(this.datasets
)))));
4443 _63
.sort(MochiKit
.Base
.compare
);
4446 PlotKit
.Layout
.prototype._evaluateLineCharts
=function(){
4447 var _64
=PlotKit
.Base
.items
;
4448 var _65
=_64(this.datasets
).length
;
4449 this.points
=new Array();
4451 for(var _66
in this.datasets
){
4452 var _67
=this.datasets
[_66
];
4453 if(PlotKit
.Base
.isFuncLike(_67
)){
4456 _67
.sort(function(a
,b
){
4457 return compare(parseFloat(a
[0]),parseFloat(b
[0]));
4459 for(var j
=0;j
<_67
.length
;j
++){
4461 var _72
={x
:((parseFloat(_71
[0])-this.minxval
)*this.xscale
),y
:1-((parseFloat(_71
[1])-this.minyval
)*this.yscale
),xval
:parseFloat(_71
[0]),yval
:parseFloat(_71
[1]),name
:_66
};
4468 if((_72
.x
>=0)&&(_72
.x
<=1)){
4469 this.points
.push(_72
);
4475 PlotKit
.Layout
.prototype._evaluateLineTicksForXAxis
=function(){
4476 var _73
=MochiKit
.Base
.isUndefinedOrNull
;
4477 if(this.options
.xTicks
){
4478 this.xticks
=new Array();
4479 var _74
=function(_75
){
4482 _76
=_75
.v
.toString();
4484 var pos
=this.xscale
*(_75
.v
-this.minxval
);
4485 if((pos
>=0)&&(pos
<=1)){
4486 this.xticks
.push([pos
,_76
]);
4489 MochiKit
.Iter
.forEach(this.options
.xTicks
,bind(_74
,this));
4491 if(this.options
.xNumberOfTicks
){
4492 var _78
=this._uniqueXValues();
4493 var _79
=this.xrange
/this.options
.xNumberOfTicks
;
4495 this.xticks
=new Array();
4496 for(var i
=0;i
<=_78
.length
;i
++){
4497 if((_78
[i
]-this.minxval
)>=(_80
*_79
)){
4498 var pos
=this.xscale
*(_78
[i
]-this.minxval
);
4499 if((pos
>1)||(pos
<0)){
4502 this.xticks
.push([pos
,_78
[i
]]);
4505 if(_80
>this.options
.xNumberOfTicks
){
4512 PlotKit
.Layout
.prototype._evaluateLineTicksForYAxis
=function(){
4513 var _81
=MochiKit
.Base
.isUndefinedOrNull
;
4514 if(this.options
.yTicks
){
4515 this.yticks
=new Array();
4516 var _82
=function(_83
){
4519 _84
=_83
.v
.toString();
4521 var pos
=1-(this.yscale
*(_83
.v
-this.minyval
));
4522 if((pos
>=0)&&(pos
<=1)){
4523 this.yticks
.push([pos
,_84
]);
4526 MochiKit
.Iter
.forEach(this.options
.yTicks
,bind(_82
,this));
4528 if(this.options
.yNumberOfTicks
){
4529 this.yticks
=new Array();
4530 var _85
=PlotKit
.Base
.roundInterval
;
4531 var _86
=this.options
.yTickPrecision
;
4532 var _87
=_85(this.yrange
,this.options
.yNumberOfTicks
,_86
);
4533 for(var i
=0;i
<=this.options
.yNumberOfTicks
;i
++){
4534 var _88
=this.minyval
+(i
*_87
);
4535 var pos
=1-((_88
-this.minyval
)*this.yscale
);
4536 if((pos
>1)||(pos
<0)){
4539 this.yticks
.push([pos
,MochiKit
.Format
.roundToFixed(_88
,_86
)]);
4544 PlotKit
.Layout
.prototype._evaluateLineTicks
=function(){
4545 this._evaluateLineTicksForXAxis();
4546 this._evaluateLineTicksForYAxis();
4548 PlotKit
.LayoutModule
={};
4549 PlotKit
.LayoutModule
.Layout
=PlotKit
.Layout
;
4550 PlotKit
.LayoutModule
.EXPORT
=["Layout"];
4551 PlotKit
.LayoutModule
.EXPORT_OK
=[];
4552 PlotKit
.LayoutModule
.__new__
=function(){
4553 var m
=MochiKit
.Base
;
4554 m
.nameFunctions(this);
4555 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
4557 PlotKit
.LayoutModule
.__new__();
4558 MochiKit
.Base
._exportSymbols(this,PlotKit
.LayoutModule
);
4560 if((typeof (PlotKit
.Base
)=="undefined")||(typeof (PlotKit
.Layout
)=="undefined")){
4565 throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Base,Layout}";
4567 if(typeof (PlotKit
.CanvasRenderer
)=="undefined"){
4568 PlotKit
.CanvasRenderer
={};
4570 PlotKit
.CanvasRenderer
.NAME
="PlotKit.CanvasRenderer";
4571 PlotKit
.CanvasRenderer
.VERSION
=PlotKit
.VERSION
;
4572 PlotKit
.CanvasRenderer
.__repr__
=function(){
4573 return "["+this.NAME
+" "+this.VERSION
+"]";
4575 PlotKit
.CanvasRenderer
.toString
=function(){
4576 return this.__repr__();
4578 PlotKit
.CanvasRenderer
=function(_89
,_90
,_91
){
4579 if(arguments
.length
>0){
4580 this.__init__(_89
,_90
,_91
);
4583 PlotKit
.CanvasRenderer
.prototype.__init__
=function(_92
,_93
,_94
){
4584 var _95
=MochiKit
.Base
.isUndefinedOrNull
;
4585 var _96
=MochiKit
.Color
.Color
;
4586 this.options
={"drawBackground":true,"backgroundColor":_96
.whiteColor(),"padding":{left
:30,right
:30,top
:5,bottom
:10},"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[0]),"strokeColor":_96
.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":_96
.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":_96
.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"pieRadius":0.4,"enableEvents":true};
4587 MochiKit
.Base
.update(this.options
,_94
?_94
:{});
4589 this.element
=MochiKit
.DOM
.getElement(_92
);
4590 this.container
=this.element
.parentNode
;
4591 this.isIE
=PlotKit
.Base
.excanvasSupported();
4592 if(this.isIE
&&!_95(G_vmlCanvasManager
)){
4595 this.renderDelay
=null;
4596 this.clearDelay
=null;
4597 this.element
=G_vmlCanvasManager
.initElement(this.element
);
4599 this.height
=this.element
.height
;
4600 this.width
=this.element
.width
;
4601 if(_95(this.element
)){
4602 throw "CanvasRenderer() - passed canvas is not found";
4604 if(!this.isIE
&&!(PlotKit
.CanvasRenderer
.isSupported(this.element
))){
4605 throw "CanvasRenderer() - Canvas is not supported.";
4607 if(_95(this.container
)||(this.container
.nodeName
.toLowerCase()!="div")){
4608 throw "CanvasRenderer() - <canvas> needs to be enclosed in <div>";
4610 this.xlabels
=new Array();
4611 this.ylabels
=new Array();
4612 this.isFirstRender
=true;
4613 this.area
={x
:this.options
.padding
.left
,y
:this.options
.padding
.top
,w
:this.width
-this.options
.padding
.left
-this.options
.padding
.right
,h
:this.height
-this.options
.padding
.top
-this.options
.padding
.bottom
};
4614 MochiKit
.DOM
.updateNodeAttributes(this.container
,{"style":{"position":"relative","width":this.width
+"px"}});
4616 PlotKit
.CanvasRenderer
.prototype.render
=function(){
4619 if(this.renderDelay
){
4620 this.renderDelay
.cancel();
4621 this.renderDelay
=null;
4623 var _97
=this.element
.getContext("2d");
4626 this.isFirstRender
=false;
4627 if(this.maxTries
-->0){
4628 this.renderDelay
=MochiKit
.Async
.wait(this.IEDelay
);
4629 this.renderDelay
.addCallback(bind(this.render
,this));
4634 if(this.options
.drawBackground
){
4635 this._renderBackground();
4637 if(this.layout
.style
=="line"){
4638 this._renderLineChart();
4639 this._renderLineAxis();
4642 PlotKit
.CanvasRenderer
.prototype._renderLineChart
=function(){
4643 var _98
=this.element
.getContext("2d");
4644 var _99
=this.options
.colorScheme
.length
;
4645 var _100
=this.options
.colorScheme
;
4646 var _101
=MochiKit
.Base
.keys(this.layout
.datasets
);
4647 var _102
=_101
.length
;
4648 var bind
=MochiKit
.Base
.bind
;
4649 var _104
=MochiKit
.Base
.partial
;
4650 for(var i
=0;i
<_102
;i
++){
4652 var _106
=_100
[i
%_99
];
4653 var _107
=this.options
.strokeColorTransform
;
4655 _98
.fillStyle
=_106
.toRGBString();
4656 if(this.options
.strokeColor
){
4657 _98
.strokeStyle
=this.options
.strokeColor
.toRGBString();
4659 if(this.options
.strokeColorTransform
){
4660 _98
.strokeStyle
=_106
[_107
]().toRGBString();
4663 _98
.lineWidth
=this.options
.strokeWidth
;
4664 var _108
=function(ctx
){
4666 ctx
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
4667 var _110
=function(ctx_
,_112
){
4668 if(_112
.name
==_105
){
4669 ctx_
.lineTo(this.area
.w
*_112
.x
+this.area
.x
,this.area
.h
*_112
.y
+this.area
.y
);
4672 MochiKit
.Iter
.forEach(this.layout
.points
,_104(_110
,ctx
),this);
4673 ctx
.lineTo(this.area
.w
+this.area
.x
,this.area
.h
+this.area
.y
);
4674 ctx
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
4677 if(this.options
.shouldFill
){
4678 bind(_108
,this)(_98
);
4681 if(this.options
.shouldStroke
){
4682 bind(_108
,this)(_98
);
4688 PlotKit
.CanvasRenderer
.prototype._renderLineAxis
=function(){
4691 PlotKit
.CanvasRenderer
.prototype._renderAxis
=function(){
4692 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
4695 var _113
=this.element
.getContext("2d");
4696 var _114
={"style":{"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
.toRGBString(),"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"}};
4698 _113
.strokeStyle
=this.options
.axisLineColor
.toRGBString();
4699 _113
.lineWidth
=this.options
.axisLineWidth
;
4700 if(this.options
.drawYAxis
){
4701 if(this.layout
.yticks
){
4702 var _115
=function(tick
){
4703 if(typeof (tick
)=="function"){
4707 var y
=this.area
.y
+tick
[0]*this.area
.h
;
4710 _113
.lineTo(x
-this.options
.axisTickSize
,y
);
4713 var _118
=DIV(_114
,tick
[1]);
4714 _118
.style
.top
=(y
-this.options
.axisLabelFontSize
)+"px";
4715 _118
.style
.left
=(x
-this.options
.padding
.left
-this.options
.axisTickSize
)+"px";
4716 _118
.style
.textAlign
="right";
4717 _118
.style
.width
=(this.options
.padding
.left
-this.options
.axisTickSize
*2)+"px";
4718 MochiKit
.DOM
.appendChildNodes(this.container
,_118
);
4719 this.ylabels
.push(_118
);
4721 MochiKit
.Iter
.forEach(this.layout
.yticks
,bind(_115
,this));
4724 _113
.moveTo(this.area
.x
,this.area
.y
);
4725 _113
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
4729 if(this.options
.drawXAxis
){
4730 if(this.layout
.xticks
){
4731 var _115
=function(tick
){
4732 if(typeof (dataset
)=="function"){
4735 var x
=this.area
.x
+tick
[0]*this.area
.w
;
4736 var y
=this.area
.y
+this.area
.h
;
4739 _113
.lineTo(x
,y
+this.options
.axisTickSize
);
4742 var _119
=DIV(_114
,tick
[1]);
4743 _119
.style
.top
=(y
+this.options
.axisTickSize
)+"px";
4744 _119
.style
.left
=(x
-this.options
.axisLabelWidth
/2)+"px";
4745 _119
.style
.textAlign
="center";
4746 _119
.style
.width
=this.options
.axisLabelWidth
+"px";
4747 MochiKit
.DOM
.appendChildNodes(this.container
,_119
);
4748 this.xlabels
.push(_119
);
4750 MochiKit
.Iter
.forEach(this.layout
.xticks
,bind(_115
,this));
4753 _113
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
4754 _113
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
4760 PlotKit
.CanvasRenderer
.prototype._renderBackground
=function(){
4761 var _120
=this.element
.getContext("2d");
4763 _120
.fillStyle
=this.options
.backgroundColor
.toRGBString();
4764 _120
.fillRect(0,0,this.width
,this.height
);
4767 PlotKit
.CanvasRenderer
.prototype.clear
=function(){
4770 if(this.clearDelay
){
4771 this.clearDelay
.cancel();
4772 this.clearDelay
=null;
4774 var _121
=this.element
.getContext("2d");
4777 this.isFirstRender
=false;
4778 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
4779 this.clearDelay
.addCallback(bind(this.clear
,this));
4783 var _121
=this.element
.getContext("2d");
4784 _121
.clearRect(0,0,this.width
,this.height
);
4785 MochiKit
.Iter
.forEach(this.xlabels
,MochiKit
.DOM
.removeElement
);
4786 MochiKit
.Iter
.forEach(this.ylabels
,MochiKit
.DOM
.removeElement
);
4787 this.xlabels
=new Array();
4788 this.ylabels
=new Array();
4790 PlotKit
.CanvasRenderer
.prototype._initialiseEvents
=function(){
4791 var _122
=MochiKit
.Signal
.connect
;
4792 var bind
=MochiKit
.Base
.bind
;
4793 _122(this.element
,"onclick",bind(this.onclick
,this));
4795 PlotKit
.CanvasRenderer
.prototype._resolveObject
=function(e
){
4796 var x
=(e
.mouse().page
.x
-PlotKit
.Base
.findPosX(this.element
)-this.area
.x
)/this.area
.w
;
4797 var y
=(e
.mouse().page
.y
-PlotKit
.Base
.findPosY(this.element
)-this.area
.y
)/this.area
.h
;
4798 var _124
=this.layout
.hitTest(x
,y
);
4804 PlotKit
.CanvasRenderer
.prototype._createEventObject
=function(_125
,e
){
4811 PlotKit
.CanvasRenderer
.prototype.onclick
=function(e
){
4812 var _126
=this._resolveObject(e
);
4813 var _127
=this._createEventObject(_126
,e
);
4815 MochiKit
.Signal
.signal(this,"onclick",_127
);
4818 PlotKit
.CanvasRenderer
.prototype.onmouseover
=function(e
){
4819 var _128
=this._resolveObject(e
);
4820 var _129
=this._createEventObject(_128
,e
);
4822 signal(this,"onmouseover",_129
);
4825 PlotKit
.CanvasRenderer
.prototype.onmouseout
=function(e
){
4826 var _130
=this._resolveObject(e
);
4827 var _131
=this._createEventObject(_130
,e
);
4829 signal(this,"onmouseout",e
);
4831 signal(this,"onmouseout",_131
);
4834 PlotKit
.CanvasRenderer
.prototype.onmousemove
=function(e
){
4835 var _132
=this._resolveObject(e
);
4836 var _133
=this._createEventObject(_132
,e
);
4837 if((_132
==null)&&(this.event_isinside
==null)){
4840 if((_132
!=null)&&(this.event_isinside
==null)){
4841 signal(this,"onmouseover",_133
);
4843 if((_132
==null)&&(this.event_isinside
!=null)){
4844 signal(this,"onmouseout",_133
);
4846 if((_132
!=null)&&(this.event_isinside
!=null)){
4847 signal(this,"onmousemove",_133
);
4849 this.event_isinside
=_132
;
4851 PlotKit
.CanvasRenderer
.isSupported
=function(_134
){
4854 if(MochiKit
.Base
.isUndefinedOrNull(_134
)){
4855 _135
=MochiKit
.DOM
.CANVAS({});
4857 _135
=MochiKit
.DOM
.getElement(_134
);
4859 var _136
=_135
.getContext("2d");
4862 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
4863 var _138
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
4864 if((!ie
)||(ie
[1]<6)||(_138
)){
4872 PlotKit
.Canvas
.CanvasRenderer
=PlotKit
.CanvasRenderer
;
4873 PlotKit
.Canvas
.EXPORT
=["CanvasRenderer"];
4874 PlotKit
.Canvas
.EXPORT_OK
=["CanvasRenderer"];
4875 PlotKit
.Canvas
.__new__
=function(){
4876 var m
=MochiKit
.Base
;
4877 m
.nameFunctions(this);
4878 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
4880 PlotKit
.Canvas
.__new__();
4881 MochiKit
.Base
._exportSymbols(this,PlotKit
.Canvas
);
4884 DateGraphLayout
=function(_1
){
4885 PlotKit
.Layout
.call(this,"line",_1
);
4887 DateGraphLayout
.prototype=new PlotKit
.Layout();
4888 DateGraphLayout
.prototype.evaluateWithError
=function(){
4890 if(!this.options
.errorBars
){
4894 for(var _3
in this.datasets
){
4896 var _5
=this.datasets
[_3
];
4897 if(PlotKit
.Base
.isFuncLike(_5
)){
4900 for(var j
=0;j
<_5
.length
;j
++,i
++){
4902 var xv
=parseFloat(_6
[0]);
4903 var yv
=parseFloat(_6
[1]);
4904 if(xv
==this.points
[i
].xval
&&yv
==this.points
[i
].yval
){
4905 this.points
[i
].errorMinus
=parseFloat(_6
[2]);
4906 this.points
[i
].errorPlus
=parseFloat(_6
[3]);
4911 DateGraphLayout
.prototype.removeAllDatasets
=function(){
4912 delete this.datasets
;
4913 this.datasets
=new Array();
4915 DateGraphLayout
.prototype.updateOptions
=function(_9
){
4916 MochiKit
.Base
.update(this.options
,_9
?_9
:{});
4918 DateGraphCanvasRenderer
=function(_10
,_11
,_12
){
4919 PlotKit
.CanvasRenderer
.call(this,_10
,_11
,_12
);
4920 this.options
.shouldFill
=false;
4921 this.options
.shouldStroke
=true;
4922 this.options
.drawYGrid
=true;
4923 this.options
.drawXGrid
=true;
4924 this.options
.gridLineColor
=MochiKit
.Color
.Color
.grayColor();
4925 MochiKit
.Base
.update(this.options
,_12
);
4926 this.options
.drawBackground
=false;
4928 DateGraphCanvasRenderer
.prototype=new PlotKit
.CanvasRenderer();
4929 DateGraphCanvasRenderer
.prototype.render
=function(){
4930 this._renderLineChart();
4931 this._renderLineAxis();
4932 var ctx
=this.element
.getContext("2d");
4933 if(this.options
.drawYGrid
){
4934 var _14
=this.layout
.yticks
;
4936 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
4937 ctx
.lineWidth
=this.options
.axisLineWidth
;
4938 for(var i
=0;i
<_14
.length
;i
++){
4940 var y
=this.area
.y
+_14
[i
][0]*this.area
.h
;
4943 ctx
.lineTo(x
+this.area
.w
,y
);
4948 if(this.options
.drawXGrid
){
4949 var _14
=this.layout
.xticks
;
4951 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
4952 ctx
.lineWidth
=this.options
.axisLineWidth
;
4953 for(var i
=0;i
<_14
.length
;i
++){
4954 var x
=this.area
.x
+_14
[i
][0]*this.area
.w
;
4955 var y
=this.area
.y
+this.area
.h
;
4958 ctx
.lineTo(x
,this.area
.y
);
4964 DateGraphCanvasRenderer
.prototype._renderLineChart
=function(){
4965 var _17
=this.element
.getContext("2d");
4966 var _18
=this.options
.colorScheme
.length
;
4967 var _19
=this.options
.colorScheme
;
4968 var _20
=MochiKit
.Base
.keys(this.layout
.datasets
);
4969 var _21
=this.layout
.options
.errorBars
;
4971 var _23
=MochiKit
.Base
.bind
;
4972 var _24
=MochiKit
.Base
.partial
;
4973 var _25
=function(_26
){
4974 _26
.canvasx
=this.area
.w
*_26
.x
+this.area
.x
;
4975 _26
.canvasy
=this.area
.h
*_26
.y
+this.area
.y
;
4977 MochiKit
.Iter
.forEach(this.layout
.points
,_25
,this);
4978 var _27
=function(ctx
){
4979 for(var i
=0;i
<_22
;i
++){
4982 var _30
=this.options
.strokeColorTransform
;
4984 _17
.strokeStyle
=_29
.toRGBString();
4985 _17
.lineWidth
=this.options
.strokeWidth
;
4987 var _31
=this.layout
.points
[0];
4989 var _33
=function(_34
,_31
){
4992 _34
.moveTo(_31
.canvasx
,_31
.canvasy
);
4994 _34
.lineTo(_31
.canvasx
,_31
.canvasy
);
4999 MochiKit
.Iter
.forEach(this.layout
.points
,_24(_33
,ctx
),this);
5003 var _35
=function(ctx
){
5004 for(var i
=0;i
<_22
;i
++){
5007 var _38
=this.options
.strokeColorTransform
;
5009 _17
.strokeStyle
=_37
.toRGBString();
5010 _17
.lineWidth
=this.options
.strokeWidth
;
5014 var _42
=this.layout
.yscale
;
5015 var _43
=function(_44
,_45
){
5018 var _46
=[_45
.y
-_45
.errorPlus
*_42
,_45
.y
+_45
.errorMinus
*_42
];
5019 _46
[0]=this.area
.h
*_46
[0]+this.area
.y
;
5020 _46
[1]=this.area
.h
*_46
[1]+this.area
.y
;
5022 _44
.moveTo(_39
,_40
[0]);
5023 _44
.lineTo(_45
.canvasx
,_46
[0]);
5024 _44
.lineTo(_45
.canvasx
,_46
[1]);
5025 _44
.lineTo(_39
,_40
[1]);
5033 var _47
=_37
.colorWithAlpha(0.15);
5034 ctx
.fillStyle
=_47
.toRGBString();
5036 MochiKit
.Iter
.forEach(this.layout
.points
,_24(_43
,ctx
),this);
5046 DateGraph
=function(div
,_49
,_50
,_51
){
5047 if(arguments
.length
>0){
5048 this.__init__(div
,_49
,_50
,_51
);
5051 DateGraph
.NAME
="DateGraph";
5052 DateGraph
.VERSION
="1.1";
5053 DateGraph
.__repr__
=function(){
5054 return "["+this.NAME
+" "+this.VERSION
+"]";
5056 DateGraph
.toString
=function(){
5057 return this.__repr__();
5059 DateGraph
.DEFAULT_ROLL_PERIOD
=1;
5060 DateGraph
.DEFAULT_WIDTH
=480;
5061 DateGraph
.DEFAULT_HEIGHT
=320;
5062 DateGraph
.DEFAULT_STROKE_WIDTH
=1;
5063 DateGraph
.AXIS_LINE_WIDTH
=0.3;
5064 DateGraph
.prototype.__init__
=function(div
,_52
,_53
,_54
){
5068 this.rollPeriod_
=_54
.rollPeriod
||DateGraph
.DEFAULT_ROLL_PERIOD
;
5069 this.previousVerticalX_
=-1;
5070 this.width_
=parseInt(div
.style
.width
,10);
5071 this.height_
=parseInt(div
.style
.height
,10);
5072 this.errorBars_
=_54
.errorBars
||false;
5073 this.fractions_
=_54
.fractions
||false;
5074 this.strokeWidth_
=_54
.strokeWidth
||DateGraph
.DEFAULT_STROKE_WIDTH
;
5075 this.dateWindow_
=_54
.dateWindow
||null;
5076 this.valueRange_
=_54
.valueRange
||null;
5077 this.labelsSeparateLines
=_54
.labelsSeparateLines
||false;
5078 this.labelsDiv_
=_54
.labelsDiv
||null;
5079 this.labelsKMB_
=_54
.labelsKMB
||false;
5080 this.minTickSize_
=_54
.minTickSize
||0;
5081 this.xValueParser_
=_54
.xValueParser
||DateGraph
.prototype.dateParser
;
5082 this.xValueFormatter_
=_54
.xValueFormatter
||DateGraph
.prototype.dateString_
;
5083 this.xTicker_
=_54
.xTicker
||DateGraph
.prototype.dateTicker
;
5084 this.sigma_
=_54
.sigma
||2;
5085 this.wilsonInterval_
=_54
.wilsonInterval
||true;
5086 this.customBars_
=_54
.customBars
||false;
5088 this.labelsFromCSV_
=(this.labels_
==null);
5089 if(this.labels_
==null){
5092 this.clickCallback_
=_54
.clickCallback
||null;
5093 this.zoomCallback_
=_54
.zoomCallback
||null;
5094 this.createInterface_();
5095 this.layoutOptions_
={"errorBars":(this.errorBars_
||this.customBars_
),"xOriginIsZero":false};
5096 MochiKit
.Base
.update(this.layoutOptions_
,_54
);
5097 this.setColors_(_54
);
5098 this.layout_
=new DateGraphLayout(this.layoutOptions_
);
5099 this.renderOptions_
={colorScheme
:this.colors_
,strokeColor
:null,strokeWidth
:this.strokeWidth_
,axisLabelFontSize
:14,axisLineWidth
:DateGraph
.AXIS_LINE_WIDTH
};
5100 MochiKit
.Base
.update(this.renderOptions_
,_54
);
5101 this.plotter_
=new DateGraphCanvasRenderer(this.hidden_
,this.layout_
,this.renderOptions_
);
5102 this.createStatusMessage_();
5103 this.createRollInterface_();
5104 this.createDragInterface_();
5105 connect(window
,"onload",this,function(e
){
5109 DateGraph
.prototype.rollPeriod
=function(){
5110 return this.rollPeriod_
;
5112 DateGraph
.prototype.createInterface_
=function(){
5113 var _56
=this.maindiv_
;
5114 this.graphDiv
=MochiKit
.DOM
.DIV({style
:{"width":this.width_
+"px","height":this.height_
+"px"}});
5115 appendChildNodes(_56
,this.graphDiv
);
5116 var _57
=MochiKit
.DOM
.CANVAS
;
5117 this.canvas_
=_57({style
:{"position":"absolute"},width
:this.width_
,height
:this.height_
});
5118 appendChildNodes(this.graphDiv
,this.canvas_
);
5119 this.hidden_
=this.createPlotKitCanvas_(this.canvas_
);
5120 connect(this.hidden_
,"onmousemove",this,function(e
){
5123 connect(this.hidden_
,"onmouseout",this,function(e
){
5127 DateGraph
.prototype.createPlotKitCanvas_
=function(_58
){
5128 var h
=document
.createElement("canvas");
5129 h
.style
.position
="absolute";
5130 h
.style
.top
=_58
.style
.top
;
5131 h
.style
.left
=_58
.style
.left
;
5132 h
.width
=this.width_
;
5133 h
.height
=this.height_
;
5134 MochiKit
.DOM
.appendChildNodes(this.graphDiv
,h
);
5137 DateGraph
.prototype.setColors_
=function(_60
){
5138 var num
=this.labels_
.length
;
5141 var sat
=_60
.colorSaturation
||1;
5142 var val
=_60
.colorValue
||0.5;
5143 for(var i
=1;i
<=num
;i
++){
5144 var hue
=(1*i
/(1+num
));
5145 this.colors_
.push(MochiKit
.Color
.Color
.fromHSV(hue
,sat
,val
));
5148 for(var i
=0;i
<num
;i
++){
5149 var _65
=_60
.colors
[i
%_60
.colors
.length
];
5150 this.colors_
.push(MochiKit
.Color
.Color
.fromString(_65
));
5154 DateGraph
.prototype.createStatusMessage_
=function(){
5155 if(!this.labelsDiv_
){
5157 var _67
={"style":{"position":"absolute","fontSize":"14px","zIndex":10,"width":_66
+"px","top":"0px","left":this.width_
-_66
+"px","background":"white","textAlign":"left","overflow":"hidden"}};
5158 this.labelsDiv_
=MochiKit
.DOM
.DIV(_67
);
5159 MochiKit
.DOM
.appendChildNodes(this.graphDiv
,this.labelsDiv_
);
5162 DateGraph
.prototype.createRollInterface_
=function(){
5163 var _68
=this.plotter_
.options
.padding
;
5164 var _69
={"type":"text","size":"2","value":this.rollPeriod_
,"style":{"position":"absolute","zIndex":10,"top":(this.height_
-25-_68
.bottom
)+"px","left":(_68
.left
+1)+"px"}};
5165 var _70
=MochiKit
.DOM
.INPUT(_69
);
5166 var pa
=this.graphDiv
;
5167 MochiKit
.DOM
.appendChildNodes(pa
,_70
);
5168 connect(_70
,"onchange",this,function(){
5169 this.adjustRoll(_70
.value
);
5173 DateGraph
.prototype.createDragInterface_
=function(){
5181 var px
=PlotKit
.Base
.findPosX(this.canvas_
);
5182 var py
=PlotKit
.Base
.findPosY(this.canvas_
);
5183 var _81
=function(e
){
5184 return e
.mouse().page
.x
-px
;
5186 var _82
=function(e
){
5187 return e
.mouse().page
.y
-py
;
5189 connect(this.hidden_
,"onmousemove",function(_83
){
5193 _72
.drawZoomRect_(_74
,_76
,_78
);
5197 connect(this.hidden_
,"onmousedown",function(_84
){
5202 connect(document
,"onmouseup",this,function(_85
){
5209 connect(this.hidden_
,"onmouseout",this,function(_86
){
5215 connect(this.hidden_
,"onmouseup",this,function(_87
){
5220 var _88
=Math
.abs(_76
-_74
);
5221 var _89
=Math
.abs(_77
-_75
);
5222 if(_88
<2&&_89
<2&&_72
.clickCallback_
!=null&&_72
.lastx_
!=undefined
){
5223 _72
.clickCallback_(_87
,new Date(_72
.lastx_
));
5226 _72
.doZoom_(Math
.min(_74
,_76
),Math
.max(_74
,_76
));
5228 _72
.canvas_
.getContext("2d").clearRect(0,0,_72
.canvas_
.width
,_72
.canvas_
.height
);
5234 connect(this.hidden_
,"ondblclick",this,function(_90
){
5235 _72
.dateWindow_
=null;
5236 _72
.drawGraph_(_72
.rawData_
);
5237 var _91
=_72
.rawData_
[0][0];
5238 var _92
=_72
.rawData_
[_72
.rawData_
.length
-1][0];
5239 _72
.zoomCallback_(_91
,_92
);
5242 DateGraph
.prototype.drawZoomRect_
=function(_93
,_94
,_95
){
5243 var ctx
=this.canvas_
.getContext("2d");
5245 ctx
.clearRect(Math
.min(_93
,_95
),0,Math
.abs(_93
-_95
),this.height_
);
5248 ctx
.fillStyle
="rgba(128,128,128,0.33)";
5249 ctx
.fillRect(Math
.min(_93
,_94
),0,Math
.abs(_94
-_93
),this.height_
);
5252 DateGraph
.prototype.doZoom_
=function(_96
,_97
){
5253 var _98
=this.layout_
.points
;
5256 for(var i
=0;i
<_98
.length
;i
++){
5257 var cx
=_98
[i
].canvasx
;
5259 if(cx
<_96
&&(_99
==null||x
>_99
)){
5262 if(cx
>_97
&&(_100
==null||x
<_100
)){
5270 _100
=_98
[_98
.length
-1].xval
;
5272 this.dateWindow_
=[_99
,_100
];
5273 this.drawGraph_(this.rawData_
);
5274 this.zoomCallback_(_99
,_100
);
5276 DateGraph
.prototype.mouseMove_
=function(_102
){
5277 var _103
=_102
.mouse().page
.x
-PlotKit
.Base
.findPosX(this.hidden_
);
5278 var _104
=this.layout_
.points
;
5283 for(var i
=0;i
<_104
.length
;i
++){
5284 var dist
=Math
.abs(_104
[i
].canvasx
-_103
);
5292 _105
=_104
[idx
].xval
;
5294 if(_103
>_104
[_104
.length
-1].canvasx
){
5295 _105
=_104
[_104
.length
-1].xval
;
5298 for(var i
=0;i
<_104
.length
;i
++){
5299 if(_104
[i
].xval
==_105
){
5304 var ctx
=this.canvas_
.getContext("2d");
5305 if(this.previousVerticalX_
>=0){
5306 var px
=this.previousVerticalX_
;
5307 ctx
.clearRect(px
-_111
-1,0,2*_111
+2,this.height_
);
5310 var _103
=_110
[0].canvasx
;
5311 var _112
=this.xValueFormatter_(_105
)+":";
5312 var clen
=this.colors_
.length
;
5313 for(var i
=0;i
<_110
.length
;i
++){
5314 if(this.labelsSeparateLines
){
5318 _112
+=" <b><font color='"+this.colors_
[i
%clen
].toHexString()+"'>"+_114
.name
+"</font></b>:"+this.round_(_114
.yval
,2);
5320 this.labelsDiv_
.innerHTML
=_112
;
5323 for(var i
=0;i
<_110
.length
;i
++){
5325 ctx
.fillStyle
=this.colors_
[i
%clen
].toRGBString();
5326 ctx
.arc(_103
,_110
[i
%clen
].canvasy
,_111
,0,360,false);
5330 this.previousVerticalX_
=_103
;
5333 DateGraph
.prototype.mouseOut_
=function(_115
){
5334 var ctx
=this.canvas_
.getContext("2d");
5335 ctx
.clearRect(0,0,this.width_
,this.height_
);
5336 this.labelsDiv_
.innerHTML
="";
5338 DateGraph
.prototype.dateString_
=function(date
){
5339 var d
=new Date(date
);
5340 var year
=""+d
.getFullYear();
5341 var _119
=""+(d
.getMonth()+1);
5345 var day
=""+d
.getDate();
5349 return year
+"/"+_119+"/"+day
;
5351 DateGraph
.prototype.round_
=function(num
,_121
){
5352 var _122
=Math
.pow(10,_121
);
5353 return Math
.round(num
*_122
)/_122
;
5355 DateGraph
.prototype.loadedEvent_
=function(data
){
5356 this.rawData_
=this.parseCSV_(data
);
5357 this.drawGraph_(this.rawData_
);
5359 DateGraph
.prototype.months
=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
5360 DateGraph
.prototype.quarters
=["Jan","Apr","Jul","Oct"];
5361 DateGraph
.prototype.addXTicks_
=function(){
5363 if(this.dateWindow_
){
5364 _124
=this.dateWindow_
[0];
5365 endDate
=this.dateWindow_
[1];
5367 _124
=this.rawData_
[0][0];
5368 endDate
=this.rawData_
[this.rawData_
.length
-1][0];
5370 var _125
=this.xTicker_(_124
,endDate
);
5371 this.layout_
.updateOptions({xTicks
:_125
});
5373 DateGraph
.prototype.dateTicker
=function(_126
,_127
){
5374 var _128
=24*60*60*1000;
5399 for(var week
=_126
-14;week
<_127
+14;week
+=7){
5400 _130
.push(week
*_128
);
5403 for(var day
=_126
-14;day
<_127
+14;day
+=1){
5404 _130
.push(day
*_128
);
5413 var _135
=1900+(new Date(_126
*_128
)).getYear();
5414 var _136
=1900+(new Date(_127
*_128
)).getYear();
5415 for(var i
=_135
;i
<=_136
;i
++){
5419 for(var j
=0;j
<_130
.length
;j
++){
5420 var date
=Date
.parse(_130
[j
]+" 1, "+i
);
5421 _134
.push({label
:_130
[j
]+"'"+(""+i
).substr(2,2),v
:date
});
5425 for(var i
=0;i
<_130
.length
;i
++){
5426 var date
=new Date(_130
[i
]);
5427 var year
=date
.getFullYear().toString();
5428 var _137
=this.months
[date
.getMonth()]+date
.getDate();
5429 _137
+="'"+year
.substr(year
.length
-2,2);
5430 _134
.push({label
:_137
,v
:date
});
5435 DateGraph
.prototype.numericTicks
=function(minV
,maxV
){
5440 _140
=Math
.pow(10,Math
.floor(Math
.log(maxV
)/Math
.log(10)));
5442 var _141
=(maxV
-minV
)/_140
;
5446 if((maxV
-minV
)/_141
<this.minTickSize_
){
5447 _141
=this.round_((maxV
-minV
)/this.minTickSize_
,1);
5450 for(var i
=0;i
<=_141
;i
++){
5451 var _143
=minV
+i
*(maxV
-minV
)/_141
;
5452 var _144
=this.round_(_143
,2);
5453 if(this.labelsKMB_
){
5456 _144
=this.round_(_143
/(k
*k
*k
),1)+"B";
5459 _144
=this.round_(_143
/(k
*k
),1)+"M";
5462 _144
=this.round_(_143
/k
,1)+"K";
5467 _142
.push({label
:_144
,v
:_143
});
5471 DateGraph
.prototype.addYTicks_
=function(minY
,maxY
){
5472 var _148
=this.numericTicks(minY
,maxY
);
5473 this.layout_
.updateOptions({yAxis
:[minY
,maxY
],yTicks
:_148
});
5475 DateGraph
.prototype.drawGraph_
=function(data
){
5477 this.layout_
.removeAllDatasets();
5478 for(var i
=1;i
<data
[0].length
;i
++){
5480 for(var j
=0;j
<data
.length
;j
++){
5481 var date
=data
[j
][0];
5482 _149
[j
]=[date
,data
[j
][i
]];
5484 _149
=this.rollingAverage(_149
,this.rollPeriod_
);
5485 var bars
=this.errorBars_
||this.customBars_
;
5486 if(this.dateWindow_
){
5487 var low
=this.dateWindow_
[0];
5488 var high
=this.dateWindow_
[1];
5490 for(var k
=0;k
<_149
.length
;k
++){
5491 if(_149
[k
][0]>=low
&&_149
[k
][0]<=high
){
5493 var y
=bars
?_149
[k
][1][0]:_149
[k
][1];
5494 if(maxY
==null||y
>maxY
){
5501 for(var j
=0;j
<_149
.length
;j
++){
5502 var y
=bars
?_149
[j
][1][0]:_149
[j
][1];
5503 if(maxY
==null||y
>maxY
){
5504 maxY
=bars
?y
+_149
[j
][1][1]:y
;
5510 for(var j
=0;j
<_149
.length
;j
++){
5511 vals
[j
]=[_149
[j
][0],_149
[j
][1][0],_149
[j
][1][1],_149
[j
][1][2]];
5513 this.layout_
.addDataset(this.labels_
[i
-1],vals
);
5515 this.layout_
.addDataset(this.labels_
[i
-1],_149
);
5518 if(this.valueRange_
!=null){
5519 this.addYTicks_(this.valueRange_
[0],this.valueRange_
[1]);
5525 var _155
=Math
.pow(10,Math
.floor(Math
.log(maxY
)/Math
.log(10)));
5526 maxY
=_155
*Math
.ceil(maxY
/_155
);
5528 this.addYTicks_(0,maxY
);
5531 this.layout_
.evaluateWithError();
5532 this.plotter_
.clear();
5533 this.plotter_
.render();
5534 this.canvas_
.getContext("2d").clearRect(0,0,this.canvas_
.width
,this.canvas_
.height
);
5536 DateGraph
.prototype.rollingAverage
=function(_156
,_157
){
5540 var _157
=Math
.min(_157
,_156
.length
-1);
5542 var _159
=this.sigma_
;
5543 if(this.fractions_
){
5547 for(var i
=0;i
<_156
.length
;i
++){
5551 num
-=_156
[i
-_157
][1][0];
5552 den
-=_156
[i
-_157
][1][1];
5554 var date
=_156
[i
][0];
5555 var _162
=den
?num
/den
:0;
5556 if(this.errorBars_
){
5557 if(this.wilsonInterval_
){
5559 var p
=_162
<0?0:_162
,n
=den
;
5560 var pm
=_159
*Math
.sqrt(p
*(1-p
)/n+_159*_159/(4*n
*n
));
5561 var _165
=1+_159
*_159
/den
;
5562 var low
=(p
+_159
*_159
/(2*den)-pm)/_165
;
5563 var high
=(p
+_159
*_159
/(2*den)+pm)/_165
;
5564 _158
[i
]=[date
,[p
*mult
,(p
-low
)*mult
,(high
-p
)*mult
]];
5566 _158
[i
]=[date
,[0,0,0]];
5569 var _166
=den
?_159
*Math
.sqrt(_162
*(1-_162
)/den
):1;
5570 _158
[i
]=[date
,[mult
*_162
,mult
*_166
,mult
*_166
]];
5573 _158
[i
]=[date
,mult
*_162
];
5577 if(this.customBars_
){
5578 for(var i
=0;i
<_156
.length
;i
++){
5579 var data
=_156
[i
][1];
5581 _158
[i
]=[_156
[i
][0],[y
,y
-data
[0],data
[2]-y
]];
5584 var _167
=Math
.min(_157
-1,_156
.length
-2);
5585 if(!this.errorBars_
){
5586 for(var i
=0;i
<_167
;i
++){
5588 for(var j
=0;j
<i
+1;j
++){
5591 _158
[i
]=[_156
[i
][0],sum
/(i
+1)];
5593 for(var i
=Math
.min(_157
-1,_156
.length
-2);i
<_156
.length
;i
++){
5595 for(var j
=i
-_157
+1;j
<i
+1;j
++){
5598 _158
[i
]=[_156
[i
][0],sum
/_157
];
5601 for(var i
=0;i
<_167
;i
++){
5604 for(var j
=0;j
<i
+1;j
++){
5606 _169
+=Math
.pow(_156
[j
][1][1],2);
5608 var _166
=Math
.sqrt(_169
)/(i
+1);
5609 _158
[i
]=[_156
[i
][0],[sum
/(i
+1),_159
*_166
,_159
*_166
]];
5611 for(var i
=Math
.min(_157
-1,_156
.length
-2);i
<_156
.length
;i
++){
5614 for(var j
=i
-_157
+1;j
<i
+1;j
++){
5616 _169
+=Math
.pow(_156
[j
][1][1],2);
5618 var _166
=Math
.sqrt(_169
)/_157
;
5619 _158
[i
]=[_156
[i
][0],[sum
/_157
,_159
*_166
,_159
*_166
]];
5626 DateGraph
.prototype.dateParser
=function(_170
){
5628 if(_170
.search("-")!=-1){
5629 _171
=_170
.replace("-","/","g");
5631 if(_170
.search("/")!=-1){
5632 return Date
.parse(_170
);
5634 _171
=_170
.substr(0,4)+"/"+_170.substr(4,2)+"/"+_170
.substr(6,2);
5637 return Date
.parse(_171
);
5639 DateGraph
.prototype.parseCSV_
=function(data
){
5641 var _173
=data
.split("\n");
5642 var _174
=this.labelsFromCSV_
?1:0;
5643 if(this.labelsFromCSV_
){
5644 var _175
=_173
[0].split(",");
5647 this.setColors_(this.attrs_
);
5648 this.renderOptions_
.colorScheme
=this.colors_
;
5649 MochiKit
.Base
.update(this.plotter_
.options
,this.renderOptions_
);
5650 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
5652 for(var i
=_174
;i
<_173
.length
;i
++){
5657 var _177
=line
.split(",");
5662 _178
[0]=this.xValueParser_(_177
[0]);
5663 if(this.fractions_
){
5664 for(var j
=1;j
<_177
.length
;j
++){
5665 var vals
=_177
[j
].split("/");
5666 _178
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1])];
5669 if(this.errorBars_
){
5670 for(var j
=1;j
<_177
.length
;j
+=2){
5671 _178
[(j
+1)/2]=[parseFloat(_177
[j
]),parseFloat(_177
[j
+1])];
5674 if(this.customBars_
){
5675 for(var j
=1;j
<_177
.length
;j
++){
5676 var vals
=_177
[j
].split(";");
5677 _178
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1]),parseFloat(vals
[2])];
5680 for(var j
=1;j
<_177
.length
;j
++){
5681 _178
[j
]=parseFloat(_177
[j
]);
5690 DateGraph
.prototype.start_
=function(){
5691 if(typeof this.file_
=="function"){
5692 this.loadedEvent_(this.file_());
5694 var req
=new XMLHttpRequest();
5696 req
.onreadystatechange
=function(){
5697 if(req
.readyState
==4){
5698 if(req
.status
==200){
5699 _180
.loadedEvent_(req
.responseText
);
5703 req
.open("GET",this.file_
,true);
5707 DateGraph
.prototype.updateOptions
=function(_181
){
5709 this.errorBars_
=_181
.errorBars
;
5711 if(_181
.customBars
){
5712 this.customBars_
=_181
.customBars
;
5714 if(_181
.strokeWidth
){
5715 this.strokeWidth_
=_181
.strokeWidth
;
5717 if(_181
.rollPeriod
){
5718 this.rollPeriod_
=_181
.rollPeriod
;
5720 if(_181
.dateWindow
){
5721 this.dateWindow_
=_181
.dateWindow
;
5723 if(_181
.valueRange
){
5724 this.valueRange_
=_181
.valueRange
;
5726 if(_181
.minTickSize
){
5727 this.minTickSize_
=_181
.minTickSize
;
5729 if(typeof (_181
.labels
)!="undefined"){
5730 this.labels_
=_181
.labels
;
5731 this.labelsFromCSV_
=(_181
.labels
==null);
5733 this.layout_
.updateOptions({"errorBars":this.errorBars_
});
5734 if(_181
["file"]&&_181
["file"]!=this.file_
){
5735 this.file_
=_181
["file"];
5738 this.drawGraph_(this.rawData_
);
5741 DateGraph
.prototype.adjustRoll
=function(_182
){
5742 this.rollPeriod_
=_182
;
5743 this.drawGraph_(this.rawData_
);