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.DOM");
1618 dojo
.require("MochiKit.Base");
1620 if(typeof (JSAN
)!="undefined"){
1621 JSAN
.use("MochiKit.Base",[]);
1624 if(typeof (MochiKit
.Base
)=="undefined"){
1629 throw "MochiKit.DOM depends on MochiKit.Base!";
1631 if(typeof (MochiKit
.DOM
)=="undefined"){
1634 MochiKit
.DOM
.NAME
="MochiKit.DOM";
1635 MochiKit
.DOM
.VERSION
="1.4";
1636 MochiKit
.DOM
.__repr__
=function(){
1637 return "["+this.NAME
+" "+this.VERSION
+"]";
1639 MochiKit
.DOM
.toString
=function(){
1640 return this.__repr__();
1642 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"];
1643 MochiKit
.DOM
.EXPORT_OK
=["domConverters"];
1644 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"]];
1645 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);");
1646 MochiKit
.Base
.update(MochiKit
.DOM
,{currentWindow
:function(){
1647 return MochiKit
.DOM
._window
;
1648 },currentDocument
:function(){
1649 return MochiKit
.DOM
._document
;
1650 },withWindow
:function(win
,func
){
1651 var self
=MochiKit
.DOM
;
1652 var _1e8
=self
._document
;
1653 var _1e9
=self
._window
;
1657 self
._document
=win
.document
;
1662 self
._document
=_1e8
;
1666 self
._document
=_1e8
;
1668 },formContents
:function(elem
){
1671 var m
=MochiKit
.Base
;
1672 var self
=MochiKit
.DOM
;
1673 if(typeof (elem
)=="undefined"||elem
===null){
1674 elem
=self
._document
.body
;
1676 elem
=self
.getElement(elem
);
1678 m
.nodeWalk(elem
,function(elem
){
1680 if(m
.isNotEmpty(name
)){
1681 var _1f2
=elem
.tagName
.toUpperCase();
1682 if(_1f2
==="INPUT"&&(elem
.type
=="radio"||elem
.type
=="checkbox")&&!elem
.checked
){
1685 if(_1f2
==="SELECT"){
1686 if(elem
.type
=="select-one"){
1687 if(elem
.selectedIndex
>=0){
1688 var opt
=elem
.options
[elem
.selectedIndex
];
1691 var h
=opt
.outerHTML
;
1692 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
1704 var opts
=elem
.options
;
1710 for(var i
=0;i
<opts
.length
;i
++){
1717 var h
=opt
.outerHTML
;
1718 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
1728 if(_1f2
==="FORM"||_1f2
==="P"||_1f2
==="SPAN"||_1f2
==="DIV"){
1729 return elem
.childNodes
;
1732 _1ed
.push(elem
.value
||"");
1735 return elem
.childNodes
;
1738 },withDocument
:function(doc
,func
){
1739 var self
=MochiKit
.DOM
;
1740 var _1fb
=self
._document
;
1747 self
._document
=_1fb
;
1750 self
._document
=_1fb
;
1752 },registerDOMConverter
:function(name
,_1fe
,wrap
,_200
){
1753 MochiKit
.DOM
.domConverters
.register(name
,_1fe
,wrap
,_200
);
1754 },coerceToDOM
:function(node
,ctx
){
1755 var m
=MochiKit
.Base
;
1756 var im
=MochiKit
.Iter
;
1757 var self
=MochiKit
.DOM
;
1763 var _209
=self
.domConverters
;
1764 var _20a
=arguments
.callee
;
1765 var _20b
=m
.NotFound
;
1767 if(typeof (node
)=="undefined"||node
===null){
1770 if(typeof (node
)=="function"&&typeof (node
.length
)=="number"&&!(node
instanceof Function
)){
1773 if(typeof (node
.nodeType
)!="undefined"&&node
.nodeType
>0){
1776 if(typeof (node
)=="number"||typeof (node
)=="boolean"){
1777 node
=node
.toString();
1779 if(typeof (node
)=="string"){
1780 return self
._document
.createTextNode(node
);
1782 if(typeof (node
.__dom__
)=="function"){
1783 node
=node
.__dom__(ctx
);
1786 if(typeof (node
.dom
)=="function"){
1790 if(typeof (node
)=="function"){
1791 node
=node
.apply(ctx
,[ctx
]);
1802 return map(_20a
,_20c
,_207(ctx
));
1806 node
=_209
.match(node
,ctx
);
1814 return self
._document
.createTextNode(node
.toString());
1817 },isChildNode
:function(node
,_20e
){
1818 var self
=MochiKit
.DOM
;
1819 if(typeof (node
)=="string"){
1820 node
=self
.getElement(node
);
1822 if(typeof (_20e
)=="string"){
1823 _20e
=self
.getElement(_20e
);
1828 while(node
&&node
.tagName
.toUpperCase()!="BODY"){
1829 node
=node
.parentNode
;
1835 },setNodeAttribute
:function(node
,attr
,_212
){
1839 return MochiKit
.DOM
.updateNodeAttributes(node
,o
);
1844 },getNodeAttribute
:function(node
,attr
){
1845 var self
=MochiKit
.DOM
;
1846 var _217
=self
.attributeArray
.renames
[attr
];
1847 node
=self
.getElement(node
);
1852 return node
.getAttribute(attr
);
1857 },removeNodeAttribute
:function(node
,attr
){
1858 var self
=MochiKit
.DOM
;
1859 var _21b
=self
.attributeArray
.renames
[attr
];
1860 node
=self
.getElement(node
);
1865 return node
.removeAttribute(attr
);
1870 },updateNodeAttributes
:function(node
,_21d
){
1872 var self
=MochiKit
.DOM
;
1873 if(typeof (node
)=="string"){
1874 elem
=self
.getElement(node
);
1877 var _220
=MochiKit
.Base
.updatetree
;
1878 if(self
.attributeArray
.compliant
){
1881 if(typeof (v
)=="object"&&typeof (elem
[k
])=="object"){
1882 if(k
=="style"&&MochiKit
.Style
){
1883 MochiKit
.Style
.setStyle(elem
,v
);
1888 if(k
.substring(0,2)=="on"){
1889 if(typeof (v
)=="string"){
1894 elem
.setAttribute(k
,v
);
1899 var _223
=self
.attributeArray
.renames
;
1903 if(k
=="style"&&typeof (v
)=="string"){
1904 elem
.style
.cssText
=v
;
1906 if(typeof (_224
)=="string"){
1909 if(typeof (elem
[k
])=="object"&&typeof (v
)=="object"){
1910 if(k
=="style"&&MochiKit
.Style
){
1911 MochiKit
.Style
.setStyle(elem
,v
);
1916 if(k
.substring(0,2)=="on"){
1917 if(typeof (v
)=="string"){
1922 elem
.setAttribute(k
,v
);
1931 },appendChildNodes
:function(node
){
1933 var self
=MochiKit
.DOM
;
1934 if(typeof (node
)=="string"){
1935 elem
=self
.getElement(node
);
1937 var _228
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1938 var _229
=MochiKit
.Base
.concat
;
1941 if(typeof (n
)=="undefined"||n
===null){
1943 if(typeof (n
.nodeType
)=="number"){
1944 elem
.appendChild(n
);
1951 },insertSiblingNodesBefore
:function(node
){
1953 var self
=MochiKit
.DOM
;
1954 if(typeof (node
)=="string"){
1955 elem
=self
.getElement(node
);
1957 var _22e
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1958 var _22f
=elem
.parentNode
;
1959 var _230
=MochiKit
.Base
.concat
;
1962 if(typeof (n
)=="undefined"||n
===null){
1964 if(typeof (n
.nodeType
)=="number"){
1965 _22f
.insertBefore(n
,elem
);
1972 },insertSiblingNodesAfter
:function(node
){
1974 var self
=MochiKit
.DOM
;
1975 if(typeof (node
)=="string"){
1976 elem
=self
.getElement(node
);
1978 var _235
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1979 if(elem
.nextSibling
){
1980 return self
.insertSiblingNodesBefore(elem
.nextSibling
,_235
);
1982 return self
.appendChildNodes(elem
.parentNode
,_235
);
1984 },replaceChildNodes
:function(node
){
1986 var self
=MochiKit
.DOM
;
1987 if(typeof (node
)=="string"){
1988 elem
=self
.getElement(node
);
1992 while((_239
=elem
.firstChild
)){
1993 elem
.removeChild(_239
);
1995 if(arguments
.length
<2){
1998 return self
.appendChildNodes
.apply(this,arguments
);
2000 },createDOM
:function(name
,_23b
){
2002 var self
=MochiKit
.DOM
;
2003 var m
=MochiKit
.Base
;
2004 if(typeof (_23b
)=="string"||typeof (_23b
)=="number"){
2005 var args
=m
.extend([name
,null],arguments
,1);
2006 return arguments
.callee
.apply(this,args
);
2008 if(typeof (name
)=="string"){
2009 var _240
=self
._xhtml
;
2010 if(_23b
&&!self
.attributeArray
.compliant
){
2013 _241
+=" name=\""+self
.escapeHTML(_23b
.name
)+"\"";
2015 if(name
=="input"&&"type" in _23b
){
2016 _241
+=" type=\""+self
.escapeHTML(_23b
.type
)+"\"";
2019 name
="<"+name
+_241
+">";
2023 var d
=self
._document
;
2024 if(_240
&&d
===document
){
2025 elem
=d
.createElementNS("http://www.w3.org/1999/xhtml",name
);
2027 elem
=d
.createElement(name
);
2033 self
.updateNodeAttributes(elem
,_23b
);
2035 if(arguments
.length
<=2){
2038 var args
=m
.extend([elem
],arguments
,2);
2039 return self
.appendChildNodes
.apply(this,args
);
2041 },createDOMFunc
:function(){
2042 var m
=MochiKit
.Base
;
2043 return m
.partial
.apply(this,m
.extend([MochiKit
.DOM
.createDOM
],arguments
));
2044 },removeElement
:function(elem
){
2045 var e
=MochiKit
.DOM
.getElement(elem
);
2046 e
.parentNode
.removeChild(e
);
2048 },swapDOM
:function(dest
,src
){
2049 var self
=MochiKit
.DOM
;
2050 dest
=self
.getElement(dest
);
2051 var _249
=dest
.parentNode
;
2053 src
=self
.getElement(src
);
2054 _249
.replaceChild(src
,dest
);
2056 _249
.removeChild(dest
);
2059 },getElement
:function(id
){
2060 var self
=MochiKit
.DOM
;
2061 if(arguments
.length
==1){
2062 return ((typeof (id
)=="string")?self
._document
.getElementById(id
):id
);
2064 return MochiKit
.Base
.map(self
.getElement
,arguments
);
2066 },getElementsByTagAndClassName
:function(_24c
,_24d
,_24e
){
2067 var self
=MochiKit
.DOM
;
2068 if(typeof (_24c
)=="undefined"||_24c
===null){
2071 if(typeof (_24e
)=="undefined"||_24e
===null){
2072 _24e
=self
._document
;
2074 _24e
=self
.getElement(_24e
);
2075 var _250
=(_24e
.getElementsByTagName(_24c
)||self
._document
.all
);
2076 if(typeof (_24d
)=="undefined"||_24d
===null){
2077 return MochiKit
.Base
.extend(null,_250
);
2080 for(var i
=0;i
<_250
.length
;i
++){
2082 var cls
=_253
.className
;
2086 var _255
=cls
.split(" ");
2087 for(var j
=0;j
<_255
.length
;j
++){
2095 },_newCallStack
:function(path
,once
){
2096 var rval
=function(){
2097 var _25a
=arguments
.callee
.callStack
;
2098 for(var i
=0;i
<_25a
.length
;i
++){
2099 if(_25a
[i
].apply(this,arguments
)===false){
2113 },addToCallStack
:function(_25c
,path
,func
,once
){
2114 var self
=MochiKit
.DOM
;
2115 var _261
=_25c
[path
];
2117 if(!(typeof (_261
)=="function"&&typeof (_261
.callStack
)=="object"&&_261
.callStack
!==null)){
2118 _262
=self
._newCallStack(path
,once
);
2119 if(typeof (_261
)=="function"){
2120 _262
.callStack
.push(_261
);
2124 _262
.callStack
.push(func
);
2125 },addLoadEvent
:function(func
){
2126 var self
=MochiKit
.DOM
;
2127 self
.addToCallStack(self
._window
,"onload",func
,true);
2128 },focusOnLoad
:function(_265
){
2129 var self
=MochiKit
.DOM
;
2130 self
.addLoadEvent(function(){
2131 _265
=self
.getElement(_265
);
2136 },setElementClass
:function(_267
,_268
){
2137 var self
=MochiKit
.DOM
;
2138 var obj
=self
.getElement(_267
);
2139 if(self
.attributeArray
.compliant
){
2140 obj
.setAttribute("class",_268
);
2142 obj
.setAttribute("className",_268
);
2144 },toggleElementClass
:function(_26b
){
2145 var self
=MochiKit
.DOM
;
2146 for(var i
=1;i
<arguments
.length
;i
++){
2147 var obj
=self
.getElement(arguments
[i
]);
2148 if(!self
.addElementClass(obj
,_26b
)){
2149 self
.removeElementClass(obj
,_26b
);
2152 },addElementClass
:function(_26f
,_270
){
2153 var self
=MochiKit
.DOM
;
2154 var obj
=self
.getElement(_26f
);
2155 var cls
=obj
.className
;
2156 if(cls
==undefined
||cls
.length
===0){
2157 self
.setElementClass(obj
,_270
);
2163 var _274
=cls
.split(" ");
2164 for(var i
=0;i
<_274
.length
;i
++){
2169 self
.setElementClass(obj
,cls
+" "+_270
);
2171 },removeElementClass
:function(_276
,_277
){
2172 var self
=MochiKit
.DOM
;
2173 var obj
=self
.getElement(_276
);
2174 var cls
=obj
.className
;
2175 if(cls
==undefined
||cls
.length
===0){
2179 self
.setElementClass(obj
,"");
2182 var _27b
=cls
.split(" ");
2183 for(var i
=0;i
<_27b
.length
;i
++){
2186 self
.setElementClass(obj
,_27b
.join(" "));
2191 },swapElementClass
:function(_27d
,_27e
,_27f
){
2192 var obj
=MochiKit
.DOM
.getElement(_27d
);
2193 var res
=MochiKit
.DOM
.removeElementClass(obj
,_27e
);
2195 MochiKit
.DOM
.addElementClass(obj
,_27f
);
2198 },hasElementClass
:function(_282
,_283
){
2199 var obj
=MochiKit
.DOM
.getElement(_282
);
2200 var cls
=obj
.className
;
2204 var _286
=cls
.split(" ");
2205 for(var i
=1;i
<arguments
.length
;i
++){
2207 for(var j
=0;j
<_286
.length
;j
++){
2208 if(_286
[j
]==arguments
[i
]){
2218 },escapeHTML
:function(s
){
2219 return s
.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");
2220 },toHTML
:function(dom
){
2221 return MochiKit
.DOM
.emitHTML(dom
).join("");
2222 },emitHTML
:function(dom
,lst
){
2223 if(typeof (lst
)=="undefined"||lst
===null){
2227 var self
=MochiKit
.DOM
;
2228 var _290
=self
.escapeHTML
;
2229 var _291
=self
.attributeArray
;
2232 if(typeof (dom
)=="string"){
2235 if(dom
.nodeType
==1){
2236 lst
.push("<"+dom
.tagName
.toLowerCase());
2239 for(var i
=0;i
<_293
.length
;i
++){
2241 _292
.push([" ",a
.name
,"=\"",_290(a
.value
),"\""]);
2244 for(i
=0;i
<_292
.length
;i
++){
2246 for(var j
=0;j
<_296
.length
;j
++){
2250 if(dom
.hasChildNodes()){
2252 _28e
.push("</"+dom
.tagName
.toLowerCase()+">");
2253 var _298
=dom
.childNodes
;
2254 for(i
=_298
.length
-1;i
>=0;i
--){
2261 if(dom
.nodeType
==3){
2262 lst
.push(_290(dom
.nodeValue
));
2268 },scrapeText
:function(node
,_29a
){
2271 var cn
=node
.childNodes
;
2273 for(var i
=0;i
<cn
.length
;i
++){
2274 arguments
.callee
.call(this,cn
[i
]);
2277 var _29f
=node
.nodeValue
;
2278 if(typeof (_29f
)=="string"){
2281 })(MochiKit
.DOM
.getElement(node
));
2285 return rval
.join("");
2287 },removeEmptyTextNodes
:function(_2a0
){
2288 _2a0
=MochiKit
.DOM
.getElement(_2a0
);
2289 for(var i
=0;i
<_2a0
.childNodes
.length
;i
++){
2290 var node
=_2a0
.childNodes
[i
];
2291 if(node
.nodeType
==3&&!/\S/.test(node
.nodeValue
)){
2292 node
.parentNode
.removeChild(node
);
2295 },makeClipping
:function(_2a3
){
2296 _2a3
=MochiKit
.DOM
.getElement(_2a3
);
2297 var _2a4
=_2a3
.style
.overflow
;
2298 if((MochiKit
.Style
.getStyle(_2a3
,"overflow")||"visible")!="hidden"){
2299 _2a3
.style
.overflow
="hidden";
2302 },undoClipping
:function(_2a5
,_2a6
){
2303 _2a5
=MochiKit
.DOM
.getElement(_2a5
);
2307 _2a5
.style
.overflow
=_2a6
;
2308 },makePositioned
:function(_2a7
){
2309 _2a7
=MochiKit
.DOM
.getElement(_2a7
);
2310 var pos
=MochiKit
.Style
.getStyle(_2a7
,"position");
2311 if(pos
=="static"||!pos
){
2312 _2a7
.style
.position
="relative";
2313 if(/Opera/.test(navigator
.userAgent
)){
2318 },undoPositioned
:function(_2a9
){
2319 _2a9
=MochiKit
.DOM
.getElement(_2a9
);
2320 if(_2a9
.style
.position
=="relative"){
2321 _2a9
.style
.position
=_2a9
.style
.top
=_2a9
.style
.left
=_2a9
.style
.bottom
=_2a9
.style
.right
="";
2323 },getFirstElementByTagAndClassName
:function(_2aa
,_2ab
,_2ac
){
2324 var self
=MochiKit
.DOM
;
2325 if(typeof (_2aa
)=="undefined"||_2aa
===null){
2328 if(typeof (_2ac
)=="undefined"||_2ac
===null){
2329 _2ac
=self
._document
;
2331 _2ac
=self
.getElement(_2ac
);
2332 var _2ae
=(_2ac
.getElementsByTagName(_2aa
)||self
._document
.all
);
2333 if(typeof (_2ab
)=="undefined"||_2ab
===null){
2336 for(var i
=0;i
<_2ae
.length
;i
++){
2338 var _2b1
=_2b0
.className
.split(" ");
2339 for(var j
=0;j
<_2b1
.length
;j
++){
2345 },getFirstParentByTagAndClassName
:function(elem
,_2b4
,_2b5
){
2346 var self
=MochiKit
.DOM
;
2347 elem
=self
.getElement(elem
);
2348 if(typeof (_2b4
)=="undefined"||_2b4
===null){
2351 _2b4
=_2b4
.toUpperCase();
2353 if(typeof (_2b5
)=="undefined"||_2b5
===null){
2358 while(elem
&&elem
.tagName
){
2359 elem
=elem
.parentNode
;
2360 if(_2b4
=="*"&&_2b5
===null){
2363 _2b7
=elem
.className
.split(" ");
2364 _2b8
=elem
.tagName
.toUpperCase();
2365 if(_2b5
===null&&_2b4
==_2b8
){
2369 for(var i
=0;i
<_2b7
.length
;i
++){
2370 if(_2b4
=="*"&&_2b7
[i
]==_2b5
){
2373 if(_2b4
==_2b8
&&_2b7
[i
]==_2b5
){
2382 },isParent
:function(_2ba
,_2bb
){
2383 if(!_2ba
.parentNode
||_2ba
==_2bb
){
2386 if(_2ba
.parentNode
==_2bb
){
2389 return MochiKit
.DOM
.isParent(_2ba
.parentNode
,_2bb
);
2390 },__new__
:function(win
){
2391 var m
=MochiKit
.Base
;
2392 if(typeof (document
)!="undefined"){
2393 this._document
=document
;
2394 var _2be
="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
2395 this._xhtml
=(document
.documentElement
&&document
.createElementNS
&&document
.documentElement
.namespaceURI
===_2be
);
2397 if(MochiKit
.MockDOM
){
2398 this._document
=MochiKit
.MockDOM
.document
;
2402 this.domConverters
=new m
.AdapterRegistry();
2403 var _2bf
=this._document
.createElement("span");
2405 if(_2bf
&&_2bf
.attributes
&&_2bf
.attributes
.length
>0){
2407 _2c0
=function(node
){
2408 return _2c1(_2c0
.ignoreAttrFilter
,node
.attributes
);
2411 var _2c3
=_2bf
.attributes
;
2412 var _2c4
=_2c0
.ignoreAttr
;
2413 for(var i
=0;i
<_2c3
.length
;i
++){
2415 _2c4
[a
.name
]=a
.value
;
2417 _2c0
.ignoreAttrFilter
=function(a
){
2418 return (_2c0
.ignoreAttr
[a
.name
]!=a
.value
);
2420 _2c0
.compliant
=false;
2421 _2c0
.renames
={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"};
2423 _2c0
=function(node
){
2424 return node
.attributes
;
2426 _2c0
.compliant
=true;
2429 this.attributeArray
=_2c0
;
2430 var _2c9
=function(_2ca
,arr
){
2431 var _2cc
=arr
[1].split(".");
2434 str
+="if (!MochiKit."+_2cc
[1]+") { throw new Error(\"";
2435 str
+="This function has been deprecated and depends on MochiKit.";
2436 str
+=_2cc
[1]+".\");}";
2437 str
+="return MochiKit."+_2cc
[1]+"."+arr
[0];
2438 str
+=".apply(this, arguments);";
2439 obj
[_2cc
[2]]=new Function(str
);
2440 MochiKit
.Base
.update(MochiKit
[_2ca
],obj
);
2442 for(var i
;i
<MochiKit
.DOM
.DEPRECATED
.length
;i
++){
2443 _2c9("DOM",MochiKit
.DOM
.DEPRECATED
[i
]);
2445 var _2cf
=this.createDOMFunc
;
2451 this.TBODY
=_2cf("tbody");
2452 this.THEAD
=_2cf("thead");
2453 this.TFOOT
=_2cf("tfoot");
2454 this.TABLE
=_2cf("table");
2456 this.INPUT
=_2cf("input");
2457 this.SPAN
=_2cf("span");
2459 this.DIV
=_2cf("div");
2460 this.IMG
=_2cf("img");
2461 this.BUTTON
=_2cf("button");
2463 this.PRE
=_2cf("pre");
2469 this.LABEL
=_2cf("label");
2470 this.TEXTAREA
=_2cf("textarea");
2471 this.FORM
=_2cf("form");
2473 this.SELECT
=_2cf("select");
2474 this.OPTION
=_2cf("option");
2475 this.OPTGROUP
=_2cf("optgroup");
2476 this.LEGEND
=_2cf("legend");
2477 this.FIELDSET
=_2cf("fieldset");
2478 this.STRONG
=_2cf("strong");
2479 this.CANVAS
=_2cf("canvas");
2480 this.$=this.getElement
;
2481 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
2482 m
.nameFunctions(this);
2484 MochiKit
.DOM
.__new__(((typeof (window
)=="undefined")?this:window
));
2485 if(MochiKit
.__export__
){
2486 withWindow
=MochiKit
.DOM
.withWindow
;
2487 withDocument
=MochiKit
.DOM
.withDocument
;
2489 MochiKit
.Base
._exportSymbols(this,MochiKit
.DOM
);
2490 if(typeof (dojo
)!="undefined"){
2491 dojo
.provide("MochiKit.Style");
2492 dojo
.require("MochiKit.Base");
2493 dojo
.require("MochiKit.DOM");
2495 if(typeof (JSAN
)!="undefined"){
2496 JSAN
.use("MochiKit.Base",[]);
2497 JSAN
.use("MochiKit.DOM",[]);
2500 if(typeof (MochiKit
.Base
)=="undefined"){
2505 throw "MochiKit.Style depends on MochiKit.Base!";
2508 if(typeof (MochiKit
.DOM
)=="undefined"){
2513 throw "MochiKit.Style depends on MochiKit.DOM!";
2515 if(typeof (MochiKit
.Style
)=="undefined"){
2518 MochiKit
.Style
.NAME
="MochiKit.Style";
2519 MochiKit
.Style
.VERSION
="1.4";
2520 MochiKit
.Style
.__repr__
=function(){
2521 return "["+this.NAME
+" "+this.VERSION
+"]";
2523 MochiKit
.Style
.toString
=function(){
2524 return this.__repr__();
2526 MochiKit
.Style
.EXPORT_OK
=[];
2527 MochiKit
.Style
.EXPORT
=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
2528 MochiKit
.Style
.Dimensions
=function(w
,h
){
2532 MochiKit
.Style
.Dimensions
.prototype.__repr__
=function(){
2533 var repr
=MochiKit
.Base
.repr
;
2534 return "{w: "+repr(this.w
)+", h: "+repr(this.h
)+"}";
2536 MochiKit
.Style
.Dimensions
.prototype.toString
=function(){
2537 return this.__repr__();
2539 MochiKit
.Style
.Coordinates
=function(x
,y
){
2543 MochiKit
.Style
.Coordinates
.prototype.__repr__
=function(){
2544 var repr
=MochiKit
.Base
.repr
;
2545 return "{x: "+repr(this.x
)+", y: "+repr(this.y
)+"}";
2547 MochiKit
.Style
.Coordinates
.prototype.toString
=function(){
2548 return this.__repr__();
2550 MochiKit
.Base
.update(MochiKit
.Style
,{getStyle
:function(elem
,_2d7
){
2551 var dom
=MochiKit
.DOM
;
2552 var d
=dom
._document
;
2553 elem
=dom
.getElement(elem
);
2554 _2d7
=MochiKit
.Base
.camelize(_2d7
);
2558 if(_2d7
=="opacity"&&elem
.filters
){
2559 var _2da
=(MochiKit
.Style
.getStyle(elem
,"filter")||"").match(/alpha\(opacity=(.*)\)/);
2561 return parseFloat(_2da
[1])/100;
2565 var _2db
=elem
.style
?elem
.style
[_2d7
]:null;
2567 if(d
.defaultView
&&d
.defaultView
.getComputedStyle
){
2568 var css
=d
.defaultView
.getComputedStyle(elem
,null);
2569 _2d7
=_2d7
.replace(/([A-Z])/g,"-$1").toLowerCase();
2570 _2db
=css
?css
.getPropertyValue(_2d7
):null;
2572 if(elem
.currentStyle
){
2573 _2db
=elem
.currentStyle
[_2d7
];
2577 if(_2d7
=="opacity"){
2578 _2db
=parseFloat(_2db
);
2580 if(/Opera/.test(navigator
.userAgent
)&&(MochiKit
.Base
.find(["left","top","right","bottom"],_2d7
)!=-1)){
2581 if(MochiKit
.Style
.getStyle(elem
,"position")=="static"){
2585 return _2db
=="auto"?null:_2db
;
2586 },setStyle
:function(elem
,_2de
){
2587 elem
=MochiKit
.DOM
.getElement(elem
);
2588 for(var name
in _2de
){
2589 if(name
=="opacity"){
2590 MochiKit
.Style
.setOpacity(elem
,_2de
[name
]);
2592 elem
.style
[MochiKit
.Base
.camelize(name
)]=_2de
[name
];
2595 },setOpacity
:function(elem
,o
){
2596 elem
=MochiKit
.DOM
.getElement(elem
);
2597 var self
=MochiKit
.Style
;
2599 var _2e3
=/Gecko/.test(navigator
.userAgent
)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator
.userAgent
));
2600 elem
.style
["opacity"]=_2e3
?0.999999:1;
2601 if(/MSIE/.test(navigator
.userAgent
)){
2602 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"");
2608 elem
.style
["opacity"]=o
;
2609 if(/MSIE/.test(navigator
.userAgent
)){
2610 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o
*100+")";
2613 },getElementPosition
:function(elem
,_2e5
){
2614 var self
=MochiKit
.Style
;
2615 var dom
=MochiKit
.DOM
;
2616 elem
=dom
.getElement(elem
);
2617 if(!elem
||(!(elem
.x
&&elem
.y
)&&(!elem
.parentNode
===null||self
.getStyle(elem
,"display")=="none"))){
2620 var c
=new self
.Coordinates(0,0);
2623 var d
=MochiKit
.DOM
._document
;
2624 var de
=d
.documentElement
;
2626 if(!elem
.parentNode
&&elem
.x
&&elem
.y
){
2630 if(elem
.getBoundingClientRect
){
2631 box
=elem
.getBoundingClientRect();
2632 c
.x
+=box
.left
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
2633 c
.y
+=box
.top
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
2635 if(elem
.offsetParent
){
2636 c
.x
+=elem
.offsetLeft
;
2637 c
.y
+=elem
.offsetTop
;
2638 _2ea
=elem
.offsetParent
;
2641 c
.x
+=_2ea
.offsetLeft
;
2642 c
.y
+=_2ea
.offsetTop
;
2643 _2ea
=_2ea
.offsetParent
;
2646 var ua
=navigator
.userAgent
.toLowerCase();
2647 if((typeof (opera
)!="undefined"&&parseFloat(opera
.version())<9)||(ua
.indexOf("AppleWebKit")!=-1&&self
.getStyle(elem
,"position")=="absolute")){
2654 if(typeof (_2e5
)!="undefined"){
2655 _2e5
=arguments
.callee(_2e5
);
2661 if(elem
.parentNode
){
2662 _2ea
=elem
.parentNode
;
2667 var _2ef
=_2ea
.tagName
.toUpperCase();
2668 if(_2ef
==="BODY"||_2ef
==="HTML"){
2671 var disp
=self
.getStyle(_2ea
,"display");
2672 if(disp
!="inline"&&disp
!="table-row"){
2673 c
.x
-=_2ea
.scrollLeft
;
2674 c
.y
-=_2ea
.scrollTop
;
2676 if(_2ea
.parentNode
){
2677 _2ea
=_2ea
.parentNode
;
2683 },setElementPosition
:function(elem
,_2f2
,_2f3
){
2684 elem
=MochiKit
.DOM
.getElement(elem
);
2685 if(typeof (_2f3
)=="undefined"){
2689 var _2f5
=MochiKit
.Base
.isUndefinedOrNull
;
2691 _2f4
["left"]=_2f2
.x
+_2f3
;
2694 _2f4
["top"]=_2f2
.y
+_2f3
;
2696 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_2f4
});
2697 },getElementDimensions
:function(elem
){
2698 var self
=MochiKit
.Style
;
2699 var dom
=MochiKit
.DOM
;
2700 if(typeof (elem
.w
)=="number"||typeof (elem
.h
)=="number"){
2701 return new self
.Dimensions(elem
.w
||0,elem
.h
||0);
2703 elem
=dom
.getElement(elem
);
2707 var disp
=self
.getStyle(elem
,"display");
2708 if(disp
!="none"&&disp
!==""&&typeof (disp
)!="undefined"){
2709 return new self
.Dimensions(elem
.offsetWidth
||0,elem
.offsetHeight
||0);
2712 var _2fb
=s
.visibility
;
2713 var _2fc
=s
.position
;
2714 s
.visibility
="hidden";
2715 s
.position
="absolute";
2717 var _2fd
=elem
.offsetWidth
;
2718 var _2fe
=elem
.offsetHeight
;
2722 return new self
.Dimensions(_2fd
,_2fe
);
2723 },setElementDimensions
:function(elem
,_300
,_301
){
2724 elem
=MochiKit
.DOM
.getElement(elem
);
2725 if(typeof (_301
)=="undefined"){
2729 var _303
=MochiKit
.Base
.isUndefinedOrNull
;
2731 _302
["width"]=_300
.w
+_301
;
2734 _302
["height"]=_300
.h
+_301
;
2736 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_302
});
2737 },setDisplayForElement
:function(_304
,_305
){
2738 var _306
=MochiKit
.Base
.extend(null,arguments
,1);
2739 var _307
=MochiKit
.DOM
.getElement
;
2740 for(var i
=0;i
<_306
.length
;i
++){
2743 _305
.style
.display
=_304
;
2746 },getViewportDimensions
:function(){
2747 var d
=new MochiKit
.Style
.Dimensions();
2748 var w
=MochiKit
.DOM
._window
;
2749 var b
=MochiKit
.DOM
._document
.body
;
2754 if(b
.parentElement
.clientWidth
){
2755 d
.w
=b
.parentElement
.clientWidth
;
2756 d
.h
=b
.parentElement
.clientHeight
;
2758 if(b
&&b
.clientWidth
){
2765 },getViewportPosition
:function(){
2766 var c
=new MochiKit
.Style
.Coordinates(0,0);
2767 var d
=MochiKit
.DOM
._document
;
2768 var de
=d
.documentElement
;
2770 if(de
&&(de
.scrollTop
||de
.scrollLeft
)){
2780 },__new__
:function(){
2781 var m
=MochiKit
.Base
;
2782 this.elementPosition
=this.getElementPosition
;
2783 this.elementDimensions
=this.getElementDimensions
;
2784 this.hideElement
=m
.partial(this.setDisplayForElement
,"none");
2785 this.showElement
=m
.partial(this.setDisplayForElement
,"block");
2786 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
2787 m
.nameFunctions(this);
2789 MochiKit
.Style
.__new__();
2790 MochiKit
.Base
._exportSymbols(this,MochiKit
.Style
);
2791 if(typeof (dojo
)!="undefined"){
2792 dojo
.provide("MochiKit.Color");
2793 dojo
.require("MochiKit.Base");
2794 dojo
.require("MochiKit.DOM");
2795 dojo
.require("MochiKit.Style");
2797 if(typeof (JSAN
)!="undefined"){
2798 JSAN
.use("MochiKit.Base",[]);
2799 JSAN
.use("MochiKit.DOM",[]);
2800 JSAN
.use("MochiKit.Style",[]);
2803 if(typeof (MochiKit
.Base
)=="undefined"){
2808 throw "MochiKit.Color depends on MochiKit.Base";
2811 if(typeof (MochiKit
.DOM
)=="undefined"){
2816 throw "MochiKit.Color depends on MochiKit.DOM";
2819 if(typeof (MochiKit
.Style
)=="undefined"){
2824 throw "MochiKit.Color depends on MochiKit.Style";
2826 if(typeof (MochiKit
.Color
)=="undefined"){
2829 MochiKit
.Color
.NAME
="MochiKit.Color";
2830 MochiKit
.Color
.VERSION
="1.4";
2831 MochiKit
.Color
.__repr__
=function(){
2832 return "["+this.NAME
+" "+this.VERSION
+"]";
2834 MochiKit
.Color
.toString
=function(){
2835 return this.__repr__();
2837 MochiKit
.Color
.Color
=function(red
,_312
,blue
,_314
){
2838 if(typeof (_314
)=="undefined"||_314
===null){
2841 this.rgb
={r
:red
,g
:_312
,b
:blue
,a
:_314
};
2843 MochiKit
.Color
.Color
.prototype={__class__
:MochiKit
.Color
.Color
,colorWithAlpha
:function(_315
){
2845 var m
=MochiKit
.Color
;
2846 return m
.Color
.fromRGB(rgb
.r
,rgb
.g
,rgb
.b
,_315
);
2847 },colorWithHue
:function(hue
){
2848 var hsl
=this.asHSL();
2850 var m
=MochiKit
.Color
;
2851 return m
.Color
.fromHSL(hsl
);
2852 },colorWithSaturation
:function(_31b
){
2853 var hsl
=this.asHSL();
2855 var m
=MochiKit
.Color
;
2856 return m
.Color
.fromHSL(hsl
);
2857 },colorWithLightness
:function(_31e
){
2858 var hsl
=this.asHSL();
2860 var m
=MochiKit
.Color
;
2861 return m
.Color
.fromHSL(hsl
);
2862 },darkerColorWithLevel
:function(_321
){
2863 var hsl
=this.asHSL();
2864 hsl
.l
=Math
.max(hsl
.l
-_321
,0);
2865 var m
=MochiKit
.Color
;
2866 return m
.Color
.fromHSL(hsl
);
2867 },lighterColorWithLevel
:function(_324
){
2868 var hsl
=this.asHSL();
2869 hsl
.l
=Math
.min(hsl
.l
+_324
,1);
2870 var m
=MochiKit
.Color
;
2871 return m
.Color
.fromHSL(hsl
);
2872 },blendedColor
:function(_327
,_328
){
2873 if(typeof (_328
)=="undefined"||_328
===null){
2880 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
));
2881 },compareRGB
:function(_32d
){
2884 return MochiKit
.Base
.compare([a
.r
,a
.g
,a
.b
,a
.a
],[b
.r
,b
.g
,b
.b
,b
.a
]);
2885 },isLight
:function(){
2886 return this.asHSL().b
>0.5;
2887 },isDark
:function(){
2888 return (!this.isLight());
2889 },toHSLString
:function(){
2891 var ccc
=MochiKit
.Color
.clampColorComponent
;
2892 var rval
=this._hslString
;
2894 var mid
=(ccc(c
.h
,360).toFixed(0)+","+ccc(c
.s
,100).toPrecision(4)+"%"+","+ccc(c
.l
,100).toPrecision(4)+"%");
2898 rval
="hsl("+mid
+")";
2903 rval
="hsla("+mid
+","+a
+")";
2905 this._hslString
=rval
;
2908 },toRGBString
:function(){
2910 var ccc
=MochiKit
.Color
.clampColorComponent
;
2911 var rval
=this._rgbString
;
2913 var mid
=(ccc(c
.r
,255).toFixed(0)+","+ccc(c
.g
,255).toFixed(0)+","+ccc(c
.b
,255).toFixed(0));
2915 rval
="rgba("+mid
+","+c
.a
+")";
2917 rval
="rgb("+mid
+")";
2919 this._rgbString
=rval
;
2923 return MochiKit
.Base
.clone(this.rgb
);
2924 },toHexString
:function(){
2925 var m
=MochiKit
.Color
;
2927 var ccc
=MochiKit
.Color
.clampColorComponent
;
2928 var rval
=this._hexString
;
2930 rval
=("#"+m
.toColorPart(ccc(c
.r
,255))+m
.toColorPart(ccc(c
.g
,255))+m
.toColorPart(ccc(c
.b
,255)));
2931 this._hexString
=rval
;
2937 if(typeof (hsv
)=="undefined"||hsv
===null){
2938 hsv
=MochiKit
.Color
.rgbToHSV(this.rgb
);
2941 return MochiKit
.Base
.clone(hsv
);
2945 if(typeof (hsl
)=="undefined"||hsl
===null){
2946 hsl
=MochiKit
.Color
.rgbToHSL(this.rgb
);
2949 return MochiKit
.Base
.clone(hsl
);
2950 },toString
:function(){
2951 return this.toRGBString();
2954 var col
=[c
.r
,c
.g
,c
.b
,c
.a
];
2955 return this.__class__
.NAME
+"("+col
.join(", ")+")";
2957 MochiKit
.Base
.update(MochiKit
.Color
.Color
,{fromRGB
:function(red
,_344
,blue
,_346
){
2958 var _347
=MochiKit
.Color
.Color
;
2959 if(arguments
.length
==1){
2964 if(typeof (rgb
.a
)=="undefined"){
2970 return new _347(red
,_344
,blue
,_346
);
2971 },fromHSL
:function(hue
,_34a
,_34b
,_34c
){
2972 var m
=MochiKit
.Color
;
2973 return m
.Color
.fromRGB(m
.hslToRGB
.apply(m
,arguments
));
2974 },fromHSV
:function(hue
,_34f
,_350
,_351
){
2975 var m
=MochiKit
.Color
;
2976 return m
.Color
.fromRGB(m
.hsvToRGB
.apply(m
,arguments
));
2977 },fromName
:function(name
){
2978 var _354
=MochiKit
.Color
.Color
;
2979 if(name
.charAt(0)=="\""){
2980 name
=name
.substr(1,name
.length
-2);
2982 var _355
=_354
._namedColors
[name
.toLowerCase()];
2983 if(typeof (_355
)=="string"){
2984 return _354
.fromHexString(_355
);
2986 if(name
=="transparent"){
2987 return _354
.transparentColor();
2991 },fromString
:function(_356
){
2992 var self
=MochiKit
.Color
.Color
;
2993 var _358
=_356
.substr(0,3);
2995 return self
.fromRGBString(_356
);
2998 return self
.fromHSLString(_356
);
3000 if(_356
.charAt(0)=="#"){
3001 return self
.fromHexString(_356
);
3005 return self
.fromName(_356
);
3006 },fromHexString
:function(_359
){
3007 if(_359
.charAt(0)=="#"){
3008 _359
=_359
.substring(1);
3014 hex
=_359
.substr(i
,1);
3015 _35a
.push(parseInt(hex
+hex
,16)/255);
3019 hex
=_359
.substr(i
,2);
3020 _35a
.push(parseInt(hex
,16)/255);
3023 var _35d
=MochiKit
.Color
.Color
;
3024 return _35d
.fromRGB
.apply(_35d
,_35a
);
3025 },_fromColorString
:function(pre
,_35f
,_360
,_361
){
3026 if(_361
.indexOf(pre
)===0){
3027 _361
=_361
.substring(_361
.indexOf("(",3)+1,_361
.length
-1);
3029 var _362
=_361
.split(/\s*,\s*/);
3031 for(var i
=0;i
<_362
.length
;i
++){
3034 var _367
=c
.substring(c
.length
-3);
3035 if(c
.charAt(c
.length
-1)=="%"){
3036 val
=0.01*parseFloat(c
.substring(0,c
.length
-1));
3039 val
=parseFloat(c
)/360;
3042 val
=parseFloat(c
)/(Math
.PI
*2);
3044 val
=_360
[i
]*parseFloat(c
);
3050 return this[_35f
].apply(this,_363
);
3051 },fromComputedStyle
:function(elem
,_369
){
3053 var cls
=MochiKit
.Color
.Color
;
3054 for(elem
=d
.getElement(elem
);elem
;elem
=elem
.parentNode
){
3055 var _36c
=MochiKit
.Style
.getStyle
.apply(d
,arguments
);
3059 var _36d
=cls
.fromString(_36c
);
3063 if(_36d
.asRGB().a
>0){
3068 },fromBackground
:function(elem
){
3069 var cls
=MochiKit
.Color
.Color
;
3070 return cls
.fromComputedStyle(elem
,"backgroundColor","background-color")||cls
.whiteColor();
3071 },fromText
:function(elem
){
3072 var cls
=MochiKit
.Color
.Color
;
3073 return cls
.fromComputedStyle(elem
,"color","color")||cls
.blackColor();
3074 },namedColors
:function(){
3075 return MochiKit
.Base
.clone(MochiKit
.Color
.Color
._namedColors
);
3077 MochiKit
.Base
.update(MochiKit
.Color
,{clampColorComponent
:function(v
,_373
){
3088 },_hslValue
:function(n1
,n2
,hue
){
3104 val
=n1
+(n2
-n1
)*(4-hue
);
3111 },hsvToRGB
:function(hue
,_379
,_37a
,_37b
){
3112 if(arguments
.length
==1){
3127 var i
=Math
.floor(hue
*6);
3129 var p
=_37a
*(1-_379
);
3130 var q
=_37a
*(1-(_379
*f
));
3131 var t
=_37a
*(1-(_379
*(1-f
)));
3166 return {r
:red
,g
:_37e
,b
:blue
,a
:_37b
};
3167 },hslToRGB
:function(hue
,_386
,_387
,_388
){
3168 if(arguments
.length
==1){
3187 m2
=_387
+_386
-(_387
*_386
);
3190 var f
=MochiKit
.Color
._hslValue
;
3196 return {r
:red
,g
:_38b
,b
:blue
,a
:_388
};
3197 },rgbToHSV
:function(red
,_392
,blue
,_394
){
3198 if(arguments
.length
==1){
3205 var max
=Math
.max(Math
.max(red
,_392
),blue
);
3206 var min
=Math
.min(Math
.min(red
,_392
),blue
);
3217 hue
=(_392
-blue
)/_39b
;
3220 hue
=2+((blue
-red
)/_39b
);
3222 hue
=4+((red
-_392
)/_39b
);
3233 return {h
:hue
,s
:_399
,v
:_39a
,a
:_394
};
3234 },rgbToHSL
:function(red
,_39d
,blue
,_39f
){
3235 if(arguments
.length
==1){
3242 var max
=Math
.max(red
,Math
.max(_39d
,blue
));
3243 var min
=Math
.min(red
,Math
.min(_39d
,blue
));
3246 var _3a5
=(max
+min
)/2;
3253 _3a4
=_3a6
/(max
+min
);
3255 _3a4
=_3a6
/(2-max
-min
);
3258 hue
=(_39d
-blue
)/_3a6
;
3261 hue
=2+((blue
-red
)/_3a6
);
3263 hue
=4+((red
-_39d
)/_3a6
);
3274 return {h
:hue
,s
:_3a4
,l
:_3a5
,a
:_39f
};
3275 },toColorPart
:function(num
){
3276 num
=Math
.round(num
);
3277 var _3a8
=num
.toString(16);
3282 },__new__
:function(){
3283 var m
=MochiKit
.Base
;
3284 this.Color
.fromRGBString
=m
.bind(this.Color
._fromColorString
,this.Color
,"rgb","fromRGB",[1/255,1/255,1/255,1]);
3285 this.Color
.fromHSLString
=m
.bind(this.Color
._fromColorString
,this.Color
,"hsl","fromHSL",[1/360,0.01,0.01,1]);
3287 var _3ab
={black
:[0,0,0],blue
:[0,0,1],brown
:[0.6,0.4,0.2],cyan
:[0,1,1],darkGray
:[_3aa
,_3aa
,_3aa
],gray
:[0.5,0.5,0.5],green
:[0,1,0],lightGray
:[2*_3aa
,2*_3aa
,2*_3aa
],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]};
3288 var _3ac
=function(name
,r
,g
,b
,a
){
3289 var rval
=this.fromRGB(r
,g
,b
,a
);
3290 this[name
]=function(){
3297 var _3b5
=m
.concat([_3ac
,this.Color
,name
],_3ab
[k
]);
3298 this.Color
[name
]=m
.bind
.apply(null,_3b5
);
3300 var _3b6
=function(){
3301 for(var i
=0;i
<arguments
.length
;i
++){
3302 if(!(arguments
[i
] instanceof Color
)){
3308 var _3b8
=function(a
,b
){
3309 return a
.compareRGB(b
);
3311 m
.nameFunctions(this);
3312 m
.registerComparator(this.Color
.NAME
,_3b6
,_3b8
);
3313 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
3315 MochiKit
.Color
.EXPORT
=["Color"];
3316 MochiKit
.Color
.EXPORT_OK
=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
3317 MochiKit
.Color
.__new__();
3318 MochiKit
.Base
._exportSymbols(this,MochiKit
.Color
);
3319 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"};
3320 if(typeof (dojo
)!="undefined"){
3321 dojo
.provide("MochiKit.Signal");
3322 dojo
.require("MochiKit.Base");
3323 dojo
.require("MochiKit.DOM");
3324 dojo
.require("MochiKit.Style");
3326 if(typeof (JSAN
)!="undefined"){
3327 JSAN
.use("MochiKit.Base",[]);
3328 JSAN
.use("MochiKit.DOM",[]);
3329 JSAN
.use("MochiKit.Style",[]);
3332 if(typeof (MochiKit
.Base
)=="undefined"){
3337 throw "MochiKit.Signal depends on MochiKit.Base!";
3340 if(typeof (MochiKit
.DOM
)=="undefined"){
3345 throw "MochiKit.Signal depends on MochiKit.DOM!";
3348 if(typeof (MochiKit
.Style
)=="undefined"){
3353 throw "MochiKit.Signal depends on MochiKit.Style!";
3355 if(typeof (MochiKit
.Signal
)=="undefined"){
3358 MochiKit
.Signal
.NAME
="MochiKit.Signal";
3359 MochiKit
.Signal
.VERSION
="1.4";
3360 MochiKit
.Signal
._observers
=[];
3361 MochiKit
.Signal
.Event
=function(src
,e
){
3362 this._event
=e
||window
.event
;
3365 MochiKit
.Base
.update(MochiKit
.Signal
.Event
.prototype,{__repr__
:function(){
3366 var repr
=MochiKit
.Base
.repr
;
3367 var str
="{event(): "+repr(this.event())+", src(): "+repr(this.src())+", type(): "+repr(this.type())+", target(): "+repr(this.target());
3368 if(this.type()&&this.type().indexOf("key")===0||this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu"){
3369 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
)+"}";
3371 if(this.type()&&this.type().indexOf("key")===0){
3372 str
+=", key(): {code: "+repr(this.key().code
)+", string: "+repr(this.key().string
)+"}";
3374 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
3375 str
+=", mouse(): {page: "+repr(this.mouse().page
)+", client: "+repr(this.mouse().client
);
3376 if(this.type()!="mousemove"){
3377 str
+=", button: {left: "+repr(this.mouse().button
.left
)+", middle: "+repr(this.mouse().button
.middle
)+", right: "+repr(this.mouse().button
.right
)+"}}";
3382 if(this.type()=="mouseover"||this.type()=="mouseout"){
3383 str
+=", relatedTarget(): "+repr(this.relatedTarget());
3387 },toString
:function(){
3388 return this.__repr__();
3394 return this._event
.type
||undefined
;
3395 },target
:function(){
3396 return this._event
.target
||this._event
.srcElement
;
3397 },_relatedTarget
:null,relatedTarget
:function(){
3398 if(this._relatedTarget
!==null){
3399 return this._relatedTarget
;
3402 if(this.type()=="mouseover"){
3403 elem
=(this._event
.relatedTarget
||this._event
.fromElement
);
3405 if(this.type()=="mouseout"){
3406 elem
=(this._event
.relatedTarget
||this._event
.toElement
);
3410 this._relatedTarget
=elem
;
3414 },_modifier
:null,modifier
:function(){
3415 if(this._modifier
!==null){
3416 return this._modifier
;
3419 m
.alt
=this._event
.altKey
;
3420 m
.ctrl
=this._event
.ctrlKey
;
3421 m
.meta
=this._event
.metaKey
||false;
3422 m
.shift
=this._event
.shiftKey
;
3423 m
.any
=m
.alt
||m
.ctrl
||m
.shift
||m
.meta
;
3426 },_key
:null,key
:function(){
3427 if(this._key
!==null){
3431 if(this.type()&&this.type().indexOf("key")===0){
3432 if(this.type()=="keydown"||this.type()=="keyup"){
3433 k
.code
=this._event
.keyCode
;
3434 k
.string
=(MochiKit
.Signal
._specialKeys
[k
.code
]||"KEY_UNKNOWN");
3438 if(this.type()=="keypress"){
3441 if(typeof (this._event
.charCode
)!="undefined"&&this._event
.charCode
!==0&&!MochiKit
.Signal
._specialMacKeys
[this._event
.charCode
]){
3442 k
.code
=this._event
.charCode
;
3443 k
.string
=String
.fromCharCode(k
.code
);
3445 if(this._event
.keyCode
&&typeof (this._event
.charCode
)=="undefined"){
3446 k
.code
=this._event
.keyCode
;
3447 k
.string
=String
.fromCharCode(k
.code
);
3456 },_mouse
:null,mouse
:function(){
3457 if(this._mouse
!==null){
3462 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
3463 m
.client
=new MochiKit
.Style
.Coordinates(0,0);
3464 if(e
.clientX
||e
.clientY
){
3465 m
.client
.x
=(!e
.clientX
||e
.clientX
<0)?0:e
.clientX
;
3466 m
.client
.y
=(!e
.clientY
||e
.clientY
<0)?0:e
.clientY
;
3468 m
.page
=new MochiKit
.Style
.Coordinates(0,0);
3469 if(e
.pageX
||e
.pageY
){
3470 m
.page
.x
=(!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
3471 m
.page
.y
=(!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
3473 var de
=MochiKit
.DOM
._document
.documentElement
;
3474 var b
=MochiKit
.DOM
._document
.body
;
3475 m
.page
.x
=e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
3476 m
.page
.y
=e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
3478 if(this.type()!="mousemove"){
3480 m
.button
.left
=false;
3481 m
.button
.right
=false;
3482 m
.button
.middle
=false;
3484 m
.button
.left
=(e
.which
==1);
3485 m
.button
.middle
=(e
.which
==2);
3486 m
.button
.right
=(e
.which
==3);
3488 m
.button
.left
=!!(e
.button
&1);
3489 m
.button
.right
=!!(e
.button
&2);
3490 m
.button
.middle
=!!(e
.button
&4);
3498 this.stopPropagation();
3499 this.preventDefault();
3500 },stopPropagation
:function(){
3501 if(this._event
.stopPropagation
){
3502 this._event
.stopPropagation();
3504 this._event
.cancelBubble
=true;
3506 },preventDefault
:function(){
3507 if(this._event
.preventDefault
){
3508 this._event
.preventDefault();
3510 if(this._confirmUnload
===null){
3511 this._event
.returnValue
=false;
3514 },_confirmUnload
:null,confirmUnload
:function(msg
){
3515 if(this.type()=="beforeunload"){
3516 this._confirmUnload
=msg
;
3517 this._event
.returnValue
=msg
;
3520 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"};
3522 var _3c7
=MochiKit
.Signal
._specialMacKeys
;
3523 for(i
=63236;i
<=63242;i
++){
3524 _3c7
[i
]="KEY_F"+(i
-63236+1);
3527 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"};
3529 var _3c8
=MochiKit
.Signal
._specialKeys
;
3530 for(var i
=48;i
<=57;i
++){
3531 _3c8
[i
]="KEY_"+(i
-48);
3533 for(i
=65;i
<=90;i
++){
3534 _3c8
[i
]="KEY_"+String
.fromCharCode(i
);
3536 for(i
=96;i
<=105;i
++){
3537 _3c8
[i
]="KEY_NUM_PAD_"+(i
-96);
3539 for(i
=112;i
<=123;i
++){
3540 _3c8
[i
]="KEY_F"+(i
-112+1);
3543 MochiKit
.Signal
.Ident
=function(_3ca
){
3544 this.source
=_3ca
.source
;
3545 this.signal
=_3ca
.signal
;
3546 this.listener
=_3ca
.listener
;
3547 this.isDOM
=_3ca
.isDOM
;
3548 this.objOrFunc
=_3ca
.objOrFunc
;
3549 this.funcOrStr
=_3ca
.funcOrStr
;
3550 this.connected
=_3ca
.connected
;
3552 MochiKit
.Signal
.Ident
.prototype={};
3553 MochiKit
.Base
.update(MochiKit
.Signal
,{__repr__
:function(){
3554 return "["+this.NAME
+" "+this.VERSION
+"]";
3555 },toString
:function(){
3556 return this.__repr__();
3557 },_unloadCache
:function(){
3558 var self
=MochiKit
.Signal
;
3559 var _3cc
=self
._observers
;
3560 for(var i
=0;i
<_3cc
.length
;i
++){
3561 if(_3cc
[i
].signal
!=="onload"&&_3cc
[i
].signal
!=="onunload"){
3562 self
._disconnect(_3cc
[i
]);
3565 },_listener
:function(src
,sig
,func
,obj
,_3d2
){
3566 var self
=MochiKit
.Signal
;
3569 return MochiKit
.Base
.bind(func
,obj
);
3572 if(typeof (func
)=="string"){
3573 if(sig
==="onload"||sig
==="onunload"){
3574 return function(_3d5
){
3575 obj
[func
].apply(obj
,[new E(src
,_3d5
)]);
3576 var _3d6
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,objOrFunc
:obj
,funcOrStr
:func
});
3577 MochiKit
.Signal
._disconnect(_3d6
);
3580 return function(_3d7
){
3581 obj
[func
].apply(obj
,[new E(src
,_3d7
)]);
3585 if(sig
==="onload"||sig
==="onunload"){
3586 return function(_3d8
){
3587 func
.apply(obj
,[new E(src
,_3d8
)]);
3588 MochiKit
.Signal
.disconnect(src
,sig
,func
);
3589 var _3d9
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,objOrFunc
:func
});
3590 MochiKit
.Signal
._disconnect(_3d9
);
3593 return function(_3da
){
3594 func
.apply(obj
,[new E(src
,_3da
)]);
3598 },_browserAlreadyHasMouseEnterAndLeave
:function(){
3599 return /MSIE/.test(navigator
.userAgent
);
3600 },_mouseEnterListener
:function(src
,sig
,func
,obj
){
3601 var E
=MochiKit
.Signal
.Event
;
3602 return function(_3e0
){
3603 var e
=new E(src
,_3e0
);
3605 e
.relatedTarget().nodeName
;
3611 if(MochiKit
.DOM
.isChildNode(e
.relatedTarget(),src
)){
3617 if(typeof (func
)=="string"){
3618 return obj
[func
].apply(obj
,[e
]);
3620 return func
.apply(obj
,[e
]);
3623 },_getDestPair
:function(_3e2
,_3e3
){
3626 if(typeof (_3e3
)!="undefined"){
3629 if(typeof (_3e3
)=="string"){
3630 if(typeof (_3e2
[_3e3
])!="function"){
3631 throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
3634 if(typeof (_3e3
)!="function"){
3635 throw new Error("'funcOrStr' must be a function or string");
3639 if(typeof (_3e2
)!="function"){
3640 throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
3646 },connect
:function(src
,sig
,_3e8
,_3e9
){
3647 src
=MochiKit
.DOM
.getElement(src
);
3648 var self
=MochiKit
.Signal
;
3649 if(typeof (sig
)!="string"){
3650 throw new Error("'sig' must be a string");
3652 var _3eb
=self
._getDestPair(_3e8
,_3e9
);
3655 if(typeof (obj
)=="undefined"||obj
===null){
3658 var _3ee
=!!(src
.addEventListener
||src
.attachEvent
);
3659 if(_3ee
&&(sig
==="onmouseenter"||sig
==="onmouseleave")&&!self
._browserAlreadyHasMouseEnterAndLeave()){
3660 var _3ef
=self
._mouseEnterListener(src
,sig
.substr(2),func
,obj
);
3661 if(sig
==="onmouseenter"){
3667 var _3ef
=self
._listener(src
,sig
,func
,obj
,_3ee
);
3669 if(src
.addEventListener
){
3670 src
.addEventListener(sig
.substr(2),_3ef
,false);
3672 if(src
.attachEvent
){
3673 src
.attachEvent(sig
,_3ef
);
3676 var _3f0
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,listener
:_3ef
,isDOM
:_3ee
,objOrFunc
:_3e8
,funcOrStr
:_3e9
,connected
:true});
3677 self
._observers
.push(_3f0
);
3678 if(!_3ee
&&typeof (src
.__connect__
)=="function"){
3679 var args
=MochiKit
.Base
.extend([_3f0
],arguments
,1);
3680 src
.__connect__
.apply(src
,args
);
3683 },_disconnect
:function(_3f2
){
3684 if(!_3f2
.connected
){
3687 _3f2
.connected
=false;
3691 var src
=_3f2
.source
;
3692 var sig
=_3f2
.signal
;
3693 var _3f5
=_3f2
.listener
;
3694 if(src
.removeEventListener
){
3695 src
.removeEventListener(sig
.substr(2),_3f5
,false);
3697 if(src
.detachEvent
){
3698 src
.detachEvent(sig
,_3f5
);
3700 throw new Error("'src' must be a DOM element");
3703 },disconnect
:function(_3f6
){
3704 var self
=MochiKit
.Signal
;
3705 var _3f8
=self
._observers
;
3706 var m
=MochiKit
.Base
;
3707 if(arguments
.length
>1){
3708 var src
=MochiKit
.DOM
.getElement(arguments
[0]);
3709 var sig
=arguments
[1];
3710 var obj
=arguments
[2];
3711 var func
=arguments
[3];
3712 for(var i
=_3f8
.length
-1;i
>=0;i
--){
3714 if(o
.source
===src
&&o
.signal
===sig
&&o
.objOrFunc
===obj
&&o
.funcOrStr
===func
){
3715 self
._disconnect(o
);
3725 var idx
=m
.findIdentical(_3f8
,_3f6
);
3727 self
._disconnect(_3f6
);
3737 },disconnectAllTo
:function(_401
,_402
){
3738 var self
=MochiKit
.Signal
;
3739 var _404
=self
._observers
;
3740 var _405
=self
._disconnect
;
3741 var _406
=self
._lock
;
3742 var _407
=self
._dirty
;
3743 if(typeof (_402
)==="undefined"){
3746 for(var i
=_404
.length
-1;i
>=0;i
--){
3748 if(_409
.objOrFunc
===_401
&&(_402
===null||_409
.funcOrStr
===_402
)){
3758 },disconnectAll
:function(src
,sig
){
3759 src
=MochiKit
.DOM
.getElement(src
);
3760 var m
=MochiKit
.Base
;
3761 var _40d
=m
.flattenArguments(m
.extend(null,arguments
,1));
3762 var self
=MochiKit
.Signal
;
3763 var _40f
=self
._disconnect
;
3764 var _410
=self
._observers
;
3766 var _413
=self
._lock
;
3767 var _414
=self
._dirty
;
3768 if(_40d
.length
===0){
3769 for(i
=_410
.length
-1;i
>=0;i
--){
3771 if(_412
.source
===src
){
3782 for(i
=0;i
<_40d
.length
;i
++){
3785 for(i
=_410
.length
-1;i
>=0;i
--){
3787 if(_412
.source
===src
&&_412
.signal
in sigs
){
3798 },signal
:function(src
,sig
){
3799 var self
=MochiKit
.Signal
;
3800 var _419
=self
._observers
;
3801 src
=MochiKit
.DOM
.getElement(src
);
3802 var args
=MochiKit
.Base
.extend(null,arguments
,2);
3805 for(var i
=0;i
<_419
.length
;i
++){
3807 if(_41d
.source
===src
&&_41d
.signal
===sig
){
3809 _41d
.listener
.apply(src
,args
);
3819 for(var i
=_419
.length
-1;i
>=0;i
--){
3820 if(!_419
[i
].connected
){
3829 var e
=new Error("Multiple errors thrown in handling 'sig', see errors property");
3835 MochiKit
.Signal
.EXPORT_OK
=[];
3836 MochiKit
.Signal
.EXPORT
=["connect","disconnect","signal","disconnectAll","disconnectAllTo"];
3837 MochiKit
.Signal
.__new__
=function(win
){
3838 var m
=MochiKit
.Base
;
3839 this._document
=document
;
3844 this.connect(window
,"onunload",this._unloadCache
);
3848 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
3849 m
.nameFunctions(this);
3851 MochiKit
.Signal
.__new__(this);
3852 if(MochiKit
.__export__
){
3853 connect
=MochiKit
.Signal
.connect
;
3854 disconnect
=MochiKit
.Signal
.disconnect
;
3855 disconnectAll
=MochiKit
.Signal
.disconnectAll
;
3856 signal
=MochiKit
.Signal
.signal
;
3858 MochiKit
.Base
._exportSymbols(this,MochiKit
.Signal
);
3863 PlotKit.PlotKit 0.9.1 : PACKED VERSION
3865 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
3866 diff against the source tree, not this file.
3868 For more information, <http://www.liquidx.net/plotkit/>.
3870 Copyright (c) 2006. Alastair Tse.
3875 if(typeof (MochiKit
.Base
)=="undefined"||typeof (MochiKit
.DOM
)=="undefined"||typeof (MochiKit
.Color
)=="undefined"){
3880 throw "PlotKit depends on MochiKit.{Base,Color,DOM}";
3882 MochiKit
.Base
.update(MochiKit
.Color
.Color
.prototype,{asFillColor
:function(){
3883 return this.lighterColorWithLevel(0.3);
3884 },asStrokeColor
:function(){
3885 return this.darkerColorWithLevel(0.1);
3886 },asPointColor
:function(){
3887 return this.lighterColorWithLevel(0.1);
3889 if(typeof (PlotKit
)=="undefined"){
3892 PlotKit
.NAME
="PlotKit";
3893 PlotKit
.VERSION
="0.8";
3894 PlotKit
.__repr__
=function(){
3895 return "["+this.NAME
+" "+this.VERSION
+"]";
3897 PlotKit
.toString
=function(){
3898 return this.__repr__();
3900 if(typeof (PlotKit
.Base
)=="undefined"){
3903 PlotKit
.Base
.NAME
="PlotKit.Base";
3904 PlotKit
.Base
.VERSION
=PlotKit
.VERSION
;
3905 PlotKit
.Base
.__repr__
=function(){
3906 return "["+this.NAME
+" "+this.VERSION
+"]";
3908 PlotKit
.Base
.toString
=function(){
3909 return this.__repr__();
3911 PlotKit
.Base
.usingPrototype
=function(){
3913 return (typeof (Object
.extend
)=="function");
3919 MochiKit
.Base
.update(PlotKit
.Base
,{collapse
:function(_1
){
3920 var m
=MochiKit
.Base
;
3922 for(var i
=0;i
<_1
.length
;i
++){
3923 _3
=m
.concat(_3
,_1
[i
]);
3925 if(PlotKit
.Base
.usingPrototype()){
3931 },uniq
:function(_5
){
3932 var m
=MochiKit
.Base
;
3933 if(!m
.isArrayLike(_5
)||(_5
.length
<1)){
3939 for(var i
=1;i
<_5
.length
;i
++){
3940 if(m
.compare(_5
[i
],_7
)!=0){
3946 },palette
:function(_8
,_9
,_10
,_11
){
3947 var _12
=MochiKit
.Base
.isUndefinedOrNull
;
3948 var _13
=new Array();
3963 var _15
=function(_16
,_17
){
3964 return _16
.lighterColorWithLevel(_17
);
3966 return MochiKit
.Base
.map(partial(_15
,_8
),_13
);
3967 },excanvasSupported
:function(){
3968 if(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
){
3972 },findPosX
:function(obj
){
3974 if(obj
.offsetParent
){
3975 while(obj
.offsetParent
){
3976 _19
+=obj
.offsetLeft
;
3977 obj
=obj
.offsetParent
;
3985 },findPosY
:function(obj
){
3987 if(obj
.offsetParent
){
3988 while(obj
.offsetParent
){
3990 obj
=obj
.offsetParent
;
3998 },isFuncLike
:function(obj
){
3999 return (typeof (obj
)=="function");
4001 PlotKit
.Base
.map
=function(fn
,lst
){
4002 if(PlotKit
.Base
.usingPrototype()){
4005 if(typeof (lst
[x
])=="function"){
4008 _23
.push(fn(lst
[x
]));
4012 return MochiKit
.Base
.map(fn
,lst
);
4015 PlotKit
.Base
.items
=function(lst
){
4016 if(PlotKit
.Base
.usingPrototype()){
4019 if(typeof (lst
[x
])=="function"){
4022 _25
.push([x
,lst
[x
]]);
4026 return MochiKit
.Base
.items(lst
);
4029 PlotKit
.Base
.keys
=function(lst
){
4030 if(PlotKit
.Base
.usingPrototype()){
4033 if(typeof (lst
[x
])=="function"){
4040 return MochiKit
.Base
.keys(lst
);
4043 PlotKit
.Base
.baseColors
=function(){
4044 var _27
=MochiKit
.Color
.Color
.fromHexString
;
4045 return [_27("#476fb2"),_27("#be2c2b"),_27("#85b730"),_27("#734a99"),_27("#26a1c5"),_27("#fb8707"),_27("#000000")];
4047 PlotKit
.Base
.EXPORT
=["baseColors","collapse","findPosX","findPosY","uniq","isFuncLike","excanvasSupported"];
4048 PlotKit
.Base
.EXPORT_OK
=[];
4049 PlotKit
.Base
.__new__
=function(){
4050 var m
=MochiKit
.Base
;
4051 m
.nameFunctions(this);
4052 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
4054 PlotKit
.Base
.__new__();
4055 MochiKit
.Base
._exportSymbols(this,PlotKit
.Base
);
4056 if(typeof (PlotKit
.Layout
)=="undefined"){
4059 PlotKit
.Layout
=function(_28
,_29
){
4061 MochiKit
.Base
.update(this.options
,_29
?_29
:{});
4062 this.datasets
=new Array();
4064 PlotKit
.Layout
.prototype.addDataset
=function(_30
,_31
){
4065 this.datasets
[_30
]=_31
;
4067 PlotKit
.Layout
.prototype.evaluate
=function(){
4068 this._evaluateLimits();
4069 this._evaluateLineCharts();
4070 this._evaluateLineTicks();
4072 PlotKit
.Layout
.prototype._evaluateLimits
=function(){
4073 this.minxval
=this.maxxval
=null;
4074 for(var _32
in this.datasets
){
4075 var _33
=this.datasets
[_32
];
4077 if(!this.minxval
||x1
<this.minxval
){
4080 var x2
=_33
[_33
.length
-1][0];
4081 if(!this.maxxval
||x2
>this.maxxval
){
4085 this.xrange
=this.maxxval
-this.minxval
;
4086 this.xscale
=(this.xrange
!=0?1/this.xrange
:1);
4087 this.minyval
=this.options
.yAxis
[0];
4088 this.maxyval
=this.options
.yAxis
[1];
4089 this.yrange
=this.maxyval
-this.minyval
;
4090 this.yscale
=(this.yrange
!=0?1/this.yrange
:1);
4092 PlotKit
.Layout
.prototype._evaluateLineCharts
=function(){
4093 var _36
=PlotKit
.Base
.items
;
4094 var _37
=_36(this.datasets
).length
;
4095 this.points
=new Array();
4096 for(var _38
in this.datasets
){
4097 var _39
=this.datasets
[_38
];
4098 for(var j
=0;j
<_39
.length
;j
++){
4100 var _42
={x
:((parseFloat(_41
[0])-this.minxval
)*this.xscale
),y
:1-((parseFloat(_41
[1])-this.minyval
)*this.yscale
),xval
:parseFloat(_41
[0]),yval
:parseFloat(_41
[1]),name
:_38
};
4107 if((_42
.x
>=0)&&(_42
.x
<=1)){
4108 this.points
.push(_42
);
4113 PlotKit
.Layout
.prototype._evaluateLineTicks
=function(){
4114 this.xticks
=new Array();
4115 for(var i
=0;i
<this.options
.xTicks
.length
;i
++){
4116 var _43
=this.options
.xTicks
[i
];
4118 var pos
=this.xscale
*(_43
.v
-this.minxval
);
4119 if((pos
>=0)&&(pos
<=1)){
4120 this.xticks
.push([pos
,_44
]);
4123 this.yticks
=new Array();
4124 for(var i
=0;i
<this.options
.yTicks
.length
;i
++){
4125 var _43
=this.options
.yTicks
[i
];
4127 var pos
=1-(this.yscale
*(_43
.v
-this.minyval
));
4128 if((pos
>=0)&&(pos
<=1)){
4129 this.yticks
.push([pos
,_44
]);
4134 if((typeof (PlotKit
.Base
)=="undefined")||(typeof (PlotKit
.Layout
)=="undefined")){
4139 throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Base,Layout}";
4141 if(typeof (PlotKit
.CanvasRenderer
)=="undefined"){
4142 PlotKit
.CanvasRenderer
={};
4144 PlotKit
.CanvasRenderer
.NAME
="PlotKit.CanvasRenderer";
4145 PlotKit
.CanvasRenderer
.VERSION
=PlotKit
.VERSION
;
4146 PlotKit
.CanvasRenderer
.__repr__
=function(){
4147 return "["+this.NAME
+" "+this.VERSION
+"]";
4149 PlotKit
.CanvasRenderer
.toString
=function(){
4150 return this.__repr__();
4152 PlotKit
.CanvasRenderer
=function(_46
,_47
,_48
){
4153 if(arguments
.length
>0){
4154 this.__init__(_46
,_47
,_48
);
4157 PlotKit
.CanvasRenderer
.prototype.__init__
=function(_49
,_50
,_51
){
4158 var _52
=MochiKit
.Base
.isUndefinedOrNull
;
4159 var _53
=MochiKit
.Color
.Color
;
4160 this.options
={"drawBackground":true,"backgroundColor":_53
.whiteColor(),"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[0]),"strokeColor":_53
.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":_53
.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":_53
.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"pieRadius":0.4,"enableEvents":true};
4161 MochiKit
.Base
.update(this.options
,_51
?_51
:{});
4163 this.element
=MochiKit
.DOM
.getElement(_49
);
4164 this.container
=this.element
.parentNode
;
4165 this.isIE
=PlotKit
.Base
.excanvasSupported();
4166 if(this.isIE
&&!_52(G_vmlCanvasManager
)){
4169 this.renderDelay
=null;
4170 this.clearDelay
=null;
4171 this.element
=G_vmlCanvasManager
.initElement(this.element
);
4173 this.height
=this.element
.height
;
4174 this.width
=this.element
.width
;
4175 if(_52(this.element
)){
4176 throw "CanvasRenderer() - passed canvas is not found";
4178 if(!this.isIE
&&!(PlotKit
.CanvasRenderer
.isSupported(this.element
))){
4179 throw "CanvasRenderer() - Canvas is not supported.";
4181 if(_52(this.container
)||(this.container
.nodeName
.toLowerCase()!="div")){
4182 throw "CanvasRenderer() - <canvas> needs to be enclosed in <div>";
4184 this.xlabels
=new Array();
4185 this.ylabels
=new Array();
4186 this.isFirstRender
=true;
4187 this.area
={x
:this.options
.yAxisLabelWidth
+2*this.options
.axisTickSize
,y
:0};
4188 this.area
.w
=this.width
-this.area
.x
-this.options
.rightGap
;
4189 this.area
.h
=this.height
-this.options
.axisLabelFontSize
-2*this.options
.axisTickSize
;
4190 MochiKit
.DOM
.updateNodeAttributes(this.container
,{"style":{"position":"relative","width":this.width
+"px"}});
4192 PlotKit
.CanvasRenderer
.prototype._renderLineAxis
=function(){
4195 PlotKit
.CanvasRenderer
.prototype._renderAxis
=function(){
4196 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
4199 var _54
=this.element
.getContext("2d");
4200 var _55
={"style":{"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
.toRGBString(),"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"}};
4202 _54
.strokeStyle
=this.options
.axisLineColor
.toRGBString();
4203 _54
.lineWidth
=this.options
.axisLineWidth
;
4204 if(this.options
.drawYAxis
){
4205 if(this.layout
.yticks
){
4206 var _56
=function(_57
){
4207 if(typeof (_57
)=="function"){
4211 var y
=this.area
.y
+_57
[0]*this.area
.h
;
4214 _54
.lineTo(x
-this.options
.axisTickSize
,y
);
4217 var _59
=DIV(_55
,_57
[1]);
4218 var top
=(y
-this.options
.axisLabelFontSize
/2);
4222 if(top
+this.options
.axisLabelFontSize
+3>this.height
){
4223 _59
.style
.bottom
="0px";
4225 _59
.style
.top
=top
+"px";
4227 _59
.style
.left
="0px";
4228 _59
.style
.textAlign
="right";
4229 _59
.style
.width
=this.options
.yAxisLabelWidth
+"px";
4230 MochiKit
.DOM
.appendChildNodes(this.container
,_59
);
4231 this.ylabels
.push(_59
);
4233 MochiKit
.Iter
.forEach(this.layout
.yticks
,bind(_56
,this));
4234 var _61
=this.ylabels
[0];
4235 var _62
=this.options
.axisLabelFontSize
;
4236 var _63
=parseInt(_61
.style
.top
)+_62
;
4237 if(_63
>this.height
-_62
){
4238 _61
.style
.top
=(parseInt(_61
.style
.top
)-_62
/2)+"px";
4242 _54
.moveTo(this.area
.x
,this.area
.y
);
4243 _54
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
4247 if(this.options
.drawXAxis
){
4248 if(this.layout
.xticks
){
4249 var _56
=function(_64
){
4250 if(typeof (dataset
)=="function"){
4253 var x
=this.area
.x
+_64
[0]*this.area
.w
;
4254 var y
=this.area
.y
+this.area
.h
;
4257 _54
.lineTo(x
,y
+this.options
.axisTickSize
);
4260 var _65
=DIV(_55
,_64
[1]);
4261 _65
.style
.textAlign
="center";
4262 _65
.style
.bottom
="0px";
4263 var _66
=(x
-this.options
.axisLabelWidth
/2);
4264 if(_66
+this.options
.axisLabelWidth
>this.width
){
4265 _66
=this.width
-this.options
.xAxisLabelWidth
;
4266 _65
.style
.textAlign
="right";
4270 _65
.style
.textAlign
="left";
4272 _65
.style
.left
=_66
+"px";
4273 _65
.style
.width
=this.options
.xAxisLabelWidth
+"px";
4274 MochiKit
.DOM
.appendChildNodes(this.container
,_65
);
4275 this.xlabels
.push(_65
);
4277 MochiKit
.Iter
.forEach(this.layout
.xticks
,bind(_56
,this));
4280 _54
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
4281 _54
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
4287 PlotKit
.CanvasRenderer
.prototype.clear
=function(){
4290 if(this.clearDelay
){
4291 this.clearDelay
.cancel();
4292 this.clearDelay
=null;
4294 var _67
=this.element
.getContext("2d");
4297 this.isFirstRender
=false;
4298 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
4299 this.clearDelay
.addCallback(bind(this.clear
,this));
4303 var _67
=this.element
.getContext("2d");
4304 _67
.clearRect(0,0,this.width
,this.height
);
4305 MochiKit
.Iter
.forEach(this.xlabels
,MochiKit
.DOM
.removeElement
);
4306 MochiKit
.Iter
.forEach(this.ylabels
,MochiKit
.DOM
.removeElement
);
4307 this.xlabels
=new Array();
4308 this.ylabels
=new Array();
4310 PlotKit
.CanvasRenderer
.isSupported
=function(_68
){
4313 if(MochiKit
.Base
.isUndefinedOrNull(_68
)){
4314 _69
=MochiKit
.DOM
.CANVAS({});
4316 _69
=MochiKit
.DOM
.getElement(_68
);
4318 var _70
=_69
.getContext("2d");
4321 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
4322 var _72
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
4323 if((!ie
)||(ie
[1]<6)||(_72
)){
4331 PlotKit
.Canvas
.CanvasRenderer
=PlotKit
.CanvasRenderer
;
4332 PlotKit
.Canvas
.EXPORT
=["CanvasRenderer"];
4333 PlotKit
.Canvas
.EXPORT_OK
=["CanvasRenderer"];
4334 PlotKit
.Canvas
.__new__
=function(){
4335 var m
=MochiKit
.Base
;
4336 m
.nameFunctions(this);
4337 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
4339 PlotKit
.Canvas
.__new__();
4340 MochiKit
.Base
._exportSymbols(this,PlotKit
.Canvas
);
4343 Date
.ext
={};Date
.ext
.util
={};Date
.ext
.util
.xPad
=function(x
,pad
,r
){if(typeof (r
)=="undefined"){r
=10}for(;parseInt(x
,10)<r
&&r
>1;r
/=10){x=pad.toString()+x}return x.toString()};Date.prototype.locale="en-GB";if(document.getElementsByTagName("html")&&document.getElementsByTagName("html")[0].lang){Date.prototype.locale=document.getElementsByTagName("html")[0].lang}Date.ext.locales={};Date.ext.locales.en={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],x:"%d/%m
/%y",X:"%T"};Date.ext.locales["en-US"]=Date.ext.locales.en;Date.ext.locales["en-US"].c="%a %d %b %Y %r %Z";Date.ext.locales["en-US"].x="%D";Date.ext.locales["en-US"].X="%r";Date.ext.locales["en-GB"]=Date.ext.locales.en;Date.ext.locales["en-AU"]=Date.ext.locales["en-GB"];Date.ext.formats={a:function(d){return Date.ext.locales[d.locale].a[d.getDay()]},A:function(d){return Date.ext.locales[d.locale].A[d.getDay()]},b:function(d){return Date.ext.locales[d.locale].b[d.getMonth()]},B:function(d){return Date.ext.locales[d.locale].B[d.getMonth()]},c:"toLocaleString",C:function(d){return Date.ext.util.xPad(parseInt(d.getFullYear()/100,10),0)},d
:["getDate","0"],e
:["getDate"," "],g
:function(d
){return Date
.ext
.util
.xPad(parseInt(Date
.ext
.util
.G(d
)/100,10),0)},G:function(d){var y=d.getFullYear();var V=parseInt(Date.ext.formats.V(d),10);var W=parseInt(Date.ext.formats.W(d),10);if(W>V){y++}else{if(W===0&&V>=52){y--}}return y},H:["getHours","0"],I:function(d){var I=d.getHours()%12;return Date.ext.util.xPad(I===0?12:I,0)},j:function(d){var ms=d-new Date(""+d.getFullYear()+"/1/1 GMT");ms+=d.getTimezoneOffset()*60000;var doy=parseInt(ms/60000/60/24,10)+1;return Date
.ext
.util
.xPad(doy
,0,100)},m
:function(d
){return Date
.ext
.util
.xPad(d
.getMonth()+1,0)},M
:["getMinutes","0"],p
:function(d
){return Date
.ext
.locales
[d
.locale
].p
[d
.getHours()>=12?1:0]},P
:function(d
){return Date
.ext
.locales
[d
.locale
].P
[d
.getHours()>=12?1:0]},S
:["getSeconds","0"],u
:function(d
){var dow
=d
.getDay();return dow
===0?7:dow
},U
:function(d
){var doy
=parseInt(Date
.ext
.formats
.j(d
),10);var rdow
=6-d
.getDay();var woy
=parseInt((doy
+rdow
)/7,10);return Date.ext.util.xPad(woy,0)},V:function(d){var woy=parseInt(Date.ext.formats.W(d),10);var dow1_1=(new Date(""+d.getFullYear()+"/1/1")).getDay();var idow=woy+(dow1_1>4||dow1_1<=1?0:1);if(idow==53&&(new Date(""+d.getFullYear()+"/12/31")).getDay()<4){idow=1}else{if(idow===0){idow=Date.ext.formats.V(new Date(""+(d.getFullYear()-1)+"/12/31"))}}return Date.ext.util.xPad(idow,0)},w:"getDay",W:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=7-Date.ext.formats.u(d);var woy=parseInt((doy+rdow)/7,10);return Date
.ext
.util
.xPad(woy
,0,10)},y
:function(d
){return Date
.ext
.util
.xPad(d
.getFullYear()%100,0)},Y
:"getFullYear",z
:function(d
){var o
=d
.getTimezoneOffset();var H
=Date
.ext
.util
.xPad(parseInt(Math
.abs(o
/60),10),0);var M=Date.ext.util.xPad(o%60,0);return(o>0?"-":"+")+H+M},Z:function(d){return d.toString().replace(/^.*\(([^)]+)\)$/,"$1")},"%":function(d){return"%"}};Date.ext.aggregates={c:"locale",D:"%m/%d
/%y",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"};Date.ext.aggregates.z=Date.ext.formats.z(new Date());Date.ext.aggregates.Z=Date.ext.formats.Z(new Date());Date.ext.unsupported={};Date.prototype.strftime=function(fmt){if(!(this.locale in Date.ext.locales)){if(this.locale.replace(/-[a
-zA
-Z
]+$/,"") in Date.ext.locales){this.locale=this.locale.replace(/-[a
-zA
-Z
]+$/,"")}else{this.locale="en-GB"}}var d=this;while(fmt.match(/%[cDhnrRtTxXzZ
]/)){fmt=fmt.replace(/%([cDhnrRtTxXzZ
])/g,function(m0,m1){var f=Date.ext.aggregates[m1];return(f=="locale"?Date.ext.locales[d.locale][m1]:f)})}var str=fmt.replace(/%([aAbBCdegGHIjmMpPSuUVwWyY
%])/g
,function(m0
,m1
){var f
=Date
.ext
.formats
[m1
];if(typeof (f
)=="string"){return d
[f
]()}else{if(typeof (f
)=="function"){return f
.call(d
,d
)}else{if(typeof (f
)=="object"&&typeof (f
[0])=="string"){return Date
.ext
.util
.xPad(d
[f
[0]](),f
[1])}else{return m1
}}}});d
=null;return str
};
4344 DygraphLayout
=function(_1
){
4345 PlotKit
.Layout
.call(this,"line",_1
);
4347 DygraphLayout
.prototype=new PlotKit
.Layout();
4348 DygraphLayout
.prototype.evaluateWithError
=function(){
4350 if(!this.options
.errorBars
){
4354 for(var _3
in this.datasets
){
4356 var _5
=this.datasets
[_3
];
4357 if(PlotKit
.Base
.isFuncLike(_5
)){
4360 for(var j
=0;j
<_5
.length
;j
++,i
++){
4362 var xv
=parseFloat(_6
[0]);
4363 var yv
=parseFloat(_6
[1]);
4364 if(xv
==this.points
[i
].xval
&&yv
==this.points
[i
].yval
){
4365 this.points
[i
].errorMinus
=parseFloat(_6
[2]);
4366 this.points
[i
].errorPlus
=parseFloat(_6
[3]);
4371 DygraphLayout
.prototype.removeAllDatasets
=function(){
4372 delete this.datasets
;
4373 this.datasets
=new Array();
4375 DygraphLayout
.prototype.updateOptions
=function(_9
){
4376 MochiKit
.Base
.update(this.options
,_9
?_9
:{});
4378 DygraphCanvasRenderer
=function(_10
,_11
,_12
,_13
){
4379 PlotKit
.CanvasRenderer
.call(this,_11
,_12
,_13
);
4381 this.options
.shouldFill
=false;
4382 this.options
.shouldStroke
=true;
4383 this.options
.drawYGrid
=true;
4384 this.options
.drawXGrid
=true;
4385 this.options
.gridLineColor
=MochiKit
.Color
.Color
.grayColor();
4386 MochiKit
.Base
.update(this.options
,_13
);
4387 this.options
.drawBackground
=false;
4389 DygraphCanvasRenderer
.prototype=new PlotKit
.CanvasRenderer();
4390 DygraphCanvasRenderer
.prototype.render
=function(){
4391 var ctx
=this.element
.getContext("2d");
4392 if(this.options
.drawYGrid
){
4393 var _15
=this.layout
.yticks
;
4395 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
4396 ctx
.lineWidth
=this.options
.axisLineWidth
;
4397 for(var i
=0;i
<_15
.length
;i
++){
4399 var y
=this.area
.y
+_15
[i
][0]*this.area
.h
;
4402 ctx
.lineTo(x
+this.area
.w
,y
);
4407 if(this.options
.drawXGrid
){
4408 var _15
=this.layout
.xticks
;
4410 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
4411 ctx
.lineWidth
=this.options
.axisLineWidth
;
4412 for(var i
=0;i
<_15
.length
;i
++){
4413 var x
=this.area
.x
+_15
[i
][0]*this.area
.w
;
4414 var y
=this.area
.y
+this.area
.h
;
4417 ctx
.lineTo(x
,this.area
.y
);
4422 this._renderLineChart();
4423 this._renderLineAxis();
4425 DygraphCanvasRenderer
.prototype._renderLineChart
=function(){
4426 var _18
=this.element
.getContext("2d");
4427 var _19
=this.options
.colorScheme
.length
;
4428 var _20
=this.options
.colorScheme
;
4429 var _21
=MochiKit
.Base
.keys(this.layout
.datasets
);
4430 var _22
=this.layout
.options
.errorBars
;
4432 var _24
=MochiKit
.Base
.bind
;
4433 var _25
=MochiKit
.Base
.partial
;
4434 var _26
=function(_27
){
4435 _27
.canvasx
=this.area
.w
*_27
.x
+this.area
.x
;
4436 _27
.canvasy
=this.area
.h
*_27
.y
+this.area
.y
;
4438 MochiKit
.Iter
.forEach(this.layout
.points
,_26
,this);
4439 var _28
=function(x
){
4440 return x
&&!isNaN(x
);
4442 var _29
=function(ctx
){
4443 for(var i
=0;i
<_23
;i
++){
4446 var _32
=this.options
.strokeColorTransform
;
4448 _18
.strokeStyle
=_31
.toRGBString();
4449 _18
.lineWidth
=this.options
.strokeWidth
;
4450 var _33
=this.layout
.points
[0];
4451 var _34
=this.dygraph_
.attr_("pointSize");
4452 var _35
=null,prevY
=null;
4453 var _36
=this.dygraph_
.attr_("drawPoints");
4454 var _37
=this.layout
.points
;
4455 for(var j
=0;j
<_37
.length
;j
++){
4458 if(!_28(_33
.canvasy
)){
4461 var _38
=(!_35
&&(j
==_37
.length
-1||!_28(_37
[j
+1].canvasy
)));
4467 ctx
.moveTo(_35
,prevY
);
4470 ctx
.lineTo(_35
,prevY
);
4475 ctx
.fillStyle
=_31
.toRGBString();
4476 ctx
.arc(_33
.canvasx
,_33
.canvasy
,_34
,0,360,false);
4484 var _39
=function(ctx
){
4485 for(var i
=0;i
<_23
;i
++){
4488 var _42
=this.options
.strokeColorTransform
;
4490 _18
.strokeStyle
=_41
.toRGBString();
4491 _18
.lineWidth
=this.options
.strokeWidth
;
4495 var _46
=this.layout
.yscale
;
4496 var _47
=function(_48
,_49
){
4499 if(!_49
.y
||isNaN(_49
.y
)){
4503 var _50
=[_49
.y
-_49
.errorPlus
*_46
,_49
.y
+_49
.errorMinus
*_46
];
4504 _50
[0]=this.area
.h
*_50
[0]+this.area
.y
;
4505 _50
[1]=this.area
.h
*_50
[1]+this.area
.y
;
4507 _48
.moveTo(_43
,_44
[0]);
4508 _48
.lineTo(_49
.canvasx
,_50
[0]);
4509 _48
.lineTo(_49
.canvasx
,_50
[1]);
4510 _48
.lineTo(_43
,_44
[1]);
4518 var _51
=_41
.colorWithAlpha(0.15);
4519 ctx
.fillStyle
=_51
.toRGBString();
4521 MochiKit
.Iter
.forEach(this.layout
.points
,_25(_47
,ctx
),this);
4531 Dygraph
=function(div
,_53
,_54
){
4532 if(arguments
.length
>0){
4533 if(arguments
.length
==4){
4534 this.warn("Using deprecated four-argument dygraph constructor");
4535 this.__old_init__(div
,_53
,arguments
[2],arguments
[3]);
4537 this.__init__(div
,_53
,_54
);
4541 Dygraph
.NAME
="Dygraph";
4542 Dygraph
.VERSION
="1.2";
4543 Dygraph
.__repr__
=function(){
4544 return "["+this.NAME
+" "+this.VERSION
+"]";
4546 Dygraph
.toString
=function(){
4547 return this.__repr__();
4549 Dygraph
.DEFAULT_ROLL_PERIOD
=1;
4550 Dygraph
.DEFAULT_WIDTH
=480;
4551 Dygraph
.DEFAULT_HEIGHT
=320;
4552 Dygraph
.AXIS_LINE_WIDTH
=0.3;
4553 Dygraph
.DEFAULT_ATTRS
={highlightCircleSize
:3,pixelsPerXLabel
:60,pixelsPerYLabel
:30,labelsDivWidth
:250,labelsDivStyles
:{},labelsSeparateLines
:false,labelsKMB
:false,strokeWidth
:1,axisTickSize
:3,axisLabelFontSize
:14,xAxisLabelWidth
:50,yAxisLabelWidth
:50,rightGap
:5,showRoller
:false,xValueFormatter
:Dygraph
.dateString_
,xValueParser
:Dygraph
.dateParser
,xTicker
:Dygraph
.dateTicker
,sigma
:2,errorBars
:false,fractions
:false,wilsonInterval
:true,customBars
:false};
4558 Dygraph
.prototype.__old_init__
=function(div
,_55
,_56
,_57
){
4561 for(var i
=0;i
<_56
.length
;i
++){
4564 MochiKit
.Base
.update(_57
,{"labels":_58
});
4566 this.__init__(div
,_55
,_57
);
4568 Dygraph
.prototype.__init__
=function(div
,_59
,_60
){
4574 this.rollPeriod_
=_60
.rollPeriod
||Dygraph
.DEFAULT_ROLL_PERIOD
;
4575 this.previousVerticalX_
=-1;
4576 this.fractions_
=_60
.fractions
||false;
4577 this.dateWindow_
=_60
.dateWindow
||null;
4578 this.valueRange_
=_60
.valueRange
||null;
4579 this.wilsonInterval_
=_60
.wilsonInterval
||true;
4581 if(div
.style
.width
==""){
4582 div
.style
.width
=Dygraph
.DEFAULT_WIDTH
+"px";
4584 if(div
.style
.height
==""){
4585 div
.style
.height
=Dygraph
.DEFAULT_HEIGHT
+"px";
4587 this.width_
=parseInt(div
.style
.width
,10);
4588 this.height_
=parseInt(div
.style
.height
,10);
4589 this.user_attrs_
={};
4590 MochiKit
.Base
.update(this.user_attrs_
,_60
);
4592 MochiKit
.Base
.update(this.attrs_
,Dygraph
.DEFAULT_ATTRS
);
4593 this.labelsFromCSV_
=(this.attr_("labels")==null);
4594 this.createInterface_();
4595 this.layoutOptions_
={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
4596 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
4597 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
4598 this.layout_
=new DygraphLayout(this.layoutOptions_
);
4599 this.renderOptions_
={colorScheme
:this.colors_
,strokeColor
:null,axisLineWidth
:Dygraph
.AXIS_LINE_WIDTH
};
4600 MochiKit
.Base
.update(this.renderOptions_
,this.attrs_
);
4601 MochiKit
.Base
.update(this.renderOptions_
,this.user_attrs_
);
4602 this.plotter_
=new DygraphCanvasRenderer(this,this.hidden_
,this.layout_
,this.renderOptions_
);
4603 this.createStatusMessage_();
4604 this.createRollInterface_();
4605 this.createDragInterface_();
4608 Dygraph
.prototype.attr_
=function(_61
){
4609 if(typeof (this.user_attrs_
[_61
])!="undefined"){
4610 return this.user_attrs_
[_61
];
4612 if(typeof (this.attrs_
[_61
])!="undefined"){
4613 return this.attrs_
[_61
];
4619 Dygraph
.prototype.log
=function(_62
,_63
){
4620 if(typeof (console
)!="undefined"){
4623 console
.debug("dygraphs: "+_63
);
4626 console
.info("dygraphs: "+_63
);
4628 case Dygraph
.WARNING
:
4629 console
.warn("dygraphs: "+_63
);
4632 console
.error("dygraphs: "+_63
);
4637 Dygraph
.prototype.info
=function(_64
){
4638 this.log(Dygraph
.INFO
,_64
);
4640 Dygraph
.prototype.warn
=function(_65
){
4641 this.log(Dygraph
.WARNING
,_65
);
4643 Dygraph
.prototype.error
=function(_66
){
4644 this.log(Dygraph
.ERROR
,_66
);
4646 Dygraph
.prototype.rollPeriod
=function(){
4647 return this.rollPeriod_
;
4649 Dygraph
.prototype.createInterface_
=function(){
4650 var _67
=this.maindiv_
;
4651 this.graphDiv
=MochiKit
.DOM
.DIV({style
:{"width":this.width_
+"px","height":this.height_
+"px"}});
4652 appendChildNodes(_67
,this.graphDiv
);
4653 var _68
=MochiKit
.DOM
.CANVAS
;
4654 this.canvas_
=_68({style
:{"position":"absolute"},width
:this.width_
,height
:this.height_
});
4655 appendChildNodes(this.graphDiv
,this.canvas_
);
4656 this.hidden_
=this.createPlotKitCanvas_(this.canvas_
);
4657 connect(this.hidden_
,"onmousemove",this,function(e
){
4660 connect(this.hidden_
,"onmouseout",this,function(e
){
4664 Dygraph
.prototype.createPlotKitCanvas_
=function(_70
){
4665 var h
=document
.createElement("canvas");
4666 h
.style
.position
="absolute";
4667 h
.style
.top
=_70
.style
.top
;
4668 h
.style
.left
=_70
.style
.left
;
4669 h
.width
=this.width_
;
4670 h
.height
=this.height_
;
4671 MochiKit
.DOM
.appendChildNodes(this.graphDiv
,h
);
4674 Dygraph
.prototype.setColors_
=function(){
4675 var num
=this.attr_("labels").length
-1;
4677 var _73
=this.attr_("colors");
4679 var sat
=this.attr_("colorSaturation")||1;
4680 var val
=this.attr_("colorValue")||0.5;
4681 for(var i
=1;i
<=num
;i
++){
4682 var hue
=(1*i
/(1+num
));
4683 this.colors_
.push(MochiKit
.Color
.Color
.fromHSV(hue
,sat
,val
));
4686 for(var i
=0;i
<num
;i
++){
4687 var _77
=_73
[i
%_73
.length
];
4688 this.colors_
.push(MochiKit
.Color
.Color
.fromString(_77
));
4691 this.renderOptions_
.colorScheme
=this.colors_
;
4692 MochiKit
.Base
.update(this.plotter_
.options
,this.renderOptions_
);
4693 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
4694 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
4696 Dygraph
.prototype.createStatusMessage_
=function(){
4697 if(!this.attr_("labelsDiv")){
4698 var _78
=this.attr_("labelsDivWidth");
4699 var _79
={"style":{"position":"absolute","fontSize":"14px","zIndex":10,"width":_78
+"px","top":"0px","left":(this.width_
-_78
-2)+"px","background":"white","textAlign":"left","overflow":"hidden"}};
4700 MochiKit
.Base
.update(_79
["style"],this.attr_("labelsDivStyles"));
4701 var div
=MochiKit
.DOM
.DIV(_79
);
4702 MochiKit
.DOM
.appendChildNodes(this.graphDiv
,div
);
4703 this.attrs_
.labelsDiv
=div
;
4706 Dygraph
.prototype.createRollInterface_
=function(){
4707 var _80
=this.attr_("showRoller")?"block":"none";
4708 var _81
={"type":"text","size":"2","value":this.rollPeriod_
,"style":{"position":"absolute","zIndex":10,"top":(this.plotter_
.area
.h
-25)+"px","left":(this.plotter_
.area
.x
+1)+"px","display":_80
}};
4709 var _82
=MochiKit
.DOM
.INPUT(_81
);
4710 var pa
=this.graphDiv
;
4711 MochiKit
.DOM
.appendChildNodes(pa
,_82
);
4712 connect(_82
,"onchange",this,function(){
4713 this.adjustRoll(_82
.value
);
4717 Dygraph
.prototype.createDragInterface_
=function(){
4727 var _93
=function(e
){
4728 return e
.mouse().page
.x
-px
;
4730 var _94
=function(e
){
4731 return e
.mouse().page
.y
-py
;
4733 connect(this.hidden_
,"onmousemove",function(_95
){
4737 _84
.drawZoomRect_(_86
,_88
,_90
);
4741 connect(this.hidden_
,"onmousedown",function(_96
){
4743 px
=PlotKit
.Base
.findPosX(_84
.canvas_
);
4744 py
=PlotKit
.Base
.findPosY(_84
.canvas_
);
4748 connect(document
,"onmouseup",this,function(_97
){
4755 connect(this.hidden_
,"onmouseout",this,function(_98
){
4761 connect(this.hidden_
,"onmouseup",this,function(_99
){
4766 var _100
=Math
.abs(_88
-_86
);
4767 var _101
=Math
.abs(_89
-_87
);
4768 if(_100
<2&&_101
<2&&_84
.attr_("clickCallback")!=null&&_84
.lastx_
!=undefined
){
4769 _84
.attr_("clickCallback")(_99
,new Date(_84
.lastx_
));
4772 _84
.doZoom_(Math
.min(_86
,_88
),Math
.max(_86
,_88
));
4774 _84
.canvas_
.getContext("2d").clearRect(0,0,_84
.canvas_
.width
,_84
.canvas_
.height
);
4780 connect(this.hidden_
,"ondblclick",this,function(_102
){
4781 _84
.dateWindow_
=null;
4782 _84
.drawGraph_(_84
.rawData_
);
4783 var _103
=_84
.rawData_
[0][0];
4784 var _104
=_84
.rawData_
[_84
.rawData_
.length
-1][0];
4785 if(_84
.attr_("zoomCallback")){
4786 _84
.attr_("zoomCallback")(_103
,_104
);
4790 Dygraph
.prototype.drawZoomRect_
=function(_105
,endX
,_107
){
4791 var ctx
=this.canvas_
.getContext("2d");
4793 ctx
.clearRect(Math
.min(_105
,_107
),0,Math
.abs(_105
-_107
),this.height_
);
4796 ctx
.fillStyle
="rgba(128,128,128,0.33)";
4797 ctx
.fillRect(Math
.min(_105
,endX
),0,Math
.abs(endX
-_105
),this.height_
);
4800 Dygraph
.prototype.doZoom_
=function(lowX
,_109
){
4801 var _110
=this.layout_
.points
;
4804 for(var i
=0;i
<_110
.length
;i
++){
4805 var cx
=_110
[i
].canvasx
;
4807 if(cx
<lowX
&&(_111
==null||x
>_111
)){
4810 if(cx
>_109
&&(_112
==null||x
<_112
)){
4818 _112
=_110
[_110
.length
-1].xval
;
4820 this.dateWindow_
=[_111
,_112
];
4821 this.drawGraph_(this.rawData_
);
4822 if(this.attr_("zoomCallback")){
4823 this.attr_("zoomCallback")(_111
,_112
);
4826 Dygraph
.prototype.mouseMove_
=function(_114
){
4827 var _115
=_114
.mouse().page
.x
-PlotKit
.Base
.findPosX(this.hidden_
);
4828 var _116
=this.layout_
.points
;
4833 for(var i
=0;i
<_116
.length
;i
++){
4834 var dist
=Math
.abs(_116
[i
].canvasx
-_115
);
4842 _117
=_116
[idx
].xval
;
4844 if(_115
>_116
[_116
.length
-1].canvasx
){
4845 _117
=_116
[_116
.length
-1].xval
;
4848 for(var i
=0;i
<_116
.length
;i
++){
4849 if(_116
[i
].xval
==_117
){
4853 var _123
=this.attr_("highlightCircleSize");
4854 var ctx
=this.canvas_
.getContext("2d");
4855 if(this.previousVerticalX_
>=0){
4856 var px
=this.previousVerticalX_
;
4857 ctx
.clearRect(px
-_123
-1,0,2*_123
+2,this.height_
);
4859 var isOK
=function(x
){
4860 return x
&&!isNaN(x
);
4863 var _115
=_122
[0].canvasx
;
4864 var _125
=this.attr_("xValueFormatter")(_117
,this)+":";
4865 var clen
=this.colors_
.length
;
4866 for(var i
=0;i
<_122
.length
;i
++){
4867 if(!isOK(_122
[i
].canvasy
)){
4870 if(this.attr_("labelsSeparateLines")){
4874 _125
+=" <b><font color='"+this.colors_
[i
%clen
].toHexString()+"'>"+_127
.name
+"</font></b>:"+this.round_(_127
.yval
,2);
4876 this.attr_("labelsDiv").innerHTML
=_125
;
4879 for(var i
=0;i
<_122
.length
;i
++){
4880 if(!isOK(_122
[i
%clen
].canvasy
)){
4884 ctx
.fillStyle
=this.colors_
[i
%clen
].toRGBString();
4885 ctx
.arc(_115
,_122
[i
%clen
].canvasy
,_123
,0,360,false);
4889 this.previousVerticalX_
=_115
;
4892 Dygraph
.prototype.mouseOut_
=function(_128
){
4893 var ctx
=this.canvas_
.getContext("2d");
4894 ctx
.clearRect(0,0,this.width_
,this.height_
);
4895 this.attr_("labelsDiv").innerHTML
="";
4897 Dygraph
.zeropad
=function(x
){
4904 Dygraph
.prototype.hmsString_
=function(date
){
4905 var _130
=Dygraph
.zeropad
;
4906 var d
=new Date(date
);
4908 return _130(d
.getHours())+":"+_130(d
.getMinutes())+":"+_130(d
.getSeconds());
4911 return _130(d
.getHours())+":"+_130(d
.getMinutes());
4913 return _130(d
.getHours());
4917 Dygraph
.dateString_
=function(date
,self
){
4918 var _133
=Dygraph
.zeropad
;
4919 var d
=new Date(date
);
4920 var year
=""+d
.getFullYear();
4921 var _135
=_133(d
.getMonth()+1);
4922 var day
=_133(d
.getDate());
4924 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
4926 ret
=" "+self
.hmsString_(date
);
4928 return year
+"/"+_135+"/"+day
+ret
;
4930 Dygraph
.prototype.round_
=function(num
,_139
){
4931 var _140
=Math
.pow(10,_139
);
4932 return Math
.round(num
*_140
)/_140
;
4934 Dygraph
.prototype.loadedEvent_
=function(data
){
4935 this.rawData_
=this.parseCSV_(data
);
4936 this.drawGraph_(this.rawData_
);
4938 Dygraph
.prototype.months
=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
4939 Dygraph
.prototype.quarters
=["Jan","Apr","Jul","Oct"];
4940 Dygraph
.prototype.addXTicks_
=function(){
4942 if(this.dateWindow_
){
4943 _142
=this.dateWindow_
[0];
4944 endDate
=this.dateWindow_
[1];
4946 _142
=this.rawData_
[0][0];
4947 endDate
=this.rawData_
[this.rawData_
.length
-1][0];
4949 var _143
=this.attr_("xTicker")(_142
,endDate
,this);
4950 this.layout_
.updateOptions({xTicks
:_143
});
4953 Dygraph
.TEN_SECONDLY
=1;
4954 Dygraph
.THIRTY_SECONDLY
=2;
4956 Dygraph
.TEN_MINUTELY
=4;
4957 Dygraph
.THIRTY_MINUTELY
=5;
4959 Dygraph
.SIX_HOURLY
=7;
4963 Dygraph
.QUARTERLY
=11;
4964 Dygraph
.BIANNUAL
=12;
4967 Dygraph
.NUM_GRANULARITIES
=15;
4968 Dygraph
.SHORT_SPACINGS
=[];
4969 Dygraph
.SHORT_SPACINGS
[Dygraph
.SECONDLY
]=1000*1;
4970 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_SECONDLY
]=1000*10;
4971 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_SECONDLY
]=1000*30;
4972 Dygraph
.SHORT_SPACINGS
[Dygraph
.MINUTELY
]=1000*60;
4973 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_MINUTELY
]=1000*60*10;
4974 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_MINUTELY
]=1000*60*30;
4975 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600;
4976 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600*6;
4977 Dygraph
.SHORT_SPACINGS
[Dygraph
.DAILY
]=1000*86400;
4978 Dygraph
.SHORT_SPACINGS
[Dygraph
.WEEKLY
]=1000*604800;
4979 Dygraph
.prototype.NumXTicks
=function(_144
,_145
,_146
){
4980 if(_146
<Dygraph
.MONTHLY
){
4981 var _147
=Dygraph
.SHORT_SPACINGS
[_146
];
4982 return Math
.floor(0.5+1*(_145
-_144
)/_147
);
4986 if(_146
==Dygraph
.QUARTERLY
){
4989 if(_146
==Dygraph
.BIANNUAL
){
4992 if(_146
==Dygraph
.ANNUAL
){
4995 if(_146
==Dygraph
.DECADAL
){
4999 var _150
=365.2524*24*3600*1000;
5000 var _151
=1*(_145
-_144
)/_150
;
5001 return Math
.floor(0.5+1*_151
*_149
/_148
);
5004 Dygraph
.prototype.GetXAxis
=function(_152
,_153
,_154
){
5006 if(_154
<Dygraph
.MONTHLY
){
5007 var _156
=Dygraph
.SHORT_SPACINGS
[_154
];
5009 if(_154
<Dygraph
.HOURLY
){
5010 _152
=_156
*Math
.floor(0.5+_152
/_156
);
5012 for(var t
=_152
;t
<=_153
;t
+=_156
){
5014 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
5015 if(frac
==0||_154
>=Dygraph
.DAILY
){
5016 _155
.push({v
:t
,label
:new Date(t
+3600*1000).strftime(_157
)});
5018 _155
.push({v
:t
,label
:this.hmsString_(t
)});
5024 if(_154
==Dygraph
.MONTHLY
){
5025 _159
=[0,1,2,3,4,5,6,7,8,9,10,11,12];
5027 if(_154
==Dygraph
.QUARTERLY
){
5030 if(_154
==Dygraph
.BIANNUAL
){
5033 if(_154
==Dygraph
.ANNUAL
){
5036 if(_154
==Dygraph
.DECADAL
){
5044 var _161
=new Date(_152
).getFullYear();
5045 var _162
=new Date(_153
).getFullYear();
5046 var _163
=Dygraph
.zeropad
;
5047 for(var i
=_161
;i
<=_162
;i
++){
5051 for(var j
=0;j
<_159
.length
;j
++){
5052 var _164
=i
+"/"+_163(1+_159[j])+"/01";
5053 var t
=Date
.parse(_164
);
5057 _155
.push({v
:t
,label
:new Date(t
).strftime("%b %y")});
5063 Dygraph
.dateTicker
=function(_165
,_166
,self
){
5065 for(var i
=0;i
<Dygraph
.NUM_GRANULARITIES
;i
++){
5066 var _168
=self
.NumXTicks(_165
,_166
,i
);
5067 if(self
.width_
/_168
>=self
.attr_("pixelsPerXLabel")){
5073 return self
.GetXAxis(_165
,_166
,_167
);
5077 Dygraph
.numericTicks
=function(minV
,maxV
,self
){
5079 var _172
,low_val
,high_val
,nTicks
;
5080 var _173
=self
.attr_("pixelsPerYLabel");
5081 for(var i
=-10;i
<50;i
++){
5082 var _174
=Math
.pow(10,i
);
5083 for(var j
=0;j
<_171
.length
;j
++){
5085 low_val
=Math
.floor(minV
/_172
)*_172
;
5086 high_val
=Math
.ceil(maxV
/_172
)*_172
;
5087 nTicks
=(high_val
-low_val
)/_172
;
5088 var _175
=self
.height_
/nTicks
;
5098 for(var i
=0;i
<nTicks
;i
++){
5099 var _177
=low_val
+i
*_172
;
5100 var _178
=self
.round_(_177
,2);
5101 if(self
.attr_("labelsKMB")){
5104 _178
=self
.round_(_177
/(k
*k
*k
),1)+"B";
5107 _178
=self
.round_(_177
/(k
*k
),1)+"M";
5110 _178
=self
.round_(_177
/k
,1)+"K";
5115 _176
.push({label
:_178
,v
:_177
});
5119 Dygraph
.prototype.addYTicks_
=function(minY
,maxY
){
5120 var _182
=Dygraph
.numericTicks(minY
,maxY
,this);
5121 this.layout_
.updateOptions({yAxis
:[minY
,maxY
],yTicks
:_182
});
5123 Dygraph
.prototype.extremeValues_
=function(_183
){
5124 var minY
=null,maxY
=null;
5125 var bars
=this.attr_("errorBars")||this.attr_("customBars");
5127 for(var j
=0;j
<_183
.length
;j
++){
5128 var y
=_183
[j
][1][0];
5132 var low
=y
-_183
[j
][1][1];
5133 var high
=y
+_183
[j
][1][2];
5140 if(maxY
==null||high
>maxY
){
5143 if(minY
==null||low
<minY
){
5148 for(var j
=0;j
<_183
.length
;j
++){
5153 if(maxY
==null||y
>maxY
){
5156 if(minY
==null||y
<minY
){
5163 Dygraph
.prototype.drawGraph_
=function(data
){
5164 var minY
=null,maxY
=null;
5165 this.layout_
.removeAllDatasets();
5167 this.attrs_
["pointSize"]=0.5*this.attr_("highlightCircleSize");
5168 for(var i
=1;i
<data
[0].length
;i
++){
5170 for(var j
=0;j
<data
.length
;j
++){
5171 var date
=data
[j
][0];
5172 _187
[j
]=[date
,data
[j
][i
]];
5174 _187
=this.rollingAverage(_187
,this.rollPeriod_
);
5175 var bars
=this.attr_("errorBars")||this.attr_("customBars");
5176 if(this.dateWindow_
){
5177 var low
=this.dateWindow_
[0];
5178 var high
=this.dateWindow_
[1];
5180 for(var k
=0;k
<_187
.length
;k
++){
5181 if(_187
[k
][0]>=low
&&_187
[k
][0]<=high
){
5187 var _189
=this.extremeValues_(_187
);
5190 if(!minY
||_190
<minY
){
5193 if(!maxY
||_191
>maxY
){
5198 for(var j
=0;j
<_187
.length
;j
++){
5199 vals
[j
]=[_187
[j
][0],_187
[j
][1][0],_187
[j
][1][1],_187
[j
][1][2]];
5201 this.layout_
.addDataset(this.attr_("labels")[i
],vals
);
5203 this.layout_
.addDataset(this.attr_("labels")[i
],_187
);
5206 if(this.valueRange_
!=null){
5207 this.addYTicks_(this.valueRange_
[0],this.valueRange_
[1]);
5210 var _194
=maxY
+0.1*span
;
5211 var _195
=minY
-0.1*span
;
5212 if(_195
<0&&minY
>=0){
5215 if(_194
>0&&maxY
<=0){
5218 if(this.attr_("includeZero")){
5226 this.addYTicks_(_195
,_194
);
5229 this.layout_
.evaluateWithError();
5230 this.plotter_
.clear();
5231 this.plotter_
.render();
5232 this.canvas_
.getContext("2d").clearRect(0,0,this.canvas_
.width
,this.canvas_
.height
);
5234 Dygraph
.prototype.rollingAverage
=function(_196
,_197
){
5238 var _197
=Math
.min(_197
,_196
.length
-1);
5240 var _199
=this.attr_("sigma");
5241 if(this.fractions_
){
5245 for(var i
=0;i
<_196
.length
;i
++){
5249 num
-=_196
[i
-_197
][1][0];
5250 den
-=_196
[i
-_197
][1][1];
5252 var date
=_196
[i
][0];
5253 var _202
=den
?num
/den
:0;
5254 if(this.attr_("errorBars")){
5255 if(this.wilsonInterval_
){
5257 var p
=_202
<0?0:_202
,n
=den
;
5258 var pm
=_199
*Math
.sqrt(p
*(1-p
)/n+_199*_199/(4*n
*n
));
5259 var _205
=1+_199
*_199
/den
;
5260 var low
=(p
+_199
*_199
/(2*den)-pm)/_205
;
5261 var high
=(p
+_199
*_199
/(2*den)+pm)/_205
;
5262 _198
[i
]=[date
,[p
*mult
,(p
-low
)*mult
,(high
-p
)*mult
]];
5264 _198
[i
]=[date
,[0,0,0]];
5267 var _206
=den
?_199
*Math
.sqrt(_202
*(1-_202
)/den
):1;
5268 _198
[i
]=[date
,[mult
*_202
,mult
*_206
,mult
*_206
]];
5271 _198
[i
]=[date
,mult
*_202
];
5275 if(this.attr_("customBars")){
5280 for(var i
=0;i
<_196
.length
;i
++){
5281 var data
=_196
[i
][1];
5283 _198
[i
]=[_196
[i
][0],[y
,y
-data
[0],data
[2]-y
]];
5289 var prev
=_196
[i
-_197
];
5295 _198
[i
]=[_196
[i
][0],[1*mid
/_208,1*(mid-low)/_208
,1*(high
-mid
)/_208
]];
5298 var _210
=Math
.min(_197
-1,_196
.length
-2);
5299 if(!this.attr_("errorBars")){
5303 for(var i
=0;i
<_196
.length
;i
++){
5306 for(var j
=Math
.max(0,i
-_197
+1);j
<i
+1;j
++){
5315 _198
[i
]=[_196
[i
][0],sum
/_212
];
5317 _198
[i
]=[_196
[i
][0],null];
5321 for(var i
=0;i
<_196
.length
;i
++){
5325 for(var j
=Math
.max(0,i
-_197
+1);j
<i
+1;j
++){
5326 var y
=_196
[j
][1][0];
5332 _213
+=Math
.pow(_196
[j
][1][1],2);
5335 var _206
=Math
.sqrt(_213
)/_212
;
5336 _198
[i
]=[_196
[i
][0],[sum
/_212
,_199
*_206
,_199
*_206
]];
5338 _198
[i
]=[_196
[i
][0],[null,null,null]];
5346 Dygraph
.dateParser
=function(_214
,self
){
5349 if(_214
.length
==10&&_214
.search("-")!=-1){
5350 _215
=_214
.replace("-","/","g");
5351 while(_215
.search("-")!=-1){
5352 _215
=_215
.replace("-","/");
5357 _215
=_214
.substr(0,4)+"/"+_214.substr(4,2)+"/"+_214
.substr(6,2);
5364 self
.error("Couldn't parse "+_214
+" as a date");
5368 Dygraph
.prototype.detectTypeFromString_
=function(str
){
5370 if(str
.indexOf("-")>=0||str
.indexOf("/")>=0||isNaN(parseFloat(str
))){
5373 if(str
.length
==8&&str
>"19700101"&&str
<"20371231"){
5378 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
5379 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
5380 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
5382 this.attrs_
.xValueFormatter
=function(x
){
5385 this.attrs_
.xValueParser
=function(x
){
5386 return parseFloat(x
);
5388 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
5391 Dygraph
.prototype.parseCSV_
=function(data
){
5393 var _218
=data
.split("\n");
5395 if(this.labelsFromCSV_
){
5397 this.attrs_
.labels
=_218
[0].split(",");
5401 var _222
=this.attr_("labels").length
;
5402 for(var i
=_219
;i
<_218
.length
;i
++){
5407 var _224
=line
.split(",");
5413 this.detectTypeFromString_(_224
[0]);
5414 _220
=this.attr_("xValueParser");
5417 _225
[0]=_220(_224
[0],this);
5418 if(this.fractions_
){
5419 for(var j
=1;j
<_224
.length
;j
++){
5420 var vals
=_224
[j
].split("/");
5421 _225
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1])];
5424 if(this.attr_("errorBars")){
5425 for(var j
=1;j
<_224
.length
;j
+=2){
5426 _225
[(j
+1)/2]=[parseFloat(_224
[j
]),parseFloat(_224
[j
+1])];
5429 if(this.attr_("customBars")){
5430 for(var j
=1;j
<_224
.length
;j
++){
5431 var vals
=_224
[j
].split(";");
5432 _225
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1]),parseFloat(vals
[2])];
5435 for(var j
=1;j
<_224
.length
;j
++){
5436 _225
[j
]=parseFloat(_224
[j
]);
5442 if(_225
.length
!=_222
){
5443 this.error("Number of columns in line "+i
+" ("+_225
.length
+") does not agree with number of labels ("+_222
+") "+line
);
5448 Dygraph
.prototype.parseArray_
=function(data
){
5450 this.error("Can't plot empty data set");
5453 if(data
[0].length
==0){
5454 this.error("Data set cannot contain an empty row");
5457 if(this.attr_("labels")==null){
5458 this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
5459 this.attrs_
.labels
=["X"];
5460 for(var i
=1;i
<data
[0].length
;i
++){
5461 this.attrs_
.labels
.push("Y"+i
);
5464 if(MochiKit
.Base
.isDateLike(data
[0][0])){
5465 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
5466 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
5467 var _226
=MochiKit
.Base
.clone(data
);
5468 for(var i
=0;i
<data
.length
;i
++){
5469 if(_226
[i
].length
==0){
5470 this.error("Row "<<(1+i
)<<" of data is empty");
5473 if(_226
[i
][0]==null||typeof (_226
[i
][0].getTime
)!="function"){
5474 this.error("x value in row "<<(1+i
)<<" is not a Date");
5477 _226
[i
][0]=_226
[i
][0].getTime();
5481 this.attrs_
.xValueFormatter
=function(x
){
5484 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
5488 Dygraph
.prototype.parseDataTable_
=function(data
){
5489 var cols
=data
.getNumberOfColumns();
5490 var rows
=data
.getNumberOfRows();
5492 for(var i
=0;i
<cols
;i
++){
5493 _229
.push(data
.getColumnLabel(i
));
5495 this.attrs_
.labels
=_229
;
5496 var _230
=data
.getColumnType(0);
5498 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
5499 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
5500 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
5503 this.attrs_
.xValueFormatter
=function(x
){
5506 this.attrs_
.xValueParser
=function(x
){
5507 return parseFloat(x
);
5509 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
5511 this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_230
+"')");
5516 for(var i
=0;i
<rows
;i
++){
5518 if(!data
.getValue(i
,0)){
5522 row
.push(data
.getValue(i
,0).getTime());
5524 row
.push(data
.getValue(i
,0));
5526 for(var j
=1;j
<cols
;j
++){
5527 row
.push(data
.getValue(i
,j
));
5533 Dygraph
.prototype.start_
=function(){
5534 if(typeof this.file_
=="function"){
5535 this.loadedEvent_(this.file_());
5537 if(MochiKit
.Base
.isArrayLike(this.file_
)){
5538 this.rawData_
=this.parseArray_(this.file_
);
5539 this.drawGraph_(this.rawData_
);
5541 if(typeof this.file_
=="object"&&typeof this.file_
.getColumnRange
=="function"){
5542 this.rawData_
=this.parseDataTable_(this.file_
);
5543 this.drawGraph_(this.rawData_
);
5545 if(typeof this.file_
=="string"){
5546 if(this.file_
.indexOf("\n")>=0){
5547 this.loadedEvent_(this.file_
);
5549 var req
=new XMLHttpRequest();
5551 req
.onreadystatechange
=function(){
5552 if(req
.readyState
==4){
5553 if(req
.status
==200){
5554 _233
.loadedEvent_(req
.responseText
);
5558 req
.open("GET",this.file_
,true);
5562 this.error("Unknown data format: "+(typeof this.file_
));
5568 Dygraph
.prototype.updateOptions
=function(_234
){
5569 if(_234
.rollPeriod
){
5570 this.rollPeriod_
=_234
.rollPeriod
;
5572 if(_234
.dateWindow
){
5573 this.dateWindow_
=_234
.dateWindow
;
5575 if(_234
.valueRange
){
5576 this.valueRange_
=_234
.valueRange
;
5578 MochiKit
.Base
.update(this.user_attrs_
,_234
);
5579 this.labelsFromCSV_
=(this.attr_("labels")==null);
5580 this.layout_
.updateOptions({"errorBars":this.attr_("errorBars")});
5581 if(_234
["file"]&&_234
["file"]!=this.file_
){
5582 this.file_
=_234
["file"];
5585 this.drawGraph_(this.rawData_
);
5588 Dygraph
.prototype.adjustRoll
=function(_235
){
5589 this.rollPeriod_
=_235
;
5590 this.drawGraph_(this.rawData_
);
5592 Dygraph
.GVizChart
=function(_236
){
5593 this.container
=_236
;
5595 Dygraph
.GVizChart
.prototype.draw
=function(data
,_237
){
5596 this.container
.innerHTML
="";
5597 this.date_graph
=new Dygraph(this.container
,data
,_237
);