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.DOM");
1006 dojo
.require("MochiKit.Base");
1008 if(typeof (JSAN
)!="undefined"){
1009 JSAN
.use("MochiKit.Base",[]);
1012 if(typeof (MochiKit
.Base
)=="undefined"){
1017 throw "MochiKit.DOM depends on MochiKit.Base!";
1019 if(typeof (MochiKit
.DOM
)=="undefined"){
1022 MochiKit
.DOM
.NAME
="MochiKit.DOM";
1023 MochiKit
.DOM
.VERSION
="1.4";
1024 MochiKit
.DOM
.__repr__
=function(){
1025 return "["+this.NAME
+" "+this.VERSION
+"]";
1027 MochiKit
.DOM
.toString
=function(){
1028 return this.__repr__();
1030 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"];
1031 MochiKit
.DOM
.EXPORT_OK
=["domConverters"];
1032 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"]];
1033 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);");
1034 MochiKit
.Base
.update(MochiKit
.DOM
,{currentWindow
:function(){
1035 return MochiKit
.DOM
._window
;
1036 },currentDocument
:function(){
1037 return MochiKit
.DOM
._document
;
1038 },withWindow
:function(win
,func
){
1039 var self
=MochiKit
.DOM
;
1040 var _150
=self
._document
;
1041 var _151
=self
._window
;
1045 self
._document
=win
.document
;
1050 self
._document
=_150
;
1054 self
._document
=_150
;
1056 },formContents
:function(elem
){
1059 var m
=MochiKit
.Base
;
1060 var self
=MochiKit
.DOM
;
1061 if(typeof (elem
)=="undefined"||elem
===null){
1062 elem
=self
._document
.body
;
1064 elem
=self
.getElement(elem
);
1066 m
.nodeWalk(elem
,function(elem
){
1068 if(m
.isNotEmpty(name
)){
1069 var _15a
=elem
.tagName
.toUpperCase();
1070 if(_15a
==="INPUT"&&(elem
.type
=="radio"||elem
.type
=="checkbox")&&!elem
.checked
){
1073 if(_15a
==="SELECT"){
1074 if(elem
.type
=="select-one"){
1075 if(elem
.selectedIndex
>=0){
1076 var opt
=elem
.options
[elem
.selectedIndex
];
1079 var h
=opt
.outerHTML
;
1080 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
1092 var opts
=elem
.options
;
1098 for(var i
=0;i
<opts
.length
;i
++){
1105 var h
=opt
.outerHTML
;
1106 if(h
&&!h
.match(/^[^>]+\svalue\s*=/i)){
1116 if(_15a
==="FORM"||_15a
==="P"||_15a
==="SPAN"||_15a
==="DIV"){
1117 return elem
.childNodes
;
1120 _155
.push(elem
.value
||"");
1123 return elem
.childNodes
;
1126 },withDocument
:function(doc
,func
){
1127 var self
=MochiKit
.DOM
;
1128 var _163
=self
._document
;
1135 self
._document
=_163
;
1138 self
._document
=_163
;
1140 },registerDOMConverter
:function(name
,_166
,wrap
,_168
){
1141 MochiKit
.DOM
.domConverters
.register(name
,_166
,wrap
,_168
);
1142 },coerceToDOM
:function(node
,ctx
){
1143 var m
=MochiKit
.Base
;
1144 var im
=MochiKit
.Iter
;
1145 var self
=MochiKit
.DOM
;
1151 var _171
=self
.domConverters
;
1152 var _172
=arguments
.callee
;
1153 var _173
=m
.NotFound
;
1155 if(typeof (node
)=="undefined"||node
===null){
1158 if(typeof (node
)=="function"&&typeof (node
.length
)=="number"&&!(node
instanceof Function
)){
1161 if(typeof (node
.nodeType
)!="undefined"&&node
.nodeType
>0){
1164 if(typeof (node
)=="number"||typeof (node
)=="boolean"){
1165 node
=node
.toString();
1167 if(typeof (node
)=="string"){
1168 return self
._document
.createTextNode(node
);
1170 if(typeof (node
.__dom__
)=="function"){
1171 node
=node
.__dom__(ctx
);
1174 if(typeof (node
.dom
)=="function"){
1178 if(typeof (node
)=="function"){
1179 node
=node
.apply(ctx
,[ctx
]);
1190 return map(_172
,_174
,_16f(ctx
));
1194 node
=_171
.match(node
,ctx
);
1202 return self
._document
.createTextNode(node
.toString());
1205 },isChildNode
:function(node
,_176
){
1206 var self
=MochiKit
.DOM
;
1207 if(typeof (node
)=="string"){
1208 node
=self
.getElement(node
);
1210 if(typeof (_176
)=="string"){
1211 _176
=self
.getElement(_176
);
1216 while(node
&&node
.tagName
.toUpperCase()!="BODY"){
1217 node
=node
.parentNode
;
1223 },setNodeAttribute
:function(node
,attr
,_17a
){
1227 return MochiKit
.DOM
.updateNodeAttributes(node
,o
);
1232 },getNodeAttribute
:function(node
,attr
){
1233 var self
=MochiKit
.DOM
;
1234 var _17f
=self
.attributeArray
.renames
[attr
];
1235 node
=self
.getElement(node
);
1240 return node
.getAttribute(attr
);
1245 },removeNodeAttribute
:function(node
,attr
){
1246 var self
=MochiKit
.DOM
;
1247 var _183
=self
.attributeArray
.renames
[attr
];
1248 node
=self
.getElement(node
);
1253 return node
.removeAttribute(attr
);
1258 },updateNodeAttributes
:function(node
,_185
){
1260 var self
=MochiKit
.DOM
;
1261 if(typeof (node
)=="string"){
1262 elem
=self
.getElement(node
);
1265 var _188
=MochiKit
.Base
.updatetree
;
1266 if(self
.attributeArray
.compliant
){
1269 if(typeof (v
)=="object"&&typeof (elem
[k
])=="object"){
1270 if(k
=="style"&&MochiKit
.Style
){
1271 MochiKit
.Style
.setStyle(elem
,v
);
1276 if(k
.substring(0,2)=="on"){
1277 if(typeof (v
)=="string"){
1282 elem
.setAttribute(k
,v
);
1287 var _18b
=self
.attributeArray
.renames
;
1291 if(k
=="style"&&typeof (v
)=="string"){
1292 elem
.style
.cssText
=v
;
1294 if(typeof (_18c
)=="string"){
1297 if(typeof (elem
[k
])=="object"&&typeof (v
)=="object"){
1298 if(k
=="style"&&MochiKit
.Style
){
1299 MochiKit
.Style
.setStyle(elem
,v
);
1304 if(k
.substring(0,2)=="on"){
1305 if(typeof (v
)=="string"){
1310 elem
.setAttribute(k
,v
);
1319 },appendChildNodes
:function(node
){
1321 var self
=MochiKit
.DOM
;
1322 if(typeof (node
)=="string"){
1323 elem
=self
.getElement(node
);
1325 var _190
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1326 var _191
=MochiKit
.Base
.concat
;
1329 if(typeof (n
)=="undefined"||n
===null){
1331 if(typeof (n
.nodeType
)=="number"){
1332 elem
.appendChild(n
);
1339 },insertSiblingNodesBefore
:function(node
){
1341 var self
=MochiKit
.DOM
;
1342 if(typeof (node
)=="string"){
1343 elem
=self
.getElement(node
);
1345 var _196
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1346 var _197
=elem
.parentNode
;
1347 var _198
=MochiKit
.Base
.concat
;
1350 if(typeof (n
)=="undefined"||n
===null){
1352 if(typeof (n
.nodeType
)=="number"){
1353 _197
.insertBefore(n
,elem
);
1360 },insertSiblingNodesAfter
:function(node
){
1362 var self
=MochiKit
.DOM
;
1363 if(typeof (node
)=="string"){
1364 elem
=self
.getElement(node
);
1366 var _19d
=[self
.coerceToDOM(MochiKit
.Base
.extend(null,arguments
,1),elem
)];
1367 if(elem
.nextSibling
){
1368 return self
.insertSiblingNodesBefore(elem
.nextSibling
,_19d
);
1370 return self
.appendChildNodes(elem
.parentNode
,_19d
);
1372 },replaceChildNodes
:function(node
){
1374 var self
=MochiKit
.DOM
;
1375 if(typeof (node
)=="string"){
1376 elem
=self
.getElement(node
);
1380 while((_1a1
=elem
.firstChild
)){
1381 elem
.removeChild(_1a1
);
1383 if(arguments
.length
<2){
1386 return self
.appendChildNodes
.apply(this,arguments
);
1388 },createDOM
:function(name
,_1a3
){
1390 var self
=MochiKit
.DOM
;
1391 var m
=MochiKit
.Base
;
1392 if(typeof (_1a3
)=="string"||typeof (_1a3
)=="number"){
1393 var args
=m
.extend([name
,null],arguments
,1);
1394 return arguments
.callee
.apply(this,args
);
1396 if(typeof (name
)=="string"){
1397 var _1a8
=self
._xhtml
;
1398 if(_1a3
&&!self
.attributeArray
.compliant
){
1401 _1a9
+=" name=\""+self
.escapeHTML(_1a3
.name
)+"\"";
1403 if(name
=="input"&&"type" in _1a3
){
1404 _1a9
+=" type=\""+self
.escapeHTML(_1a3
.type
)+"\"";
1407 name
="<"+name
+_1a9
+">";
1411 var d
=self
._document
;
1412 if(_1a8
&&d
===document
){
1413 elem
=d
.createElementNS("http://www.w3.org/1999/xhtml",name
);
1415 elem
=d
.createElement(name
);
1421 self
.updateNodeAttributes(elem
,_1a3
);
1423 if(arguments
.length
<=2){
1426 var args
=m
.extend([elem
],arguments
,2);
1427 return self
.appendChildNodes
.apply(this,args
);
1429 },createDOMFunc
:function(){
1430 var m
=MochiKit
.Base
;
1431 return m
.partial
.apply(this,m
.extend([MochiKit
.DOM
.createDOM
],arguments
));
1432 },removeElement
:function(elem
){
1433 var e
=MochiKit
.DOM
.getElement(elem
);
1434 e
.parentNode
.removeChild(e
);
1436 },swapDOM
:function(dest
,src
){
1437 var self
=MochiKit
.DOM
;
1438 dest
=self
.getElement(dest
);
1439 var _1b1
=dest
.parentNode
;
1441 src
=self
.getElement(src
);
1442 _1b1
.replaceChild(src
,dest
);
1444 _1b1
.removeChild(dest
);
1447 },getElement
:function(id
){
1448 var self
=MochiKit
.DOM
;
1449 if(arguments
.length
==1){
1450 return ((typeof (id
)=="string")?self
._document
.getElementById(id
):id
);
1452 return MochiKit
.Base
.map(self
.getElement
,arguments
);
1454 },getElementsByTagAndClassName
:function(_1b4
,_1b5
,_1b6
){
1455 var self
=MochiKit
.DOM
;
1456 if(typeof (_1b4
)=="undefined"||_1b4
===null){
1459 if(typeof (_1b6
)=="undefined"||_1b6
===null){
1460 _1b6
=self
._document
;
1462 _1b6
=self
.getElement(_1b6
);
1463 var _1b8
=(_1b6
.getElementsByTagName(_1b4
)||self
._document
.all
);
1464 if(typeof (_1b5
)=="undefined"||_1b5
===null){
1465 return MochiKit
.Base
.extend(null,_1b8
);
1468 for(var i
=0;i
<_1b8
.length
;i
++){
1470 var cls
=_1bb
.className
;
1474 var _1bd
=cls
.split(" ");
1475 for(var j
=0;j
<_1bd
.length
;j
++){
1483 },_newCallStack
:function(path
,once
){
1484 var rval
=function(){
1485 var _1c2
=arguments
.callee
.callStack
;
1486 for(var i
=0;i
<_1c2
.length
;i
++){
1487 if(_1c2
[i
].apply(this,arguments
)===false){
1501 },addToCallStack
:function(_1c4
,path
,func
,once
){
1502 var self
=MochiKit
.DOM
;
1503 var _1c9
=_1c4
[path
];
1505 if(!(typeof (_1c9
)=="function"&&typeof (_1c9
.callStack
)=="object"&&_1c9
.callStack
!==null)){
1506 _1ca
=self
._newCallStack(path
,once
);
1507 if(typeof (_1c9
)=="function"){
1508 _1ca
.callStack
.push(_1c9
);
1512 _1ca
.callStack
.push(func
);
1513 },addLoadEvent
:function(func
){
1514 var self
=MochiKit
.DOM
;
1515 self
.addToCallStack(self
._window
,"onload",func
,true);
1516 },focusOnLoad
:function(_1cd
){
1517 var self
=MochiKit
.DOM
;
1518 self
.addLoadEvent(function(){
1519 _1cd
=self
.getElement(_1cd
);
1524 },setElementClass
:function(_1cf
,_1d0
){
1525 var self
=MochiKit
.DOM
;
1526 var obj
=self
.getElement(_1cf
);
1527 if(self
.attributeArray
.compliant
){
1528 obj
.setAttribute("class",_1d0
);
1530 obj
.setAttribute("className",_1d0
);
1532 },toggleElementClass
:function(_1d3
){
1533 var self
=MochiKit
.DOM
;
1534 for(var i
=1;i
<arguments
.length
;i
++){
1535 var obj
=self
.getElement(arguments
[i
]);
1536 if(!self
.addElementClass(obj
,_1d3
)){
1537 self
.removeElementClass(obj
,_1d3
);
1540 },addElementClass
:function(_1d7
,_1d8
){
1541 var self
=MochiKit
.DOM
;
1542 var obj
=self
.getElement(_1d7
);
1543 var cls
=obj
.className
;
1544 if(cls
==undefined
||cls
.length
===0){
1545 self
.setElementClass(obj
,_1d8
);
1551 var _1dc
=cls
.split(" ");
1552 for(var i
=0;i
<_1dc
.length
;i
++){
1557 self
.setElementClass(obj
,cls
+" "+_1d8
);
1559 },removeElementClass
:function(_1de
,_1df
){
1560 var self
=MochiKit
.DOM
;
1561 var obj
=self
.getElement(_1de
);
1562 var cls
=obj
.className
;
1563 if(cls
==undefined
||cls
.length
===0){
1567 self
.setElementClass(obj
,"");
1570 var _1e3
=cls
.split(" ");
1571 for(var i
=0;i
<_1e3
.length
;i
++){
1574 self
.setElementClass(obj
,_1e3
.join(" "));
1579 },swapElementClass
:function(_1e5
,_1e6
,_1e7
){
1580 var obj
=MochiKit
.DOM
.getElement(_1e5
);
1581 var res
=MochiKit
.DOM
.removeElementClass(obj
,_1e6
);
1583 MochiKit
.DOM
.addElementClass(obj
,_1e7
);
1586 },hasElementClass
:function(_1ea
,_1eb
){
1587 var obj
=MochiKit
.DOM
.getElement(_1ea
);
1588 var cls
=obj
.className
;
1592 var _1ee
=cls
.split(" ");
1593 for(var i
=1;i
<arguments
.length
;i
++){
1595 for(var j
=0;j
<_1ee
.length
;j
++){
1596 if(_1ee
[j
]==arguments
[i
]){
1606 },escapeHTML
:function(s
){
1607 return s
.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");
1608 },toHTML
:function(dom
){
1609 return MochiKit
.DOM
.emitHTML(dom
).join("");
1610 },emitHTML
:function(dom
,lst
){
1611 if(typeof (lst
)=="undefined"||lst
===null){
1615 var self
=MochiKit
.DOM
;
1616 var _1f8
=self
.escapeHTML
;
1617 var _1f9
=self
.attributeArray
;
1620 if(typeof (dom
)=="string"){
1623 if(dom
.nodeType
==1){
1624 lst
.push("<"+dom
.tagName
.toLowerCase());
1627 for(var i
=0;i
<_1fb
.length
;i
++){
1629 _1fa
.push([" ",a
.name
,"=\"",_1f8(a
.value
),"\""]);
1632 for(i
=0;i
<_1fa
.length
;i
++){
1634 for(var j
=0;j
<_1fe
.length
;j
++){
1638 if(dom
.hasChildNodes()){
1640 _1f6
.push("</"+dom
.tagName
.toLowerCase()+">");
1641 var _200
=dom
.childNodes
;
1642 for(i
=_200
.length
-1;i
>=0;i
--){
1649 if(dom
.nodeType
==3){
1650 lst
.push(_1f8(dom
.nodeValue
));
1656 },scrapeText
:function(node
,_202
){
1659 var cn
=node
.childNodes
;
1661 for(var i
=0;i
<cn
.length
;i
++){
1662 arguments
.callee
.call(this,cn
[i
]);
1665 var _207
=node
.nodeValue
;
1666 if(typeof (_207
)=="string"){
1669 })(MochiKit
.DOM
.getElement(node
));
1673 return rval
.join("");
1675 },removeEmptyTextNodes
:function(_208
){
1676 _208
=MochiKit
.DOM
.getElement(_208
);
1677 for(var i
=0;i
<_208
.childNodes
.length
;i
++){
1678 var node
=_208
.childNodes
[i
];
1679 if(node
.nodeType
==3&&!/\S/.test(node
.nodeValue
)){
1680 node
.parentNode
.removeChild(node
);
1683 },makeClipping
:function(_20b
){
1684 _20b
=MochiKit
.DOM
.getElement(_20b
);
1685 var _20c
=_20b
.style
.overflow
;
1686 if((MochiKit
.Style
.getStyle(_20b
,"overflow")||"visible")!="hidden"){
1687 _20b
.style
.overflow
="hidden";
1690 },undoClipping
:function(_20d
,_20e
){
1691 _20d
=MochiKit
.DOM
.getElement(_20d
);
1695 _20d
.style
.overflow
=_20e
;
1696 },makePositioned
:function(_20f
){
1697 _20f
=MochiKit
.DOM
.getElement(_20f
);
1698 var pos
=MochiKit
.Style
.getStyle(_20f
,"position");
1699 if(pos
=="static"||!pos
){
1700 _20f
.style
.position
="relative";
1701 if(/Opera/.test(navigator
.userAgent
)){
1706 },undoPositioned
:function(_211
){
1707 _211
=MochiKit
.DOM
.getElement(_211
);
1708 if(_211
.style
.position
=="relative"){
1709 _211
.style
.position
=_211
.style
.top
=_211
.style
.left
=_211
.style
.bottom
=_211
.style
.right
="";
1711 },getFirstElementByTagAndClassName
:function(_212
,_213
,_214
){
1712 var self
=MochiKit
.DOM
;
1713 if(typeof (_212
)=="undefined"||_212
===null){
1716 if(typeof (_214
)=="undefined"||_214
===null){
1717 _214
=self
._document
;
1719 _214
=self
.getElement(_214
);
1720 var _216
=(_214
.getElementsByTagName(_212
)||self
._document
.all
);
1721 if(typeof (_213
)=="undefined"||_213
===null){
1724 for(var i
=0;i
<_216
.length
;i
++){
1726 var _219
=_218
.className
.split(" ");
1727 for(var j
=0;j
<_219
.length
;j
++){
1733 },getFirstParentByTagAndClassName
:function(elem
,_21c
,_21d
){
1734 var self
=MochiKit
.DOM
;
1735 elem
=self
.getElement(elem
);
1736 if(typeof (_21c
)=="undefined"||_21c
===null){
1739 _21c
=_21c
.toUpperCase();
1741 if(typeof (_21d
)=="undefined"||_21d
===null){
1746 while(elem
&&elem
.tagName
){
1747 elem
=elem
.parentNode
;
1748 if(_21c
=="*"&&_21d
===null){
1751 _21f
=elem
.className
.split(" ");
1752 _220
=elem
.tagName
.toUpperCase();
1753 if(_21d
===null&&_21c
==_220
){
1757 for(var i
=0;i
<_21f
.length
;i
++){
1758 if(_21c
=="*"&&_21f
[i
]==_21d
){
1761 if(_21c
==_220
&&_21f
[i
]==_21d
){
1770 },isParent
:function(_222
,_223
){
1771 if(!_222
.parentNode
||_222
==_223
){
1774 if(_222
.parentNode
==_223
){
1777 return MochiKit
.DOM
.isParent(_222
.parentNode
,_223
);
1778 },__new__
:function(win
){
1779 var m
=MochiKit
.Base
;
1780 if(typeof (document
)!="undefined"){
1781 this._document
=document
;
1782 var _226
="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
1783 this._xhtml
=(document
.documentElement
&&document
.createElementNS
&&document
.documentElement
.namespaceURI
===_226
);
1785 if(MochiKit
.MockDOM
){
1786 this._document
=MochiKit
.MockDOM
.document
;
1790 this.domConverters
=new m
.AdapterRegistry();
1791 var _227
=this._document
.createElement("span");
1793 if(_227
&&_227
.attributes
&&_227
.attributes
.length
>0){
1795 _228
=function(node
){
1796 return _229(_228
.ignoreAttrFilter
,node
.attributes
);
1799 var _22b
=_227
.attributes
;
1800 var _22c
=_228
.ignoreAttr
;
1801 for(var i
=0;i
<_22b
.length
;i
++){
1803 _22c
[a
.name
]=a
.value
;
1805 _228
.ignoreAttrFilter
=function(a
){
1806 return (_228
.ignoreAttr
[a
.name
]!=a
.value
);
1808 _228
.compliant
=false;
1809 _228
.renames
={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"};
1811 _228
=function(node
){
1812 return node
.attributes
;
1814 _228
.compliant
=true;
1817 this.attributeArray
=_228
;
1818 var _231
=function(_232
,arr
){
1819 var _234
=arr
[1].split(".");
1822 str
+="if (!MochiKit."+_234
[1]+") { throw new Error(\"";
1823 str
+="This function has been deprecated and depends on MochiKit.";
1824 str
+=_234
[1]+".\");}";
1825 str
+="return MochiKit."+_234
[1]+"."+arr
[0];
1826 str
+=".apply(this, arguments);";
1827 obj
[_234
[2]]=new Function(str
);
1828 MochiKit
.Base
.update(MochiKit
[_232
],obj
);
1830 for(var i
;i
<MochiKit
.DOM
.DEPRECATED
.length
;i
++){
1831 _231("DOM",MochiKit
.DOM
.DEPRECATED
[i
]);
1833 var _237
=this.createDOMFunc
;
1839 this.TBODY
=_237("tbody");
1840 this.THEAD
=_237("thead");
1841 this.TFOOT
=_237("tfoot");
1842 this.TABLE
=_237("table");
1844 this.INPUT
=_237("input");
1845 this.SPAN
=_237("span");
1847 this.DIV
=_237("div");
1848 this.IMG
=_237("img");
1849 this.BUTTON
=_237("button");
1851 this.PRE
=_237("pre");
1857 this.LABEL
=_237("label");
1858 this.TEXTAREA
=_237("textarea");
1859 this.FORM
=_237("form");
1861 this.SELECT
=_237("select");
1862 this.OPTION
=_237("option");
1863 this.OPTGROUP
=_237("optgroup");
1864 this.LEGEND
=_237("legend");
1865 this.FIELDSET
=_237("fieldset");
1866 this.STRONG
=_237("strong");
1867 this.CANVAS
=_237("canvas");
1868 this.$=this.getElement
;
1869 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
1870 m
.nameFunctions(this);
1872 MochiKit
.DOM
.__new__(((typeof (window
)=="undefined")?this:window
));
1873 if(MochiKit
.__export__
){
1874 withWindow
=MochiKit
.DOM
.withWindow
;
1875 withDocument
=MochiKit
.DOM
.withDocument
;
1877 MochiKit
.Base
._exportSymbols(this,MochiKit
.DOM
);
1878 if(typeof (dojo
)!="undefined"){
1879 dojo
.provide("MochiKit.Style");
1880 dojo
.require("MochiKit.Base");
1881 dojo
.require("MochiKit.DOM");
1883 if(typeof (JSAN
)!="undefined"){
1884 JSAN
.use("MochiKit.Base",[]);
1885 JSAN
.use("MochiKit.DOM",[]);
1888 if(typeof (MochiKit
.Base
)=="undefined"){
1893 throw "MochiKit.Style depends on MochiKit.Base!";
1896 if(typeof (MochiKit
.DOM
)=="undefined"){
1901 throw "MochiKit.Style depends on MochiKit.DOM!";
1903 if(typeof (MochiKit
.Style
)=="undefined"){
1906 MochiKit
.Style
.NAME
="MochiKit.Style";
1907 MochiKit
.Style
.VERSION
="1.4";
1908 MochiKit
.Style
.__repr__
=function(){
1909 return "["+this.NAME
+" "+this.VERSION
+"]";
1911 MochiKit
.Style
.toString
=function(){
1912 return this.__repr__();
1914 MochiKit
.Style
.EXPORT_OK
=[];
1915 MochiKit
.Style
.EXPORT
=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
1916 MochiKit
.Style
.Dimensions
=function(w
,h
){
1920 MochiKit
.Style
.Dimensions
.prototype.__repr__
=function(){
1921 var repr
=MochiKit
.Base
.repr
;
1922 return "{w: "+repr(this.w
)+", h: "+repr(this.h
)+"}";
1924 MochiKit
.Style
.Dimensions
.prototype.toString
=function(){
1925 return this.__repr__();
1927 MochiKit
.Style
.Coordinates
=function(x
,y
){
1931 MochiKit
.Style
.Coordinates
.prototype.__repr__
=function(){
1932 var repr
=MochiKit
.Base
.repr
;
1933 return "{x: "+repr(this.x
)+", y: "+repr(this.y
)+"}";
1935 MochiKit
.Style
.Coordinates
.prototype.toString
=function(){
1936 return this.__repr__();
1938 MochiKit
.Base
.update(MochiKit
.Style
,{getStyle
:function(elem
,_23f
){
1939 var dom
=MochiKit
.DOM
;
1940 var d
=dom
._document
;
1941 elem
=dom
.getElement(elem
);
1942 _23f
=MochiKit
.Base
.camelize(_23f
);
1946 if(_23f
=="opacity"&&elem
.filters
){
1947 var _242
=(MochiKit
.Style
.getStyle(elem
,"filter")||"").match(/alpha\(opacity=(.*)\)/);
1949 return parseFloat(_242
[1])/100;
1953 var _243
=elem
.style
?elem
.style
[_23f
]:null;
1955 if(d
.defaultView
&&d
.defaultView
.getComputedStyle
){
1956 var css
=d
.defaultView
.getComputedStyle(elem
,null);
1957 _23f
=_23f
.replace(/([A-Z])/g,"-$1").toLowerCase();
1958 _243
=css
?css
.getPropertyValue(_23f
):null;
1960 if(elem
.currentStyle
){
1961 _243
=elem
.currentStyle
[_23f
];
1965 if(_23f
=="opacity"){
1966 _243
=parseFloat(_243
);
1968 if(/Opera/.test(navigator
.userAgent
)&&(MochiKit
.Base
.find(["left","top","right","bottom"],_23f
)!=-1)){
1969 if(MochiKit
.Style
.getStyle(elem
,"position")=="static"){
1973 return _243
=="auto"?null:_243
;
1974 },setStyle
:function(elem
,_246
){
1975 elem
=MochiKit
.DOM
.getElement(elem
);
1976 for(var name
in _246
){
1977 if(name
=="opacity"){
1978 MochiKit
.Style
.setOpacity(elem
,_246
[name
]);
1980 elem
.style
[MochiKit
.Base
.camelize(name
)]=_246
[name
];
1983 },setOpacity
:function(elem
,o
){
1984 elem
=MochiKit
.DOM
.getElement(elem
);
1985 var self
=MochiKit
.Style
;
1987 var _24b
=/Gecko/.test(navigator
.userAgent
)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator
.userAgent
));
1988 elem
.style
["opacity"]=_24b
?0.999999:1;
1989 if(/MSIE/.test(navigator
.userAgent
)){
1990 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"");
1996 elem
.style
["opacity"]=o
;
1997 if(/MSIE/.test(navigator
.userAgent
)){
1998 elem
.style
["filter"]=self
.getStyle(elem
,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o
*100+")";
2001 },getElementPosition
:function(elem
,_24d
){
2002 var self
=MochiKit
.Style
;
2003 var dom
=MochiKit
.DOM
;
2004 elem
=dom
.getElement(elem
);
2005 if(!elem
||(!(elem
.x
&&elem
.y
)&&(!elem
.parentNode
===null||self
.getStyle(elem
,"display")=="none"))){
2008 var c
=new self
.Coordinates(0,0);
2011 var d
=MochiKit
.DOM
._document
;
2012 var de
=d
.documentElement
;
2014 if(!elem
.parentNode
&&elem
.x
&&elem
.y
){
2018 if(elem
.getBoundingClientRect
){
2019 box
=elem
.getBoundingClientRect();
2020 c
.x
+=box
.left
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
2021 c
.y
+=box
.top
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
2023 if(elem
.offsetParent
){
2024 c
.x
+=elem
.offsetLeft
;
2025 c
.y
+=elem
.offsetTop
;
2026 _252
=elem
.offsetParent
;
2029 c
.x
+=_252
.offsetLeft
;
2030 c
.y
+=_252
.offsetTop
;
2031 _252
=_252
.offsetParent
;
2034 var ua
=navigator
.userAgent
.toLowerCase();
2035 if((typeof (opera
)!="undefined"&&parseFloat(opera
.version())<9)||(ua
.indexOf("AppleWebKit")!=-1&&self
.getStyle(elem
,"position")=="absolute")){
2042 if(typeof (_24d
)!="undefined"){
2043 _24d
=arguments
.callee(_24d
);
2049 if(elem
.parentNode
){
2050 _252
=elem
.parentNode
;
2055 var _257
=_252
.tagName
.toUpperCase();
2056 if(_257
==="BODY"||_257
==="HTML"){
2059 var disp
=self
.getStyle(_252
,"display");
2060 if(disp
!="inline"&&disp
!="table-row"){
2061 c
.x
-=_252
.scrollLeft
;
2062 c
.y
-=_252
.scrollTop
;
2064 if(_252
.parentNode
){
2065 _252
=_252
.parentNode
;
2071 },setElementPosition
:function(elem
,_25a
,_25b
){
2072 elem
=MochiKit
.DOM
.getElement(elem
);
2073 if(typeof (_25b
)=="undefined"){
2077 var _25d
=MochiKit
.Base
.isUndefinedOrNull
;
2079 _25c
["left"]=_25a
.x
+_25b
;
2082 _25c
["top"]=_25a
.y
+_25b
;
2084 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_25c
});
2085 },getElementDimensions
:function(elem
){
2086 var self
=MochiKit
.Style
;
2087 var dom
=MochiKit
.DOM
;
2088 if(typeof (elem
.w
)=="number"||typeof (elem
.h
)=="number"){
2089 return new self
.Dimensions(elem
.w
||0,elem
.h
||0);
2091 elem
=dom
.getElement(elem
);
2095 var disp
=self
.getStyle(elem
,"display");
2096 if(disp
!="none"&&disp
!==""&&typeof (disp
)!="undefined"){
2097 return new self
.Dimensions(elem
.offsetWidth
||0,elem
.offsetHeight
||0);
2100 var _263
=s
.visibility
;
2101 var _264
=s
.position
;
2102 s
.visibility
="hidden";
2103 s
.position
="absolute";
2105 var _265
=elem
.offsetWidth
;
2106 var _266
=elem
.offsetHeight
;
2110 return new self
.Dimensions(_265
,_266
);
2111 },setElementDimensions
:function(elem
,_268
,_269
){
2112 elem
=MochiKit
.DOM
.getElement(elem
);
2113 if(typeof (_269
)=="undefined"){
2117 var _26b
=MochiKit
.Base
.isUndefinedOrNull
;
2119 _26a
["width"]=_268
.w
+_269
;
2122 _26a
["height"]=_268
.h
+_269
;
2124 MochiKit
.DOM
.updateNodeAttributes(elem
,{"style":_26a
});
2125 },setDisplayForElement
:function(_26c
,_26d
){
2126 var _26e
=MochiKit
.Base
.extend(null,arguments
,1);
2127 var _26f
=MochiKit
.DOM
.getElement
;
2128 for(var i
=0;i
<_26e
.length
;i
++){
2131 _26d
.style
.display
=_26c
;
2134 },getViewportDimensions
:function(){
2135 var d
=new MochiKit
.Style
.Dimensions();
2136 var w
=MochiKit
.DOM
._window
;
2137 var b
=MochiKit
.DOM
._document
.body
;
2142 if(b
.parentElement
.clientWidth
){
2143 d
.w
=b
.parentElement
.clientWidth
;
2144 d
.h
=b
.parentElement
.clientHeight
;
2146 if(b
&&b
.clientWidth
){
2153 },getViewportPosition
:function(){
2154 var c
=new MochiKit
.Style
.Coordinates(0,0);
2155 var d
=MochiKit
.DOM
._document
;
2156 var de
=d
.documentElement
;
2158 if(de
&&(de
.scrollTop
||de
.scrollLeft
)){
2168 },__new__
:function(){
2169 var m
=MochiKit
.Base
;
2170 this.elementPosition
=this.getElementPosition
;
2171 this.elementDimensions
=this.getElementDimensions
;
2172 this.hideElement
=m
.partial(this.setDisplayForElement
,"none");
2173 this.showElement
=m
.partial(this.setDisplayForElement
,"block");
2174 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
2175 m
.nameFunctions(this);
2177 MochiKit
.Style
.__new__();
2178 MochiKit
.Base
._exportSymbols(this,MochiKit
.Style
);
2179 if(typeof (dojo
)!="undefined"){
2180 dojo
.provide("MochiKit.Color");
2181 dojo
.require("MochiKit.Base");
2182 dojo
.require("MochiKit.DOM");
2183 dojo
.require("MochiKit.Style");
2185 if(typeof (JSAN
)!="undefined"){
2186 JSAN
.use("MochiKit.Base",[]);
2187 JSAN
.use("MochiKit.DOM",[]);
2188 JSAN
.use("MochiKit.Style",[]);
2191 if(typeof (MochiKit
.Base
)=="undefined"){
2196 throw "MochiKit.Color depends on MochiKit.Base";
2199 if(typeof (MochiKit
.DOM
)=="undefined"){
2204 throw "MochiKit.Color depends on MochiKit.DOM";
2207 if(typeof (MochiKit
.Style
)=="undefined"){
2212 throw "MochiKit.Color depends on MochiKit.Style";
2214 if(typeof (MochiKit
.Color
)=="undefined"){
2217 MochiKit
.Color
.NAME
="MochiKit.Color";
2218 MochiKit
.Color
.VERSION
="1.4";
2219 MochiKit
.Color
.__repr__
=function(){
2220 return "["+this.NAME
+" "+this.VERSION
+"]";
2222 MochiKit
.Color
.toString
=function(){
2223 return this.__repr__();
2225 MochiKit
.Color
.Color
=function(red
,_27a
,blue
,_27c
){
2226 if(typeof (_27c
)=="undefined"||_27c
===null){
2229 this.rgb
={r
:red
,g
:_27a
,b
:blue
,a
:_27c
};
2231 MochiKit
.Color
.Color
.prototype={__class__
:MochiKit
.Color
.Color
,colorWithAlpha
:function(_27d
){
2233 var m
=MochiKit
.Color
;
2234 return m
.Color
.fromRGB(rgb
.r
,rgb
.g
,rgb
.b
,_27d
);
2235 },colorWithHue
:function(hue
){
2236 var hsl
=this.asHSL();
2238 var m
=MochiKit
.Color
;
2239 return m
.Color
.fromHSL(hsl
);
2240 },colorWithSaturation
:function(_283
){
2241 var hsl
=this.asHSL();
2243 var m
=MochiKit
.Color
;
2244 return m
.Color
.fromHSL(hsl
);
2245 },colorWithLightness
:function(_286
){
2246 var hsl
=this.asHSL();
2248 var m
=MochiKit
.Color
;
2249 return m
.Color
.fromHSL(hsl
);
2250 },darkerColorWithLevel
:function(_289
){
2251 var hsl
=this.asHSL();
2252 hsl
.l
=Math
.max(hsl
.l
-_289
,0);
2253 var m
=MochiKit
.Color
;
2254 return m
.Color
.fromHSL(hsl
);
2255 },lighterColorWithLevel
:function(_28c
){
2256 var hsl
=this.asHSL();
2257 hsl
.l
=Math
.min(hsl
.l
+_28c
,1);
2258 var m
=MochiKit
.Color
;
2259 return m
.Color
.fromHSL(hsl
);
2260 },blendedColor
:function(_28f
,_290
){
2261 if(typeof (_290
)=="undefined"||_290
===null){
2268 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
));
2269 },compareRGB
:function(_295
){
2272 return MochiKit
.Base
.compare([a
.r
,a
.g
,a
.b
,a
.a
],[b
.r
,b
.g
,b
.b
,b
.a
]);
2273 },isLight
:function(){
2274 return this.asHSL().b
>0.5;
2275 },isDark
:function(){
2276 return (!this.isLight());
2277 },toHSLString
:function(){
2279 var ccc
=MochiKit
.Color
.clampColorComponent
;
2280 var rval
=this._hslString
;
2282 var mid
=(ccc(c
.h
,360).toFixed(0)+","+ccc(c
.s
,100).toPrecision(4)+"%"+","+ccc(c
.l
,100).toPrecision(4)+"%");
2286 rval
="hsl("+mid
+")";
2291 rval
="hsla("+mid
+","+a
+")";
2293 this._hslString
=rval
;
2296 },toRGBString
:function(){
2298 var ccc
=MochiKit
.Color
.clampColorComponent
;
2299 var rval
=this._rgbString
;
2301 var mid
=(ccc(c
.r
,255).toFixed(0)+","+ccc(c
.g
,255).toFixed(0)+","+ccc(c
.b
,255).toFixed(0));
2303 rval
="rgba("+mid
+","+c
.a
+")";
2305 rval
="rgb("+mid
+")";
2307 this._rgbString
=rval
;
2311 return MochiKit
.Base
.clone(this.rgb
);
2312 },toHexString
:function(){
2313 var m
=MochiKit
.Color
;
2315 var ccc
=MochiKit
.Color
.clampColorComponent
;
2316 var rval
=this._hexString
;
2318 rval
=("#"+m
.toColorPart(ccc(c
.r
,255))+m
.toColorPart(ccc(c
.g
,255))+m
.toColorPart(ccc(c
.b
,255)));
2319 this._hexString
=rval
;
2325 if(typeof (hsv
)=="undefined"||hsv
===null){
2326 hsv
=MochiKit
.Color
.rgbToHSV(this.rgb
);
2329 return MochiKit
.Base
.clone(hsv
);
2333 if(typeof (hsl
)=="undefined"||hsl
===null){
2334 hsl
=MochiKit
.Color
.rgbToHSL(this.rgb
);
2337 return MochiKit
.Base
.clone(hsl
);
2338 },toString
:function(){
2339 return this.toRGBString();
2342 var col
=[c
.r
,c
.g
,c
.b
,c
.a
];
2343 return this.__class__
.NAME
+"("+col
.join(", ")+")";
2345 MochiKit
.Base
.update(MochiKit
.Color
.Color
,{fromRGB
:function(red
,_2ac
,blue
,_2ae
){
2346 var _2af
=MochiKit
.Color
.Color
;
2347 if(arguments
.length
==1){
2352 if(typeof (rgb
.a
)=="undefined"){
2358 return new _2af(red
,_2ac
,blue
,_2ae
);
2359 },fromHSL
:function(hue
,_2b2
,_2b3
,_2b4
){
2360 var m
=MochiKit
.Color
;
2361 return m
.Color
.fromRGB(m
.hslToRGB
.apply(m
,arguments
));
2362 },fromHSV
:function(hue
,_2b7
,_2b8
,_2b9
){
2363 var m
=MochiKit
.Color
;
2364 return m
.Color
.fromRGB(m
.hsvToRGB
.apply(m
,arguments
));
2365 },fromName
:function(name
){
2366 var _2bc
=MochiKit
.Color
.Color
;
2367 if(name
.charAt(0)=="\""){
2368 name
=name
.substr(1,name
.length
-2);
2370 var _2bd
=_2bc
._namedColors
[name
.toLowerCase()];
2371 if(typeof (_2bd
)=="string"){
2372 return _2bc
.fromHexString(_2bd
);
2374 if(name
=="transparent"){
2375 return _2bc
.transparentColor();
2379 },fromString
:function(_2be
){
2380 var self
=MochiKit
.Color
.Color
;
2381 var _2c0
=_2be
.substr(0,3);
2383 return self
.fromRGBString(_2be
);
2386 return self
.fromHSLString(_2be
);
2388 if(_2be
.charAt(0)=="#"){
2389 return self
.fromHexString(_2be
);
2393 return self
.fromName(_2be
);
2394 },fromHexString
:function(_2c1
){
2395 if(_2c1
.charAt(0)=="#"){
2396 _2c1
=_2c1
.substring(1);
2402 hex
=_2c1
.substr(i
,1);
2403 _2c2
.push(parseInt(hex
+hex
,16)/255);
2407 hex
=_2c1
.substr(i
,2);
2408 _2c2
.push(parseInt(hex
,16)/255);
2411 var _2c5
=MochiKit
.Color
.Color
;
2412 return _2c5
.fromRGB
.apply(_2c5
,_2c2
);
2413 },_fromColorString
:function(pre
,_2c7
,_2c8
,_2c9
){
2414 if(_2c9
.indexOf(pre
)===0){
2415 _2c9
=_2c9
.substring(_2c9
.indexOf("(",3)+1,_2c9
.length
-1);
2417 var _2ca
=_2c9
.split(/\s*,\s*/);
2419 for(var i
=0;i
<_2ca
.length
;i
++){
2422 var _2cf
=c
.substring(c
.length
-3);
2423 if(c
.charAt(c
.length
-1)=="%"){
2424 val
=0.01*parseFloat(c
.substring(0,c
.length
-1));
2427 val
=parseFloat(c
)/360;
2430 val
=parseFloat(c
)/(Math
.PI
*2);
2432 val
=_2c8
[i
]*parseFloat(c
);
2438 return this[_2c7
].apply(this,_2cb
);
2439 },fromComputedStyle
:function(elem
,_2d1
){
2441 var cls
=MochiKit
.Color
.Color
;
2442 for(elem
=d
.getElement(elem
);elem
;elem
=elem
.parentNode
){
2443 var _2d4
=MochiKit
.Style
.getStyle
.apply(d
,arguments
);
2447 var _2d5
=cls
.fromString(_2d4
);
2451 if(_2d5
.asRGB().a
>0){
2456 },fromBackground
:function(elem
){
2457 var cls
=MochiKit
.Color
.Color
;
2458 return cls
.fromComputedStyle(elem
,"backgroundColor","background-color")||cls
.whiteColor();
2459 },fromText
:function(elem
){
2460 var cls
=MochiKit
.Color
.Color
;
2461 return cls
.fromComputedStyle(elem
,"color","color")||cls
.blackColor();
2462 },namedColors
:function(){
2463 return MochiKit
.Base
.clone(MochiKit
.Color
.Color
._namedColors
);
2465 MochiKit
.Base
.update(MochiKit
.Color
,{clampColorComponent
:function(v
,_2db
){
2476 },_hslValue
:function(n1
,n2
,hue
){
2492 val
=n1
+(n2
-n1
)*(4-hue
);
2499 },hsvToRGB
:function(hue
,_2e1
,_2e2
,_2e3
){
2500 if(arguments
.length
==1){
2515 var i
=Math
.floor(hue
*6);
2517 var p
=_2e2
*(1-_2e1
);
2518 var q
=_2e2
*(1-(_2e1
*f
));
2519 var t
=_2e2
*(1-(_2e1
*(1-f
)));
2554 return {r
:red
,g
:_2e6
,b
:blue
,a
:_2e3
};
2555 },hslToRGB
:function(hue
,_2ee
,_2ef
,_2f0
){
2556 if(arguments
.length
==1){
2575 m2
=_2ef
+_2ee
-(_2ef
*_2ee
);
2578 var f
=MochiKit
.Color
._hslValue
;
2584 return {r
:red
,g
:_2f3
,b
:blue
,a
:_2f0
};
2585 },rgbToHSV
:function(red
,_2fa
,blue
,_2fc
){
2586 if(arguments
.length
==1){
2593 var max
=Math
.max(Math
.max(red
,_2fa
),blue
);
2594 var min
=Math
.min(Math
.min(red
,_2fa
),blue
);
2605 hue
=(_2fa
-blue
)/_303
;
2608 hue
=2+((blue
-red
)/_303
);
2610 hue
=4+((red
-_2fa
)/_303
);
2621 return {h
:hue
,s
:_301
,v
:_302
,a
:_2fc
};
2622 },rgbToHSL
:function(red
,_305
,blue
,_307
){
2623 if(arguments
.length
==1){
2630 var max
=Math
.max(red
,Math
.max(_305
,blue
));
2631 var min
=Math
.min(red
,Math
.min(_305
,blue
));
2634 var _30d
=(max
+min
)/2;
2641 _30c
=_30e
/(max
+min
);
2643 _30c
=_30e
/(2-max
-min
);
2646 hue
=(_305
-blue
)/_30e
;
2649 hue
=2+((blue
-red
)/_30e
);
2651 hue
=4+((red
-_305
)/_30e
);
2662 return {h
:hue
,s
:_30c
,l
:_30d
,a
:_307
};
2663 },toColorPart
:function(num
){
2664 num
=Math
.round(num
);
2665 var _310
=num
.toString(16);
2670 },__new__
:function(){
2671 var m
=MochiKit
.Base
;
2672 this.Color
.fromRGBString
=m
.bind(this.Color
._fromColorString
,this.Color
,"rgb","fromRGB",[1/255,1/255,1/255,1]);
2673 this.Color
.fromHSLString
=m
.bind(this.Color
._fromColorString
,this.Color
,"hsl","fromHSL",[1/360,0.01,0.01,1]);
2675 var _313
={black
:[0,0,0],blue
:[0,0,1],brown
:[0.6,0.4,0.2],cyan
:[0,1,1],darkGray
:[_312
,_312
,_312
],gray
:[0.5,0.5,0.5],green
:[0,1,0],lightGray
:[2*_312
,2*_312
,2*_312
],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]};
2676 var _314
=function(name
,r
,g
,b
,a
){
2677 var rval
=this.fromRGB(r
,g
,b
,a
);
2678 this[name
]=function(){
2685 var _31d
=m
.concat([_314
,this.Color
,name
],_313
[k
]);
2686 this.Color
[name
]=m
.bind
.apply(null,_31d
);
2688 var _31e
=function(){
2689 for(var i
=0;i
<arguments
.length
;i
++){
2690 if(!(arguments
[i
] instanceof Color
)){
2696 var _320
=function(a
,b
){
2697 return a
.compareRGB(b
);
2699 m
.nameFunctions(this);
2700 m
.registerComparator(this.Color
.NAME
,_31e
,_320
);
2701 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
2703 MochiKit
.Color
.EXPORT
=["Color"];
2704 MochiKit
.Color
.EXPORT_OK
=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
2705 MochiKit
.Color
.__new__();
2706 MochiKit
.Base
._exportSymbols(this,MochiKit
.Color
);
2707 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"};
2708 if(typeof (dojo
)!="undefined"){
2709 dojo
.provide("MochiKit.Signal");
2710 dojo
.require("MochiKit.Base");
2711 dojo
.require("MochiKit.DOM");
2712 dojo
.require("MochiKit.Style");
2714 if(typeof (JSAN
)!="undefined"){
2715 JSAN
.use("MochiKit.Base",[]);
2716 JSAN
.use("MochiKit.DOM",[]);
2717 JSAN
.use("MochiKit.Style",[]);
2720 if(typeof (MochiKit
.Base
)=="undefined"){
2725 throw "MochiKit.Signal depends on MochiKit.Base!";
2728 if(typeof (MochiKit
.DOM
)=="undefined"){
2733 throw "MochiKit.Signal depends on MochiKit.DOM!";
2736 if(typeof (MochiKit
.Style
)=="undefined"){
2741 throw "MochiKit.Signal depends on MochiKit.Style!";
2743 if(typeof (MochiKit
.Signal
)=="undefined"){
2746 MochiKit
.Signal
.NAME
="MochiKit.Signal";
2747 MochiKit
.Signal
.VERSION
="1.4";
2748 MochiKit
.Signal
._observers
=[];
2749 MochiKit
.Signal
.Event
=function(src
,e
){
2750 this._event
=e
||window
.event
;
2753 MochiKit
.Base
.update(MochiKit
.Signal
.Event
.prototype,{__repr__
:function(){
2754 var repr
=MochiKit
.Base
.repr
;
2755 var str
="{event(): "+repr(this.event())+", src(): "+repr(this.src())+", type(): "+repr(this.type())+", target(): "+repr(this.target());
2756 if(this.type()&&this.type().indexOf("key")===0||this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu"){
2757 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
)+"}";
2759 if(this.type()&&this.type().indexOf("key")===0){
2760 str
+=", key(): {code: "+repr(this.key().code
)+", string: "+repr(this.key().string
)+"}";
2762 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
2763 str
+=", mouse(): {page: "+repr(this.mouse().page
)+", client: "+repr(this.mouse().client
);
2764 if(this.type()!="mousemove"){
2765 str
+=", button: {left: "+repr(this.mouse().button
.left
)+", middle: "+repr(this.mouse().button
.middle
)+", right: "+repr(this.mouse().button
.right
)+"}}";
2770 if(this.type()=="mouseover"||this.type()=="mouseout"){
2771 str
+=", relatedTarget(): "+repr(this.relatedTarget());
2775 },toString
:function(){
2776 return this.__repr__();
2782 return this._event
.type
||undefined
;
2783 },target
:function(){
2784 return this._event
.target
||this._event
.srcElement
;
2785 },_relatedTarget
:null,relatedTarget
:function(){
2786 if(this._relatedTarget
!==null){
2787 return this._relatedTarget
;
2790 if(this.type()=="mouseover"){
2791 elem
=(this._event
.relatedTarget
||this._event
.fromElement
);
2793 if(this.type()=="mouseout"){
2794 elem
=(this._event
.relatedTarget
||this._event
.toElement
);
2798 this._relatedTarget
=elem
;
2802 },_modifier
:null,modifier
:function(){
2803 if(this._modifier
!==null){
2804 return this._modifier
;
2807 m
.alt
=this._event
.altKey
;
2808 m
.ctrl
=this._event
.ctrlKey
;
2809 m
.meta
=this._event
.metaKey
||false;
2810 m
.shift
=this._event
.shiftKey
;
2811 m
.any
=m
.alt
||m
.ctrl
||m
.shift
||m
.meta
;
2814 },_key
:null,key
:function(){
2815 if(this._key
!==null){
2819 if(this.type()&&this.type().indexOf("key")===0){
2820 if(this.type()=="keydown"||this.type()=="keyup"){
2821 k
.code
=this._event
.keyCode
;
2822 k
.string
=(MochiKit
.Signal
._specialKeys
[k
.code
]||"KEY_UNKNOWN");
2826 if(this.type()=="keypress"){
2829 if(typeof (this._event
.charCode
)!="undefined"&&this._event
.charCode
!==0&&!MochiKit
.Signal
._specialMacKeys
[this._event
.charCode
]){
2830 k
.code
=this._event
.charCode
;
2831 k
.string
=String
.fromCharCode(k
.code
);
2833 if(this._event
.keyCode
&&typeof (this._event
.charCode
)=="undefined"){
2834 k
.code
=this._event
.keyCode
;
2835 k
.string
=String
.fromCharCode(k
.code
);
2844 },_mouse
:null,mouse
:function(){
2845 if(this._mouse
!==null){
2850 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
2851 m
.client
=new MochiKit
.Style
.Coordinates(0,0);
2852 if(e
.clientX
||e
.clientY
){
2853 m
.client
.x
=(!e
.clientX
||e
.clientX
<0)?0:e
.clientX
;
2854 m
.client
.y
=(!e
.clientY
||e
.clientY
<0)?0:e
.clientY
;
2856 m
.page
=new MochiKit
.Style
.Coordinates(0,0);
2857 if(e
.pageX
||e
.pageY
){
2858 m
.page
.x
=(!e
.pageX
||e
.pageX
<0)?0:e
.pageX
;
2859 m
.page
.y
=(!e
.pageY
||e
.pageY
<0)?0:e
.pageY
;
2861 var de
=MochiKit
.DOM
._document
.documentElement
;
2862 var b
=MochiKit
.DOM
._document
.body
;
2863 m
.page
.x
=e
.clientX
+(de
.scrollLeft
||b
.scrollLeft
)-(de
.clientLeft
||0);
2864 m
.page
.y
=e
.clientY
+(de
.scrollTop
||b
.scrollTop
)-(de
.clientTop
||0);
2866 if(this.type()!="mousemove"){
2868 m
.button
.left
=false;
2869 m
.button
.right
=false;
2870 m
.button
.middle
=false;
2872 m
.button
.left
=(e
.which
==1);
2873 m
.button
.middle
=(e
.which
==2);
2874 m
.button
.right
=(e
.which
==3);
2876 m
.button
.left
=!!(e
.button
&1);
2877 m
.button
.right
=!!(e
.button
&2);
2878 m
.button
.middle
=!!(e
.button
&4);
2886 this.stopPropagation();
2887 this.preventDefault();
2888 },stopPropagation
:function(){
2889 if(this._event
.stopPropagation
){
2890 this._event
.stopPropagation();
2892 this._event
.cancelBubble
=true;
2894 },preventDefault
:function(){
2895 if(this._event
.preventDefault
){
2896 this._event
.preventDefault();
2898 if(this._confirmUnload
===null){
2899 this._event
.returnValue
=false;
2902 },_confirmUnload
:null,confirmUnload
:function(msg
){
2903 if(this.type()=="beforeunload"){
2904 this._confirmUnload
=msg
;
2905 this._event
.returnValue
=msg
;
2908 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"};
2910 var _32f
=MochiKit
.Signal
._specialMacKeys
;
2911 for(i
=63236;i
<=63242;i
++){
2912 _32f
[i
]="KEY_F"+(i
-63236+1);
2915 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"};
2917 var _330
=MochiKit
.Signal
._specialKeys
;
2918 for(var i
=48;i
<=57;i
++){
2919 _330
[i
]="KEY_"+(i
-48);
2921 for(i
=65;i
<=90;i
++){
2922 _330
[i
]="KEY_"+String
.fromCharCode(i
);
2924 for(i
=96;i
<=105;i
++){
2925 _330
[i
]="KEY_NUM_PAD_"+(i
-96);
2927 for(i
=112;i
<=123;i
++){
2928 _330
[i
]="KEY_F"+(i
-112+1);
2931 MochiKit
.Signal
.Ident
=function(_332
){
2932 this.source
=_332
.source
;
2933 this.signal
=_332
.signal
;
2934 this.listener
=_332
.listener
;
2935 this.isDOM
=_332
.isDOM
;
2936 this.objOrFunc
=_332
.objOrFunc
;
2937 this.funcOrStr
=_332
.funcOrStr
;
2938 this.connected
=_332
.connected
;
2940 MochiKit
.Signal
.Ident
.prototype={};
2941 MochiKit
.Base
.update(MochiKit
.Signal
,{__repr__
:function(){
2942 return "["+this.NAME
+" "+this.VERSION
+"]";
2943 },toString
:function(){
2944 return this.__repr__();
2945 },_unloadCache
:function(){
2946 var self
=MochiKit
.Signal
;
2947 var _334
=self
._observers
;
2948 for(var i
=0;i
<_334
.length
;i
++){
2949 if(_334
[i
].signal
!=="onload"&&_334
[i
].signal
!=="onunload"){
2950 self
._disconnect(_334
[i
]);
2953 },_listener
:function(src
,sig
,func
,obj
,_33a
){
2954 var self
=MochiKit
.Signal
;
2957 return MochiKit
.Base
.bind(func
,obj
);
2960 if(typeof (func
)=="string"){
2961 if(sig
==="onload"||sig
==="onunload"){
2962 return function(_33d
){
2963 obj
[func
].apply(obj
,[new E(src
,_33d
)]);
2964 var _33e
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,objOrFunc
:obj
,funcOrStr
:func
});
2965 MochiKit
.Signal
._disconnect(_33e
);
2968 return function(_33f
){
2969 obj
[func
].apply(obj
,[new E(src
,_33f
)]);
2973 if(sig
==="onload"||sig
==="onunload"){
2974 return function(_340
){
2975 func
.apply(obj
,[new E(src
,_340
)]);
2976 MochiKit
.Signal
.disconnect(src
,sig
,func
);
2977 var _341
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,objOrFunc
:func
});
2978 MochiKit
.Signal
._disconnect(_341
);
2981 return function(_342
){
2982 func
.apply(obj
,[new E(src
,_342
)]);
2986 },_browserAlreadyHasMouseEnterAndLeave
:function(){
2987 return /MSIE/.test(navigator
.userAgent
);
2988 },_mouseEnterListener
:function(src
,sig
,func
,obj
){
2989 var E
=MochiKit
.Signal
.Event
;
2990 return function(_348
){
2991 var e
=new E(src
,_348
);
2993 e
.relatedTarget().nodeName
;
2999 if(MochiKit
.DOM
.isChildNode(e
.relatedTarget(),src
)){
3005 if(typeof (func
)=="string"){
3006 return obj
[func
].apply(obj
,[e
]);
3008 return func
.apply(obj
,[e
]);
3011 },_getDestPair
:function(_34a
,_34b
){
3014 if(typeof (_34b
)!="undefined"){
3017 if(typeof (_34b
)=="string"){
3018 if(typeof (_34a
[_34b
])!="function"){
3019 throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
3022 if(typeof (_34b
)!="function"){
3023 throw new Error("'funcOrStr' must be a function or string");
3027 if(typeof (_34a
)!="function"){
3028 throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
3034 },connect
:function(src
,sig
,_350
,_351
){
3035 src
=MochiKit
.DOM
.getElement(src
);
3036 var self
=MochiKit
.Signal
;
3037 if(typeof (sig
)!="string"){
3038 throw new Error("'sig' must be a string");
3040 var _353
=self
._getDestPair(_350
,_351
);
3043 if(typeof (obj
)=="undefined"||obj
===null){
3046 var _356
=!!(src
.addEventListener
||src
.attachEvent
);
3047 if(_356
&&(sig
==="onmouseenter"||sig
==="onmouseleave")&&!self
._browserAlreadyHasMouseEnterAndLeave()){
3048 var _357
=self
._mouseEnterListener(src
,sig
.substr(2),func
,obj
);
3049 if(sig
==="onmouseenter"){
3055 var _357
=self
._listener(src
,sig
,func
,obj
,_356
);
3057 if(src
.addEventListener
){
3058 src
.addEventListener(sig
.substr(2),_357
,false);
3060 if(src
.attachEvent
){
3061 src
.attachEvent(sig
,_357
);
3064 var _358
=new MochiKit
.Signal
.Ident({source
:src
,signal
:sig
,listener
:_357
,isDOM
:_356
,objOrFunc
:_350
,funcOrStr
:_351
,connected
:true});
3065 self
._observers
.push(_358
);
3066 if(!_356
&&typeof (src
.__connect__
)=="function"){
3067 var args
=MochiKit
.Base
.extend([_358
],arguments
,1);
3068 src
.__connect__
.apply(src
,args
);
3071 },_disconnect
:function(_35a
){
3072 if(!_35a
.connected
){
3075 _35a
.connected
=false;
3079 var src
=_35a
.source
;
3080 var sig
=_35a
.signal
;
3081 var _35d
=_35a
.listener
;
3082 if(src
.removeEventListener
){
3083 src
.removeEventListener(sig
.substr(2),_35d
,false);
3085 if(src
.detachEvent
){
3086 src
.detachEvent(sig
,_35d
);
3088 throw new Error("'src' must be a DOM element");
3091 },disconnect
:function(_35e
){
3092 var self
=MochiKit
.Signal
;
3093 var _360
=self
._observers
;
3094 var m
=MochiKit
.Base
;
3095 if(arguments
.length
>1){
3096 var src
=MochiKit
.DOM
.getElement(arguments
[0]);
3097 var sig
=arguments
[1];
3098 var obj
=arguments
[2];
3099 var func
=arguments
[3];
3100 for(var i
=_360
.length
-1;i
>=0;i
--){
3102 if(o
.source
===src
&&o
.signal
===sig
&&o
.objOrFunc
===obj
&&o
.funcOrStr
===func
){
3103 self
._disconnect(o
);
3113 var idx
=m
.findIdentical(_360
,_35e
);
3115 self
._disconnect(_35e
);
3125 },disconnectAllTo
:function(_369
,_36a
){
3126 var self
=MochiKit
.Signal
;
3127 var _36c
=self
._observers
;
3128 var _36d
=self
._disconnect
;
3129 var _36e
=self
._lock
;
3130 var _36f
=self
._dirty
;
3131 if(typeof (_36a
)==="undefined"){
3134 for(var i
=_36c
.length
-1;i
>=0;i
--){
3136 if(_371
.objOrFunc
===_369
&&(_36a
===null||_371
.funcOrStr
===_36a
)){
3146 },disconnectAll
:function(src
,sig
){
3147 src
=MochiKit
.DOM
.getElement(src
);
3148 var m
=MochiKit
.Base
;
3149 var _375
=m
.flattenArguments(m
.extend(null,arguments
,1));
3150 var self
=MochiKit
.Signal
;
3151 var _377
=self
._disconnect
;
3152 var _378
=self
._observers
;
3154 var _37b
=self
._lock
;
3155 var _37c
=self
._dirty
;
3156 if(_375
.length
===0){
3157 for(i
=_378
.length
-1;i
>=0;i
--){
3159 if(_37a
.source
===src
){
3170 for(i
=0;i
<_375
.length
;i
++){
3173 for(i
=_378
.length
-1;i
>=0;i
--){
3175 if(_37a
.source
===src
&&_37a
.signal
in sigs
){
3186 },signal
:function(src
,sig
){
3187 var self
=MochiKit
.Signal
;
3188 var _381
=self
._observers
;
3189 src
=MochiKit
.DOM
.getElement(src
);
3190 var args
=MochiKit
.Base
.extend(null,arguments
,2);
3193 for(var i
=0;i
<_381
.length
;i
++){
3195 if(_385
.source
===src
&&_385
.signal
===sig
){
3197 _385
.listener
.apply(src
,args
);
3207 for(var i
=_381
.length
-1;i
>=0;i
--){
3208 if(!_381
[i
].connected
){
3217 var e
=new Error("Multiple errors thrown in handling 'sig', see errors property");
3223 MochiKit
.Signal
.EXPORT_OK
=[];
3224 MochiKit
.Signal
.EXPORT
=["connect","disconnect","signal","disconnectAll","disconnectAllTo"];
3225 MochiKit
.Signal
.__new__
=function(win
){
3226 var m
=MochiKit
.Base
;
3227 this._document
=document
;
3232 this.connect(window
,"onunload",this._unloadCache
);
3236 this.EXPORT_TAGS
={":common":this.EXPORT
,":all":m
.concat(this.EXPORT
,this.EXPORT_OK
)};
3237 m
.nameFunctions(this);
3239 MochiKit
.Signal
.__new__(this);
3240 if(MochiKit
.__export__
){
3241 connect
=MochiKit
.Signal
.connect
;
3242 disconnect
=MochiKit
.Signal
.disconnect
;
3243 disconnectAll
=MochiKit
.Signal
.disconnectAll
;
3244 signal
=MochiKit
.Signal
.signal
;
3246 MochiKit
.Base
._exportSymbols(this,MochiKit
.Signal
);
3249 Date
.ext
={};Date
.ext
.util
={};Date
.ext
.util
.xPad
=function(x
,pad
,r
){if(typeof (r
)=="undefined"){r
=10}for(;parseInt(x
,10)<r
&&r
>1;r
/=10){x=pad.toString()+x}return x.toString()};Date.prototype.locale="en-GB";if(document.getElementsByTagName("html")&&document.getElementsByTagName("html")[0].lang){Date.prototype.locale=document.getElementsByTagName("html")[0].lang}Date.ext.locales={};Date.ext.locales.en={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],x:"%d/%m
/%y",X:"%T"};Date.ext.locales["en-US"]=Date.ext.locales.en;Date.ext.locales["en-US"].c="%a %d %b %Y %r %Z";Date.ext.locales["en-US"].x="%D";Date.ext.locales["en-US"].X="%r";Date.ext.locales["en-GB"]=Date.ext.locales.en;Date.ext.locales["en-AU"]=Date.ext.locales["en-GB"];Date.ext.formats={a:function(d){return Date.ext.locales[d.locale].a[d.getDay()]},A:function(d){return Date.ext.locales[d.locale].A[d.getDay()]},b:function(d){return Date.ext.locales[d.locale].b[d.getMonth()]},B:function(d){return Date.ext.locales[d.locale].B[d.getMonth()]},c:"toLocaleString",C:function(d){return Date.ext.util.xPad(parseInt(d.getFullYear()/100,10),0)},d
:["getDate","0"],e
:["getDate"," "],g
:function(d
){return Date
.ext
.util
.xPad(parseInt(Date
.ext
.util
.G(d
)/100,10),0)},G:function(d){var y=d.getFullYear();var V=parseInt(Date.ext.formats.V(d),10);var W=parseInt(Date.ext.formats.W(d),10);if(W>V){y++}else{if(W===0&&V>=52){y--}}return y},H:["getHours","0"],I:function(d){var I=d.getHours()%12;return Date.ext.util.xPad(I===0?12:I,0)},j:function(d){var ms=d-new Date(""+d.getFullYear()+"/1/1 GMT");ms+=d.getTimezoneOffset()*60000;var doy=parseInt(ms/60000/60/24,10)+1;return Date
.ext
.util
.xPad(doy
,0,100)},m
:function(d
){return Date
.ext
.util
.xPad(d
.getMonth()+1,0)},M
:["getMinutes","0"],p
:function(d
){return Date
.ext
.locales
[d
.locale
].p
[d
.getHours()>=12?1:0]},P
:function(d
){return Date
.ext
.locales
[d
.locale
].P
[d
.getHours()>=12?1:0]},S
:["getSeconds","0"],u
:function(d
){var dow
=d
.getDay();return dow
===0?7:dow
},U
:function(d
){var doy
=parseInt(Date
.ext
.formats
.j(d
),10);var rdow
=6-d
.getDay();var woy
=parseInt((doy
+rdow
)/7,10);return Date.ext.util.xPad(woy,0)},V:function(d){var woy=parseInt(Date.ext.formats.W(d),10);var dow1_1=(new Date(""+d.getFullYear()+"/1/1")).getDay();var idow=woy+(dow1_1>4||dow1_1<=1?0:1);if(idow==53&&(new Date(""+d.getFullYear()+"/12/31")).getDay()<4){idow=1}else{if(idow===0){idow=Date.ext.formats.V(new Date(""+(d.getFullYear()-1)+"/12/31"))}}return Date.ext.util.xPad(idow,0)},w:"getDay",W:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=7-Date.ext.formats.u(d);var woy=parseInt((doy+rdow)/7,10);return Date
.ext
.util
.xPad(woy
,0,10)},y
:function(d
){return Date
.ext
.util
.xPad(d
.getFullYear()%100,0)},Y
:"getFullYear",z
:function(d
){var o
=d
.getTimezoneOffset();var H
=Date
.ext
.util
.xPad(parseInt(Math
.abs(o
/60),10),0);var M=Date.ext.util.xPad(o%60,0);return(o>0?"-":"+")+H+M},Z:function(d){return d.toString().replace(/^.*\(([^)]+)\)$/,"$1")},"%":function(d){return"%"}};Date.ext.aggregates={c:"locale",D:"%m/%d
/%y",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"};Date.ext.aggregates.z=Date.ext.formats.z(new Date());Date.ext.aggregates.Z=Date.ext.formats.Z(new Date());Date.ext.unsupported={};Date.prototype.strftime=function(fmt){if(!(this.locale in Date.ext.locales)){if(this.locale.replace(/-[a
-zA
-Z
]+$/,"") in Date.ext.locales){this.locale=this.locale.replace(/-[a
-zA
-Z
]+$/,"")}else{this.locale="en-GB"}}var d=this;while(fmt.match(/%[cDhnrRtTxXzZ
]/)){fmt=fmt.replace(/%([cDhnrRtTxXzZ
])/g,function(m0,m1){var f=Date.ext.aggregates[m1];return(f=="locale"?Date.ext.locales[d.locale][m1]:f)})}var str=fmt.replace(/%([aAbBCdegGHIjmMpPSuUVwWyY
%])/g
,function(m0
,m1
){var f
=Date
.ext
.formats
[m1
];if(typeof (f
)=="string"){return d
[f
]()}else{if(typeof (f
)=="function"){return f
.call(d
,d
)}else{if(typeof (f
)=="object"&&typeof (f
[0])=="string"){return Date
.ext
.util
.xPad(d
[f
[0]](),f
[1])}else{return m1
}}}});d
=null;return str
};
3250 DygraphLayout
=function(_1
,_2
){
3253 MochiKit
.Base
.update(this.options
,_2
?_2
:{});
3254 this.datasets
=new Array();
3256 DygraphLayout
.prototype.attr_
=function(_3
){
3257 return this.dygraph_
.attr_(_3
);
3259 DygraphLayout
.prototype.addDataset
=function(_4
,_5
){
3260 this.datasets
[_4
]=_5
;
3262 DygraphLayout
.prototype.evaluate
=function(){
3263 this._evaluateLimits();
3264 this._evaluateLineCharts();
3265 this._evaluateLineTicks();
3267 DygraphLayout
.prototype._evaluateLimits
=function(){
3268 this.minxval
=this.maxxval
=null;
3269 for(var _6
in this.datasets
){
3270 var _7
=this.datasets
[_6
];
3272 if(!this.minxval
||x1
<this.minxval
){
3275 var x2
=_7
[_7
.length
-1][0];
3276 if(!this.maxxval
||x2
>this.maxxval
){
3280 this.xrange
=this.maxxval
-this.minxval
;
3281 this.xscale
=(this.xrange
!=0?1/this.xrange
:1);
3282 this.minyval
=this.options
.yAxis
[0];
3283 this.maxyval
=this.options
.yAxis
[1];
3284 this.yrange
=this.maxyval
-this.minyval
;
3285 this.yscale
=(this.yrange
!=0?1/this.yrange
:1);
3287 DygraphLayout
.prototype._evaluateLineCharts
=function(){
3288 this.points
=new Array();
3289 for(var _10
in this.datasets
){
3290 var _11
=this.datasets
[_10
];
3291 for(var j
=0;j
<_11
.length
;j
++){
3293 var _14
={x
:((parseFloat(_13
[0])-this.minxval
)*this.xscale
),y
:1-((parseFloat(_13
[1])-this.minyval
)*this.yscale
),xval
:parseFloat(_13
[0]),yval
:parseFloat(_13
[1]),name
:_10
};
3300 if((_14
.x
>=0)&&(_14
.x
<=1)){
3301 this.points
.push(_14
);
3306 DygraphLayout
.prototype._evaluateLineTicks
=function(){
3307 this.xticks
=new Array();
3308 for(var i
=0;i
<this.options
.xTicks
.length
;i
++){
3309 var _16
=this.options
.xTicks
[i
];
3311 var pos
=this.xscale
*(_16
.v
-this.minxval
);
3312 if((pos
>=0)&&(pos
<=1)){
3313 this.xticks
.push([pos
,_17
]);
3316 this.yticks
=new Array();
3317 for(var i
=0;i
<this.options
.yTicks
.length
;i
++){
3318 var _16
=this.options
.yTicks
[i
];
3320 var pos
=1-(this.yscale
*(_16
.v
-this.minyval
));
3321 if((pos
>=0)&&(pos
<=1)){
3322 this.yticks
.push([pos
,_17
]);
3326 DygraphLayout
.prototype.evaluateWithError
=function(){
3328 if(!this.options
.errorBars
){
3332 for(var _19
in this.datasets
){
3334 var _20
=this.datasets
[_19
];
3335 for(var j
=0;j
<_20
.length
;j
++,i
++){
3337 var xv
=parseFloat(_21
[0]);
3338 var yv
=parseFloat(_21
[1]);
3339 if(xv
==this.points
[i
].xval
&&yv
==this.points
[i
].yval
){
3340 this.points
[i
].errorMinus
=parseFloat(_21
[2]);
3341 this.points
[i
].errorPlus
=parseFloat(_21
[3]);
3346 DygraphLayout
.prototype.removeAllDatasets
=function(){
3347 delete this.datasets
;
3348 this.datasets
=new Array();
3350 DygraphLayout
.prototype.updateOptions
=function(_24
){
3351 MochiKit
.Base
.update(this.options
,_24
?_24
:{});
3353 DygraphCanvasRenderer
=function(_25
,_26
,_27
,_28
){
3355 this.options
={"strokeWidth":0.5,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color
.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color
.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"drawYGrid":true,"drawXGrid":true,"gridLineColor":MochiKit
.Color
.Color
.grayColor()};
3356 MochiKit
.Base
.update(this.options
,_28
);
3358 this.element
=MochiKit
.DOM
.getElement(_26
);
3359 this.container
=this.element
.parentNode
;
3360 this.isIE
=(/MSIE/.test(navigator
.userAgent
)&&!window
.opera
);
3361 if(this.isIE
&&!isNil(G_vmlCanvasManager
)){
3364 this.renderDelay
=null;
3365 this.clearDelay
=null;
3366 this.element
=G_vmlCanvasManager
.initElement(this.element
);
3368 this.height
=this.element
.height
;
3369 this.width
=this.element
.width
;
3370 if(!this.isIE
&&!(DygraphCanvasRenderer
.isSupported(this.element
))){
3371 throw "Canvas is not supported.";
3373 this.xlabels
=new Array();
3374 this.ylabels
=new Array();
3375 this.area
={x
:this.options
.yAxisLabelWidth
+2*this.options
.axisTickSize
,y
:0};
3376 this.area
.w
=this.width
-this.area
.x
-this.options
.rightGap
;
3377 this.area
.h
=this.height
-this.options
.axisLabelFontSize
-2*this.options
.axisTickSize
;
3378 MochiKit
.DOM
.updateNodeAttributes(this.container
,{"style":{"position":"relative","width":this.width
+"px"}});
3380 DygraphCanvasRenderer
.prototype.clear
=function(){
3383 if(this.clearDelay
){
3384 this.clearDelay
.cancel();
3385 this.clearDelay
=null;
3387 var _29
=this.element
.getContext("2d");
3390 this.clearDelay
=MochiKit
.Async
.wait(this.IEDelay
);
3391 this.clearDelay
.addCallback(bind(this.clear
,this));
3395 var _29
=this.element
.getContext("2d");
3396 _29
.clearRect(0,0,this.width
,this.height
);
3397 for(var i
=0;i
<this.xlabels
.length
;i
++){
3398 MochiKit
.DOM
.removeElement(this.xlabels
[i
]);
3400 for(var i
=0;i
<this.ylabels
.length
;i
++){
3401 MochiKit
.DOM
.removeElement(this.ylabels
[i
]);
3403 this.xlabels
=new Array();
3404 this.ylabels
=new Array();
3406 DygraphCanvasRenderer
.isSupported
=function(_30
){
3409 if(MochiKit
.Base
.isUndefinedOrNull(_30
)){
3410 _31
=MochiKit
.DOM
.CANVAS({});
3412 _31
=MochiKit
.DOM
.getElement(_30
);
3414 var _32
=_31
.getContext("2d");
3417 var ie
=navigator
.appVersion
.match(/MSIE (\d\.\d)/);
3418 var _34
=(navigator
.userAgent
.toLowerCase().indexOf("opera")!=-1);
3419 if((!ie
)||(ie
[1]<6)||(_34
)){
3426 DygraphCanvasRenderer
.prototype.render
=function(){
3427 var ctx
=this.element
.getContext("2d");
3428 if(this.options
.drawYGrid
){
3429 var _36
=this.layout
.yticks
;
3431 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
3432 ctx
.lineWidth
=this.options
.axisLineWidth
;
3433 for(var i
=0;i
<_36
.length
;i
++){
3435 var y
=this.area
.y
+_36
[i
][0]*this.area
.h
;
3438 ctx
.lineTo(x
+this.area
.w
,y
);
3443 if(this.options
.drawXGrid
){
3444 var _36
=this.layout
.xticks
;
3446 ctx
.strokeStyle
=this.options
.gridLineColor
.toRGBString();
3447 ctx
.lineWidth
=this.options
.axisLineWidth
;
3448 for(var i
=0;i
<_36
.length
;i
++){
3449 var x
=this.area
.x
+_36
[i
][0]*this.area
.w
;
3450 var y
=this.area
.y
+this.area
.h
;
3453 ctx
.lineTo(x
,this.area
.y
);
3458 this._renderLineChart();
3461 DygraphCanvasRenderer
.prototype._renderAxis
=function(){
3462 if(!this.options
.drawXAxis
&&!this.options
.drawYAxis
){
3465 var _39
=this.element
.getContext("2d");
3466 var _40
={"style":{"position":"absolute","fontSize":this.options
.axisLabelFontSize
+"px","zIndex":10,"color":this.options
.axisLabelColor
.toRGBString(),"width":this.options
.axisLabelWidth
+"px","overflow":"hidden"}};
3468 _39
.strokeStyle
=this.options
.axisLineColor
.toRGBString();
3469 _39
.lineWidth
=this.options
.axisLineWidth
;
3470 if(this.options
.drawYAxis
){
3471 if(this.layout
.yticks
){
3472 for(var i
=0;i
<this.layout
.yticks
.length
;i
++){
3473 var _41
=this.layout
.yticks
[i
];
3474 if(typeof (_41
)=="function"){
3478 var y
=this.area
.y
+_41
[0]*this.area
.h
;
3481 _39
.lineTo(x
-this.options
.axisTickSize
,y
);
3484 var _42
=DIV(_40
,_41
[1]);
3485 var top
=(y
-this.options
.axisLabelFontSize
/2);
3489 if(top
+this.options
.axisLabelFontSize
+3>this.height
){
3490 _42
.style
.bottom
="0px";
3492 _42
.style
.top
=top
+"px";
3494 _42
.style
.left
="0px";
3495 _42
.style
.textAlign
="right";
3496 _42
.style
.width
=this.options
.yAxisLabelWidth
+"px";
3497 MochiKit
.DOM
.appendChildNodes(this.container
,_42
);
3498 this.ylabels
.push(_42
);
3500 var _44
=this.ylabels
[0];
3501 var _45
=this.options
.axisLabelFontSize
;
3502 var _46
=parseInt(_44
.style
.top
)+_45
;
3503 if(_46
>this.height
-_45
){
3504 _44
.style
.top
=(parseInt(_44
.style
.top
)-_45
/2)+"px";
3508 _39
.moveTo(this.area
.x
,this.area
.y
);
3509 _39
.lineTo(this.area
.x
,this.area
.y
+this.area
.h
);
3513 if(this.options
.drawXAxis
){
3514 if(this.layout
.xticks
){
3515 for(var i
=0;i
<this.layout
.xticks
.length
;i
++){
3516 var _41
=this.layout
.xticks
[i
];
3517 if(typeof (dataset
)=="function"){
3520 var x
=this.area
.x
+_41
[0]*this.area
.w
;
3521 var y
=this.area
.y
+this.area
.h
;
3524 _39
.lineTo(x
,y
+this.options
.axisTickSize
);
3527 var _42
=DIV(_40
,_41
[1]);
3528 _42
.style
.textAlign
="center";
3529 _42
.style
.bottom
="0px";
3530 var _47
=(x
-this.options
.axisLabelWidth
/2);
3531 if(_47
+this.options
.axisLabelWidth
>this.width
){
3532 _47
=this.width
-this.options
.xAxisLabelWidth
;
3533 _42
.style
.textAlign
="right";
3537 _42
.style
.textAlign
="left";
3539 _42
.style
.left
=_47
+"px";
3540 _42
.style
.width
=this.options
.xAxisLabelWidth
+"px";
3541 MochiKit
.DOM
.appendChildNodes(this.container
,_42
);
3542 this.xlabels
.push(_42
);
3546 _39
.moveTo(this.area
.x
,this.area
.y
+this.area
.h
);
3547 _39
.lineTo(this.area
.x
+this.area
.w
,this.area
.y
+this.area
.h
);
3553 DygraphCanvasRenderer
.prototype._renderLineChart
=function(){
3554 var _48
=this.element
.getContext("2d");
3555 var _49
=this.options
.colorScheme
.length
;
3556 var _50
=this.options
.colorScheme
;
3557 var _51
=MochiKit
.Base
.keys(this.layout
.datasets
);
3558 var _52
=this.layout
.options
.errorBars
;
3560 var _54
=MochiKit
.Base
.bind
;
3561 var _55
=MochiKit
.Base
.partial
;
3562 for(var i
=0;i
<this.layout
.points
.length
;i
++){
3563 var _56
=this.layout
.points
[i
];
3564 _56
.canvasx
=this.area
.w
*_56
.x
+this.area
.x
;
3565 _56
.canvasy
=this.area
.h
*_56
.y
+this.area
.y
;
3567 var _57
=function(x
){
3568 return x
&&!isNaN(x
);
3570 var _58
=function(ctx
){
3571 for(var i
=0;i
<_53
;i
++){
3574 var _61
=this.options
.strokeColorTransform
;
3576 _48
.strokeStyle
=_60
.toRGBString();
3577 _48
.lineWidth
=this.options
.strokeWidth
;
3578 var _56
=this.layout
.points
[0];
3579 var _62
=this.dygraph_
.attr_("pointSize");
3580 var _63
=null,prevY
=null;
3581 var _64
=this.dygraph_
.attr_("drawPoints");
3582 var _65
=this.layout
.points
;
3583 for(var j
=0;j
<_65
.length
;j
++){
3586 if(!_57(_56
.canvasy
)){
3589 var _66
=(!_63
&&(j
==_65
.length
-1||!_57(_65
[j
+1].canvasy
)));
3595 ctx
.moveTo(_63
,prevY
);
3598 ctx
.lineTo(_63
,prevY
);
3603 ctx
.fillStyle
=_60
.toRGBString();
3604 ctx
.arc(_56
.canvasx
,_56
.canvasy
,_62
,0,360,false);
3612 var _67
=function(ctx
){
3613 for(var i
=0;i
<_53
;i
++){
3616 var _70
=this.options
.strokeColorTransform
;
3618 _48
.strokeStyle
=_69
.toRGBString();
3619 _48
.lineWidth
=this.options
.strokeWidth
;
3623 var _74
=this.layout
.yscale
;
3624 var _75
=function(_76
,_77
){
3627 if(!_77
.y
||isNaN(_77
.y
)){
3631 var _78
=[_77
.y
-_77
.errorPlus
*_74
,_77
.y
+_77
.errorMinus
*_74
];
3632 _78
[0]=this.area
.h
*_78
[0]+this.area
.y
;
3633 _78
[1]=this.area
.h
*_78
[1]+this.area
.y
;
3635 _76
.moveTo(_71
,_72
[0]);
3636 _76
.lineTo(_77
.canvasx
,_78
[0]);
3637 _76
.lineTo(_77
.canvasx
,_78
[1]);
3638 _76
.lineTo(_71
,_72
[1]);
3646 var _79
=_69
.colorWithAlpha(0.15);
3647 ctx
.fillStyle
=_79
.toRGBString();
3649 MochiKit
.Iter
.forEach(this.layout
.points
,_55(_75
,ctx
),this);
3659 Dygraph
=function(div
,_81
,_82
){
3660 if(arguments
.length
>0){
3661 if(arguments
.length
==4){
3662 this.warn("Using deprecated four-argument dygraph constructor");
3663 this.__old_init__(div
,_81
,arguments
[2],arguments
[3]);
3665 this.__init__(div
,_81
,_82
);
3669 Dygraph
.NAME
="Dygraph";
3670 Dygraph
.VERSION
="1.2";
3671 Dygraph
.__repr__
=function(){
3672 return "["+this.NAME
+" "+this.VERSION
+"]";
3674 Dygraph
.toString
=function(){
3675 return this.__repr__();
3677 Dygraph
.DEFAULT_ROLL_PERIOD
=1;
3678 Dygraph
.DEFAULT_WIDTH
=480;
3679 Dygraph
.DEFAULT_HEIGHT
=320;
3680 Dygraph
.AXIS_LINE_WIDTH
=0.3;
3681 Dygraph
.DEFAULT_ATTRS
={highlightCircleSize
:3,pixelsPerXLabel
:60,pixelsPerYLabel
:30,labelsDivWidth
:250,labelsDivStyles
:{},labelsSeparateLines
:false,labelsKMB
:false,strokeWidth
:1,axisTickSize
:3,axisLabelFontSize
:14,xAxisLabelWidth
:50,yAxisLabelWidth
:50,rightGap
:5,showRoller
:false,xValueFormatter
:Dygraph
.dateString_
,xValueParser
:Dygraph
.dateParser
,xTicker
:Dygraph
.dateTicker
,sigma
:2,errorBars
:false,fractions
:false,wilsonInterval
:true,customBars
:false};
3686 Dygraph
.prototype.__old_init__
=function(div
,_83
,_84
,_85
){
3689 for(var i
=0;i
<_84
.length
;i
++){
3692 MochiKit
.Base
.update(_85
,{"labels":_86
});
3694 this.__init__(div
,_83
,_85
);
3696 Dygraph
.prototype.__init__
=function(div
,_87
,_88
){
3702 this.rollPeriod_
=_88
.rollPeriod
||Dygraph
.DEFAULT_ROLL_PERIOD
;
3703 this.previousVerticalX_
=-1;
3704 this.fractions_
=_88
.fractions
||false;
3705 this.dateWindow_
=_88
.dateWindow
||null;
3706 this.valueRange_
=_88
.valueRange
||null;
3707 this.wilsonInterval_
=_88
.wilsonInterval
||true;
3709 if(div
.style
.width
==""){
3710 div
.style
.width
=Dygraph
.DEFAULT_WIDTH
+"px";
3712 if(div
.style
.height
==""){
3713 div
.style
.height
=Dygraph
.DEFAULT_HEIGHT
+"px";
3715 this.width_
=parseInt(div
.style
.width
,10);
3716 this.height_
=parseInt(div
.style
.height
,10);
3717 this.user_attrs_
={};
3718 MochiKit
.Base
.update(this.user_attrs_
,_88
);
3720 MochiKit
.Base
.update(this.attrs_
,Dygraph
.DEFAULT_ATTRS
);
3721 this.labelsFromCSV_
=(this.attr_("labels")==null);
3722 this.createInterface_();
3723 this.layoutOptions_
={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
3724 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
3725 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
3726 this.layout_
=new DygraphLayout(this,this.layoutOptions_
);
3727 this.renderOptions_
={colorScheme
:this.colors_
,strokeColor
:null,axisLineWidth
:Dygraph
.AXIS_LINE_WIDTH
};
3728 MochiKit
.Base
.update(this.renderOptions_
,this.attrs_
);
3729 MochiKit
.Base
.update(this.renderOptions_
,this.user_attrs_
);
3730 this.plotter_
=new DygraphCanvasRenderer(this,this.hidden_
,this.layout_
,this.renderOptions_
);
3731 this.createStatusMessage_();
3732 this.createRollInterface_();
3733 this.createDragInterface_();
3736 Dygraph
.prototype.attr_
=function(_89
){
3737 if(typeof (this.user_attrs_
[_89
])!="undefined"){
3738 return this.user_attrs_
[_89
];
3740 if(typeof (this.attrs_
[_89
])!="undefined"){
3741 return this.attrs_
[_89
];
3747 Dygraph
.prototype.log
=function(_90
,_91
){
3748 if(typeof (console
)!="undefined"){
3751 console
.debug("dygraphs: "+_91
);
3754 console
.info("dygraphs: "+_91
);
3756 case Dygraph
.WARNING
:
3757 console
.warn("dygraphs: "+_91
);
3760 console
.error("dygraphs: "+_91
);
3765 Dygraph
.prototype.info
=function(_92
){
3766 this.log(Dygraph
.INFO
,_92
);
3768 Dygraph
.prototype.warn
=function(_93
){
3769 this.log(Dygraph
.WARNING
,_93
);
3771 Dygraph
.prototype.error
=function(_94
){
3772 this.log(Dygraph
.ERROR
,_94
);
3774 Dygraph
.prototype.rollPeriod
=function(){
3775 return this.rollPeriod_
;
3777 Dygraph
.prototype.createInterface_
=function(){
3778 var _95
=this.maindiv_
;
3779 this.graphDiv
=MochiKit
.DOM
.DIV({style
:{"width":this.width_
+"px","height":this.height_
+"px"}});
3780 appendChildNodes(_95
,this.graphDiv
);
3781 var _96
=MochiKit
.DOM
.CANVAS
;
3782 this.canvas_
=_96({style
:{"position":"absolute"},width
:this.width_
,height
:this.height_
});
3783 appendChildNodes(this.graphDiv
,this.canvas_
);
3784 this.hidden_
=this.createPlotKitCanvas_(this.canvas_
);
3785 connect(this.hidden_
,"onmousemove",this,function(e
){
3788 connect(this.hidden_
,"onmouseout",this,function(e
){
3792 Dygraph
.prototype.createPlotKitCanvas_
=function(_98
){
3793 var h
=document
.createElement("canvas");
3794 h
.style
.position
="absolute";
3795 h
.style
.top
=_98
.style
.top
;
3796 h
.style
.left
=_98
.style
.left
;
3797 h
.width
=this.width_
;
3798 h
.height
=this.height_
;
3799 MochiKit
.DOM
.appendChildNodes(this.graphDiv
,h
);
3802 Dygraph
.prototype.setColors_
=function(){
3803 var num
=this.attr_("labels").length
-1;
3805 var _101
=this.attr_("colors");
3807 var sat
=this.attr_("colorSaturation")||1;
3808 var val
=this.attr_("colorValue")||0.5;
3809 for(var i
=1;i
<=num
;i
++){
3810 var hue
=(1*i
/(1+num
));
3811 this.colors_
.push(MochiKit
.Color
.Color
.fromHSV(hue
,sat
,val
));
3814 for(var i
=0;i
<num
;i
++){
3815 var _105
=_101
[i
%_101
.length
];
3816 this.colors_
.push(MochiKit
.Color
.Color
.fromString(_105
));
3819 this.renderOptions_
.colorScheme
=this.colors_
;
3820 MochiKit
.Base
.update(this.plotter_
.options
,this.renderOptions_
);
3821 MochiKit
.Base
.update(this.layoutOptions_
,this.user_attrs_
);
3822 MochiKit
.Base
.update(this.layoutOptions_
,this.attrs_
);
3824 Dygraph
.findPosX
=function(obj
){
3826 if(obj
.offsetParent
){
3827 while(obj
.offsetParent
){
3828 _107
+=obj
.offsetLeft
;
3829 obj
=obj
.offsetParent
;
3838 Dygraph
.findPosY
=function(obj
){
3840 if(obj
.offsetParent
){
3841 while(obj
.offsetParent
){
3842 _108
+=obj
.offsetTop
;
3843 obj
=obj
.offsetParent
;
3852 Dygraph
.prototype.createStatusMessage_
=function(){
3853 if(!this.attr_("labelsDiv")){
3854 var _109
=this.attr_("labelsDivWidth");
3855 var _110
={"style":{"position":"absolute","fontSize":"14px","zIndex":10,"width":_109
+"px","top":"0px","left":(this.width_
-_109
-2)+"px","background":"white","textAlign":"left","overflow":"hidden"}};
3856 MochiKit
.Base
.update(_110
["style"],this.attr_("labelsDivStyles"));
3857 var div
=MochiKit
.DOM
.DIV(_110
);
3858 MochiKit
.DOM
.appendChildNodes(this.graphDiv
,div
);
3859 this.attrs_
.labelsDiv
=div
;
3862 Dygraph
.prototype.createRollInterface_
=function(){
3863 var _111
=this.attr_("showRoller")?"block":"none";
3864 var _112
={"type":"text","size":"2","value":this.rollPeriod_
,"style":{"position":"absolute","zIndex":10,"top":(this.plotter_
.area
.h
-25)+"px","left":(this.plotter_
.area
.x
+1)+"px","display":_111
}};
3865 var _113
=MochiKit
.DOM
.INPUT(_112
);
3866 var pa
=this.graphDiv
;
3867 MochiKit
.DOM
.appendChildNodes(pa
,_113
);
3868 connect(_113
,"onchange",this,function(){
3869 this.adjustRoll(_113
.value
);
3873 Dygraph
.prototype.createDragInterface_
=function(){
3883 var getX
=function(e
){
3884 return e
.mouse().page
.x
-px
;
3886 var getY
=function(e
){
3887 return e
.mouse().page
.y
-py
;
3889 connect(this.hidden_
,"onmousemove",function(_126
){
3893 self
.drawZoomRect_(_117
,_119
,_121
);
3897 connect(this.hidden_
,"onmousedown",function(_127
){
3899 px
=Dygraph
.findPosX(self
.canvas_
);
3900 py
=Dygraph
.findPosY(self
.canvas_
);
3904 connect(document
,"onmouseup",this,function(_128
){
3911 connect(this.hidden_
,"onmouseout",this,function(_129
){
3917 connect(this.hidden_
,"onmouseup",this,function(_130
){
3922 var _131
=Math
.abs(_119
-_117
);
3923 var _132
=Math
.abs(_120
-_118
);
3924 if(_131
<2&&_132
<2&&self
.attr_("clickCallback")!=null&&self
.lastx_
!=undefined
){
3925 self
.attr_("clickCallback")(_130
,new Date(self
.lastx_
));
3928 self
.doZoom_(Math
.min(_117
,_119
),Math
.max(_117
,_119
));
3930 self
.canvas_
.getContext("2d").clearRect(0,0,self
.canvas_
.width
,self
.canvas_
.height
);
3936 connect(this.hidden_
,"ondblclick",this,function(_133
){
3937 self
.dateWindow_
=null;
3938 self
.drawGraph_(self
.rawData_
);
3939 var _134
=self
.rawData_
[0][0];
3940 var _135
=self
.rawData_
[self
.rawData_
.length
-1][0];
3941 if(self
.attr_("zoomCallback")){
3942 self
.attr_("zoomCallback")(_134
,_135
);
3946 Dygraph
.prototype.drawZoomRect_
=function(_136
,endX
,_138
){
3947 var ctx
=this.canvas_
.getContext("2d");
3949 ctx
.clearRect(Math
.min(_136
,_138
),0,Math
.abs(_136
-_138
),this.height_
);
3952 ctx
.fillStyle
="rgba(128,128,128,0.33)";
3953 ctx
.fillRect(Math
.min(_136
,endX
),0,Math
.abs(endX
-_136
),this.height_
);
3956 Dygraph
.prototype.doZoom_
=function(lowX
,_140
){
3957 var _141
=this.layout_
.points
;
3960 for(var i
=0;i
<_141
.length
;i
++){
3961 var cx
=_141
[i
].canvasx
;
3963 if(cx
<lowX
&&(_142
==null||x
>_142
)){
3966 if(cx
>_140
&&(_143
==null||x
<_143
)){
3974 _143
=_141
[_141
.length
-1].xval
;
3976 this.dateWindow_
=[_142
,_143
];
3977 this.drawGraph_(this.rawData_
);
3978 if(this.attr_("zoomCallback")){
3979 this.attr_("zoomCallback")(_142
,_143
);
3982 Dygraph
.prototype.mouseMove_
=function(_145
){
3983 var _146
=_145
.mouse().page
.x
-Dygraph
.findPosX(this.hidden_
);
3984 var _147
=this.layout_
.points
;
3989 for(var i
=0;i
<_147
.length
;i
++){
3990 var dist
=Math
.abs(_147
[i
].canvasx
-_146
);
3998 _148
=_147
[idx
].xval
;
4000 if(_146
>_147
[_147
.length
-1].canvasx
){
4001 _148
=_147
[_147
.length
-1].xval
;
4004 for(var i
=0;i
<_147
.length
;i
++){
4005 if(_147
[i
].xval
==_148
){
4009 var _154
=this.attr_("highlightCircleSize");
4010 var ctx
=this.canvas_
.getContext("2d");
4011 if(this.previousVerticalX_
>=0){
4012 var px
=this.previousVerticalX_
;
4013 ctx
.clearRect(px
-_154
-1,0,2*_154
+2,this.height_
);
4015 var isOK
=function(x
){
4016 return x
&&!isNaN(x
);
4019 var _146
=_153
[0].canvasx
;
4020 var _156
=this.attr_("xValueFormatter")(_148
,this)+":";
4021 var clen
=this.colors_
.length
;
4022 for(var i
=0;i
<_153
.length
;i
++){
4023 if(!isOK(_153
[i
].canvasy
)){
4026 if(this.attr_("labelsSeparateLines")){
4030 _156
+=" <b><font color='"+this.colors_
[i
%clen
].toHexString()+"'>"+_158
.name
+"</font></b>:"+this.round_(_158
.yval
,2);
4032 this.attr_("labelsDiv").innerHTML
=_156
;
4035 for(var i
=0;i
<_153
.length
;i
++){
4036 if(!isOK(_153
[i
%clen
].canvasy
)){
4040 ctx
.fillStyle
=this.colors_
[i
%clen
].toRGBString();
4041 ctx
.arc(_146
,_153
[i
%clen
].canvasy
,_154
,0,360,false);
4045 this.previousVerticalX_
=_146
;
4048 Dygraph
.prototype.mouseOut_
=function(_159
){
4049 var ctx
=this.canvas_
.getContext("2d");
4050 ctx
.clearRect(0,0,this.width_
,this.height_
);
4051 this.attr_("labelsDiv").innerHTML
="";
4053 Dygraph
.zeropad
=function(x
){
4060 Dygraph
.prototype.hmsString_
=function(date
){
4061 var _161
=Dygraph
.zeropad
;
4062 var d
=new Date(date
);
4064 return _161(d
.getHours())+":"+_161(d
.getMinutes())+":"+_161(d
.getSeconds());
4067 return _161(d
.getHours())+":"+_161(d
.getMinutes());
4069 return _161(d
.getHours());
4073 Dygraph
.dateString_
=function(date
,self
){
4074 var _163
=Dygraph
.zeropad
;
4075 var d
=new Date(date
);
4076 var year
=""+d
.getFullYear();
4077 var _165
=_163(d
.getMonth()+1);
4078 var day
=_163(d
.getDate());
4080 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
4082 ret
=" "+self
.hmsString_(date
);
4084 return year
+"/"+_165+"/"+day
+ret
;
4086 Dygraph
.prototype.round_
=function(num
,_169
){
4087 var _170
=Math
.pow(10,_169
);
4088 return Math
.round(num
*_170
)/_170
;
4090 Dygraph
.prototype.loadedEvent_
=function(data
){
4091 this.rawData_
=this.parseCSV_(data
);
4092 this.drawGraph_(this.rawData_
);
4094 Dygraph
.prototype.months
=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
4095 Dygraph
.prototype.quarters
=["Jan","Apr","Jul","Oct"];
4096 Dygraph
.prototype.addXTicks_
=function(){
4098 if(this.dateWindow_
){
4099 _172
=this.dateWindow_
[0];
4100 endDate
=this.dateWindow_
[1];
4102 _172
=this.rawData_
[0][0];
4103 endDate
=this.rawData_
[this.rawData_
.length
-1][0];
4105 var _173
=this.attr_("xTicker")(_172
,endDate
,this);
4106 this.layout_
.updateOptions({xTicks
:_173
});
4109 Dygraph
.TEN_SECONDLY
=1;
4110 Dygraph
.THIRTY_SECONDLY
=2;
4112 Dygraph
.TEN_MINUTELY
=4;
4113 Dygraph
.THIRTY_MINUTELY
=5;
4115 Dygraph
.SIX_HOURLY
=7;
4119 Dygraph
.QUARTERLY
=11;
4120 Dygraph
.BIANNUAL
=12;
4123 Dygraph
.NUM_GRANULARITIES
=15;
4124 Dygraph
.SHORT_SPACINGS
=[];
4125 Dygraph
.SHORT_SPACINGS
[Dygraph
.SECONDLY
]=1000*1;
4126 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_SECONDLY
]=1000*10;
4127 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_SECONDLY
]=1000*30;
4128 Dygraph
.SHORT_SPACINGS
[Dygraph
.MINUTELY
]=1000*60;
4129 Dygraph
.SHORT_SPACINGS
[Dygraph
.TEN_MINUTELY
]=1000*60*10;
4130 Dygraph
.SHORT_SPACINGS
[Dygraph
.THIRTY_MINUTELY
]=1000*60*30;
4131 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600;
4132 Dygraph
.SHORT_SPACINGS
[Dygraph
.HOURLY
]=1000*3600*6;
4133 Dygraph
.SHORT_SPACINGS
[Dygraph
.DAILY
]=1000*86400;
4134 Dygraph
.SHORT_SPACINGS
[Dygraph
.WEEKLY
]=1000*604800;
4135 Dygraph
.prototype.NumXTicks
=function(_174
,_175
,_176
){
4136 if(_176
<Dygraph
.MONTHLY
){
4137 var _177
=Dygraph
.SHORT_SPACINGS
[_176
];
4138 return Math
.floor(0.5+1*(_175
-_174
)/_177
);
4142 if(_176
==Dygraph
.QUARTERLY
){
4145 if(_176
==Dygraph
.BIANNUAL
){
4148 if(_176
==Dygraph
.ANNUAL
){
4151 if(_176
==Dygraph
.DECADAL
){
4155 var _180
=365.2524*24*3600*1000;
4156 var _181
=1*(_175
-_174
)/_180
;
4157 return Math
.floor(0.5+1*_181
*_179
/_178
);
4160 Dygraph
.prototype.GetXAxis
=function(_182
,_183
,_184
){
4162 if(_184
<Dygraph
.MONTHLY
){
4163 var _186
=Dygraph
.SHORT_SPACINGS
[_184
];
4165 if(_184
<Dygraph
.HOURLY
){
4166 _182
=_186
*Math
.floor(0.5+_182
/_186
);
4168 for(var t
=_182
;t
<=_183
;t
+=_186
){
4170 var frac
=d
.getHours()*3600+d
.getMinutes()*60+d
.getSeconds();
4171 if(frac
==0||_184
>=Dygraph
.DAILY
){
4172 _185
.push({v
:t
,label
:new Date(t
+3600*1000).strftime(_187
)});
4174 _185
.push({v
:t
,label
:this.hmsString_(t
)});
4180 if(_184
==Dygraph
.MONTHLY
){
4181 _189
=[0,1,2,3,4,5,6,7,8,9,10,11,12];
4183 if(_184
==Dygraph
.QUARTERLY
){
4186 if(_184
==Dygraph
.BIANNUAL
){
4189 if(_184
==Dygraph
.ANNUAL
){
4192 if(_184
==Dygraph
.DECADAL
){
4200 var _191
=new Date(_182
).getFullYear();
4201 var _192
=new Date(_183
).getFullYear();
4202 var _193
=Dygraph
.zeropad
;
4203 for(var i
=_191
;i
<=_192
;i
++){
4207 for(var j
=0;j
<_189
.length
;j
++){
4208 var _194
=i
+"/"+_193(1+_189[j])+"/01";
4209 var t
=Date
.parse(_194
);
4213 _185
.push({v
:t
,label
:new Date(t
).strftime("%b %y")});
4219 Dygraph
.dateTicker
=function(_195
,_196
,self
){
4221 for(var i
=0;i
<Dygraph
.NUM_GRANULARITIES
;i
++){
4222 var _198
=self
.NumXTicks(_195
,_196
,i
);
4223 if(self
.width_
/_198
>=self
.attr_("pixelsPerXLabel")){
4229 return self
.GetXAxis(_195
,_196
,_197
);
4233 Dygraph
.numericTicks
=function(minV
,maxV
,self
){
4235 var _202
,low_val
,high_val
,nTicks
;
4236 var _203
=self
.attr_("pixelsPerYLabel");
4237 for(var i
=-10;i
<50;i
++){
4238 var _204
=Math
.pow(10,i
);
4239 for(var j
=0;j
<_201
.length
;j
++){
4241 low_val
=Math
.floor(minV
/_202
)*_202
;
4242 high_val
=Math
.ceil(maxV
/_202
)*_202
;
4243 nTicks
=(high_val
-low_val
)/_202
;
4244 var _205
=self
.height_
/nTicks
;
4254 for(var i
=0;i
<nTicks
;i
++){
4255 var _207
=low_val
+i
*_202
;
4256 var _208
=self
.round_(_207
,2);
4257 if(self
.attr_("labelsKMB")){
4260 _208
=self
.round_(_207
/(k
*k
*k
),1)+"B";
4263 _208
=self
.round_(_207
/(k
*k
),1)+"M";
4266 _208
=self
.round_(_207
/k
,1)+"K";
4271 _206
.push({label
:_208
,v
:_207
});
4275 Dygraph
.prototype.addYTicks_
=function(minY
,maxY
){
4276 var _212
=Dygraph
.numericTicks(minY
,maxY
,this);
4277 this.layout_
.updateOptions({yAxis
:[minY
,maxY
],yTicks
:_212
});
4279 Dygraph
.prototype.extremeValues_
=function(_213
){
4280 var minY
=null,maxY
=null;
4281 var bars
=this.attr_("errorBars")||this.attr_("customBars");
4283 for(var j
=0;j
<_213
.length
;j
++){
4284 var y
=_213
[j
][1][0];
4288 var low
=y
-_213
[j
][1][1];
4289 var high
=y
+_213
[j
][1][2];
4296 if(maxY
==null||high
>maxY
){
4299 if(minY
==null||low
<minY
){
4304 for(var j
=0;j
<_213
.length
;j
++){
4309 if(maxY
==null||y
>maxY
){
4312 if(minY
==null||y
<minY
){
4319 Dygraph
.prototype.drawGraph_
=function(data
){
4320 var minY
=null,maxY
=null;
4321 this.layout_
.removeAllDatasets();
4323 this.attrs_
["pointSize"]=0.5*this.attr_("highlightCircleSize");
4324 for(var i
=1;i
<data
[0].length
;i
++){
4326 for(var j
=0;j
<data
.length
;j
++){
4327 var date
=data
[j
][0];
4328 _217
[j
]=[date
,data
[j
][i
]];
4330 _217
=this.rollingAverage(_217
,this.rollPeriod_
);
4331 var bars
=this.attr_("errorBars")||this.attr_("customBars");
4332 if(this.dateWindow_
){
4333 var low
=this.dateWindow_
[0];
4334 var high
=this.dateWindow_
[1];
4336 for(var k
=0;k
<_217
.length
;k
++){
4337 if(_217
[k
][0]>=low
&&_217
[k
][0]<=high
){
4343 var _219
=this.extremeValues_(_217
);
4346 if(!minY
||_220
<minY
){
4349 if(!maxY
||_221
>maxY
){
4354 for(var j
=0;j
<_217
.length
;j
++){
4355 vals
[j
]=[_217
[j
][0],_217
[j
][1][0],_217
[j
][1][1],_217
[j
][1][2]];
4357 this.layout_
.addDataset(this.attr_("labels")[i
],vals
);
4359 this.layout_
.addDataset(this.attr_("labels")[i
],_217
);
4362 if(this.valueRange_
!=null){
4363 this.addYTicks_(this.valueRange_
[0],this.valueRange_
[1]);
4366 var _224
=maxY
+0.1*span
;
4367 var _225
=minY
-0.1*span
;
4368 if(_225
<0&&minY
>=0){
4371 if(_224
>0&&maxY
<=0){
4374 if(this.attr_("includeZero")){
4382 this.addYTicks_(_225
,_224
);
4385 this.layout_
.evaluateWithError();
4386 this.plotter_
.clear();
4387 this.plotter_
.render();
4388 this.canvas_
.getContext("2d").clearRect(0,0,this.canvas_
.width
,this.canvas_
.height
);
4390 Dygraph
.prototype.rollingAverage
=function(_226
,_227
){
4394 var _227
=Math
.min(_227
,_226
.length
-1);
4396 var _229
=this.attr_("sigma");
4397 if(this.fractions_
){
4401 for(var i
=0;i
<_226
.length
;i
++){
4405 num
-=_226
[i
-_227
][1][0];
4406 den
-=_226
[i
-_227
][1][1];
4408 var date
=_226
[i
][0];
4409 var _232
=den
?num
/den
:0;
4410 if(this.attr_("errorBars")){
4411 if(this.wilsonInterval_
){
4413 var p
=_232
<0?0:_232
,n
=den
;
4414 var pm
=_229
*Math
.sqrt(p
*(1-p
)/n+_229*_229/(4*n
*n
));
4415 var _235
=1+_229
*_229
/den
;
4416 var low
=(p
+_229
*_229
/(2*den)-pm)/_235
;
4417 var high
=(p
+_229
*_229
/(2*den)+pm)/_235
;
4418 _228
[i
]=[date
,[p
*mult
,(p
-low
)*mult
,(high
-p
)*mult
]];
4420 _228
[i
]=[date
,[0,0,0]];
4423 var _236
=den
?_229
*Math
.sqrt(_232
*(1-_232
)/den
):1;
4424 _228
[i
]=[date
,[mult
*_232
,mult
*_236
,mult
*_236
]];
4427 _228
[i
]=[date
,mult
*_232
];
4431 if(this.attr_("customBars")){
4436 for(var i
=0;i
<_226
.length
;i
++){
4437 var data
=_226
[i
][1];
4439 _228
[i
]=[_226
[i
][0],[y
,y
-data
[0],data
[2]-y
]];
4445 var prev
=_226
[i
-_227
];
4451 _228
[i
]=[_226
[i
][0],[1*mid
/_238,1*(mid-low)/_238
,1*(high
-mid
)/_238
]];
4454 var _240
=Math
.min(_227
-1,_226
.length
-2);
4455 if(!this.attr_("errorBars")){
4459 for(var i
=0;i
<_226
.length
;i
++){
4462 for(var j
=Math
.max(0,i
-_227
+1);j
<i
+1;j
++){
4471 _228
[i
]=[_226
[i
][0],sum
/_242
];
4473 _228
[i
]=[_226
[i
][0],null];
4477 for(var i
=0;i
<_226
.length
;i
++){
4481 for(var j
=Math
.max(0,i
-_227
+1);j
<i
+1;j
++){
4482 var y
=_226
[j
][1][0];
4488 _243
+=Math
.pow(_226
[j
][1][1],2);
4491 var _236
=Math
.sqrt(_243
)/_242
;
4492 _228
[i
]=[_226
[i
][0],[sum
/_242
,_229
*_236
,_229
*_236
]];
4494 _228
[i
]=[_226
[i
][0],[null,null,null]];
4502 Dygraph
.dateParser
=function(_244
,self
){
4505 if(_244
.length
==10&&_244
.search("-")!=-1){
4506 _245
=_244
.replace("-","/","g");
4507 while(_245
.search("-")!=-1){
4508 _245
=_245
.replace("-","/");
4513 _245
=_244
.substr(0,4)+"/"+_244.substr(4,2)+"/"+_244
.substr(6,2);
4520 self
.error("Couldn't parse "+_244
+" as a date");
4524 Dygraph
.prototype.detectTypeFromString_
=function(str
){
4526 if(str
.indexOf("-")>=0||str
.indexOf("/")>=0||isNaN(parseFloat(str
))){
4529 if(str
.length
==8&&str
>"19700101"&&str
<"20371231"){
4534 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
4535 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
4536 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
4538 this.attrs_
.xValueFormatter
=function(x
){
4541 this.attrs_
.xValueParser
=function(x
){
4542 return parseFloat(x
);
4544 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
4547 Dygraph
.prototype.parseCSV_
=function(data
){
4549 var _248
=data
.split("\n");
4551 if(this.labelsFromCSV_
){
4553 this.attrs_
.labels
=_248
[0].split(",");
4557 var _252
=this.attr_("labels").length
;
4558 for(var i
=_249
;i
<_248
.length
;i
++){
4563 var _254
=line
.split(",");
4569 this.detectTypeFromString_(_254
[0]);
4570 _250
=this.attr_("xValueParser");
4573 _255
[0]=_250(_254
[0],this);
4574 if(this.fractions_
){
4575 for(var j
=1;j
<_254
.length
;j
++){
4576 var vals
=_254
[j
].split("/");
4577 _255
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1])];
4580 if(this.attr_("errorBars")){
4581 for(var j
=1;j
<_254
.length
;j
+=2){
4582 _255
[(j
+1)/2]=[parseFloat(_254
[j
]),parseFloat(_254
[j
+1])];
4585 if(this.attr_("customBars")){
4586 for(var j
=1;j
<_254
.length
;j
++){
4587 var vals
=_254
[j
].split(";");
4588 _255
[j
]=[parseFloat(vals
[0]),parseFloat(vals
[1]),parseFloat(vals
[2])];
4591 for(var j
=1;j
<_254
.length
;j
++){
4592 _255
[j
]=parseFloat(_254
[j
]);
4598 if(_255
.length
!=_252
){
4599 this.error("Number of columns in line "+i
+" ("+_255
.length
+") does not agree with number of labels ("+_252
+") "+line
);
4604 Dygraph
.prototype.parseArray_
=function(data
){
4606 this.error("Can't plot empty data set");
4609 if(data
[0].length
==0){
4610 this.error("Data set cannot contain an empty row");
4613 if(this.attr_("labels")==null){
4614 this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
4615 this.attrs_
.labels
=["X"];
4616 for(var i
=1;i
<data
[0].length
;i
++){
4617 this.attrs_
.labels
.push("Y"+i
);
4620 if(MochiKit
.Base
.isDateLike(data
[0][0])){
4621 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
4622 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
4623 var _256
=MochiKit
.Base
.clone(data
);
4624 for(var i
=0;i
<data
.length
;i
++){
4625 if(_256
[i
].length
==0){
4626 this.error("Row "<<(1+i
)<<" of data is empty");
4629 if(_256
[i
][0]==null||typeof (_256
[i
][0].getTime
)!="function"){
4630 this.error("x value in row "<<(1+i
)<<" is not a Date");
4633 _256
[i
][0]=_256
[i
][0].getTime();
4637 this.attrs_
.xValueFormatter
=function(x
){
4640 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
4644 Dygraph
.prototype.parseDataTable_
=function(data
){
4645 var cols
=data
.getNumberOfColumns();
4646 var rows
=data
.getNumberOfRows();
4648 for(var i
=0;i
<cols
;i
++){
4649 _259
.push(data
.getColumnLabel(i
));
4651 this.attrs_
.labels
=_259
;
4652 var _260
=data
.getColumnType(0);
4654 this.attrs_
.xValueFormatter
=Dygraph
.dateString_
;
4655 this.attrs_
.xValueParser
=Dygraph
.dateParser
;
4656 this.attrs_
.xTicker
=Dygraph
.dateTicker
;
4659 this.attrs_
.xValueFormatter
=function(x
){
4662 this.attrs_
.xValueParser
=function(x
){
4663 return parseFloat(x
);
4665 this.attrs_
.xTicker
=Dygraph
.numericTicks
;
4667 this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_260
+"')");
4672 for(var i
=0;i
<rows
;i
++){
4674 if(!data
.getValue(i
,0)){
4678 row
.push(data
.getValue(i
,0).getTime());
4680 row
.push(data
.getValue(i
,0));
4682 for(var j
=1;j
<cols
;j
++){
4683 row
.push(data
.getValue(i
,j
));
4689 Dygraph
.prototype.start_
=function(){
4690 if(typeof this.file_
=="function"){
4691 this.loadedEvent_(this.file_());
4693 if(MochiKit
.Base
.isArrayLike(this.file_
)){
4694 this.rawData_
=this.parseArray_(this.file_
);
4695 this.drawGraph_(this.rawData_
);
4697 if(typeof this.file_
=="object"&&typeof this.file_
.getColumnRange
=="function"){
4698 this.rawData_
=this.parseDataTable_(this.file_
);
4699 this.drawGraph_(this.rawData_
);
4701 if(typeof this.file_
=="string"){
4702 if(this.file_
.indexOf("\n")>=0){
4703 this.loadedEvent_(this.file_
);
4705 var req
=new XMLHttpRequest();
4707 req
.onreadystatechange
=function(){
4708 if(req
.readyState
==4){
4709 if(req
.status
==200){
4710 _263
.loadedEvent_(req
.responseText
);
4714 req
.open("GET",this.file_
,true);
4718 this.error("Unknown data format: "+(typeof this.file_
));
4724 Dygraph
.prototype.updateOptions
=function(_264
){
4725 if(_264
.rollPeriod
){
4726 this.rollPeriod_
=_264
.rollPeriod
;
4728 if(_264
.dateWindow
){
4729 this.dateWindow_
=_264
.dateWindow
;
4731 if(_264
.valueRange
){
4732 this.valueRange_
=_264
.valueRange
;
4734 MochiKit
.Base
.update(this.user_attrs_
,_264
);
4735 this.labelsFromCSV_
=(this.attr_("labels")==null);
4736 this.layout_
.updateOptions({"errorBars":this.attr_("errorBars")});
4737 if(_264
["file"]&&_264
["file"]!=this.file_
){
4738 this.file_
=_264
["file"];
4741 this.drawGraph_(this.rawData_
);
4744 Dygraph
.prototype.adjustRoll
=function(_265
){
4745 this.rollPeriod_
=_265
;
4746 this.drawGraph_(this.rawData_
);
4748 Dygraph
.GVizChart
=function(_266
){
4749 this.container
=_266
;
4751 Dygraph
.GVizChart
.prototype.draw
=function(data
,_267
){
4752 this.container
.innerHTML
="";
4753 this.date_graph
=new Dygraph(this.container
,data
,_267
);