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.Color");
1006 dojo
.require("MochiKit.Base");
1008 if(typeof (JSAN
)!="undefined"){
1009 JSAN
.use("MochiKit.Base",[]);
1012 if(typeof (MochiKit
.Base
)=="undefined"){
1017 throw "MochiKit.Color depends on MochiKit.Base";
1019 if(typeof (MochiKit
.Color
)=="undefined"){
1022 MochiKit
.Color
.NAME
="MochiKit.Color";
1023 MochiKit
.Color
.VERSION
="1.4";
1024 MochiKit
.Color
.__repr__
=function(){
1025 return "["+this.NAME
+" "+this.VERSION
+"]";
1027 MochiKit
.Color
.toString
=function(){
1028 return this.__repr__();
1030 MochiKit
.Color
.Color
=function(red
,_14e
,blue
,_150
){
1031 if(typeof (_150
)=="undefined"||_150
===null){
1034 this.rgb
={r
:red
,g
:_14e
,b
:blue
,a
:_150
};
1036 MochiKit
.Color
.Color
.prototype={__class__
:MochiKit
.Color
.Color
,colorWithAlpha
:function(_151
){
1038 var m
=MochiKit
.Color
;
1039 return m
.Color
.fromRGB(rgb
.r
,rgb
.g
,rgb
.b
,_151
);
1040 },colorWithHue
:function(hue
){
1041 var hsl
=this.asHSL();
1043 var m
=MochiKit
.Color
;
1044 return m
.Color
.fromHSL(hsl
);
1045 },colorWithSaturation
:function(_157
){
1046 var hsl
=this.asHSL();
1048 var m
=MochiKit
.Color
;
1049 return m
.Color
.fromHSL(hsl
);
1050 },colorWithLightness
:function(_15a
){
1051 var hsl
=this.asHSL();
1053 var m
=MochiKit
.Color
;
1054 return m
.Color
.fromHSL(hsl
);
1055 },darkerColorWithLevel
:function(_15d
){
1056 var hsl
=this.asHSL();
1057 hsl
.l
=Math
.max(hsl
.l
-_15d
,0);
1058 var m
=MochiKit
.Color
;
1059 return m
.Color
.fromHSL(hsl
);
1060 },lighterColorWithLevel
:function(_160
){
1061 var hsl
=this.asHSL();
1062 hsl
.l
=Math
.min(hsl
.l
+_160
,1);
1063 var m
=MochiKit
.Color
;
1064 return m
.Color
.fromHSL(hsl
);
1065 },blendedColor
:function(_163
,_164
){
1066 if(typeof (_164
)=="undefined"||_164
===null){
1073 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
));
1074 },compareRGB
:function(_169
){
1077 return MochiKit
.Base
.compare([a
.r
,a
.g
,a
.b
,a
.a
],[b
.r
,b
.g
,b
.b
,b
.a
]);
1078 },isLight
:function(){
1079 return this.asHSL().b
>0.5;
1080 },isDark
:function(){
1081 return (!this.isLight());
1082 },toHSLString
:function(){
1084 var ccc
=MochiKit
.Color
.clampColorComponent
;
1085 var rval
=this._hslString
;
1087 var mid
=(ccc(c
.h
,360).toFixed(0)+","+ccc(c
.s
,100).toPrecision(4)+"%"+","+ccc(c
.l
,100).toPrecision(4)+"%");
1091 rval
="hsl("+mid
+")";
1096 rval
="hsla("+mid
+","+a
+")";
1098 this._hslString
=rval
;
1101 },toRGBString
:function(){
1103 var ccc
=MochiKit
.Color
.clampColorComponent
;
1104 var rval
=this._rgbString
;
1106 var mid
=(ccc(c
.r
,255).toFixed(0)+","+ccc(c
.g
,255).toFixed(0)+","+ccc(c
.b
,255).toFixed(0));
1108 rval
="rgba("+mid
+","+c
.a
+")";
1110 rval
="rgb("+mid
+")";
1112 this._rgbString
=rval
;
1116 return MochiKit
.Base
.clone(this.rgb
);
1117 },toHexString
:function(){
1118 var m
=MochiKit
.Color
;
1120 var ccc
=MochiKit
.Color
.clampColorComponent
;
1121 var rval
=this._hexString
;
1123 rval
=("#"+m
.toColorPart(ccc(c
.r
,255))+m
.toColorPart(ccc(c
.g
,255))+m
.toColorPart(ccc(c
.b
,255)));
1124 this._hexString
=rval
;
1130 if(typeof (hsv
)=="undefined"||hsv
===null){
1131 hsv
=MochiKit
.Color
.rgbToHSV(this.rgb
);
1134 return MochiKit
.Base
.clone(hsv
);
1138 if(typeof (hsl
)=="undefined"||hsl
===null){
1139 hsl
=MochiKit
.Color
.rgbToHSL(this.rgb
);
1142 return MochiKit
.Base
.clone(hsl
);
1143 },toString
:function(){
1144 return this.toRGBString();
1147 var col
=[c
.r
,c
.g
,c
.b
,c
.a
];
1148 return this.__class__
.NAME
+"("+col
.join(", ")+")";
1150 MochiKit
.Base
.update(MochiKit
.Color
.Color
,{fromRGB
:function(red
,_180
,blue
,_182
){
1151 var _183
=MochiKit
.Color
.Color
;
1152 if(arguments
.length
==1){
1157 if(typeof (rgb
.a
)=="undefined"){
1163 return new _183(red
,_180
,blue
,_182
);
1164 },fromHSL
:function(hue
,_186
,_187
,_188
){
1165 var m
=MochiKit
.Color
;
1166 return m
.Color
.fromRGB(m
.hslToRGB
.apply(m
,arguments
));
1167 },fromHSV
:function(hue
,_18b
,_18c
,_18d
){
1168 var m
=MochiKit
.Color
;
1169 return m
.Color
.fromRGB(m
.hsvToRGB
.apply(m
,arguments
));
1170 },fromName
:function(name
){
1171 var _190
=MochiKit
.Color
.Color
;
1172 if(name
.charAt(0)=="\""){
1173 name
=name
.substr(1,name
.length
-2);
1175 var _191
=_190
._namedColors
[name
.toLowerCase()];
1176 if(typeof (_191
)=="string"){
1177 return _190
.fromHexString(_191
);
1179 if(name
=="transparent"){
1180 return _190
.transparentColor();
1184 },fromString
:function(_192
){
1185 var self
=MochiKit
.Color
.Color
;
1186 var _194
=_192
.substr(0,3);
1188 return self
.fromRGBString(_192
);
1191 return self
.fromHSLString(_192
);
1193 if(_192
.charAt(0)=="#"){
1194 return self
.fromHexString(_192
);
1198 return self
.fromName(_192
);
1199 },fromHexString
:function(_195
){
1200 if(_195
.charAt(0)=="#"){
1201 _195
=_195
.substring(1);
1207 hex
=_195
.substr(i
,1);
1208 _196
.push(parseInt(hex
+hex
,16)/255);
1212 hex
=_195
.substr(i
,2);
1213 _196
.push(parseInt(hex
,16)/255);
1216 var _199
=MochiKit
.Color
.Color
;
1217 return _199
.fromRGB
.apply(_199
,_196
);
1218 },_fromColorString
:function(pre
,_19b
,_19c
,_19d
){
1219 if(_19d
.indexOf(pre
)===0){
1220 _19d
=_19d
.substring(_19d
.indexOf("(",3)+1,_19d
.length
-1);
1222 var _19e
=_19d
.split(/\s*,\s*/);
1224 for(var i
=0;i
<_19e
.length
;i
++){
1227 var _1a3
=c
.substring(c
.length
-3);
1228 if(c
.charAt(c
.length
-1)=="%"){
1229 val
=0.01*parseFloat(c
.substring(0,c
.length
-1));
1232 val
=parseFloat(c
)/360;
1235 val
=parseFloat(c
)/(Math
.PI
*2);
1237 val
=_19c
[i
]*parseFloat(c
);
1243 return this[_19b
].apply(this,_19f
);
1244 },fromBackground
:function(elem
){
1245 var cls
=MochiKit
.Color
.Color
;
1246 return cls
.fromComputedStyle(elem
,"backgroundColor","background-color")||cls
.whiteColor();
1247 },fromText
:function(elem
){
1248 var cls
=MochiKit
.Color
.Color
;
1249 return cls
.fromComputedStyle(elem
,"color","color")||cls
.blackColor();
1250 },namedColors
:function(){
1251 return MochiKit
.Base
.clone(MochiKit
.Color
.Color
._namedColors
);
1253 MochiKit
.Base
.update(MochiKit
.Color
,{clampColorComponent
:function(v
,_1a9
){
1264 },_hslValue
:function(n1
,n2
,hue
){
1280 val
=n1
+(n2
-n1
)*(4-hue
);
1287 },hsvToRGB
:function(hue
,_1af
,_1b0
,_1b1
){
1288 if(arguments
.length
==1){
1303 var i
=Math
.floor(hue
*6);
1305 var p
=_1b0
*(1-_1af
);
1306 var q
=_1b0
*(1-(_1af
*f
));
1307 var t
=_1b0
*(1-(_1af
*(1-f
)));
1342 return {r
:red
,g
:_1b4
,b
:blue
,a
:_1b1
};
1343 },hslToRGB
:function(hue
,_1bc
,_1bd
,_1be
){
1344 if(arguments
.length
==1){
1363 m2
=_1bd
+_1bc
-(_1bd
*_1bc
);
1366 var f
=MochiKit
.Color
._hslValue
;
1372 return {r
:red
,g
:_1c1
,b
:blue
,a
:_1be
};
1373 },rgbToHSV
:function(red
,_1c8
,blue
,_1ca
){
1374 if(arguments
.length
==1){
1381 var max
=Math
.max(Math
.max(red
,_1c8
),blue
);
1382 var min
=Math
.min(Math
.min(red
,_1c8
),blue
);
1393 hue
=(_1c8
-blue
)/_1d1
;
1396 hue
=2+((blue
-red
)/_1d1
);
1398 hue
=4+((red
-_1c8
)/_1d1
);
1409 return {h
:hue
,s
:_1cf
,v
:_1d0
,a
:_1ca
};
1410 },rgbToHSL
:function(red
,_1d3
,blue
,_1d5
){
1411 if(arguments
.length
==1){
1418 var max
=Math
.max(red
,Math
.max(_1d3
,blue
));
1419 var min
=Math
.min(red
,Math
.min(_1d3
,blue
));
1422 var _1db
=(max
+min
)/2;
1429 _1da
=_1dc
/(max
+min
);
1431 _1da
=_1dc
/(2-max
-min
);
1434 hue
=(_1d3
-blue
)/_1dc
;
1437 hue
=2+((blue
-red
)/_1dc
);
1439 hue
=4+((red
-_1d3
)/_1dc
);
1450 return {h
:hue
,s
:_1da
,l
:_1db
,a
:_1d5
};
1451 },toColorPart
:function(num
){
1452 num
=Math
.round(num
);
1453 var _1de
=num
.toString(16);
1458 },__new__
:function(){
1459 var m
=MochiKit
.Base
;
1460 this.Color
.fromRGBString
=m
.bind(this.Color
._fromColorString
,this.Color
,"rgb","fromRGB",[1/255,1/255,1/255,1]);
1461 this.Color
.fromHSLString
=m
.bind(this.Color
._fromColorString
,this.Color
,"hsl","fromHSL",[1/360,0.01,0.01,1]);
1463 var _1e1
={black
:[0,0,0],blue
:[0,0,1],brown
:[0.6,0.4,0.2],cyan
:[0,1,1],darkGray
:[_1e0
,_1e0
,_1e0
],gray
:[0.5,0.5,0.5],green
:[0,1,0],lightGray
:[2*_1e0
,2*_1e0
,2*_1e0
],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]};
1464 var _1e2
=function(name
,r
,g
,b
,a
){
1465 var rval
=this.fromRGB(r
,g
,b
,a
);
1466 this[name
]=function(){
1473 var _1eb
=m
.concat([_1e2
,this.Color
,name
],_1e1
[k
]);
1474 this.Color
[name
]=m
.bind
.apply(null,_1eb
);
1476 var _1ec
=function(){
1477 for(var i
=0;i
<arguments
.length
;i
++){
1478 if(!(arguments
[i
] instanceof Color
)){
1484 var _1ee
=function(a
,b
){
1485 return a
.compareRGB(b
);
1487 m
.nameFunctions(this);
1488 m
.registerComparator(this.Color
.NAME
,_1ec
,_1ee
);
1489 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
1491 MochiKit
.Color
.EXPORT
=["Color"];
1492 MochiKit
.Color
.EXPORT_OK
=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
1493 MochiKit
.Color
.__new__();
1494 MochiKit
.Base
._exportSymbols(this,MochiKit
.Color
);
1495 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"};
1496 if(typeof (dojo
)!="undefined"){
1497 dojo
.provide("MochiKit.DOM");
1498 dojo
.require("MochiKit.Base");
1500 if(typeof (JSAN
)!="undefined"){
1501 JSAN
.use("MochiKit.Base",[]);
1504 if(typeof (MochiKit
.Base
)=="undefined"){
1509 throw "MochiKit.DOM depends on MochiKit.Base!";
1511 if(typeof (MochiKit
.DOM
)=="undefined"){
1514 MochiKit
.DOM
.NAME
="MochiKit.DOM";
1515 MochiKit
.DOM
.VERSION
="1.4";
1516 MochiKit
.DOM
.__repr__
=function(){
1517 return "["+this.NAME
+" "+this.VERSION
+"]";
1519 MochiKit
.DOM
.toString
=function(){
1520 return this.__repr__();
1522 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"];
1523 MochiKit
.DOM
.EXPORT_OK
=["domConverters"];
1524 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"]];
1525 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);");
1526 MochiKit
.Base
.update(MochiKit
.DOM
,{currentWindow
:function(){
1527 return MochiKit
.DOM
._window
;
1528 },currentDocument
:function(){
1529 return MochiKit
.DOM
._document
;
1530 },withWindow
:function(win
,func
){
1531 var self
=MochiKit
.DOM
;
1532 var _1f4
=self
._document
;
1533 var _1f5
=self
._window
;
1537 self
._document
=win
.document
;
1542 self
._document
=_1f4
;
1546 self
._document
=_1f4
;
1548 },formContents
:function(elem
){
1551 var m
=MochiKit
.Base
;
1552 var self
=MochiKit
.DOM
;
1553 if(typeof (elem
)=="undefined"||elem
===null){
1554 elem
=self
._document
.body
;
1556 elem
=self
.getElement(elem
);
1558 m
.nodeWalk(elem
,function(elem
){
1560 if(m
.isNotEmpty(name
)){
1561 var _1fe
=elem
.tagName
.toUpperCase();
1562 if(_1fe
==="INPUT"&&(elem
.type
=="radio"||elem
.type
=="checkbox")&&!elem
.checked
){
1565 if(_1fe
==="SELECT"){
1566 if(elem
.type
=="select-one"){
1567 if(elem
.selectedIndex
>=0){
1568 var opt
=elem
.options
[elem
.selectedIndex
];
1571 var h
=opt
.outerHTML
;
1572 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
1584 var opts
=elem
.options
;
1590 for(var i
=0;i
<opts
.length
;i
++){
1597 var h
=opt
.outerHTML
;
1598 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
1608 if(_1fe
==="FORM"||_1fe
==="P"||_1fe
==="SPAN"||_1fe
==="DIV"){
1609 return elem
.childNodes
;
1612 _1f9
.push(elem
.value
||"");
1615 return elem
.childNodes
;
1618 },withDocument
:function(doc
,func
){
1619 var self
=MochiKit
.DOM
;
1620 var _207
=self
._document
;
1627 self
._document
=_207
;
1630 self
._document
=_207
;
1632 },registerDOMConverter
:function(name
,_20a
,wrap
,_20c
){
1633 MochiKit
.DOM
.domConverters
.register(name
,_20a
,wrap
,_20c
);
1634 },coerceToDOM
:function(node
,ctx
){
1635 var m
=MochiKit
.Base
;
1636 var im
=MochiKit
.Iter
;
1637 var self
=MochiKit
.DOM
;
1643 var _215
=self
.domConverters
;
1644 var _216
=arguments
.callee
;
1645 var _217
=m
.NotFound
;
1647 if(typeof (node
)=="undefined"||node
===null){
1650 if(typeof (node
)=="function"&&typeof (node
.length
)=="number"&&!(node
instanceof Function
)){
1653 if(typeof (node
.nodeType
)!="undefined"&&node
.nodeType
>0){
1656 if(typeof (node
)=="number"||typeof (node
)=="boolean"){
1657 node
=node
.toString();
1659 if(typeof (node
)=="string"){
1660 return self
._document
.createTextNode(node
);
1662 if(typeof (node
.__dom__
)=="function"){
1663 node
=node
.__dom__(ctx
);
1666 if(typeof (node
.dom
)=="function"){
1670 if(typeof (node
)=="function"){
1671 node
=node
.apply(ctx
,[ctx
]);
1682 return map(_216
,_218
,_213(ctx
));
1686 node
=_215
.match(node
,ctx
);
1694 return self
._document
.createTextNode(node
.toString());
1697 },isChildNode
:function(node
,_21a
){
1698 var self
=MochiKit
.DOM
;
1699 if(typeof (node
)=="string"){
1700 node
=self
.getElement(node
);
1702 if(typeof (_21a
)=="string"){
1703 _21a
=self
.getElement(_21a
);
1708 while(node
&&node
.tagName
.toUpperCase()!="BODY"){
1709 node
=node
.parentNode
;
1715 },setNodeAttribute
:function(node
,attr
,_21e
){
1719 return MochiKit
.DOM
.updateNodeAttributes(node
,o
);
1724 },getNodeAttribute
:function(node
,attr
){
1725 var self
=MochiKit
.DOM
;
1726 var _223
=self
.attributeArray
.renames
[attr
];
1727 node
=self
.getElement(node
);
1732 return node
.getAttribute(attr
);
1737 },removeNodeAttribute
:function(node
,attr
){
1738 var self
=MochiKit
.DOM
;
1739 var _227
=self
.attributeArray
.renames
[attr
];
1740 node
=self
.getElement(node
);
1745 return node
.removeAttribute(attr
);
1750 },updateNodeAttributes
:function(node
,_229
){
1752 var self
=MochiKit
.DOM
;
1753 if(typeof (node
)=="string"){
1754 elem
=self
.getElement(node
);
1757 var _22c
=MochiKit
.Base
.updatetree
;
1758 if(self
.attributeArray
.compliant
){
1761 if(typeof (v
)=="object"&&typeof (elem
[k
])=="object"){
1762 if(k
=="style"&&MochiKit
.Style
){
1763 MochiKit
.Style
.setStyle(elem
,v
);
1768 if(k
.substring(0,2)=="on"){
1769 if(typeof (v
)=="string"){
1774 elem
.setAttribute(k
,v
);
1779 var _22f
=self
.attributeArray
.renames
;
1783 if(k
=="style"&&typeof (v
)=="string"){
1784 elem
.style
.cssText
=v
;
1786 if(typeof (_230
)=="string"){
1789 if(typeof (elem
[k
])=="object"&&typeof (v
)=="object"){
1790 if(k
=="style"&&MochiKit
.Style
){
1791 MochiKit
.Style
.setStyle(elem
,v
);
1796 if(k
.substring(0,2)=="on"){
1797 if(typeof (v
)=="string"){
1802 elem
.setAttribute(k
,v
);
1811 },appendChildNodes
:function(node
){
1813 var self
=MochiKit
.DOM
;
1814 if(typeof (node
)=="string"){
1815 elem
=self
.getElement(node
);
1817 var _234
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1818 var _235
=MochiKit
.Base
.concat
;
1821 if(typeof (n
)=="undefined"||n
===null){
1823 if(typeof (n
.nodeType
)=="number"){
1824 elem
.appendChild(n
);
1831 },insertSiblingNodesBefore
:function(node
){
1833 var self
=MochiKit
.DOM
;
1834 if(typeof (node
)=="string"){
1835 elem
=self
.getElement(node
);
1837 var _23a
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1838 var _23b
=elem
.parentNode
;
1839 var _23c
=MochiKit
.Base
.concat
;
1842 if(typeof (n
)=="undefined"||n
===null){
1844 if(typeof (n
.nodeType
)=="number"){
1845 _23b
.insertBefore(n
,elem
);
1852 },insertSiblingNodesAfter
:function(node
){
1854 var self
=MochiKit
.DOM
;
1855 if(typeof (node
)=="string"){
1856 elem
=self
.getElement(node
);
1858 var _241
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1859 if(elem
.nextSibling
){
1860 return self
.insertSiblingNodesBefore(elem
.nextSibling
,_241
);
1862 return self
.appendChildNodes(elem
.parentNode
,_241
);
1864 },replaceChildNodes
:function(node
){
1866 var self
=MochiKit
.DOM
;
1867 if(typeof (node
)=="string"){
1868 elem
=self
.getElement(node
);
1872 while((_245
=elem
.firstChild
)){
1873 elem
.removeChild(_245
);
1875 if(arguments
.length
<2){
1878 return self
.appendChildNodes
.apply(this,arguments
);
1880 },createDOM
:function(name
,_247
){
1882 var self
=MochiKit
.DOM
;
1883 var m
=MochiKit
.Base
;
1884 if(typeof (_247
)=="string"||typeof (_247
)=="number"){
1885 var args
=m
.extend([name
,null],arguments
,1);
1886 return arguments
.callee
.apply(this,args
);
1888 if(typeof (name
)=="string"){
1889 var _24c
=self
._xhtml
;
1890 if(_247
&&!self
.attributeArray
.compliant
){
1893 _24d
+=" name=\""+self
.escapeHTML(_247
.name
)+"\"";
1895 if(name
=="input"&&"type" in _247
){
1896 _24d
+=" type=\""+self
.escapeHTML(_247
.type
)+"\"";
1899 name
="<"+name
+_24d
+">";
1903 var d
=self
._document
;
1904 if(_24c
&&d
===document
){
1905 elem
=d
.createElementNS("http://www.w3.org/1999/xhtml",name
);
1907 elem
=d
.createElement(name
);
1913 self
.updateNodeAttributes(elem
,_247
);
1915 if(arguments
.length
<=2){
1918 var args
=m
.extend([elem
],arguments
,2);
1919 return self
.appendChildNodes
.apply(this,args
);
1921 },createDOMFunc
:function(){
1922 var m
=MochiKit
.Base
;
1923 return m
.partial
.apply(this,m
.extend([MochiKit
.DOM
.createDOM
],arguments
));
1924 },removeElement
:function(elem
){
1925 var e
=MochiKit
.DOM
.getElement(elem
);
1926 e
.parentNode
.removeChild(e
);
1928 },swapDOM
:function(dest
,src
){
1929 var self
=MochiKit
.DOM
;
1930 dest
=self
.getElement(dest
);
1931 var _255
=dest
.parentNode
;
1933 src
=self
.getElement(src
);
1934 _255
.replaceChild(src
,dest
);
1936 _255
.removeChild(dest
);
1939 },getElement
:function(id
){
1940 var self
=MochiKit
.DOM
;
1941 if(arguments
.length
==1){
1942 return ((typeof (id
)=="string")?self
._document
.getElementById(id
):id
);
1944 return MochiKit
.Base
.map(self
.getElement
,arguments
);
1946 },getElementsByTagAndClassName
:function(_258
,_259
,_25a
){
1947 var self
=MochiKit
.DOM
;
1948 if(typeof (_258
)=="undefined"||_258
===null){
1951 if(typeof (_25a
)=="undefined"||_25a
===null){
1952 _25a
=self
._document
;
1954 _25a
=self
.getElement(_25a
);
1955 var _25c
=(_25a
.getElementsByTagName(_258
)||self
._document
.all
);
1956 if(typeof (_259
)=="undefined"||_259
===null){
1957 return MochiKit
.Base
.extend(null,_25c
);
1960 for(var i
=0;i
<_25c
.length
;i
++){
1962 var cls
=_25f
.className
;
1966 var _261
=cls
.split(" ");
1967 for(var j
=0;j
<_261
.length
;j
++){
1975 },_newCallStack
:function(path
,once
){
1976 var rval
=function(){
1977 var _266
=arguments
.callee
.callStack
;
1978 for(var i
=0;i
<_266
.length
;i
++){
1979 if(_266
[i
].apply(this,arguments
)===false){
1993 },addToCallStack
:function(_268
,path
,func
,once
){
1994 var self
=MochiKit
.DOM
;
1995 var _26d
=_268
[path
];
1997 if(!(typeof (_26d
)=="function"&&typeof (_26d
.callStack
)=="object"&&_26d
.callStack
!==null)){
1998 _26e
=self
._newCallStack(path
,once
);
1999 if(typeof (_26d
)=="function"){
2000 _26e
.callStack
.push(_26d
);
2004 _26e
.callStack
.push(func
);
2005 },addLoadEvent
:function(func
){
2006 var self
=MochiKit
.DOM
;
2007 self
.addToCallStack(self
._window
,"onload",func
,true);
2008 },focusOnLoad
:function(_271
){
2009 var self
=MochiKit
.DOM
;
2010 self
.addLoadEvent(function(){
2011 _271
=self
.getElement(_271
);
2016 },setElementClass
:function(_273
,_274
){
2017 var self
=MochiKit
.DOM
;
2018 var obj
=self
.getElement(_273
);
2019 if(self
.attributeArray
.compliant
){
2020 obj
.setAttribute("class",_274
);
2022 obj
.setAttribute("className",_274
);
2024 },toggleElementClass
:function(_277
){
2025 var self
=MochiKit
.DOM
;
2026 for(var i
=1;i
<arguments
.length
;i
++){
2027 var obj
=self
.getElement(arguments
[i
]);
2028 if(!self
.addElementClass(obj
,_277
)){
2029 self
.removeElementClass(obj
,_277
);
2032 },addElementClass
:function(_27b
,_27c
){
2033 var self
=MochiKit
.DOM
;
2034 var obj
=self
.getElement(_27b
);
2035 var cls
=obj
.className
;
2036 if(cls
==undefined
||cls
.length
===0){
2037 self
.setElementClass(obj
,_27c
);
2043 var _280
=cls
.split(" ");
2044 for(var i
=0;i
<_280
.length
;i
++){
2049 self
.setElementClass(obj
,cls
+" "+_27c
);
2051 },removeElementClass
:function(_282
,_283
){
2052 var self
=MochiKit
.DOM
;
2053 var obj
=self
.getElement(_282
);
2054 var cls
=obj
.className
;
2055 if(cls
==undefined
||cls
.length
===0){
2059 self
.setElementClass(obj
,"");
2062 var _287
=cls
.split(" ");
2063 for(var i
=0;i
<_287
.length
;i
++){
2066 self
.setElementClass(obj
,_287
.join(" "));
2071 },swapElementClass
:function(_289
,_28a
,_28b
){
2072 var obj
=MochiKit
.DOM
.getElement(_289
);
2073 var res
=MochiKit
.DOM
.removeElementClass(obj
,_28a
);
2075 MochiKit
.DOM
.addElementClass(obj
,_28b
);
2078 },hasElementClass
:function(_28e
,_28f
){
2079 var obj
=MochiKit
.DOM
.getElement(_28e
);
2080 var cls
=obj
.className
;
2084 var _292
=cls
.split(" ");
2085 for(var i
=1;i
<arguments
.length
;i
++){
2087 for(var j
=0;j
<_292
.length
;j
++){
2088 if(_292
[j
]==arguments
[i
]){
2098 },escapeHTML
:function(s
){
2099 return s
.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");
2100 },toHTML
:function(dom
){
2101 return MochiKit
.DOM
.emitHTML(dom
).join("");
2102 },emitHTML
:function(dom
,lst
){
2103 if(typeof (lst
)=="undefined"||lst
===null){
2107 var self
=MochiKit
.DOM
;
2108 var _29c
=self
.escapeHTML
;
2109 var _29d
=self
.attributeArray
;
2112 if(typeof (dom
)=="string"){
2115 if(dom
.nodeType
==1){
2116 lst
.push("<"+dom
.tagName
.toLowerCase());
2119 for(var i
=0;i
<_29f
.length
;i
++){
2121 _29e
.push([" ",a
.name
,"=\"",_29c(a
.value
),"\""]);
2124 for(i
=0;i
<_29e
.length
;i
++){
2126 for(var j
=0;j
<_2a2
.length
;j
++){
2130 if(dom
.hasChildNodes()){
2132 _29a
.push("</"+dom
.tagName
.toLowerCase()+">");
2133 var _2a4
=dom
.childNodes
;
2134 for(i
=_2a4
.length
-1;i
>=0;i
--){
2141 if(dom
.nodeType
==3){
2142 lst
.push(_29c(dom
.nodeValue
));
2148 },scrapeText
:function(node
,_2a6
){
2151 var cn
=node
.childNodes
;
2153 for(var i
=0;i
<cn
.length
;i
++){
2154 arguments
.callee
.call(this,cn
[i
]);
2157 var _2ab
=node
.nodeValue
;
2158 if(typeof (_2ab
)=="string"){
2161 })(MochiKit
.DOM
.getElement(node
));
2165 return rval
.join("");
2167 },removeEmptyTextNodes
:function(_2ac
){
2168 _2ac
=MochiKit
.DOM
.getElement(_2ac
);
2169 for(var i
=0;i
<_2ac
.childNodes
.length
;i
++){
2170 var node
=_2ac
.childNodes
[i
];
2171 if(node
.nodeType
==3&&!/\S/.test(node
.nodeValue
)){
2172 node
.parentNode
.removeChild(node
);
2175 },makeClipping
:function(_2af
){
2176 _2af
=MochiKit
.DOM
.getElement(_2af
);
2177 var _2b0
=_2af
.style
.overflow
;
2178 if((MochiKit
.Style
.getStyle(_2af
,"overflow")||"visible")!="hidden"){
2179 _2af
.style
.overflow
="hidden";
2182 },undoClipping
:function(_2b1
,_2b2
){
2183 _2b1
=MochiKit
.DOM
.getElement(_2b1
);
2187 _2b1
.style
.overflow
=_2b2
;
2188 },makePositioned
:function(_2b3
){
2189 _2b3
=MochiKit
.DOM
.getElement(_2b3
);
2190 var pos
=MochiKit
.Style
.getStyle(_2b3
,"position");
2191 if(pos
=="static"||!pos
){
2192 _2b3
.style
.position
="relative";
2193 if(/Opera/.test(navigator
.userAgent
)){
2198 },undoPositioned
:function(_2b5
){
2199 _2b5
=MochiKit
.DOM
.getElement(_2b5
);
2200 if(_2b5
.style
.position
=="relative"){
2201 _2b5
.style
.position
=_2b5
.style
.top
=_2b5
.style
.left
=_2b5
.style
.bottom
=_2b5
.style
.right
="";
2203 },getFirstElementByTagAndClassName
:function(_2b6
,_2b7
,_2b8
){
2204 var self
=MochiKit
.DOM
;
2205 if(typeof (_2b6
)=="undefined"||_2b6
===null){
2208 if(typeof (_2b8
)=="undefined"||_2b8
===null){
2209 _2b8
=self
._document
;
2211 _2b8
=self
.getElement(_2b8
);
2212 var _2ba
=(_2b8
.getElementsByTagName(_2b6
)||self
._document
.all
);
2213 if(typeof (_2b7
)=="undefined"||_2b7
===null){
2216 for(var i
=0;i
<_2ba
.length
;i
++){
2218 var _2bd
=_2bc
.className
.split(" ");
2219 for(var j
=0;j
<_2bd
.length
;j
++){
2225 },getFirstParentByTagAndClassName
:function(elem
,_2c0
,_2c1
){
2226 var self
=MochiKit
.DOM
;
2227 elem
=self
.getElement(elem
);
2228 if(typeof (_2c0
)=="undefined"||_2c0
===null){
2231 _2c0
=_2c0
.toUpperCase();
2233 if(typeof (_2c1
)=="undefined"||_2c1
===null){
2238 while(elem
&&elem
.tagName
){
2239 elem
=elem
.parentNode
;
2240 if(_2c0
=="*"&&_2c1
===null){
2243 _2c3
=elem
.className
.split(" ");
2244 _2c4
=elem
.tagName
.toUpperCase();
2245 if(_2c1
===null&&_2c0
==_2c4
){
2249 for(var i
=0;i
<_2c3
.length
;i
++){
2250 if(_2c0
=="*"&&_2c3
[i
]==_2c1
){
2253 if(_2c0
==_2c4
&&_2c3
[i
]==_2c1
){
2262 },isParent
:function(_2c6
,_2c7
){
2263 if(!_2c6
.parentNode
||_2c6
==_2c7
){
2266 if(_2c6
.parentNode
==_2c7
){
2269 return MochiKit
.DOM
.isParent(_2c6
.parentNode
,_2c7
);
2270 },__new__
:function(win
){
2271 var m
=MochiKit
.Base
;
2272 if(typeof (document
)!="undefined"){
2273 this._document
=document
;
2274 var _2ca
="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
2275 this._xhtml
=(document
.documentElement
&&document
.createElementNS
&&document
.documentElement
.namespaceURI
===_2ca
);
2277 if(MochiKit
.MockDOM
){
2278 this._document
=MochiKit
.MockDOM
.document
;
2282 this.domConverters
=new m
.AdapterRegistry();
2283 var _2cb
=this._document
.createElement("span");
2285 if(_2cb
&&_2cb
.attributes
&&_2cb
.attributes
.length
>0){
2287 _2cc
=function(node
){
2288 return _2cd(_2cc
.ignoreAttrFilter
,node
.attributes
);
2291 var _2cf
=_2cb
.attributes
;
2292 var _2d0
=_2cc
.ignoreAttr
;
2293 for(var i
=0;i
<_2cf
.length
;i
++){
2295 _2d0
[a
.name
]=a
.value
;
2297 _2cc
.ignoreAttrFilter
=function(a
){
2298 return (_2cc
.ignoreAttr
[a
.name
]!=a
.value
);
2300 _2cc
.compliant
=false;
2301 _2cc
.renames
={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"};
2303 _2cc
=function(node
){
2304 return node
.attributes
;
2306 _2cc
.compliant
=true;
2309 this.attributeArray
=_2cc
;
2310 var _2d5
=function(_2d6
,arr
){
2311 var _2d8
=arr
[1].split(".");
2314 str
+="if (!MochiKit."+_2d8
[1]+") { throw new Error(\"";
2315 str
+="This function has been deprecated and depends on MochiKit.";
2316 str
+=_2d8
[1]+".\");}";
2317 str
+="return MochiKit."+_2d8
[1]+"."+arr
[0];
2318 str
+=".apply(this, arguments);";
2319 obj
[_2d8
[2]]=new Function(str
);
2320 MochiKit
.Base
.update(MochiKit
[_2d6
],obj
);
2322 for(var i
;i
<MochiKit
.DOM
.DEPRECATED
.length
;i
++){
2323 _2d5("DOM",MochiKit
.DOM
.DEPRECATED
[i
]);
2325 var _2db
=this.createDOMFunc
;
2331 this.TBODY
=_2db("tbody");
2332 this.THEAD
=_2db("thead");
2333 this.TFOOT
=_2db("tfoot");
2334 this.TABLE
=_2db("table");
2336 this.INPUT
=_2db("input");
2337 this.SPAN
=_2db("span");
2339 this.DIV
=_2db("div");
2340 this.IMG
=_2db("img");
2341 this.BUTTON
=_2db("button");
2343 this.PRE
=_2db("pre");
2349 this.LABEL
=_2db("label");
2350 this.TEXTAREA
=_2db("textarea");
2351 this.FORM
=_2db("form");
2353 this.SELECT
=_2db("select");
2354 this.OPTION
=_2db("option");
2355 this.OPTGROUP
=_2db("optgroup");
2356 this.LEGEND
=_2db("legend");
2357 this.FIELDSET
=_2db("fieldset");
2358 this.STRONG
=_2db("strong");
2359 this.CANVAS
=_2db("canvas");
2360 this.$=this.getElement
;
2361 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
2362 m
.nameFunctions(this);
2364 MochiKit
.DOM
.__new__(((typeof (window
)=="undefined")?this:window
));
2365 if(MochiKit
.__export__
){
2366 withWindow
=MochiKit
.DOM
.withWindow
;
2367 withDocument
=MochiKit
.DOM
.withDocument
;
2369 MochiKit
.Base
._exportSymbols(this,MochiKit
.DOM
);
2370 if(typeof (dojo
)!="undefined"){
2371 dojo
.provide("MochiKit.Style");
2372 dojo
.require("MochiKit.Base");
2373 dojo
.require("MochiKit.DOM");
2375 if(typeof (JSAN
)!="undefined"){
2376 JSAN
.use("MochiKit.Base",[]);
2377 JSAN
.use("MochiKit.DOM",[]);
2380 if(typeof (MochiKit
.Base
)=="undefined"){
2385 throw "MochiKit.Style depends on MochiKit.Base!";
2388 if(typeof (MochiKit
.DOM
)=="undefined"){
2393 throw "MochiKit.Style depends on MochiKit.DOM!";
2395 if(typeof (MochiKit
.Style
)=="undefined"){
2398 MochiKit
.Style
.NAME
="MochiKit.Style";
2399 MochiKit
.Style
.VERSION
="1.4";
2400 MochiKit
.Style
.__repr__
=function(){
2401 return "["+this.NAME
+" "+this.VERSION
+"]";
2403 MochiKit
.Style
.toString
=function(){
2404 return this.__repr__();
2406 MochiKit
.Style
.EXPORT_OK
=[];
2407 MochiKit
.Style
.EXPORT
=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
2408 MochiKit
.Style
.Dimensions
=function(w
,h
){
2412 MochiKit
.Style
.Dimensions
.prototype.__repr__
=function(){
2413 var repr
=MochiKit
.Base
.repr
;
2414 return "{w: "+repr(this.w
)+", h: "+repr(this.h
)+"}";
2416 MochiKit
.Style
.Dimensions
.prototype.toString
=function(){
2417 return this.__repr__();
2419 MochiKit
.Style
.Coordinates
=function(x
,y
){
2423 MochiKit
.Style
.Coordinates
.prototype.__repr__
=function(){
2424 var repr
=MochiKit
.Base
.repr
;
2425 return "{x: "+repr(this.x
)+", y: "+repr(this.y
)+"}";
2427 MochiKit
.Style
.Coordinates
.prototype.toString
=function(){
2428 return this.__repr__();
2430 MochiKit
.Base
.update(MochiKit
.Style
,{getStyle
:function(elem
,_2e3
){
2431 var dom
=MochiKit
.DOM
;
2432 var d
=dom
._document
;
2433 elem
=dom
.getElement(elem
);
2434 _2e3
=MochiKit
.Base
.camelize(_2e3
);
2438 if(_2e3
=="opacity"&&elem
.filters
){
2439 var _2e6
=(MochiKit
.Style
.getStyle(elem
,"filter")||"").match(/alpha\(opacity=(.*)\)/);
2441 return parseFloat(_2e6
[1])/100;
2445 var _2e7
=elem
.style
?elem
.style
[_2e3
]:null;
2447 if(d
.defaultView
&&d
.defaultView
.getComputedStyle
){
2448 var css
=d
.defaultView
.getComputedStyle(elem
,null);
2449 _2e3
=_2e3
.replace(/([A-Z])/g,"-$1").toLowerCase();
2450 _2e7
=css
?css
.getPropertyValue(_2e3
):null;
2452 if(elem
.currentStyle
){
2453 _2e7
=elem
.currentStyle
[_2e3
];
2457 if(_2e3
=="opacity"){
2458 _2e7
=parseFloat(_2e7
);
2460 if(/Opera/.test(navigator
.userAgent
)&&(MochiKit
.Base
.find(["left","top","right","bottom"],_2e3
)!=-1)){
2461 if(MochiKit
.Style
.getStyle(elem
,"position")=="static"){
2465 return _2e7
=="auto"?null:_2e7
;
2466 },setStyle
:function(elem
,_2ea
){
2467 elem
=MochiKit
.DOM
.getElement(elem
);
2468 for(var name
in _2ea
){
2469 if(name
=="opacity"){
2470 MochiKit
.Style
.setOpacity(elem
,_2ea
[name
]);
2472 elem
.style
[MochiKit
.Base
.camelize(name
)]=_2ea
[name
];
2475 },setOpacity
:function(elem
,o
){
2476 elem
=MochiKit
.DOM
.getElement(elem
);
2477 var self
=MochiKit
.Style
;
2479 var _2ef
=/Gecko/.test(navigator
.userAgent
)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator
.userAgent
));
2480 elem
.style
["opacity"]=_2ef
?0.999999:1;
2481 if(/MSIE/.test(navigator
.userAgent
)){
2482 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"");
2488 elem
.style
["opacity"]=o
;
2489 if(/MSIE/.test(navigator
.userAgent
)){
2490 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o
*100+")";
2493 },getElementPosition
:function(elem
,_2f1
){
2494 var self
=MochiKit
.Style
;
2495 var dom
=MochiKit
.DOM
;
2496 elem
=dom
.getElement(elem
);
2497 if(!elem
||(!(elem
.x
&&elem
.y
)&&(!elem
.parentNode
===null||self
.getStyle(elem
,"display")=="none"))){
2500 var c
=new self
.Coordinates(0,0);
2503 var d
=MochiKit
.DOM
._document
;
2504 var de
=d
.documentElement
;
2506 if(!elem
.parentNode
&&elem
.x
&&elem
.y
){
2510 if(elem
.getBoundingClientRect
){
2511 box
=elem
.getBoundingClientRect();
2512 c
.x
+=box
.left
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
2513 c
.y
+=box
.top
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
2515 if(elem
.offsetParent
){
2516 c
.x
+=elem
.offsetLeft
;
2517 c
.y
+=elem
.offsetTop
;
2518 _2f6
=elem
.offsetParent
;
2521 c
.x
+=_2f6
.offsetLeft
;
2522 c
.y
+=_2f6
.offsetTop
;
2523 _2f6
=_2f6
.offsetParent
;
2526 var ua
=navigator
.userAgent
.toLowerCase();
2527 if((typeof (opera
)!="undefined"&&parseFloat(opera
.version())<9)||(ua
.indexOf("AppleWebKit")!=-1&&self
.getStyle(elem
,"position")=="absolute")){
2534 if(typeof (_2f1
)!="undefined"){
2535 _2f1
=arguments
.callee(_2f1
);
2541 if(elem
.parentNode
){
2542 _2f6
=elem
.parentNode
;
2547 var _2fb
=_2f6
.tagName
.toUpperCase();
2548 if(_2fb
==="BODY"||_2fb
==="HTML"){
2551 var disp
=self
.getStyle(_2f6
,"display");
2552 if(disp
!="inline"&&disp
!="table-row"){
2553 c
.x
-=_2f6
.scrollLeft
;
2554 c
.y
-=_2f6
.scrollTop
;
2556 if(_2f6
.parentNode
){
2557 _2f6
=_2f6
.parentNode
;
2563 },setElementPosition
:function(elem
,_2fe
,_2ff
){
2564 elem
=MochiKit
.DOM
.getElement(elem
);
2565 if(typeof (_2ff
)=="undefined"){
2569 var _301
=MochiKit
.Base
.isUndefinedOrNull
;
2571 _300
["left"]=_2fe
.x
+_2ff
;
2574 _300
["top"]=_2fe
.y
+_2ff
;
2576 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_300
});
2577 },getElementDimensions
:function(elem
){
2578 var self
=MochiKit
.Style
;
2579 var dom
=MochiKit
.DOM
;
2580 if(typeof (elem
.w
)=="number"||typeof (elem
.h
)=="number"){
2581 return new self
.Dimensions(elem
.w
||0,elem
.h
||0);
2583 elem
=dom
.getElement(elem
);
2587 var disp
=self
.getStyle(elem
,"display");
2588 if(disp
!="none"&&disp
!==""&&typeof (disp
)!="undefined"){
2589 return new self
.Dimensions(elem
.offsetWidth
||0,elem
.offsetHeight
||0);
2592 var _307
=s
.visibility
;
2593 var _308
=s
.position
;
2594 s
.visibility
="hidden";
2595 s
.position
="absolute";
2597 var _309
=elem
.offsetWidth
;
2598 var _30a
=elem
.offsetHeight
;
2602 return new self
.Dimensions(_309
,_30a
);
2603 },setElementDimensions
:function(elem
,_30c
,_30d
){
2604 elem
=MochiKit
.DOM
.getElement(elem
);
2605 if(typeof (_30d
)=="undefined"){
2609 var _30f
=MochiKit
.Base
.isUndefinedOrNull
;
2611 _30e
["width"]=_30c
.w
+_30d
;
2614 _30e
["height"]=_30c
.h
+_30d
;
2616 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_30e
});
2617 },setDisplayForElement
:function(_310
,_311
){
2618 var _312
=MochiKit
.Base
.extend(null,arguments
,1);
2619 var _313
=MochiKit
.DOM
.getElement
;
2620 for(var i
=0;i
<_312
.length
;i
++){
2623 _311
.style
.display
=_310
;
2626 },getViewportDimensions
:function(){
2627 var d
=new MochiKit
.Style
.Dimensions();
2628 var w
=MochiKit
.DOM
._window
;
2629 var b
=MochiKit
.DOM
._document
.body
;
2634 if(b
.parentElement
.clientWidth
){
2635 d
.w
=b
.parentElement
.clientWidth
;
2636 d
.h
=b
.parentElement
.clientHeight
;
2638 if(b
&&b
.clientWidth
){
2645 },getViewportPosition
:function(){
2646 var c
=new MochiKit
.Style
.Coordinates(0,0);
2647 var d
=MochiKit
.DOM
._document
;
2648 var de
=d
.documentElement
;
2650 if(de
&&(de
.scrollTop
||de
.scrollLeft
)){
2660 },__new__
:function(){
2661 var m
=MochiKit
.Base
;
2662 this.elementPosition
=this.getElementPosition
;
2663 this.elementDimensions
=this.getElementDimensions
;
2664 this.hideElement
=m
.partial(this.setDisplayForElement
,"none");
2665 this.showElement
=m
.partial(this.setDisplayForElement
,"block");
2666 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
2667 m
.nameFunctions(this);
2669 MochiKit
.Style
.__new__();
2670 MochiKit
.Base
._exportSymbols(this,MochiKit
.Style
);
2673 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
};
2674 DygraphLayout
=function(_1
,_2
){
2677 MochiKit
.Base
.update(this.options
,_2
?_2
:{});
2678 this.datasets
=new Array();
2680 DygraphLayout
.prototype.attr_
=function(_3
){
2681 return this.dygraph_
.attr_(_3
);
2683 DygraphLayout
.prototype.addDataset
=function(_4
,_5
){
2684 this.datasets
[_4
]=_5
;
2686 DygraphLayout
.prototype.evaluate
=function(){
2687 this._evaluateLimits();
2688 this._evaluateLineCharts();
2689 this._evaluateLineTicks();
2691 DygraphLayout
.prototype._evaluateLimits
=function(){
2692 this.minxval
=this.maxxval
=null;
2693 for(var _6
in this.datasets
){
2694 var _7
=this.datasets
[_6
];
2696 if(!this.minxval
||x1
<this.minxval
){
2699 var x2
=_7
[_7
.length
-1][0];
2700 if(!this.maxxval
||x2
>this.maxxval
){
2704 this.xrange
=this.maxxval
-this.minxval
;
2705 this.xscale
=(this.xrange
!=0?1/this.xrange
:1);
2706 this.minyval
=this.options
.yAxis
[0];
2707 this.maxyval
=this.options
.yAxis
[1];
2708 this.yrange
=this.maxyval
-this.minyval
;
2709 this.yscale
=(this.yrange
!=0?1/this.yrange
:1);
2711 DygraphLayout
.prototype._evaluateLineCharts
=function(){
2712 this.points
=new Array();
2713 for(var _10
in this.datasets
){
2714 var _11
=this.datasets
[_10
];
2715 for(var j
=0;j
<_11
.length
;j
++){
2717 var _14
={x
:((parseFloat(_13
[0])-this.minxval
)*this.xscale
),y
:1-((parseFloat(_13
[1])-this.minyval
)*this.yscale
),xval
:parseFloat(_13
[0]),yval
:parseFloat(_13
[1]),name
:_10
};
2724 if((_14
.x
>=0)&&(_14
.x
<=1)){
2725 this.points
.push(_14
);
2730 DygraphLayout
.prototype._evaluateLineTicks
=function(){
2731 this.xticks
=new Array();
2732 for(var i
=0;i
<this.options
.xTicks
.length
;i
++){
2733 var _16
=this.options
.xTicks
[i
];
2735 var pos
=this.xscale
*(_16
.v
-this.minxval
);
2736 if((pos
>=0)&&(pos
<=1)){
2737 this.xticks
.push([pos
,_17
]);
2740 this.yticks
=new Array();
2741 for(var i
=0;i
<this.options
.yTicks
.length
;i
++){
2742 var _16
=this.options
.yTicks
[i
];
2744 var pos
=1-(this.yscale
*(_16
.v
-this.minyval
));
2745 if((pos
>=0)&&(pos
<=1)){
2746 this.yticks
.push([pos
,_17
]);
2750 DygraphLayout
.prototype.evaluateWithError
=function(){
2752 if(!this.options
.errorBars
){
2756 for(var _19
in this.datasets
){
2758 var _20
=this.datasets
[_19
];
2759 for(var j
=0;j
<_20
.length
;j
++,i
++){
2761 var xv
=parseFloat(_21
[0]);
2762 var yv
=parseFloat(_21
[1]);
2763 if(xv
==this.points
[i
].xval
&&yv
==this.points
[i
].yval
){
2764 this.points
[i
].errorMinus
=parseFloat(_21
[2]);
2765 this.points
[i
].errorPlus
=parseFloat(_21
[3]);
2770 DygraphLayout
.prototype.removeAllDatasets
=function(){
2771 delete this.datasets
;
2772 this.datasets
=new Array();
2774 DygraphLayout
.prototype.updateOptions
=function(_24
){
2775 MochiKit
.Base
.update(this.options
,_24
?_24
:{});
2777 DygraphCanvasRenderer
=function(_25
,_26
,_27
,_28
){
2779 this.options
={"strokeWidth":0.5,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color
.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color
.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"drawYGrid":true,"drawXGrid":true,"gridLineColor":MochiKit
.Color
.Color
.grayColor()};
2780 MochiKit
.Base
.update(this.options
,_28
);
2783 this.container
=this.element
.parentNode
;
2784 this.isIE
=(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
);
2785 if(this.isIE
&&!isNil(G_vmlCanvasManager
)){
2788 this.renderDelay
=null;
2789 this.clearDelay
=null;
2790 this.element
=G_vmlCanvasManager
.initElement(this.element
);
2792 this.height
=this.element
.height
;
2793 this.width
=this.element
.width
;
2794 if(!this.isIE
&&!(DygraphCanvasRenderer
.isSupported(this.element
))){
2795 throw "Canvas is not supported.";
2797 this.xlabels
=new Array();
2798 this.ylabels
=new Array();
2799 this.area
={x
:this.options
.yAxisLabelWidth
+2*this.options
.axisTickSize
,y
:0};
2800 this.area
.w
=this.width
-this.area
.x
-this.options
.rightGap
;
2801 this.area
.h
=this.height
-this.options
.axisLabelFontSize
-2*this.options
.axisTickSize
;
2802 this.container
.style
.position
="relative";
2803 this.container
.style
.width
=this.width
+"px";
2805 DygraphCanvasRenderer
.prototype.clear
=function(){
2808 if(this.clearDelay
){
2809 this.clearDelay
.cancel();
2810 this.clearDelay
=null;
2812 var _29
=this.element
.getContext("2d");
2815 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
2816 this.clearDelay
.addCallback(bind(this.clear
,this));
2820 var _29
=this.element
.getContext("2d");
2821 _29
.clearRect(0,0,this.width
,this.height
);
2822 for(var i
=0;i
<this.xlabels
.length
;i
++){
2823 var el
=this.xlabels
[i
];
2824 el
.parentNode
.removeChild(el
);
2826 for(var i
=0;i
<this.ylabels
.length
;i
++){
2827 var el
=this.ylabels
[i
];
2828 el
.parentNode
.removeChild(el
);
2830 this.xlabels
=new Array();
2831 this.ylabels
=new Array();
2833 DygraphCanvasRenderer
.isSupported
=function(_31
){
2836 if(MochiKit
.Base
.isUndefinedOrNull(_31
)){
2837 _32
=document
.createElement("canvas");
2841 var _33
=_32
.getContext("2d");
2844 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
2845 var _35
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
2846 if((!ie
)||(ie
[1]<6)||(_35
)){
2853 DygraphCanvasRenderer
.prototype.render
=function(){
2854 var ctx
=this.element
.getContext("2d");
2855 if(this.options
.drawYGrid
){
2856 var _37
=this.layout
.yticks
;
2858 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
2859 ctx
.lineWidth
=this.options
.axisLineWidth
;
2860 for(var i
=0;i
<_37
.length
;i
++){
2862 var y
=this.area
.y
+_37
[i
][0]*this.area
.h
;
2865 ctx
.lineTo(x
+this.area
.w
,y
);
2870 if(this.options
.drawXGrid
){
2871 var _37
=this.layout
.xticks
;
2873 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
2874 ctx
.lineWidth
=this.options
.axisLineWidth
;
2875 for(var i
=0;i
<_37
.length
;i
++){
2876 var x
=this.area
.x
+_37
[i
][0]*this.area
.w
;
2877 var y
=this.area
.y
+this.area
.h
;
2880 ctx
.lineTo(x
,this.area
.y
);
2885 this._renderLineChart();
2888 DygraphCanvasRenderer
.prototype._renderAxis
=function(){
2889 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
2892 var _40
=this.element
.getContext("2d");
2893 var _41
={"style":{"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
.toRGBString(),"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"}};
2895 _40
.strokeStyle
=this.options
.axisLineColor
.toRGBString();
2896 _40
.lineWidth
=this.options
.axisLineWidth
;
2897 if(this.options
.drawYAxis
){
2898 if(this.layout
.yticks
){
2899 for(var i
=0;i
<this.layout
.yticks
.length
;i
++){
2900 var _42
=this.layout
.yticks
[i
];
2901 if(typeof (_42
)=="function"){
2905 var y
=this.area
.y
+_42
[0]*this.area
.h
;
2908 _40
.lineTo(x
-this.options
.axisTickSize
,y
);
2911 var _43
=DIV(_41
,_42
[1]);
2912 var top
=(y
-this.options
.axisLabelFontSize
/2);
2916 if(top
+this.options
.axisLabelFontSize
+3>this.height
){
2917 _43
.style
.bottom
="0px";
2919 _43
.style
.top
=top
+"px";
2921 _43
.style
.left
="0px";
2922 _43
.style
.textAlign
="right";
2923 _43
.style
.width
=this.options
.yAxisLabelWidth
+"px";
2924 this.container
.appendChild(_43
);
2925 this.ylabels
.push(_43
);
2927 var _45
=this.ylabels
[0];
2928 var _46
=this.options
.axisLabelFontSize
;
2929 var _47
=parseInt(_45
.style
.top
)+_46
;
2930 if(_47
>this.height
-_46
){
2931 _45
.style
.top
=(parseInt(_45
.style
.top
)-_46
/2)+"px";
2935 _40
.moveTo(this.area
.x
,this.area
.y
);
2936 _40
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
2940 if(this.options
.drawXAxis
){
2941 if(this.layout
.xticks
){
2942 for(var i
=0;i
<this.layout
.xticks
.length
;i
++){
2943 var _42
=this.layout
.xticks
[i
];
2944 if(typeof (dataset
)=="function"){
2947 var x
=this.area
.x
+_42
[0]*this.area
.w
;
2948 var y
=this.area
.y
+this.area
.h
;
2951 _40
.lineTo(x
,y
+this.options
.axisTickSize
);
2954 var _43
=DIV(_41
,_42
[1]);
2955 _43
.style
.textAlign
="center";
2956 _43
.style
.bottom
="0px";
2957 var _48
=(x
-this.options
.axisLabelWidth
/2);
2958 if(_48
+this.options
.axisLabelWidth
>this.width
){
2959 _48
=this.width
-this.options
.xAxisLabelWidth
;
2960 _43
.style
.textAlign
="right";
2964 _43
.style
.textAlign
="left";
2966 _43
.style
.left
=_48
+"px";
2967 _43
.style
.width
=this.options
.xAxisLabelWidth
+"px";
2968 this.container
.appendChild(_43
);
2969 this.xlabels
.push(_43
);
2973 _40
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
2974 _40
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
2980 DygraphCanvasRenderer
.prototype._renderLineChart
=function(){
2981 var _49
=this.element
.getContext("2d");
2982 var _50
=this.options
.colorScheme
.length
;
2983 var _51
=this.options
.colorScheme
;
2984 var _52
=MochiKit
.Base
.keys(this.layout
.datasets
);
2985 var _53
=this.layout
.options
.errorBars
;
2987 var _55
=MochiKit
.Base
.bind
;
2988 var _56
=MochiKit
.Base
.partial
;
2989 for(var i
=0;i
<this.layout
.points
.length
;i
++){
2990 var _57
=this.layout
.points
[i
];
2991 _57
.canvasx
=this.area
.w
*_57
.x
+this.area
.x
;
2992 _57
.canvasy
=this.area
.h
*_57
.y
+this.area
.y
;
2994 var _58
=function(x
){
2995 return x
&&!isNaN(x
);
2997 var _59
=function(ctx
){
2998 for(var i
=0;i
<_54
;i
++){
3001 var _62
=this.options
.strokeColorTransform
;
3003 _49
.strokeStyle
=_61
.toRGBString();
3004 _49
.lineWidth
=this.options
.strokeWidth
;
3005 var _57
=this.layout
.points
[0];
3006 var _63
=this.dygraph_
.attr_("pointSize");
3007 var _64
=null,prevY
=null;
3008 var _65
=this.dygraph_
.attr_("drawPoints");
3009 var _66
=this.layout
.points
;
3010 for(var j
=0;j
<_66
.length
;j
++){
3013 if(!_58(_57
.canvasy
)){
3016 var _67
=(!_64
&&(j
==_66
.length
-1||!_58(_66
[j
+1].canvasy
)));
3022 ctx
.moveTo(_64
,prevY
);
3025 ctx
.lineTo(_64
,prevY
);
3030 ctx
.fillStyle
=_61
.toRGBString();
3031 ctx
.arc(_57
.canvasx
,_57
.canvasy
,_63
,0,360,false);
3039 var _68
=function(ctx
){
3040 for(var i
=0;i
<_54
;i
++){
3043 var _71
=this.options
.strokeColorTransform
;
3045 _49
.strokeStyle
=_70
.toRGBString();
3046 _49
.lineWidth
=this.options
.strokeWidth
;
3050 var _75
=this.layout
.yscale
;
3051 var _76
=_70
.colorWithAlpha(0.15);
3052 ctx
.fillStyle
=_76
.toRGBString();
3054 for(var j
=0;j
<this.layout
.points
.length
;j
++){
3055 var _77
=this.layout
.points
[j
];
3058 if(!_77
.y
||isNaN(_77
.y
)){
3062 var _78
=[_77
.y
-_77
.errorPlus
*_75
,_77
.y
+_77
.errorMinus
*_75
];
3063 _78
[0]=this.area
.h
*_78
[0]+this.area
.y
;
3064 _78
[1]=this.area
.h
*_78
[1]+this.area
.y
;
3066 ctx
.moveTo(_72
,_73
[0]);
3067 ctx
.lineTo(_77
.canvasx
,_78
[0]);
3068 ctx
.lineTo(_77
.canvasx
,_78
[1]);
3069 ctx
.lineTo(_72
,_73
[1]);
3086 Dygraph
=function(div
,_80
,_81
){
3087 if(arguments
.length
>0){
3088 if(arguments
.length
==4){
3089 this.warn("Using deprecated four-argument dygraph constructor");
3090 this.__old_init__(div
,_80
,arguments
[2],arguments
[3]);
3092 this.__init__(div
,_80
,_81
);
3096 Dygraph
.NAME
="Dygraph";
3097 Dygraph
.VERSION
="1.2";
3098 Dygraph
.__repr__
=function(){
3099 return "["+this.NAME
+" "+this.VERSION
+"]";
3101 Dygraph
.toString
=function(){
3102 return this.__repr__();
3104 Dygraph
.DEFAULT_ROLL_PERIOD
=1;
3105 Dygraph
.DEFAULT_WIDTH
=480;
3106 Dygraph
.DEFAULT_HEIGHT
=320;
3107 Dygraph
.AXIS_LINE_WIDTH
=0.3;
3108 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};
3113 Dygraph
.prototype.__old_init__
=function(div
,_82
,_83
,_84
){
3116 for(var i
=0;i
<_83
.length
;i
++){
3119 MochiKit
.Base
.update(_84
,{"labels":_85
});
3121 this.__init__(div
,_82
,_84
);
3123 Dygraph
.prototype.__init__
=function(div
,_86
,_87
){
3129 this.rollPeriod_
=_87
.rollPeriod
||Dygraph
.DEFAULT_ROLL_PERIOD
;
3130 this.previousVerticalX_
=-1;
3131 this.fractions_
=_87
.fractions
||false;
3132 this.dateWindow_
=_87
.dateWindow
||null;
3133 this.valueRange_
=_87
.valueRange
||null;
3134 this.wilsonInterval_
=_87
.wilsonInterval
||true;
3136 if(div
.style
.width
==""){
3137 div
.style
.width
=Dygraph
.DEFAULT_WIDTH
+"px";
3139 if(div
.style
.height
==""){
3140 div
.style
.height
=Dygraph
.DEFAULT_HEIGHT
+"px";
3142 this.width_
=parseInt(div
.style
.width
,10);
3143 this.height_
=parseInt(div
.style
.height
,10);
3144 this.user_attrs_
={};
3145 MochiKit
.Base
.update(this.user_attrs_
,_87
);
3147 MochiKit
.Base
.update(this.attrs_
,Dygraph
.DEFAULT_ATTRS
);
3148 this.labelsFromCSV_
=(this.attr_("labels")==null);
3149 this.createInterface_();
3150 this.layoutOptions_
={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
3151 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
3152 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
3153 this.layout_
=new DygraphLayout(this,this.layoutOptions_
);
3154 this.renderOptions_
={colorScheme
:this.colors_
,strokeColor
:null,axisLineWidth
:Dygraph
.AXIS_LINE_WIDTH
};
3155 MochiKit
.Base
.update(this.renderOptions_
,this.attrs_
);
3156 MochiKit
.Base
.update(this.renderOptions_
,this.user_attrs_
);
3157 this.plotter_
=new DygraphCanvasRenderer(this,this.hidden_
,this.layout_
,this.renderOptions_
);
3158 this.createStatusMessage_();
3159 this.createRollInterface_();
3160 this.createDragInterface_();
3163 Dygraph
.prototype.attr_
=function(_88
){
3164 if(typeof (this.user_attrs_
[_88
])!="undefined"){
3165 return this.user_attrs_
[_88
];
3167 if(typeof (this.attrs_
[_88
])!="undefined"){
3168 return this.attrs_
[_88
];
3174 Dygraph
.prototype.log
=function(_89
,_90
){
3175 if(typeof (console
)!="undefined"){
3178 console
.debug("dygraphs: "+_90
);
3181 console
.info("dygraphs: "+_90
);
3183 case Dygraph
.WARNING
:
3184 console
.warn("dygraphs: "+_90
);
3187 console
.error("dygraphs: "+_90
);
3192 Dygraph
.prototype.info
=function(_91
){
3193 this.log(Dygraph
.INFO
,_91
);
3195 Dygraph
.prototype.warn
=function(_92
){
3196 this.log(Dygraph
.WARNING
,_92
);
3198 Dygraph
.prototype.error
=function(_93
){
3199 this.log(Dygraph
.ERROR
,_93
);
3201 Dygraph
.prototype.rollPeriod
=function(){
3202 return this.rollPeriod_
;
3204 Dygraph
.addEvent
=function(el
,evt
,fn
){
3205 var _96
=function(e
){
3211 if(window
.addEventListener
){
3212 el
.addEventListener(evt
,_96
,false);
3214 el
.attachEvent("on"+evt
,_96
);
3217 Dygraph
.prototype.createInterface_
=function(){
3218 var _98
=this.maindiv_
;
3219 this.graphDiv
=document
.createElement("div");
3220 this.graphDiv
.style
.width
=this.width_
+"px";
3221 this.graphDiv
.style
.height
=this.height_
+"px";
3222 _98
.appendChild(this.graphDiv
);
3223 this.canvas_
=document
.createElement("canvas");
3224 this.canvas_
.style
.position
="absolute";
3225 this.canvas_
.width
=this.width_
;
3226 this.canvas_
.height
=this.height_
;
3227 this.graphDiv
.appendChild(this.canvas_
);
3228 this.hidden_
=this.createPlotKitCanvas_(this.canvas_
);
3230 Dygraph
.addEvent(this.hidden_
,"mousemove",function(e
){
3233 Dygraph
.addEvent(this.hidden_
,"mouseout",function(e
){
3237 Dygraph
.prototype.createPlotKitCanvas_
=function(_100
){
3238 var h
=document
.createElement("canvas");
3239 h
.style
.position
="absolute";
3240 h
.style
.top
=_100
.style
.top
;
3241 h
.style
.left
=_100
.style
.left
;
3242 h
.width
=this.width_
;
3243 h
.height
=this.height_
;
3244 this.graphDiv
.appendChild(h
);
3247 Dygraph
.prototype.setColors_
=function(){
3248 var num
=this.attr_("labels").length
-1;
3250 var _103
=this.attr_("colors");
3252 var sat
=this.attr_("colorSaturation")||1;
3253 var val
=this.attr_("colorValue")||0.5;
3254 for(var i
=1;i
<=num
;i
++){
3255 var hue
=(1*i
/(1+num
));
3256 this.colors_
.push(MochiKit
.Color
.Color
.fromHSV(hue
,sat
,val
));
3259 for(var i
=0;i
<num
;i
++){
3260 var _107
=_103
[i
%_103
.length
];
3261 this.colors_
.push(MochiKit
.Color
.Color
.fromString(_107
));
3264 this.renderOptions_
.colorScheme
=this.colors_
;
3265 MochiKit
.Base
.update(this.plotter_
.options
,this.renderOptions_
);
3266 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
3267 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
3269 Dygraph
.findPosX
=function(obj
){
3271 if(obj
.offsetParent
){
3272 while(obj
.offsetParent
){
3273 _109
+=obj
.offsetLeft
;
3274 obj
=obj
.offsetParent
;
3283 Dygraph
.findPosY
=function(obj
){
3285 if(obj
.offsetParent
){
3286 while(obj
.offsetParent
){
3287 _110
+=obj
.offsetTop
;
3288 obj
=obj
.offsetParent
;
3297 Dygraph
.prototype.createStatusMessage_
=function(){
3298 if(!this.attr_("labelsDiv")){
3299 var _111
=this.attr_("labelsDivWidth");
3300 var _112
={"position":"absolute","fontSize":"14px","zIndex":10,"width":_111
+"px","top":"0px","left":(this.width_
-_111
-2)+"px","background":"white","textAlign":"left","overflow":"hidden"};
3301 MochiKit
.Base
.update(_112
,this.attr_("labelsDivStyles"));
3302 var div
=document
.createElement("div");
3303 for(var name
in _112
){
3304 div
.style
[name
]=_112
[name
];
3306 this.graphDiv
.appendChild(div
);
3307 this.attrs_
.labelsDiv
=div
;
3310 Dygraph
.prototype.createRollInterface_
=function(){
3311 var _114
=this.attr_("showRoller")?"block":"none";
3312 var _115
={"position":"absolute","zIndex":10,"top":(this.plotter_
.area
.h
-25)+"px","left":(this.plotter_
.area
.x
+1)+"px","display":_114
};
3313 var _116
=document
.createElement("input");
3316 _116
.value
=this.rollPeriod_
;
3317 for(var name
in _115
){
3318 _116
.style
[name
]=_115
[name
];
3320 var pa
=this.graphDiv
;
3321 pa
.appendChild(_116
);
3323 _116
.onchange
=function(){
3324 _118
.adjustRoll(_116
.value
);
3328 Dygraph
.pageX
=function(e
){
3330 return (!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
3333 var b
=document
.body
;
3334 return e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
3337 Dygraph
.pageY
=function(e
){
3339 return (!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
3342 var b
=document
.body
;
3343 return e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
3346 Dygraph
.prototype.createDragInterface_
=function(){
3356 var getX
=function(e
){
3357 return Dygraph
.pageX(e
)-px
;
3359 var getY
=function(e
){
3360 return Dygraph
.pageX(e
)-py
;
3362 Dygraph
.addEvent(this.hidden_
,"mousemove",function(_132
){
3366 self
.drawZoomRect_(_123
,_125
,_127
);
3370 Dygraph
.addEvent(this.hidden_
,"mousedown",function(_133
){
3372 px
=Dygraph
.findPosX(self
.canvas_
);
3373 py
=Dygraph
.findPosY(self
.canvas_
);
3377 Dygraph
.addEvent(document
,"mouseup",function(_134
){
3384 Dygraph
.addEvent(this.hidden_
,"mouseout",function(_135
){
3390 Dygraph
.addEvent(this.hidden_
,"mouseup",function(_136
){
3395 var _137
=Math
.abs(_125
-_123
);
3396 var _138
=Math
.abs(_126
-_124
);
3397 if(_137
<2&&_138
<2&&self
.attr_("clickCallback")!=null&&self
.lastx_
!=undefined
){
3398 self
.attr_("clickCallback")(_136
,new Date(self
.lastx_
));
3401 self
.doZoom_(Math
.min(_123
,_125
),Math
.max(_123
,_125
));
3403 self
.canvas_
.getContext("2d").clearRect(0,0,self
.canvas_
.width
,self
.canvas_
.height
);
3409 Dygraph
.addEvent(this.hidden_
,"dblclick",function(_139
){
3410 self
.dateWindow_
=null;
3411 self
.drawGraph_(self
.rawData_
);
3412 var _140
=self
.rawData_
[0][0];
3413 var _141
=self
.rawData_
[self
.rawData_
.length
-1][0];
3414 if(self
.attr_("zoomCallback")){
3415 self
.attr_("zoomCallback")(_140
,_141
);
3419 Dygraph
.prototype.drawZoomRect_
=function(_142
,endX
,_144
){
3420 var ctx
=this.canvas_
.getContext("2d");
3422 ctx
.clearRect(Math
.min(_142
,_144
),0,Math
.abs(_142
-_144
),this.height_
);
3425 ctx
.fillStyle
="rgba(128,128,128,0.33)";
3426 ctx
.fillRect(Math
.min(_142
,endX
),0,Math
.abs(endX
-_142
),this.height_
);
3429 Dygraph
.prototype.doZoom_
=function(lowX
,_146
){
3430 var _147
=this.layout_
.points
;
3433 for(var i
=0;i
<_147
.length
;i
++){
3434 var cx
=_147
[i
].canvasx
;
3436 if(cx
<lowX
&&(_148
==null||x
>_148
)){
3439 if(cx
>_146
&&(_149
==null||x
<_149
)){
3447 _149
=_147
[_147
.length
-1].xval
;
3449 this.dateWindow_
=[_148
,_149
];
3450 this.drawGraph_(this.rawData_
);
3451 if(this.attr_("zoomCallback")){
3452 this.attr_("zoomCallback")(_148
,_149
);
3455 Dygraph
.prototype.mouseMove_
=function(_151
){
3456 var _152
=Dygraph
.pageX(_151
)-Dygraph
.findPosX(this.hidden_
);
3457 var _153
=this.layout_
.points
;
3462 for(var i
=0;i
<_153
.length
;i
++){
3463 var dist
=Math
.abs(_153
[i
].canvasx
-_152
);
3471 _154
=_153
[idx
].xval
;
3473 if(_152
>_153
[_153
.length
-1].canvasx
){
3474 _154
=_153
[_153
.length
-1].xval
;
3477 for(var i
=0;i
<_153
.length
;i
++){
3478 if(_153
[i
].xval
==_154
){
3482 var _160
=this.attr_("highlightCircleSize");
3483 var ctx
=this.canvas_
.getContext("2d");
3484 if(this.previousVerticalX_
>=0){
3485 var px
=this.previousVerticalX_
;
3486 ctx
.clearRect(px
-_160
-1,0,2*_160
+2,this.height_
);
3488 var isOK
=function(x
){
3489 return x
&&!isNaN(x
);
3492 var _152
=_159
[0].canvasx
;
3493 var _162
=this.attr_("xValueFormatter")(_154
,this)+":";
3494 var clen
=this.colors_
.length
;
3495 for(var i
=0;i
<_159
.length
;i
++){
3496 if(!isOK(_159
[i
].canvasy
)){
3499 if(this.attr_("labelsSeparateLines")){
3503 _162
+=" <b><font color='"+this.colors_
[i
%clen
].toHexString()+"'>"+_164
.name
+"</font></b>:"+this.round_(_164
.yval
,2);
3505 this.attr_("labelsDiv").innerHTML
=_162
;
3508 for(var i
=0;i
<_159
.length
;i
++){
3509 if(!isOK(_159
[i
%clen
].canvasy
)){
3513 ctx
.fillStyle
=this.colors_
[i
%clen
].toRGBString();
3514 ctx
.arc(_152
,_159
[i
%clen
].canvasy
,_160
,0,360,false);
3518 this.previousVerticalX_
=_152
;
3521 Dygraph
.prototype.mouseOut_
=function(_165
){
3522 var ctx
=this.canvas_
.getContext("2d");
3523 ctx
.clearRect(0,0,this.width_
,this.height_
);
3524 this.attr_("labelsDiv").innerHTML
="";
3526 Dygraph
.zeropad
=function(x
){
3533 Dygraph
.prototype.hmsString_
=function(date
){
3534 var _167
=Dygraph
.zeropad
;
3535 var d
=new Date(date
);
3537 return _167(d
.getHours())+":"+_167(d
.getMinutes())+":"+_167(d
.getSeconds());
3540 return _167(d
.getHours())+":"+_167(d
.getMinutes());
3542 return _167(d
.getHours());
3546 Dygraph
.dateString_
=function(date
,self
){
3547 var _169
=Dygraph
.zeropad
;
3548 var d
=new Date(date
);
3549 var year
=""+d
.getFullYear();
3550 var _171
=_169(d
.getMonth()+1);
3551 var day
=_169(d
.getDate());
3553 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
3555 ret
=" "+self
.hmsString_(date
);
3557 return year
+"/"+_171+"/"+day
+ret
;
3559 Dygraph
.prototype.round_
=function(num
,_175
){
3560 var _176
=Math
.pow(10,_175
);
3561 return Math
.round(num
*_176
)/_176
;
3563 Dygraph
.prototype.loadedEvent_
=function(data
){
3564 this.rawData_
=this.parseCSV_(data
);
3565 this.drawGraph_(this.rawData_
);
3567 Dygraph
.prototype.months
=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
3568 Dygraph
.prototype.quarters
=["Jan","Apr","Jul","Oct"];
3569 Dygraph
.prototype.addXTicks_
=function(){
3571 if(this.dateWindow_
){
3572 _178
=this.dateWindow_
[0];
3573 endDate
=this.dateWindow_
[1];
3575 _178
=this.rawData_
[0][0];
3576 endDate
=this.rawData_
[this.rawData_
.length
-1][0];
3578 var _179
=this.attr_("xTicker")(_178
,endDate
,this);
3579 this.layout_
.updateOptions({xTicks
:_179
});
3582 Dygraph
.TEN_SECONDLY
=1;
3583 Dygraph
.THIRTY_SECONDLY
=2;
3585 Dygraph
.TEN_MINUTELY
=4;
3586 Dygraph
.THIRTY_MINUTELY
=5;
3588 Dygraph
.SIX_HOURLY
=7;
3592 Dygraph
.QUARTERLY
=11;
3593 Dygraph
.BIANNUAL
=12;
3596 Dygraph
.NUM_GRANULARITIES
=15;
3597 Dygraph
.SHORT_SPACINGS
=[];
3598 Dygraph
.SHORT_SPACINGS
[Dygraph
.SECONDLY
]=1000*1;
3599 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_SECONDLY
]=1000*10;
3600 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_SECONDLY
]=1000*30;
3601 Dygraph
.SHORT_SPACINGS
[Dygraph
.MINUTELY
]=1000*60;
3602 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_MINUTELY
]=1000*60*10;
3603 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_MINUTELY
]=1000*60*30;
3604 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600;
3605 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600*6;
3606 Dygraph
.SHORT_SPACINGS
[Dygraph
.DAILY
]=1000*86400;
3607 Dygraph
.SHORT_SPACINGS
[Dygraph
.WEEKLY
]=1000*604800;
3608 Dygraph
.prototype.NumXTicks
=function(_180
,_181
,_182
){
3609 if(_182
<Dygraph
.MONTHLY
){
3610 var _183
=Dygraph
.SHORT_SPACINGS
[_182
];
3611 return Math
.floor(0.5+1*(_181
-_180
)/_183
);
3615 if(_182
==Dygraph
.QUARTERLY
){
3618 if(_182
==Dygraph
.BIANNUAL
){
3621 if(_182
==Dygraph
.ANNUAL
){
3624 if(_182
==Dygraph
.DECADAL
){
3628 var _186
=365.2524*24*3600*1000;
3629 var _187
=1*(_181
-_180
)/_186
;
3630 return Math
.floor(0.5+1*_187
*_185
/_184
);
3633 Dygraph
.prototype.GetXAxis
=function(_188
,_189
,_190
){
3635 if(_190
<Dygraph
.MONTHLY
){
3636 var _192
=Dygraph
.SHORT_SPACINGS
[_190
];
3638 if(_190
<Dygraph
.HOURLY
){
3639 _188
=_192
*Math
.floor(0.5+_188
/_192
);
3641 for(var t
=_188
;t
<=_189
;t
+=_192
){
3643 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
3644 if(frac
==0||_190
>=Dygraph
.DAILY
){
3645 _191
.push({v
:t
,label
:new Date(t
+3600*1000).strftime(_193
)});
3647 _191
.push({v
:t
,label
:this.hmsString_(t
)});
3653 if(_190
==Dygraph
.MONTHLY
){
3654 _195
=[0,1,2,3,4,5,6,7,8,9,10,11,12];
3656 if(_190
==Dygraph
.QUARTERLY
){
3659 if(_190
==Dygraph
.BIANNUAL
){
3662 if(_190
==Dygraph
.ANNUAL
){
3665 if(_190
==Dygraph
.DECADAL
){
3673 var _197
=new Date(_188
).getFullYear();
3674 var _198
=new Date(_189
).getFullYear();
3675 var _199
=Dygraph
.zeropad
;
3676 for(var i
=_197
;i
<=_198
;i
++){
3680 for(var j
=0;j
<_195
.length
;j
++){
3681 var _200
=i
+"/"+_199(1+_195[j])+"/01";
3682 var t
=Date
.parse(_200
);
3686 _191
.push({v
:t
,label
:new Date(t
).strftime("%b %y")});
3692 Dygraph
.dateTicker
=function(_201
,_202
,self
){
3694 for(var i
=0;i
<Dygraph
.NUM_GRANULARITIES
;i
++){
3695 var _204
=self
.NumXTicks(_201
,_202
,i
);
3696 if(self
.width_
/_204
>=self
.attr_("pixelsPerXLabel")){
3702 return self
.GetXAxis(_201
,_202
,_203
);
3706 Dygraph
.numericTicks
=function(minV
,maxV
,self
){
3708 var _208
,low_val
,high_val
,nTicks
;
3709 var _209
=self
.attr_("pixelsPerYLabel");
3710 for(var i
=-10;i
<50;i
++){
3711 var _210
=Math
.pow(10,i
);
3712 for(var j
=0;j
<_207
.length
;j
++){
3714 low_val
=Math
.floor(minV
/_208
)*_208
;
3715 high_val
=Math
.ceil(maxV
/_208
)*_208
;
3716 nTicks
=(high_val
-low_val
)/_208
;
3717 var _211
=self
.height_
/nTicks
;
3727 for(var i
=0;i
<nTicks
;i
++){
3728 var _213
=low_val
+i
*_208
;
3729 var _214
=self
.round_(_213
,2);
3730 if(self
.attr_("labelsKMB")){
3733 _214
=self
.round_(_213
/(k
*k
*k
),1)+"B";
3736 _214
=self
.round_(_213
/(k
*k
),1)+"M";
3739 _214
=self
.round_(_213
/k
,1)+"K";
3744 _212
.push({label
:_214
,v
:_213
});
3748 Dygraph
.prototype.addYTicks_
=function(minY
,maxY
){
3749 var _218
=Dygraph
.numericTicks(minY
,maxY
,this);
3750 this.layout_
.updateOptions({yAxis
:[minY
,maxY
],yTicks
:_218
});
3752 Dygraph
.prototype.extremeValues_
=function(_219
){
3753 var minY
=null,maxY
=null;
3754 var bars
=this.attr_("errorBars")||this.attr_("customBars");
3756 for(var j
=0;j
<_219
.length
;j
++){
3757 var y
=_219
[j
][1][0];
3761 var low
=y
-_219
[j
][1][1];
3762 var high
=y
+_219
[j
][1][2];
3769 if(maxY
==null||high
>maxY
){
3772 if(minY
==null||low
<minY
){
3777 for(var j
=0;j
<_219
.length
;j
++){
3782 if(maxY
==null||y
>maxY
){
3785 if(minY
==null||y
<minY
){
3792 Dygraph
.prototype.drawGraph_
=function(data
){
3793 var minY
=null,maxY
=null;
3794 this.layout_
.removeAllDatasets();
3796 this.attrs_
["pointSize"]=0.5*this.attr_("highlightCircleSize");
3797 for(var i
=1;i
<data
[0].length
;i
++){
3799 for(var j
=0;j
<data
.length
;j
++){
3800 var date
=data
[j
][0];
3801 _223
[j
]=[date
,data
[j
][i
]];
3803 _223
=this.rollingAverage(_223
,this.rollPeriod_
);
3804 var bars
=this.attr_("errorBars")||this.attr_("customBars");
3805 if(this.dateWindow_
){
3806 var low
=this.dateWindow_
[0];
3807 var high
=this.dateWindow_
[1];
3809 for(var k
=0;k
<_223
.length
;k
++){
3810 if(_223
[k
][0]>=low
&&_223
[k
][0]<=high
){
3816 var _225
=this.extremeValues_(_223
);
3819 if(!minY
||_226
<minY
){
3822 if(!maxY
||_227
>maxY
){
3827 for(var j
=0;j
<_223
.length
;j
++){
3828 vals
[j
]=[_223
[j
][0],_223
[j
][1][0],_223
[j
][1][1],_223
[j
][1][2]];
3830 this.layout_
.addDataset(this.attr_("labels")[i
],vals
);
3832 this.layout_
.addDataset(this.attr_("labels")[i
],_223
);
3835 if(this.valueRange_
!=null){
3836 this.addYTicks_(this.valueRange_
[0],this.valueRange_
[1]);
3839 var _230
=maxY
+0.1*span
;
3840 var _231
=minY
-0.1*span
;
3841 if(_231
<0&&minY
>=0){
3844 if(_230
>0&&maxY
<=0){
3847 if(this.attr_("includeZero")){
3855 this.addYTicks_(_231
,_230
);
3858 this.layout_
.evaluateWithError();
3859 this.plotter_
.clear();
3860 this.plotter_
.render();
3861 this.canvas_
.getContext("2d").clearRect(0,0,this.canvas_
.width
,this.canvas_
.height
);
3863 Dygraph
.prototype.rollingAverage
=function(_232
,_233
){
3867 var _233
=Math
.min(_233
,_232
.length
-1);
3869 var _235
=this.attr_("sigma");
3870 if(this.fractions_
){
3874 for(var i
=0;i
<_232
.length
;i
++){
3878 num
-=_232
[i
-_233
][1][0];
3879 den
-=_232
[i
-_233
][1][1];
3881 var date
=_232
[i
][0];
3882 var _238
=den
?num
/den
:0;
3883 if(this.attr_("errorBars")){
3884 if(this.wilsonInterval_
){
3886 var p
=_238
<0?0:_238
,n
=den
;
3887 var pm
=_235
*Math
.sqrt(p
*(1-p
)/n+_235*_235/(4*n
*n
));
3888 var _241
=1+_235
*_235
/den
;
3889 var low
=(p
+_235
*_235
/(2*den)-pm)/_241
;
3890 var high
=(p
+_235
*_235
/(2*den)+pm)/_241
;
3891 _234
[i
]=[date
,[p
*mult
,(p
-low
)*mult
,(high
-p
)*mult
]];
3893 _234
[i
]=[date
,[0,0,0]];
3896 var _242
=den
?_235
*Math
.sqrt(_238
*(1-_238
)/den
):1;
3897 _234
[i
]=[date
,[mult
*_238
,mult
*_242
,mult
*_242
]];
3900 _234
[i
]=[date
,mult
*_238
];
3904 if(this.attr_("customBars")){
3909 for(var i
=0;i
<_232
.length
;i
++){
3910 var data
=_232
[i
][1];
3912 _234
[i
]=[_232
[i
][0],[y
,y
-data
[0],data
[2]-y
]];
3918 var prev
=_232
[i
-_233
];
3924 _234
[i
]=[_232
[i
][0],[1*mid
/_244,1*(mid-low)/_244
,1*(high
-mid
)/_244
]];
3927 var _246
=Math
.min(_233
-1,_232
.length
-2);
3928 if(!this.attr_("errorBars")){
3932 for(var i
=0;i
<_232
.length
;i
++){
3935 for(var j
=Math
.max(0,i
-_233
+1);j
<i
+1;j
++){
3944 _234
[i
]=[_232
[i
][0],sum
/_248
];
3946 _234
[i
]=[_232
[i
][0],null];
3950 for(var i
=0;i
<_232
.length
;i
++){
3954 for(var j
=Math
.max(0,i
-_233
+1);j
<i
+1;j
++){
3955 var y
=_232
[j
][1][0];
3961 _249
+=Math
.pow(_232
[j
][1][1],2);
3964 var _242
=Math
.sqrt(_249
)/_248
;
3965 _234
[i
]=[_232
[i
][0],[sum
/_248
,_235
*_242
,_235
*_242
]];
3967 _234
[i
]=[_232
[i
][0],[null,null,null]];
3975 Dygraph
.dateParser
=function(_250
,self
){
3978 if(_250
.length
==10&&_250
.search("-")!=-1){
3979 _251
=_250
.replace("-","/","g");
3980 while(_251
.search("-")!=-1){
3981 _251
=_251
.replace("-","/");
3986 _251
=_250
.substr(0,4)+"/"+_250.substr(4,2)+"/"+_250
.substr(6,2);
3993 self
.error("Couldn't parse "+_250
+" as a date");
3997 Dygraph
.prototype.detectTypeFromString_
=function(str
){
3999 if(str
.indexOf("-")>=0||str
.indexOf("/")>=0||isNaN(parseFloat(str
))){
4002 if(str
.length
==8&&str
>"19700101"&&str
<"20371231"){
4007 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
4008 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
4009 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
4011 this.attrs_
.xValueFormatter
=function(x
){
4014 this.attrs_
.xValueParser
=function(x
){
4015 return parseFloat(x
);
4017 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
4020 Dygraph
.prototype.parseCSV_
=function(data
){
4022 var _254
=data
.split("\n");
4024 if(this.labelsFromCSV_
){
4026 this.attrs_
.labels
=_254
[0].split(",");
4030 var _258
=this.attr_("labels").length
;
4031 for(var i
=_255
;i
<_254
.length
;i
++){
4036 var _260
=line
.split(",");
4042 this.detectTypeFromString_(_260
[0]);
4043 _256
=this.attr_("xValueParser");
4046 _261
[0]=_256(_260
[0],this);
4047 if(this.fractions_
){
4048 for(var j
=1;j
<_260
.length
;j
++){
4049 var vals
=_260
[j
].split("/");
4050 _261
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1])];
4053 if(this.attr_("errorBars")){
4054 for(var j
=1;j
<_260
.length
;j
+=2){
4055 _261
[(j
+1)/2]=[parseFloat(_260
[j
]),parseFloat(_260
[j
+1])];
4058 if(this.attr_("customBars")){
4059 for(var j
=1;j
<_260
.length
;j
++){
4060 var vals
=_260
[j
].split(";");
4061 _261
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1]),parseFloat(vals
[2])];
4064 for(var j
=1;j
<_260
.length
;j
++){
4065 _261
[j
]=parseFloat(_260
[j
]);
4071 if(_261
.length
!=_258
){
4072 this.error("Number of columns in line "+i
+" ("+_261
.length
+") does not agree with number of labels ("+_258
+") "+line
);
4077 Dygraph
.prototype.parseArray_
=function(data
){
4079 this.error("Can't plot empty data set");
4082 if(data
[0].length
==0){
4083 this.error("Data set cannot contain an empty row");
4086 if(this.attr_("labels")==null){
4087 this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
4088 this.attrs_
.labels
=["X"];
4089 for(var i
=1;i
<data
[0].length
;i
++){
4090 this.attrs_
.labels
.push("Y"+i
);
4093 if(MochiKit
.Base
.isDateLike(data
[0][0])){
4094 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
4095 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
4096 var _262
=MochiKit
.Base
.clone(data
);
4097 for(var i
=0;i
<data
.length
;i
++){
4098 if(_262
[i
].length
==0){
4099 this.error("Row "<<(1+i
)<<" of data is empty");
4102 if(_262
[i
][0]==null||typeof (_262
[i
][0].getTime
)!="function"){
4103 this.error("x value in row "<<(1+i
)<<" is not a Date");
4106 _262
[i
][0]=_262
[i
][0].getTime();
4110 this.attrs_
.xValueFormatter
=function(x
){
4113 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
4117 Dygraph
.prototype.parseDataTable_
=function(data
){
4118 var cols
=data
.getNumberOfColumns();
4119 var rows
=data
.getNumberOfRows();
4121 for(var i
=0;i
<cols
;i
++){
4122 _265
.push(data
.getColumnLabel(i
));
4124 this.attrs_
.labels
=_265
;
4125 var _266
=data
.getColumnType(0);
4127 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
4128 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
4129 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
4132 this.attrs_
.xValueFormatter
=function(x
){
4135 this.attrs_
.xValueParser
=function(x
){
4136 return parseFloat(x
);
4138 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
4140 this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_266
+"')");
4145 for(var i
=0;i
<rows
;i
++){
4147 if(!data
.getValue(i
,0)){
4151 row
.push(data
.getValue(i
,0).getTime());
4153 row
.push(data
.getValue(i
,0));
4155 for(var j
=1;j
<cols
;j
++){
4156 row
.push(data
.getValue(i
,j
));
4162 Dygraph
.prototype.start_
=function(){
4163 if(typeof this.file_
=="function"){
4164 this.loadedEvent_(this.file_());
4166 if(MochiKit
.Base
.isArrayLike(this.file_
)){
4167 this.rawData_
=this.parseArray_(this.file_
);
4168 this.drawGraph_(this.rawData_
);
4170 if(typeof this.file_
=="object"&&typeof this.file_
.getColumnRange
=="function"){
4171 this.rawData_
=this.parseDataTable_(this.file_
);
4172 this.drawGraph_(this.rawData_
);
4174 if(typeof this.file_
=="string"){
4175 if(this.file_
.indexOf("\n")>=0){
4176 this.loadedEvent_(this.file_
);
4178 var req
=new XMLHttpRequest();
4180 req
.onreadystatechange
=function(){
4181 if(req
.readyState
==4){
4182 if(req
.status
==200){
4183 _269
.loadedEvent_(req
.responseText
);
4187 req
.open("GET",this.file_
,true);
4191 this.error("Unknown data format: "+(typeof this.file_
));
4197 Dygraph
.prototype.updateOptions
=function(_270
){
4198 if(_270
.rollPeriod
){
4199 this.rollPeriod_
=_270
.rollPeriod
;
4201 if(_270
.dateWindow
){
4202 this.dateWindow_
=_270
.dateWindow
;
4204 if(_270
.valueRange
){
4205 this.valueRange_
=_270
.valueRange
;
4207 MochiKit
.Base
.update(this.user_attrs_
,_270
);
4208 this.labelsFromCSV_
=(this.attr_("labels")==null);
4209 this.layout_
.updateOptions({"errorBars":this.attr_("errorBars")});
4210 if(_270
["file"]&&_270
["file"]!=this.file_
){
4211 this.file_
=_270
["file"];
4214 this.drawGraph_(this.rawData_
);
4217 Dygraph
.prototype.adjustRoll
=function(_271
){
4218 this.rollPeriod_
=_271
;
4219 this.drawGraph_(this.rawData_
);
4221 Dygraph
.GVizChart
=function(_272
){
4222 this.container
=_272
;
4224 Dygraph
.GVizChart
.prototype.draw
=function(data
,_273
){
4225 this.container
.innerHTML
="";
4226 this.date_graph
=new Dygraph(this.container
,data
,_273
);