3 MochiKit.MochiKit 1.4 : PACKED VERSION
5 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
6 diff against the source tree, not this file.
8 See <http://mochikit.com/> for documentation, downloads, license, etc.
10 (c) 2005 Bob Ippolito. All rights Reserved.
14 if(typeof (dojo
)!="undefined"){
15 dojo
.provide("MochiKit.Base");
17 if(typeof (MochiKit
)=="undefined"){
20 if(typeof (MochiKit
.Base
)=="undefined"){
23 if(typeof (MochiKit
.__export__
)=="undefined"){
24 MochiKit
.__export__
=(MochiKit
.__compat__
||(typeof (JSAN
)=="undefined"&&typeof (dojo
)=="undefined"));
26 MochiKit
.Base
.VERSION
="1.4";
27 MochiKit
.Base
.NAME
="MochiKit.Base";
28 MochiKit
.Base
.update
=function(_1
,_2
){
32 for(var i
=1;i
<arguments
.length
;i
++){
34 if(typeof (o
)!="undefined"&&o
!==null){
42 MochiKit
.Base
.update(MochiKit
.Base
,{__repr__
:function(){
43 return "["+this.NAME
+" "+this.VERSION
+"]";
44 },toString
:function(){
45 return this.__repr__();
46 },camelize
:function(_6
){
49 for(var i
=1;i
<_7
.length
;i
++){
50 cc
+=_7
[i
].charAt(0).toUpperCase()+_7
[i
].substring(1);
53 },counter
:function(n
){
54 if(arguments
.length
===0){
61 var me
=arguments
.callee
;
62 if(arguments
.length
==1){
66 },_flattenArray
:function(_d
,_e
){
67 for(var i
=0;i
<_e
.length
;i
++){
69 if(o
instanceof Array
){
70 arguments
.callee(_d
,o
);
76 },flattenArray
:function(lst
){
77 return MochiKit
.Base
._flattenArray([],lst
);
78 },flattenArguments
:function(lst
){
81 var _15
=m
.extend(null,arguments
);
84 if(o
&&typeof (o
)=="object"&&typeof (o
.length
)=="number"){
85 for(var i
=o
.length
-1;i
>=0;i
--){
93 },extend
:function(_18
,obj
,_1a
){
99 if(typeof (l
)!="number"){
100 if(typeof (MochiKit
.Iter
)!="undefined"){
101 obj
=MochiKit
.Iter
.list(obj
);
104 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
110 for(var i
=_1a
;i
<l
;i
++){
115 },updatetree
:function(_1d
,obj
){
119 for(var i
=1;i
<arguments
.length
;i
++){
121 if(typeof (o
)!="undefined"&&o
!==null){
124 if(typeof (_1d
[k
])=="object"&&typeof (v
)=="object"){
125 arguments
.callee(_1d
[k
],v
);
133 },setdefault
:function(_23
,obj
){
137 for(var i
=1;i
<arguments
.length
;i
++){
146 },keys
:function(obj
){
152 },values
:function(obj
){
158 },items
:function(obj
){
172 },_newNamedError
:function(_33
,_34
,_35
){
173 _35
.prototype=new MochiKit
.Base
.NamedError(_33
.NAME
+"."+_34
);
175 },operator
:{truth
:function(a
){
177 },lognot
:function(a
){
179 },identity
:function(a
){
201 },lshift
:function(a
,b
){
203 },rshift
:function(a
,b
){
205 },zrshift
:function(a
,b
){
224 return MochiKit
.Base
.compare(a
,b
)===0;
226 return MochiKit
.Base
.compare(a
,b
)!==0;
228 return MochiKit
.Base
.compare(a
,b
)==1;
230 return MochiKit
.Base
.compare(a
,b
)!=-1;
232 return MochiKit
.Base
.compare(a
,b
)==-1;
234 return MochiKit
.Base
.compare(a
,b
)!=1;
235 },logand
:function(a
,b
){
237 },logor
:function(a
,b
){
239 },contains
:function(a
,b
){
241 }},forwardCall
:function(_73
){
243 return this[_73
].apply(this,arguments
);
245 },itemgetter
:function(_74
){
246 return function(arg
){
249 },typeMatcher
:function(){
251 for(var i
=0;i
<arguments
.length
;i
++){
252 var typ
=arguments
[i
];
256 for(var i
=0;i
<arguments
.length
;i
++){
257 if(!(typeof (arguments
[i
]) in _76
)){
264 for(var i
=0;i
<arguments
.length
;i
++){
265 if(arguments
[i
]!==null){
270 },isUndefinedOrNull
:function(){
271 for(var i
=0;i
<arguments
.length
;i
++){
273 if(!(typeof (o
)=="undefined"||o
===null)){
278 },isEmpty
:function(obj
){
279 return !MochiKit
.Base
.isNotEmpty
.apply(this,arguments
);
280 },isNotEmpty
:function(obj
){
281 for(var i
=0;i
<arguments
.length
;i
++){
288 },isArrayLike
:function(){
289 for(var i
=0;i
<arguments
.length
;i
++){
292 if((typ
!="object"&&!(typ
=="function"&&typeof (o
.item
)=="function"))||o
===null||typeof (o
.length
)!="number"||o
.nodeType
===3){
297 },isDateLike
:function(){
298 for(var i
=0;i
<arguments
.length
;i
++){
300 if(typeof (o
)!="object"||o
===null||typeof (o
.getTime
)!="function"){
307 return MochiKit
.Base
.extend(null,arguments
,1);
310 for(var i
=1;i
<arguments
.length
;i
++){
311 _87
.push(fn(arguments
[i
]));
314 },map
:function(fn
,lst
){
316 var itr
=MochiKit
.Iter
;
317 var _8d
=m
.isArrayLike
;
318 if(arguments
.length
<=2){
326 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
330 return m
.extend(null,lst
);
333 for(var i
=0;i
<lst
.length
;i
++){
334 _8e
.push(fn(lst
[i
]));
342 for(i
=1;i
<arguments
.length
;i
++){
343 if(!_8d(arguments
[i
])){
345 return itr
.list(itr
.imap
.apply(null,arguments
));
347 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
350 var l
=arguments
[i
].length
;
351 if(_90
===null||_90
>l
){
358 for(var j
=1;j
<arguments
.length
;j
++){
359 _92
.push(arguments
[j
][i
]);
361 _8e
.push(fn
.apply(this,_92
));
365 },xfilter
:function(fn
){
368 fn
=MochiKit
.Base
.operator
.truth
;
370 for(var i
=1;i
<arguments
.length
;i
++){
377 },filter
:function(fn
,lst
,_9a
){
380 if(!m
.isArrayLike(lst
)){
382 lst
=MochiKit
.Iter
.list(lst
);
384 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
390 if(typeof (Array
.prototype.filter
)=="function"){
391 return Array
.prototype.filter
.call(lst
,fn
,_9a
);
393 if(typeof (_9a
)=="undefined"||_9a
===null){
394 for(var i
=0;i
<lst
.length
;i
++){
401 for(i
=0;i
<lst
.length
;i
++){
410 },_wrapDumbFunction
:function(_9f
){
412 switch(arguments
.length
){
416 return _9f(arguments
[0]);
418 return _9f(arguments
[0],arguments
[1]);
420 return _9f(arguments
[0],arguments
[1],arguments
[2]);
423 for(var i
=0;i
<arguments
.length
;i
++){
424 _a0
.push("arguments["+i
+"]");
426 return eval("(func("+_a0
.join(",")+"))");
428 },methodcaller
:function(_a2
){
429 var _a3
=MochiKit
.Base
.extend(null,arguments
,1);
430 if(typeof (_a2
)=="function"){
431 return function(obj
){
432 return _a2
.apply(obj
,_a3
);
435 return function(obj
){
436 return obj
[_a2
].apply(obj
,_a3
);
439 },method
:function(_a6
,_a7
){
441 return m
.bind
.apply(this,m
.extend([_a7
,_a6
],arguments
,2));
442 },compose
:function(f1
,f2
){
445 if(arguments
.length
===0){
446 throw new TypeError("compose() requires at least one argument");
448 for(var i
=0;i
<arguments
.length
;i
++){
450 if(typeof (fn
)!="function"){
451 throw new TypeError(m
.repr(fn
)+" is not a function");
457 for(var i
=_ab
.length
-1;i
>=0;i
--){
458 _af
=[_ab
[i
].apply(this,_af
)];
462 },bind
:function(_b1
,_b2
){
463 if(typeof (_b1
)=="string"){
467 var _b4
=_b1
.im_preargs
;
470 if(typeof (_b1
)=="function"&&typeof (_b1
.apply
)=="undefined"){
471 _b1
=m
._wrapDumbFunction(_b1
);
473 if(typeof (_b3
)!="function"){
476 if(typeof (_b2
)!="undefined"){
479 if(typeof (_b4
)=="undefined"){
484 m
.extend(_b4
,arguments
,2);
487 var me
=arguments
.callee
;
488 if(me
.im_preargs
.length
>0){
489 _b8
=m
.concat(me
.im_preargs
,_b8
);
495 return me
.im_func
.apply(_ba
,_b8
);
501 },bindMethods
:function(_bb
){
502 var _bc
=MochiKit
.Base
.bind
;
505 if(typeof (_be
)=="function"){
509 },registerComparator
:function(_bf
,_c0
,_c1
,_c2
){
510 MochiKit
.Base
.comparatorRegistry
.register(_bf
,_c0
,_c1
,_c2
);
511 },_primitives
:{"boolean":true,"string":true,"number":true},compare
:function(a
,b
){
515 var _c5
=(typeof (a
)=="undefined"||a
===null);
516 var _c6
=(typeof (b
)=="undefined"||b
===null);
529 var _c8
=m
._primitives
;
530 if(!(typeof (a
) in _c8
&&typeof (b
) in _c8
)){
532 return m
.comparatorRegistry
.match(a
,b
);
548 throw new TypeError(_c9(a
)+" and "+_c9(b
)+" can not be compared");
549 },compareDateLike
:function(a
,b
){
550 return MochiKit
.Base
.compare(a
.getTime(),b
.getTime());
551 },compareArrayLike
:function(a
,b
){
552 var _ce
=MochiKit
.Base
.compare
;
563 for(var i
=0;i
<_cf
;i
++){
564 var cmp
=_ce(a
[i
],b
[i
]);
570 },registerRepr
:function(_d3
,_d4
,_d5
,_d6
){
571 MochiKit
.Base
.reprRegistry
.register(_d3
,_d4
,_d5
,_d6
);
573 if(typeof (o
)=="undefined"){
581 if(typeof (o
.__repr__
)=="function"){
584 if(typeof (o
.repr
)=="function"&&o
.repr
!=arguments
.callee
){
588 return MochiKit
.Base
.reprRegistry
.match(o
);
591 if(typeof (o
.NAME
)=="string"&&(o
.toString
==Function
.prototype.toString
||o
.toString
==Object
.prototype.toString
)){
599 return "["+typeof (o
)+"]";
601 if(typeof (o
)=="function"){
602 o
=_d8
.replace(/^\s+/,"");
603 var idx
=o
.indexOf("{");
605 o
=o
.substr(0,idx
)+"{...}";
609 },reprArrayLike
:function(o
){
611 return "["+m
.map(m
.repr
,o
).join(", ")+"]";
612 },reprString
:function(o
){
613 return ("\""+o
.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r");
614 },reprNumber
:function(o
){
616 },registerJSON
:function(_de
,_df
,_e0
,_e1
){
617 MochiKit
.Base
.jsonRegistry
.register(_de
,_df
,_e0
,_e1
);
618 },evalJSON
:function(){
619 return eval("("+arguments
[0]+")");
620 },serializeJSON
:function(o
){
622 if(_e3
=="number"||_e3
=="boolean"){
630 var _e5
=m
.reprString
;
634 var me
=arguments
.callee
;
636 if(typeof (o
.__json__
)=="function"){
642 if(typeof (o
.json
)=="function"){
648 if(_e3
!="function"&&typeof (o
.length
)=="number"){
650 for(var i
=0;i
<o
.length
;i
++){
652 if(typeof (val
)!="string"){
657 return "["+res
.join(", ")+"]";
660 _e7
=m
.jsonRegistry
.match(o
);
670 if(_e3
=="undefined"){
671 throw new TypeError("undefined can not be serialized as JSON");
679 if(typeof (k
)=="number"){
682 if(typeof (k
)=="string"){
689 if(typeof (val
)!="string"){
692 res
.push(_ec
+":"+val
);
694 return "{"+res
.join(", ")+"}";
695 },objEqual
:function(a
,b
){
696 return (MochiKit
.Base
.compare(a
,b
)===0);
697 },arrayEqual
:function(_ef
,arr
){
698 if(_ef
.length
!=arr
.length
){
701 return (MochiKit
.Base
.compare(_ef
,arr
)===0);
704 var _f2
=MochiKit
.Base
.extend
;
705 for(var i
=0;i
<arguments
.length
;i
++){
706 _f2(_f1
,arguments
[i
]);
709 },keyComparator
:function(key
){
712 if(arguments
.length
==1){
713 return function(a
,b
){
714 return _f6(a
[key
],b
[key
]);
717 var _f9
=m
.extend(null,arguments
);
718 return function(a
,b
){
720 for(var i
=0;(_fc
===0)&&(i
<_f9
.length
);i
++){
722 _fc
=_f6(a
[key
],b
[key
]);
726 },reverseKeyComparator
:function(key
){
727 var _100
=MochiKit
.Base
.keyComparator
.apply(this,arguments
);
728 return function(a
,b
){
731 },partial
:function(func
){
733 return m
.bind
.apply(this,m
.extend([func
,undefined
],arguments
,1));
734 },listMinMax
:function(_105
,lst
){
739 var _108
=MochiKit
.Base
.compare
;
740 for(var i
=1;i
<lst
.length
;i
++){
742 if(_108(o
,cur
)==_105
){
748 return MochiKit
.Base
.listMinMax(1,arguments
);
750 return MochiKit
.Base
.listMinMax(-1,arguments
);
751 },findIdentical
:function(lst
,_10c
,_10d
,end
){
752 if(typeof (end
)=="undefined"||end
===null){
755 if(typeof (_10d
)=="undefined"||_10d
===null){
758 for(var i
=_10d
;i
<end
;i
++){
767 var args
=m
.extend(null,arguments
);
768 var _113
=args
.length
;
771 if(o
&&typeof (o
)=="object"&&typeof (o
.length
)=="number"){
773 for(var i
=o
.length
-1;i
>=0;i
--){
781 throw new TypeError("mean() requires at least one argument");
785 var data
=MochiKit
.Base
.flattenArguments(arguments
);
787 throw new TypeError("median() requires at least one argument");
790 if(data
.length
%2==0){
791 var _117
=data
.length
/2;
792 return (data
[_117
]+data
[_117
-1])/2;
794 return data
[(data
.length
-1)/2];
796 },findValue
:function(lst
,_119
,_11a
,end
){
797 if(typeof (end
)=="undefined"||end
===null){
800 if(typeof (_11a
)=="undefined"||_11a
===null){
803 var cmp
=MochiKit
.Base
.compare
;
804 for(var i
=_11a
;i
<end
;i
++){
805 if(cmp(lst
[i
],_119
)===0){
810 },nodeWalk
:function(node
,_11f
){
812 var _121
=MochiKit
.Base
.extend
;
814 var res
=_11f(_120
.shift());
819 },nameFunctions
:function(_123
){
821 if(typeof (base
)=="undefined"){
826 for(var name
in _123
){
828 if(typeof (o
)=="function"&&typeof (o
.NAME
)=="undefined"){
836 },queryString
:function(_127
,_128
){
837 if(typeof (MochiKit
.DOM
)!="undefined"&&arguments
.length
==1&&(typeof (_127
)=="string"||(typeof (_127
.nodeType
)!="undefined"&&_127
.nodeType
>0))){
838 var kv
=MochiKit
.DOM
.formContents(_127
);
842 if(arguments
.length
==1){
843 if(typeof (_127
.length
)=="number"&&_127
.length
==2){
844 return arguments
.callee(_127
[0],_127
[1]);
851 if(typeof (v
)=="function"){
854 if(typeof (v
)!="string"&&typeof (v
.length
)=="number"){
855 for(var i
=0;i
<v
.length
;i
++){
868 var len
=Math
.min(_127
.length
,_128
.length
);
869 var _130
=MochiKit
.Base
.urlEncode
;
870 for(var i
=0;i
<len
;i
++){
872 if(typeof (v
)!="undefined"&&v
!==null){
873 rval
.push(_130(_127
[i
])+"="+_130(v
));
876 return rval
.join("&");
877 },parseQueryString
:function(_131
,_132
){
878 var qstr
=(_131
.charAt(0)=="?")?_131
.substring(1):_131
;
879 var _134
=qstr
.replace(/\+/g,"%20").split(/(\&\;|\&\#38\;|\&|\&)/);
882 if(typeof (decodeURIComponent
)!="undefined"){
883 _136
=decodeURIComponent
;
888 for(var i
=0;i
<_134
.length
;i
++){
889 var pair
=_134
[i
].split("=");
890 var name
=_136(pair
.shift());
895 if(!(arr
instanceof Array
)){
899 arr
.push(_136(pair
.join("=")));
902 for(i
=0;i
<_134
.length
;i
++){
903 pair
=_134
[i
].split("=");
904 var name
=pair
.shift();
908 o
[_136(name
)]=_136(pair
.join("="));
913 MochiKit
.Base
.AdapterRegistry
=function(){
916 MochiKit
.Base
.AdapterRegistry
.prototype={register
:function(name
,_13c
,wrap
,_13e
){
918 this.pairs
.unshift([name
,_13c
,wrap
]);
920 this.pairs
.push([name
,_13c
,wrap
]);
923 for(var i
=0;i
<this.pairs
.length
;i
++){
924 var pair
=this.pairs
[i
];
925 if(pair
[1].apply(this,arguments
)){
926 return pair
[2].apply(this,arguments
);
929 throw MochiKit
.Base
.NotFound
;
930 },unregister
:function(name
){
931 for(var i
=0;i
<this.pairs
.length
;i
++){
932 var pair
=this.pairs
[i
];
934 this.pairs
.splice(i
,1);
940 MochiKit
.Base
.EXPORT
=["flattenArray","noop","camelize","counter","clone","extend","update","updatetree","setdefault","keys","values","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isEmpty","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","methodcaller","compose","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","findValue","findIdentical","flattenArguments","method","average","mean","median"];
941 MochiKit
.Base
.EXPORT_OK
=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"];
942 MochiKit
.Base
._exportSymbols
=function(_144
,_145
){
943 if(!MochiKit
.__export__
){
946 var all
=_145
.EXPORT_TAGS
[":all"];
947 for(var i
=0;i
<all
.length
;i
++){
948 _144
[all
[i
]]=_145
[all
[i
]];
951 MochiKit
.Base
.__new__
=function(){
953 m
.noop
=m
.operator
.identity
;
954 m
.forward
=m
.forwardCall
;
956 if(typeof (encodeURIComponent
)!="undefined"){
957 m
.urlEncode
=function(_149
){
958 return encodeURIComponent(_149
).replace(/\'/g,"%27");
961 m
.urlEncode
=function(_14a
){
962 return escape(_14a
).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval
.replace(/\'/g,"%27");
965 m
.NamedError
=function(name
){
969 m
.NamedError
.prototype=new Error();
970 m
.update(m
.NamedError
.prototype,{repr
:function(){
971 if(this.message
&&this.message
!=this.name
){
972 return this.name
+"("+m
.repr(this.message
)+")";
974 return this.name
+"()";
976 },toString
:m
.forwardCall("repr")});
977 m
.NotFound
=new m
.NamedError("MochiKit.Base.NotFound");
978 m
.listMax
=m
.partial(m
.listMinMax
,1);
979 m
.listMin
=m
.partial(m
.listMinMax
,-1);
980 m
.isCallable
=m
.typeMatcher("function");
981 m
.isUndefined
=m
.typeMatcher("undefined");
982 m
.merge
=m
.partial(m
.update
,null);
983 m
.zip
=m
.partial(m
.map
,null);
985 m
.comparatorRegistry
=new m
.AdapterRegistry();
986 m
.registerComparator("dateLike",m
.isDateLike
,m
.compareDateLike
);
987 m
.registerComparator("arrayLike",m
.isArrayLike
,m
.compareArrayLike
);
988 m
.reprRegistry
=new m
.AdapterRegistry();
989 m
.registerRepr("arrayLike",m
.isArrayLike
,m
.reprArrayLike
);
990 m
.registerRepr("string",m
.typeMatcher("string"),m
.reprString
);
991 m
.registerRepr("numbers",m
.typeMatcher("number","boolean"),m
.reprNumber
);
992 m
.jsonRegistry
=new m
.AdapterRegistry();
993 var all
=m
.concat(m
.EXPORT
,m
.EXPORT_OK
);
994 m
.EXPORT_TAGS
={":common":m
.concat(m
.EXPORT_OK
),":all":all
};
995 m
.nameFunctions(this);
997 MochiKit
.Base
.__new__();
998 if(MochiKit
.__export__
){
999 compare
=MochiKit
.Base
.compare
;
1000 compose
=MochiKit
.Base
.compose
;
1001 serializeJSON
=MochiKit
.Base
.serializeJSON
;
1003 MochiKit
.Base
._exportSymbols(this,MochiKit
.Base
);
1004 if(typeof (dojo
)!="undefined"){
1005 dojo
.provide("MochiKit.Iter");
1006 dojo
.require("MochiKit.Base");
1008 if(typeof (JSAN
)!="undefined"){
1009 JSAN
.use("MochiKit.Base",[]);
1012 if(typeof (MochiKit
.Base
)=="undefined"){
1017 throw "MochiKit.Iter depends on MochiKit.Base!";
1019 if(typeof (MochiKit
.Iter
)=="undefined"){
1022 MochiKit
.Iter
.NAME
="MochiKit.Iter";
1023 MochiKit
.Iter
.VERSION
="1.4";
1024 MochiKit
.Base
.update(MochiKit
.Iter
,{__repr__
:function(){
1025 return "["+this.NAME
+" "+this.VERSION
+"]";
1026 },toString
:function(){
1027 return this.__repr__();
1028 },registerIteratorFactory
:function(name
,_14e
,_14f
,_150
){
1029 MochiKit
.Iter
.iteratorRegistry
.register(name
,_14e
,_14f
,_150
);
1030 },iter
:function(_151
,_152
){
1031 var self
=MochiKit
.Iter
;
1032 if(arguments
.length
==2){
1033 return self
.takewhile(function(a
){
1037 if(typeof (_151
.next
)=="function"){
1040 if(typeof (_151
.iter
)=="function"){
1045 return self
.iteratorRegistry
.match(_151
);
1048 var m
=MochiKit
.Base
;
1050 e
=new TypeError(typeof (_151
)+": "+m
.repr(_151
)+" is not iterable");
1054 },count
:function(n
){
1058 var m
=MochiKit
.Base
;
1059 return {repr
:function(){
1060 return "count("+n
+")";
1061 },toString
:m
.forwardCall("repr"),next
:m
.counter(n
)};
1062 },cycle
:function(p
){
1063 var self
=MochiKit
.Iter
;
1064 var m
=MochiKit
.Base
;
1066 var _15c
=self
.iter(p
);
1067 return {repr
:function(){
1068 return "cycle(...)";
1069 },toString
:m
.forwardCall("repr"),next
:function(){
1071 var rval
=_15c
.next();
1076 if(e
!=self
.StopIteration
){
1080 this.next
=function(){
1081 throw self
.StopIteration
;
1085 this.next
=function(){
1093 },repeat
:function(elem
,n
){
1094 var m
=MochiKit
.Base
;
1095 if(typeof (n
)=="undefined"){
1096 return {repr
:function(){
1097 return "repeat("+m
.repr(elem
)+")";
1098 },toString
:m
.forwardCall("repr"),next
:function(){
1102 return {repr
:function(){
1103 return "repeat("+m
.repr(elem
)+", "+n
+")";
1104 },toString
:m
.forwardCall("repr"),next
:function(){
1106 throw MochiKit
.Iter
.StopIteration
;
1111 },next
:function(_162
){
1113 },izip
:function(p
,q
){
1114 var m
=MochiKit
.Base
;
1115 var self
=MochiKit
.Iter
;
1117 var _168
=m
.map(self
.iter
,arguments
);
1118 return {repr
:function(){
1120 },toString
:m
.forwardCall("repr"),next
:function(){
1121 return m
.map(next
,_168
);
1123 },ifilter
:function(pred
,seq
){
1124 var m
=MochiKit
.Base
;
1125 seq
=MochiKit
.Iter
.iter(seq
);
1127 pred
=m
.operator
.truth
;
1129 return {repr
:function(){
1130 return "ifilter(...)";
1131 },toString
:m
.forwardCall("repr"),next
:function(){
1133 var rval
=seq
.next();
1140 },ifilterfalse
:function(pred
,seq
){
1141 var m
=MochiKit
.Base
;
1142 seq
=MochiKit
.Iter
.iter(seq
);
1144 pred
=m
.operator
.truth
;
1146 return {repr
:function(){
1147 return "ifilterfalse(...)";
1148 },toString
:m
.forwardCall("repr"),next
:function(){
1150 var rval
=seq
.next();
1157 },islice
:function(seq
){
1158 var self
=MochiKit
.Iter
;
1159 var m
=MochiKit
.Base
;
1165 if(arguments
.length
==2){
1168 if(arguments
.length
==3){
1177 return {repr
:function(){
1178 return "islice("+["...",_174
,stop
,step
].join(", ")+")";
1179 },toString
:m
.forwardCall("repr"),next
:function(){
1186 throw self
.StopIteration
;
1191 },imap
:function(fun
,p
,q
){
1192 var m
=MochiKit
.Base
;
1193 var self
=MochiKit
.Iter
;
1194 var _17e
=m
.map(self
.iter
,m
.extend(null,arguments
,1));
1197 return {repr
:function(){
1199 },toString
:m
.forwardCall("repr"),next
:function(){
1200 return fun
.apply(this,map(next
,_17e
));
1202 },applymap
:function(fun
,seq
,self
){
1203 seq
=MochiKit
.Iter
.iter(seq
);
1204 var m
=MochiKit
.Base
;
1205 return {repr
:function(){
1206 return "applymap(...)";
1207 },toString
:m
.forwardCall("repr"),next
:function(){
1208 return fun
.apply(self
,seq
.next());
1210 },chain
:function(p
,q
){
1211 var self
=MochiKit
.Iter
;
1212 var m
=MochiKit
.Base
;
1213 if(arguments
.length
==1){
1214 return self
.iter(arguments
[0]);
1216 var _189
=m
.map(self
.iter
,arguments
);
1217 return {repr
:function(){
1218 return "chain(...)";
1219 },toString
:m
.forwardCall("repr"),next
:function(){
1220 while(_189
.length
>1){
1222 return _189
[0].next();
1225 if(e
!=self
.StopIteration
){
1232 var arg
=_189
.shift();
1233 this.next
=m
.bind("next",arg
);
1236 throw self
.StopIteration
;
1238 },takewhile
:function(pred
,seq
){
1239 var self
=MochiKit
.Iter
;
1241 return {repr
:function(){
1242 return "takewhile(...)";
1243 },toString
:MochiKit
.Base
.forwardCall("repr"),next
:function(){
1244 var rval
=seq
.next();
1246 this.next
=function(){
1247 throw self
.StopIteration
;
1253 },dropwhile
:function(pred
,seq
){
1254 seq
=MochiKit
.Iter
.iter(seq
);
1255 var m
=MochiKit
.Base
;
1257 return {"repr":function(){
1258 return "dropwhile(...)";
1259 },"toString":m
.forwardCall("repr"),"next":function(){
1261 var rval
=seq
.next();
1266 this.next
=bind("next",seq
);
1269 },_tee
:function(_194
,sync
,_196
){
1271 var m
=MochiKit
.Base
;
1273 return {repr
:function(){
1274 return "tee("+_194
+", ...)";
1275 },toString
:m
.forwardCall("repr"),next
:function(){
1277 var i
=sync
.pos
[_194
];
1280 sync
.deque
.push(rval
);
1284 rval
=sync
.deque
[i
-sync
.min
];
1286 if(i
==sync
.min
&&_198(sync
.pos
)!=sync
.min
){
1293 },tee
:function(_19b
,n
){
1295 var sync
={"pos":[],"deque":[],"max":-1,"min":-1};
1296 if(arguments
.length
==1||typeof (n
)=="undefined"||n
===null){
1299 var self
=MochiKit
.Iter
;
1300 _19b
=self
.iter(_19b
);
1302 for(var i
=0;i
<n
;i
++){
1303 rval
.push(_tee(i
,sync
,_19b
));
1306 },list
:function(_1a2
){
1308 if(_1a2
instanceof Array
){
1309 return _1a2
.slice();
1311 if(typeof (_1a2
)=="function"&&!(_1a2
instanceof Function
)&&typeof (_1a2
.length
)=="number"){
1313 for(var i
=0;i
<_1a2
.length
;i
++){
1318 var self
=MochiKit
.Iter
;
1319 _1a2
=self
.iter(_1a2
);
1323 rval
.push(_1a2
.next());
1327 if(e
!=self
.StopIteration
){
1333 },reduce
:function(fn
,_1a7
,_1a8
){
1336 var self
=MochiKit
.Iter
;
1337 _1a7
=self
.iter(_1a7
);
1338 if(arguments
.length
<3){
1343 if(e
==self
.StopIteration
){
1344 e
=new TypeError("reduce() of empty sequence with no initial value");
1352 x
=fn(x
,_1a7
.next());
1356 if(e
!=self
.StopIteration
){
1365 if(arguments
.length
==1){
1368 if(arguments
.length
==2){
1372 if(arguments
.length
==3){
1377 throw new TypeError("range() takes 1, 2, or 3 arguments!");
1382 throw new TypeError("range() step must not be 0");
1384 return {next
:function(){
1385 if((step
>0&&_1ac
>=stop
)||(step
<0&&_1ac
<=stop
)){
1386 throw MochiKit
.Iter
.StopIteration
;
1392 return "range("+[_1ac
,stop
,step
].join(", ")+")";
1393 },toString
:MochiKit
.Base
.forwardCall("repr")};
1394 },sum
:function(_1b0
,_1b1
){
1395 if(typeof (_1b1
)=="undefined"||_1b1
===null){
1399 var self
=MochiKit
.Iter
;
1400 _1b0
=self
.iter(_1b0
);
1407 if(e
!=self
.StopIteration
){
1412 },exhaust
:function(_1b4
){
1413 var self
=MochiKit
.Iter
;
1414 _1b4
=self
.iter(_1b4
);
1421 if(e
!=self
.StopIteration
){
1425 },forEach
:function(_1b6
,func
,self
){
1426 var m
=MochiKit
.Base
;
1427 if(arguments
.length
>2){
1428 func
=m
.bind(func
,self
);
1430 if(m
.isArrayLike(_1b6
)){
1432 for(var i
=0;i
<_1b6
.length
;i
++){
1437 if(e
!=MochiKit
.Iter
.StopIteration
){
1443 self
.exhaust(self
.imap(func
,_1b6
));
1445 },every
:function(_1bb
,func
){
1446 var self
=MochiKit
.Iter
;
1448 self
.ifilterfalse(func
,_1bb
).next();
1452 if(e
!=self
.StopIteration
){
1457 },sorted
:function(_1be
,cmp
){
1458 var rval
=MochiKit
.Iter
.list(_1be
);
1459 if(arguments
.length
==1){
1460 cmp
=MochiKit
.Base
.compare
;
1464 },reversed
:function(_1c1
){
1465 var rval
=MochiKit
.Iter
.list(_1c1
);
1468 },some
:function(_1c3
,func
){
1469 var self
=MochiKit
.Iter
;
1471 self
.ifilter(func
,_1c3
).next();
1475 if(e
!=self
.StopIteration
){
1480 },iextend
:function(lst
,_1c7
){
1481 if(MochiKit
.Base
.isArrayLike(_1c7
)){
1482 for(var i
=0;i
<_1c7
.length
;i
++){
1486 var self
=MochiKit
.Iter
;
1487 _1c7
=self
.iter(_1c7
);
1490 lst
.push(_1c7
.next());
1494 if(e
!=self
.StopIteration
){
1500 },groupby
:function(_1ca
,_1cb
){
1501 var m
=MochiKit
.Base
;
1502 var self
=MochiKit
.Iter
;
1503 if(arguments
.length
<2){
1504 _1cb
=m
.operator
.identity
;
1506 _1ca
=self
.iter(_1ca
);
1521 return {repr
:function(){
1522 return "groupby(...)";
1524 while(_1d3(k
,pk
)===0){
1532 return [k
,{next
:function(){
1537 throw self
.StopIteration
;
1542 },groupby_as_array
:function(_1d4
,_1d5
){
1543 var m
=MochiKit
.Base
;
1544 var self
=MochiKit
.Iter
;
1545 if(arguments
.length
<2){
1546 _1d5
=m
.operator
.identity
;
1548 _1d4
=self
.iter(_1d4
);
1555 var _1dc
=_1d4
.next();
1559 if(e
==self
.StopIteration
){
1564 if(_1d9
||_1db(key
,_1da
)!==0){
1566 _1d8
.push([key
,_1de
]);
1573 },arrayLikeIter
:function(_1df
){
1575 return {repr
:function(){
1576 return "arrayLikeIter(...)";
1577 },toString
:MochiKit
.Base
.forwardCall("repr"),next
:function(){
1579 throw MochiKit
.Iter
.StopIteration
;
1583 },hasIterateNext
:function(_1e1
){
1584 return (_1e1
&&typeof (_1e1
.iterateNext
)=="function");
1585 },iterateNextIter
:function(_1e2
){
1586 return {repr
:function(){
1587 return "iterateNextIter(...)";
1588 },toString
:MochiKit
.Base
.forwardCall("repr"),next
:function(){
1589 var rval
=_1e2
.iterateNext();
1590 if(rval
===null||rval
===undefined
){
1591 throw MochiKit
.Iter
.StopIteration
;
1596 MochiKit
.Iter
.EXPORT_OK
=["iteratorRegistry","arrayLikeIter","hasIterateNext","iterateNextIter",];
1597 MochiKit
.Iter
.EXPORT
=["StopIteration","registerIteratorFactory","iter","count","cycle","repeat","next","izip","ifilter","ifilterfalse","islice","imap","applymap","chain","takewhile","dropwhile","tee","list","reduce","range","sum","exhaust","forEach","every","sorted","reversed","some","iextend","groupby","groupby_as_array"];
1598 MochiKit
.Iter
.__new__
=function(){
1599 var m
=MochiKit
.Base
;
1600 if(typeof (StopIteration
)!="undefined"){
1601 this.StopIteration
=StopIteration
;
1603 this.StopIteration
=new m
.NamedError("StopIteration");
1605 this.iteratorRegistry
=new m
.AdapterRegistry();
1606 this.registerIteratorFactory("arrayLike",m
.isArrayLike
,this.arrayLikeIter
);
1607 this.registerIteratorFactory("iterateNext",this.hasIterateNext
,this.iterateNextIter
);
1608 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
1609 m
.nameFunctions(this);
1611 MochiKit
.Iter
.__new__();
1612 if(MochiKit
.__export__
){
1613 reduce
=MochiKit
.Iter
.reduce
;
1615 MochiKit
.Base
._exportSymbols(this,MochiKit
.Iter
);
1616 if(typeof (dojo
)!="undefined"){
1617 dojo
.provide("MochiKit.Logging");
1618 dojo
.require("MochiKit.Base");
1620 if(typeof (JSAN
)!="undefined"){
1621 JSAN
.use("MochiKit.Base",[]);
1624 if(typeof (MochiKit
.Base
)=="undefined"){
1629 throw "MochiKit.Logging depends on MochiKit.Base!";
1631 if(typeof (MochiKit
.Logging
)=="undefined"){
1632 MochiKit
.Logging
={};
1634 MochiKit
.Logging
.NAME
="MochiKit.Logging";
1635 MochiKit
.Logging
.VERSION
="1.4";
1636 MochiKit
.Logging
.__repr__
=function(){
1637 return "["+this.NAME
+" "+this.VERSION
+"]";
1639 MochiKit
.Logging
.toString
=function(){
1640 return this.__repr__();
1642 MochiKit
.Logging
.EXPORT
=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"];
1643 MochiKit
.Logging
.EXPORT_OK
=["logLevelAtLeast","isLogMessage","compareLogMessage"];
1644 MochiKit
.Logging
.LogMessage
=function(num
,_1e6
,info
){
1648 this.timestamp
=new Date();
1650 MochiKit
.Logging
.LogMessage
.prototype={repr
:function(){
1651 var m
=MochiKit
.Base
;
1652 return "LogMessage("+m
.map(m
.repr
,[this.num
,this.level
,this.info
]).join(", ")+")";
1653 },toString
:MochiKit
.Base
.forwardCall("repr")};
1654 MochiKit
.Base
.update(MochiKit
.Logging
,{logLevelAtLeast
:function(_1e9
){
1655 var self
=MochiKit
.Logging
;
1656 if(typeof (_1e9
)=="string"){
1657 _1e9
=self
.LogLevel
[_1e9
];
1659 return function(msg
){
1661 if(typeof (_1ec
)=="string"){
1662 _1ec
=self
.LogLevel
[_1ec
];
1666 },isLogMessage
:function(){
1667 var _1ed
=MochiKit
.Logging
.LogMessage
;
1668 for(var i
=0;i
<arguments
.length
;i
++){
1669 if(!(arguments
[i
] instanceof _1ed
)){
1674 },compareLogMessage
:function(a
,b
){
1675 return MochiKit
.Base
.compare([a
.level
,a
.info
],[b
.level
,b
.info
]);
1676 },alertListener
:function(msg
){
1677 alert("num: "+msg
.num
+"\nlevel: "+msg
.level
+"\ninfo: "+msg
.info
.join(" "));
1679 MochiKit
.Logging
.Logger
=function(_1f2
){
1681 if(typeof (_1f2
)=="undefined"||_1f2
===null){
1687 this.useNativeConsole
=false;
1689 MochiKit
.Logging
.Logger
.prototype={clear
:function(){
1690 this._messages
.splice(0,this._messages
.length
);
1691 },logToConsole
:function(msg
){
1692 if(typeof (window
)!="undefined"&&window
.console
&&window
.console
.log
){
1693 window
.console
.log(msg
.replace(/%/g,"\uff05"));
1695 if(typeof (opera
)!="undefined"&&opera
.postError
){
1696 opera
.postError(msg
);
1698 if(typeof (printfire
)=="function"){
1701 if(typeof (Debug
)!="undefined"&&Debug
.writeln
){
1704 if(typeof (debug
)!="undefined"&&debug
.trace
){
1711 },dispatchListeners
:function(msg
){
1712 for(var k
in this.listeners
){
1713 var pair
=this.listeners
[k
];
1714 if(pair
.ident
!=k
||(pair
[0]&&!pair
[0](msg
))){
1719 },addListener
:function(_1f7
,_1f8
,_1f9
){
1720 if(typeof (_1f8
)=="string"){
1721 _1f8
=MochiKit
.Logging
.logLevelAtLeast(_1f8
);
1723 var _1fa
=[_1f8
,_1f9
];
1725 this.listeners
[_1f7
]=_1fa
;
1726 },removeListener
:function(_1fb
){
1727 delete this.listeners
[_1fb
];
1728 },baseLog
:function(_1fc
,_1fd
){
1729 var msg
=new MochiKit
.Logging
.LogMessage(this.counter
,_1fc
,MochiKit
.Base
.extend(null,arguments
,1));
1730 this._messages
.push(msg
);
1731 this.dispatchListeners(msg
);
1732 if(this.useNativeConsole
){
1733 this.logToConsole(msg
.level
+": "+msg
.info
.join(" "));
1736 while(this.maxSize
>=0&&this._messages
.length
>this.maxSize
){
1737 this._messages
.shift();
1739 },getMessages
:function(_1ff
){
1741 if(!(typeof (_1ff
)=="undefined"||_1ff
===null)){
1742 _200
=Math
.max(0,this._messages
.length
-_1ff
);
1744 return this._messages
.slice(_200
);
1745 },getMessageText
:function(_201
){
1746 if(typeof (_201
)=="undefined"||_201
===null){
1749 var _202
=this.getMessages(_201
);
1751 var lst
=map(function(m
){
1752 return "\n ["+m
.num
+"] "+m
.level
+": "+m
.info
.join(" ");
1754 lst
.unshift("LAST "+_202
.length
+" MESSAGES:");
1755 return lst
.join("");
1758 },debuggingBookmarklet
:function(_205
){
1759 if(typeof (MochiKit
.LoggingPane
)=="undefined"){
1760 alert(this.getMessageText());
1762 MochiKit
.LoggingPane
.createLoggingPane(_205
||false);
1765 MochiKit
.Logging
.__new__
=function(){
1766 this.LogLevel
={ERROR
:40,FATAL
:50,WARNING
:30,INFO
:20,DEBUG
:10};
1767 var m
=MochiKit
.Base
;
1768 m
.registerComparator("LogMessage",this.isLogMessage
,this.compareLogMessage
);
1770 var _208
=this.Logger
;
1771 var _209
=_208
.prototype.baseLog
;
1772 m
.update(this.Logger
.prototype,{debug
:_207(_209
,"DEBUG"),log
:_207(_209
,"INFO"),error
:_207(_209
,"ERROR"),fatal
:_207(_209
,"FATAL"),warning
:_207(_209
,"WARNING")});
1774 var _20b
=function(name
){
1776 self
.logger
[name
].apply(self
.logger
,arguments
);
1779 this.log
=_20b("log");
1780 this.logError
=_20b("error");
1781 this.logDebug
=_20b("debug");
1782 this.logFatal
=_20b("fatal");
1783 this.logWarning
=_20b("warning");
1784 this.logger
=new _208();
1785 this.logger
.useNativeConsole
=true;
1786 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
1787 m
.nameFunctions(this);
1789 if(typeof (printfire
)=="undefined"&&typeof (document
)!="undefined"&&document
.createEvent
&&typeof (dispatchEvent
)!="undefined"){
1790 printfire
=function(){
1791 printfire
.args
=arguments
;
1792 var ev
=document
.createEvent("Events");
1793 ev
.initEvent("printfire",false,true);
1797 MochiKit
.Logging
.__new__();
1798 MochiKit
.Base
._exportSymbols(this,MochiKit
.Logging
);
1799 if(typeof (dojo
)!="undefined"){
1800 dojo
.provide("MochiKit.DateTime");
1802 if(typeof (MochiKit
)=="undefined"){
1805 if(typeof (MochiKit
.DateTime
)=="undefined"){
1806 MochiKit
.DateTime
={};
1808 MochiKit
.DateTime
.NAME
="MochiKit.DateTime";
1809 MochiKit
.DateTime
.VERSION
="1.4";
1810 MochiKit
.DateTime
.__repr__
=function(){
1811 return "["+this.NAME
+" "+this.VERSION
+"]";
1813 MochiKit
.DateTime
.toString
=function(){
1814 return this.__repr__();
1816 MochiKit
.DateTime
.isoDate
=function(str
){
1818 if(typeof (str
)!="string"||str
.length
===0){
1821 var iso
=str
.split("-");
1825 return new Date(iso
[0],iso
[1]-1,iso
[2]);
1827 MochiKit
.DateTime
._isoRegexp
=/(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/;
1828 MochiKit
.DateTime
.isoTimestamp
=function(str
){
1830 if(typeof (str
)!="string"||str
.length
===0){
1833 var res
=str
.match(MochiKit
.DateTime
._isoRegexp
);
1834 if(typeof (res
)=="undefined"||res
===null){
1837 var year
,_213
,day
,hour
,min
,sec
,msec
;
1838 year
=parseInt(res
[1],10);
1839 if(typeof (res
[2])=="undefined"||res
[2]===""){
1840 return new Date(year
);
1842 _213
=parseInt(res
[2],10)-1;
1843 day
=parseInt(res
[3],10);
1844 if(typeof (res
[4])=="undefined"||res
[4]===""){
1845 return new Date(year
,_213
,day
);
1847 hour
=parseInt(res
[4],10);
1848 min
=parseInt(res
[5],10);
1849 sec
=(typeof (res
[6])!="undefined"&&res
[6]!=="")?parseInt(res
[6],10):0;
1850 if(typeof (res
[7])!="undefined"&&res
[7]!==""){
1851 msec
=Math
.round(1000*parseFloat("0."+res
[7]));
1855 if((typeof (res
[8])=="undefined"||res
[8]==="")&&(typeof (res
[9])=="undefined"||res
[9]==="")){
1856 return new Date(year
,_213
,day
,hour
,min
,sec
,msec
);
1859 if(typeof (res
[9])!="undefined"&&res
[9]!==""){
1860 ofs
=parseInt(res
[10],10)*3600000;
1861 if(typeof (res
[11])!="undefined"&&res
[11]!==""){
1862 ofs
+=parseInt(res
[11],10)*60000;
1870 return new Date(Date
.UTC(year
,_213
,day
,hour
,min
,sec
,msec
)-ofs
);
1872 MochiKit
.DateTime
.toISOTime
=function(date
,_21b
){
1873 if(typeof (date
)=="undefined"||date
===null){
1876 var hh
=date
.getHours();
1877 var mm
=date
.getMinutes();
1878 var ss
=date
.getSeconds();
1879 var lst
=[((_21b
&&(hh
<10))?"0"+hh
:hh
),((mm
<10)?"0"+mm
:mm
),((ss
<10)?"0"+ss
:ss
)];
1880 return lst
.join(":");
1882 MochiKit
.DateTime
.toISOTimestamp
=function(date
,_221
){
1883 if(typeof (date
)=="undefined"||date
===null){
1886 var sep
=_221
?"T":" ";
1887 var foot
=_221
?"Z":"";
1889 date
=new Date(date
.getTime()+(date
.getTimezoneOffset()*60000));
1891 return MochiKit
.DateTime
.toISODate(date
)+sep
+MochiKit
.DateTime
.toISOTime(date
,_221
)+foot
;
1893 MochiKit
.DateTime
.toISODate
=function(date
){
1894 if(typeof (date
)=="undefined"||date
===null){
1897 var _225
=MochiKit
.DateTime
._padTwo
;
1898 return [date
.getFullYear(),_225(date
.getMonth()+1),_225(date
.getDate())].join("-");
1900 MochiKit
.DateTime
.americanDate
=function(d
){
1902 if(typeof (d
)!="string"||d
.length
===0){
1906 return new Date(a
[2],a
[0]-1,a
[1]);
1908 MochiKit
.DateTime
._padTwo
=function(n
){
1909 return (n
>9)?n
:"0"+n
;
1911 MochiKit
.DateTime
.toPaddedAmericanDate
=function(d
){
1912 if(typeof (d
)=="undefined"||d
===null){
1915 var _22a
=MochiKit
.DateTime
._padTwo
;
1916 return [_22a(d
.getMonth()+1),_22a(d
.getDate()),d
.getFullYear()].join("/");
1918 MochiKit
.DateTime
.toAmericanDate
=function(d
){
1919 if(typeof (d
)=="undefined"||d
===null){
1922 return [d
.getMonth()+1,d
.getDate(),d
.getFullYear()].join("/");
1924 MochiKit
.DateTime
.EXPORT
=["isoDate","isoTimestamp","toISOTime","toISOTimestamp","toISODate","americanDate","toPaddedAmericanDate","toAmericanDate"];
1925 MochiKit
.DateTime
.EXPORT_OK
=[];
1926 MochiKit
.DateTime
.EXPORT_TAGS
={":common":MochiKit
.DateTime
.EXPORT
,":all":MochiKit
.DateTime
.EXPORT
};
1927 MochiKit
.DateTime
.__new__
=function(){
1928 var base
=this.NAME
+".";
1931 if(typeof (o
)=="function"&&typeof (o
.NAME
)=="undefined"){
1940 MochiKit
.DateTime
.__new__();
1941 if(typeof (MochiKit
.Base
)!="undefined"){
1942 MochiKit
.Base
._exportSymbols(this,MochiKit
.DateTime
);
1944 (function(_22f
,_230
){
1945 if((typeof (JSAN
)=="undefined"&&typeof (dojo
)=="undefined")||(MochiKit
.__export__
===false)){
1946 var all
=_230
.EXPORT_TAGS
[":all"];
1947 for(var i
=0;i
<all
.length
;i
++){
1948 _22f
[all
[i
]]=_230
[all
[i
]];
1951 })(this,MochiKit
.DateTime
);
1953 if(typeof (dojo
)!="undefined"){
1954 dojo
.provide("MochiKit.Format");
1956 if(typeof (MochiKit
)=="undefined"){
1959 if(typeof (MochiKit
.Format
)=="undefined"){
1962 MochiKit
.Format
.NAME
="MochiKit.Format";
1963 MochiKit
.Format
.VERSION
="1.4";
1964 MochiKit
.Format
.__repr__
=function(){
1965 return "["+this.NAME
+" "+this.VERSION
+"]";
1967 MochiKit
.Format
.toString
=function(){
1968 return this.__repr__();
1970 MochiKit
.Format
._numberFormatter
=function(_233
,_234
,_235
,_236
,_237
,_238
,_239
,_23a
,_23b
){
1971 return function(num
){
1972 num
=parseFloat(num
);
1973 if(typeof (num
)=="undefined"||num
===null||isNaN(num
)){
1981 _23d
=_23d
.replace(/-/,"");
1983 var me
=arguments
.callee
;
1984 var fmt
=MochiKit
.Format
.formatLocale(_236
);
1987 _23e
=fmt
.percent
+_23e
;
1989 num
=MochiKit
.Format
.roundToFixed(num
,_238
);
1990 var _241
=num
.split(/\./);
1992 var frac
=(_241
.length
==1)?"":_241
[1];
1994 while(_242
.length
<_239
){
1998 while(_242
.length
>_23a
){
1999 var i
=_242
.length
-_23a
;
2000 res
=fmt
.separator
+_242
.substring(i
,_242
.length
)+res
;
2001 _242
=_242
.substring(0,i
);
2006 while(frac
.length
<_23b
){
2009 res
=res
+fmt
.decimal+frac
;
2011 return _23d
+res
+_23e
;
2014 MochiKit
.Format
.numberFormatter
=function(_246
,_247
,_248
){
2015 if(typeof (_247
)=="undefined"){
2018 var _249
=_246
.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);
2020 throw TypeError("Invalid pattern");
2022 var _24a
=_246
.substr(0,_249
.index
);
2023 var _24b
=_246
.substr(_249
.index
+_249
[0].length
);
2024 if(_24a
.search(/-/)==-1){
2028 var frac
=(typeof (_249
[2])=="string"&&_249
[2]!="")?_249
[2]:"";
2029 var _24e
=(typeof (_249
[3])=="string"&&_249
[3]!="");
2030 var tmp
=_24c
.split(/,/);
2032 if(typeof (_248
)=="undefined"){
2040 var _251
=_24c
.length
-_24c
.replace(/0/g,"").length
;
2041 var _252
=frac
.length
-frac
.replace(/0/g,"").length
;
2042 var _253
=frac
.length
;
2043 var rval
=MochiKit
.Format
._numberFormatter(_247
,_24a
,_24b
,_248
,_24e
,_253
,_251
,_250
,_252
);
2044 var m
=MochiKit
.Base
;
2046 var fn
=arguments
.callee
;
2047 var args
=m
.concat(arguments
);
2048 rval
.repr
=function(){
2049 return [self
.NAME
,"(",map(m
.repr
,args
).join(", "),")"].join("");
2054 MochiKit
.Format
.formatLocale
=function(_258
){
2055 if(typeof (_258
)=="undefined"||_258
===null){
2058 if(typeof (_258
)=="string"){
2059 var rval
=MochiKit
.Format
.LOCALE
[_258
];
2060 if(typeof (rval
)=="string"){
2061 rval
=arguments
.callee(rval
);
2062 MochiKit
.Format
.LOCALE
[_258
]=rval
;
2069 MochiKit
.Format
.twoDigitAverage
=function(_25a
,_25b
){
2073 return MochiKit
.Format
.twoDigitFloat(_25a
/_25b
);
2078 MochiKit
.Format
.twoDigitFloat
=function(_25d
){
2079 var sign
=(_25d
<0?"-":"");
2080 var s
=Math
.floor(Math
.abs(_25d
)*100).toString();
2085 while(s
.charAt(s
.length
-1)=="0"){
2086 s
=s
.substring(0,s
.length
-1);
2090 var head
=sign
+s
.substring(0,s
.length
-2);
2091 var tail
=s
.substring(s
.length
-2,s
.length
);
2095 if(tail
.charAt(1)=="0"){
2096 return head
+"."+tail
.charAt(0);
2098 return head
+"."+tail
;
2102 MochiKit
.Format
.lstrip
=function(str
,_263
){
2104 if(typeof (str
)!="string"){
2108 return str
.replace(/^\s+/,"");
2110 return str
.replace(new RegExp("^["+_263
+"]+"),"");
2113 MochiKit
.Format
.rstrip
=function(str
,_265
){
2115 if(typeof (str
)!="string"){
2119 return str
.replace(/\s+$/,"");
2121 return str
.replace(new RegExp("["+_265
+"]+$"),"");
2124 MochiKit
.Format
.strip
=function(str
,_267
){
2125 var self
=MochiKit
.Format
;
2126 return self
.rstrip(self
.lstrip(str
,_267
),_267
);
2128 MochiKit
.Format
.truncToFixed
=function(_269
,_26a
){
2129 _269
=Math
.floor(_269
*Math
.pow(10,_26a
));
2130 var res
=(_269
*Math
.pow(10,-_26a
)).toFixed(_26a
);
2131 if(res
.charAt(0)=="."){
2136 MochiKit
.Format
.roundToFixed
=function(_26c
,_26d
){
2137 return MochiKit
.Format
.truncToFixed(_26c
+0.5*Math
.pow(10,-_26d
),_26d
);
2139 MochiKit
.Format
.percentFormat
=function(_26e
){
2140 return MochiKit
.Format
.twoDigitFloat(100*_26e
)+"%";
2142 MochiKit
.Format
.EXPORT
=["truncToFixed","roundToFixed","numberFormatter","formatLocale","twoDigitAverage","twoDigitFloat","percentFormat","lstrip","rstrip","strip"];
2143 MochiKit
.Format
.LOCALE
={en_US
:{separator
:",",decimal:".",percent
:"%"},de_DE
:{separator
:".",decimal:",",percent
:"%"},fr_FR
:{separator
:" ",decimal:",",percent
:"%"},"default":"en_US"};
2144 MochiKit
.Format
.EXPORT_OK
=[];
2145 MochiKit
.Format
.EXPORT_TAGS
={":all":MochiKit
.Format
.EXPORT
,":common":MochiKit
.Format
.EXPORT
};
2146 MochiKit
.Format
.__new__
=function(){
2147 var base
=this.NAME
+".";
2149 for(k
in this.LOCALE
){
2151 if(typeof (o
)=="object"){
2155 o
.NAME
=base
+"LOCALE."+k
;
2160 if(typeof (o
)=="function"&&typeof (o
.NAME
)=="undefined"){
2169 MochiKit
.Format
.__new__();
2170 if(typeof (MochiKit
.Base
)!="undefined"){
2171 MochiKit
.Base
._exportSymbols(this,MochiKit
.Format
);
2173 (function(_273
,_274
){
2174 if((typeof (JSAN
)=="undefined"&&typeof (dojo
)=="undefined")||(MochiKit
.__export__
===false)){
2175 var all
=_274
.EXPORT_TAGS
[":all"];
2176 for(var i
=0;i
<all
.length
;i
++){
2177 _273
[all
[i
]]=_274
[all
[i
]];
2180 })(this,MochiKit
.Format
);
2182 if(typeof (dojo
)!="undefined"){
2183 dojo
.provide("MochiKit.Async");
2184 dojo
.require("MochiKit.Base");
2186 if(typeof (JSAN
)!="undefined"){
2187 JSAN
.use("MochiKit.Base",[]);
2190 if(typeof (MochiKit
.Base
)=="undefined"){
2195 throw "MochiKit.Async depends on MochiKit.Base!";
2197 if(typeof (MochiKit
.Async
)=="undefined"){
2200 MochiKit
.Async
.NAME
="MochiKit.Async";
2201 MochiKit
.Async
.VERSION
="1.4";
2202 MochiKit
.Async
.__repr__
=function(){
2203 return "["+this.NAME
+" "+this.VERSION
+"]";
2205 MochiKit
.Async
.toString
=function(){
2206 return this.__repr__();
2208 MochiKit
.Async
.Deferred
=function(_277
){
2210 this.id
=this._nextId();
2213 this.results
=[null,null];
2214 this.canceller
=_277
;
2215 this.silentlyCancelled
=false;
2218 MochiKit
.Async
.Deferred
.prototype={repr
:function(){
2229 return "Deferred("+this.id
+", "+_278
+")";
2230 },toString
:MochiKit
.Base
.forwardCall("repr"),_nextId
:MochiKit
.Base
.counter(),cancel
:function(){
2231 var self
=MochiKit
.Async
;
2234 this.canceller(this);
2236 this.silentlyCancelled
=true;
2239 this.errback(new self
.CancelledError(this));
2242 if((this.fired
===0)&&(this.results
[0] instanceof self
.Deferred
)){
2243 this.results
[0].cancel();
2246 },_resback
:function(res
){
2247 this.fired
=((res
instanceof Error
)?1:0);
2248 this.results
[this.fired
]=res
;
2250 },_check
:function(){
2252 if(!this.silentlyCancelled
){
2253 throw new MochiKit
.Async
.AlreadyCalledError(this);
2255 this.silentlyCancelled
=false;
2258 },callback
:function(res
){
2260 if(res
instanceof MochiKit
.Async
.Deferred
){
2261 throw new Error("Deferred instances can only be chained if they are the result of a callback");
2264 },errback
:function(res
){
2266 var self
=MochiKit
.Async
;
2267 if(res
instanceof self
.Deferred
){
2268 throw new Error("Deferred instances can only be chained if they are the result of a callback");
2270 if(!(res
instanceof Error
)){
2271 res
=new self
.GenericError(res
);
2274 },addBoth
:function(fn
){
2275 if(arguments
.length
>1){
2276 fn
=MochiKit
.Base
.partial
.apply(null,arguments
);
2278 return this.addCallbacks(fn
,fn
);
2279 },addCallback
:function(fn
){
2280 if(arguments
.length
>1){
2281 fn
=MochiKit
.Base
.partial
.apply(null,arguments
);
2283 return this.addCallbacks(fn
,null);
2284 },addErrback
:function(fn
){
2285 if(arguments
.length
>1){
2286 fn
=MochiKit
.Base
.partial
.apply(null,arguments
);
2288 return this.addCallbacks(null,fn
);
2289 },addCallbacks
:function(cb
,eb
){
2291 throw new Error("Chained Deferreds can not be re-used");
2293 this.chain
.push([cb
,eb
]);
2299 var _283
=this.chain
;
2300 var _284
=this.fired
;
2301 var res
=this.results
[_284
];
2304 while(_283
.length
>0&&this.paused
===0){
2305 var pair
=_283
.shift();
2312 _284
=((res
instanceof Error
)?1:0);
2313 if(res
instanceof MochiKit
.Async
.Deferred
){
2317 if((self
.paused
===0)&&(self
.fired
>=0)){
2326 if(!(err
instanceof Error
)){
2327 err
=new MochiKit
.Async
.GenericError(err
);
2333 this.results
[_284
]=res
;
2334 if(cb
&&this.paused
){
2339 MochiKit
.Base
.update(MochiKit
.Async
,{evalJSONRequest
:function(){
2340 return eval("("+arguments
[0].responseText
+")");
2341 },succeed
:function(_28b
){
2342 var d
=new MochiKit
.Async
.Deferred();
2343 d
.callback
.apply(d
,arguments
);
2345 },fail
:function(_28d
){
2346 var d
=new MochiKit
.Async
.Deferred();
2347 d
.errback
.apply(d
,arguments
);
2349 },getXMLHttpRequest
:function(){
2350 var self
=arguments
.callee
;
2351 if(!self
.XMLHttpRequest
){
2352 var _290
=[function(){
2353 return new XMLHttpRequest();
2355 return new ActiveXObject("Msxml2.XMLHTTP");
2357 return new ActiveXObject("Microsoft.XMLHTTP");
2359 return new ActiveXObject("Msxml2.XMLHTTP.4.0");
2361 throw new MochiKit
.Async
.BrowserComplianceError("Browser does not support XMLHttpRequest");
2363 for(var i
=0;i
<_290
.length
;i
++){
2366 self
.XMLHttpRequest
=func
;
2373 return self
.XMLHttpRequest();
2374 },_xhr_onreadystatechange
:function(d
){
2375 var m
=MochiKit
.Base
;
2376 if(this.readyState
==4){
2378 this.onreadystatechange
=null;
2382 this.onreadystatechange
=m
.noop
;
2390 if(!_295
&&m
.isNotEmpty(this.responseText
)){
2396 if(_295
==200||_295
==201||_295
==204||_295
==304||_295
==1223){
2399 var err
=new MochiKit
.Async
.XMLHttpRequestError(this,"Request failed");
2407 },_xhr_canceller
:function(req
){
2409 req
.onreadystatechange
=null;
2413 req
.onreadystatechange
=MochiKit
.Base
.noop
;
2419 },sendXMLHttpRequest
:function(req
,_299
){
2420 if(typeof (_299
)=="undefined"||_299
===null){
2423 var m
=MochiKit
.Base
;
2424 var self
=MochiKit
.Async
;
2425 var d
=new self
.Deferred(m
.partial(self
._xhr_canceller
,req
));
2427 req
.onreadystatechange
=m
.bind(self
._xhr_onreadystatechange
,req
,d
);
2432 req
.onreadystatechange
=null;
2439 },doXHR
:function(url
,opts
){
2440 var self
=MochiKit
.Async
;
2441 return self
.callLater(0,self
._doXHR
,url
,opts
);
2442 },_doXHR
:function(url
,opts
){
2443 var m
=MochiKit
.Base
;
2444 opts
=m
.update({method
:"GET",sendContent
:""},opts
);
2445 var self
=MochiKit
.Async
;
2446 var req
=self
.getXMLHttpRequest();
2447 if(opts
.queryString
){
2448 var qs
=m
.queryString(opts
.queryString
);
2453 if("username" in opts
){
2454 req
.open(opts
.method
,url
,true,opts
.username
,opts
.password
);
2456 req
.open(opts
.method
,url
,true);
2458 if(req
.overrideMimeType
&&opts
.mimeType
){
2459 req
.overrideMimeType(opts
.mimeType
);
2462 var _2a6
=opts
.headers
;
2463 if(!m
.isArrayLike(_2a6
)){
2466 for(var i
=0;i
<_2a6
.length
;i
++){
2470 req
.setRequestHeader(name
,_2aa
);
2473 return self
.sendXMLHttpRequest(req
,opts
.sendContent
);
2474 },_buildURL
:function(url
){
2475 if(arguments
.length
>1){
2476 var m
=MochiKit
.Base
;
2477 var qs
=m
.queryString
.apply(null,m
.extend(null,arguments
,1));
2483 },doSimpleXMLHttpRequest
:function(url
){
2484 var self
=MochiKit
.Async
;
2485 url
=self
._buildURL
.apply(self
,arguments
);
2486 return self
.doXHR(url
);
2487 },loadJSONDoc
:function(url
){
2488 var self
=MochiKit
.Async
;
2489 url
=self
._buildURL
.apply(self
,arguments
);
2490 var d
=self
.doXHR(url
,{"mimeType":"text/plain","headers":[["Accept","application/json"]]});
2491 d
=d
.addCallback(self
.evalJSONRequest
);
2493 },wait
:function(_2b3
,_2b4
){
2494 var d
=new MochiKit
.Async
.Deferred();
2495 var m
=MochiKit
.Base
;
2496 if(typeof (_2b4
)!="undefined"){
2497 d
.addCallback(function(){
2501 var _2b7
=setTimeout(m
.bind("callback",d
),Math
.floor(_2b3
*1000));
2502 d
.canceller
=function(){
2510 },callLater
:function(_2b8
,func
){
2511 var m
=MochiKit
.Base
;
2512 var _2bb
=m
.partial
.apply(m
,m
.extend(null,arguments
,1));
2513 return MochiKit
.Async
.wait(_2b8
).addCallback(function(res
){
2517 MochiKit
.Async
.DeferredLock
=function(){
2520 this.id
=this._nextId();
2522 MochiKit
.Async
.DeferredLock
.prototype={__class__
:MochiKit
.Async
.DeferredLock
,acquire
:function(){
2523 var d
=new MochiKit
.Async
.Deferred();
2525 this.waiting
.push(d
);
2531 },release
:function(){
2533 throw TypeError("Tried to release an unlocked DeferredLock");
2536 if(this.waiting
.length
>0){
2538 this.waiting
.shift().callback(this);
2540 },_nextId
:MochiKit
.Base
.counter(),repr
:function(){
2543 _2be
="locked, "+this.waiting
.length
+" waiting";
2547 return "DeferredLock("+this.id
+", "+_2be
+")";
2548 },toString
:MochiKit
.Base
.forwardCall("repr")};
2549 MochiKit
.Async
.DeferredList
=function(list
,_2c0
,_2c1
,_2c2
,_2c3
){
2550 MochiKit
.Async
.Deferred
.apply(this,[_2c3
]);
2553 this.resultList
=_2c4
;
2554 this.finishedCount
=0;
2555 this.fireOnOneCallback
=_2c0
;
2556 this.fireOnOneErrback
=_2c1
;
2557 this.consumeErrors
=_2c2
;
2558 var cb
=MochiKit
.Base
.bind(this._cbDeferred
,this);
2559 for(var i
=0;i
<list
.length
;i
++){
2561 _2c4
.push(undefined
);
2562 d
.addCallback(cb
,i
,true);
2563 d
.addErrback(cb
,i
,false);
2565 if(list
.length
===0&&!_2c0
){
2566 this.callback(this.resultList
);
2569 MochiKit
.Async
.DeferredList
.prototype=new MochiKit
.Async
.Deferred();
2570 MochiKit
.Async
.DeferredList
.prototype._cbDeferred
=function(_2c8
,_2c9
,_2ca
){
2571 this.resultList
[_2c8
]=[_2c9
,_2ca
];
2572 this.finishedCount
+=1;
2574 if(_2c9
&&this.fireOnOneCallback
){
2575 this.callback([_2c8
,_2ca
]);
2577 if(!_2c9
&&this.fireOnOneErrback
){
2580 if(this.finishedCount
==this.list
.length
){
2581 this.callback(this.resultList
);
2586 if(!_2c9
&&this.consumeErrors
){
2591 MochiKit
.Async
.gatherResults
=function(_2cb
){
2592 var d
=new MochiKit
.Async
.DeferredList(_2cb
,false,true,false);
2593 d
.addCallback(function(_2cd
){
2595 for(var i
=0;i
<_2cd
.length
;i
++){
2596 ret
.push(_2cd
[i
][1]);
2602 MochiKit
.Async
.maybeDeferred
=function(func
){
2603 var self
=MochiKit
.Async
;
2606 var r
=func
.apply(null,MochiKit
.Base
.extend([],arguments
,1));
2607 if(r
instanceof self
.Deferred
){
2610 if(r
instanceof Error
){
2613 _2d2
=self
.succeed(r
);
2622 MochiKit
.Async
.EXPORT
=["AlreadyCalledError","CancelledError","BrowserComplianceError","GenericError","XMLHttpRequestError","Deferred","succeed","fail","getXMLHttpRequest","doSimpleXMLHttpRequest","loadJSONDoc","wait","callLater","sendXMLHttpRequest","DeferredLock","DeferredList","gatherResults","maybeDeferred","doXHR"];
2623 MochiKit
.Async
.EXPORT_OK
=["evalJSONRequest"];
2624 MochiKit
.Async
.__new__
=function(){
2625 var m
=MochiKit
.Base
;
2626 var ne
=m
.partial(m
._newNamedError
,this);
2627 ne("AlreadyCalledError",function(_2d6
){
2630 ne("CancelledError",function(_2d7
){
2633 ne("BrowserComplianceError",function(msg
){
2636 ne("GenericError",function(msg
){
2639 ne("XMLHttpRequestError",function(req
,msg
){
2643 this.number
=req
.status
;
2648 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
2649 m
.nameFunctions(this);
2651 MochiKit
.Async
.__new__();
2652 MochiKit
.Base
._exportSymbols(this,MochiKit
.Async
);
2653 if(typeof (dojo
)!="undefined"){
2654 dojo
.provide("MochiKit.DOM");
2655 dojo
.require("MochiKit.Base");
2657 if(typeof (JSAN
)!="undefined"){
2658 JSAN
.use("MochiKit.Base",[]);
2661 if(typeof (MochiKit
.Base
)=="undefined"){
2666 throw "MochiKit.DOM depends on MochiKit.Base!";
2668 if(typeof (MochiKit
.DOM
)=="undefined"){
2671 MochiKit
.DOM
.NAME
="MochiKit.DOM";
2672 MochiKit
.DOM
.VERSION
="1.4";
2673 MochiKit
.DOM
.__repr__
=function(){
2674 return "["+this.NAME
+" "+this.VERSION
+"]";
2676 MochiKit
.DOM
.toString
=function(){
2677 return this.__repr__();
2679 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"];
2680 MochiKit
.DOM
.EXPORT_OK
=["domConverters"];
2681 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"]];
2682 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);");
2683 MochiKit
.Base
.update(MochiKit
.DOM
,{currentWindow
:function(){
2684 return MochiKit
.DOM
._window
;
2685 },currentDocument
:function(){
2686 return MochiKit
.DOM
._document
;
2687 },withWindow
:function(win
,func
){
2688 var self
=MochiKit
.DOM
;
2689 var _2df
=self
._document
;
2690 var _2e0
=self
._window
;
2694 self
._document
=win
.document
;
2699 self
._document
=_2df
;
2703 self
._document
=_2df
;
2705 },formContents
:function(elem
){
2708 var m
=MochiKit
.Base
;
2709 var self
=MochiKit
.DOM
;
2710 if(typeof (elem
)=="undefined"||elem
===null){
2711 elem
=self
._document
.body
;
2713 elem
=self
.getElement(elem
);
2715 m
.nodeWalk(elem
,function(elem
){
2717 if(m
.isNotEmpty(name
)){
2718 var _2e9
=elem
.tagName
.toUpperCase();
2719 if(_2e9
==="INPUT"&&(elem
.type
=="radio"||elem
.type
=="checkbox")&&!elem
.checked
){
2722 if(_2e9
==="SELECT"){
2723 if(elem
.type
=="select-one"){
2724 if(elem
.selectedIndex
>=0){
2725 var opt
=elem
.options
[elem
.selectedIndex
];
2728 var h
=opt
.outerHTML
;
2729 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
2741 var opts
=elem
.options
;
2747 for(var i
=0;i
<opts
.length
;i
++){
2754 var h
=opt
.outerHTML
;
2755 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
2765 if(_2e9
==="FORM"||_2e9
==="P"||_2e9
==="SPAN"||_2e9
==="DIV"){
2766 return elem
.childNodes
;
2769 _2e4
.push(elem
.value
||"");
2772 return elem
.childNodes
;
2775 },withDocument
:function(doc
,func
){
2776 var self
=MochiKit
.DOM
;
2777 var _2f2
=self
._document
;
2784 self
._document
=_2f2
;
2787 self
._document
=_2f2
;
2789 },registerDOMConverter
:function(name
,_2f5
,wrap
,_2f7
){
2790 MochiKit
.DOM
.domConverters
.register(name
,_2f5
,wrap
,_2f7
);
2791 },coerceToDOM
:function(node
,ctx
){
2792 var m
=MochiKit
.Base
;
2793 var im
=MochiKit
.Iter
;
2794 var self
=MochiKit
.DOM
;
2800 var _300
=self
.domConverters
;
2801 var _301
=arguments
.callee
;
2802 var _302
=m
.NotFound
;
2804 if(typeof (node
)=="undefined"||node
===null){
2807 if(typeof (node
)=="function"&&typeof (node
.length
)=="number"&&!(node
instanceof Function
)){
2810 if(typeof (node
.nodeType
)!="undefined"&&node
.nodeType
>0){
2813 if(typeof (node
)=="number"||typeof (node
)=="boolean"){
2814 node
=node
.toString();
2816 if(typeof (node
)=="string"){
2817 return self
._document
.createTextNode(node
);
2819 if(typeof (node
.__dom__
)=="function"){
2820 node
=node
.__dom__(ctx
);
2823 if(typeof (node
.dom
)=="function"){
2827 if(typeof (node
)=="function"){
2828 node
=node
.apply(ctx
,[ctx
]);
2839 return map(_301
,_303
,_2fe(ctx
));
2843 node
=_300
.match(node
,ctx
);
2851 return self
._document
.createTextNode(node
.toString());
2854 },isChildNode
:function(node
,_305
){
2855 var self
=MochiKit
.DOM
;
2856 if(typeof (node
)=="string"){
2857 node
=self
.getElement(node
);
2859 if(typeof (_305
)=="string"){
2860 _305
=self
.getElement(_305
);
2865 while(node
&&node
.tagName
.toUpperCase()!="BODY"){
2866 node
=node
.parentNode
;
2872 },setNodeAttribute
:function(node
,attr
,_309
){
2876 return MochiKit
.DOM
.updateNodeAttributes(node
,o
);
2881 },getNodeAttribute
:function(node
,attr
){
2882 var self
=MochiKit
.DOM
;
2883 var _30e
=self
.attributeArray
.renames
[attr
];
2884 node
=self
.getElement(node
);
2889 return node
.getAttribute(attr
);
2894 },removeNodeAttribute
:function(node
,attr
){
2895 var self
=MochiKit
.DOM
;
2896 var _312
=self
.attributeArray
.renames
[attr
];
2897 node
=self
.getElement(node
);
2902 return node
.removeAttribute(attr
);
2907 },updateNodeAttributes
:function(node
,_314
){
2909 var self
=MochiKit
.DOM
;
2910 if(typeof (node
)=="string"){
2911 elem
=self
.getElement(node
);
2914 var _317
=MochiKit
.Base
.updatetree
;
2915 if(self
.attributeArray
.compliant
){
2918 if(typeof (v
)=="object"&&typeof (elem
[k
])=="object"){
2919 if(k
=="style"&&MochiKit
.Style
){
2920 MochiKit
.Style
.setStyle(elem
,v
);
2925 if(k
.substring(0,2)=="on"){
2926 if(typeof (v
)=="string"){
2931 elem
.setAttribute(k
,v
);
2936 var _31a
=self
.attributeArray
.renames
;
2940 if(k
=="style"&&typeof (v
)=="string"){
2941 elem
.style
.cssText
=v
;
2943 if(typeof (_31b
)=="string"){
2946 if(typeof (elem
[k
])=="object"&&typeof (v
)=="object"){
2947 if(k
=="style"&&MochiKit
.Style
){
2948 MochiKit
.Style
.setStyle(elem
,v
);
2953 if(k
.substring(0,2)=="on"){
2954 if(typeof (v
)=="string"){
2959 elem
.setAttribute(k
,v
);
2968 },appendChildNodes
:function(node
){
2970 var self
=MochiKit
.DOM
;
2971 if(typeof (node
)=="string"){
2972 elem
=self
.getElement(node
);
2974 var _31f
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
2975 var _320
=MochiKit
.Base
.concat
;
2978 if(typeof (n
)=="undefined"||n
===null){
2980 if(typeof (n
.nodeType
)=="number"){
2981 elem
.appendChild(n
);
2988 },insertSiblingNodesBefore
:function(node
){
2990 var self
=MochiKit
.DOM
;
2991 if(typeof (node
)=="string"){
2992 elem
=self
.getElement(node
);
2994 var _325
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
2995 var _326
=elem
.parentNode
;
2996 var _327
=MochiKit
.Base
.concat
;
2999 if(typeof (n
)=="undefined"||n
===null){
3001 if(typeof (n
.nodeType
)=="number"){
3002 _326
.insertBefore(n
,elem
);
3009 },insertSiblingNodesAfter
:function(node
){
3011 var self
=MochiKit
.DOM
;
3012 if(typeof (node
)=="string"){
3013 elem
=self
.getElement(node
);
3015 var _32c
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
3016 if(elem
.nextSibling
){
3017 return self
.insertSiblingNodesBefore(elem
.nextSibling
,_32c
);
3019 return self
.appendChildNodes(elem
.parentNode
,_32c
);
3021 },replaceChildNodes
:function(node
){
3023 var self
=MochiKit
.DOM
;
3024 if(typeof (node
)=="string"){
3025 elem
=self
.getElement(node
);
3029 while((_330
=elem
.firstChild
)){
3030 elem
.removeChild(_330
);
3032 if(arguments
.length
<2){
3035 return self
.appendChildNodes
.apply(this,arguments
);
3037 },createDOM
:function(name
,_332
){
3039 var self
=MochiKit
.DOM
;
3040 var m
=MochiKit
.Base
;
3041 if(typeof (_332
)=="string"||typeof (_332
)=="number"){
3042 var args
=m
.extend([name
,null],arguments
,1);
3043 return arguments
.callee
.apply(this,args
);
3045 if(typeof (name
)=="string"){
3046 var _337
=self
._xhtml
;
3047 if(_332
&&!self
.attributeArray
.compliant
){
3050 _338
+=" name=\""+self
.escapeHTML(_332
.name
)+"\"";
3052 if(name
=="input"&&"type" in _332
){
3053 _338
+=" type=\""+self
.escapeHTML(_332
.type
)+"\"";
3056 name
="<"+name
+_338
+">";
3060 var d
=self
._document
;
3061 if(_337
&&d
===document
){
3062 elem
=d
.createElementNS("http://www.w3.org/1999/xhtml",name
);
3064 elem
=d
.createElement(name
);
3070 self
.updateNodeAttributes(elem
,_332
);
3072 if(arguments
.length
<=2){
3075 var args
=m
.extend([elem
],arguments
,2);
3076 return self
.appendChildNodes
.apply(this,args
);
3078 },createDOMFunc
:function(){
3079 var m
=MochiKit
.Base
;
3080 return m
.partial
.apply(this,m
.extend([MochiKit
.DOM
.createDOM
],arguments
));
3081 },removeElement
:function(elem
){
3082 var e
=MochiKit
.DOM
.getElement(elem
);
3083 e
.parentNode
.removeChild(e
);
3085 },swapDOM
:function(dest
,src
){
3086 var self
=MochiKit
.DOM
;
3087 dest
=self
.getElement(dest
);
3088 var _340
=dest
.parentNode
;
3090 src
=self
.getElement(src
);
3091 _340
.replaceChild(src
,dest
);
3093 _340
.removeChild(dest
);
3096 },getElement
:function(id
){
3097 var self
=MochiKit
.DOM
;
3098 if(arguments
.length
==1){
3099 return ((typeof (id
)=="string")?self
._document
.getElementById(id
):id
);
3101 return MochiKit
.Base
.map(self
.getElement
,arguments
);
3103 },getElementsByTagAndClassName
:function(_343
,_344
,_345
){
3104 var self
=MochiKit
.DOM
;
3105 if(typeof (_343
)=="undefined"||_343
===null){
3108 if(typeof (_345
)=="undefined"||_345
===null){
3109 _345
=self
._document
;
3111 _345
=self
.getElement(_345
);
3112 var _347
=(_345
.getElementsByTagName(_343
)||self
._document
.all
);
3113 if(typeof (_344
)=="undefined"||_344
===null){
3114 return MochiKit
.Base
.extend(null,_347
);
3117 for(var i
=0;i
<_347
.length
;i
++){
3119 var cls
=_34a
.className
;
3123 var _34c
=cls
.split(" ");
3124 for(var j
=0;j
<_34c
.length
;j
++){
3132 },_newCallStack
:function(path
,once
){
3133 var rval
=function(){
3134 var _351
=arguments
.callee
.callStack
;
3135 for(var i
=0;i
<_351
.length
;i
++){
3136 if(_351
[i
].apply(this,arguments
)===false){
3150 },addToCallStack
:function(_353
,path
,func
,once
){
3151 var self
=MochiKit
.DOM
;
3152 var _358
=_353
[path
];
3154 if(!(typeof (_358
)=="function"&&typeof (_358
.callStack
)=="object"&&_358
.callStack
!==null)){
3155 _359
=self
._newCallStack(path
,once
);
3156 if(typeof (_358
)=="function"){
3157 _359
.callStack
.push(_358
);
3161 _359
.callStack
.push(func
);
3162 },addLoadEvent
:function(func
){
3163 var self
=MochiKit
.DOM
;
3164 self
.addToCallStack(self
._window
,"onload",func
,true);
3165 },focusOnLoad
:function(_35c
){
3166 var self
=MochiKit
.DOM
;
3167 self
.addLoadEvent(function(){
3168 _35c
=self
.getElement(_35c
);
3173 },setElementClass
:function(_35e
,_35f
){
3174 var self
=MochiKit
.DOM
;
3175 var obj
=self
.getElement(_35e
);
3176 if(self
.attributeArray
.compliant
){
3177 obj
.setAttribute("class",_35f
);
3179 obj
.setAttribute("className",_35f
);
3181 },toggleElementClass
:function(_362
){
3182 var self
=MochiKit
.DOM
;
3183 for(var i
=1;i
<arguments
.length
;i
++){
3184 var obj
=self
.getElement(arguments
[i
]);
3185 if(!self
.addElementClass(obj
,_362
)){
3186 self
.removeElementClass(obj
,_362
);
3189 },addElementClass
:function(_366
,_367
){
3190 var self
=MochiKit
.DOM
;
3191 var obj
=self
.getElement(_366
);
3192 var cls
=obj
.className
;
3193 if(cls
==undefined
||cls
.length
===0){
3194 self
.setElementClass(obj
,_367
);
3200 var _36b
=cls
.split(" ");
3201 for(var i
=0;i
<_36b
.length
;i
++){
3206 self
.setElementClass(obj
,cls
+" "+_367
);
3208 },removeElementClass
:function(_36d
,_36e
){
3209 var self
=MochiKit
.DOM
;
3210 var obj
=self
.getElement(_36d
);
3211 var cls
=obj
.className
;
3212 if(cls
==undefined
||cls
.length
===0){
3216 self
.setElementClass(obj
,"");
3219 var _372
=cls
.split(" ");
3220 for(var i
=0;i
<_372
.length
;i
++){
3223 self
.setElementClass(obj
,_372
.join(" "));
3228 },swapElementClass
:function(_374
,_375
,_376
){
3229 var obj
=MochiKit
.DOM
.getElement(_374
);
3230 var res
=MochiKit
.DOM
.removeElementClass(obj
,_375
);
3232 MochiKit
.DOM
.addElementClass(obj
,_376
);
3235 },hasElementClass
:function(_379
,_37a
){
3236 var obj
=MochiKit
.DOM
.getElement(_379
);
3237 var cls
=obj
.className
;
3241 var _37d
=cls
.split(" ");
3242 for(var i
=1;i
<arguments
.length
;i
++){
3244 for(var j
=0;j
<_37d
.length
;j
++){
3245 if(_37d
[j
]==arguments
[i
]){
3255 },escapeHTML
:function(s
){
3256 return s
.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");
3257 },toHTML
:function(dom
){
3258 return MochiKit
.DOM
.emitHTML(dom
).join("");
3259 },emitHTML
:function(dom
,lst
){
3260 if(typeof (lst
)=="undefined"||lst
===null){
3264 var self
=MochiKit
.DOM
;
3265 var _387
=self
.escapeHTML
;
3266 var _388
=self
.attributeArray
;
3269 if(typeof (dom
)=="string"){
3272 if(dom
.nodeType
==1){
3273 lst
.push("<"+dom
.tagName
.toLowerCase());
3276 for(var i
=0;i
<_38a
.length
;i
++){
3278 _389
.push([" ",a
.name
,"=\"",_387(a
.value
),"\""]);
3281 for(i
=0;i
<_389
.length
;i
++){
3283 for(var j
=0;j
<_38d
.length
;j
++){
3287 if(dom
.hasChildNodes()){
3289 _385
.push("</"+dom
.tagName
.toLowerCase()+">");
3290 var _38f
=dom
.childNodes
;
3291 for(i
=_38f
.length
-1;i
>=0;i
--){
3298 if(dom
.nodeType
==3){
3299 lst
.push(_387(dom
.nodeValue
));
3305 },scrapeText
:function(node
,_391
){
3308 var cn
=node
.childNodes
;
3310 for(var i
=0;i
<cn
.length
;i
++){
3311 arguments
.callee
.call(this,cn
[i
]);
3314 var _396
=node
.nodeValue
;
3315 if(typeof (_396
)=="string"){
3318 })(MochiKit
.DOM
.getElement(node
));
3322 return rval
.join("");
3324 },removeEmptyTextNodes
:function(_397
){
3325 _397
=MochiKit
.DOM
.getElement(_397
);
3326 for(var i
=0;i
<_397
.childNodes
.length
;i
++){
3327 var node
=_397
.childNodes
[i
];
3328 if(node
.nodeType
==3&&!/\S/.test(node
.nodeValue
)){
3329 node
.parentNode
.removeChild(node
);
3332 },makeClipping
:function(_39a
){
3333 _39a
=MochiKit
.DOM
.getElement(_39a
);
3334 var _39b
=_39a
.style
.overflow
;
3335 if((MochiKit
.Style
.getStyle(_39a
,"overflow")||"visible")!="hidden"){
3336 _39a
.style
.overflow
="hidden";
3339 },undoClipping
:function(_39c
,_39d
){
3340 _39c
=MochiKit
.DOM
.getElement(_39c
);
3344 _39c
.style
.overflow
=_39d
;
3345 },makePositioned
:function(_39e
){
3346 _39e
=MochiKit
.DOM
.getElement(_39e
);
3347 var pos
=MochiKit
.Style
.getStyle(_39e
,"position");
3348 if(pos
=="static"||!pos
){
3349 _39e
.style
.position
="relative";
3350 if(/Opera/.test(navigator
.userAgent
)){
3355 },undoPositioned
:function(_3a0
){
3356 _3a0
=MochiKit
.DOM
.getElement(_3a0
);
3357 if(_3a0
.style
.position
=="relative"){
3358 _3a0
.style
.position
=_3a0
.style
.top
=_3a0
.style
.left
=_3a0
.style
.bottom
=_3a0
.style
.right
="";
3360 },getFirstElementByTagAndClassName
:function(_3a1
,_3a2
,_3a3
){
3361 var self
=MochiKit
.DOM
;
3362 if(typeof (_3a1
)=="undefined"||_3a1
===null){
3365 if(typeof (_3a3
)=="undefined"||_3a3
===null){
3366 _3a3
=self
._document
;
3368 _3a3
=self
.getElement(_3a3
);
3369 var _3a5
=(_3a3
.getElementsByTagName(_3a1
)||self
._document
.all
);
3370 if(typeof (_3a2
)=="undefined"||_3a2
===null){
3373 for(var i
=0;i
<_3a5
.length
;i
++){
3375 var _3a8
=_3a7
.className
.split(" ");
3376 for(var j
=0;j
<_3a8
.length
;j
++){
3382 },getFirstParentByTagAndClassName
:function(elem
,_3ab
,_3ac
){
3383 var self
=MochiKit
.DOM
;
3384 elem
=self
.getElement(elem
);
3385 if(typeof (_3ab
)=="undefined"||_3ab
===null){
3388 _3ab
=_3ab
.toUpperCase();
3390 if(typeof (_3ac
)=="undefined"||_3ac
===null){
3395 while(elem
&&elem
.tagName
){
3396 elem
=elem
.parentNode
;
3397 if(_3ab
=="*"&&_3ac
===null){
3400 _3ae
=elem
.className
.split(" ");
3401 _3af
=elem
.tagName
.toUpperCase();
3402 if(_3ac
===null&&_3ab
==_3af
){
3406 for(var i
=0;i
<_3ae
.length
;i
++){
3407 if(_3ab
=="*"&&_3ae
[i
]==_3ac
){
3410 if(_3ab
==_3af
&&_3ae
[i
]==_3ac
){
3419 },isParent
:function(_3b1
,_3b2
){
3420 if(!_3b1
.parentNode
||_3b1
==_3b2
){
3423 if(_3b1
.parentNode
==_3b2
){
3426 return MochiKit
.DOM
.isParent(_3b1
.parentNode
,_3b2
);
3427 },__new__
:function(win
){
3428 var m
=MochiKit
.Base
;
3429 if(typeof (document
)!="undefined"){
3430 this._document
=document
;
3431 var _3b5
="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
3432 this._xhtml
=(document
.documentElement
&&document
.createElementNS
&&document
.documentElement
.namespaceURI
===_3b5
);
3434 if(MochiKit
.MockDOM
){
3435 this._document
=MochiKit
.MockDOM
.document
;
3439 this.domConverters
=new m
.AdapterRegistry();
3440 var _3b6
=this._document
.createElement("span");
3442 if(_3b6
&&_3b6
.attributes
&&_3b6
.attributes
.length
>0){
3444 _3b7
=function(node
){
3445 return _3b8(_3b7
.ignoreAttrFilter
,node
.attributes
);
3448 var _3ba
=_3b6
.attributes
;
3449 var _3bb
=_3b7
.ignoreAttr
;
3450 for(var i
=0;i
<_3ba
.length
;i
++){
3452 _3bb
[a
.name
]=a
.value
;
3454 _3b7
.ignoreAttrFilter
=function(a
){
3455 return (_3b7
.ignoreAttr
[a
.name
]!=a
.value
);
3457 _3b7
.compliant
=false;
3458 _3b7
.renames
={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"};
3460 _3b7
=function(node
){
3461 return node
.attributes
;
3463 _3b7
.compliant
=true;
3466 this.attributeArray
=_3b7
;
3467 var _3c0
=function(_3c1
,arr
){
3468 var _3c3
=arr
[1].split(".");
3471 str
+="if (!MochiKit."+_3c3
[1]+") { throw new Error(\"";
3472 str
+="This function has been deprecated and depends on MochiKit.";
3473 str
+=_3c3
[1]+".\");}";
3474 str
+="return MochiKit."+_3c3
[1]+"."+arr
[0];
3475 str
+=".apply(this, arguments);";
3476 obj
[_3c3
[2]]=new Function(str
);
3477 MochiKit
.Base
.update(MochiKit
[_3c1
],obj
);
3479 for(var i
;i
<MochiKit
.DOM
.DEPRECATED
.length
;i
++){
3480 _3c0("DOM",MochiKit
.DOM
.DEPRECATED
[i
]);
3482 var _3c6
=this.createDOMFunc
;
3488 this.TBODY
=_3c6("tbody");
3489 this.THEAD
=_3c6("thead");
3490 this.TFOOT
=_3c6("tfoot");
3491 this.TABLE
=_3c6("table");
3493 this.INPUT
=_3c6("input");
3494 this.SPAN
=_3c6("span");
3496 this.DIV
=_3c6("div");
3497 this.IMG
=_3c6("img");
3498 this.BUTTON
=_3c6("button");
3500 this.PRE
=_3c6("pre");
3506 this.LABEL
=_3c6("label");
3507 this.TEXTAREA
=_3c6("textarea");
3508 this.FORM
=_3c6("form");
3510 this.SELECT
=_3c6("select");
3511 this.OPTION
=_3c6("option");
3512 this.OPTGROUP
=_3c6("optgroup");
3513 this.LEGEND
=_3c6("legend");
3514 this.FIELDSET
=_3c6("fieldset");
3515 this.STRONG
=_3c6("strong");
3516 this.CANVAS
=_3c6("canvas");
3517 this.$=this.getElement
;
3518 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
3519 m
.nameFunctions(this);
3521 MochiKit
.DOM
.__new__(((typeof (window
)=="undefined")?this:window
));
3522 if(MochiKit
.__export__
){
3523 withWindow
=MochiKit
.DOM
.withWindow
;
3524 withDocument
=MochiKit
.DOM
.withDocument
;
3526 MochiKit
.Base
._exportSymbols(this,MochiKit
.DOM
);
3527 if(typeof (dojo
)!="undefined"){
3528 dojo
.provide("MochiKit.Selector");
3529 dojo
.require("MochiKit.Base");
3530 dojo
.require("MochiKit.DOM");
3531 dojo
.require("MochiKit.Iter");
3533 if(typeof (JSAN
)!="undefined"){
3534 JSAN
.use("MochiKit.Base",[]);
3535 JSAN
.use("MochiKit.DOM",[]);
3536 JSAN
.use("MochiKit.Iter",[]);
3539 if(typeof (MochiKit
.Base
)==="undefined"||typeof (MochiKit
.DOM
)==="undefined"||typeof (MochiKit
.Iter
)==="undefined"){
3544 throw "MochiKit.Selector depends on MochiKit.Base, MochiKit.DOM and MochiKit.Iter!";
3546 if(typeof (MochiKit
.Selector
)=="undefined"){
3547 MochiKit
.Selector
={};
3549 MochiKit
.Selector
.NAME
="MochiKit.Selector";
3550 MochiKit
.Selector
.VERSION
="1.4";
3551 MochiKit
.Selector
.__repr__
=function(){
3552 return "["+this.NAME
+" "+this.VERSION
+"]";
3554 MochiKit
.Selector
.toString
=function(){
3555 return this.__repr__();
3557 MochiKit
.Selector
.EXPORT
=["Selector","findChildElements","findDocElements","$$"];
3558 MochiKit
.Selector
.EXPORT_OK
=[];
3559 MochiKit
.Selector
.Selector
=function(_3c7
){
3560 this.params
={classNames
:[],pseudoClassNames
:[]};
3561 this.expression
=_3c7
.toString().replace(/(^\s+|\s+$)/g,"");
3562 this.parseExpression();
3563 this.compileMatcher();
3565 MochiKit
.Selector
.Selector
.prototype={__class__
:MochiKit
.Selector
.Selector
,parseExpression
:function(){
3566 function abort(_3c8
){
3567 throw "Parse error in selector: "+_3c8
;
3569 if(this.expression
==""){
3570 abort("empty expression");
3572 var repr
=MochiKit
.Base
.repr
;
3573 var _3ca
=this.params
;
3574 var expr
=this.expression
;
3575 var _3cc
,_3cd
,_3ce
,rest
;
3576 while(_3cc
=expr
.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!^$*]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)){
3577 _3ca
.attributes
=_3ca
.attributes
||[];
3578 _3ca
.attributes
.push({name
:_3cc
[2],operator
:_3cc
[3],value
:_3cc
[4]||_3cc
[5]||""});
3582 return this.params
.wildcard
=true;
3584 while(_3cc
=expr
.match(/^([^a-z0-9_-])?([a-z0-9_-]+(?:\([^)]*\))?)(.*)/i)){
3593 _3ca
.classNames
.push(_3ce
);
3596 _3ca
.pseudoClassNames
.push(_3ce
);
3600 _3ca
.tagName
=_3ce
.toUpperCase();
3610 },buildMatchExpression
:function(){
3611 var repr
=MochiKit
.Base
.repr
;
3612 var _3d1
=this.params
;
3615 function childElements(_3d5
){
3616 return "MochiKit.Base.filter(function (node) { return node.nodeType == 1; }, "+_3d5
+".childNodes)";
3622 _3d2
.push("element.id == "+repr(_3d3
));
3624 if(_3d3
=_3d1
.tagName
){
3625 _3d2
.push("element.tagName.toUpperCase() == "+repr(_3d3
));
3627 if((_3d3
=_3d1
.classNames
).length
>0){
3628 for(i
=0;i
<_3d3
.length
;i
++){
3629 _3d2
.push("MochiKit.DOM.hasElementClass(element, "+repr(_3d3
[i
])+")");
3632 if((_3d3
=_3d1
.pseudoClassNames
).length
>0){
3633 for(i
=0;i
<_3d3
.length
;i
++){
3634 var _3d6
=_3d3
[i
].match(/^([^(]+)(?:\((.*)\))?$/);
3639 _3d2
.push("element.nodeType == 9 || element === element.ownerDocument.documentElement");
3642 case "nth-last-child":
3644 case "nth-last-of-type":
3645 _3d6
=_3d8
.match(/^((?:(\d+)n\+)?(\d+)|odd|even)$/);
3647 throw "Invalid argument to pseudo element nth-child: "+_3d8
;
3654 if(_3d6
[0]=="even"){
3658 a
=_3d6
[2]&&parseInt(_3d6
)||null;
3659 b
=parseInt(_3d6
[3]);
3662 _3d2
.push("this.nthChild(element,"+a
+","+b
+","+!!_3d7
.match("^nth-last")+","+!!_3d7
.match("of-type$")+")");
3665 _3d2
.push("this.nthChild(element, null, 1)");
3668 _3d2
.push("this.nthChild(element, null, 1, true)");
3670 case "first-of-type":
3671 _3d2
.push("this.nthChild(element, null, 1, false, true)");
3673 case "last-of-type":
3674 _3d2
.push("this.nthChild(element, null, 1, true, true)");
3677 _3d2
.push(childElements("element.parentNode")+".length == 1");
3679 case "only-of-type":
3680 _3d2
.push("MochiKit.Base.filter(function (node) { return node.tagName == element.tagName; }, "+childElements("element.parentNode")+").length == 1");
3683 _3d2
.push("element.childNodes.length == 0");
3686 _3d2
.push("(this.isUIElement(element) && element.disabled === false)");
3689 _3d2
.push("(this.isUIElement(element) && element.disabled === true)");
3692 _3d2
.push("(this.isUIElement(element) && element.checked === true)");
3695 var _3db
=new MochiKit
.Selector
.Selector(_3d8
);
3696 _3d2
.push("!( "+_3db
.buildMatchExpression()+")");
3701 if(_3d3
=_3d1
.attributes
){
3702 MochiKit
.Base
.map(function(_3dc
){
3703 var _3dd
="MochiKit.DOM.getNodeAttribute(element, "+repr(_3dc
.name
)+")";
3704 var _3de
=function(_3df
){
3705 return _3dd
+".split("+repr(_3df
)+")";
3707 switch(_3dc
.operator
){
3709 _3d2
.push(_3dd
+" == "+repr(_3dc
.value
));
3712 _3d2
.push(_3dd
+" && MochiKit.Base.findValue("+_3de(" ")+", "+repr(_3dc
.value
)+") > -1");
3715 _3d2
.push(_3dd
+".substring(0, "+_3dc
.value
.length
+") == "+repr(_3dc
.value
));
3718 _3d2
.push(_3dd
+".substring("+_3dd
+".length - "+_3dc
.value
.length
+") == "+repr(_3dc
.value
));
3721 _3d2
.push(_3dd
+".match("+repr(_3dc
.value
)+")");
3724 _3d2
.push(_3dd
+" && "+_3de("-")+"[0].toUpperCase() == "+repr(_3dc
.value
.toUpperCase()));
3727 _3d2
.push(_3dd
+" != "+repr(_3dc
.value
));
3731 _3d2
.push(_3dd
+" != null");
3734 throw "Unknown operator "+_3dc
.operator
+" in selector";
3738 return _3d2
.join(" && ");
3739 },compileMatcher
:function(){
3740 this.match
=new Function("element","if (!element.tagName) return false; return "+this.buildMatchExpression());
3741 },nthChild
:function(_3e0
,a
,b
,_3e3
,_3e4
){
3742 var _3e5
=MochiKit
.Base
.filter(function(node
){
3743 return node
.nodeType
==1;
3744 },_3e0
.parentNode
.childNodes
);
3746 _3e5
=MochiKit
.Base
.filter(function(node
){
3747 return node
.tagName
==_3e0
.tagName
;
3751 _3e5
=MochiKit
.Iter
.reversed(_3e5
);
3754 var _3e8
=MochiKit
.Base
.findIdentical(_3e5
,_3e0
);
3755 return ((_3e8
+1-b
)/a
)%1==0;
3757 return b
==MochiKit
.Base
.findIdentical(_3e5
,_3e0
)+1;
3759 },isUIElement
:function(_3e9
){
3760 return MochiKit
.Base
.findValue(["input","button","select","option","textarea","object"],_3e9
.tagName
.toLowerCase())>-1;
3761 },findElements
:function(_3ea
,axis
){
3763 if(axis
==undefined
){
3766 function inScope(_3ed
,_3ee
){
3768 return MochiKit
.DOM
.isChildNode(_3ed
,_3ee
);
3771 return _3ed
.parentNode
==_3ee
;
3774 return _3ed
==nextSiblingElement(_3ee
);
3778 while(_3ef
=nextSiblingElement(_3ef
)){
3785 throw "Invalid axis: "+axis
;
3791 if(_3ec
=MochiKit
.DOM
.getElement(this.params
.id
)){
3792 if(this.match(_3ec
)){
3793 if(!_3ea
||inScope(_3ec
,_3ea
)){
3798 function nextSiblingElement(node
){
3799 node
=node
.nextSibling
;
3800 while(node
&&node
.nodeType
!=1){
3801 node
=node
.nextSibling
;
3806 _3ea
=(_3ea
||MochiKit
.DOM
.currentDocument()).getElementsByTagName(this.params
.tagName
||"*");
3810 throw "> combinator not allowed without preceeding expression";
3812 _3ea
=MochiKit
.Base
.filter(function(node
){
3813 return node
.nodeType
==1;
3818 throw "+ combinator not allowed without preceeding expression";
3820 _3ea
=nextSiblingElement(_3ea
)&&[nextSiblingElement(_3ea
)];
3824 throw "~ combinator not allowed without preceeding expression";
3827 while(nextSiblingElement(_3ea
)){
3828 _3ea
=nextSiblingElement(_3ea
);
3839 var _3f3
=MochiKit
.Base
.filter(MochiKit
.Base
.bind(function(_3f4
){
3840 return this.match(_3f4
);
3844 return "Selector("+this.expression
+")";
3845 },toString
:MochiKit
.Base
.forwardCall("repr")};
3846 MochiKit
.Base
.update(MochiKit
.Selector
,{findChildElements
:function(_3f5
,_3f6
){
3847 return MochiKit
.Base
.flattenArray(MochiKit
.Base
.map(function(_3f7
){
3849 return MochiKit
.Iter
.reduce(function(_3f9
,expr
){
3850 if(match
=expr
.match(/^[>+~]$/)){
3854 var _3fb
=new MochiKit
.Selector
.Selector(expr
);
3855 var _3fc
=MochiKit
.Iter
.reduce(function(_3fd
,_3fe
){
3856 return MochiKit
.Base
.extend(_3fd
,_3fb
.findElements(_3fe
||_3f5
,_3f8
));
3861 },_3f7
.replace(/(^\s+|\s+$)/g,"").split(/\s+/),[null]);
3863 },findDocElements
:function(){
3864 return MochiKit
.Selector
.findChildElements(MochiKit
.DOM
.currentDocument(),arguments
);
3865 },__new__
:function(){
3866 var m
=MochiKit
.Base
;
3867 this.$$=this.findDocElements
;
3868 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
3869 m
.nameFunctions(this);
3871 MochiKit
.Selector
.__new__();
3872 MochiKit
.Base
._exportSymbols(this,MochiKit
.Selector
);
3873 if(typeof (dojo
)!="undefined"){
3874 dojo
.provide("MochiKit.Style");
3875 dojo
.require("MochiKit.Base");
3876 dojo
.require("MochiKit.DOM");
3878 if(typeof (JSAN
)!="undefined"){
3879 JSAN
.use("MochiKit.Base",[]);
3880 JSAN
.use("MochiKit.DOM",[]);
3883 if(typeof (MochiKit
.Base
)=="undefined"){
3888 throw "MochiKit.Style depends on MochiKit.Base!";
3891 if(typeof (MochiKit
.DOM
)=="undefined"){
3896 throw "MochiKit.Style depends on MochiKit.DOM!";
3898 if(typeof (MochiKit
.Style
)=="undefined"){
3901 MochiKit
.Style
.NAME
="MochiKit.Style";
3902 MochiKit
.Style
.VERSION
="1.4";
3903 MochiKit
.Style
.__repr__
=function(){
3904 return "["+this.NAME
+" "+this.VERSION
+"]";
3906 MochiKit
.Style
.toString
=function(){
3907 return this.__repr__();
3909 MochiKit
.Style
.EXPORT_OK
=[];
3910 MochiKit
.Style
.EXPORT
=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
3911 MochiKit
.Style
.Dimensions
=function(w
,h
){
3915 MochiKit
.Style
.Dimensions
.prototype.__repr__
=function(){
3916 var repr
=MochiKit
.Base
.repr
;
3917 return "{w: "+repr(this.w
)+", h: "+repr(this.h
)+"}";
3919 MochiKit
.Style
.Dimensions
.prototype.toString
=function(){
3920 return this.__repr__();
3922 MochiKit
.Style
.Coordinates
=function(x
,y
){
3926 MochiKit
.Style
.Coordinates
.prototype.__repr__
=function(){
3927 var repr
=MochiKit
.Base
.repr
;
3928 return "{x: "+repr(this.x
)+", y: "+repr(this.y
)+"}";
3930 MochiKit
.Style
.Coordinates
.prototype.toString
=function(){
3931 return this.__repr__();
3933 MochiKit
.Base
.update(MochiKit
.Style
,{getStyle
:function(elem
,_407
){
3934 var dom
=MochiKit
.DOM
;
3935 var d
=dom
._document
;
3936 elem
=dom
.getElement(elem
);
3937 _407
=MochiKit
.Base
.camelize(_407
);
3941 if(_407
=="opacity"&&elem
.filters
){
3942 var _40a
=(MochiKit
.Style
.getStyle(elem
,"filter")||"").match(/alpha\(opacity=(.*)\)/);
3944 return parseFloat(_40a
[1])/100;
3948 var _40b
=elem
.style
?elem
.style
[_407
]:null;
3950 if(d
.defaultView
&&d
.defaultView
.getComputedStyle
){
3951 var css
=d
.defaultView
.getComputedStyle(elem
,null);
3952 _407
=_407
.replace(/([A-Z])/g,"-$1").toLowerCase();
3953 _40b
=css
?css
.getPropertyValue(_407
):null;
3955 if(elem
.currentStyle
){
3956 _40b
=elem
.currentStyle
[_407
];
3960 if(_407
=="opacity"){
3961 _40b
=parseFloat(_40b
);
3963 if(/Opera/.test(navigator
.userAgent
)&&(MochiKit
.Base
.find(["left","top","right","bottom"],_407
)!=-1)){
3964 if(MochiKit
.Style
.getStyle(elem
,"position")=="static"){
3968 return _40b
=="auto"?null:_40b
;
3969 },setStyle
:function(elem
,_40e
){
3970 elem
=MochiKit
.DOM
.getElement(elem
);
3971 for(var name
in _40e
){
3972 if(name
=="opacity"){
3973 MochiKit
.Style
.setOpacity(elem
,_40e
[name
]);
3975 elem
.style
[MochiKit
.Base
.camelize(name
)]=_40e
[name
];
3978 },setOpacity
:function(elem
,o
){
3979 elem
=MochiKit
.DOM
.getElement(elem
);
3980 var self
=MochiKit
.Style
;
3982 var _413
=/Gecko/.test(navigator
.userAgent
)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator
.userAgent
));
3983 elem
.style
["opacity"]=_413
?0.999999:1;
3984 if(/MSIE/.test(navigator
.userAgent
)){
3985 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"");
3991 elem
.style
["opacity"]=o
;
3992 if(/MSIE/.test(navigator
.userAgent
)){
3993 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o
*100+")";
3996 },getElementPosition
:function(elem
,_415
){
3997 var self
=MochiKit
.Style
;
3998 var dom
=MochiKit
.DOM
;
3999 elem
=dom
.getElement(elem
);
4000 if(!elem
||(!(elem
.x
&&elem
.y
)&&(!elem
.parentNode
===null||self
.getStyle(elem
,"display")=="none"))){
4003 var c
=new self
.Coordinates(0,0);
4006 var d
=MochiKit
.DOM
._document
;
4007 var de
=d
.documentElement
;
4009 if(!elem
.parentNode
&&elem
.x
&&elem
.y
){
4013 if(elem
.getBoundingClientRect
){
4014 box
=elem
.getBoundingClientRect();
4015 c
.x
+=box
.left
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
4016 c
.y
+=box
.top
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
4018 if(elem
.offsetParent
){
4019 c
.x
+=elem
.offsetLeft
;
4020 c
.y
+=elem
.offsetTop
;
4021 _41a
=elem
.offsetParent
;
4024 c
.x
+=_41a
.offsetLeft
;
4025 c
.y
+=_41a
.offsetTop
;
4026 _41a
=_41a
.offsetParent
;
4029 var ua
=navigator
.userAgent
.toLowerCase();
4030 if((typeof (opera
)!="undefined"&&parseFloat(opera
.version())<9)||(ua
.indexOf("AppleWebKit")!=-1&&self
.getStyle(elem
,"position")=="absolute")){
4037 if(typeof (_415
)!="undefined"){
4038 _415
=arguments
.callee(_415
);
4044 if(elem
.parentNode
){
4045 _41a
=elem
.parentNode
;
4050 var _41f
=_41a
.tagName
.toUpperCase();
4051 if(_41f
==="BODY"||_41f
==="HTML"){
4054 var disp
=self
.getStyle(_41a
,"display");
4055 if(disp
!="inline"&&disp
!="table-row"){
4056 c
.x
-=_41a
.scrollLeft
;
4057 c
.y
-=_41a
.scrollTop
;
4059 if(_41a
.parentNode
){
4060 _41a
=_41a
.parentNode
;
4066 },setElementPosition
:function(elem
,_422
,_423
){
4067 elem
=MochiKit
.DOM
.getElement(elem
);
4068 if(typeof (_423
)=="undefined"){
4072 var _425
=MochiKit
.Base
.isUndefinedOrNull
;
4074 _424
["left"]=_422
.x
+_423
;
4077 _424
["top"]=_422
.y
+_423
;
4079 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_424
});
4080 },getElementDimensions
:function(elem
){
4081 var self
=MochiKit
.Style
;
4082 var dom
=MochiKit
.DOM
;
4083 if(typeof (elem
.w
)=="number"||typeof (elem
.h
)=="number"){
4084 return new self
.Dimensions(elem
.w
||0,elem
.h
||0);
4086 elem
=dom
.getElement(elem
);
4090 var disp
=self
.getStyle(elem
,"display");
4091 if(disp
!="none"&&disp
!==""&&typeof (disp
)!="undefined"){
4092 return new self
.Dimensions(elem
.offsetWidth
||0,elem
.offsetHeight
||0);
4095 var _42b
=s
.visibility
;
4096 var _42c
=s
.position
;
4097 s
.visibility
="hidden";
4098 s
.position
="absolute";
4100 var _42d
=elem
.offsetWidth
;
4101 var _42e
=elem
.offsetHeight
;
4105 return new self
.Dimensions(_42d
,_42e
);
4106 },setElementDimensions
:function(elem
,_430
,_431
){
4107 elem
=MochiKit
.DOM
.getElement(elem
);
4108 if(typeof (_431
)=="undefined"){
4112 var _433
=MochiKit
.Base
.isUndefinedOrNull
;
4114 _432
["width"]=_430
.w
+_431
;
4117 _432
["height"]=_430
.h
+_431
;
4119 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_432
});
4120 },setDisplayForElement
:function(_434
,_435
){
4121 var _436
=MochiKit
.Base
.extend(null,arguments
,1);
4122 var _437
=MochiKit
.DOM
.getElement
;
4123 for(var i
=0;i
<_436
.length
;i
++){
4126 _435
.style
.display
=_434
;
4129 },getViewportDimensions
:function(){
4130 var d
=new MochiKit
.Style
.Dimensions();
4131 var w
=MochiKit
.DOM
._window
;
4132 var b
=MochiKit
.DOM
._document
.body
;
4137 if(b
.parentElement
.clientWidth
){
4138 d
.w
=b
.parentElement
.clientWidth
;
4139 d
.h
=b
.parentElement
.clientHeight
;
4141 if(b
&&b
.clientWidth
){
4148 },getViewportPosition
:function(){
4149 var c
=new MochiKit
.Style
.Coordinates(0,0);
4150 var d
=MochiKit
.DOM
._document
;
4151 var de
=d
.documentElement
;
4153 if(de
&&(de
.scrollTop
||de
.scrollLeft
)){
4163 },__new__
:function(){
4164 var m
=MochiKit
.Base
;
4165 this.elementPosition
=this.getElementPosition
;
4166 this.elementDimensions
=this.getElementDimensions
;
4167 this.hideElement
=m
.partial(this.setDisplayForElement
,"none");
4168 this.showElement
=m
.partial(this.setDisplayForElement
,"block");
4169 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
4170 m
.nameFunctions(this);
4172 MochiKit
.Style
.__new__();
4173 MochiKit
.Base
._exportSymbols(this,MochiKit
.Style
);
4174 if(typeof (dojo
)!="undefined"){
4175 dojo
.provide("MochiKit.LoggingPane");
4176 dojo
.require("MochiKit.Logging");
4177 dojo
.require("MochiKit.Base");
4179 if(typeof (JSAN
)!="undefined"){
4180 JSAN
.use("MochiKit.Logging",[]);
4181 JSAN
.use("MochiKit.Base",[]);
4184 if(typeof (MochiKit
.Base
)=="undefined"||typeof (MochiKit
.Logging
)=="undefined"){
4189 throw "MochiKit.LoggingPane depends on MochiKit.Base and MochiKit.Logging!";
4191 if(typeof (MochiKit
.LoggingPane
)=="undefined"){
4192 MochiKit
.LoggingPane
={};
4194 MochiKit
.LoggingPane
.NAME
="MochiKit.LoggingPane";
4195 MochiKit
.LoggingPane
.VERSION
="1.4";
4196 MochiKit
.LoggingPane
.__repr__
=function(){
4197 return "["+this.NAME
+" "+this.VERSION
+"]";
4199 MochiKit
.LoggingPane
.toString
=function(){
4200 return this.__repr__();
4202 MochiKit
.LoggingPane
.createLoggingPane
=function(_441
){
4203 var m
=MochiKit
.LoggingPane
;
4205 if(m
._loggingPane
&&m
._loggingPane
.inline
!=_441
){
4206 m
._loggingPane
.closePane();
4207 m
._loggingPane
=null;
4209 if(!m
._loggingPane
||m
._loggingPane
.closed
){
4210 m
._loggingPane
=new m
.LoggingPane(_441
,MochiKit
.Logging
.logger
);
4212 return m
._loggingPane
;
4214 MochiKit
.LoggingPane
.LoggingPane
=function(_443
,_444
){
4215 if(typeof (_444
)=="undefined"||_444
===null){
4216 _444
=MochiKit
.Logging
.logger
;
4219 var _445
=MochiKit
.Base
.update
;
4220 var _446
=MochiKit
.Base
.updatetree
;
4221 var bind
=MochiKit
.Base
.bind
;
4222 var _448
=MochiKit
.Base
.clone
;
4224 var uid
="_MochiKit_LoggingPane";
4225 if(typeof (MochiKit
.DOM
)!="undefined"){
4226 win
=MochiKit
.DOM
.currentWindow();
4229 var url
=win
.location
.href
.split("?")[0].replace(/[#:\/.><&-]/g
,"_");
4230 var name
=uid
+"_"+url
;
4231 var nwin
=win
.open("",name
,"dependent,resizable,height=200");
4233 alert("Not able to open debugging window due to pop-up blocking.");
4236 nwin
.document
.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" "+"\"http://www.w3.org/TR/html4/loose.dtd\">"+"<html><head><title>[MochiKit.LoggingPane]</title></head>"+"<body></body></html>");
4237 nwin
.document
.close();
4238 nwin
.document
.title
+=" "+win
.document
.title
;
4241 var doc
=win
.document
;
4243 var _44f
=doc
.getElementById(uid
);
4245 if(_44f
&&typeof (_44f
.loggingPane
)!="undefined"){
4246 _44f
.loggingPane
.logger
=this.logger
;
4247 _44f
.loggingPane
.buildAndApplyFilter();
4248 return _44f
.loggingPane
;
4252 while((_451
=_44f
.firstChild
)){
4253 _44f
.removeChild(_451
);
4256 _44f
=doc
.createElement("div");
4259 _44f
.loggingPane
=this;
4260 var _452
=doc
.createElement("input");
4261 var _453
=doc
.createElement("input");
4262 var _454
=doc
.createElement("button");
4263 var _455
=doc
.createElement("button");
4264 var _456
=doc
.createElement("button");
4265 var _457
=doc
.createElement("button");
4266 var _458
=doc
.createElement("div");
4267 var _459
=doc
.createElement("div");
4268 var _45a
=uid
+"_Listener";
4269 this.colorTable
=_448(this.colorTable
);
4272 var _45d
=function(msg
){
4274 if(typeof (_45f
)=="number"){
4275 _45f
=MochiKit
.Logging
.LogLevel
[_45f
];
4279 var _460
=function(msg
){
4280 return msg
.info
.join(" ");
4282 var _462
=bind(function(msg
){
4285 var c
=this.colorTable
[_464
];
4286 var p
=doc
.createElement("span");
4287 p
.className
="MochiKit-LogMessage MochiKit-LogLevel-"+_464
;
4288 p
.style
.cssText
="margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: "+c
;
4289 p
.appendChild(doc
.createTextNode(_464
+": "+text
));
4290 _459
.appendChild(p
);
4291 _459
.appendChild(doc
.createElement("br"));
4292 if(_458
.offsetHeight
>_458
.scrollHeight
){
4295 _458
.scrollTop
=_458
.scrollHeight
;
4298 var _468
=function(msg
){
4299 _45b
[_45b
.length
]=msg
;
4302 var _46a
=function(){
4305 _46b
=new RegExp(_452
.value
);
4306 _46c
=new RegExp(_453
.value
);
4309 logDebug("Error in filter regex: "+e
.message
);
4312 return function(msg
){
4313 return (_46b
.test(_45d(msg
))&&_46c
.test(_460(msg
)));
4316 var _46e
=function(){
4317 while(_459
.firstChild
){
4318 _459
.removeChild(_459
.firstChild
);
4321 var _46f
=function(){
4325 var _470
=bind(function(){
4330 if(MochiKit
.LoggingPane
._loggingPane
==this){
4331 MochiKit
.LoggingPane
._loggingPane
=null;
4333 this.logger
.removeListener(_45a
);
4336 _44f
.loggingPane
=null;
4339 logFatal("Bookmarklet was closed incorrectly.");
4342 _44f
.parentNode
.removeChild(_44f
);
4350 var _471
=function(){
4352 for(var i
=0;i
<_45b
.length
;i
++){
4354 if(_45c
===null||_45c(msg
)){
4359 this.buildAndApplyFilter
=function(){
4362 this.logger
.removeListener(_45a
);
4363 this.logger
.addListener(_45a
,_45c
,_468
);
4365 var _474
=bind(function(){
4366 _45b
=this.logger
.getMessages();
4369 var _475
=bind(function(_476
){
4370 _476
=_476
||window
.event
;
4371 key
=_476
.which
||_476
.keyCode
;
4373 this.buildAndApplyFilter();
4376 var _477
="display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: "+this.logFont
;
4378 _477
+="; height: 10em; border-top: 2px solid black";
4380 _477
+="; height: 100%;";
4382 _44f
.style
.cssText
=_477
;
4384 doc
.body
.appendChild(_44f
);
4386 _477
={"cssText":"width: 33%; display: inline; font: "+this.logFont
};
4387 _446(_452
,{"value":"FATAL|ERROR|WARNING|INFO|DEBUG","onkeypress":_475
,"style":_477
});
4388 _44f
.appendChild(_452
);
4389 _446(_453
,{"value":".*","onkeypress":_475
,"style":_477
});
4390 _44f
.appendChild(_453
);
4391 _477
="width: 8%; display:inline; font: "+this.logFont
;
4392 _454
.appendChild(doc
.createTextNode("Filter"));
4393 _454
.onclick
=bind("buildAndApplyFilter",this);
4394 _454
.style
.cssText
=_477
;
4395 _44f
.appendChild(_454
);
4396 _455
.appendChild(doc
.createTextNode("Load"));
4398 _455
.style
.cssText
=_477
;
4399 _44f
.appendChild(_455
);
4400 _456
.appendChild(doc
.createTextNode("Clear"));
4402 _456
.style
.cssText
=_477
;
4403 _44f
.appendChild(_456
);
4404 _457
.appendChild(doc
.createTextNode("Close"));
4406 _457
.style
.cssText
=_477
;
4407 _44f
.appendChild(_457
);
4408 _458
.style
.cssText
="overflow: auto; width: 100%";
4409 _459
.style
.cssText
="width: 100%; height: "+(_443
?"8em":"100%");
4410 _458
.appendChild(_459
);
4411 _44f
.appendChild(_458
);
4412 this.buildAndApplyFilter();
4420 this.closePane
=_470
;
4424 MochiKit
.LoggingPane
.LoggingPane
.prototype={"logFont":"8pt Verdana,sans-serif","colorTable":{"ERROR":"red","FATAL":"darkred","WARNING":"blue","INFO":"black","DEBUG":"green"}};
4425 MochiKit
.LoggingPane
.EXPORT_OK
=["LoggingPane"];
4426 MochiKit
.LoggingPane
.EXPORT
=["createLoggingPane"];
4427 MochiKit
.LoggingPane
.__new__
=function(){
4428 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":MochiKit
.Base
.concat(this.EXPORT
,this.EXPORT_OK
)};
4429 MochiKit
.Base
.nameFunctions(this);
4430 MochiKit
.LoggingPane
._loggingPane
=null;
4432 MochiKit
.LoggingPane
.__new__();
4433 MochiKit
.Base
._exportSymbols(this,MochiKit
.LoggingPane
);
4434 if(typeof (dojo
)!="undefined"){
4435 dojo
.provide("MochiKit.Color");
4436 dojo
.require("MochiKit.Base");
4437 dojo
.require("MochiKit.DOM");
4438 dojo
.require("MochiKit.Style");
4440 if(typeof (JSAN
)!="undefined"){
4441 JSAN
.use("MochiKit.Base",[]);
4442 JSAN
.use("MochiKit.DOM",[]);
4443 JSAN
.use("MochiKit.Style",[]);
4446 if(typeof (MochiKit
.Base
)=="undefined"){
4451 throw "MochiKit.Color depends on MochiKit.Base";
4454 if(typeof (MochiKit
.DOM
)=="undefined"){
4459 throw "MochiKit.Color depends on MochiKit.DOM";
4462 if(typeof (MochiKit
.Style
)=="undefined"){
4467 throw "MochiKit.Color depends on MochiKit.Style";
4469 if(typeof (MochiKit
.Color
)=="undefined"){
4472 MochiKit
.Color
.NAME
="MochiKit.Color";
4473 MochiKit
.Color
.VERSION
="1.4";
4474 MochiKit
.Color
.__repr__
=function(){
4475 return "["+this.NAME
+" "+this.VERSION
+"]";
4477 MochiKit
.Color
.toString
=function(){
4478 return this.__repr__();
4480 MochiKit
.Color
.Color
=function(red
,_479
,blue
,_47b
){
4481 if(typeof (_47b
)=="undefined"||_47b
===null){
4484 this.rgb
={r
:red
,g
:_479
,b
:blue
,a
:_47b
};
4486 MochiKit
.Color
.Color
.prototype={__class__
:MochiKit
.Color
.Color
,colorWithAlpha
:function(_47c
){
4488 var m
=MochiKit
.Color
;
4489 return m
.Color
.fromRGB(rgb
.r
,rgb
.g
,rgb
.b
,_47c
);
4490 },colorWithHue
:function(hue
){
4491 var hsl
=this.asHSL();
4493 var m
=MochiKit
.Color
;
4494 return m
.Color
.fromHSL(hsl
);
4495 },colorWithSaturation
:function(_482
){
4496 var hsl
=this.asHSL();
4498 var m
=MochiKit
.Color
;
4499 return m
.Color
.fromHSL(hsl
);
4500 },colorWithLightness
:function(_485
){
4501 var hsl
=this.asHSL();
4503 var m
=MochiKit
.Color
;
4504 return m
.Color
.fromHSL(hsl
);
4505 },darkerColorWithLevel
:function(_488
){
4506 var hsl
=this.asHSL();
4507 hsl
.l
=Math
.max(hsl
.l
-_488
,0);
4508 var m
=MochiKit
.Color
;
4509 return m
.Color
.fromHSL(hsl
);
4510 },lighterColorWithLevel
:function(_48b
){
4511 var hsl
=this.asHSL();
4512 hsl
.l
=Math
.min(hsl
.l
+_48b
,1);
4513 var m
=MochiKit
.Color
;
4514 return m
.Color
.fromHSL(hsl
);
4515 },blendedColor
:function(_48e
,_48f
){
4516 if(typeof (_48f
)=="undefined"||_48f
===null){
4523 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
));
4524 },compareRGB
:function(_494
){
4527 return MochiKit
.Base
.compare([a
.r
,a
.g
,a
.b
,a
.a
],[b
.r
,b
.g
,b
.b
,b
.a
]);
4528 },isLight
:function(){
4529 return this.asHSL().b
>0.5;
4530 },isDark
:function(){
4531 return (!this.isLight());
4532 },toHSLString
:function(){
4534 var ccc
=MochiKit
.Color
.clampColorComponent
;
4535 var rval
=this._hslString
;
4537 var mid
=(ccc(c
.h
,360).toFixed(0)+","+ccc(c
.s
,100).toPrecision(4)+"%"+","+ccc(c
.l
,100).toPrecision(4)+"%");
4541 rval
="hsl("+mid
+")";
4546 rval
="hsla("+mid
+","+a
+")";
4548 this._hslString
=rval
;
4551 },toRGBString
:function(){
4553 var ccc
=MochiKit
.Color
.clampColorComponent
;
4554 var rval
=this._rgbString
;
4556 var mid
=(ccc(c
.r
,255).toFixed(0)+","+ccc(c
.g
,255).toFixed(0)+","+ccc(c
.b
,255).toFixed(0));
4558 rval
="rgba("+mid
+","+c
.a
+")";
4560 rval
="rgb("+mid
+")";
4562 this._rgbString
=rval
;
4566 return MochiKit
.Base
.clone(this.rgb
);
4567 },toHexString
:function(){
4568 var m
=MochiKit
.Color
;
4570 var ccc
=MochiKit
.Color
.clampColorComponent
;
4571 var rval
=this._hexString
;
4573 rval
=("#"+m
.toColorPart(ccc(c
.r
,255))+m
.toColorPart(ccc(c
.g
,255))+m
.toColorPart(ccc(c
.b
,255)));
4574 this._hexString
=rval
;
4580 if(typeof (hsv
)=="undefined"||hsv
===null){
4581 hsv
=MochiKit
.Color
.rgbToHSV(this.rgb
);
4584 return MochiKit
.Base
.clone(hsv
);
4588 if(typeof (hsl
)=="undefined"||hsl
===null){
4589 hsl
=MochiKit
.Color
.rgbToHSL(this.rgb
);
4592 return MochiKit
.Base
.clone(hsl
);
4593 },toString
:function(){
4594 return this.toRGBString();
4597 var col
=[c
.r
,c
.g
,c
.b
,c
.a
];
4598 return this.__class__
.NAME
+"("+col
.join(", ")+")";
4600 MochiKit
.Base
.update(MochiKit
.Color
.Color
,{fromRGB
:function(red
,_4ab
,blue
,_4ad
){
4601 var _4ae
=MochiKit
.Color
.Color
;
4602 if(arguments
.length
==1){
4607 if(typeof (rgb
.a
)=="undefined"){
4613 return new _4ae(red
,_4ab
,blue
,_4ad
);
4614 },fromHSL
:function(hue
,_4b1
,_4b2
,_4b3
){
4615 var m
=MochiKit
.Color
;
4616 return m
.Color
.fromRGB(m
.hslToRGB
.apply(m
,arguments
));
4617 },fromHSV
:function(hue
,_4b6
,_4b7
,_4b8
){
4618 var m
=MochiKit
.Color
;
4619 return m
.Color
.fromRGB(m
.hsvToRGB
.apply(m
,arguments
));
4620 },fromName
:function(name
){
4621 var _4bb
=MochiKit
.Color
.Color
;
4622 if(name
.charAt(0)=="\""){
4623 name
=name
.substr(1,name
.length
-2);
4625 var _4bc
=_4bb
._namedColors
[name
.toLowerCase()];
4626 if(typeof (_4bc
)=="string"){
4627 return _4bb
.fromHexString(_4bc
);
4629 if(name
=="transparent"){
4630 return _4bb
.transparentColor();
4634 },fromString
:function(_4bd
){
4635 var self
=MochiKit
.Color
.Color
;
4636 var _4bf
=_4bd
.substr(0,3);
4638 return self
.fromRGBString(_4bd
);
4641 return self
.fromHSLString(_4bd
);
4643 if(_4bd
.charAt(0)=="#"){
4644 return self
.fromHexString(_4bd
);
4648 return self
.fromName(_4bd
);
4649 },fromHexString
:function(_4c0
){
4650 if(_4c0
.charAt(0)=="#"){
4651 _4c0
=_4c0
.substring(1);
4657 hex
=_4c0
.substr(i
,1);
4658 _4c1
.push(parseInt(hex
+hex
,16)/255);
4662 hex
=_4c0
.substr(i
,2);
4663 _4c1
.push(parseInt(hex
,16)/255);
4666 var _4c4
=MochiKit
.Color
.Color
;
4667 return _4c4
.fromRGB
.apply(_4c4
,_4c1
);
4668 },_fromColorString
:function(pre
,_4c6
,_4c7
,_4c8
){
4669 if(_4c8
.indexOf(pre
)===0){
4670 _4c8
=_4c8
.substring(_4c8
.indexOf("(",3)+1,_4c8
.length
-1);
4672 var _4c9
=_4c8
.split(/\s*,\s*/);
4674 for(var i
=0;i
<_4c9
.length
;i
++){
4677 var _4ce
=c
.substring(c
.length
-3);
4678 if(c
.charAt(c
.length
-1)=="%"){
4679 val
=0.01*parseFloat(c
.substring(0,c
.length
-1));
4682 val
=parseFloat(c
)/360;
4685 val
=parseFloat(c
)/(Math
.PI
*2);
4687 val
=_4c7
[i
]*parseFloat(c
);
4693 return this[_4c6
].apply(this,_4ca
);
4694 },fromComputedStyle
:function(elem
,_4d0
){
4696 var cls
=MochiKit
.Color
.Color
;
4697 for(elem
=d
.getElement(elem
);elem
;elem
=elem
.parentNode
){
4698 var _4d3
=MochiKit
.Style
.getStyle
.apply(d
,arguments
);
4702 var _4d4
=cls
.fromString(_4d3
);
4706 if(_4d4
.asRGB().a
>0){
4711 },fromBackground
:function(elem
){
4712 var cls
=MochiKit
.Color
.Color
;
4713 return cls
.fromComputedStyle(elem
,"backgroundColor","background-color")||cls
.whiteColor();
4714 },fromText
:function(elem
){
4715 var cls
=MochiKit
.Color
.Color
;
4716 return cls
.fromComputedStyle(elem
,"color","color")||cls
.blackColor();
4717 },namedColors
:function(){
4718 return MochiKit
.Base
.clone(MochiKit
.Color
.Color
._namedColors
);
4720 MochiKit
.Base
.update(MochiKit
.Color
,{clampColorComponent
:function(v
,_4da
){
4731 },_hslValue
:function(n1
,n2
,hue
){
4747 val
=n1
+(n2
-n1
)*(4-hue
);
4754 },hsvToRGB
:function(hue
,_4e0
,_4e1
,_4e2
){
4755 if(arguments
.length
==1){
4770 var i
=Math
.floor(hue
*6);
4772 var p
=_4e1
*(1-_4e0
);
4773 var q
=_4e1
*(1-(_4e0
*f
));
4774 var t
=_4e1
*(1-(_4e0
*(1-f
)));
4809 return {r
:red
,g
:_4e5
,b
:blue
,a
:_4e2
};
4810 },hslToRGB
:function(hue
,_4ed
,_4ee
,_4ef
){
4811 if(arguments
.length
==1){
4830 m2
=_4ee
+_4ed
-(_4ee
*_4ed
);
4833 var f
=MochiKit
.Color
._hslValue
;
4839 return {r
:red
,g
:_4f2
,b
:blue
,a
:_4ef
};
4840 },rgbToHSV
:function(red
,_4f9
,blue
,_4fb
){
4841 if(arguments
.length
==1){
4848 var max
=Math
.max(Math
.max(red
,_4f9
),blue
);
4849 var min
=Math
.min(Math
.min(red
,_4f9
),blue
);
4860 hue
=(_4f9
-blue
)/_502
;
4863 hue
=2+((blue
-red
)/_502
);
4865 hue
=4+((red
-_4f9
)/_502
);
4876 return {h
:hue
,s
:_500
,v
:_501
,a
:_4fb
};
4877 },rgbToHSL
:function(red
,_504
,blue
,_506
){
4878 if(arguments
.length
==1){
4885 var max
=Math
.max(red
,Math
.max(_504
,blue
));
4886 var min
=Math
.min(red
,Math
.min(_504
,blue
));
4889 var _50c
=(max
+min
)/2;
4896 _50b
=_50d
/(max
+min
);
4898 _50b
=_50d
/(2-max
-min
);
4901 hue
=(_504
-blue
)/_50d
;
4904 hue
=2+((blue
-red
)/_50d
);
4906 hue
=4+((red
-_504
)/_50d
);
4917 return {h
:hue
,s
:_50b
,l
:_50c
,a
:_506
};
4918 },toColorPart
:function(num
){
4919 num
=Math
.round(num
);
4920 var _50f
=num
.toString(16);
4925 },__new__
:function(){
4926 var m
=MochiKit
.Base
;
4927 this.Color
.fromRGBString
=m
.bind(this.Color
._fromColorString
,this.Color
,"rgb","fromRGB",[1/255,1/255,1/255,1]);
4928 this.Color
.fromHSLString
=m
.bind(this.Color
._fromColorString
,this.Color
,"hsl","fromHSL",[1/360,0.01,0.01,1]);
4930 var _512
={black
:[0,0,0],blue
:[0,0,1],brown
:[0.6,0.4,0.2],cyan
:[0,1,1],darkGray
:[_511
,_511
,_511
],gray
:[0.5,0.5,0.5],green
:[0,1,0],lightGray
:[2*_511
,2*_511
,2*_511
],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]};
4931 var _513
=function(name
,r
,g
,b
,a
){
4932 var rval
=this.fromRGB(r
,g
,b
,a
);
4933 this[name
]=function(){
4940 var _51c
=m
.concat([_513
,this.Color
,name
],_512
[k
]);
4941 this.Color
[name
]=m
.bind
.apply(null,_51c
);
4943 var _51d
=function(){
4944 for(var i
=0;i
<arguments
.length
;i
++){
4945 if(!(arguments
[i
] instanceof Color
)){
4951 var _51f
=function(a
,b
){
4952 return a
.compareRGB(b
);
4954 m
.nameFunctions(this);
4955 m
.registerComparator(this.Color
.NAME
,_51d
,_51f
);
4956 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
4958 MochiKit
.Color
.EXPORT
=["Color"];
4959 MochiKit
.Color
.EXPORT_OK
=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
4960 MochiKit
.Color
.__new__();
4961 MochiKit
.Base
._exportSymbols(this,MochiKit
.Color
);
4962 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"};
4963 if(typeof (dojo
)!="undefined"){
4964 dojo
.provide("MochiKit.Signal");
4965 dojo
.require("MochiKit.Base");
4966 dojo
.require("MochiKit.DOM");
4967 dojo
.require("MochiKit.Style");
4969 if(typeof (JSAN
)!="undefined"){
4970 JSAN
.use("MochiKit.Base",[]);
4971 JSAN
.use("MochiKit.DOM",[]);
4972 JSAN
.use("MochiKit.Style",[]);
4975 if(typeof (MochiKit
.Base
)=="undefined"){
4980 throw "MochiKit.Signal depends on MochiKit.Base!";
4983 if(typeof (MochiKit
.DOM
)=="undefined"){
4988 throw "MochiKit.Signal depends on MochiKit.DOM!";
4991 if(typeof (MochiKit
.Style
)=="undefined"){
4996 throw "MochiKit.Signal depends on MochiKit.Style!";
4998 if(typeof (MochiKit
.Signal
)=="undefined"){
5001 MochiKit
.Signal
.NAME
="MochiKit.Signal";
5002 MochiKit
.Signal
.VERSION
="1.4";
5003 MochiKit
.Signal
._observers
=[];
5004 MochiKit
.Signal
.Event
=function(src
,e
){
5005 this._event
=e
||window
.event
;
5008 MochiKit
.Base
.update(MochiKit
.Signal
.Event
.prototype,{__repr__
:function(){
5009 var repr
=MochiKit
.Base
.repr
;
5010 var str
="{event(): "+repr(this.event())+", src(): "+repr(this.src())+", type(): "+repr(this.type())+", target(): "+repr(this.target());
5011 if(this.type()&&this.type().indexOf("key")===0||this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu"){
5012 str
+=", modifier(): "+"{alt: "+repr(this.modifier().alt
)+", ctrl: "+repr(this.modifier().ctrl
)+", meta: "+repr(this.modifier().meta
)+", shift: "+repr(this.modifier().shift
)+", any: "+repr(this.modifier().any
)+"}";
5014 if(this.type()&&this.type().indexOf("key")===0){
5015 str
+=", key(): {code: "+repr(this.key().code
)+", string: "+repr(this.key().string
)+"}";
5017 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
5018 str
+=", mouse(): {page: "+repr(this.mouse().page
)+", client: "+repr(this.mouse().client
);
5019 if(this.type()!="mousemove"){
5020 str
+=", button: {left: "+repr(this.mouse().button
.left
)+", middle: "+repr(this.mouse().button
.middle
)+", right: "+repr(this.mouse().button
.right
)+"}}";
5025 if(this.type()=="mouseover"||this.type()=="mouseout"){
5026 str
+=", relatedTarget(): "+repr(this.relatedTarget());
5030 },toString
:function(){
5031 return this.__repr__();
5037 return this._event
.type
||undefined
;
5038 },target
:function(){
5039 return this._event
.target
||this._event
.srcElement
;
5040 },_relatedTarget
:null,relatedTarget
:function(){
5041 if(this._relatedTarget
!==null){
5042 return this._relatedTarget
;
5045 if(this.type()=="mouseover"){
5046 elem
=(this._event
.relatedTarget
||this._event
.fromElement
);
5048 if(this.type()=="mouseout"){
5049 elem
=(this._event
.relatedTarget
||this._event
.toElement
);
5053 this._relatedTarget
=elem
;
5057 },_modifier
:null,modifier
:function(){
5058 if(this._modifier
!==null){
5059 return this._modifier
;
5062 m
.alt
=this._event
.altKey
;
5063 m
.ctrl
=this._event
.ctrlKey
;
5064 m
.meta
=this._event
.metaKey
||false;
5065 m
.shift
=this._event
.shiftKey
;
5066 m
.any
=m
.alt
||m
.ctrl
||m
.shift
||m
.meta
;
5069 },_key
:null,key
:function(){
5070 if(this._key
!==null){
5074 if(this.type()&&this.type().indexOf("key")===0){
5075 if(this.type()=="keydown"||this.type()=="keyup"){
5076 k
.code
=this._event
.keyCode
;
5077 k
.string
=(MochiKit
.Signal
._specialKeys
[k
.code
]||"KEY_UNKNOWN");
5081 if(this.type()=="keypress"){
5084 if(typeof (this._event
.charCode
)!="undefined"&&this._event
.charCode
!==0&&!MochiKit
.Signal
._specialMacKeys
[this._event
.charCode
]){
5085 k
.code
=this._event
.charCode
;
5086 k
.string
=String
.fromCharCode(k
.code
);
5088 if(this._event
.keyCode
&&typeof (this._event
.charCode
)=="undefined"){
5089 k
.code
=this._event
.keyCode
;
5090 k
.string
=String
.fromCharCode(k
.code
);
5099 },_mouse
:null,mouse
:function(){
5100 if(this._mouse
!==null){
5105 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
5106 m
.client
=new MochiKit
.Style
.Coordinates(0,0);
5107 if(e
.clientX
||e
.clientY
){
5108 m
.client
.x
=(!e
.clientX
||e
.clientX
<0)?0:e
.clientX
;
5109 m
.client
.y
=(!e
.clientY
||e
.clientY
<0)?0:e
.clientY
;
5111 m
.page
=new MochiKit
.Style
.Coordinates(0,0);
5112 if(e
.pageX
||e
.pageY
){
5113 m
.page
.x
=(!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
5114 m
.page
.y
=(!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
5116 var de
=MochiKit
.DOM
._document
.documentElement
;
5117 var b
=MochiKit
.DOM
._document
.body
;
5118 m
.page
.x
=e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
5119 m
.page
.y
=e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
5121 if(this.type()!="mousemove"){
5123 m
.button
.left
=false;
5124 m
.button
.right
=false;
5125 m
.button
.middle
=false;
5127 m
.button
.left
=(e
.which
==1);
5128 m
.button
.middle
=(e
.which
==2);
5129 m
.button
.right
=(e
.which
==3);
5131 m
.button
.left
=!!(e
.button
&1);
5132 m
.button
.right
=!!(e
.button
&2);
5133 m
.button
.middle
=!!(e
.button
&4);
5141 this.stopPropagation();
5142 this.preventDefault();
5143 },stopPropagation
:function(){
5144 if(this._event
.stopPropagation
){
5145 this._event
.stopPropagation();
5147 this._event
.cancelBubble
=true;
5149 },preventDefault
:function(){
5150 if(this._event
.preventDefault
){
5151 this._event
.preventDefault();
5153 if(this._confirmUnload
===null){
5154 this._event
.returnValue
=false;
5157 },_confirmUnload
:null,confirmUnload
:function(msg
){
5158 if(this.type()=="beforeunload"){
5159 this._confirmUnload
=msg
;
5160 this._event
.returnValue
=msg
;
5163 MochiKit
.Signal
._specialMacKeys
={3:"KEY_ENTER",63289:"KEY_NUM_PAD_CLEAR",63276:"KEY_PAGE_UP",63277:"KEY_PAGE_DOWN",63275:"KEY_END",63273:"KEY_HOME",63234:"KEY_ARROW_LEFT",63232:"KEY_ARROW_UP",63235:"KEY_ARROW_RIGHT",63233:"KEY_ARROW_DOWN",63302:"KEY_INSERT",63272:"KEY_DELETE"};
5165 var _52e
=MochiKit
.Signal
._specialMacKeys
;
5166 for(i
=63236;i
<=63242;i
++){
5167 _52e
[i
]="KEY_F"+(i
-63236+1);
5170 MochiKit
.Signal
._specialKeys
={8:"KEY_BACKSPACE",9:"KEY_TAB",12:"KEY_NUM_PAD_CLEAR",13:"KEY_ENTER",16:"KEY_SHIFT",17:"KEY_CTRL",18:"KEY_ALT",19:"KEY_PAUSE",20:"KEY_CAPS_LOCK",27:"KEY_ESCAPE",32:"KEY_SPACEBAR",33:"KEY_PAGE_UP",34:"KEY_PAGE_DOWN",35:"KEY_END",36:"KEY_HOME",37:"KEY_ARROW_LEFT",38:"KEY_ARROW_UP",39:"KEY_ARROW_RIGHT",40:"KEY_ARROW_DOWN",44:"KEY_PRINT_SCREEN",45:"KEY_INSERT",46:"KEY_DELETE",59:"KEY_SEMICOLON",91:"KEY_WINDOWS_LEFT",92:"KEY_WINDOWS_RIGHT",93:"KEY_SELECT",106:"KEY_NUM_PAD_ASTERISK",107:"KEY_NUM_PAD_PLUS_SIGN",109:"KEY_NUM_PAD_HYPHEN-MINUS",110:"KEY_NUM_PAD_FULL_STOP",111:"KEY_NUM_PAD_SOLIDUS",144:"KEY_NUM_LOCK",145:"KEY_SCROLL_LOCK",186:"KEY_SEMICOLON",187:"KEY_EQUALS_SIGN",188:"KEY_COMMA",189:"KEY_HYPHEN-MINUS",190:"KEY_FULL_STOP",191:"KEY_SOLIDUS",192:"KEY_GRAVE_ACCENT",219:"KEY_LEFT_SQUARE_BRACKET",220:"KEY_REVERSE_SOLIDUS",221:"KEY_RIGHT_SQUARE_BRACKET",222:"KEY_APOSTROPHE"};
5172 var _52f
=MochiKit
.Signal
._specialKeys
;
5173 for(var i
=48;i
<=57;i
++){
5174 _52f
[i
]="KEY_"+(i
-48);
5176 for(i
=65;i
<=90;i
++){
5177 _52f
[i
]="KEY_"+String
.fromCharCode(i
);
5179 for(i
=96;i
<=105;i
++){
5180 _52f
[i
]="KEY_NUM_PAD_"+(i
-96);
5182 for(i
=112;i
<=123;i
++){
5183 _52f
[i
]="KEY_F"+(i
-112+1);
5186 MochiKit
.Signal
.Ident
=function(_531
){
5187 this.source
=_531
.source
;
5188 this.signal
=_531
.signal
;
5189 this.listener
=_531
.listener
;
5190 this.isDOM
=_531
.isDOM
;
5191 this.objOrFunc
=_531
.objOrFunc
;
5192 this.funcOrStr
=_531
.funcOrStr
;
5193 this.connected
=_531
.connected
;
5195 MochiKit
.Signal
.Ident
.prototype={};
5196 MochiKit
.Base
.update(MochiKit
.Signal
,{__repr__
:function(){
5197 return "["+this.NAME
+" "+this.VERSION
+"]";
5198 },toString
:function(){
5199 return this.__repr__();
5200 },_unloadCache
:function(){
5201 var self
=MochiKit
.Signal
;
5202 var _533
=self
._observers
;
5203 for(var i
=0;i
<_533
.length
;i
++){
5204 if(_533
[i
].signal
!=="onload"&&_533
[i
].signal
!=="onunload"){
5205 self
._disconnect(_533
[i
]);
5208 },_listener
:function(src
,sig
,func
,obj
,_539
){
5209 var self
=MochiKit
.Signal
;
5212 return MochiKit
.Base
.bind(func
,obj
);
5215 if(typeof (func
)=="string"){
5216 if(sig
==="onload"||sig
==="onunload"){
5217 return function(_53c
){
5218 obj
[func
].apply(obj
,[new E(src
,_53c
)]);
5219 var _53d
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,objOrFunc
:obj
,funcOrStr
:func
});
5220 MochiKit
.Signal
._disconnect(_53d
);
5223 return function(_53e
){
5224 obj
[func
].apply(obj
,[new E(src
,_53e
)]);
5228 if(sig
==="onload"||sig
==="onunload"){
5229 return function(_53f
){
5230 func
.apply(obj
,[new E(src
,_53f
)]);
5231 MochiKit
.Signal
.disconnect(src
,sig
,func
);
5232 var _540
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,objOrFunc
:func
});
5233 MochiKit
.Signal
._disconnect(_540
);
5236 return function(_541
){
5237 func
.apply(obj
,[new E(src
,_541
)]);
5241 },_browserAlreadyHasMouseEnterAndLeave
:function(){
5242 return /MSIE/.test(navigator
.userAgent
);
5243 },_mouseEnterListener
:function(src
,sig
,func
,obj
){
5244 var E
=MochiKit
.Signal
.Event
;
5245 return function(_547
){
5246 var e
=new E(src
,_547
);
5248 e
.relatedTarget().nodeName
;
5254 if(MochiKit
.DOM
.isChildNode(e
.relatedTarget(),src
)){
5260 if(typeof (func
)=="string"){
5261 return obj
[func
].apply(obj
,[e
]);
5263 return func
.apply(obj
,[e
]);
5266 },_getDestPair
:function(_549
,_54a
){
5269 if(typeof (_54a
)!="undefined"){
5272 if(typeof (_54a
)=="string"){
5273 if(typeof (_549
[_54a
])!="function"){
5274 throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
5277 if(typeof (_54a
)!="function"){
5278 throw new Error("'funcOrStr' must be a function or string");
5282 if(typeof (_549
)!="function"){
5283 throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
5289 },connect
:function(src
,sig
,_54f
,_550
){
5290 src
=MochiKit
.DOM
.getElement(src
);
5291 var self
=MochiKit
.Signal
;
5292 if(typeof (sig
)!="string"){
5293 throw new Error("'sig' must be a string");
5295 var _552
=self
._getDestPair(_54f
,_550
);
5298 if(typeof (obj
)=="undefined"||obj
===null){
5301 var _555
=!!(src
.addEventListener
||src
.attachEvent
);
5302 if(_555
&&(sig
==="onmouseenter"||sig
==="onmouseleave")&&!self
._browserAlreadyHasMouseEnterAndLeave()){
5303 var _556
=self
._mouseEnterListener(src
,sig
.substr(2),func
,obj
);
5304 if(sig
==="onmouseenter"){
5310 var _556
=self
._listener(src
,sig
,func
,obj
,_555
);
5312 if(src
.addEventListener
){
5313 src
.addEventListener(sig
.substr(2),_556
,false);
5315 if(src
.attachEvent
){
5316 src
.attachEvent(sig
,_556
);
5319 var _557
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,listener
:_556
,isDOM
:_555
,objOrFunc
:_54f
,funcOrStr
:_550
,connected
:true});
5320 self
._observers
.push(_557
);
5321 if(!_555
&&typeof (src
.__connect__
)=="function"){
5322 var args
=MochiKit
.Base
.extend([_557
],arguments
,1);
5323 src
.__connect__
.apply(src
,args
);
5326 },_disconnect
:function(_559
){
5327 if(!_559
.connected
){
5330 _559
.connected
=false;
5334 var src
=_559
.source
;
5335 var sig
=_559
.signal
;
5336 var _55c
=_559
.listener
;
5337 if(src
.removeEventListener
){
5338 src
.removeEventListener(sig
.substr(2),_55c
,false);
5340 if(src
.detachEvent
){
5341 src
.detachEvent(sig
,_55c
);
5343 throw new Error("'src' must be a DOM element");
5346 },disconnect
:function(_55d
){
5347 var self
=MochiKit
.Signal
;
5348 var _55f
=self
._observers
;
5349 var m
=MochiKit
.Base
;
5350 if(arguments
.length
>1){
5351 var src
=MochiKit
.DOM
.getElement(arguments
[0]);
5352 var sig
=arguments
[1];
5353 var obj
=arguments
[2];
5354 var func
=arguments
[3];
5355 for(var i
=_55f
.length
-1;i
>=0;i
--){
5357 if(o
.source
===src
&&o
.signal
===sig
&&o
.objOrFunc
===obj
&&o
.funcOrStr
===func
){
5358 self
._disconnect(o
);
5368 var idx
=m
.findIdentical(_55f
,_55d
);
5370 self
._disconnect(_55d
);
5380 },disconnectAllTo
:function(_568
,_569
){
5381 var self
=MochiKit
.Signal
;
5382 var _56b
=self
._observers
;
5383 var _56c
=self
._disconnect
;
5384 var _56d
=self
._lock
;
5385 var _56e
=self
._dirty
;
5386 if(typeof (_569
)==="undefined"){
5389 for(var i
=_56b
.length
-1;i
>=0;i
--){
5391 if(_570
.objOrFunc
===_568
&&(_569
===null||_570
.funcOrStr
===_569
)){
5401 },disconnectAll
:function(src
,sig
){
5402 src
=MochiKit
.DOM
.getElement(src
);
5403 var m
=MochiKit
.Base
;
5404 var _574
=m
.flattenArguments(m
.extend(null,arguments
,1));
5405 var self
=MochiKit
.Signal
;
5406 var _576
=self
._disconnect
;
5407 var _577
=self
._observers
;
5409 var _57a
=self
._lock
;
5410 var _57b
=self
._dirty
;
5411 if(_574
.length
===0){
5412 for(i
=_577
.length
-1;i
>=0;i
--){
5414 if(_579
.source
===src
){
5425 for(i
=0;i
<_574
.length
;i
++){
5428 for(i
=_577
.length
-1;i
>=0;i
--){
5430 if(_579
.source
===src
&&_579
.signal
in sigs
){
5441 },signal
:function(src
,sig
){
5442 var self
=MochiKit
.Signal
;
5443 var _580
=self
._observers
;
5444 src
=MochiKit
.DOM
.getElement(src
);
5445 var args
=MochiKit
.Base
.extend(null,arguments
,2);
5448 for(var i
=0;i
<_580
.length
;i
++){
5450 if(_584
.source
===src
&&_584
.signal
===sig
){
5452 _584
.listener
.apply(src
,args
);
5462 for(var i
=_580
.length
-1;i
>=0;i
--){
5463 if(!_580
[i
].connected
){
5472 var e
=new Error("Multiple errors thrown in handling 'sig', see errors property");
5478 MochiKit
.Signal
.EXPORT_OK
=[];
5479 MochiKit
.Signal
.EXPORT
=["connect","disconnect","signal","disconnectAll","disconnectAllTo"];
5480 MochiKit
.Signal
.__new__
=function(win
){
5481 var m
=MochiKit
.Base
;
5482 this._document
=document
;
5487 this.connect(window
,"onunload",this._unloadCache
);
5491 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
5492 m
.nameFunctions(this);
5494 MochiKit
.Signal
.__new__(this);
5495 if(MochiKit
.__export__
){
5496 connect
=MochiKit
.Signal
.connect
;
5497 disconnect
=MochiKit
.Signal
.disconnect
;
5498 disconnectAll
=MochiKit
.Signal
.disconnectAll
;
5499 signal
=MochiKit
.Signal
.signal
;
5501 MochiKit
.Base
._exportSymbols(this,MochiKit
.Signal
);
5502 if(typeof (dojo
)!="undefined"){
5503 dojo
.provide("MochiKit.Position");
5504 dojo
.require("MochiKit.Base");
5505 dojo
.require("MochiKit.DOM");
5506 dojo
.require("MochiKit.Style");
5508 if(typeof (JSAN
)!="undefined"){
5509 JSAN
.use("MochiKit.Base",[]);
5510 JSAN
.use("MochiKit.DOM",[]);
5511 JSAN
.use("MochiKit.Style",[]);
5514 if(typeof (MochiKit
.Base
)=="undefined"||typeof (MochiKit
.Style
)=="undefined"||typeof (MochiKit
.DOM
)=="undefined"){
5519 throw "MochiKit.Style depends on MochiKit.Base, MochiKit.DOM, and MochiKit.Style!";
5521 if(typeof (MochiKit
.Position
)=="undefined"){
5522 MochiKit
.Position
={};
5524 MochiKit
.Position
.NAME
="MochiKit.Position";
5525 MochiKit
.Position
.VERSION
="1.4";
5526 MochiKit
.Position
.__repr__
=function(){
5527 return "["+this.NAME
+" "+this.VERSION
+"]";
5529 MochiKit
.Position
.toString
=function(){
5530 return this.__repr__();
5532 MochiKit
.Position
.EXPORT_OK
=[];
5533 MochiKit
.Position
.EXPORT
=[];
5534 MochiKit
.Base
.update(MochiKit
.Position
,{includeScrollOffsets
:false,prepare
:function(){
5535 var _588
=window
.pageXOffset
||document
.documentElement
.scrollLeft
||document
.body
.scrollLeft
||0;
5536 var _589
=window
.pageYOffset
||document
.documentElement
.scrollTop
||document
.body
.scrollTop
||0;
5537 this.windowOffset
=new MochiKit
.Style
.Coordinates(_588
,_589
);
5538 },cumulativeOffset
:function(_58a
){
5542 _58b
+=_58a
.offsetTop
||0;
5543 _58c
+=_58a
.offsetLeft
||0;
5544 _58a
=_58a
.offsetParent
;
5546 return new MochiKit
.Style
.Coordinates(_58c
,_58b
);
5547 },realOffset
:function(_58d
){
5551 _58e
+=_58d
.scrollTop
||0;
5552 _58f
+=_58d
.scrollLeft
||0;
5553 _58d
=_58d
.parentNode
;
5555 return new MochiKit
.Style
.Coordinates(_58f
,_58e
);
5556 },within
:function(_590
,x
,y
){
5557 if(this.includeScrollOffsets
){
5558 return this.withinIncludingScrolloffsets(_590
,x
,y
);
5562 this.offset
=this.cumulativeOffset(_590
);
5563 if(_590
.style
.position
=="fixed"){
5564 this.offset
.x
+=this.windowOffset
.x
;
5565 this.offset
.y
+=this.windowOffset
.y
;
5567 return (y
>=this.offset
.y
&&y
<this.offset
.y
+_590
.offsetHeight
&&x
>=this.offset
.x
&&x
<this.offset
.x
+_590
.offsetWidth
);
5568 },withinIncludingScrolloffsets
:function(_593
,x
,y
){
5569 var _596
=this.realOffset(_593
);
5570 this.xcomp
=x
+_596
.x
-this.windowOffset
.x
;
5571 this.ycomp
=y
+_596
.y
-this.windowOffset
.y
;
5572 this.offset
=this.cumulativeOffset(_593
);
5573 return (this.ycomp
>=this.offset
.y
&&this.ycomp
<this.offset
.y
+_593
.offsetHeight
&&this.xcomp
>=this.offset
.x
&&this.xcomp
<this.offset
.x
+_593
.offsetWidth
);
5574 },overlap
:function(mode
,_598
){
5578 if(mode
=="vertical"){
5579 return ((this.offset
.y
+_598
.offsetHeight
)-this.ycomp
)/_598
.offsetHeight
;
5581 if(mode
=="horizontal"){
5582 return ((this.offset
.x
+_598
.offsetWidth
)-this.xcomp
)/_598
.offsetWidth
;
5584 },absolutize
:function(_599
){
5585 _599
=MochiKit
.DOM
.getElement(_599
);
5586 if(_599
.style
.position
=="absolute"){
5589 MochiKit
.Position
.prepare();
5590 var _59a
=MochiKit
.Position
.positionedOffset(_599
);
5591 var _59b
=_599
.clientWidth
;
5592 var _59c
=_599
.clientHeight
;
5593 var _59d
={"position":_599
.style
.position
,"left":_59a
.x
-parseFloat(_599
.style
.left
||0),"top":_59a
.y
-parseFloat(_599
.style
.top
||0),"width":_599
.style
.width
,"height":_599
.style
.height
};
5594 _599
.style
.position
="absolute";
5595 _599
.style
.top
=_59a
.y
+"px";
5596 _599
.style
.left
=_59a
.x
+"px";
5597 _599
.style
.width
=_59b
+"px";
5598 _599
.style
.height
=_59c
+"px";
5600 },positionedOffset
:function(_59e
){
5603 _59f
+=_59e
.offsetTop
||0;
5604 _5a0
+=_59e
.offsetLeft
||0;
5605 _59e
=_59e
.offsetParent
;
5607 p
=MochiKit
.Style
.getStyle(_59e
,"position");
5608 if(p
=="relative"||p
=="absolute"){
5613 return new MochiKit
.Style
.Coordinates(_5a0
,_59f
);
5614 },relativize
:function(_5a1
,_5a2
){
5615 _5a1
=MochiKit
.DOM
.getElement(_5a1
);
5616 if(_5a1
.style
.position
=="relative"){
5619 MochiKit
.Position
.prepare();
5620 var top
=parseFloat(_5a1
.style
.top
||0)-(_5a2
["top"]||0);
5621 var left
=parseFloat(_5a1
.style
.left
||0)-(_5a2
["left"]||0);
5622 _5a1
.style
.position
=_5a2
["position"];
5623 _5a1
.style
.top
=top
+"px";
5624 _5a1
.style
.left
=left
+"px";
5625 _5a1
.style
.width
=_5a2
["width"];
5626 _5a1
.style
.height
=_5a2
["height"];
5627 },clone
:function(_5a5
,_5a6
){
5628 _5a5
=MochiKit
.DOM
.getElement(_5a5
);
5629 _5a6
=MochiKit
.DOM
.getElement(_5a6
);
5630 _5a6
.style
.position
="absolute";
5631 var _5a7
=this.cumulativeOffset(_5a5
);
5632 _5a6
.style
.top
=_5a7
.y
+"px";
5633 _5a6
.style
.left
=_5a7
.x
+"px";
5634 _5a6
.style
.width
=_5a5
.offsetWidth
+"px";
5635 _5a6
.style
.height
=_5a5
.offsetHeight
+"px";
5636 },page
:function(_5a8
){
5641 _5a9
+=_5ab
.offsetTop
||0;
5642 _5aa
+=_5ab
.offsetLeft
||0;
5643 if(_5ab
.offsetParent
==document
.body
&&MochiKit
.Style
.getStyle(_5ab
,"position")=="absolute"){
5646 }while(_5ab
=_5ab
.offsetParent
);
5649 _5a9
-=_5ab
.scrollTop
||0;
5650 _5aa
-=_5ab
.scrollLeft
||0;
5651 }while(_5ab
=_5ab
.parentNode
);
5652 return new MochiKit
.Style
.Coordinates(_5aa
,_5a9
);
5654 MochiKit
.Position
.__new__
=function(win
){
5655 var m
=MochiKit
.Base
;
5656 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
5657 m
.nameFunctions(this);
5659 MochiKit
.Position
.__new__(this);
5660 if(typeof (dojo
)!="undefined"){
5661 dojo
.provide("MochiKit.Visual");
5662 dojo
.require("MochiKit.Base");
5663 dojo
.require("MochiKit.DOM");
5664 dojo
.require("MochiKit.Style");
5665 dojo
.require("MochiKit.Color");
5666 dojo
.require("MochiKit.Position");
5668 if(typeof (JSAN
)!="undefined"){
5669 JSAN
.use("MochiKit.Base",[]);
5670 JSAN
.use("MochiKit.DOM",[]);
5671 JSAN
.use("MochiKit.Style",[]);
5672 JSAN
.use("MochiKit.Color",[]);
5673 JSAN
.use("MochiKit.Position",[]);
5676 if(typeof (MochiKit
.Base
)==="undefined"||typeof (MochiKit
.DOM
)==="undefined"||typeof (MochiKit
.Style
)==="undefined"||typeof (MochiKit
.Position
)==="undefined"||typeof (MochiKit
.Color
)==="undefined"){
5681 throw "MochiKit.Visual depends on MochiKit.Base, MochiKit.DOM, MochiKit.Style, MochiKit.Position and MochiKit.Color!";
5683 if(typeof (MochiKit
.Visual
)=="undefined"){
5686 MochiKit
.Visual
.NAME
="MochiKit.Visual";
5687 MochiKit
.Visual
.VERSION
="1.4";
5688 MochiKit
.Visual
.__repr__
=function(){
5689 return "["+this.NAME
+" "+this.VERSION
+"]";
5691 MochiKit
.Visual
.toString
=function(){
5692 return this.__repr__();
5694 MochiKit
.Visual
._RoundCorners
=function(e
,_5af
){
5695 e
=MochiKit
.DOM
.getElement(e
);
5696 this._setOptions(_5af
);
5697 if(this.options
.__unstable__wrapElement
){
5700 var _5b0
=this.options
.color
;
5701 var C
=MochiKit
.Color
.Color
;
5702 if(this.options
.color
==="fromElement"){
5703 _5b0
=C
.fromBackground(e
);
5705 if(!(_5b0
instanceof C
)){
5706 _5b0
=C
.fromString(_5b0
);
5709 this.isTransparent
=(_5b0
.asRGB().a
<=0);
5710 var _5b2
=this.options
.bgColor
;
5711 if(this.options
.bgColor
==="fromParent"){
5712 _5b2
=C
.fromBackground(e
.offsetParent
);
5714 if(!(_5b2
instanceof C
)){
5715 _5b2
=C
.fromString(_5b2
);
5718 this._roundCornersImpl(e
,_5b0
,_5b2
);
5720 MochiKit
.Visual
._RoundCorners
.prototype={_doWrap
:function(e
){
5721 var _5b4
=e
.parentNode
;
5722 var doc
=MochiKit
.DOM
.currentDocument();
5723 if(typeof (doc
.defaultView
)==="undefined"||doc
.defaultView
===null){
5726 var _5b6
=doc
.defaultView
.getComputedStyle(e
,null);
5727 if(typeof (_5b6
)==="undefined"||_5b6
===null){
5730 var _5b7
=MochiKit
.DOM
.DIV({"style":{display
:"block",marginTop
:_5b6
.getPropertyValue("padding-top"),marginRight
:_5b6
.getPropertyValue("padding-right"),marginBottom
:_5b6
.getPropertyValue("padding-bottom"),marginLeft
:_5b6
.getPropertyValue("padding-left"),padding
:"0px"}});
5731 _5b7
.innerHTML
=e
.innerHTML
;
5733 e
.appendChild(_5b7
);
5735 },_roundCornersImpl
:function(e
,_5b9
,_5ba
){
5736 if(this.options
.border
){
5737 this._renderBorder(e
,_5ba
);
5739 if(this._isTopRounded()){
5740 this._roundTopCorners(e
,_5b9
,_5ba
);
5742 if(this._isBottomRounded()){
5743 this._roundBottomCorners(e
,_5b9
,_5ba
);
5745 },_renderBorder
:function(el
,_5bc
){
5746 var _5bd
="1px solid "+this._borderColor(_5bc
);
5747 var _5be
="border-left: "+_5bd
;
5748 var _5bf
="border-right: "+_5bd
;
5749 var _5c0
="style='"+_5be
+";"+_5bf
+"'";
5750 el
.innerHTML
="<div "+_5c0
+">"+el
.innerHTML
+"</div>";
5751 },_roundTopCorners
:function(el
,_5c2
,_5c3
){
5752 var _5c4
=this._createCorner(_5c3
);
5753 for(var i
=0;i
<this.options
.numSlices
;i
++){
5754 _5c4
.appendChild(this._createCornerSlice(_5c2
,_5c3
,i
,"top"));
5756 el
.style
.paddingTop
=0;
5757 el
.insertBefore(_5c4
,el
.firstChild
);
5758 },_roundBottomCorners
:function(el
,_5c7
,_5c8
){
5759 var _5c9
=this._createCorner(_5c8
);
5760 for(var i
=(this.options
.numSlices
-1);i
>=0;i
--){
5761 _5c9
.appendChild(this._createCornerSlice(_5c7
,_5c8
,i
,"bottom"));
5763 el
.style
.paddingBottom
=0;
5764 el
.appendChild(_5c9
);
5765 },_createCorner
:function(_5cb
){
5766 var dom
=MochiKit
.DOM
;
5767 return dom
.DIV({style
:{backgroundColor
:_5cb
.toString()}});
5768 },_createCornerSlice
:function(_5cd
,_5ce
,n
,_5d0
){
5769 var _5d1
=MochiKit
.DOM
.SPAN();
5770 var _5d2
=_5d1
.style
;
5771 _5d2
.backgroundColor
=_5cd
.toString();
5772 _5d2
.display
="block";
5774 _5d2
.overflow
="hidden";
5775 _5d2
.fontSize
="1px";
5776 var _5d3
=this._borderColor(_5cd
,_5ce
);
5777 if(this.options
.border
&&n
===0){
5778 _5d2
.borderTopStyle
="solid";
5779 _5d2
.borderTopWidth
="1px";
5780 _5d2
.borderLeftWidth
="0px";
5781 _5d2
.borderRightWidth
="0px";
5782 _5d2
.borderBottomWidth
="0px";
5784 _5d2
.borderColor
=_5d3
.toString();
5787 _5d2
.borderColor
=_5d3
.toString();
5788 _5d2
.borderStyle
="solid";
5789 _5d2
.borderWidth
="0px 1px";
5792 if(!this.options
.compact
&&(n
==(this.options
.numSlices
-1))){
5795 this._setMargin(_5d1
,n
,_5d0
);
5796 this._setBorder(_5d1
,n
,_5d0
);
5798 },_setOptions
:function(_5d4
){
5799 this.options
={corners
:"all",color
:"fromElement",bgColor
:"fromParent",blend
:true,border
:false,compact
:false,__unstable__wrapElement
:false};
5800 MochiKit
.Base
.update(this.options
,_5d4
);
5801 this.options
.numSlices
=(this.options
.compact
?2:4);
5802 },_whichSideTop
:function(){
5803 var _5d5
=this.options
.corners
;
5804 if(this._hasString(_5d5
,"all","top")){
5807 var _5d6
=(_5d5
.indexOf("tl")!=-1);
5808 var _5d7
=(_5d5
.indexOf("tr")!=-1);
5819 },_whichSideBottom
:function(){
5820 var _5d8
=this.options
.corners
;
5821 if(this._hasString(_5d8
,"all","bottom")){
5824 var _5d9
=(_5d8
.indexOf("bl")!=-1);
5825 var _5da
=(_5d8
.indexOf("br")!=-1);
5836 },_borderColor
:function(_5db
,_5dc
){
5837 if(_5db
=="transparent"){
5840 if(this.options
.border
){
5841 return this.options
.border
;
5843 if(this.options
.blend
){
5844 return _5dc
.blendedColor(_5db
);
5849 },_setMargin
:function(el
,n
,_5df
){
5850 var _5e0
=this._marginSize(n
)+"px";
5851 var _5e1
=(_5df
=="top"?this._whichSideTop():this._whichSideBottom());
5854 _5e2
.marginLeft
=_5e0
;
5855 _5e2
.marginRight
="0px";
5858 _5e2
.marginRight
=_5e0
;
5859 _5e2
.marginLeft
="0px";
5861 _5e2
.marginLeft
=_5e0
;
5862 _5e2
.marginRight
=_5e0
;
5865 },_setBorder
:function(el
,n
,_5e5
){
5866 var _5e6
=this._borderSize(n
)+"px";
5867 var _5e7
=(_5e5
=="top"?this._whichSideTop():this._whichSideBottom());
5870 _5e8
.borderLeftWidth
=_5e6
;
5871 _5e8
.borderRightWidth
="0px";
5874 _5e8
.borderRightWidth
=_5e6
;
5875 _5e8
.borderLeftWidth
="0px";
5877 _5e8
.borderLeftWidth
=_5e6
;
5878 _5e8
.borderRightWidth
=_5e6
;
5881 },_marginSize
:function(n
){
5882 if(this.isTransparent
){
5886 if(o
.compact
&&o
.blend
){
5903 },_borderSize
:function(n
){
5906 if(o
.compact
&&(o
.blend
||this.isTransparent
)){
5918 if(this.isTransparent
){
5928 },_hasString
:function(str
){
5929 for(var i
=1;i
<arguments
.length
;i
++){
5930 if(str
.indexOf(arguments
[i
])!=-1){
5935 },_isTopRounded
:function(){
5936 return this._hasString(this.options
.corners
,"all","top","tl","tr");
5937 },_isBottomRounded
:function(){
5938 return this._hasString(this.options
.corners
,"all","bottom","bl","br");
5939 },_hasSingleTextChild
:function(el
){
5940 return (el
.childNodes
.length
==1&&el
.childNodes
[0].nodeType
==3);
5942 MochiKit
.Visual
.roundElement
=function(e
,_5f6
){
5943 new MochiKit
.Visual
._RoundCorners(e
,_5f6
);
5945 MochiKit
.Visual
.roundClass
=function(_5f7
,_5f8
,_5f9
){
5946 var _5fa
=MochiKit
.DOM
.getElementsByTagAndClassName(_5f7
,_5f8
);
5947 for(var i
=0;i
<_5fa
.length
;i
++){
5948 MochiKit
.Visual
.roundElement(_5fa
[i
],_5f9
);
5951 MochiKit
.Visual
.tagifyText
=function(_5fc
,_5fd
){
5952 _5fd
=_5fd
||"position:relative";
5953 if(/MSIE/.test(navigator
.userAgent
)){
5956 _5fc
=MochiKit
.DOM
.getElement(_5fc
);
5957 var ma
=MochiKit
.Base
.map
;
5959 if(_5ff
.nodeType
==3){
5961 _5fc
.insertBefore(MochiKit
.DOM
.SPAN({style
:_5fd
},_600
==" "?String
.fromCharCode(160):_600
),_5ff
);
5962 },_5ff
.nodeValue
.split(""));
5963 MochiKit
.DOM
.removeElement(_5ff
);
5967 MochiKit
.Visual
.forceRerendering
=function(_601
){
5969 _601
=MochiKit
.DOM
.getElement(_601
);
5970 var n
=document
.createTextNode(" ");
5971 _601
.appendChild(n
);
5972 _601
.removeChild(n
);
5977 MochiKit
.Visual
.multiple
=function(_603
,_604
,_605
){
5978 _605
=MochiKit
.Base
.update({speed
:0.1,delay
:0},_605
||{});
5979 var _606
=_605
.delay
;
5981 MochiKit
.Base
.map(function(_608
){
5982 _605
.delay
=_607
*_605
.speed
+_606
;
5983 new _604(_608
,_605
);
5987 MochiKit
.Visual
.PAIRS
={"slide":["slideDown","slideUp"],"blind":["blindDown","blindUp"],"appear":["appear","fade"],"size":["grow","shrink"]};
5988 MochiKit
.Visual
.toggle
=function(_609
,_60a
,_60b
){
5989 _609
=MochiKit
.DOM
.getElement(_609
);
5990 _60a
=(_60a
||"appear").toLowerCase();
5991 _60b
=MochiKit
.Base
.update({queue
:{position
:"end",scope
:(_609
.id
||"global"),limit
:1}},_60b
||{});
5992 var v
=MochiKit
.Visual
;
5993 v
[_609
.style
.display
!="none"?v
.PAIRS
[_60a
][1]:v
.PAIRS
[_60a
][0]](_609
,_60b
);
5995 MochiKit
.Visual
.Transitions
={};
5996 MochiKit
.Visual
.Transitions
.linear
=function(pos
){
5999 MochiKit
.Visual
.Transitions
.sinoidal
=function(pos
){
6000 return (-Math
.cos(pos
*Math
.PI
)/2)+0.5;
6002 MochiKit
.Visual
.Transitions
.reverse
=function(pos
){
6005 MochiKit
.Visual
.Transitions
.flicker
=function(pos
){
6006 return ((-Math
.cos(pos
*Math
.PI
)/4)+0.75)+Math.random()/4;
6008 MochiKit
.Visual
.Transitions
.wobble
=function(pos
){
6009 return (-Math
.cos(pos
*Math
.PI
*(9*pos
))/2)+0.5;
6011 MochiKit
.Visual
.Transitions
.pulse
=function(pos
,_613
){
6013 return (Math
.floor(pos
*10)%2===0?(pos
*10-Math
.floor(pos
*10)):1-(pos
*10-Math
.floor(pos
*10)));
6015 return (Math
.round((pos
%(1/_613
))*_613
)==0?((pos
*_613
*2)-Math
.floor(pos
*_613
*2)):1-((pos
*_613
*2)-Math
.floor(pos
*_613
*2)));
6017 MochiKit
.Visual
.Transitions
.none
=function(pos
){
6020 MochiKit
.Visual
.Transitions
.full
=function(pos
){
6023 MochiKit
.Visual
.ScopedQueue
=function(){
6024 var cls
=arguments
.callee
;
6025 if(!(this instanceof cls
)){
6030 MochiKit
.Base
.update(MochiKit
.Visual
.ScopedQueue
.prototype,{__init__
:function(){
6033 },add
:function(_617
){
6034 var _618
=new Date().getTime();
6035 var _619
=(typeof (_617
.options
.queue
)=="string")?_617
.options
.queue
:_617
.options
.queue
.position
;
6036 var ma
=MochiKit
.Base
.map
;
6040 if(e
.state
=="idle"){
6041 e
.startOn
+=_617
.finishOn
;
6042 e
.finishOn
+=_617
.finishOn
;
6063 _617
.finishOn
+=_618
;
6064 if(!_617
.options
.queue
.limit
||this.effects
.length
<_617
.options
.queue
.limit
){
6065 this.effects
.push(_617
);
6068 this.interval
=this.startLoop(MochiKit
.Base
.bind(this.loop
,this),40);
6070 },startLoop
:function(func
,_621
){
6071 return setInterval(func
,_621
);
6072 },remove
:function(_622
){
6073 this.effects
=MochiKit
.Base
.filter(function(e
){
6076 if(!this.effects
.length
){
6077 this.stopLoop(this.interval
);
6080 },stopLoop
:function(_624
){
6081 clearInterval(_624
);
6083 var _625
=new Date().getTime();
6084 MochiKit
.Base
.map(function(_626
){
6088 MochiKit
.Visual
.Queues
={instances
:{},get
:function(_627
){
6089 if(typeof (_627
)!="string"){
6092 if(!this.instances
[_627
]){
6093 this.instances
[_627
]=new MochiKit
.Visual
.ScopedQueue();
6095 return this.instances
[_627
];
6097 MochiKit
.Visual
.Queue
=MochiKit
.Visual
.Queues
.get("global");
6098 MochiKit
.Visual
.DefaultOptions
={transition
:MochiKit
.Visual
.Transitions
.sinoidal
,duration
:1,fps
:25,sync
:false,from
:0,to
:1,delay
:0,queue
:"parallel"};
6099 MochiKit
.Visual
.Base
=function(){
6101 MochiKit
.Visual
.Base
.prototype={__class__
:MochiKit
.Visual
.Base
,start
:function(_628
){
6102 var v
=MochiKit
.Visual
;
6103 this.options
=MochiKit
.Base
.setdefault(_628
||{},v
.DefaultOptions
);
6104 this.currentFrame
=0;
6106 this.startOn
=this.options
.delay
*1000;
6107 this.finishOn
=this.startOn
+(this.options
.duration
*1000);
6108 this.event("beforeStart");
6109 if(!this.options
.sync
){
6110 v
.Queues
.get(typeof (this.options
.queue
)=="string"?"global":this.options
.queue
.scope
).add(this);
6112 },loop
:function(_62a
){
6113 if(_62a
>=this.startOn
){
6114 if(_62a
>=this.finishOn
){
6115 return this.finalize();
6117 var pos
=(_62a
-this.startOn
)/(this.finishOn
-this.startOn
);
6118 var _62c
=Math
.round(pos
*this.options
.fps
*this.options
.duration
);
6119 if(_62c
>this.currentFrame
){
6121 this.currentFrame
=_62c
;
6124 },render
:function(pos
){
6125 if(this.state
=="idle"){
6126 this.state
="running";
6127 this.event("beforeSetup");
6129 this.event("afterSetup");
6131 if(this.state
=="running"){
6132 if(this.options
.transition
){
6133 pos
=this.options
.transition(pos
);
6135 pos
*=(this.options
.to
-this.options
.from
);
6136 pos
+=this.options
.from
;
6137 this.event("beforeUpdate");
6139 this.event("afterUpdate");
6141 },cancel
:function(){
6142 if(!this.options
.sync
){
6143 MochiKit
.Visual
.Queues
.get(typeof (this.options
.queue
)=="string"?"global":this.options
.queue
.scope
).remove(this);
6145 this.state
="finished";
6146 },finalize
:function(){
6149 this.event("beforeFinish");
6151 this.event("afterFinish");
6153 },finish
:function(){
6154 },update
:function(_62e
){
6155 },event
:function(_62f
){
6156 if(this.options
[_62f
+"Internal"]){
6157 this.options
[_62f
+"Internal"](this);
6159 if(this.options
[_62f
]){
6160 this.options
[_62f
](this);
6163 return "["+this.__class__
.NAME
+", options:"+MochiKit
.Base
.repr(this.options
)+"]";
6165 MochiKit
.Visual
.Parallel
=function(_630
,_631
){
6166 var cls
=arguments
.callee
;
6167 if(!(this instanceof cls
)){
6168 return new cls(_630
,_631
);
6170 this.__init__(_630
,_631
);
6172 MochiKit
.Visual
.Parallel
.prototype=new MochiKit
.Visual
.Base();
6173 MochiKit
.Base
.update(MochiKit
.Visual
.Parallel
.prototype,{__class__
:MochiKit
.Visual
.Parallel
,__init__
:function(_633
,_634
){
6174 this.effects
=_633
||[];
6176 },update
:function(_635
){
6177 MochiKit
.Base
.map(function(_636
){
6180 },finish
:function(){
6181 MochiKit
.Base
.map(function(_637
){
6185 MochiKit
.Visual
.Opacity
=function(_638
,_639
){
6186 var cls
=arguments
.callee
;
6187 if(!(this instanceof cls
)){
6188 return new cls(_638
,_639
);
6190 this.__init__(_638
,_639
);
6192 MochiKit
.Visual
.Opacity
.prototype=new MochiKit
.Visual
.Base();
6193 MochiKit
.Base
.update(MochiKit
.Visual
.Opacity
.prototype,{__class__
:MochiKit
.Visual
.Opacity
,__init__
:function(_63b
,_63c
){
6194 var b
=MochiKit
.Base
;
6195 var s
=MochiKit
.Style
;
6196 this.element
=MochiKit
.DOM
.getElement(_63b
);
6197 if(this.element
.currentStyle
&&(!this.element
.currentStyle
.hasLayout
)){
6198 s
.setStyle(this.element
,{zoom
:1});
6200 _63c
=b
.update({from
:s
.getStyle(this.element
,"opacity")||0,to
:1},_63c
||{});
6202 },update
:function(_63f
){
6203 MochiKit
.Style
.setStyle(this.element
,{"opacity":_63f
});
6205 MochiKit
.Visual
.Move
=function(_640
,_641
){
6206 var cls
=arguments
.callee
;
6207 if(!(this instanceof cls
)){
6208 return new cls(_640
,_641
);
6210 this.__init__(_640
,_641
);
6212 MochiKit
.Visual
.Move
.prototype=new MochiKit
.Visual
.Base();
6213 MochiKit
.Base
.update(MochiKit
.Visual
.Move
.prototype,{__class__
:MochiKit
.Visual
.Move
,__init__
:function(_643
,_644
){
6214 this.element
=MochiKit
.DOM
.getElement(_643
);
6215 _644
=MochiKit
.Base
.update({x
:0,y
:0,mode
:"relative"},_644
||{});
6218 MochiKit
.DOM
.makePositioned(this.element
);
6219 var s
=this.element
.style
;
6220 var _646
=s
.visibility
;
6223 s
.visibility
="hidden";
6226 this.originalLeft
=parseFloat(MochiKit
.Style
.getStyle(this.element
,"left")||"0");
6227 this.originalTop
=parseFloat(MochiKit
.Style
.getStyle(this.element
,"top")||"0");
6228 if(this.options
.mode
=="absolute"){
6229 this.options
.x
-=this.originalLeft
;
6230 this.options
.y
-=this.originalTop
;
6236 },update
:function(_648
){
6237 MochiKit
.Style
.setStyle(this.element
,{left
:Math
.round(this.options
.x
*_648
+this.originalLeft
)+"px",top
:Math
.round(this.options
.y
*_648
+this.originalTop
)+"px"});
6239 MochiKit
.Visual
.Scale
=function(_649
,_64a
,_64b
){
6240 var cls
=arguments
.callee
;
6241 if(!(this instanceof cls
)){
6242 return new cls(_649
,_64a
,_64b
);
6244 this.__init__(_649
,_64a
,_64b
);
6246 MochiKit
.Visual
.Scale
.prototype=new MochiKit
.Visual
.Base();
6247 MochiKit
.Base
.update(MochiKit
.Visual
.Scale
.prototype,{__class__
:MochiKit
.Visual
.Scale
,__init__
:function(_64d
,_64e
,_64f
){
6248 this.element
=MochiKit
.DOM
.getElement(_64d
);
6249 _64f
=MochiKit
.Base
.update({scaleX
:true,scaleY
:true,scaleContent
:true,scaleFromCenter
:false,scaleMode
:"box",scaleFrom
:100,scaleTo
:_64e
},_64f
||{});
6252 this.restoreAfterFinish
=this.options
.restoreAfterFinish
||false;
6253 this.elementPositioning
=MochiKit
.Style
.getStyle(this.element
,"position");
6254 var ma
=MochiKit
.Base
.map
;
6255 var b
=MochiKit
.Base
.bind
;
6256 this.originalStyle
={};
6258 this.originalStyle
[k
]=this.element
.style
[k
];
6259 },this),["top","left","width","height","fontSize"]);
6260 this.originalTop
=this.element
.offsetTop
;
6261 this.originalLeft
=this.element
.offsetLeft
;
6262 var _653
=MochiKit
.Style
.getStyle(this.element
,"font-size")||"100%";
6263 ma(b(function(_654
){
6264 if(_653
.indexOf(_654
)>0){
6265 this.fontSize
=parseFloat(_653
);
6266 this.fontSizeType
=_654
;
6268 },this),["em","px","%"]);
6269 this.factor
=(this.options
.scaleTo
-this.options
.scaleFrom
)/100;
6270 if(/^content/.test(this.options
.scaleMode
)){
6271 this.dims
=[this.element
.scrollHeight
,this.element
.scrollWidth
];
6273 if(this.options
.scaleMode
=="box"){
6274 this.dims
=[this.element
.offsetHeight
,this.element
.offsetWidth
];
6276 this.dims
=[this.options
.scaleMode
.originalHeight
,this.options
.scaleMode
.originalWidth
];
6279 },update
:function(_655
){
6280 var _656
=(this.options
.scaleFrom
/100)+(this.factor
*_655
);
6281 if(this.options
.scaleContent
&&this.fontSize
){
6282 MochiKit
.Style
.setStyle(this.element
,{fontSize
:this.fontSize
*_656
+this.fontSizeType
});
6284 this.setDimensions(this.dims
[0]*_656
,this.dims
[1]*_656
);
6285 },finish
:function(){
6286 if(this.restoreAfterFinish
){
6287 MochiKit
.Style
.setStyle(this.element
,this.originalStyle
);
6289 },setDimensions
:function(_657
,_658
){
6292 if(/MSIE/.test(navigator
.userAgent
)){
6295 if(this.options
.scaleX
){
6296 d
.width
=r(_658
)+"px";
6298 if(this.options
.scaleY
){
6299 d
.height
=r(_657
)+"px";
6301 if(this.options
.scaleFromCenter
){
6302 var topd
=(_657
-this.dims
[0])/2;
6303 var _65c
=(_658
-this.dims
[1])/2;
6304 if(this.elementPositioning
=="absolute"){
6305 if(this.options
.scaleY
){
6306 d
.top
=this.originalTop
-topd
+"px";
6308 if(this.options
.scaleX
){
6309 d
.left
=this.originalLeft
-_65c
+"px";
6312 if(this.options
.scaleY
){
6315 if(this.options
.scaleX
){
6320 MochiKit
.Style
.setStyle(this.element
,d
);
6322 MochiKit
.Visual
.Highlight
=function(_65d
,_65e
){
6323 var cls
=arguments
.callee
;
6324 if(!(this instanceof cls
)){
6325 return new cls(_65d
,_65e
);
6327 this.__init__(_65d
,_65e
);
6329 MochiKit
.Visual
.Highlight
.prototype=new MochiKit
.Visual
.Base();
6330 MochiKit
.Base
.update(MochiKit
.Visual
.Highlight
.prototype,{__class__
:MochiKit
.Visual
.Highlight
,__init__
:function(_660
,_661
){
6331 this.element
=MochiKit
.DOM
.getElement(_660
);
6332 _661
=MochiKit
.Base
.update({startcolor
:"#ffff99"},_661
||{});
6335 var b
=MochiKit
.Base
;
6336 var s
=MochiKit
.Style
;
6337 if(s
.getStyle(this.element
,"display")=="none"){
6341 this.oldStyle
={backgroundImage
:s
.getStyle(this.element
,"background-image")};
6342 s
.setStyle(this.element
,{backgroundImage
:"none"});
6343 if(!this.options
.endcolor
){
6344 this.options
.endcolor
=MochiKit
.Color
.Color
.fromBackground(this.element
).toHexString();
6346 if(b
.isUndefinedOrNull(this.options
.restorecolor
)){
6347 this.options
.restorecolor
=s
.getStyle(this.element
,"background-color");
6349 this._base
=b
.map(b
.bind(function(i
){
6350 return parseInt(this.options
.startcolor
.slice(i
*2+1,i
*2+3),16);
6352 this._delta
=b
.map(b
.bind(function(i
){
6353 return parseInt(this.options
.endcolor
.slice(i
*2+1,i
*2+3),16)-this._base
[i
];
6355 },update
:function(_666
){
6357 MochiKit
.Base
.map(MochiKit
.Base
.bind(function(i
){
6358 m
+=MochiKit
.Color
.toColorPart(Math
.round(this._base
[i
]+this._delta
[i
]*_666
));
6360 MochiKit
.Style
.setStyle(this.element
,{backgroundColor
:m
});
6361 },finish
:function(){
6362 MochiKit
.Style
.setStyle(this.element
,MochiKit
.Base
.update(this.oldStyle
,{backgroundColor
:this.options
.restorecolor
}));
6364 MochiKit
.Visual
.ScrollTo
=function(_669
,_66a
){
6365 var cls
=arguments
.callee
;
6366 if(!(this instanceof cls
)){
6367 return new cls(_669
,_66a
);
6369 this.__init__(_669
,_66a
);
6371 MochiKit
.Visual
.ScrollTo
.prototype=new MochiKit
.Visual
.Base();
6372 MochiKit
.Base
.update(MochiKit
.Visual
.ScrollTo
.prototype,{__class__
:MochiKit
.Visual
.ScrollTo
,__init__
:function(_66c
,_66d
){
6373 this.element
=MochiKit
.DOM
.getElement(_66c
);
6374 this.start(_66d
||{});
6376 var p
=MochiKit
.Position
;
6378 var _66f
=p
.cumulativeOffset(this.element
);
6379 if(this.options
.offset
){
6380 _66f
.y
+=this.options
.offset
;
6383 if(window
.innerHeight
){
6384 max
=window
.innerHeight
-window
.height
;
6386 if(document
.documentElement
&&document
.documentElement
.clientHeight
){
6387 max
=document
.documentElement
.clientHeight
-document
.body
.scrollHeight
;
6390 max
=document
.body
.clientHeight
-document
.body
.scrollHeight
;
6394 this.scrollStart
=p
.windowOffset
.y
;
6395 this.delta
=(_66f
.y
>max
?max
:_66f
.y
)-this.scrollStart
;
6396 },update
:function(_671
){
6397 var p
=MochiKit
.Position
;
6399 window
.scrollTo(p
.windowOffset
.x
,this.scrollStart
+(_671
*this.delta
));
6401 MochiKit
.Visual
.CSS_LENGTH
=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
6402 MochiKit
.Visual
.Morph
=function(_673
,_674
){
6403 var cls
=arguments
.callee
;
6404 if(!(this instanceof cls
)){
6405 return new cls(_673
,_674
);
6407 this.__init__(_673
,_674
);
6409 MochiKit
.Visual
.Morph
.prototype=new MochiKit
.Visual
.Base();
6410 MochiKit
.Base
.update(MochiKit
.Visual
.Morph
.prototype,{__class__
:MochiKit
.Visual
.Morph
,__init__
:function(_676
,_677
){
6411 this.element
=MochiKit
.DOM
.getElement(_676
);
6412 this.start(_677
||{});
6414 var b
=MochiKit
.Base
;
6415 var _679
=this.options
.style
;
6423 if(MochiKit
.Visual
.CSS_LENGTH
.test(_67a
)){
6424 var _67d
=_67a
.match(/^([\+\-]?[0-9\.]+)(.*)$/);
6425 _67a
=parseFloat(_67d
[1]);
6426 unit
=(_67d
.length
==3)?_67d
[2]:null;
6427 this.styleEnd
[s
]=_67a
;
6429 _67a
=MochiKit
.Style
.getStyle(this.element
,s
);
6430 _67d
=_67a
.match(/^([\+\-]?[0-9\.]+)(.*)$/);
6431 _67a
=parseFloat(_67d
[1]);
6432 this.styleStart
[s
]=_67a
;
6434 var c
=MochiKit
.Color
.Color
;
6435 _67a
=c
.fromString(_67a
);
6437 this.units
[s
]="color";
6438 this.styleEnd
[s
]=_67a
.toHexString();
6439 _67a
=MochiKit
.Style
.getStyle(this.element
,s
);
6440 this.styleStart
[s
]=c
.fromString(_67a
).toHexString();
6441 this.styleStart
[s
]=b
.map(b
.bind(function(i
){
6442 return parseInt(this.styleStart
[s
].slice(i
*2+1,i
*2+3),16);
6444 this.styleEnd
[s
]=b
.map(b
.bind(function(i
){
6445 return parseInt(this.styleEnd
[s
].slice(i
*2+1,i
*2+3),16);
6450 },update
:function(_681
){
6452 for(var s
in this.styleStart
){
6453 if(this.units
[s
]=="color"){
6455 var _685
=this.styleStart
[s
];
6456 var end
=this.styleEnd
[s
];
6457 MochiKit
.Base
.map(MochiKit
.Base
.bind(function(i
){
6458 m
+=MochiKit
.Color
.toColorPart(Math
.round(_685
[i
]+(end
[i
]-_685
[i
])*_681
));
6460 this.element
.style
[s
]=m
;
6462 _682
=this.styleStart
[s
]+Math
.round((this.styleEnd
[s
]-this.styleStart
[s
])*_681
*1000)/1000+this.units
[s
];
6463 this.element
.style
[s
]=_682
;
6467 MochiKit
.Visual
.fade
=function(_688
,_689
){
6468 var s
=MochiKit
.Style
;
6469 var _68b
=s
.getStyle(_688
,"opacity");
6470 _689
=MochiKit
.Base
.update({from
:s
.getStyle(_688
,"opacity")||1,to
:0,afterFinishInternal
:function(_68c
){
6471 if(_68c
.options
.to
!==0){
6474 s
.hideElement(_68c
.element
);
6475 s
.setStyle(_68c
.element
,{"opacity":_68b
});
6477 return new MochiKit
.Visual
.Opacity(_688
,_689
);
6479 MochiKit
.Visual
.appear
=function(_68d
,_68e
){
6480 var s
=MochiKit
.Style
;
6481 var v
=MochiKit
.Visual
;
6482 _68e
=MochiKit
.Base
.update({from
:(s
.getStyle(_68d
,"display")=="none"?0:s
.getStyle(_68d
,"opacity")||0),to
:1,afterFinishInternal
:function(_691
){
6483 v
.forceRerendering(_691
.element
);
6484 },beforeSetupInternal
:function(_692
){
6485 s
.setStyle(_692
.element
,{"opacity":_692
.options
.from
});
6486 s
.showElement(_692
.element
);
6488 return new v
.Opacity(_68d
,_68e
);
6490 MochiKit
.Visual
.puff
=function(_693
,_694
){
6491 var s
=MochiKit
.Style
;
6492 var v
=MochiKit
.Visual
;
6493 _693
=MochiKit
.DOM
.getElement(_693
);
6494 var _697
={position
:s
.getStyle(_693
,"position"),top
:_693
.style
.top
,left
:_693
.style
.left
,width
:_693
.style
.width
,height
:_693
.style
.height
,opacity
:s
.getStyle(_693
,"opacity")};
6495 _694
=MochiKit
.Base
.update({beforeSetupInternal
:function(_698
){
6496 MochiKit
.Position
.absolutize(_698
.effects
[0].element
);
6497 },afterFinishInternal
:function(_699
){
6498 s
.hideElement(_699
.effects
[0].element
);
6499 s
.setStyle(_699
.effects
[0].element
,_697
);
6500 },scaleContent
:true,scaleFromCenter
:true},_694
||{});
6501 return new v
.Parallel([new v
.Scale(_693
,200,{sync
:true,scaleFromCenter
:_694
.scaleFromCenter
,scaleContent
:_694
.scaleContent
,restoreAfterFinish
:true}),new v
.Opacity(_693
,{sync
:true,to
:0})],_694
);
6503 MochiKit
.Visual
.blindUp
=function(_69a
,_69b
){
6505 _69a
=d
.getElement(_69a
);
6506 var _69d
=d
.makeClipping(_69a
);
6507 _69b
=MochiKit
.Base
.update({scaleContent
:false,scaleX
:false,restoreAfterFinish
:true,afterFinishInternal
:function(_69e
){
6508 MochiKit
.Style
.hideElement(_69e
.element
);
6509 d
.undoClipping(_69e
.element
,_69d
);
6511 return new MochiKit
.Visual
.Scale(_69a
,0,_69b
);
6513 MochiKit
.Visual
.blindDown
=function(_69f
,_6a0
){
6515 var s
=MochiKit
.Style
;
6516 _69f
=d
.getElement(_69f
);
6517 var _6a3
=s
.getElementDimensions(_69f
);
6519 _6a0
=MochiKit
.Base
.update({scaleContent
:false,scaleX
:false,scaleFrom
:0,scaleMode
:{originalHeight
:_6a3
.h
,originalWidth
:_6a3
.w
},restoreAfterFinish
:true,afterSetupInternal
:function(_6a5
){
6520 _6a4
=d
.makeClipping(_6a5
.element
);
6521 s
.setStyle(_6a5
.element
,{height
:"0px"});
6522 s
.showElement(_6a5
.element
);
6523 },afterFinishInternal
:function(_6a6
){
6524 d
.undoClipping(_6a6
.element
,_6a4
);
6526 return new MochiKit
.Visual
.Scale(_69f
,100,_6a0
);
6528 MochiKit
.Visual
.switchOff
=function(_6a7
,_6a8
){
6530 _6a7
=d
.getElement(_6a7
);
6531 var _6aa
=MochiKit
.Style
.getStyle(_6a7
,"opacity");
6533 _6a8
=MochiKit
.Base
.update({duration
:0.3,scaleFromCenter
:true,scaleX
:false,scaleContent
:false,restoreAfterFinish
:true,beforeSetupInternal
:function(_6ac
){
6534 d
.makePositioned(_6ac
.element
);
6535 _6ab
=d
.makeClipping(_6ac
.element
);
6536 },afterFinishInternal
:function(_6ad
){
6537 MochiKit
.Style
.hideElement(_6ad
.element
);
6538 d
.undoClipping(_6ad
.element
,_6ab
);
6539 d
.undoPositioned(_6ad
.element
);
6540 MochiKit
.Style
.setStyle(_6ad
.element
,{"opacity":_6aa
});
6542 var v
=MochiKit
.Visual
;
6543 return new v
.appear(_6a7
,{duration
:0.4,from
:0,transition
:v
.Transitions
.flicker
,afterFinishInternal
:function(_6af
){
6544 new v
.Scale(_6af
.element
,1,_6a8
);
6547 MochiKit
.Visual
.dropOut
=function(_6b0
,_6b1
){
6549 var s
=MochiKit
.Style
;
6550 _6b0
=d
.getElement(_6b0
);
6551 var _6b4
={top
:s
.getStyle(_6b0
,"top"),left
:s
.getStyle(_6b0
,"left"),opacity
:s
.getStyle(_6b0
,"opacity")};
6552 _6b1
=MochiKit
.Base
.update({duration
:0.5,distance
:100,beforeSetupInternal
:function(_6b5
){
6553 d
.makePositioned(_6b5
.effects
[0].element
);
6554 },afterFinishInternal
:function(_6b6
){
6555 s
.hideElement(_6b6
.effects
[0].element
);
6556 d
.undoPositioned(_6b6
.effects
[0].element
);
6557 s
.setStyle(_6b6
.effects
[0].element
,_6b4
);
6559 var v
=MochiKit
.Visual
;
6560 return new v
.Parallel([new v
.Move(_6b0
,{x
:0,y
:_6b1
.distance
,sync
:true}),new v
.Opacity(_6b0
,{sync
:true,to
:0})],_6b1
);
6562 MochiKit
.Visual
.shake
=function(_6b8
,_6b9
){
6564 var v
=MochiKit
.Visual
;
6565 var s
=MochiKit
.Style
;
6566 _6b8
=d
.getElement(_6b8
);
6567 _6b9
=MochiKit
.Base
.update({x
:-20,y
:0,duration
:0.05,afterFinishInternal
:function(_6bd
){
6568 d
.undoPositioned(_6bd
.element
);
6569 s
.setStyle(_6bd
.element
,_6be
);
6571 var _6be
={top
:s
.getStyle(_6b8
,"top"),left
:s
.getStyle(_6b8
,"left")};
6572 return new v
.Move(_6b8
,{x
:20,y
:0,duration
:0.05,afterFinishInternal
:function(_6bf
){
6573 new v
.Move(_6bf
.element
,{x
:-40,y
:0,duration
:0.1,afterFinishInternal
:function(_6c0
){
6574 new v
.Move(_6c0
.element
,{x
:40,y
:0,duration
:0.1,afterFinishInternal
:function(_6c1
){
6575 new v
.Move(_6c1
.element
,{x
:-40,y
:0,duration
:0.1,afterFinishInternal
:function(_6c2
){
6576 new v
.Move(_6c2
.element
,{x
:40,y
:0,duration
:0.1,afterFinishInternal
:function(_6c3
){
6577 new v
.Move(_6c3
.element
,_6b9
);
6584 MochiKit
.Visual
.slideDown
=function(_6c4
,_6c5
){
6586 var b
=MochiKit
.Base
;
6587 var s
=MochiKit
.Style
;
6588 _6c4
=d
.getElement(_6c4
);
6589 if(!_6c4
.firstChild
){
6590 throw "MochiKit.Visual.slideDown must be used on a element with a child";
6592 d
.removeEmptyTextNodes(_6c4
);
6593 var _6c9
=s
.getStyle(_6c4
.firstChild
,"bottom")||0;
6594 var _6ca
=s
.getElementDimensions(_6c4
);
6596 _6c5
=b
.update({scaleContent
:false,scaleX
:false,scaleFrom
:0,scaleMode
:{originalHeight
:_6ca
.h
,originalWidth
:_6ca
.w
},restoreAfterFinish
:true,afterSetupInternal
:function(_6cc
){
6597 d
.makePositioned(_6cc
.element
);
6598 d
.makePositioned(_6cc
.element
.firstChild
);
6599 if(/Opera/.test(navigator
.userAgent
)){
6600 s
.setStyle(_6cc
.element
,{top
:""});
6602 _6cb
=d
.makeClipping(_6cc
.element
);
6603 s
.setStyle(_6cc
.element
,{height
:"0px"});
6604 s
.showElement(_6cc
.element
);
6605 },afterUpdateInternal
:function(_6cd
){
6606 s
.setStyle(_6cd
.element
.firstChild
,{bottom
:(_6cd
.dims
[0]-_6cd
.element
.clientHeight
)+"px"});
6607 },afterFinishInternal
:function(_6ce
){
6608 d
.undoClipping(_6ce
.element
,_6cb
);
6609 if(/MSIE/.test(navigator
.userAgent
)){
6610 d
.undoPositioned(_6ce
.element
);
6611 d
.undoPositioned(_6ce
.element
.firstChild
);
6613 d
.undoPositioned(_6ce
.element
.firstChild
);
6614 d
.undoPositioned(_6ce
.element
);
6616 s
.setStyle(_6ce
.element
.firstChild
,{bottom
:_6c9
});
6618 return new MochiKit
.Visual
.Scale(_6c4
,100,_6c5
);
6620 MochiKit
.Visual
.slideUp
=function(_6cf
,_6d0
){
6622 var b
=MochiKit
.Base
;
6623 var s
=MochiKit
.Style
;
6624 _6cf
=d
.getElement(_6cf
);
6625 if(!_6cf
.firstChild
){
6626 throw "MochiKit.Visual.slideUp must be used on a element with a child";
6628 d
.removeEmptyTextNodes(_6cf
);
6629 var _6d4
=s
.getStyle(_6cf
.firstChild
,"bottom");
6631 _6d0
=b
.update({scaleContent
:false,scaleX
:false,scaleMode
:"box",scaleFrom
:100,restoreAfterFinish
:true,beforeStartInternal
:function(_6d6
){
6632 d
.makePositioned(_6d6
.element
);
6633 d
.makePositioned(_6d6
.element
.firstChild
);
6634 if(/Opera/.test(navigator
.userAgent
)){
6635 s
.setStyle(_6d6
.element
,{top
:""});
6637 _6d5
=d
.makeClipping(_6d6
.element
);
6638 s
.showElement(_6d6
.element
);
6639 },afterUpdateInternal
:function(_6d7
){
6640 s
.setStyle(_6d7
.element
.firstChild
,{bottom
:(_6d7
.dims
[0]-_6d7
.element
.clientHeight
)+"px"});
6641 },afterFinishInternal
:function(_6d8
){
6642 s
.hideElement(_6d8
.element
);
6643 d
.undoClipping(_6d8
.element
,_6d5
);
6644 d
.undoPositioned(_6d8
.element
.firstChild
);
6645 d
.undoPositioned(_6d8
.element
);
6646 s
.setStyle(_6d8
.element
.firstChild
,{bottom
:_6d4
});
6648 return new MochiKit
.Visual
.Scale(_6cf
,0,_6d0
);
6650 MochiKit
.Visual
.squish
=function(_6d9
,_6da
){
6652 var b
=MochiKit
.Base
;
6654 _6da
=b
.update({restoreAfterFinish
:true,beforeSetupInternal
:function(_6de
){
6655 _6dd
=d
.makeClipping(_6de
.element
);
6656 },afterFinishInternal
:function(_6df
){
6657 MochiKit
.Style
.hideElement(_6df
.element
);
6658 d
.undoClipping(_6df
.element
,_6dd
);
6660 return new MochiKit
.Visual
.Scale(_6d9
,/Opera/.test(navigator
.userAgent
)?1:0,_6da
);
6662 MochiKit
.Visual
.grow
=function(_6e0
,_6e1
){
6664 var v
=MochiKit
.Visual
;
6665 var s
=MochiKit
.Style
;
6666 _6e0
=d
.getElement(_6e0
);
6667 _6e1
=MochiKit
.Base
.update({direction
:"center",moveTransition
:v
.Transitions
.sinoidal
,scaleTransition
:v
.Transitions
.sinoidal
,opacityTransition
:v
.Transitions
.full
,scaleContent
:true,scaleFromCenter
:false},_6e1
||{});
6668 var _6e5
={top
:_6e0
.style
.top
,left
:_6e0
.style
.left
,height
:_6e0
.style
.height
,width
:_6e0
.style
.width
,opacity
:s
.getStyle(_6e0
,"opacity")};
6669 var dims
=s
.getElementDimensions(_6e0
);
6672 switch(_6e1
.direction
){
6674 _6e7
=_6e8
=_6e9
=_6ea
=0;
6686 case "bottom-right":
6699 var _6eb
=MochiKit
.Base
.update({beforeSetupInternal
:function(_6ec
){
6700 s
.setStyle(_6ec
.effects
[0].element
,{height
:"0px"});
6701 s
.showElement(_6ec
.effects
[0].element
);
6702 },afterFinishInternal
:function(_6ed
){
6703 d
.undoClipping(_6ed
.effects
[0].element
);
6704 d
.undoPositioned(_6ed
.effects
[0].element
);
6705 s
.setStyle(_6ed
.effects
[0].element
,_6e5
);
6707 return new v
.Move(_6e0
,{x
:_6e7
,y
:_6e8
,duration
:0.01,beforeSetupInternal
:function(_6ee
){
6708 s
.hideElement(_6ee
.element
);
6709 d
.makeClipping(_6ee
.element
);
6710 d
.makePositioned(_6ee
.element
);
6711 },afterFinishInternal
:function(_6ef
){
6712 new v
.Parallel([new v
.Opacity(_6ef
.element
,{sync
:true,to
:1,from
:0,transition
:_6e1
.opacityTransition
}),new v
.Move(_6ef
.element
,{x
:_6e9
,y
:_6ea
,sync
:true,transition
:_6e1
.moveTransition
}),new v
.Scale(_6ef
.element
,100,{scaleMode
:{originalHeight
:dims
.h
,originalWidth
:dims
.w
},sync
:true,scaleFrom
:/Opera/.test(navigator
.userAgent
)?1:0,transition
:_6e1
.scaleTransition
,scaleContent
:_6e1
.scaleContent
,scaleFromCenter
:_6e1
.scaleFromCenter
,restoreAfterFinish
:true})],_6eb
);
6715 MochiKit
.Visual
.shrink
=function(_6f0
,_6f1
){
6717 var v
=MochiKit
.Visual
;
6718 var s
=MochiKit
.Style
;
6719 _6f0
=d
.getElement(_6f0
);
6720 _6f1
=MochiKit
.Base
.update({direction
:"center",moveTransition
:v
.Transitions
.sinoidal
,scaleTransition
:v
.Transitions
.sinoidal
,opacityTransition
:v
.Transitions
.none
,scaleContent
:true,scaleFromCenter
:false},_6f1
||{});
6721 var _6f5
={top
:_6f0
.style
.top
,left
:_6f0
.style
.left
,height
:_6f0
.style
.height
,width
:_6f0
.style
.width
,opacity
:s
.getStyle(_6f0
,"opacity")};
6722 var dims
=s
.getElementDimensions(_6f0
);
6724 switch(_6f1
.direction
){
6736 case "bottom-right":
6746 var _6fa
=MochiKit
.Base
.update({beforeStartInternal
:function(_6fb
){
6747 _6f9
=d
.makePositioned(_6fb
.effects
[0].element
);
6748 d
.makeClipping(_6fb
.effects
[0].element
);
6749 },afterFinishInternal
:function(_6fc
){
6750 s
.hideElement(_6fc
.effects
[0].element
);
6751 d
.undoClipping(_6fc
.effects
[0].element
,_6f9
);
6752 d
.undoPositioned(_6fc
.effects
[0].element
);
6753 s
.setStyle(_6fc
.effects
[0].element
,_6f5
);
6755 return new v
.Parallel([new v
.Opacity(_6f0
,{sync
:true,to
:0,from
:1,transition
:_6f1
.opacityTransition
}),new v
.Scale(_6f0
,/Opera/.test(navigator
.userAgent
)?1:0,{sync
:true,transition
:_6f1
.scaleTransition
,scaleContent
:_6f1
.scaleContent
,scaleFromCenter
:_6f1
.scaleFromCenter
,restoreAfterFinish
:true}),new v
.Move(_6f0
,{x
:_6f7
,y
:_6f8
,sync
:true,transition
:_6f1
.moveTransition
})],_6fa
);
6757 MochiKit
.Visual
.pulsate
=function(_6fd
,_6fe
){
6759 var v
=MochiKit
.Visual
;
6760 var b
=MochiKit
.Base
;
6761 var _702
=MochiKit
.Style
.getStyle(_6fd
,"opacity");
6762 _6fe
=b
.update({duration
:3,from
:0,afterFinishInternal
:function(_703
){
6763 MochiKit
.Style
.setStyle(_703
.element
,{"opacity":_702
});
6765 var _704
=_6fe
.transition
||v
.Transitions
.sinoidal
;
6766 var _705
=b
.bind(function(pos
){
6767 return _704(1-v
.Transitions
.pulse(pos
,_6fe
.pulses
));
6770 return new v
.Opacity(_6fd
,b
.update({transition
:_705
},_6fe
));
6772 MochiKit
.Visual
.fold
=function(_707
,_708
){
6774 var v
=MochiKit
.Visual
;
6775 var s
=MochiKit
.Style
;
6776 _707
=d
.getElement(_707
);
6777 var _70c
={top
:_707
.style
.top
,left
:_707
.style
.left
,width
:_707
.style
.width
,height
:_707
.style
.height
};
6778 var _70d
=d
.makeClipping(_707
);
6779 _708
=MochiKit
.Base
.update({scaleContent
:false,scaleX
:false,afterFinishInternal
:function(_70e
){
6780 new v
.Scale(_707
,1,{scaleContent
:false,scaleY
:false,afterFinishInternal
:function(_70f
){
6781 s
.hideElement(_70f
.element
);
6782 d
.undoClipping(_70f
.element
,_70d
);
6783 s
.setStyle(_70f
.element
,_70c
);
6786 return new v
.Scale(_707
,5,_708
);
6788 MochiKit
.Visual
.Color
=MochiKit
.Color
.Color
;
6789 MochiKit
.Visual
.getElementsComputedStyle
=MochiKit
.DOM
.computedStyle
;
6790 MochiKit
.Visual
.__new__
=function(){
6791 var m
=MochiKit
.Base
;
6792 m
.nameFunctions(this);
6793 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
6795 MochiKit
.Visual
.EXPORT
=["roundElement","roundClass","tagifyText","multiple","toggle","Parallel","Opacity","Move","Scale","Highlight","ScrollTo","Morph","fade","appear","puff","blindUp","blindDown","switchOff","dropOut","shake","slideDown","slideUp","squish","grow","shrink","pulsate","fold"];
6796 MochiKit
.Visual
.EXPORT_OK
=["Base","PAIRS"];
6797 MochiKit
.Visual
.__new__();
6798 MochiKit
.Base
._exportSymbols(this,MochiKit
.Visual
);
6799 if(typeof (MochiKit
)=="undefined"){
6802 if(typeof (MochiKit
.MochiKit
)=="undefined"){
6803 MochiKit
.MochiKit
={};
6805 MochiKit
.MochiKit
.NAME
="MochiKit.MochiKit";
6806 MochiKit
.MochiKit
.VERSION
="1.4";
6807 MochiKit
.MochiKit
.__repr__
=function(){
6808 return "["+this.NAME
+" "+this.VERSION
+"]";
6810 MochiKit
.MochiKit
.toString
=function(){
6811 return this.__repr__();
6813 MochiKit
.MochiKit
.SUBMODULES
=["Base","Iter","Logging","DateTime","Format","Async","DOM","Selector","Style","LoggingPane","Color","Signal","Position","Visual"];
6814 if(typeof (JSAN
)!="undefined"||typeof (dojo
)!="undefined"){
6815 if(typeof (dojo
)!="undefined"){
6816 dojo
.provide("MochiKit.MochiKit");
6817 dojo
.require("MochiKit.*");
6819 if(typeof (JSAN
)!="undefined"){
6821 for(var i
=0;i
<lst
.length
;i
++){
6822 JSAN
.use("MochiKit."+lst
[i
],[]);
6824 })(MochiKit
.MochiKit
.SUBMODULES
);
6827 var _713
=MochiKit
.Base
.extend
;
6828 var self
=MochiKit
.MochiKit
;
6829 var _715
=self
.SUBMODULES
;
6834 for(i
=0;i
<_715
.length
;i
++){
6835 m
=MochiKit
[_715
[i
]];
6836 _713(_716
,m
.EXPORT
);
6837 _713(_717
,m
.EXPORT_OK
);
6838 for(k
in m
.EXPORT_TAGS
){
6839 _718
[k
]=_713(_718
[k
],m
.EXPORT_TAGS
[k
]);
6841 all
=m
.EXPORT_TAGS
[":all"];
6843 all
=_713(null,m
.EXPORT
,m
.EXPORT_OK
);
6846 for(j
=0;j
<all
.length
;j
++){
6852 self
.EXPORT_OK
=_717
;
6853 self
.EXPORT_TAGS
=_718
;
6856 if(typeof (MochiKit
.__compat__
)=="undefined"){
6857 MochiKit
.__compat__
=true;
6860 if(typeof (document
)=="undefined"){
6863 var _71e
=document
.getElementsByTagName("script");
6864 var _71f
="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
6869 for(i
=0;i
<_71e
.length
;i
++){
6870 var src
=_71e
[i
].getAttribute("src");
6875 if(src
.match(/MochiKit.js$/)){
6876 base
=src
.substring(0,src
.lastIndexOf("MochiKit.js"));
6883 var _725
=MochiKit
.MochiKit
.SUBMODULES
;
6884 for(var i
=0;i
<_725
.length
;i
++){
6885 if(MochiKit
[_725
[i
]]){
6888 var uri
=base
+_725
[i
]+".js";
6892 if(document
.documentElement
&&document
.documentElement
.namespaceURI
==_71f
){
6893 var s
=document
.createElementNS(_71f
,"script");
6894 s
.setAttribute("id","MochiKit_"+base
+_725
[i
]);
6895 s
.setAttribute("src",uri
);
6896 s
.setAttribute("type","application/x-javascript");
6897 _721
.parentNode
.appendChild(s
);
6899 document
.write("<script src=\""+uri
+"\" type=\"text/javascript\"></script>");
6908 PlotKit.PlotKit 0.9.1 : PACKED VERSION
6910 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
6911 diff against the source tree, not this file.
6913 For more information, <http://www.liquidx.net/plotkit/>.
6915 Copyright (c) 2006. Alastair Tse.
6920 if(typeof (MochiKit
.Base
)=="undefined"||typeof (MochiKit
.DOM
)=="undefined"||typeof (MochiKit
.Color
)=="undefined"||typeof (MochiKit
.Format
)=="undefined"){
6925 throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format}";
6927 MochiKit
.Base
.update(MochiKit
.Color
.Color
.prototype,{asFillColor
:function(){
6928 return this.lighterColorWithLevel(0.3);
6929 },asStrokeColor
:function(){
6930 return this.darkerColorWithLevel(0.1);
6931 },asPointColor
:function(){
6932 return this.lighterColorWithLevel(0.1);
6934 if(typeof (PlotKit
)=="undefined"){
6937 PlotKit
.NAME
="PlotKit";
6938 PlotKit
.VERSION
="0.8";
6939 PlotKit
.__repr__
=function(){
6940 return "["+this.NAME
+" "+this.VERSION
+"]";
6942 PlotKit
.toString
=function(){
6943 return this.__repr__();
6945 if(typeof (PlotKit
.Base
)=="undefined"){
6948 PlotKit
.Base
.NAME
="PlotKit.Base";
6949 PlotKit
.Base
.VERSION
=PlotKit
.VERSION
;
6950 PlotKit
.Base
.__repr__
=function(){
6951 return "["+this.NAME
+" "+this.VERSION
+"]";
6953 PlotKit
.Base
.toString
=function(){
6954 return this.__repr__();
6956 PlotKit
.Base
.usingPrototype
=function(){
6958 return (typeof (Object
.extend
)=="function");
6964 MochiKit
.Base
.update(PlotKit
.Base
,{roundInterval
:function(_1
,_2
,_3
){
6965 var _4
=MochiKit
.Format
.roundToFixed
;
6967 return parseFloat(_4(_5
,_3
));
6968 },collapse
:function(_6
){
6969 var m
=MochiKit
.Base
;
6971 for(var i
=0;i
<_6
.length
;i
++){
6972 _8
=m
.concat(_8
,_6
[i
]);
6974 if(PlotKit
.Base
.usingPrototype()){
6980 },uniq
:function(_10
){
6981 var m
=MochiKit
.Base
;
6982 if(!m
.isArrayLike(_10
)||(_10
.length
<1)){
6985 var _11
=new Array();
6988 for(var i
=1;i
<_10
.length
;i
++){
6989 if(m
.compare(_10
[i
],_12
)!=0){
6995 },colorScheme
:function(){
6996 var mb
=MochiKit
.Base
;
6997 var mc
=MochiKit
.Color
;
6998 var _15
=["red","orange","yellow","green","cyan","blue","purple","magenta"];
6999 var _16
=function(_17
){
7000 return mc
.Color
[_17
+"Color"]();
7002 return mb
.map(_16
,_15
);
7003 },baseDarkPrimaryColors
:function(){
7004 var _18
=MochiKit
.Color
.Color
.fromHexString
;
7005 return [_18("#ad3f40"),_18("#ddac2c"),_18("#dfdd0c"),_18("#5276c4"),_18("#739c5a")];
7006 },basePrimaryColors
:function(){
7007 var _19
=MochiKit
.Color
.Color
.fromHexString
;
7008 return [_19("#d24c4d"),_19("#f2b32f"),_19("#ece90e"),_19("#5d83da"),_19("#78a15d")];
7009 },baseBlueColors
:function(){
7010 var _20
=MochiKit
.Color
.Color
.fromHexString
;
7011 return [_20("#4b6b94"),_20("#5d81b4"),_20("#acbad2")];
7012 },palette
:function(_21
,_22
,_23
,_24
){
7013 var _25
=MochiKit
.Base
.isUndefinedOrNull
;
7014 var _26
=new Array();
7029 var _28
=function(_29
,_30
){
7030 return _29
.lighterColorWithLevel(_30
);
7032 return MochiKit
.Base
.map(partial(_28
,_21
),_26
);
7033 },excanvasSupported
:function(){
7034 if(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
){
7038 },findPosX
:function(obj
){
7040 if(obj
.offsetParent
){
7041 while(obj
.offsetParent
){
7042 _32
+=obj
.offsetLeft
;
7043 obj
=obj
.offsetParent
;
7051 },findPosY
:function(obj
){
7053 if(obj
.offsetParent
){
7054 while(obj
.offsetParent
){
7056 obj
=obj
.offsetParent
;
7064 },isFuncLike
:function(obj
){
7065 return (typeof (obj
)=="function");
7067 PlotKit
.Base
.map
=function(fn
,lst
){
7068 if(PlotKit
.Base
.usingPrototype()){
7071 if(typeof (lst
[x
])=="function"){
7074 _36
.push(fn(lst
[x
]));
7078 return MochiKit
.Base
.map(fn
,lst
);
7081 PlotKit
.Base
.items
=function(lst
){
7082 if(PlotKit
.Base
.usingPrototype()){
7085 if(typeof (lst
[x
])=="function"){
7088 _38
.push([x
,lst
[x
]]);
7092 return MochiKit
.Base
.items(lst
);
7095 PlotKit
.Base
.keys
=function(lst
){
7096 if(PlotKit
.Base
.usingPrototype()){
7099 if(typeof (lst
[x
])=="function"){
7106 return MochiKit
.Base
.keys(lst
);
7109 PlotKit
.Base
.baseColors
=function(){
7110 var _40
=MochiKit
.Color
.Color
.fromHexString
;
7111 return [_40("#476fb2"),_40("#be2c2b"),_40("#85b730"),_40("#734a99"),_40("#26a1c5"),_40("#fb8707"),_40("#000000")];
7113 PlotKit
.Base
.officeBaseStyle
={"axisLineWidth":2,"axisLabelColor":Color
.grayColor(),"axisLineColor":Color
.whiteColor(),"padding":{top
:5,bottom
:10,left
:30,right
:30}};
7114 MochiKit
.Base
.update(PlotKit
.Base
,{officeBlue
:function(){
7115 var r
={"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[0]),"backgroundColor":PlotKit
.Base
.baseColors()[0].lighterColorWithLevel(0.45)};
7116 MochiKit
.Base
.update(r
,PlotKit
.Base
.officeBaseStyle
);
7118 },officeRed
:function(){
7119 var r
={"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[1]),"backgroundColor":PlotKit
.Base
.baseColors()[1].lighterColorWithLevel(0.5)};
7120 MochiKit
.Base
.update(r
,PlotKit
.Base
.officeBaseStyle
);
7122 },officeGreen
:function(){
7123 var r
={"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[2]),"backgroundColor":PlotKit
.Base
.baseColors()[2].lighterColorWithLevel(0.5)};
7124 MochiKit
.Base
.update(r
,PlotKit
.Base
.officeBaseStyle
);
7126 },officePurple
:function(){
7127 var r
={"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[3]),"backgroundColor":PlotKit
.Base
.baseColors()[3].lighterColorWithLevel(0.5)};
7128 MochiKit
.Base
.update(r
,PlotKit
.Base
.officeBaseStyle
);
7130 },officeCyan
:function(){
7131 var r
={"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[4]),"backgroundColor":PlotKit
.Base
.baseColors()[4].lighterColorWithLevel(0.5)};
7132 MochiKit
.Base
.update(r
,PlotKit
.Base
.officeBaseStyle
);
7134 },officeOrange
:function(){
7135 var r
={"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[5]),"backgroundColor":PlotKit
.Base
.baseColors()[5].lighterColorWithLevel(0.4)};
7136 MochiKit
.Base
.update(r
,PlotKit
.Base
.officeBaseStyle
);
7138 },officeBlack
:function(){
7139 var r
={"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[6],0,0.6),"backgroundColor":PlotKit
.Base
.baseColors()[6].lighterColorWithLevel(0.9)};
7140 MochiKit
.Base
.update(r
,PlotKit
.Base
.officeBaseStyle
);
7143 PlotKit
.Base
.EXPORT
=["baseColors","collapse","colorScheme","findPosX","findPosY","officeBaseStyle","officeBlue","officeRed","officeGreen","officePurple","officeCyan","officeOrange","officeBlack","roundInterval","uniq","isFuncLike","excanvasSupported"];
7144 PlotKit
.Base
.EXPORT_OK
=[];
7145 PlotKit
.Base
.__new__
=function(){
7146 var m
=MochiKit
.Base
;
7147 m
.nameFunctions(this);
7148 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
7150 PlotKit
.Base
.__new__();
7151 MochiKit
.Base
._exportSymbols(this,PlotKit
.Base
);
7153 if(typeof (PlotKit
.Base
)=="undefined"){
7158 throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Base";
7160 if(typeof (PlotKit
.Layout
)=="undefined"){
7163 PlotKit
.Layout
.NAME
="PlotKit.Layout";
7164 PlotKit
.Layout
.VERSION
=PlotKit
.VERSION
;
7165 PlotKit
.Layout
.__repr__
=function(){
7166 return "["+this.NAME
+" "+this.VERSION
+"]";
7168 PlotKit
.Layout
.toString
=function(){
7169 return this.__repr__();
7171 PlotKit
.Layout
.valid_styles
=["bar","line","pie","point"];
7172 PlotKit
.Layout
=function(_42
,_43
){
7173 this.options
={"barWidthFillFraction":0.75,"barOrientation":"vertical","xOriginIsZero":true,"yOriginIsZero":true,"xAxis":null,"yAxis":null,"xTicks":null,"yTicks":null,"xNumberOfTicks":10,"yNumberOfTicks":5,"xTickPrecision":1,"yTickPrecision":1,"pieRadius":0.4};
7175 MochiKit
.Base
.update(this.options
,_43
?_43
:{});
7176 if(!MochiKit
.Base
.isUndefinedOrNull(this.options
.xAxis
)){
7177 this.minxval
=this.options
.xAxis
[0];
7178 this.maxxval
=this.options
.xAxis
[1];
7179 this.xscale
=this.maxxval
-this.minxval
;
7185 if(!MochiKit
.Base
.isUndefinedOrNull(this.options
.yAxis
)){
7186 this.minyval
=this.options
.yAxis
[0];
7187 this.maxyval
=this.options
.yAxis
[1];
7188 this.yscale
=this.maxyval
-this.minyval
;
7194 this.bars
=new Array();
7195 this.points
=new Array();
7196 this.slices
=new Array();
7197 this.xticks
=new Array();
7198 this.yticks
=new Array();
7199 this.datasets
=new Array();
7203 this.hitTestCache
={x2maxy
:null};
7205 PlotKit
.Layout
.prototype.addDataset
=function(_44
,_45
){
7206 this.datasets
[_44
]=_45
;
7208 PlotKit
.Layout
.prototype.removeDataset
=function(_46
,_47
){
7209 delete this.datasets
[_46
];
7211 PlotKit
.Layout
.prototype.addDatasetFromTable
=function(_48
,_49
,_50
,_51
,_52
){
7212 var _53
=MochiKit
.Base
.isUndefinedOrNull
;
7213 var _54
=MochiKit
.DOM
.scrapeText
;
7214 var _55
=MochiKit
.Format
.strip
;
7224 var _56
=_49
.tBodies
[0].rows
;
7225 var _57
=new Array();
7226 var _58
=new Array();
7228 for(var i
=0;i
<_56
.length
;i
++){
7229 _57
.push([parseFloat(_55(_54(_56
[i
].cells
[_50
]))),parseFloat(_55(_54(_56
[i
].cells
[_51
])))]);
7231 _58
.push({v
:parseFloat(_55(_54(_56
[i
].cells
[_50
]))),label
:_55(_54(_56
[i
].cells
[_52
]))});
7234 this.addDataset(_48
,_57
);
7236 this.options
.xTicks
=_58
;
7242 PlotKit
.Layout
.prototype.evaluate
=function(){
7243 this._evaluateLimits();
7244 this._evaluateScales();
7245 if(this.style
=="bar"){
7246 if(this.options
.barOrientation
=="horizontal"){
7247 this._evaluateHorizBarCharts();
7249 this._evaluateBarCharts();
7251 this._evaluateBarTicks();
7253 if(this.style
=="line"){
7254 this._evaluateLineCharts();
7255 this._evaluateLineTicks();
7257 if(this.style
=="pie"){
7258 this._evaluatePieCharts();
7259 this._evaluatePieTicks();
7264 PlotKit
.Layout
.prototype.hitTest
=function(x
,y
){
7265 var f
=MochiKit
.Format
.twoDigitFloat
;
7266 if((this.style
=="bar")&&this.bars
&&(this.bars
.length
>0)){
7267 for(var i
=0;i
<this.bars
.length
;i
++){
7268 var bar
=this.bars
[i
];
7269 if((x
>=bar
.x
)&&(x
<=bar
.x
+bar
.w
)&&(y
>=bar
.y
)&&(y
-bar
.y
<=bar
.h
)){
7274 if(this.style
=="line"){
7275 if(this.hitTestCache
.x2maxy
==null){
7276 this._regenerateHitTestCache();
7278 var _62
=x
/this.xscale
;
7279 var _63
=this.hitTestCache
.xvalues
;
7282 for(var i
=1;i
<_63
.length
;i
++){
7290 var _66
=this.hitTestCache
.x2maxy
[_64
];
7291 var _67
=this.hitTestCache
.x2maxy
[_65
];
7292 var _68
=(1-y
)/this.yscale
;
7293 var _69
=(_67
-_66
)/(_65
-_64
);
7294 var _70
=_66
+_69
*(_62
-_64
);
7296 var obj
={xval
:_62
,yval
:_68
,xafter
:_65
,yafter
:_67
,xbefore
:_64
,ybefore
:_66
,yprojected
:_70
};
7301 if(this.style
=="pie"){
7302 var _71
=Math
.sqrt((y
-0.5)*(y
-0.5)+(x
-0.5)*(x
-0.5));
7303 if(_71
>this.options
.pieRadius
){
7306 var _72
=Math
.atan2(y
-0.5,x
-0.5)-Math
.PI
/2;
7307 for(var i
=0;i
<this.slices
.length
;i
++){
7308 var _73
=this.slices
[i
];
7309 if(_73
.startAngle
<_72
&&_73
.endAngle
>=_72
){
7318 PlotKit
.Layout
.prototype.rectForX
=function(x
){
7321 PlotKit
.Layout
.prototype.angleRangeForX
=function(x
){
7324 PlotKit
.Layout
.prototype._evaluateLimits
=function(){
7325 var map
=PlotKit
.Base
.map
;
7326 var _75
=PlotKit
.Base
.items
;
7327 var _76
=MochiKit
.Base
.itemgetter
;
7328 var _77
=PlotKit
.Base
.collapse
;
7329 var _78
=MochiKit
.Base
.listMin
;
7330 var _79
=MochiKit
.Base
.listMax
;
7331 var _80
=MochiKit
.Base
.isUndefinedOrNull
;
7332 var all
=_77(map(_76(1),_75(this.datasets
)));
7333 if(_80(this.options
.xAxis
)){
7334 if(this.options
.xOriginIsZero
){
7337 this.minxval
=_78(map(parseFloat
,map(_76(0),all
)));
7339 this.maxxval
=_79(map(parseFloat
,map(_76(0),all
)));
7341 this.minxval
=this.options
.xAxis
[0];
7342 this.maxxval
=this.options
.xAxis
[1];
7343 this.xscale
=this.maxval
-this.minxval
;
7345 if(_80(this.options
.yAxis
)){
7346 if(this.options
.yOriginIsZero
){
7349 this.minyval
=_78(map(parseFloat
,map(_76(1),all
)));
7351 this.maxyval
=_79(map(parseFloat
,map(_76(1),all
)));
7353 this.minyval
=this.options
.yAxis
[0];
7354 this.maxyval
=this.options
.yAxis
[1];
7355 this.yscale
=this.maxyval
-this.minyval
;
7358 PlotKit
.Layout
.prototype._evaluateScales
=function(){
7359 var _82
=MochiKit
.Base
.isUndefinedOrNull
;
7360 this.xrange
=this.maxxval
-this.minxval
;
7364 this.xscale
=1/this.xrange
;
7366 this.yrange
=this.maxyval
-this.minyval
;
7370 this.yscale
=1/this.yrange
;
7373 PlotKit
.Layout
.prototype._uniqueXValues
=function(){
7374 var _83
=PlotKit
.Base
.collapse
;
7375 var map
=PlotKit
.Base
.map
;
7376 var _84
=PlotKit
.Base
.uniq
;
7377 var _85
=MochiKit
.Base
.itemgetter
;
7378 var _86
=PlotKit
.Base
.items
;
7379 var _87
=map(parseFloat
,map(_85(0),_83(map(_85(1),_86(this.datasets
)))));
7380 _87
.sort(MochiKit
.Base
.compare
);
7383 PlotKit
.Layout
.prototype._evaluateBarCharts
=function(){
7384 var _88
=PlotKit
.Base
.items
;
7385 var _89
=_88(this.datasets
).length
;
7387 var _91
=this._uniqueXValues();
7388 for(var i
=1;i
<_91
.length
;i
++){
7389 _90
=Math
.min(Math
.abs(_91
[i
]-_91
[i
-1]),_90
);
7397 this.minxval
=_91
[0];
7398 _92
=1*this.options
.barWidthFillFraction
;
7400 _94
=(1-this.options
.barWidthFillFraction
)/2;
7408 this.xscale
=(1-_90
/this.xrange)/this.xrange
;
7411 _92
=_90
*this.xscale
*this.options
.barWidthFillFraction
;
7413 _94
=_90
*this.xscale
*(1-this.options
.barWidthFillFraction
)/2;
7416 this.bars
=new Array();
7418 for(var _95
in this.datasets
){
7419 var _96
=this.datasets
[_95
];
7420 if(PlotKit
.Base
.isFuncLike(_96
)){
7423 for(var j
=0;j
<_96
.length
;j
++){
7425 var _99
={x
:((parseFloat(_98
[0])-this.minxval
)*this.xscale
)+(i
*_93
)+_94
,y
:1-((parseFloat(_98
[1])-this.minyval
)*this.yscale
),w
:_93
,h
:((parseFloat(_98
[1])-this.minyval
)*this.yscale
),xval
:parseFloat(_98
[0]),yval
:parseFloat(_98
[1]),name
:_95
};
7426 if((_99
.x
>=0)&&(_99
.x
<=1)&&(_99
.y
>=0)&&(_99
.y
<=1)){
7427 this.bars
.push(_99
);
7433 PlotKit
.Layout
.prototype._evaluateHorizBarCharts
=function(){
7434 var _100
=PlotKit
.Base
.items
;
7435 var _101
=_100(this.datasets
).length
;
7437 var _103
=this._uniqueXValues();
7438 for(var i
=1;i
<_103
.length
;i
++){
7439 _102
=Math
.min(Math
.abs(_103
[i
]-_103
[i
-1]),_102
);
7447 this.minxval
=_103
[0];
7448 _104
=1*this.options
.barWidthFillFraction
;
7450 _106
=(1-this.options
.barWidthFillFraction
)/2;
7452 this.xscale
=(1-_102
/this.xrange)/this.xrange
;
7453 _104
=_102
*this.xscale
*this.options
.barWidthFillFraction
;
7455 _106
=_102
*this.xscale
*(1-this.options
.barWidthFillFraction
)/2;
7457 this.minxdelta
=_102
;
7458 this.bars
=new Array();
7460 for(var _107
in this.datasets
){
7461 var _108
=this.datasets
[_107
];
7462 if(PlotKit
.Base
.isFuncLike(_108
)){
7465 for(var j
=0;j
<_108
.length
;j
++){
7467 var rect
={y
:((parseFloat(item
[0])-this.minxval
)*this.xscale
)+(i
*_105
)+_106
,x
:0,h
:_105
,w
:((parseFloat(item
[1])-this.minyval
)*this.yscale
),xval
:parseFloat(item
[0]),yval
:parseFloat(item
[1]),name
:_107
};
7474 if((rect
.x
>=0)&&(rect
.x
<=1)){
7475 this.bars
.push(rect
);
7481 PlotKit
.Layout
.prototype._evaluateLineCharts
=function(){
7482 var _111
=PlotKit
.Base
.items
;
7483 var _112
=_111(this.datasets
).length
;
7484 this.points
=new Array();
7486 for(var _113
in this.datasets
){
7487 var _114
=this.datasets
[_113
];
7488 if(PlotKit
.Base
.isFuncLike(_114
)){
7491 _114
.sort(function(a
,b
){
7492 return compare(parseFloat(a
[0]),parseFloat(b
[0]));
7494 for(var j
=0;j
<_114
.length
;j
++){
7496 var _117
={x
:((parseFloat(item
[0])-this.minxval
)*this.xscale
),y
:1-((parseFloat(item
[1])-this.minyval
)*this.yscale
),xval
:parseFloat(item
[0]),yval
:parseFloat(item
[1]),name
:_113
};
7503 if((_117
.x
>=0)&&(_117
.x
<=1)){
7504 this.points
.push(_117
);
7510 PlotKit
.Layout
.prototype._evaluatePieCharts
=function(){
7511 var _118
=PlotKit
.Base
.items
;
7512 var sum
=MochiKit
.Iter
.sum
;
7513 var _120
=MochiKit
.Base
.itemgetter
;
7514 var _121
=_118(this.datasets
).length
;
7515 var _122
=_118(this.datasets
)[0][1];
7516 var _123
=sum(map(_120(1),_122
));
7517 this.slices
=new Array();
7519 for(var i
=0;i
<_122
.length
;i
++){
7520 var _125
=_122
[i
][1]/_123
;
7521 var _126
=_124
*Math
.PI
*2;
7522 var _127
=(_124
+_125
)*Math
.PI
*2;
7523 var _128
={fraction
:_125
,xval
:_122
[i
][0],yval
:_122
[i
][1],startAngle
:_126
,endAngle
:_127
};
7525 this.slices
.push(_128
);
7530 PlotKit
.Layout
.prototype._evaluateLineTicksForXAxis
=function(){
7531 var _129
=MochiKit
.Base
.isUndefinedOrNull
;
7532 if(this.options
.xTicks
){
7533 this.xticks
=new Array();
7534 var _130
=function(tick
){
7535 var _132
=tick
.label
;
7537 _132
=tick
.v
.toString();
7539 var pos
=this.xscale
*(tick
.v
-this.minxval
);
7540 if((pos
>=0)&&(pos
<=1)){
7541 this.xticks
.push([pos
,_132
]);
7544 MochiKit
.Iter
.forEach(this.options
.xTicks
,bind(_130
,this));
7546 if(this.options
.xNumberOfTicks
){
7547 var _134
=this._uniqueXValues();
7548 var _135
=this.xrange
/this.options
.xNumberOfTicks
;
7550 this.xticks
=new Array();
7551 for(var i
=0;i
<=_134
.length
;i
++){
7552 if((_134
[i
]-this.minxval
)>=(_136
*_135
)){
7553 var pos
=this.xscale
*(_134
[i
]-this.minxval
);
7554 if((pos
>1)||(pos
<0)){
7557 this.xticks
.push([pos
,_134
[i
]]);
7560 if(_136
>this.options
.xNumberOfTicks
){
7567 PlotKit
.Layout
.prototype._evaluateLineTicksForYAxis
=function(){
7568 var _137
=MochiKit
.Base
.isUndefinedOrNull
;
7569 if(this.options
.yTicks
){
7570 this.yticks
=new Array();
7571 var _138
=function(tick
){
7572 var _139
=tick
.label
;
7574 _139
=tick
.v
.toString();
7576 var pos
=1-(this.yscale
*(tick
.v
-this.minyval
));
7577 if((pos
>=0)&&(pos
<=1)){
7578 this.yticks
.push([pos
,_139
]);
7581 MochiKit
.Iter
.forEach(this.options
.yTicks
,bind(_138
,this));
7583 if(this.options
.yNumberOfTicks
){
7584 this.yticks
=new Array();
7585 var _140
=PlotKit
.Base
.roundInterval
;
7586 var prec
=this.options
.yTickPrecision
;
7587 var _142
=_140(this.yrange
,this.options
.yNumberOfTicks
,prec
);
7588 for(var i
=0;i
<=this.options
.yNumberOfTicks
;i
++){
7589 var yval
=this.minyval
+(i
*_142
);
7590 var pos
=1-((yval
-this.minyval
)*this.yscale
);
7591 if((pos
>1)||(pos
<0)){
7594 this.yticks
.push([pos
,MochiKit
.Format
.roundToFixed(yval
,prec
)]);
7599 PlotKit
.Layout
.prototype._evaluateLineTicks
=function(){
7600 this._evaluateLineTicksForXAxis();
7601 this._evaluateLineTicksForYAxis();
7603 PlotKit
.Layout
.prototype._evaluateBarTicks
=function(){
7604 this._evaluateLineTicks();
7605 var _144
=function(tick
){
7606 return [tick
[0]+(this.minxdelta
*this.xscale
)/2,tick
[1]];
7608 this.xticks
=MochiKit
.Base
.map(bind(_144
,this),this.xticks
);
7609 if(this.options
.barOrientation
=="horizontal"){
7610 var _145
=this.xticks
;
7611 this.xticks
=this.yticks
;
7613 var _146
=function(tick
){
7614 return [1-tick
[0],tick
[1]];
7616 this.xticks
=MochiKit
.Base
.map(_146
,this.xticks
);
7619 PlotKit
.Layout
.prototype._evaluatePieTicks
=function(){
7620 var _147
=MochiKit
.Base
.isUndefinedOrNull
;
7621 var _148
=MochiKit
.Format
.numberFormatter("#%");
7622 this.xticks
=new Array();
7623 if(this.options
.xTicks
){
7624 var _149
=new Array();
7625 for(var i
=0;i
<this.slices
.length
;i
++){
7626 _149
[this.slices
[i
].xval
]=this.slices
[i
];
7628 for(var i
=0;i
<this.options
.xTicks
.length
;i
++){
7629 var tick
=this.options
.xTicks
[i
];
7630 var _150
=_149
[tick
.v
];
7631 var _151
=tick
.label
;
7634 _151
=tick
.v
.toString();
7636 _151
+=" ("+_148(_150
.fraction
)+")";
7637 this.xticks
.push([tick
.v
,_151
]);
7641 for(var i
=0;i
<this.slices
.length
;i
++){
7642 var _150
=this.slices
[i
];
7643 var _151
=_150
.xval
+" ("+_148(_150
.fraction
)+")";
7644 this.xticks
.push([_150
.xval
,_151
]);
7648 PlotKit
.Layout
.prototype._regenerateHitTestCache
=function(){
7649 this.hitTestCache
.xvalues
=this._uniqueXValues();
7650 this.hitTestCache
.xlookup
=new Array();
7651 this.hitTestCache
.x2maxy
=new Array();
7652 var _152
=MochiKit
.Base
.listMax
;
7653 var _153
=MochiKit
.Base
.itemgetter
;
7654 var map
=MochiKit
.Base
.map
;
7655 var _154
=keys(this.datasets
);
7656 for(var i
=0;i
<_154
.length
;i
++){
7657 var _155
=this.datasets
[_154
[i
]];
7658 for(var j
=0;j
<_155
.length
;j
++){
7659 var xval
=_155
[j
][0];
7660 var yval
=_155
[j
][1];
7661 if(this.hitTestCache
.xlookup
[xval
]){
7662 this.hitTestCache
.xlookup
[xval
].push([yval
,_154
[i
]]);
7664 this.hitTestCache
.xlookup
[xval
]=[[yval
,_154
[i
]]];
7668 for(var x
in this.hitTestCache
.xlookup
){
7669 var _157
=this.hitTestCache
.xlookup
[x
];
7670 this.hitTestCache
.x2maxy
[x
]=_152(map(_153(0),_157
));
7673 PlotKit
.LayoutModule
={};
7674 PlotKit
.LayoutModule
.Layout
=PlotKit
.Layout
;
7675 PlotKit
.LayoutModule
.EXPORT
=["Layout"];
7676 PlotKit
.LayoutModule
.EXPORT_OK
=[];
7677 PlotKit
.LayoutModule
.__new__
=function(){
7678 var m
=MochiKit
.Base
;
7679 m
.nameFunctions(this);
7680 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
7682 PlotKit
.LayoutModule
.__new__();
7683 MochiKit
.Base
._exportSymbols(this,PlotKit
.LayoutModule
);
7685 if((typeof (PlotKit
.Base
)=="undefined")||(typeof (PlotKit
.Layout
)=="undefined")){
7690 throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Base,Layout}";
7692 if(typeof (PlotKit
.CanvasRenderer
)=="undefined"){
7693 PlotKit
.CanvasRenderer
={};
7695 PlotKit
.CanvasRenderer
.NAME
="PlotKit.CanvasRenderer";
7696 PlotKit
.CanvasRenderer
.VERSION
=PlotKit
.VERSION
;
7697 PlotKit
.CanvasRenderer
.__repr__
=function(){
7698 return "["+this.NAME
+" "+this.VERSION
+"]";
7700 PlotKit
.CanvasRenderer
.toString
=function(){
7701 return this.__repr__();
7703 PlotKit
.CanvasRenderer
=function(_158
,_159
,_160
){
7704 if(arguments
.length
>0){
7705 this.__init__(_158
,_159
,_160
);
7708 PlotKit
.CanvasRenderer
.prototype.__init__
=function(_161
,_162
,_163
){
7709 var _164
=MochiKit
.Base
.isUndefinedOrNull
;
7710 var _165
=MochiKit
.Color
.Color
;
7711 this.options
={"drawBackground":true,"backgroundColor":_165
.whiteColor(),"padding":{left
:30,right
:30,top
:5,bottom
:10},"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[0]),"strokeColor":_165
.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":_165
.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":_165
.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"pieRadius":0.4,"enableEvents":true};
7712 MochiKit
.Base
.update(this.options
,_163
?_163
:{});
7714 this.element
=MochiKit
.DOM
.getElement(_161
);
7715 this.container
=this.element
.parentNode
;
7716 this.isIE
=PlotKit
.Base
.excanvasSupported();
7717 if(this.isIE
&&!_164(G_vmlCanvasManager
)){
7720 this.renderDelay
=null;
7721 this.clearDelay
=null;
7722 this.element
=G_vmlCanvasManager
.initElement(this.element
);
7724 this.height
=this.element
.height
;
7725 this.width
=this.element
.width
;
7726 if(_164(this.element
)){
7727 throw "CanvasRenderer() - passed canvas is not found";
7729 if(!this.isIE
&&!(PlotKit
.CanvasRenderer
.isSupported(this.element
))){
7730 throw "CanvasRenderer() - Canvas is not supported.";
7732 if(_164(this.container
)||(this.container
.nodeName
.toLowerCase()!="div")){
7733 throw "CanvasRenderer() - <canvas> needs to be enclosed in <div>";
7735 this.xlabels
=new Array();
7736 this.ylabels
=new Array();
7737 this.isFirstRender
=true;
7738 this.area
={x
:this.options
.padding
.left
,y
:this.options
.padding
.top
,w
:this.width
-this.options
.padding
.left
-this.options
.padding
.right
,h
:this.height
-this.options
.padding
.top
-this.options
.padding
.bottom
};
7739 MochiKit
.DOM
.updateNodeAttributes(this.container
,{"style":{"position":"relative","width":this.width
+"px"}});
7741 PlotKit
.CanvasRenderer
.prototype.render
=function(){
7744 if(this.renderDelay
){
7745 this.renderDelay
.cancel();
7746 this.renderDelay
=null;
7748 var _166
=this.element
.getContext("2d");
7751 this.isFirstRender
=false;
7752 if(this.maxTries
-->0){
7753 this.renderDelay
=MochiKit
.Async
.wait(this.IEDelay
);
7754 this.renderDelay
.addCallback(bind(this.render
,this));
7759 if(this.options
.drawBackground
){
7760 this._renderBackground();
7762 if(this.layout
.style
=="bar"){
7763 this._renderBarChart();
7764 this._renderBarAxis();
7766 if(this.layout
.style
=="pie"){
7767 this._renderPieChart();
7768 this._renderPieAxis();
7770 if(this.layout
.style
=="line"){
7771 this._renderLineChart();
7772 this._renderLineAxis();
7777 PlotKit
.CanvasRenderer
.prototype._renderBarChartWrap
=function(data
,_168
){
7778 var _169
=this.element
.getContext("2d");
7779 var _170
=this.options
.colorScheme
.length
;
7780 var _171
=this.options
.colorScheme
;
7781 var _172
=MochiKit
.Base
.keys(this.layout
.datasets
);
7782 var _173
=_172
.length
;
7783 for(var i
=0;i
<_173
;i
++){
7785 var _175
=_171
[i
%_170
];
7787 _169
.fillStyle
=_175
.toRGBString();
7788 if(this.options
.strokeColor
){
7789 _169
.strokeStyle
=this.options
.strokeColor
.toRGBString();
7791 if(this.options
.strokeColorTransform
){
7792 _169
.strokeStyle
=_175
[this.options
.strokeColorTransform
]().toRGBString();
7795 _169
.lineWidth
=this.options
.strokeWidth
;
7796 var _176
=function(obj
){
7801 MochiKit
.Iter
.forEach(data
,bind(_176
,this));
7805 PlotKit
.CanvasRenderer
.prototype._renderBarChart
=function(){
7806 var bind
=MochiKit
.Base
.bind
;
7807 var _178
=function(_179
,bar
){
7808 var x
=this.area
.w
*bar
.x
+this.area
.x
;
7809 var y
=this.area
.h
*bar
.y
+this.area
.y
;
7810 var w
=this.area
.w
*bar
.w
;
7811 var h
=this.area
.h
*bar
.h
;
7815 if(this.options
.shouldFill
){
7816 _179
.fillRect(x
,y
,w
,h
);
7818 if(this.options
.shouldStroke
){
7819 _179
.strokeRect(x
,y
,w
,h
);
7822 this._renderBarChartWrap(this.layout
.bars
,bind(_178
,this));
7824 PlotKit
.CanvasRenderer
.prototype._renderLineChart
=function(){
7825 var _182
=this.element
.getContext("2d");
7826 var _183
=this.options
.colorScheme
.length
;
7827 var _184
=this.options
.colorScheme
;
7828 var _185
=MochiKit
.Base
.keys(this.layout
.datasets
);
7829 var _186
=_185
.length
;
7830 var bind
=MochiKit
.Base
.bind
;
7831 var _187
=MochiKit
.Base
.partial
;
7832 for(var i
=0;i
<_186
;i
++){
7834 var _189
=_184
[i
%_183
];
7835 var _190
=this.options
.strokeColorTransform
;
7837 _182
.fillStyle
=_189
.toRGBString();
7838 if(this.options
.strokeColor
){
7839 _182
.strokeStyle
=this.options
.strokeColor
.toRGBString();
7841 if(this.options
.strokeColorTransform
){
7842 _182
.strokeStyle
=_189
[_190
]().toRGBString();
7845 _182
.lineWidth
=this.options
.strokeWidth
;
7846 var _191
=function(ctx
){
7848 ctx
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
7849 var _193
=function(ctx_
,_195
){
7850 if(_195
.name
==_188
){
7851 ctx_
.lineTo(this.area
.w
*_195
.x
+this.area
.x
,this.area
.h
*_195
.y
+this.area
.y
);
7854 MochiKit
.Iter
.forEach(this.layout
.points
,_187(_193
,ctx
),this);
7855 ctx
.lineTo(this.area
.w
+this.area
.x
,this.area
.h
+this.area
.y
);
7856 ctx
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
7859 if(this.options
.shouldFill
){
7860 bind(_191
,this)(_182
);
7863 if(this.options
.shouldStroke
){
7864 bind(_191
,this)(_182
);
7870 PlotKit
.CanvasRenderer
.prototype._renderPieChart
=function(){
7871 var _196
=this.element
.getContext("2d");
7872 var _197
=this.options
.colorScheme
.length
;
7873 var _198
=this.layout
.slices
;
7874 var _199
=this.area
.x
+this.area
.w
*0.5;
7875 var _200
=this.area
.y
+this.area
.h
*0.5;
7876 var _201
=Math
.min(this.area
.w
*this.options
.pieRadius
,this.area
.h
*this.options
.pieRadius
);
7878 _199
=parseInt(_199
);
7879 _200
=parseInt(_200
);
7880 _201
=parseInt(_201
);
7882 for(var i
=0;i
<_198
.length
;i
++){
7883 var _202
=this.options
.colorScheme
[i
%_197
];
7885 _196
.fillStyle
=_202
.toRGBString();
7886 var _203
=function(){
7888 _196
.moveTo(_199
,_200
);
7889 _196
.arc(_199
,_200
,_201
,_198
[i
].startAngle
-Math
.PI
/2,_198[i].endAngle-Math.PI/2,false);
7890 _196
.lineTo(_199
,_200
);
7893 if(Math
.abs(_198
[i
].startAngle
-_198
[i
].endAngle
)>0.001){
7894 if(this.options
.shouldFill
){
7898 if(this.options
.shouldStroke
){
7900 _196
.lineWidth
=this.options
.strokeWidth
;
7901 if(this.options
.strokeColor
){
7902 _196
.strokeStyle
=this.options
.strokeColor
.toRGBString();
7904 if(this.options
.strokeColorTransform
){
7905 _196
.strokeStyle
=_202
[this.options
.strokeColorTransform
]().toRGBString();
7914 PlotKit
.CanvasRenderer
.prototype._renderBarAxis
=function(){
7917 PlotKit
.CanvasRenderer
.prototype._renderLineAxis
=function(){
7920 PlotKit
.CanvasRenderer
.prototype._renderAxis
=function(){
7921 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
7924 var _204
=this.element
.getContext("2d");
7925 var _205
={"style":{"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
.toRGBString(),"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"}};
7927 _204
.strokeStyle
=this.options
.axisLineColor
.toRGBString();
7928 _204
.lineWidth
=this.options
.axisLineWidth
;
7929 if(this.options
.drawYAxis
){
7930 if(this.layout
.yticks
){
7931 var _206
=function(tick
){
7932 if(typeof (tick
)=="function"){
7936 var y
=this.area
.y
+tick
[0]*this.area
.h
;
7939 _204
.lineTo(x
-this.options
.axisTickSize
,y
);
7942 var _207
=DIV(_205
,tick
[1]);
7943 _207
.style
.top
=(y
-this.options
.axisLabelFontSize
)+"px";
7944 _207
.style
.left
=(x
-this.options
.padding
.left
-this.options
.axisTickSize
)+"px";
7945 _207
.style
.textAlign
="right";
7946 _207
.style
.width
=(this.options
.padding
.left
-this.options
.axisTickSize
*2)+"px";
7947 MochiKit
.DOM
.appendChildNodes(this.container
,_207
);
7948 this.ylabels
.push(_207
);
7950 MochiKit
.Iter
.forEach(this.layout
.yticks
,bind(_206
,this));
7953 _204
.moveTo(this.area
.x
,this.area
.y
);
7954 _204
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
7958 if(this.options
.drawXAxis
){
7959 if(this.layout
.xticks
){
7960 var _206
=function(tick
){
7961 if(typeof (dataset
)=="function"){
7964 var x
=this.area
.x
+tick
[0]*this.area
.w
;
7965 var y
=this.area
.y
+this.area
.h
;
7968 _204
.lineTo(x
,y
+this.options
.axisTickSize
);
7971 var _208
=DIV(_205
,tick
[1]);
7972 _208
.style
.top
=(y
+this.options
.axisTickSize
)+"px";
7973 _208
.style
.left
=(x
-this.options
.axisLabelWidth
/2)+"px";
7974 _208
.style
.textAlign
="center";
7975 _208
.style
.width
=this.options
.axisLabelWidth
+"px";
7976 MochiKit
.DOM
.appendChildNodes(this.container
,_208
);
7977 this.xlabels
.push(_208
);
7979 MochiKit
.Iter
.forEach(this.layout
.xticks
,bind(_206
,this));
7982 _204
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
7983 _204
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
7989 PlotKit
.CanvasRenderer
.prototype._renderPieAxis
=function(){
7990 if(!this.options
.drawXAxis
){
7993 if(this.layout
.xticks
){
7994 var _209
=new Array();
7995 for(var i
=0;i
<this.layout
.slices
.length
;i
++){
7996 _209
[this.layout
.slices
[i
].xval
]=this.layout
.slices
[i
];
7998 var _210
=this.area
.x
+this.area
.w
*0.5;
7999 var _211
=this.area
.y
+this.area
.h
*0.5;
8000 var _212
=Math
.min(this.area
.w
*this.options
.pieRadius
,this.area
.h
*this.options
.pieRadius
);
8001 var _213
=this.options
.axisLabelWidth
;
8002 for(var i
=0;i
<this.layout
.xticks
.length
;i
++){
8003 var _214
=_209
[this.layout
.xticks
[i
][0]];
8004 if(MochiKit
.Base
.isUndefinedOrNull(_214
)){
8007 var _215
=(_214
.startAngle
+_214
.endAngle
)/2;
8010 _216
=_216
-Math
.PI
*2;
8013 _216
=_216
+Math
.PI
*2;
8016 var _217
=_210
+Math
.sin(_216
)*(_212
+10);
8017 var _218
=_211
-Math
.cos(_216
)*(_212
+10);
8018 var _219
={"position":"absolute","zIndex":11,"width":_213
+"px","fontSize":this.options
.axisLabelFontSize
+"px","overflow":"hidden","color":this.options
.axisLabelColor
.toHexString()};
8019 if(_216
<=Math
.PI
*0.5){
8020 _219
["textAlign"]="left";
8021 _219
["verticalAlign"]="top";
8022 _219
["left"]=_217
+"px";
8023 _219
["top"]=(_218
-this.options
.axisLabelFontSize
)+"px";
8025 if((_216
>Math
.PI
*0.5)&&(_216
<=Math
.PI
)){
8026 _219
["textAlign"]="left";
8027 _219
["verticalAlign"]="bottom";
8028 _219
["left"]=_217
+"px";
8029 _219
["top"]=_218
+"px";
8031 if((_216
>Math
.PI
)&&(_216
<=Math
.PI
*1.5)){
8032 _219
["textAlign"]="right";
8033 _219
["verticalAlign"]="bottom";
8034 _219
["left"]=(_217
-_213
)+"px";
8035 _219
["top"]=_218
+"px";
8037 _219
["textAlign"]="right";
8038 _219
["verticalAlign"]="bottom";
8039 _219
["left"]=(_217
-_213
)+"px";
8040 _219
["top"]=(_218
-this.options
.axisLabelFontSize
)+"px";
8044 var _220
=DIV({"style":_219
},this.layout
.xticks
[i
][1]);
8045 this.xlabels
.push(_220
);
8046 MochiKit
.DOM
.appendChildNodes(this.container
,_220
);
8050 PlotKit
.CanvasRenderer
.prototype._renderBackground
=function(){
8051 var _221
=this.element
.getContext("2d");
8053 _221
.fillStyle
=this.options
.backgroundColor
.toRGBString();
8054 _221
.fillRect(0,0,this.width
,this.height
);
8057 PlotKit
.CanvasRenderer
.prototype.clear
=function(){
8060 if(this.clearDelay
){
8061 this.clearDelay
.cancel();
8062 this.clearDelay
=null;
8064 var _222
=this.element
.getContext("2d");
8067 this.isFirstRender
=false;
8068 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
8069 this.clearDelay
.addCallback(bind(this.clear
,this));
8073 var _222
=this.element
.getContext("2d");
8074 _222
.clearRect(0,0,this.width
,this.height
);
8075 MochiKit
.Iter
.forEach(this.xlabels
,MochiKit
.DOM
.removeElement
);
8076 MochiKit
.Iter
.forEach(this.ylabels
,MochiKit
.DOM
.removeElement
);
8077 this.xlabels
=new Array();
8078 this.ylabels
=new Array();
8080 PlotKit
.CanvasRenderer
.prototype._initialiseEvents
=function(){
8081 var _223
=MochiKit
.Signal
.connect
;
8082 var bind
=MochiKit
.Base
.bind
;
8083 _223(this.element
,"onclick",bind(this.onclick
,this));
8085 PlotKit
.CanvasRenderer
.prototype._resolveObject
=function(e
){
8086 var x
=(e
.mouse().page
.x
-PlotKit
.Base
.findPosX(this.element
)-this.area
.x
)/this.area
.w
;
8087 var y
=(e
.mouse().page
.y
-PlotKit
.Base
.findPosY(this.element
)-this.area
.y
)/this.area
.h
;
8088 var _225
=this.layout
.hitTest(x
,y
);
8094 PlotKit
.CanvasRenderer
.prototype._createEventObject
=function(_226
,e
){
8101 PlotKit
.CanvasRenderer
.prototype.onclick
=function(e
){
8102 var _227
=this._resolveObject(e
);
8103 var _228
=this._createEventObject(_227
,e
);
8105 MochiKit
.Signal
.signal(this,"onclick",_228
);
8108 PlotKit
.CanvasRenderer
.prototype.onmouseover
=function(e
){
8109 var _229
=this._resolveObject(e
);
8110 var _230
=this._createEventObject(_229
,e
);
8112 signal(this,"onmouseover",_230
);
8115 PlotKit
.CanvasRenderer
.prototype.onmouseout
=function(e
){
8116 var _231
=this._resolveObject(e
);
8117 var _232
=this._createEventObject(_231
,e
);
8119 signal(this,"onmouseout",e
);
8121 signal(this,"onmouseout",_232
);
8124 PlotKit
.CanvasRenderer
.prototype.onmousemove
=function(e
){
8125 var _233
=this._resolveObject(e
);
8126 var _234
=this._createEventObject(_233
,e
);
8127 if((_233
==null)&&(this.event_isinside
==null)){
8130 if((_233
!=null)&&(this.event_isinside
==null)){
8131 signal(this,"onmouseover",_234
);
8133 if((_233
==null)&&(this.event_isinside
!=null)){
8134 signal(this,"onmouseout",_234
);
8136 if((_233
!=null)&&(this.event_isinside
!=null)){
8137 signal(this,"onmousemove",_234
);
8139 this.event_isinside
=_233
;
8141 PlotKit
.CanvasRenderer
.isSupported
=function(_235
){
8144 if(MochiKit
.Base
.isUndefinedOrNull(_235
)){
8145 _236
=MochiKit
.DOM
.CANVAS({});
8147 _236
=MochiKit
.DOM
.getElement(_235
);
8149 var _237
=_236
.getContext("2d");
8152 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
8153 var _239
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
8154 if((!ie
)||(ie
[1]<6)||(_239
)){
8162 PlotKit
.Canvas
.CanvasRenderer
=PlotKit
.CanvasRenderer
;
8163 PlotKit
.Canvas
.EXPORT
=["CanvasRenderer"];
8164 PlotKit
.Canvas
.EXPORT_OK
=["CanvasRenderer"];
8165 PlotKit
.Canvas
.__new__
=function(){
8166 var m
=MochiKit
.Base
;
8167 m
.nameFunctions(this);
8168 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
8170 PlotKit
.Canvas
.__new__();
8171 MochiKit
.Base
._exportSymbols(this,PlotKit
.Canvas
);
8173 if(typeof (PlotKit
.Layout
)=="undefined"){
8178 throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Layout";
8180 PlotKit
.SVGRenderer
=function(_240
,_241
,_242
){
8181 if(arguments
.length
>0){
8182 this.__init__(_240
,_241
,_242
);
8185 PlotKit
.SVGRenderer
.NAME
="PlotKit.SVGRenderer";
8186 PlotKit
.SVGRenderer
.VERSION
=PlotKit
.VERSION
;
8187 PlotKit
.SVGRenderer
.__repr__
=function(){
8188 return "["+this.NAME
+" "+this.VERSION
+"]";
8190 PlotKit
.SVGRenderer
.toString
=function(){
8191 return this.__repr__();
8193 PlotKit
.SVGRenderer
.SVGNS
="http://www.w3.org/2000/svg";
8194 PlotKit
.SVGRenderer
.prototype.__init__
=function(_243
,_244
,_245
){
8195 var _246
=MochiKit
.Base
.isUndefinedOrNull
;
8196 this.options
={"drawBackground":true,"backgroundColor":Color
.whiteColor(),"padding":{left
:30,right
:30,top
:5,bottom
:10},"colorScheme":PlotKit
.Base
.palette(PlotKit
.Base
.baseColors()[1]),"strokeColor":Color
.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color
.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color
.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"axisLabelUseDiv":true,"pieRadius":0.4,"enableEvents":true};
8197 MochiKit
.Base
.update(this.options
,_245
?_245
:{});
8199 this.element
=MochiKit
.DOM
.getElement(_243
);
8200 this.container
=this.element
.parentNode
;
8201 this.height
=parseInt(this.element
.getAttribute("height"));
8202 this.width
=parseInt(this.element
.getAttribute("width"));
8203 this.document
=document
;
8204 this.root
=this.element
;
8206 this.document
=this.element
.getSVGDocument();
8207 this.root
=_246(this.document
.documentElement
)?this.element
:this.document
.documentElement
;
8211 this.element
.style
.zIndex
=1;
8212 if(_246(this.element
)){
8213 throw "SVGRenderer() - passed SVG object is not found";
8215 if(_246(this.container
)||this.container
.nodeName
.toLowerCase()!="div"){
8216 throw "SVGRenderer() - No DIV's around the SVG.";
8218 this.xlabels
=new Array();
8219 this.ylabels
=new Array();
8220 this.defs
=this.createSVGElement("defs");
8221 this.area
={x
:this.options
.padding
.left
,y
:this.options
.padding
.top
,w
:this.width
-this.options
.padding
.left
-this.options
.padding
.right
,h
:this.height
-this.options
.padding
.top
-this.options
.padding
.bottom
};
8222 MochiKit
.DOM
.updateNodeAttributes(this.container
,{"style":{"position":"relative","width":this.width
+"px"}});
8224 PlotKit
.SVGRenderer
.prototype.render
=function(){
8225 if(this.options
.drawBackground
){
8226 this._renderBackground();
8228 if(this.layout
.style
=="bar"){
8229 this._renderBarChart();
8230 this._renderBarAxis();
8232 if(this.layout
.style
=="pie"){
8233 this._renderPieChart();
8234 this._renderPieAxis();
8236 if(this.layout
.style
=="line"){
8237 this._renderLineChart();
8238 this._renderLineAxis();
8243 PlotKit
.SVGRenderer
.prototype._renderBarOrLine
=function(data
,_247
,_248
,_249
){
8244 var _250
=this.options
.colorScheme
.length
;
8245 var _251
=this.options
.colorScheme
;
8246 var _252
=MochiKit
.Base
.keys(this.layout
.datasets
);
8247 var _253
=_252
.length
;
8248 for(var i
=0;i
<_253
;i
++){
8250 var _255
=new Array();
8251 var _256
=_251
[i
%_250
];
8252 if(this.options
.shouldFill
){
8253 _255
["fill"]=_256
.toRGBString();
8255 _255
["fill"]="none";
8257 if(this.options
.shouldStroke
&&(this.options
.strokeColor
||this.options
.strokeColorTransform
)){
8258 if(this.options
.strokeColor
){
8259 _255
["stroke"]=this.options
.strokeColor
.toRGBString();
8261 if(this.options
.strokeColorTransform
){
8262 _255
["stroke"]=_256
[this.options
.strokeColorTransform
]().toRGBString();
8265 _255
["strokeWidth"]=this.options
.strokeWidth
;
8270 var _257
=function(obj
){
8275 MochiKit
.Iter
.forEach(data
,bind(_257
,this));
8281 PlotKit
.SVGRenderer
.prototype._renderBarChart
=function(){
8282 var bind
=MochiKit
.Base
.bind
;
8283 var _258
=function(_259
,bar
){
8284 var x
=this.area
.w
*bar
.x
+this.area
.x
;
8285 var y
=this.area
.h
*bar
.y
+this.area
.y
;
8286 var w
=this.area
.w
*bar
.w
;
8287 var h
=this.area
.h
*bar
.h
;
8288 this._drawRect(x
,y
,w
,h
,_259
);
8290 this._renderBarOrLine(this.layout
.bars
,bind(_258
,this));
8292 PlotKit
.SVGRenderer
.prototype._renderLineChart
=function(){
8293 var bind
=MochiKit
.Base
.bind
;
8294 var _260
=function(_261
,_262
){
8295 this._tempPointsBuffer
+=(this.area
.w
*_262
.x
+this.area
.x
)+","+(this.area
.h
*_262
.y
+this.area
.y
)+" ";
8297 var _263
=function(_264
){
8298 this._tempPointsBuffer
="";
8299 this._tempPointsBuffer
+=(this.area
.x
)+","+(this.area
.y
+this.area
.h
)+" ";
8301 var _265
=function(_266
){
8302 this._tempPointsBuffer
+=(this.area
.w
+this.area
.x
)+","+(this.area
.h
+this.area
.y
);
8303 _266
["points"]=this._tempPointsBuffer
;
8304 var elem
=this.createSVGElement("polygon",_266
);
8305 this.root
.appendChild(elem
);
8307 this._renderBarOrLine(this.layout
.points
,bind(_260
,this),bind(_263
,this),bind(_265
,this));
8309 PlotKit
.SVGRenderer
.prototype._renderPieChart
=function(){
8310 var _268
=this.options
.colorScheme
.length
;
8311 var _269
=this.layout
.slices
;
8312 var _270
=this.area
.x
+this.area
.w
*0.5;
8313 var _271
=this.area
.y
+this.area
.h
*0.5;
8314 var _272
=Math
.min(this.area
.w
*this.options
.pieRadius
,this.area
.h
*this.options
.pieRadius
);
8315 if(_269
.length
==1&&(Math
.abs(_269
[0].startAngle
)-Math
.abs(_269
[0].endAngle
)<0.1)){
8316 var _273
={"cx":_270
,"cy":_271
,"r":_272
};
8317 var _274
=this.options
.colorScheme
[0];
8318 if(this.options
.shouldFill
){
8319 _273
["fill"]=_274
.toRGBString();
8321 _273
["fill"]="none";
8323 if(this.options
.shouldStroke
&&(this.options
.strokeColor
||this.options
.strokeColorTransform
)){
8324 if(this.options
.strokeColor
){
8325 _273
["stroke"]=this.options
.strokeColor
.toRGBString();
8327 if(this.options
.strokeColorTransform
){
8328 _273
["stroke"]=_274
[this.options
.strokeColorTransform
]().toRGBString();
8331 _273
["style"]="stroke-width: "+this.options
.strokeWidth
;
8333 this.root
.appendChild(this.createSVGElement("circle",_273
));
8336 for(var i
=0;i
<_269
.length
;i
++){
8337 var _273
=new Array();
8338 var _274
=this.options
.colorScheme
[i
%_268
];
8339 if(this.options
.shouldFill
){
8340 _273
["fill"]=_274
.toRGBString();
8342 _273
["fill"]="none";
8344 if(this.options
.shouldStroke
&&(this.options
.strokeColor
||this.options
.strokeColorTransform
)){
8345 if(this.options
.strokeColor
){
8346 _273
["stroke"]=this.options
.strokeColor
.toRGBString();
8348 if(this.options
.strokeColorTransform
){
8349 _273
["stroke"]=_274
[this.options
.strokeColorTransform
]().toRGBString();
8352 _273
["style"]="stroke-width:"+this.options
.strokeWidth
;
8355 if(Math
.abs(_269
[i
].endAngle
-_269
[i
].startAngle
)>Math
.PI
){
8358 var x1
=Math
.cos(_269
[i
].startAngle
-Math
.PI
/2)*_272
;
8359 var y1
=Math
.sin(_269
[i
].startAngle
-Math
.PI
/2)*_272
;
8360 var x2
=Math
.cos(_269
[i
].endAngle
-Math
.PI
/2)*_272
;
8361 var y2
=Math
.sin(_269
[i
].endAngle
-Math
.PI
/2)*_272
;
8364 var _282
="M"+_270
+","+_271
+" ";
8365 _282
+="l"+x1
+","+y1
+" ";
8366 _282
+="a"+_272
+","+_272
+" 0 "+_275
+",1 "+rx
+","+ry
+" z";
8368 var elem
=this.createSVGElement("path",_273
);
8369 this.root
.appendChild(elem
);
8372 PlotKit
.SVGRenderer
.prototype._renderBarAxis
=function(){
8375 PlotKit
.SVGRenderer
.prototype._renderLineAxis
=function(){
8378 PlotKit
.SVGRenderer
.prototype._renderAxis
=function(){
8379 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
8382 var _283
={"style":{"position":"absolute","textAlign":"center","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
.toRGBString(),"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"}};
8383 var _284
={"stroke":this.options
.axisLineColor
.toRGBString(),"strokeWidth":this.options
.axisLineWidth
};
8384 if(this.options
.drawYAxis
){
8385 if(this.layout
.yticks
){
8386 var _285
=function(tick
){
8388 var y
=this.area
.y
+tick
[0]*this.area
.h
;
8389 this._drawLine(x
,y
,x
-3,y
,_284
);
8390 if(this.options
.axisLabelUseDiv
){
8391 var _286
=DIV(_283
,tick
[1]);
8392 _286
.style
.top
=(y
-this.options
.axisLabelFontSize
)+"px";
8393 _286
.style
.left
=(x
-this.options
.padding
.left
+this.options
.axisTickSize
)+"px";
8394 _286
.style
.textAlign
="left";
8395 _286
.style
.width
=(this.options
.padding
.left
-3)+"px";
8396 MochiKit
.DOM
.appendChildNodes(this.container
,_286
);
8397 this.ylabels
.push(_286
);
8399 var _287
={y
:y
+3,x
:(x
-this.options
.padding
.left
+3),width
:(this.options
.padding
.left
-this.options
.axisTickSize
)+"px",height
:(this.options
.axisLabelFontSize
+3)+"px",fontFamily
:"Arial",fontSize
:this.options
.axisLabelFontSize
+"px",fill
:this.options
.axisLabelColor
.toRGBString()};
8400 var _286
=this.createSVGElement("text",_287
);
8401 _286
.appendChild(this.document
.createTextNode(tick
[1]));
8402 this.root
.appendChild(_286
);
8405 MochiKit
.Iter
.forEach(this.layout
.yticks
,bind(_285
,this));
8407 this._drawLine(this.area
.x
,this.area
.y
,this.area
.x
,this.area
.y
+this.area
.h
,_284
);
8409 if(this.options
.drawXAxis
){
8410 if(this.layout
.xticks
){
8411 var _285
=function(tick
){
8412 var x
=this.area
.x
+tick
[0]*this.area
.w
;
8413 var y
=this.area
.y
+this.area
.h
;
8414 this._drawLine(x
,y
,x
,y
+this.options
.axisTickSize
,_284
);
8415 if(this.options
.axisLabelUseDiv
){
8416 var _288
=DIV(_283
,tick
[1]);
8417 _288
.style
.top
=(y
+this.options
.axisTickSize
)+"px";
8418 _288
.style
.left
=(x
-this.options
.axisLabelWidth
/2)+"px";
8419 _288
.style
.textAlign
="center";
8420 _288
.style
.width
=this.options
.axisLabelWidth
+"px";
8421 MochiKit
.DOM
.appendChildNodes(this.container
,_288
);
8422 this.xlabels
.push(_288
);
8424 var _289
={y
:(y
+this.options
.axisTickSize
+this.options
.axisLabelFontSize
),x
:x
-3,width
:this.options
.axisLabelWidth
+"px",height
:(this.options
.axisLabelFontSize
+3)+"px",fontFamily
:"Arial",fontSize
:this.options
.axisLabelFontSize
+"px",fill
:this.options
.axisLabelColor
.toRGBString(),textAnchor
:"middle"};
8425 var _288
=this.createSVGElement("text",_289
);
8426 _288
.appendChild(this.document
.createTextNode(tick
[1]));
8427 this.root
.appendChild(_288
);
8430 MochiKit
.Iter
.forEach(this.layout
.xticks
,bind(_285
,this));
8432 this._drawLine(this.area
.x
,this.area
.y
+this.area
.h
,this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
,_284
);
8435 PlotKit
.SVGRenderer
.prototype._renderPieAxis
=function(){
8436 if(this.layout
.xticks
){
8437 var _290
=new Array();
8438 for(var i
=0;i
<this.layout
.slices
.length
;i
++){
8439 _290
[this.layout
.slices
[i
].xval
]=this.layout
.slices
[i
];
8441 var _291
=this.area
.x
+this.area
.w
*0.5;
8442 var _292
=this.area
.y
+this.area
.h
*0.5;
8443 var _293
=Math
.min(this.area
.w
*this.options
.pieRadius
+10,this.area
.h
*this.options
.pieRadius
+10);
8444 var _294
=this.options
.axisLabelWidth
;
8445 for(var i
=0;i
<this.layout
.xticks
.length
;i
++){
8446 var _295
=_290
[this.layout
.xticks
[i
][0]];
8447 if(MochiKit
.Base
.isUndefinedOrNull(_295
)){
8450 var _296
=(_295
.startAngle
+_295
.endAngle
)/2;
8453 _297
=_297
-Math
.PI
*2;
8456 _297
=_297
+Math
.PI
*2;
8459 var _298
=_291
+Math
.sin(_297
)*(_293
+10);
8460 var _299
=_292
-Math
.cos(_297
)*(_293
+10);
8461 var _300
={"position":"absolute","zIndex":11,"width":_294
+"px","fontSize":this.options
.axisLabelFontSize
+"px","overflow":"hidden","color":this.options
.axisLabelColor
.toHexString()};
8462 var _301
={"width":_294
+"px","fontSize":this.options
.axisLabelFontSize
+"px","height":(this.options
.axisLabelFontSize
+3)+"px","fill":this.options
.axisLabelColor
.toRGBString()};
8463 if(_297
<=Math
.PI
*0.5){
8464 MochiKit
.Base
.update(_300
,{"textAlign":"left","verticalAlign":"top","left":_298
+"px","top":(_299
-this.options
.axisLabelFontSize
)+"px"});
8465 MochiKit
.Base
.update(_301
,{"x":_298
,"y":(_299
-this.options
.axisLabelFontSize
),"textAnchor":"left"});
8467 if((_297
>Math
.PI
*0.5)&&(_297
<=Math
.PI
)){
8468 MochiKit
.Base
.update(_300
,{"textAlign":"left","verticalAlign":"bottom","left":_298
+"px","top":_299
+"px"});
8469 MochiKit
.Base
.update(_301
,{"textAnchor":"left","x":_298
,"y":_299
});
8471 if((_297
>Math
.PI
)&&(_297
<=Math
.PI
*1.5)){
8472 MochiKit
.Base
.update(_300
,{"textAlign":"right","verticalAlign":"bottom","left":_298
+"px","top":_299
+"px"});
8473 MochiKit
.Base
.update(_301
,{"textAnchor":"right","x":_298
-_294
,"y":_299
});
8475 MochiKit
.Base
.update(_300
,{"textAlign":"left","verticalAlign":"bottom","left":_298
+"px","top":_299
+"px"});
8476 MochiKit
.Base
.update(_301
,{"textAnchor":"left","x":_298
-_294
,"y":_299
-this.options
.axisLabelFontSize
});
8480 if(this.options
.axisLabelUseDiv
){
8481 var _302
=DIV({"style":_300
},this.layout
.xticks
[i
][1]);
8482 this.xlabels
.push(_302
);
8483 MochiKit
.DOM
.appendChildNodes(this.container
,_302
);
8485 var _302
=this.createSVGElement("text",_301
);
8486 _302
.appendChild(this.document
.createTextNode(this.layout
.xticks
[i
][1]));
8487 this.root
.appendChild(_302
);
8492 PlotKit
.SVGRenderer
.prototype._renderBackground
=function(){
8493 var opts
={"stroke":"none","fill":this.options
.backgroundColor
.toRGBString()};
8494 this._drawRect(0,0,this.width
,this.height
,opts
);
8496 PlotKit
.SVGRenderer
.prototype._drawRect
=function(x
,y
,w
,h
,_304
){
8497 var _305
={x
:x
+"px",y
:y
+"px",width
:w
+"px",height
:h
+"px"};
8499 MochiKit
.Base
.update(_305
,_304
);
8501 var elem
=this.createSVGElement("rect",_305
);
8502 this.root
.appendChild(elem
);
8504 PlotKit
.SVGRenderer
.prototype._drawLine
=function(x1
,y1
,x2
,y2
,_306
){
8505 var _307
={x1
:x1
+"px",y1
:y1
+"px",x2
:x2
+"px",y2
:y2
+"px"};
8507 MochiKit
.Base
.update(_307
,_306
);
8509 var elem
=this.createSVGElement("line",_307
);
8510 this.root
.appendChild(elem
);
8512 PlotKit
.SVGRenderer
.prototype.clear
=function(){
8513 while(this.element
.firstChild
){
8514 this.element
.removeChild(this.element
.firstChild
);
8516 if(this.options
.axisLabelUseDiv
){
8517 for(var i
=0;i
<this.xlabels
.length
;i
++){
8518 MochiKit
.DOM
.removeElement(this.xlabels
[i
]);
8520 for(var i
=0;i
<this.ylabels
.length
;i
++){
8521 MochiKit
.DOM
.removeElement(this.ylabels
[i
]);
8524 this.xlabels
=new Array();
8525 this.ylabels
=new Array();
8527 PlotKit
.SVGRenderer
.prototype.createSVGElement
=function(name
,_309
){
8528 var _310
=MochiKit
.Base
.isUndefinedOrNull
;
8530 var doc
=_310(this.document
)?document
:this.document
;
8532 elem
=doc
.createElementNS(PlotKit
.SVGRenderer
.SVGNS
,name
);
8535 elem
=doc
.createElement(name
);
8536 elem
.setAttribute("xmlns",PlotKit
.SVGRenderer
.SVGNS
);
8539 MochiKit
.DOM
.updateNodeAttributes(elem
,_309
);
8543 PlotKit
.SVGRenderer
.SVG
=function(_312
){
8544 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
8545 var _313
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
8546 if(ie
&&(ie
[1]>=6)&&(!_313
)){
8547 var _314
=_312
["width"]?_312
["width"]:"100";
8548 var _315
=_312
["height"]?_312
["height"]:"100";
8549 var eid
=_312
["id"]?_312
["id"]:"notunique";
8550 var html
="<svg:svg width=\""+_314
+"\" height=\""+_315
+"\" ";
8551 html
+="id=\""+eid
+"\" version=\"1.1\" baseProfile=\"full\" />";
8552 var _318
=document
.createElement(html
);
8553 var _319
=_318
.getSVGDocument().createElementNS(PlotKit
.SVGRenderer
.SVGNS
,"svg");
8554 _319
.setAttribute("width",_314
);
8555 _319
.setAttribute("height",_315
);
8556 _318
.getSVGDocument().appendChild(_319
);
8559 return PlotKit
.SVGRenderer
.prototype.createSVGElement("svg",_312
);
8562 PlotKit
.SVGRenderer
.isSupported
=function(){
8563 var _320
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
8564 var _321
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
8565 var _322
=navigator
.userAgent
.match(/AppleWebKit\/(\d
+)/);
8566 var _323
=navigator
.userAgent
.match(/Opera\/(\d
*\.\d
*)/);
8567 var _324
=navigator
.userAgent
.match(/rv:(\d*\.\d*).*Gecko/);
8568 var _325
="http://www.w3.org/TR/SVG11/feature#SVG";
8569 if(_321
&&(_321
[1]>=6)&&!_320
){
8570 return document
.implementation
.hasFeature(_325
,"1.1");
8572 if(_323
&&(_323
[1]>8.9)){
8575 if(_324
&&(_324
>1.7)){
8581 PlotKit
.SVG
.SVGRenderer
=PlotKit
.SVGRenderer
;
8582 PlotKit
.SVG
.EXPORT
=["SVGRenderer"];
8583 PlotKit
.SVG
.EXPORT_OK
=["SVGRenderer"];
8584 PlotKit
.SVG
.__new__
=function(){
8585 var m
=MochiKit
.Base
;
8586 m
.nameFunctions(this);
8587 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
8589 PlotKit
.SVG
.__new__();
8590 MochiKit
.Base
._exportSymbols(this,PlotKit
.SVG
);
8592 if(typeof (PlotKit
.CanvasRenderer
)=="undefined"){
8597 throw "SweetCanvas depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, Canvas}";
8599 if(typeof (PlotKit
.SweetCanvasRenderer
)=="undefined"){
8600 PlotKit
.SweetCanvasRenderer
={};
8602 PlotKit
.SweetCanvasRenderer
=function(_326
,_327
,_328
){
8603 if(arguments
.length
>0){
8604 this.__init__(_326
,_327
,_328
);
8607 PlotKit
.SweetCanvasRenderer
.NAME
="PlotKit.SweetCanvasRenderer";
8608 PlotKit
.SweetCanvasRenderer
.VERSION
=PlotKit
.VERSION
;
8609 PlotKit
.SweetCanvasRenderer
.__repr__
=function(){
8610 return "["+this.NAME
+" "+this.VERSION
+"]";
8612 PlotKit
.SweetCanvasRenderer
.toString
=function(){
8613 return this.__repr__();
8615 PlotKit
.SweetCanvasRenderer
.prototype=new PlotKit
.CanvasRenderer();
8616 PlotKit
.SweetCanvasRenderer
.prototype.constructor
=PlotKit
.SweetCanvasRenderer
;
8617 PlotKit
.SweetCanvasRenderer
.__super__
=PlotKit
.CanvasRenderer
.prototype;
8618 PlotKit
.SweetCanvasRenderer
.prototype.__init__
=function(el
,_330
,opts
){
8619 var _331
=PlotKit
.Base
.officeBlue();
8620 MochiKit
.Base
.update(_331
,opts
);
8621 PlotKit
.SweetCanvasRenderer
.__super__
.__init__
.call(this,el
,_330
,_331
);
8623 PlotKit
.SweetCanvasRenderer
.prototype._renderBarChart
=function(){
8624 var bind
=MochiKit
.Base
.bind
;
8625 var _332
=Color
.blackColor().colorWithAlpha(0.1).toRGBString();
8626 var _333
=function(_334
,x
,y
,w
,h
){
8627 _334
.fillStyle
=_332
;
8628 _334
.fillRect(x
-2,y
-2,w
+4,h
+2);
8629 _334
.fillStyle
=_332
;
8630 _334
.fillRect(x
-1,y
-1,w
+2,h
+1);
8632 var _335
=this.options
.colorScheme
.length
;
8633 var _336
=this.options
.colorScheme
;
8634 var _337
=PlotKit
.Base
.keys(this.layout
.datasets
);
8635 var _338
=_337
.length
;
8636 var _339
=function(name
){
8637 for(var i
=0;i
<_338
;i
++){
8639 return _336
[i
%_335
];
8644 var _340
=function(_341
,bar
){
8645 var x
=this.area
.w
*bar
.x
+this.area
.x
;
8646 var y
=this.area
.h
*bar
.y
+this.area
.y
;
8647 var w
=this.area
.w
*bar
.w
;
8648 var h
=this.area
.h
*bar
.h
;
8654 _341
.shadowColor
=Color
.fromHexString("#888888").toRGBString();
8657 _341
.fillStyle
="#cccccc";
8658 _341
.fillRect(x
-2,y
-2,w
+4,h
+2);
8663 if(this.options
.shouldFill
){
8664 _341
.fillStyle
=_339(bar
.name
).toRGBString();
8665 _341
.fillRect(x
,y
,w
,h
);
8668 _341
.strokeStyle
=Color
.whiteColor().toRGBString();
8670 if(this.options
.shouldStroke
){
8671 _341
.strokeRect(x
,y
,w
,h
);
8675 this._renderBarChartWrap(this.layout
.bars
,bind(_340
,this));
8677 PlotKit
.SweetCanvasRenderer
.prototype._renderLineChart
=function(){
8678 var _342
=this.element
.getContext("2d");
8679 var _343
=this.options
.colorScheme
.length
;
8680 var _344
=this.options
.colorScheme
;
8681 var _345
=PlotKit
.Base
.keys(this.layout
.datasets
);
8682 var _346
=_345
.length
;
8683 var bind
=MochiKit
.Base
.bind
;
8684 for(var i
=0;i
<_346
;i
++){
8686 var _348
=_344
[i
%_343
];
8687 var _349
=this.options
.strokeColorTransform
;
8689 var _350
=function(ctx
){
8691 ctx
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
8692 var _351
=function(ctx_
,_352
){
8693 if(_352
.name
==_347
){
8694 ctx_
.lineTo(this.area
.w
*_352
.x
+this.area
.x
,this.area
.h
*_352
.y
+this.area
.y
);
8697 MochiKit
.Iter
.forEach(this.layout
.points
,partial(_351
,ctx
),this);
8698 ctx
.lineTo(this.area
.w
+this.area
.x
,this.area
.h
+this.area
.y
);
8699 ctx
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
8702 if(this.options
.shouldFill
){
8705 _342
.fillStyle
="#cccccc";
8707 _342
.fillStyle
=Color
.blackColor().colorWithAlpha(0.2).toRGBString();
8709 _342
.translate(-1,-2);
8710 bind(_350
,this)(_342
);
8711 if(this.options
.shouldFill
){
8717 _342
.shadowColor
=Color
.fromHexString("#888888").toRGBString();
8718 _342
.fillStyle
=_348
.toRGBString();
8720 _342
.strokeStyle
=Color
.whiteColor().toRGBString();
8721 if(this.options
.shouldFill
){
8722 bind(_350
,this)(_342
);
8725 if(this.options
.shouldStroke
){
8726 bind(_350
,this)(_342
);
8732 PlotKit
.SweetCanvasRenderer
.prototype._renderPieChart
=function(){
8733 var _353
=this.element
.getContext("2d");
8734 var _354
=this.options
.colorScheme
.length
;
8735 var _355
=this.layout
.slices
;
8736 var _356
=this.area
.x
+this.area
.w
*0.5;
8737 var _357
=this.area
.y
+this.area
.h
*0.5;
8738 var _358
=Math
.min(this.area
.w
*this.options
.pieRadius
,this.area
.h
*this.options
.pieRadius
);
8740 _356
=parseInt(_356
);
8741 _357
=parseInt(_357
);
8742 _358
=parseInt(_358
);
8746 var _359
=Color
.blackColor().colorWithAlpha(0.2);
8747 _353
.fillStyle
=_359
.toRGBString();
8749 _353
.shadowColor
=Color
.fromHexString("#888888").toRGBString();
8750 _353
.translate(1,1);
8752 _353
.moveTo(_356
,_357
);
8753 _353
.arc(_356
,_357
,_358
+2,0,Math
.PI
*2,false);
8759 _353
.strokeStyle
=Color
.whiteColor().toRGBString();
8761 for(var i
=0;i
<_355
.length
;i
++){
8762 var _360
=this.options
.colorScheme
[i
%_354
];
8763 _353
.fillStyle
=_360
.toRGBString();
8764 var _361
=function(){
8766 _353
.moveTo(_356
,_357
);
8767 _353
.arc(_356
,_357
,_358
,_355
[i
].startAngle
-Math
.PI
/2,_355[i].endAngle-Math.PI/2,false);
8768 _353
.lineTo(_356
,_357
);
8771 if(Math
.abs(_355
[i
].startAngle
-_355
[i
].endAngle
)>0.0001){
8772 if(this.options
.shouldFill
){
8776 if(this.options
.shouldStroke
){
8784 PlotKit
.SweetCanvasRenderer
.prototype._renderBackground
=function(){
8785 var _362
=this.element
.getContext("2d");
8786 if(this.layout
.style
=="bar"||this.layout
.style
=="line"){
8788 _362
.fillStyle
=this.options
.backgroundColor
.toRGBString();
8789 _362
.fillRect(this.area
.x
,this.area
.y
,this.area
.w
,this.area
.h
);
8790 _362
.strokeStyle
=this.options
.axisLineColor
.toRGBString();
8792 var _363
=this.layout
.yticks
;
8794 if(this.layout
.style
=="bar"&&this.layout
.options
.barOrientation
=="horizontal"){
8795 _363
=this.layout
.xticks
;
8798 for(var i
=0;i
<_363
.length
;i
++){
8804 x1
=_363
[i
][0]*this.area
.w
+this.area
.x
;
8810 y1
=_363
[i
][0]*this.area
.h
+this.area
.y
;
8822 PlotKit
.SweetCanvasRenderer
.__super__
._renderBackground
.call(this);
8825 PlotKit
.SweetCanvas
={};
8826 PlotKit
.SweetCanvas
.SweetCanvasRenderer
=PlotKit
.SweetCanvasRenderer
;
8827 PlotKit
.SweetCanvas
.EXPORT
=["SweetCanvasRenderer"];
8828 PlotKit
.SweetCanvas
.EXPORT_OK
=["SweetCanvasRenderer"];
8829 PlotKit
.SweetCanvas
.__new__
=function(){
8830 var m
=MochiKit
.Base
;
8831 m
.nameFunctions(this);
8832 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
8834 PlotKit
.SweetCanvas
.__new__();
8835 MochiKit
.Base
._exportSymbols(this,PlotKit
.SweetCanvas
);
8837 if(typeof (PlotKit
.SVGRenderer
)=="undefined"){
8842 throw "SweetSVG depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, SVG}";
8844 if(typeof (PlotKit
.SweetSVGRenderer
)=="undefined"){
8845 PlotKit
.SweetSVGRenderer
={};
8847 PlotKit
.SweetSVGRenderer
=function(_365
,_366
,_367
){
8848 if(arguments
.length
>0){
8849 this.__init__(_365
,_366
,_367
);
8852 PlotKit
.SweetSVGRenderer
.NAME
="PlotKit.SweetSVGRenderer";
8853 PlotKit
.SweetSVGRenderer
.VERSION
=PlotKit
.VERSION
;
8854 PlotKit
.SweetSVGRenderer
.__repr__
=function(){
8855 return "["+this.NAME
+" "+this.VERSION
+"]";
8857 PlotKit
.SweetSVGRenderer
.toString
=function(){
8858 return this.__repr__();
8860 PlotKit
.SweetSVGRenderer
.prototype=new PlotKit
.SVGRenderer();
8861 PlotKit
.SweetSVGRenderer
.prototype.constructor
=PlotKit
.SweetSVGRenderer
;
8862 PlotKit
.SweetSVGRenderer
.__super__
=PlotKit
.SVGRenderer
.prototype;
8863 PlotKit
.SweetSVGRenderer
.prototype.__init__
=function(_368
,_369
,_370
){
8864 var _371
=PlotKit
.Base
.officeBlue();
8865 MochiKit
.Base
.update(_371
,_370
);
8866 PlotKit
.SweetSVGRenderer
.__super__
.__init__
.call(this,_368
,_369
,_371
);
8868 PlotKit
.SweetSVGRenderer
.prototype._addDropShadowFilter
=function(){
8869 var _372
=this.createSVGElement("filter",{x
:0,y
:0,"id":"dropShadow"});
8870 var _373
=this.createSVGElement("feOffset",{"in":"SourceGraphic","dx":0,"dy":0,"result":"topCopy"});
8871 var blur
=this.createSVGElement("feGaussianBlur",{"in":"SourceAlpha","StdDeviation":2,"result":"shadow"});
8872 var _375
=this.createSVGElement("feOffset",{"in":"shadow","dx":-1,"dy":-2,"result":"movedShadow"});
8873 var _376
=this.createSVGElement("feMerge");
8874 var _377
=this.createSVGElement("feMergeNode",{"in":"topCopy"});
8875 var _378
=this.createSVGElement("feMergeNode",{"in":"movedShadow"});
8876 _376
.appendChild(_377
);
8877 _376
.appendChild(_378
);
8878 _372
.appendChild(_373
);
8879 _372
.appendChild(blur
);
8880 _372
.appendChild(_375
);
8881 _372
.appendChild(_376
);
8882 this.defs
.appendChild(_372
);
8884 PlotKit
.SweetSVGRenderer
.prototype._renderBarChart
=function(){
8885 var bind
=MochiKit
.Base
.bind
;
8886 var _379
=Color
.blackColor().toRGBString();
8887 var _380
="fill:"+_379
+";fill-opacity:0.15";
8888 var _381
="stroke-width: 2.0; stroke:"+Color
.whiteColor().toRGBString();
8889 var _382
=function(_383
,bar
){
8890 var x
=this.area
.w
*bar
.x
+this.area
.x
;
8891 var y
=this.area
.h
*bar
.y
+this.area
.y
;
8892 var w
=this.area
.w
*bar
.w
;
8893 var h
=this.area
.h
*bar
.h
;
8898 this._drawRect(x
-2,y
-1,w
+4,h
+2,{"style":_380
});
8899 this._drawRect(x
,y
,w
,h
,_383
);
8901 this._renderBarOrLine(this.layout
.bars
,bind(_382
,this));
8903 PlotKit
.SweetSVGRenderer
.prototype._renderLineChart
=function(){
8904 var bind
=MochiKit
.Base
.bind
;
8905 var _384
=Color
.blackColor().toRGBString();
8906 var _385
="fill:"+_384
+";fill-opacity:0.15";
8907 var _386
="stroke-width: 2.0; stroke:"+Color
.whiteColor().toRGBString();
8908 var _387
=function(_388
,_389
){
8909 this._tempPointsBuffer
+=(this.area
.w
*_389
.x
+this.area
.x
)+","+(this.area
.h
*_389
.y
+this.area
.y
)+" ";
8911 var _390
=function(_391
){
8912 this._tempPointsBuffer
="";
8913 this._tempPointsBuffer
+=(this.area
.x
)+","+(this.area
.y
+this.area
.h
)+" ";
8915 var _392
=function(_393
){
8916 this._tempPointsBuffer
+=(this.area
.w
+this.area
.x
)+","+(this.area
.h
+this.area
.y
);
8917 _393
["points"]=this._tempPointsBuffer
;
8918 _393
["stroke"]="none";
8919 _393
["transform"]="translate(-2, -1)";
8921 var _394
=this.createSVGElement("polygon",_393
);
8922 this.root
.appendChild(_394
);
8923 _393
["transform"]="";
8925 var elem
=this.createSVGElement("polygon",_393
);
8926 this.root
.appendChild(elem
);
8928 this._renderBarOrLine(this.layout
.points
,bind(_387
,this),bind(_390
,this),bind(_392
,this));
8930 PlotKit
.SweetSVGRenderer
.prototype._renderPieChart
=function(){
8931 var _395
=this.area
.x
+this.area
.w
*0.5;
8932 var _396
=this.area
.y
+this.area
.h
*0.5;
8933 var _397
=Color
.blackColor().toRGBString();
8934 var _398
=Math
.min(this.area
.w
*this.options
.pieRadius
,this.area
.h
*this.options
.pieRadius
);
8935 var _399
="fill:"+_397
+";fill-opacity:0.15";
8936 var _400
=this.createSVGElement("circle",{"style":_399
,"cx":_395
+1,"cy":_396
+1,"r":_398
+1});
8937 this.root
.appendChild(_400
);
8938 PlotKit
.SweetSVGRenderer
.__super__
._renderPieChart
.call(this);
8940 PlotKit
.SweetSVGRenderer
.prototype._renderBackground
=function(){
8941 var _401
={"fill":this.options
.backgroundColor
.toRGBString(),"stroke":"none"};
8942 if(this.layout
.style
=="bar"||this.layout
.style
=="line"){
8943 this._drawRect(this.area
.x
,this.area
.y
,this.area
.w
,this.area
.h
,_401
);
8944 var _402
=this.layout
.yticks
;
8946 if(this.layout
.style
=="bar"&&this.layout
.options
.barOrientation
=="horizontal"){
8947 _402
=this.layout
.xticks
;
8950 for(var i
=0;i
<_402
.length
;i
++){
8956 x
=_402
[i
][0]*this.area
.w
+this.area
.x
;
8962 y
=_402
[i
][0]*this.area
.h
+this.area
.y
;
8966 this._drawRect(x
,y
,w
,h
,{"fill":this.options
.axisLineColor
.toRGBString()});
8969 PlotKit
.SweetSVGRenderer
.__super__
._renderBackground
.call(this);
8972 PlotKit
.SweetSVG
={};
8973 PlotKit
.SweetSVG
.SweetSVGRenderer
=PlotKit
.SweetSVGRenderer
;
8974 PlotKit
.SweetSVG
.EXPORT
=["SweetSVGRenderer"];
8975 PlotKit
.SweetSVG
.EXPORT_OK
=["SweetSVGRenderer"];
8976 PlotKit
.SweetSVG
.__new__
=function(){
8977 var m
=MochiKit
.Base
;
8978 m
.nameFunctions(this);
8979 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
8981 PlotKit
.SweetSVG
.__new__();
8982 MochiKit
.Base
._exportSymbols(this,PlotKit
.SweetSVG
);
8984 if(typeof (PlotKit
.CanvasRenderer
)=="undefined"){
8989 throw "PlotKit.EasyPlot depends on all of PlotKit's components";
8991 if(typeof (PlotKit
.EasyPlot
)=="undefined"){
8992 PlotKit
.EasyPlot
={};
8994 PlotKit
.EasyPlot
.NAME
="PlotKit.EasyPlot";
8995 PlotKit
.EasyPlot
.VERSION
=PlotKit
.VERSION
;
8996 PlotKit
.EasyPlot
.__repr__
=function(){
8997 return "["+this.NAME
+" "+this.VERSION
+"]";
8999 PlotKit
.EasyPlot
.toString
=function(){
9000 return this.__repr__();
9002 PlotKit
.EasyPlot
=function(_404
,_405
,_406
,_407
){
9003 this.layout
=new Layout(_404
,_405
);
9005 this.width
=parseInt(_406
.getAttribute("width"));
9006 this.height
=parseInt(_406
.getAttribute("height"));
9007 this.deferredCount
=0;
9009 this.width
=this.divElem
.width
?this.divElem
.width
:300;
9012 this.height
=this.divElem
.height
?this.divElem
.height
:300;
9014 if(isArrayLike(_407
)){
9015 for(var i
=0;i
<_407
.length
;i
++){
9016 if(typeof (_407
[i
])=="string"){
9017 this.deferredCount
++;
9018 var d
=MochiKit
.Async
.doSimpleXMLHttpRequest(_407
[i
]);
9019 d
.addCallback(MochiKit
.Base
.bind(PlotKit
.EasyPlot
.onDataLoaded
,this));
9021 if(isArrayLike(_407
[i
])){
9022 this.layout
.addDataset("data-"+i
,_407
[i
]);
9027 if(!isUndefinedOrNull(_407
)){
9028 throw "Passed datasources are not Array like";
9031 if(CanvasRenderer
.isSupported()){
9032 this.element
=CANVAS({"id":this.divElem
.getAttribute("id")+"-canvas","width":this.width
,"height":this.height
},"");
9033 this.divElem
.appendChild(this.element
);
9034 this.renderer
=new SweetCanvasRenderer(this.element
,this.layout
,_405
);
9036 if(SVGRenderer
.isSupported()){
9037 this.element
=SVGRenderer
.SVG({"id":this.divElem
.getAttribute("id")+"-svg","width":this.width
,"height":this.height
,"version":"1.1","baseProfile":"full"},"");
9038 this.divElem
.appendChild(this.element
);
9039 this.renderer
=new SweetSVGRenderer(this.element
,this.layout
,_405
);
9042 if((this.deferredCount
==0)&&(PlotKit
.Base
.keys(this.layout
.datasets
).length
>0)){
9043 this.layout
.evaluate();
9044 this.renderer
.clear();
9045 this.renderer
.render();
9048 PlotKit
.EasyPlot
.onDataLoaded
=function(_409
){
9049 var _410
=new Array();
9050 var _411
=_409
.responseText
.split("\n");
9051 for(var i
=0;i
<_411
.length
;i
++){
9052 var _412
=MochiKit
.Format
.strip(_411
[i
]);
9053 if((_412
.length
>1)&&(_412
.charAt(0)!="#")){
9054 _410
.push(_412
.split(","));
9057 this.layout
.addDataset("data-ajax-"+this.deferredCount
,_410
);
9058 this.deferredCount
--;
9059 if((this.deferredCount
==0)&&(PlotKit
.Base
.keys(this.layout
.datasets
).length
>0)){
9060 this.layout
.evaluate();
9061 this.renderer
.clear();
9062 this.renderer
.render();
9065 PlotKit
.EasyPlot
.prototype.reload
=function(){
9066 this.layout
.evaluate();
9067 this.renderer
.clear();
9068 this.renderer
.render();
9070 PlotKit
.EasyPlotModule
={};
9071 PlotKit
.EasyPlotModule
.EasyPlot
=PlotKit
.EasyPlot
;
9072 PlotKit
.EasyPlotModule
.EXPORT
=["EasyPlot"];
9073 PlotKit
.EasyPlotModule
.EXPORT_OK
=[];
9074 PlotKit
.EasyPlotModule
.__new__
=function(){
9075 var m
=MochiKit
.Base
;
9076 m
.nameFunctions(this);
9077 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
9079 PlotKit
.EasyPlotModule
.__new__();
9080 MochiKit
.Base
._exportSymbols(this,PlotKit
.EasyPlotModule
);
9083 // Copyright 2006 Dan Vanderkam (danvdk@gmail.com)
9084 // All Rights Reserved.
9087 * @fileoverview Subclasses various parts of PlotKit to meet the additional
9088 * needs of DateGraph: grid overlays and error bars
9091 // Subclass PlotKit.Layout to add:
9092 // 1. Sigma/errorBars properties
9093 // 2. Copy error terms for PlotKit.CanvasRenderer._renderLineChart
9096 * Creates a new DateGraphLayout object. Options are the same as those allowed
9097 * by the PlotKit.Layout constructor.
9098 * @param {Object} options Options for PlotKit.Layout
9099 * @return {Object} The DateGraphLayout object
9101 DateGraphLayout
= function(options
) {
9102 PlotKit
.Layout
.call(this, "line", options
);
9104 DateGraphLayout
.prototype = new PlotKit
.Layout();
9107 * Behaves the same way as PlotKit.Layout, but also copies the errors
9110 DateGraphLayout
.prototype.evaluateWithError
= function() {
9112 if (!this.options
.errorBars
) return;
9114 // Copy over the error terms
9115 var i
= 0; // index in this.points
9116 for (var setName
in this.datasets
) {
9118 var dataset
= this.datasets
[setName
];
9119 if (PlotKit
.Base
.isFuncLike(dataset
)) continue;
9120 for (var j
= 0; j
< dataset
.length
; j
++, i
++) {
9121 var item
= dataset
[j
];
9122 var xv
= parseFloat(item
[0]);
9123 var yv
= parseFloat(item
[1]);
9125 if (xv
== this.points
[i
].xval
&&
9126 yv
== this.points
[i
].yval
) {
9127 this.points
[i
].errorMinus
= parseFloat(item
[2]);
9128 this.points
[i
].errorPlus
= parseFloat(item
[3]);
9135 * Convenience function to remove all the data sets from a graph
9137 DateGraphLayout
.prototype.removeAllDatasets
= function() {
9138 delete this.datasets
;
9139 this.datasets
= new Array();
9143 * Change the values of various layout options
9144 * @param {Object} new_options an associative array of new properties
9146 DateGraphLayout
.prototype.updateOptions
= function(new_options
) {
9147 MochiKit
.Base
.update(this.options
, new_options
? new_options
: {});
9150 // Subclass PlotKit.CanvasRenderer to add:
9151 // 1. X/Y grid overlay
9152 // 2. Ability to draw error bars (if required)
9155 * Sets some PlotKit.CanvasRenderer options
9156 * @param {Object} element The canvas to attach to
9157 * @param {Layout} layout The DateGraphLayout object for this graph.
9158 * @param {Object} options Options to pass on to CanvasRenderer
9160 DateGraphCanvasRenderer
= function(element
, layout
, options
) {
9161 PlotKit
.CanvasRenderer
.call(this, element
, layout
, options
);
9162 this.options
.shouldFill
= false;
9163 this.options
.shouldStroke
= true;
9164 this.options
.drawYGrid
= true;
9165 this.options
.drawXGrid
= true;
9166 this.options
.gridLineColor
= MochiKit
.Color
.Color
.grayColor();
9167 MochiKit
.Base
.update(this.options
, options
);
9169 // TODO(danvk) This shouldn't be necessary: effects should be overlaid
9170 this.options
.drawBackground
= false;
9172 DateGraphCanvasRenderer
.prototype = new PlotKit
.CanvasRenderer();
9175 * Draw an X/Y grid on top of the existing plot
9177 DateGraphCanvasRenderer
.prototype.render
= function() {
9178 // Do the ordinary rendering, as before
9179 // TODO(danvk) Call super.render()
9180 this._renderLineChart();
9181 this._renderLineAxis();
9183 // Draw the new X/Y grid
9184 var ctx
= this.element
.getContext("2d");
9185 if (this.options
.drawYGrid
) {
9186 var ticks
= this.layout
.yticks
;
9188 ctx
.strokeStyle
= this.options
.gridLineColor
.toRGBString();
9189 ctx
.lineWidth
= this.options
.axisLineWidth
;
9190 for (var i
= 0; i
< ticks
.length
; i
++) {
9191 var x
= this.area
.x
;
9192 var y
= this.area
.y
+ ticks
[i
][0] * this.area
.h
;
9195 ctx
.lineTo(x
+ this.area
.w
, y
);
9201 if (this.options
.drawXGrid
) {
9202 var ticks
= this.layout
.xticks
;
9204 ctx
.strokeStyle
= this.options
.gridLineColor
.toRGBString();
9205 ctx
.lineWidth
= this.options
.axisLineWidth
;
9206 for (var i
=0; i
<ticks
.length
; i
++) {
9207 var x
= this.area
.x
+ ticks
[i
][0] * this.area
.w
;
9208 var y
= this.area
.y
+ this.area
.h
;
9211 ctx
.lineTo(x
, this.area
.y
);
9219 * Overrides the CanvasRenderer method to draw error bars
9221 DateGraphCanvasRenderer
.prototype._renderLineChart
= function() {
9222 var context
= this.element
.getContext("2d");
9223 var colorCount
= this.options
.colorScheme
.length
;
9224 var colorScheme
= this.options
.colorScheme
;
9225 var setNames
= MochiKit
.Base
.keys(this.layout
.datasets
);
9226 var errorBars
= this.layout
.options
.errorBars
;
9227 var setCount
= setNames
.length
;
9228 var bind
= MochiKit
.Base
.bind
;
9229 var partial
= MochiKit
.Base
.partial
;
9232 var updatePoint
= function(point
) {
9233 point
.canvasx
= this.area
.w
* point
.x
+ this.area
.x
;
9234 point
.canvasy
= this.area
.h
* point
.y
+ this.area
.y
;
9236 MochiKit
.Iter
.forEach(this.layout
.points
, updatePoint
, this);
9239 var makePath
= function(ctx
) {
9240 for (var i
= 0; i
< setCount
; i
++) {
9241 var setName
= setNames
[i
];
9242 var color
= colorScheme
[i
%colorCount
];
9243 var strokeX
= this.options
.strokeColorTransform
;
9245 // setup graphics context
9247 context
.strokeStyle
= color
.toRGBString();
9248 context
.lineWidth
= this.options
.strokeWidth
;
9250 var point
= this.layout
.points
[0];
9251 var first_point
= true;
9252 var addPoint
= function(ctx_
, point
) {
9253 if (point
.name
== setName
) {
9255 ctx_
.moveTo(point
.canvasx
, point
.canvasy
);
9257 ctx_
.lineTo(point
.canvasx
, point
.canvasy
);
9258 first_point
= false;
9261 MochiKit
.Iter
.forEach(this.layout
.points
, partial(addPoint
, ctx
), this);
9266 var makeErrorBars
= function(ctx
) {
9267 for (var i
= 0; i
< setCount
; i
++) {
9268 var setName
= setNames
[i
];
9269 var color
= colorScheme
[i
% colorCount
];
9270 var strokeX
= this.options
.strokeColorTransform
;
9272 // setup graphics context
9274 context
.strokeStyle
= color
.toRGBString();
9275 context
.lineWidth
= this.options
.strokeWidth
;
9277 var prevYs
= [-1, -1];
9279 var yscale
= this.layout
.yscale
;
9280 var errorTrapezoid
= function(ctx_
,point
) {
9282 if (point
.name
== setName
) {
9283 var newYs
= [ point
.y
- point
.errorPlus
* yscale
,
9284 point
.y
+ point
.errorMinus
* yscale
];
9285 newYs
[0] = this.area
.h
* newYs
[0] + this.area
.y
;
9286 newYs
[1] = this.area
.h
* newYs
[1] + this.area
.y
;
9288 ctx_
.moveTo(prevX
, prevYs
[0]);
9289 ctx_
.lineTo(point
.canvasx
, newYs
[0]);
9290 ctx_
.lineTo(point
.canvasx
, newYs
[1]);
9291 ctx_
.lineTo(prevX
, prevYs
[1]);
9294 prevYs
[0] = newYs
[0];
9295 prevYs
[1] = newYs
[1];
9296 prevX
= point
.canvasx
;
9299 // should be same color as the lines
9300 var err_color
= color
.colorWithAlpha(0.15);
9301 ctx
.fillStyle
= err_color
.toRGBString();
9303 MochiKit
.Iter
.forEach(this.layout
.points
, partial(errorTrapezoid
, ctx
), this);
9309 bind(makeErrorBars
, this)(context
);
9310 bind(makePath
, this)(context
);
9313 // Copyright 2006 Dan Vanderkam (danvdk@gmail.com)
9314 // All Rights Reserved.
9317 * @fileoverview Creates an interactive, zoomable graph based on a CSV file or
9318 * string. DateGraph can handle multiple series with or without error bars. The
9319 * date/value ranges will be automatically set. DateGraph uses the
9320 * <canvas> tag, so it only works in FF1.5+.
9321 * @author danvdk@gmail.com (Dan Vanderkam)
9324 <div id="graphdiv" style="width:800px; height:500px;"></div>
9325 <script type="text/javascript">
9326 new DateGraph(document.getElementById("graphdiv"),
9328 ["Series 1", "Series 2"],
9332 The CSV file is of the form
9337 If null is passed as the third parameter (series names), then the first line
9338 of the CSV file is assumed to contain names for each series.
9340 If the 'errorBars' option is set in the constructor, the input should be of
9343 YYYYMMDD,A1,sigmaA1,B1,sigmaB1,...
9344 YYYYMMDD,A2,sigmaA2,B2,sigmaB2,...
9346 If the 'fractions' option is set, the input should be of the form:
9348 YYYYMMDD,A1/B1,A2/B2,...
9349 YYYYMMDD,A1/B1,A2/B2,...
9351 And error bars will be calculated automatically using a binomial distribution.
9353 For further documentation and examples, see http://www/~danvk/dg/
9358 * An interactive, zoomable graph
9359 * @param {String | Function} file A file containing CSV data or a function that
9360 * returns this data. The expected format for each line is
9361 * YYYYMMDD,val1,val2,... or, if attrs.errorBars is set,
9362 * YYYYMMDD,val1,stddev1,val2,stddev2,...
9363 * @param {Array.<String>} labels Labels for the data series
9364 * @param {Object} attrs Various other attributes, e.g. errorBars determines
9365 * whether the input data contains error ranges.
9367 DateGraph
= function(div
, file
, labels
, attrs
) {
9368 if (arguments
.length
> 0)
9369 this.__init__(div
, file
, labels
, attrs
);
9372 DateGraph
.NAME
= "DateGraph";
9373 DateGraph
.VERSION
= "1.1";
9374 DateGraph
.__repr__
= function() {
9375 return "[" + this.NAME
+ " " + this.VERSION
+ "]";
9377 DateGraph
.toString
= function() {
9378 return this.__repr__();
9381 // Various default values
9382 DateGraph
.DEFAULT_ROLL_PERIOD
= 1;
9383 DateGraph
.DEFAULT_WIDTH
= 480;
9384 DateGraph
.DEFAULT_HEIGHT
= 320;
9385 DateGraph
.DEFAULT_STROKE_WIDTH
= 1.0;
9386 DateGraph
.AXIS_LINE_WIDTH
= 0.3;
9389 * Initializes the DateGraph. This creates a new DIV and constructs the PlotKit
9390 * and interaction <canvas> inside of it. See the constructor for details
9391 * on the parameters.
9392 * @param {String | Function} file Source data
9393 * @param {Array.<String>} labels Names of the data series
9394 * @param {Object} attrs Miscellaneous other options
9397 DateGraph
.prototype.__init__
= function(div
, file
, labels
, attrs
) {
9398 // Copy the important bits into the object
9399 this.maindiv_
= div
;
9400 this.labels_
= labels
;
9402 this.rollPeriod_
= attrs
.rollPeriod
|| DateGraph
.DEFAULT_ROLL_PERIOD
;
9403 this.previousVerticalX_
= -1;
9404 this.width_
= parseInt(div
.style
.width
, 10);
9405 this.height_
= parseInt(div
.style
.height
, 10);
9406 this.errorBars_
= attrs
.errorBars
|| false;
9407 this.fractions_
= attrs
.fractions
|| false;
9408 this.strokeWidth_
= attrs
.strokeWidth
|| DateGraph
.DEFAULT_STROKE_WIDTH
;
9409 this.dateWindow_
= attrs
.dateWindow
|| null;
9410 this.valueRange_
= attrs
.valueRange
|| null;
9411 this.labelsSeparateLines
= attrs
.labelsSeparateLines
|| false;
9412 this.labelsDiv_
= attrs
.labelsDiv
|| null;
9413 this.labelsKMB_
= attrs
.labelsKMB
|| false;
9414 this.minTickSize_
= attrs
.minTickSize
|| 0;
9415 this.xValueParser_
= attrs
.xValueParser
|| DateGraph
.prototype.dateParser
;
9416 this.xValueFormatter_
= attrs
.xValueFormatter
||
9417 DateGraph
.prototype.dateString_
;
9418 this.xTicker_
= attrs
.xTicker
|| DateGraph
.prototype.dateTicker
;
9419 this.sigma_
= attrs
.sigma
|| 2.0;
9420 this.wilsonInterval_
= attrs
.wilsonInterval
|| true;
9421 this.customBars_
= attrs
.customBars
|| false;
9422 this.attrs_
= attrs
;
9424 // Make a note of whether labels will be pulled from the CSV file.
9425 this.labelsFromCSV_
= (this.labels_
== null);
9426 if (this.labels_
== null)
9429 // Prototype of the callback is "void clickCallback(event, date)"
9430 this.clickCallback_
= attrs
.clickCallback
|| null;
9432 // Prototype of zoom callback is "void dragCallback(minDate, maxDate)"
9433 this.zoomCallback_
= attrs
.zoomCallback
|| null;
9435 // Create the containing DIV and other interactive elements
9436 this.createInterface_();
9438 // Create the PlotKit grapher
9439 this.layoutOptions_
= { 'errorBars': (this.errorBars_
|| this.customBars_
),
9440 'xOriginIsZero': false };
9441 MochiKit
.Base
.update(this.layoutOptions_
, attrs
);
9442 this.setColors_(attrs
);
9444 this.layout_
= new DateGraphLayout(this.layoutOptions_
);
9446 this.renderOptions_
= { colorScheme
: this.colors_
,
9448 strokeWidth
: this.strokeWidth_
,
9449 axisLabelFontSize
: 14,
9450 axisLineWidth
: DateGraph
.AXIS_LINE_WIDTH
};
9451 MochiKit
.Base
.update(this.renderOptions_
, attrs
);
9452 this.plotter_
= new DateGraphCanvasRenderer(this.hidden_
, this.layout_
,
9453 this.renderOptions_
);
9455 this.createStatusMessage_();
9456 this.createRollInterface_();
9457 this.createDragInterface_();
9459 MochiKit
.DOM
.addLoadEvent(this.start_());
9463 * Returns the current rolling period, as set by the user or an option.
9464 * @return {Number} The number of days in the rolling window
9466 DateGraph
.prototype.rollPeriod
= function() {
9467 return this.rollPeriod_
;
9471 * Generates interface elements for the DateGraph: a containing div, a div to
9472 * display the current point, and a textbox to adjust the rolling average
9476 DateGraph
.prototype.createInterface_
= function() {
9477 // Create the all-enclosing graph div
9478 var enclosing
= this.maindiv_
;
9480 this.graphDiv
= MochiKit
.DOM
.DIV( { style
: { 'width': this.width_
+ "px",
9481 'height': this.height_
+ "px"
9483 appendChildNodes(enclosing
, this.graphDiv
);
9485 // Create the canvas to store
9486 var canvas
= MochiKit
.DOM
.CANVAS
;
9487 this.canvas_
= canvas( { style
: { 'position': 'absolute' },
9489 height
: this.height_
});
9490 appendChildNodes(this.graphDiv
, this.canvas_
);
9492 this.hidden_
= this.createPlotKitCanvas_(this.canvas_
);
9493 connect(this.hidden_
, 'onmousemove', this, function(e
) { this.mouseMove_(e
) });
9494 connect(this.hidden_
, 'onmouseout', this, function(e
) { this.mouseOut_(e
) });
9498 * Creates the canvas containing the PlotKit graph. Only plotkit ever draws on
9499 * this particular canvas. All DateGraph work is done on this.canvas_.
9500 * @param {Object} canvas The DateGraph canvas to over which to overlay the plot
9501 * @return {Object} The newly-created canvas
9504 DateGraph
.prototype.createPlotKitCanvas_
= function(canvas
) {
9505 var h
= document
.createElement("canvas");
9506 h
.style
.position
= "absolute";
9507 h
.style
.top
= canvas
.style
.top
;
9508 h
.style
.left
= canvas
.style
.left
;
9509 h
.width
= this.width_
;
9510 h
.height
= this.height_
;
9511 MochiKit
.DOM
.appendChildNodes(this.graphDiv
, h
);
9516 * Generate a set of distinct colors for the data series. This is done with a
9517 * color wheel. Saturation/Value are customizable, and the hue is
9518 * equally-spaced around the color wheel. If a custom set of colors is
9519 * specified, that is used instead.
9520 * @param {Object} attrs Various attributes, e.g. saturation and value
9523 DateGraph
.prototype.setColors_
= function(attrs
) {
9524 var num
= this.labels_
.length
;
9526 if (!attrs
.colors
) {
9527 var sat
= attrs
.colorSaturation
|| 1.0;
9528 var val
= attrs
.colorValue
|| 0.5;
9529 for (var i
= 1; i
<= num
; i
++) {
9530 var hue
= (1.0*i
/(1+num
));
9531 this.colors_
.push( MochiKit
.Color
.Color
.fromHSV(hue
, sat
, val
) );
9534 for (var i
= 0; i
< num
; i
++) {
9535 var colorStr
= attrs
.colors
[i
% attrs
.colors
.length
];
9536 this.colors_
.push( MochiKit
.Color
.Color
.fromString(colorStr
) );
9542 * Create the div that contains information on the selected point(s)
9543 * This goes in the top right of the canvas, unless an external div has already
9547 DateGraph
.prototype.createStatusMessage_
= function(){
9548 if (!this.labelsDiv_
) {
9550 var messagestyle
= { "style": {
9551 "position": "absolute",
9554 "width": divWidth
+ "px",
9556 "left": this.width_
- divWidth
+ "px",
9557 "background": "white",
9558 "textAlign": "left",
9559 "overflow": "hidden"}};
9560 this.labelsDiv_
= MochiKit
.DOM
.DIV(messagestyle
);
9561 MochiKit
.DOM
.appendChildNodes(this.graphDiv
, this.labelsDiv_
);
9566 * Create the text box to adjust the averaging period
9567 * @return {Object} The newly-created text box
9570 DateGraph
.prototype.createRollInterface_
= function() {
9571 var padding
= this.plotter_
.options
.padding
;
9572 var textAttr
= { "type": "text",
9574 "value": this.rollPeriod_
,
9575 "style": { "position": "absolute",
9577 "top": (this.height_
- 25 - padding
.bottom
) + "px",
9578 "left": (padding
.left
+1) + "px" }
9580 var roller
= MochiKit
.DOM
.INPUT(textAttr
);
9581 var pa
= this.graphDiv
;
9582 MochiKit
.DOM
.appendChildNodes(pa
, roller
);
9583 connect(roller
, 'onchange', this,
9584 function() { this.adjustRoll(roller
.value
); });
9589 * Set up all the mouse handlers needed to capture dragging behavior for zoom
9590 * events. Uses MochiKit.Signal to attach all the event handlers.
9593 DateGraph
.prototype.createDragInterface_
= function() {
9596 // Tracks whether the mouse is down right now
9597 var mouseDown
= false;
9598 var dragStartX
= null;
9599 var dragStartY
= null;
9600 var dragEndX
= null;
9601 var dragEndY
= null;
9602 var prevEndX
= null;
9604 // Utility function to convert page-wide coordinates to canvas coords
9605 var px
= PlotKit
.Base
.findPosX(this.canvas_
);
9606 var py
= PlotKit
.Base
.findPosY(this.canvas_
);
9607 var getX
= function(e
) { return e
.mouse().page
.x
- px
};
9608 var getY
= function(e
) { return e
.mouse().page
.y
- py
};
9610 // Draw zoom rectangles when the mouse is down and the user moves around
9611 connect(this.hidden_
, 'onmousemove', function(event
) {
9613 dragEndX
= getX(event
);
9614 dragEndY
= getY(event
);
9616 self
.drawZoomRect_(dragStartX
, dragEndX
, prevEndX
);
9617 prevEndX
= dragEndX
;
9621 // Track the beginning of drag events
9622 connect(this.hidden_
, 'onmousedown', function(event
) {
9624 dragStartX
= getX(event
);
9625 dragStartY
= getY(event
);
9628 // If the user releases the mouse button during a drag, but not over the
9629 // canvas, then it doesn't count as a zooming action.
9630 connect(document
, 'onmouseup', this, function(event
) {
9638 // Temporarily cancel the dragging event when the mouse leaves the graph
9639 connect(this.hidden_
, 'onmouseout', this, function(event
) {
9646 // If the mouse is released on the canvas during a drag event, then it's a
9647 // zoom. Only do the zoom if it's over a large enough area (>= 10 pixels)
9648 connect(this.hidden_
, 'onmouseup', this, function(event
) {
9651 dragEndX
= getX(event
);
9652 dragEndY
= getY(event
);
9653 var regionWidth
= Math
.abs(dragEndX
- dragStartX
);
9654 var regionHeight
= Math
.abs(dragEndY
- dragStartY
);
9656 if (regionWidth
< 2 && regionHeight
< 2 &&
9657 self
.clickCallback_
!= null &&
9658 self
.lastx_
!= undefined
) {
9659 self
.clickCallback_(event
, new Date(self
.lastx_
));
9662 if (regionWidth
>= 10) {
9663 self
.doZoom_(Math
.min(dragStartX
, dragEndX
),
9664 Math
.max(dragStartX
, dragEndX
));
9666 self
.canvas_
.getContext("2d").clearRect(0, 0,
9668 self
.canvas_
.height
);
9676 // Double-clicking zooms back out
9677 connect(this.hidden_
, 'ondblclick', this, function(event
) {
9678 self
.dateWindow_
= null;
9679 self
.drawGraph_(self
.rawData_
);
9680 var minDate
= self
.rawData_
[0][0];
9681 var maxDate
= self
.rawData_
[self
.rawData_
.length
- 1][0];
9682 self
.zoomCallback_(minDate
, maxDate
);
9687 * Draw a gray zoom rectangle over the desired area of the canvas. Also clears
9688 * up any previous zoom rectangles that were drawn. This could be optimized to
9689 * avoid extra redrawing, but it's tricky to avoid interactions with the status
9691 * @param {Number} startX The X position where the drag started, in canvas
9693 * @param {Number} endX The current X position of the drag, in canvas coords.
9694 * @param {Number} prevEndX The value of endX on the previous call to this
9695 * function. Used to avoid excess redrawing
9698 DateGraph
.prototype.drawZoomRect_
= function(startX
, endX
, prevEndX
) {
9699 var ctx
= this.canvas_
.getContext("2d");
9701 // Clean up from the previous rect if necessary
9703 ctx
.clearRect(Math
.min(startX
, prevEndX
), 0,
9704 Math
.abs(startX
- prevEndX
), this.height_
);
9707 // Draw a light-grey rectangle to show the new viewing area
9708 if (endX
&& startX
) {
9709 ctx
.fillStyle
= "rgba(128,128,128,0.33)";
9710 ctx
.fillRect(Math
.min(startX
, endX
), 0,
9711 Math
.abs(endX
- startX
), this.height_
);
9716 * Zoom to something containing [lowX, highX]. These are pixel coordinates
9717 * in the canvas. The exact zoom window may be slightly larger if there are no
9718 * data points near lowX or highX. This function redraws the graph.
9719 * @param {Number} lowX The leftmost pixel value that should be visible.
9720 * @param {Number} highX The rightmost pixel value that should be visible.
9723 DateGraph
.prototype.doZoom_
= function(lowX
, highX
) {
9724 // Find the earliest and latest dates contained in this canvasx range.
9725 var points
= this.layout_
.points
;
9728 // Find the nearest [minDate, maxDate] that contains [lowX, highX]
9729 for (var i
= 0; i
< points
.length
; i
++) {
9730 var cx
= points
[i
].canvasx
;
9731 var x
= points
[i
].xval
;
9732 if (cx
< lowX
&& (minDate
== null || x
> minDate
)) minDate
= x
;
9733 if (cx
> highX
&& (maxDate
== null || x
< maxDate
)) maxDate
= x
;
9735 // Use the extremes if either is missing
9736 if (minDate
== null) minDate
= points
[0].xval
;
9737 if (maxDate
== null) maxDate
= points
[points
.length
-1].xval
;
9739 this.dateWindow_
= [minDate
, maxDate
];
9740 this.drawGraph_(this.rawData_
);
9741 this.zoomCallback_(minDate
, maxDate
);
9745 * When the mouse moves in the canvas, display information about a nearby data
9746 * point and draw dots over those points in the data series. This function
9747 * takes care of cleanup of previously-drawn dots.
9748 * @param {Object} event The mousemove event from the browser.
9751 DateGraph
.prototype.mouseMove_
= function(event
) {
9752 var canvasx
= event
.mouse().page
.x
- PlotKit
.Base
.findPosX(this.hidden_
);
9753 var points
= this.layout_
.points
;
9758 // Loop through all the points and find the date nearest to our current
9760 var minDist
= 1e+100;
9762 for (var i
= 0; i
< points
.length
; i
++) {
9763 var dist
= Math
.abs(points
[i
].canvasx
- canvasx
);
9764 if (dist
> minDist
) break;
9768 if (idx
>= 0) lastx
= points
[idx
].xval
;
9769 // Check that you can really highlight the last day's data
9770 if (canvasx
> points
[points
.length
-1].canvasx
)
9771 lastx
= points
[points
.length
-1].xval
;
9773 // Extract the points we've selected
9775 for (var i
= 0; i
< points
.length
; i
++) {
9776 if (points
[i
].xval
== lastx
) {
9777 selPoints
.push(points
[i
]);
9781 // Clear the previously drawn vertical, if there is one
9783 var ctx
= this.canvas_
.getContext("2d");
9784 if (this.previousVerticalX_
>= 0) {
9785 var px
= this.previousVerticalX_
;
9786 ctx
.clearRect(px
- circleSize
- 1, 0, 2 * circleSize
+ 2, this.height_
);
9789 if (selPoints
.length
> 0) {
9790 var canvasx
= selPoints
[0].canvasx
;
9792 // Set the status message to indicate the selected point(s)
9793 var replace
= this.xValueFormatter_(lastx
) + ":";
9794 var clen
= this.colors_
.length
;
9795 for (var i
= 0; i
< selPoints
.length
; i
++) {
9796 if (this.labelsSeparateLines
) {
9799 var point
= selPoints
[i
];
9800 replace
+= " <b><font color='" + this.colors_
[i
%clen
].toHexString() + "'>"
9801 + point
.name
+ "</font></b>:"
9802 + this.round_(point
.yval
, 2);
9804 this.labelsDiv_
.innerHTML
= replace
;
9806 // Save last x position for callbacks.
9807 this.lastx_
= lastx
;
9809 // Draw colored circles over the center of each selected point
9811 for (var i
= 0; i
< selPoints
.length
; i
++) {
9813 ctx
.fillStyle
= this.colors_
[i
%clen
].toRGBString();
9814 ctx
.arc(canvasx
, selPoints
[i
%clen
].canvasy
, circleSize
, 0, 360, false);
9819 this.previousVerticalX_
= canvasx
;
9824 * The mouse has left the canvas. Clear out whatever artifacts remain
9825 * @param {Object} event the mouseout event from the browser.
9828 DateGraph
.prototype.mouseOut_
= function(event
) {
9829 // Get rid of the overlay data
9830 var ctx
= this.canvas_
.getContext("2d");
9831 ctx
.clearRect(0, 0, this.width_
, this.height_
);
9832 this.labelsDiv_
.innerHTML
= "";
9836 * Convert a JS date (millis since epoch) to YYYY/MM/DD
9837 * @param {Number} date The JavaScript date (ms since epoch)
9838 * @return {String} A date of the form "YYYY/MM/DD"
9841 DateGraph
.prototype.dateString_
= function(date
) {
9842 var d
= new Date(date
);
9845 var year
= "" + d
.getFullYear();
9846 // Get a 0 padded month string
9847 var month
= "" + (d
.getMonth() + 1); //months are 0-offset, sigh
9848 if (month
.length
< 2) month
= "0" + month
;
9849 // Get a 0 padded day string
9850 var day
= "" + d
.getDate();
9851 if (day
.length
< 2) day
= "0" + day
;
9853 return year
+ "/" + month + "/" + day
;
9857 * Round a number to the specified number of digits past the decimal point.
9858 * @param {Number} num The number to round
9859 * @param {Number} places The number of decimals to which to round
9860 * @return {Number} The rounded number
9863 DateGraph
.prototype.round_
= function(num
, places
) {
9864 var shift
= Math
.pow(10, places
);
9865 return Math
.round(num
* shift
)/shift
;
9869 * Fires when there's data available to be graphed.
9870 * @param {String} data Raw CSV data to be plotted
9873 DateGraph
.prototype.loadedEvent_
= function(data
) {
9874 this.rawData_
= this.parseCSV_(data
);
9875 this.drawGraph_(this.rawData_
);
9878 DateGraph
.prototype.months
= ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
9879 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
9880 DateGraph
.prototype.quarters
= ["Jan", "Apr", "Jul", "Oct"];
9883 * Add ticks on the x-axis representing years, months, quarters, weeks, or days
9886 DateGraph
.prototype.addXTicks_
= function() {
9887 // Determine the correct ticks scale on the x-axis: quarterly, monthly, ...
9888 var startDate
, endDate
;
9889 if (this.dateWindow_
) {
9890 startDate
= this.dateWindow_
[0];
9891 endDate
= this.dateWindow_
[1];
9893 startDate
= this.rawData_
[0][0];
9894 endDate
= this.rawData_
[this.rawData_
.length
- 1][0];
9897 var xTicks
= this.xTicker_(startDate
, endDate
);
9898 this.layout_
.updateOptions({xTicks
: xTicks
});
9902 * Add ticks to the x-axis based on a date range.
9903 * @param {Number} startDate Start of the date window (millis since epoch)
9904 * @param {Number} endDate End of the date window (millis since epoch)
9905 * @return {Array.<Object>} Array of {label, value} tuples.
9908 DateGraph
.prototype.dateTicker
= function(startDate
, endDate
) {
9909 var ONE_DAY
= 24*60*60*1000;
9910 startDate
= startDate
/ ONE_DAY
;
9911 endDate
= endDate
/ ONE_DAY
;
9912 var dateSpan
= endDate
- startDate
;
9915 var isMonthly
= false;
9917 if (dateSpan
> 30 * 366) { // decadal
9921 } else if (dateSpan
> 4*366) { // annual
9924 } else if (dateSpan
> 366) { // quarterly
9925 scale
= this.quarters
;
9927 } else if (dateSpan
> 40) { // monthly
9928 scale
= this.months
;
9930 } else if (dateSpan
> 10) { // weekly
9931 for (var week
= startDate
- 14; week
< endDate
+ 14; week
+= 7) {
9932 scale
.push(week
* ONE_DAY
);
9935 for (var day
= startDate
- 14; day
< endDate
+ 14; day
+= 1) {
9936 scale
.push(day
* ONE_DAY
);
9943 var startYear
= 1900 + (new Date(startDate
* ONE_DAY
)).getYear();
9944 var endYear
= 1900 + (new Date(endDate
* ONE_DAY
)).getYear();
9945 for (var i
= startYear
; i
<= endYear
; i
++) {
9946 if (i
% yearMod
!= 0) continue;
9947 for (var j
= 0; j
< scale
.length
; j
++ ) {
9948 var date
= Date
.parse(scale
[j
] + " 1, " + i
);
9949 xTicks
.push( {label
: scale
[j
] + "'" + ("" + i
).substr(2,2), v
: date
} );
9953 for (var i
= 0; i
< scale
.length
; i
++) {
9954 var date
= new Date(scale
[i
]);
9955 var year
= date
.getFullYear().toString();
9956 var label
= this.months
[date
.getMonth()] + date
.getDate();
9957 label
+= "'" + year
.substr(year
.length
- 2, 2);
9958 xTicks
.push( {label
: label
, v
: date
} );
9965 * Add ticks when the x axis has numbers on it (instead of dates)
9966 * @param {Number} startDate Start of the date window (millis since epoch)
9967 * @param {Number} endDate End of the date window (millis since epoch)
9968 * @return {Array.<Object>} Array of {label, value} tuples.
9971 DateGraph
.prototype.numericTicks
= function(minV
, maxV
) {
9976 scale
= Math
.pow( 10, Math
.floor(Math
.log(maxV
)/Math
.log(10.0)) );
9979 // Add a smallish number of ticks at human-friendly points
9980 var nTicks
= (maxV
- minV
) / scale
;
9981 while (2 * nTicks
< 20) {
9984 if ((maxV
- minV
) / nTicks
< this.minTickSize_
) {
9985 nTicks
= this.round_((maxV
- minV
) / this.minTickSize_
, 1);
9988 // Construct labels for the ticks
9990 for (var i
= 0; i
<= nTicks
; i
++) {
9991 var tickV
= minV
+ i
* (maxV
- minV
) / nTicks
;
9992 var label
= this.round_(tickV
, 2);
9993 if (this.labelsKMB_
) {
9995 if (tickV
>= k
*k
*k
) {
9996 label
= this.round_(tickV
/(k
*k
*k
), 1) + "B";
9997 } else if (tickV
>= k
*k
) {
9998 label
= this.round_(tickV
/(k
*k
), 1) + "M";
9999 } else if (tickV
>= k
) {
10000 label
= this.round_(tickV
/k
, 1) + "K";
10003 ticks
.push( {label
: label
, v
: tickV
} );
10009 * Adds appropriate ticks on the y-axis
10010 * @param {Number} minY The minimum Y value in the data set
10011 * @param {Number} maxY The maximum Y value in the data set
10014 DateGraph
.prototype.addYTicks_
= function(minY
, maxY
) {
10015 // Set the number of ticks so that the labels are human-friendly.
10016 var ticks
= this.numericTicks(minY
, maxY
);
10017 this.layout_
.updateOptions( { yAxis
: [minY
, maxY
],
10022 * Update the graph with new data. Data is in the format
10023 * [ [date1, val1, val2, ...], [date2, val1, val2, ...] if errorBars=false
10024 * or, if errorBars=true,
10025 * [ [date1, [val1,stddev1], [val2,stddev2], ...], [date2, ...], ...]
10026 * @param {Array.<Object>} data The data (see above)
10029 DateGraph
.prototype.drawGraph_
= function(data
) {
10031 this.layout_
.removeAllDatasets();
10032 // Loop over all fields in the dataset
10033 for (var i
= 1; i
< data
[0].length
; i
++) {
10035 for (var j
= 0; j
< data
.length
; j
++) {
10036 var date
= data
[j
][0];
10037 series
[j
] = [date
, data
[j
][i
]];
10039 series
= this.rollingAverage(series
, this.rollPeriod_
);
10041 // Prune down to the desired range, if necessary (for zooming)
10042 var bars
= this.errorBars_
|| this.customBars_
;
10043 if (this.dateWindow_
) {
10044 var low
= this.dateWindow_
[0];
10045 var high
= this.dateWindow_
[1];
10047 for (var k
= 0; k
< series
.length
; k
++) {
10048 if (series
[k
][0] >= low
&& series
[k
][0] <= high
) {
10049 pruned
.push(series
[k
]);
10050 var y
= bars
? series
[k
][1][0] : series
[k
][1];
10051 if (maxY
== null || y
> maxY
) maxY
= y
;
10056 for (var j
= 0; j
< series
.length
; j
++) {
10057 var y
= bars
? series
[j
][1][0] : series
[j
][1];
10058 if (maxY
== null || y
> maxY
) {
10059 maxY
= bars
? y
+ series
[j
][1][1] : y
;
10066 for (var j
=0; j
<series
.length
; j
++)
10067 vals
[j
] = [series
[j
][0],
10068 series
[j
][1][0], series
[j
][1][1], series
[j
][1][2]];
10069 this.layout_
.addDataset(this.labels_
[i
- 1], vals
);
10071 this.layout_
.addDataset(this.labels_
[i
- 1], series
);
10075 // Use some heuristics to come up with a good maxY value, unless it's been
10076 // set explicitly by the user.
10077 if (this.valueRange_
!= null) {
10078 this.addYTicks_(this.valueRange_
[0], this.valueRange_
[1]);
10080 // Add some padding and round up to an integer to be human-friendly.
10082 if (maxY
<= 0.0) maxY
= 1.0;
10084 var scale
= Math
.pow(10, Math
.floor(Math
.log(maxY
) / Math
.log(10.0)));
10085 maxY
= scale
* Math
.ceil(maxY
/ scale
);
10087 this.addYTicks_(0, maxY
);
10092 // Tell PlotKit to use this new data and render itself
10093 this.layout_
.evaluateWithError();
10094 this.plotter_
.clear();
10095 this.plotter_
.render();
10096 this.canvas_
.getContext('2d').clearRect(0, 0,
10097 this.canvas_
.width
, this.canvas_
.height
);
10101 * Calculates the rolling average of a data set.
10102 * If originalData is [label, val], rolls the average of those.
10103 * If originalData is [label, [, it's interpreted as [value, stddev]
10104 * and the roll is returned in the same form, with appropriately reduced
10105 * stddev for each value.
10106 * Note that this is where fractional input (i.e. '5/10') is converted into
10108 * @param {Array} originalData The data in the appropriate format (see above)
10109 * @param {Number} rollPeriod The number of days over which to average the data
10111 DateGraph
.prototype.rollingAverage
= function(originalData
, rollPeriod
) {
10112 if (originalData
.length
< 2)
10113 return originalData
;
10114 var rollPeriod
= Math
.min(rollPeriod
, originalData
.length
- 1);
10115 var rollingData
= [];
10116 var sigma
= this.sigma_
;
10118 if (this.fractions_
) {
10120 var den
= 0; // numerator/denominator
10122 for (var i
= 0; i
< originalData
.length
; i
++) {
10123 num
+= originalData
[i
][1][0];
10124 den
+= originalData
[i
][1][1];
10125 if (i
- rollPeriod
>= 0) {
10126 num
-= originalData
[i
- rollPeriod
][1][0];
10127 den
-= originalData
[i
- rollPeriod
][1][1];
10130 var date
= originalData
[i
][0];
10131 var value
= den
? num
/ den
: 0.0;
10132 if (this.errorBars_
) {
10133 if (this.wilsonInterval_
) {
10134 // For more details on this confidence interval, see:
10135 // http://en.wikipedia.org/wiki
/Binomial_confidence_interval
10137 var p
= value
< 0 ? 0 : value
, n
= den
;
10138 var pm
= sigma
* Math
.sqrt(p
*(1-p
)/n + sigma*sigma/(4*n
*n
));
10139 var denom
= 1 + sigma
* sigma
/ den
;
10140 var low
= (p
+ sigma
* sigma
/ (2 * den) - pm) / denom
;
10141 var high
= (p
+ sigma
* sigma
/ (2 * den) + pm) / denom
;
10142 rollingData
[i
] = [date
,
10143 [p
* mult
, (p
- low
) * mult
, (high
- p
) * mult
]];
10145 rollingData
[i
] = [date
, [0, 0, 0]];
10148 var stddev
= den
? sigma
* Math
.sqrt(value
* (1 - value
) / den
) : 1.0;
10149 rollingData
[i
] = [date
, [mult
* value
, mult
* stddev
, mult
* stddev
]];
10152 rollingData
[i
] = [date
, mult
* value
];
10155 } else if (this.customBars_
) {
10156 // just ignore the rolling for now.
10157 // TODO(danvk): do something reasonable.
10158 for (var i
= 0; i
< originalData
.length
; i
++) {
10159 var data
= originalData
[i
][1];
10161 rollingData
[i
] = [originalData
[i
][0], [y
, y
- data
[0], data
[2] - y
]];
10164 // Calculate the rolling average for the first rollPeriod - 1 points where
10165 // there is not enough data to roll over the full number of days
10166 var num_init_points
= Math
.min(rollPeriod
- 1, originalData
.length
- 2);
10167 if (!this.errorBars_
){
10168 for (var i
= 0; i
< num_init_points
; i
++) {
10170 for (var j
= 0; j
< i
+ 1; j
++)
10171 sum
+= originalData
[j
][1];
10172 rollingData
[i
] = [originalData
[i
][0], sum
/ (i
+ 1)];
10174 // Calculate the rolling average for the remaining points
10175 for (var i
= Math
.min(rollPeriod
- 1, originalData
.length
- 2);
10176 i
< originalData
.length
;
10179 for (var j
= i
- rollPeriod
+ 1; j
< i
+ 1; j
++)
10180 sum
+= originalData
[j
][1];
10181 rollingData
[i
] = [originalData
[i
][0], sum
/ rollPeriod
];
10184 for (var i
= 0; i
< num_init_points
; i
++) {
10187 for (var j
= 0; j
< i
+ 1; j
++) {
10188 sum
+= originalData
[j
][1][0];
10189 variance
+= Math
.pow(originalData
[j
][1][1], 2);
10191 var stddev
= Math
.sqrt(variance
)/(i
+1);
10192 rollingData
[i
] = [originalData
[i
][0],
10193 [sum
/(i
+1), sigma
* stddev
, sigma
* stddev
]];
10195 // Calculate the rolling average for the remaining points
10196 for (var i
= Math
.min(rollPeriod
- 1, originalData
.length
- 2);
10197 i
< originalData
.length
;
10201 for (var j
= i
- rollPeriod
+ 1; j
< i
+ 1; j
++) {
10202 sum
+= originalData
[j
][1][0];
10203 variance
+= Math
.pow(originalData
[j
][1][1], 2);
10205 var stddev
= Math
.sqrt(variance
) / rollPeriod
;
10206 rollingData
[i
] = [originalData
[i
][0],
10207 [sum
/ rollPeriod
, sigma
* stddev
, sigma
* stddev
]];
10212 return rollingData
;
10216 * Parses a date, returning the number of milliseconds since epoch. This can be
10217 * passed in as an xValueParser in the DateGraph constructor.
10218 * @param {String} A date in YYYYMMDD format.
10219 * @return {Number} Milliseconds since epoch.
10222 DateGraph
.prototype.dateParser
= function(dateStr
) {
10223 var dateStrSlashed
;
10224 if (dateStr
.search("-") != -1) {
10225 dateStrSlashed
= dateStr
.replace("-", "/", "g");
10226 } else if (dateStr
.search("/") != -1) {
10227 return Date
.parse(dateStr
);
10229 dateStrSlashed
= dateStr
.substr(0,4) + "/" + dateStr
.substr(4,2)
10230 + "/" + dateStr
.substr(6,2);
10232 return Date
.parse(dateStrSlashed
);
10236 * Parses a string in a special csv format. We expect a csv file where each
10237 * line is a date point, and the first field in each line is the date string.
10238 * We also expect that all remaining fields represent series.
10239 * if this.errorBars_ is set, then interpret the fields as:
10240 * date, series1, stddev1, series2, stddev2, ...
10241 * @param {Array.<Object>} data See above.
10244 DateGraph
.prototype.parseCSV_
= function(data
) {
10246 var lines
= data
.split("\n");
10247 var start
= this.labelsFromCSV_
? 1 : 0;
10248 if (this.labelsFromCSV_
) {
10249 var labels
= lines
[0].split(",");
10250 labels
.shift(); // a "date" parameter is assumed.
10251 this.labels_
= labels
;
10252 // regenerate automatic colors.
10253 this.setColors_(this.attrs_
);
10254 this.renderOptions_
.colorScheme
= this.colors_
;
10255 MochiKit
.Base
.update(this.plotter_
.options
, this.renderOptions_
);
10256 MochiKit
.Base
.update(this.layoutOptions_
, this.attrs_
);
10259 for (var i
= start
; i
< lines
.length
; i
++) {
10260 var line
= lines
[i
];
10261 if (line
.length
== 0) continue; // skip blank lines
10262 var inFields
= line
.split(',');
10263 if (inFields
.length
< 2)
10267 fields
[0] = this.xValueParser_(inFields
[0]);
10269 // If fractions are expected, parse the numbers as "A/B
"
10270 if (this.fractions_) {
10271 for (var j = 1; j < inFields.length; j++) {
10272 // TODO(danvk): figure out an appropriate way to flag parse errors.
10273 var vals = inFields[j].split("/");
10274 fields[j] = [parseFloat(vals[0]), parseFloat(vals[1])];
10276 } else if (this.errorBars_) {
10277 // If there are error bars, values are (value, stddev) pairs
10278 for (var j = 1; j < inFields.length; j += 2)
10279 fields[(j + 1) / 2] = [parseFloat(inFields[j]),
10280 parseFloat(inFields[j + 1])];
10281 } else if (this.customBars_) {
10282 // Bars are a low;center;high tuple
10283 for (var j = 1; j < inFields.length; j++) {
10284 var vals = inFields[j].split(";");
10285 fields[j] = [ parseFloat(vals[0]),
10286 parseFloat(vals[1]),
10287 parseFloat(vals[2]) ];
10290 // Values are just numbers
10291 for (var j = 1; j < inFields.length; j++)
10292 fields[j] = parseFloat(inFields[j]);
10300 * Get the CSV data. If it's in a function, call that function. If it's in a
10301 * file, do an XMLHttpRequest to get it.
10304 DateGraph.prototype.start_ = function() {
10305 if (typeof this.file_ == 'function') {
10306 // Stubbed out to allow this to run off a filesystem
10307 this.loadedEvent_(this.file_());
10309 var req = new XMLHttpRequest();
10311 req.onreadystatechange = function () {
10312 if (req.readyState == 4) {
10313 if (req.status == 200) {
10314 caller.loadedEvent_(req.responseText);
10319 req.open("GET
", this.file_, true);
10325 * Changes various properties of the graph. These can include:
10327 * <li>file: changes the source data for the graph</li>
10328 * <li>errorBars: changes whether the data contains stddev</li>
10330 * @param {Object} attrs The new properties and values
10332 DateGraph.prototype.updateOptions = function(attrs) {
10333 if (attrs.errorBars) {
10334 this.errorBars_ = attrs.errorBars;
10336 if (attrs.customBars) {
10337 this.customBars_ = attrs.customBars;
10339 if (attrs.strokeWidth) {
10340 this.strokeWidth_ = attrs.strokeWidth;
10342 if (attrs.rollPeriod) {
10343 this.rollPeriod_ = attrs.rollPeriod;
10345 if (attrs.dateWindow) {
10346 this.dateWindow_ = attrs.dateWindow;
10348 if (attrs.valueRange) {
10349 this.valueRange_ = attrs.valueRange;
10351 if (attrs.minTickSize) {
10352 this.minTickSize_ = attrs.minTickSize;
10354 if (typeof(attrs.labels) != 'undefined') {
10355 this.labels_ = attrs.labels;
10356 this.labelsFromCSV_ = (attrs.labels == null);
10358 this.layout_.updateOptions({ 'errorBars': this.errorBars_ });
10359 if (attrs['file'] && attrs['file'] != this.file_) {
10360 this.file_ = attrs['file'];
10363 this.drawGraph_(this.rawData_);
10368 * Adjusts the number of days in the rolling average. Updates the graph to
10369 * reflect the new averaging period.
10370 * @param {Number} length Number of days over which to average the data.
10372 DateGraph.prototype.adjustRoll = function(length) {
10373 this.rollPeriod_ = length;
10374 this.drawGraph_(this.rawData_);