1 | /*** |
---|
2 | |
---|
3 | MochiKit.MochiKit 1.3.1 : PACKED VERSION |
---|
4 | |
---|
5 | THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please |
---|
6 | diff against the source tree, not this file. |
---|
7 | |
---|
8 | See <http://mochikit.com/> for documentation, downloads, license, etc. |
---|
9 | |
---|
10 | (c) 2005 Bob Ippolito. All rights Reserved. |
---|
11 | |
---|
12 | ***/ |
---|
13 | |
---|
14 | if(typeof (dojo)!="undefined"){ |
---|
15 | dojo.provide("MochiKit.Base"); |
---|
16 | } |
---|
17 | if(typeof (MochiKit)=="undefined"){ |
---|
18 | MochiKit={}; |
---|
19 | } |
---|
20 | if(typeof (MochiKit.Base)=="undefined"){ |
---|
21 | MochiKit.Base={}; |
---|
22 | } |
---|
23 | MochiKit.Base.VERSION="1.3.1"; |
---|
24 | MochiKit.Base.NAME="MochiKit.Base"; |
---|
25 | MochiKit.Base.update=function(_1,_2){ |
---|
26 | if(_1===null){ |
---|
27 | _1={}; |
---|
28 | } |
---|
29 | for(var i=1;i<arguments.length;i++){ |
---|
30 | var o=arguments[i]; |
---|
31 | if(typeof (o)!="undefined"&&o!==null){ |
---|
32 | for(var k in o){ |
---|
33 | _1[k]=o[k]; |
---|
34 | } |
---|
35 | } |
---|
36 | } |
---|
37 | return _1; |
---|
38 | }; |
---|
39 | MochiKit.Base.update(MochiKit.Base,{__repr__:function(){ |
---|
40 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
41 | },toString:function(){ |
---|
42 | return this.__repr__(); |
---|
43 | },counter:function(n){ |
---|
44 | if(arguments.length===0){ |
---|
45 | n=1; |
---|
46 | } |
---|
47 | return function(){ |
---|
48 | return n++; |
---|
49 | }; |
---|
50 | },clone:function(_7){ |
---|
51 | var me=arguments.callee; |
---|
52 | if(arguments.length==1){ |
---|
53 | me.prototype=_7; |
---|
54 | return new me(); |
---|
55 | } |
---|
56 | },flattenArguments:function(_9){ |
---|
57 | var res=[]; |
---|
58 | var m=MochiKit.Base; |
---|
59 | var _12=m.extend(null,arguments); |
---|
60 | while(_12.length){ |
---|
61 | var o=_12.shift(); |
---|
62 | if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){ |
---|
63 | for(var i=o.length-1;i>=0;i--){ |
---|
64 | _12.unshift(o[i]); |
---|
65 | } |
---|
66 | }else{ |
---|
67 | res.push(o); |
---|
68 | } |
---|
69 | } |
---|
70 | return res; |
---|
71 | },extend:function(_13,obj,_15){ |
---|
72 | if(!_15){ |
---|
73 | _15=0; |
---|
74 | } |
---|
75 | if(obj){ |
---|
76 | var l=obj.length; |
---|
77 | if(typeof (l)!="number"){ |
---|
78 | if(typeof (MochiKit.Iter)!="undefined"){ |
---|
79 | obj=MochiKit.Iter.list(obj); |
---|
80 | l=obj.length; |
---|
81 | }else{ |
---|
82 | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
---|
83 | } |
---|
84 | } |
---|
85 | if(!_13){ |
---|
86 | _13=[]; |
---|
87 | } |
---|
88 | for(var i=_15;i<l;i++){ |
---|
89 | _13.push(obj[i]); |
---|
90 | } |
---|
91 | } |
---|
92 | return _13; |
---|
93 | },updatetree:function(_17,obj){ |
---|
94 | if(_17===null){ |
---|
95 | _17={}; |
---|
96 | } |
---|
97 | for(var i=1;i<arguments.length;i++){ |
---|
98 | var o=arguments[i]; |
---|
99 | if(typeof (o)!="undefined"&&o!==null){ |
---|
100 | for(var k in o){ |
---|
101 | var v=o[k]; |
---|
102 | if(typeof (_17[k])=="object"&&typeof (v)=="object"){ |
---|
103 | arguments.callee(_17[k],v); |
---|
104 | }else{ |
---|
105 | _17[k]=v; |
---|
106 | } |
---|
107 | } |
---|
108 | } |
---|
109 | } |
---|
110 | return _17; |
---|
111 | },setdefault:function(_19,obj){ |
---|
112 | if(_19===null){ |
---|
113 | _19={}; |
---|
114 | } |
---|
115 | for(var i=1;i<arguments.length;i++){ |
---|
116 | var o=arguments[i]; |
---|
117 | for(var k in o){ |
---|
118 | if(!(k in _19)){ |
---|
119 | _19[k]=o[k]; |
---|
120 | } |
---|
121 | } |
---|
122 | } |
---|
123 | return _19; |
---|
124 | },keys:function(obj){ |
---|
125 | var _20=[]; |
---|
126 | for(var _21 in obj){ |
---|
127 | _20.push(_21); |
---|
128 | } |
---|
129 | return _20; |
---|
130 | },items:function(obj){ |
---|
131 | var _22=[]; |
---|
132 | var e; |
---|
133 | for(var _24 in obj){ |
---|
134 | var v; |
---|
135 | try{ |
---|
136 | v=obj[_24]; |
---|
137 | } |
---|
138 | catch(e){ |
---|
139 | continue; |
---|
140 | } |
---|
141 | _22.push([_24,v]); |
---|
142 | } |
---|
143 | return _22; |
---|
144 | },_newNamedError:function(_25,_26,_27){ |
---|
145 | _27.prototype=new MochiKit.Base.NamedError(_25.NAME+"."+_26); |
---|
146 | _25[_26]=_27; |
---|
147 | },operator:{truth:function(a){ |
---|
148 | return !!a; |
---|
149 | },lognot:function(a){ |
---|
150 | return !a; |
---|
151 | },identity:function(a){ |
---|
152 | return a; |
---|
153 | },not:function(a){ |
---|
154 | return ~a; |
---|
155 | },neg:function(a){ |
---|
156 | return -a; |
---|
157 | },add:function(a,b){ |
---|
158 | return a+b; |
---|
159 | },sub:function(a,b){ |
---|
160 | return a-b; |
---|
161 | },div:function(a,b){ |
---|
162 | return a/b; |
---|
163 | },mod:function(a,b){ |
---|
164 | return a%b; |
---|
165 | },mul:function(a,b){ |
---|
166 | return a*b; |
---|
167 | },and:function(a,b){ |
---|
168 | return a&b; |
---|
169 | },or:function(a,b){ |
---|
170 | return a|b; |
---|
171 | },xor:function(a,b){ |
---|
172 | return a^b; |
---|
173 | },lshift:function(a,b){ |
---|
174 | return a<<b; |
---|
175 | },rshift:function(a,b){ |
---|
176 | return a>>b; |
---|
177 | },zrshift:function(a,b){ |
---|
178 | return a>>>b; |
---|
179 | },eq:function(a,b){ |
---|
180 | return a==b; |
---|
181 | },ne:function(a,b){ |
---|
182 | return a!=b; |
---|
183 | },gt:function(a,b){ |
---|
184 | return a>b; |
---|
185 | },ge:function(a,b){ |
---|
186 | return a>=b; |
---|
187 | },lt:function(a,b){ |
---|
188 | return a<b; |
---|
189 | },le:function(a,b){ |
---|
190 | return a<=b; |
---|
191 | },ceq:function(a,b){ |
---|
192 | return MochiKit.Base.compare(a,b)===0; |
---|
193 | },cne:function(a,b){ |
---|
194 | return MochiKit.Base.compare(a,b)!==0; |
---|
195 | },cgt:function(a,b){ |
---|
196 | return MochiKit.Base.compare(a,b)==1; |
---|
197 | },cge:function(a,b){ |
---|
198 | return MochiKit.Base.compare(a,b)!=-1; |
---|
199 | },clt:function(a,b){ |
---|
200 | return MochiKit.Base.compare(a,b)==-1; |
---|
201 | },cle:function(a,b){ |
---|
202 | return MochiKit.Base.compare(a,b)!=1; |
---|
203 | },logand:function(a,b){ |
---|
204 | return a&&b; |
---|
205 | },logor:function(a,b){ |
---|
206 | return a||b; |
---|
207 | },contains:function(a,b){ |
---|
208 | return b in a; |
---|
209 | }},forwardCall:function(_30){ |
---|
210 | return function(){ |
---|
211 | return this[_30].apply(this,arguments); |
---|
212 | }; |
---|
213 | },itemgetter:function(_31){ |
---|
214 | return function(arg){ |
---|
215 | return arg[_31]; |
---|
216 | }; |
---|
217 | },typeMatcher:function(){ |
---|
218 | var _33={}; |
---|
219 | for(var i=0;i<arguments.length;i++){ |
---|
220 | var typ=arguments[i]; |
---|
221 | _33[typ]=typ; |
---|
222 | } |
---|
223 | return function(){ |
---|
224 | for(var i=0;i<arguments.length;i++){ |
---|
225 | if(!(typeof (arguments[i]) in _33)){ |
---|
226 | return false; |
---|
227 | } |
---|
228 | } |
---|
229 | return true; |
---|
230 | }; |
---|
231 | },isNull:function(){ |
---|
232 | for(var i=0;i<arguments.length;i++){ |
---|
233 | if(arguments[i]!==null){ |
---|
234 | return false; |
---|
235 | } |
---|
236 | } |
---|
237 | return true; |
---|
238 | },isUndefinedOrNull:function(){ |
---|
239 | for(var i=0;i<arguments.length;i++){ |
---|
240 | var o=arguments[i]; |
---|
241 | if(!(typeof (o)=="undefined"||o===null)){ |
---|
242 | return false; |
---|
243 | } |
---|
244 | } |
---|
245 | return true; |
---|
246 | },isEmpty:function(obj){ |
---|
247 | return !MochiKit.Base.isNotEmpty.apply(this,arguments); |
---|
248 | },isNotEmpty:function(obj){ |
---|
249 | for(var i=0;i<arguments.length;i++){ |
---|
250 | var o=arguments[i]; |
---|
251 | if(!(o&&o.length)){ |
---|
252 | return false; |
---|
253 | } |
---|
254 | } |
---|
255 | return true; |
---|
256 | },isArrayLike:function(){ |
---|
257 | for(var i=0;i<arguments.length;i++){ |
---|
258 | var o=arguments[i]; |
---|
259 | var typ=typeof (o); |
---|
260 | if((typ!="object"&&!(typ=="function"&&typeof (o.item)=="function"))||o===null||typeof (o.length)!="number"){ |
---|
261 | return false; |
---|
262 | } |
---|
263 | } |
---|
264 | return true; |
---|
265 | },isDateLike:function(){ |
---|
266 | for(var i=0;i<arguments.length;i++){ |
---|
267 | var o=arguments[i]; |
---|
268 | if(typeof (o)!="object"||o===null||typeof (o.getTime)!="function"){ |
---|
269 | return false; |
---|
270 | } |
---|
271 | } |
---|
272 | return true; |
---|
273 | },xmap:function(fn){ |
---|
274 | if(fn===null){ |
---|
275 | return MochiKit.Base.extend(null,arguments,1); |
---|
276 | } |
---|
277 | var _36=[]; |
---|
278 | for(var i=1;i<arguments.length;i++){ |
---|
279 | _36.push(fn(arguments[i])); |
---|
280 | } |
---|
281 | return _36; |
---|
282 | },map:function(fn,lst){ |
---|
283 | var m=MochiKit.Base; |
---|
284 | var itr=MochiKit.Iter; |
---|
285 | var _39=m.isArrayLike; |
---|
286 | if(arguments.length<=2){ |
---|
287 | if(!_39(lst)){ |
---|
288 | if(itr){ |
---|
289 | lst=itr.list(lst); |
---|
290 | if(fn===null){ |
---|
291 | return lst; |
---|
292 | } |
---|
293 | }else{ |
---|
294 | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
---|
295 | } |
---|
296 | } |
---|
297 | if(fn===null){ |
---|
298 | return m.extend(null,lst); |
---|
299 | } |
---|
300 | var _40=[]; |
---|
301 | for(var i=0;i<lst.length;i++){ |
---|
302 | _40.push(fn(lst[i])); |
---|
303 | } |
---|
304 | return _40; |
---|
305 | }else{ |
---|
306 | if(fn===null){ |
---|
307 | fn=Array; |
---|
308 | } |
---|
309 | var _41=null; |
---|
310 | for(i=1;i<arguments.length;i++){ |
---|
311 | if(!_39(arguments[i])){ |
---|
312 | if(itr){ |
---|
313 | return itr.list(itr.imap.apply(null,arguments)); |
---|
314 | }else{ |
---|
315 | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
---|
316 | } |
---|
317 | } |
---|
318 | var l=arguments[i].length; |
---|
319 | if(_41===null||_41>l){ |
---|
320 | _41=l; |
---|
321 | } |
---|
322 | } |
---|
323 | _40=[]; |
---|
324 | for(i=0;i<_41;i++){ |
---|
325 | var _42=[]; |
---|
326 | for(var j=1;j<arguments.length;j++){ |
---|
327 | _42.push(arguments[j][i]); |
---|
328 | } |
---|
329 | _40.push(fn.apply(this,_42)); |
---|
330 | } |
---|
331 | return _40; |
---|
332 | } |
---|
333 | },xfilter:function(fn){ |
---|
334 | var _44=[]; |
---|
335 | if(fn===null){ |
---|
336 | fn=MochiKit.Base.operator.truth; |
---|
337 | } |
---|
338 | for(var i=1;i<arguments.length;i++){ |
---|
339 | var o=arguments[i]; |
---|
340 | if(fn(o)){ |
---|
341 | _44.push(o); |
---|
342 | } |
---|
343 | } |
---|
344 | return _44; |
---|
345 | },filter:function(fn,lst,_45){ |
---|
346 | var _46=[]; |
---|
347 | var m=MochiKit.Base; |
---|
348 | if(!m.isArrayLike(lst)){ |
---|
349 | if(MochiKit.Iter){ |
---|
350 | lst=MochiKit.Iter.list(lst); |
---|
351 | }else{ |
---|
352 | throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); |
---|
353 | } |
---|
354 | } |
---|
355 | if(fn===null){ |
---|
356 | fn=m.operator.truth; |
---|
357 | } |
---|
358 | if(typeof (Array.prototype.filter)=="function"){ |
---|
359 | return Array.prototype.filter.call(lst,fn,_45); |
---|
360 | }else{ |
---|
361 | if(typeof (_45)=="undefined"||_45===null){ |
---|
362 | for(var i=0;i<lst.length;i++){ |
---|
363 | var o=lst[i]; |
---|
364 | if(fn(o)){ |
---|
365 | _46.push(o); |
---|
366 | } |
---|
367 | } |
---|
368 | }else{ |
---|
369 | for(i=0;i<lst.length;i++){ |
---|
370 | o=lst[i]; |
---|
371 | if(fn.call(_45,o)){ |
---|
372 | _46.push(o); |
---|
373 | } |
---|
374 | } |
---|
375 | } |
---|
376 | } |
---|
377 | return _46; |
---|
378 | },_wrapDumbFunction:function(_47){ |
---|
379 | return function(){ |
---|
380 | switch(arguments.length){ |
---|
381 | case 0: |
---|
382 | return _47(); |
---|
383 | case 1: |
---|
384 | return _47(arguments[0]); |
---|
385 | case 2: |
---|
386 | return _47(arguments[0],arguments[1]); |
---|
387 | case 3: |
---|
388 | return _47(arguments[0],arguments[1],arguments[2]); |
---|
389 | } |
---|
390 | var _48=[]; |
---|
391 | for(var i=0;i<arguments.length;i++){ |
---|
392 | _48.push("arguments["+i+"]"); |
---|
393 | } |
---|
394 | return eval("(func("+_48.join(",")+"))"); |
---|
395 | }; |
---|
396 | },method:function(_49,_50){ |
---|
397 | var m=MochiKit.Base; |
---|
398 | return m.bind.apply(this,m.extend([_50,_49],arguments,2)); |
---|
399 | },bind:function(_51,_52){ |
---|
400 | if(typeof (_51)=="string"){ |
---|
401 | _51=_52[_51]; |
---|
402 | } |
---|
403 | var _53=_51.im_func; |
---|
404 | var _54=_51.im_preargs; |
---|
405 | var _55=_51.im_self; |
---|
406 | var m=MochiKit.Base; |
---|
407 | if(typeof (_51)=="function"&&typeof (_51.apply)=="undefined"){ |
---|
408 | _51=m._wrapDumbFunction(_51); |
---|
409 | } |
---|
410 | if(typeof (_53)!="function"){ |
---|
411 | _53=_51; |
---|
412 | } |
---|
413 | if(typeof (_52)!="undefined"){ |
---|
414 | _55=_52; |
---|
415 | } |
---|
416 | if(typeof (_54)=="undefined"){ |
---|
417 | _54=[]; |
---|
418 | }else{ |
---|
419 | _54=_54.slice(); |
---|
420 | } |
---|
421 | m.extend(_54,arguments,2); |
---|
422 | var _56=function(){ |
---|
423 | var _57=arguments; |
---|
424 | var me=arguments.callee; |
---|
425 | if(me.im_preargs.length>0){ |
---|
426 | _57=m.concat(me.im_preargs,_57); |
---|
427 | } |
---|
428 | var _52=me.im_self; |
---|
429 | if(!_52){ |
---|
430 | _52=this; |
---|
431 | } |
---|
432 | return me.im_func.apply(_52,_57); |
---|
433 | }; |
---|
434 | _56.im_self=_55; |
---|
435 | _56.im_func=_53; |
---|
436 | _56.im_preargs=_54; |
---|
437 | return _56; |
---|
438 | },bindMethods:function(_58){ |
---|
439 | var _59=MochiKit.Base.bind; |
---|
440 | for(var k in _58){ |
---|
441 | var _60=_58[k]; |
---|
442 | if(typeof (_60)=="function"){ |
---|
443 | _58[k]=_59(_60,_58); |
---|
444 | } |
---|
445 | } |
---|
446 | },registerComparator:function(_61,_62,_63,_64){ |
---|
447 | MochiKit.Base.comparatorRegistry.register(_61,_62,_63,_64); |
---|
448 | },_primitives:{"boolean":true,"string":true,"number":true},compare:function(a,b){ |
---|
449 | if(a==b){ |
---|
450 | return 0; |
---|
451 | } |
---|
452 | var _65=(typeof (a)=="undefined"||a===null); |
---|
453 | var _66=(typeof (b)=="undefined"||b===null); |
---|
454 | if(_65&&_66){ |
---|
455 | return 0; |
---|
456 | }else{ |
---|
457 | if(_65){ |
---|
458 | return -1; |
---|
459 | }else{ |
---|
460 | if(_66){ |
---|
461 | return 1; |
---|
462 | } |
---|
463 | } |
---|
464 | } |
---|
465 | var m=MochiKit.Base; |
---|
466 | var _67=m._primitives; |
---|
467 | if(!(typeof (a) in _67&&typeof (b) in _67)){ |
---|
468 | try{ |
---|
469 | return m.comparatorRegistry.match(a,b); |
---|
470 | } |
---|
471 | catch(e){ |
---|
472 | if(e!=m.NotFound){ |
---|
473 | throw e; |
---|
474 | } |
---|
475 | } |
---|
476 | } |
---|
477 | if(a<b){ |
---|
478 | return -1; |
---|
479 | }else{ |
---|
480 | if(a>b){ |
---|
481 | return 1; |
---|
482 | } |
---|
483 | } |
---|
484 | var _68=m.repr; |
---|
485 | throw new TypeError(_68(a)+" and "+_68(b)+" can not be compared"); |
---|
486 | },compareDateLike:function(a,b){ |
---|
487 | return MochiKit.Base.compare(a.getTime(),b.getTime()); |
---|
488 | },compareArrayLike:function(a,b){ |
---|
489 | var _69=MochiKit.Base.compare; |
---|
490 | var _70=a.length; |
---|
491 | var _71=0; |
---|
492 | if(_70>b.length){ |
---|
493 | _71=1; |
---|
494 | _70=b.length; |
---|
495 | }else{ |
---|
496 | if(_70<b.length){ |
---|
497 | _71=-1; |
---|
498 | } |
---|
499 | } |
---|
500 | for(var i=0;i<_70;i++){ |
---|
501 | var cmp=_69(a[i],b[i]); |
---|
502 | if(cmp){ |
---|
503 | return cmp; |
---|
504 | } |
---|
505 | } |
---|
506 | return _71; |
---|
507 | },registerRepr:function(_73,_74,_75,_76){ |
---|
508 | MochiKit.Base.reprRegistry.register(_73,_74,_75,_76); |
---|
509 | },repr:function(o){ |
---|
510 | if(typeof (o)=="undefined"){ |
---|
511 | return "undefined"; |
---|
512 | }else{ |
---|
513 | if(o===null){ |
---|
514 | return "null"; |
---|
515 | } |
---|
516 | } |
---|
517 | try{ |
---|
518 | if(typeof (o.__repr__)=="function"){ |
---|
519 | return o.__repr__(); |
---|
520 | }else{ |
---|
521 | if(typeof (o.repr)=="function"&&o.repr!=arguments.callee){ |
---|
522 | return o.repr(); |
---|
523 | } |
---|
524 | } |
---|
525 | return MochiKit.Base.reprRegistry.match(o); |
---|
526 | } |
---|
527 | catch(e){ |
---|
528 | if(typeof (o.NAME)=="string"&&(o.toString==Function.prototype.toString||o.toString==Object.prototype.toString)){ |
---|
529 | return o.NAME; |
---|
530 | } |
---|
531 | } |
---|
532 | try{ |
---|
533 | var _77=(o+""); |
---|
534 | } |
---|
535 | catch(e){ |
---|
536 | return "["+typeof (o)+"]"; |
---|
537 | } |
---|
538 | if(typeof (o)=="function"){ |
---|
539 | o=_77.replace(/^\s+/,""); |
---|
540 | var idx=o.indexOf("{"); |
---|
541 | if(idx!=-1){ |
---|
542 | o=o.substr(0,idx)+"{...}"; |
---|
543 | } |
---|
544 | } |
---|
545 | return _77; |
---|
546 | },reprArrayLike:function(o){ |
---|
547 | var m=MochiKit.Base; |
---|
548 | return "["+m.map(m.repr,o).join(", ")+"]"; |
---|
549 | },reprString:function(o){ |
---|
550 | 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"); |
---|
551 | },reprNumber:function(o){ |
---|
552 | return o+""; |
---|
553 | },registerJSON:function(_79,_80,_81,_82){ |
---|
554 | MochiKit.Base.jsonRegistry.register(_79,_80,_81,_82); |
---|
555 | },evalJSON:function(){ |
---|
556 | return eval("("+arguments[0]+")"); |
---|
557 | },serializeJSON:function(o){ |
---|
558 | var _83=typeof (o); |
---|
559 | if(_83=="undefined"){ |
---|
560 | return "undefined"; |
---|
561 | }else{ |
---|
562 | if(_83=="number"||_83=="boolean"){ |
---|
563 | return o+""; |
---|
564 | }else{ |
---|
565 | if(o===null){ |
---|
566 | return "null"; |
---|
567 | } |
---|
568 | } |
---|
569 | } |
---|
570 | var m=MochiKit.Base; |
---|
571 | var _84=m.reprString; |
---|
572 | if(_83=="string"){ |
---|
573 | return _84(o); |
---|
574 | } |
---|
575 | var me=arguments.callee; |
---|
576 | var _85; |
---|
577 | if(typeof (o.__json__)=="function"){ |
---|
578 | _85=o.__json__(); |
---|
579 | if(o!==_85){ |
---|
580 | return me(_85); |
---|
581 | } |
---|
582 | } |
---|
583 | if(typeof (o.json)=="function"){ |
---|
584 | _85=o.json(); |
---|
585 | if(o!==_85){ |
---|
586 | return me(_85); |
---|
587 | } |
---|
588 | } |
---|
589 | if(_83!="function"&&typeof (o.length)=="number"){ |
---|
590 | var res=[]; |
---|
591 | for(var i=0;i<o.length;i++){ |
---|
592 | var val=me(o[i]); |
---|
593 | if(typeof (val)!="string"){ |
---|
594 | val="undefined"; |
---|
595 | } |
---|
596 | res.push(val); |
---|
597 | } |
---|
598 | return "["+res.join(", ")+"]"; |
---|
599 | } |
---|
600 | try{ |
---|
601 | _85=m.jsonRegistry.match(o); |
---|
602 | return me(_85); |
---|
603 | } |
---|
604 | catch(e){ |
---|
605 | if(e!=m.NotFound){ |
---|
606 | throw e; |
---|
607 | } |
---|
608 | } |
---|
609 | if(_83=="function"){ |
---|
610 | return null; |
---|
611 | } |
---|
612 | res=[]; |
---|
613 | for(var k in o){ |
---|
614 | var _87; |
---|
615 | if(typeof (k)=="number"){ |
---|
616 | _87="\""+k+"\""; |
---|
617 | }else{ |
---|
618 | if(typeof (k)=="string"){ |
---|
619 | _87=_84(k); |
---|
620 | }else{ |
---|
621 | continue; |
---|
622 | } |
---|
623 | } |
---|
624 | val=me(o[k]); |
---|
625 | if(typeof (val)!="string"){ |
---|
626 | continue; |
---|
627 | } |
---|
628 | res.push(_87+":"+val); |
---|
629 | } |
---|
630 | return "{"+res.join(", ")+"}"; |
---|
631 | },objEqual:function(a,b){ |
---|
632 | return (MochiKit.Base.compare(a,b)===0); |
---|
633 | },arrayEqual:function(_88,arr){ |
---|
634 | if(_88.length!=arr.length){ |
---|
635 | return false; |
---|
636 | } |
---|
637 | return (MochiKit.Base.compare(_88,arr)===0); |
---|
638 | },concat:function(){ |
---|
639 | var _90=[]; |
---|
640 | var _91=MochiKit.Base.extend; |
---|
641 | for(var i=0;i<arguments.length;i++){ |
---|
642 | _91(_90,arguments[i]); |
---|
643 | } |
---|
644 | return _90; |
---|
645 | },keyComparator:function(key){ |
---|
646 | var m=MochiKit.Base; |
---|
647 | var _93=m.compare; |
---|
648 | if(arguments.length==1){ |
---|
649 | return function(a,b){ |
---|
650 | return _93(a[key],b[key]); |
---|
651 | }; |
---|
652 | } |
---|
653 | var _94=m.extend(null,arguments); |
---|
654 | return function(a,b){ |
---|
655 | var _95=0; |
---|
656 | for(var i=0;(_95===0)&&(i<_94.length);i++){ |
---|
657 | var key=_94[i]; |
---|
658 | _95=_93(a[key],b[key]); |
---|
659 | } |
---|
660 | return _95; |
---|
661 | }; |
---|
662 | },reverseKeyComparator:function(key){ |
---|
663 | var _96=MochiKit.Base.keyComparator.apply(this,arguments); |
---|
664 | return function(a,b){ |
---|
665 | return _96(b,a); |
---|
666 | }; |
---|
667 | },partial:function(_97){ |
---|
668 | var m=MochiKit.Base; |
---|
669 | return m.bind.apply(this,m.extend([_97,undefined],arguments,1)); |
---|
670 | },listMinMax:function(_98,lst){ |
---|
671 | if(lst.length===0){ |
---|
672 | return null; |
---|
673 | } |
---|
674 | var cur=lst[0]; |
---|
675 | var _100=MochiKit.Base.compare; |
---|
676 | for(var i=1;i<lst.length;i++){ |
---|
677 | var o=lst[i]; |
---|
678 | if(_100(o,cur)==_98){ |
---|
679 | cur=o; |
---|
680 | } |
---|
681 | } |
---|
682 | return cur; |
---|
683 | },objMax:function(){ |
---|
684 | return MochiKit.Base.listMinMax(1,arguments); |
---|
685 | },objMin:function(){ |
---|
686 | return MochiKit.Base.listMinMax(-1,arguments); |
---|
687 | },findIdentical:function(lst,_101,_102,end){ |
---|
688 | if(typeof (end)=="undefined"||end===null){ |
---|
689 | end=lst.length; |
---|
690 | } |
---|
691 | for(var i=(_102||0);i<end;i++){ |
---|
692 | if(lst[i]===_101){ |
---|
693 | return i; |
---|
694 | } |
---|
695 | } |
---|
696 | return -1; |
---|
697 | },findValue:function(lst,_104,_105,end){ |
---|
698 | if(typeof (end)=="undefined"||end===null){ |
---|
699 | end=lst.length; |
---|
700 | } |
---|
701 | var cmp=MochiKit.Base.compare; |
---|
702 | for(var i=(_105||0);i<end;i++){ |
---|
703 | if(cmp(lst[i],_104)===0){ |
---|
704 | return i; |
---|
705 | } |
---|
706 | } |
---|
707 | return -1; |
---|
708 | },nodeWalk:function(node,_107){ |
---|
709 | var _108=[node]; |
---|
710 | var _109=MochiKit.Base.extend; |
---|
711 | while(_108.length){ |
---|
712 | var res=_107(_108.shift()); |
---|
713 | if(res){ |
---|
714 | _109(_108,res); |
---|
715 | } |
---|
716 | } |
---|
717 | },nameFunctions:function(_110){ |
---|
718 | var base=_110.NAME; |
---|
719 | if(typeof (base)=="undefined"){ |
---|
720 | base=""; |
---|
721 | }else{ |
---|
722 | base=base+"."; |
---|
723 | } |
---|
724 | for(var name in _110){ |
---|
725 | var o=_110[name]; |
---|
726 | if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){ |
---|
727 | try{ |
---|
728 | o.NAME=base+name; |
---|
729 | } |
---|
730 | catch(e){ |
---|
731 | } |
---|
732 | } |
---|
733 | } |
---|
734 | },queryString:function(_113,_114){ |
---|
735 | if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_113)=="string"||(typeof (_113.nodeType)!="undefined"&&_113.nodeType>0))){ |
---|
736 | var kv=MochiKit.DOM.formContents(_113); |
---|
737 | _113=kv[0]; |
---|
738 | _114=kv[1]; |
---|
739 | }else{ |
---|
740 | if(arguments.length==1){ |
---|
741 | var o=_113; |
---|
742 | _113=[]; |
---|
743 | _114=[]; |
---|
744 | for(var k in o){ |
---|
745 | var v=o[k]; |
---|
746 | if(typeof (v)!="function"){ |
---|
747 | _113.push(k); |
---|
748 | _114.push(v); |
---|
749 | } |
---|
750 | } |
---|
751 | } |
---|
752 | } |
---|
753 | var rval=[]; |
---|
754 | var len=Math.min(_113.length,_114.length); |
---|
755 | var _118=MochiKit.Base.urlEncode; |
---|
756 | for(var i=0;i<len;i++){ |
---|
757 | v=_114[i]; |
---|
758 | if(typeof (v)!="undefined"&&v!==null){ |
---|
759 | rval.push(_118(_113[i])+"="+_118(v)); |
---|
760 | } |
---|
761 | } |
---|
762 | return rval.join("&"); |
---|
763 | },parseQueryString:function(_119,_120){ |
---|
764 | var _121=_119.replace(/\+/g,"%20").split("&"); |
---|
765 | var o={}; |
---|
766 | var _122; |
---|
767 | if(typeof (decodeURIComponent)!="undefined"){ |
---|
768 | _122=decodeURIComponent; |
---|
769 | }else{ |
---|
770 | _122=unescape; |
---|
771 | } |
---|
772 | if(_120){ |
---|
773 | for(var i=0;i<_121.length;i++){ |
---|
774 | var pair=_121[i].split("="); |
---|
775 | var name=_122(pair[0]); |
---|
776 | var arr=o[name]; |
---|
777 | if(!(arr instanceof Array)){ |
---|
778 | arr=[]; |
---|
779 | o[name]=arr; |
---|
780 | } |
---|
781 | arr.push(_122(pair[1])); |
---|
782 | } |
---|
783 | }else{ |
---|
784 | for(i=0;i<_121.length;i++){ |
---|
785 | pair=_121[i].split("="); |
---|
786 | o[_122(pair[0])]=_122(pair[1]); |
---|
787 | } |
---|
788 | } |
---|
789 | return o; |
---|
790 | }}); |
---|
791 | MochiKit.Base.AdapterRegistry=function(){ |
---|
792 | this.pairs=[]; |
---|
793 | }; |
---|
794 | MochiKit.Base.AdapterRegistry.prototype={register:function(name,_124,wrap,_126){ |
---|
795 | if(_126){ |
---|
796 | this.pairs.unshift([name,_124,wrap]); |
---|
797 | }else{ |
---|
798 | this.pairs.push([name,_124,wrap]); |
---|
799 | } |
---|
800 | },match:function(){ |
---|
801 | for(var i=0;i<this.pairs.length;i++){ |
---|
802 | var pair=this.pairs[i]; |
---|
803 | if(pair[1].apply(this,arguments)){ |
---|
804 | return pair[2].apply(this,arguments); |
---|
805 | } |
---|
806 | } |
---|
807 | throw MochiKit.Base.NotFound; |
---|
808 | },unregister:function(name){ |
---|
809 | for(var i=0;i<this.pairs.length;i++){ |
---|
810 | var pair=this.pairs[i]; |
---|
811 | if(pair[0]==name){ |
---|
812 | this.pairs.splice(i,1); |
---|
813 | return true; |
---|
814 | } |
---|
815 | } |
---|
816 | return false; |
---|
817 | }}; |
---|
818 | MochiKit.Base.EXPORT=["counter","clone","extend","update","updatetree","setdefault","keys","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isEmpty","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","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"]; |
---|
819 | MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"]; |
---|
820 | MochiKit.Base._exportSymbols=function(_127,_128){ |
---|
821 | if(typeof (MochiKit.__export__)=="undefined"){ |
---|
822 | MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")); |
---|
823 | } |
---|
824 | if(!MochiKit.__export__){ |
---|
825 | return; |
---|
826 | } |
---|
827 | var all=_128.EXPORT_TAGS[":all"]; |
---|
828 | for(var i=0;i<all.length;i++){ |
---|
829 | _127[all[i]]=_128[all[i]]; |
---|
830 | } |
---|
831 | }; |
---|
832 | MochiKit.Base.__new__=function(){ |
---|
833 | var m=this; |
---|
834 | m.forward=m.forwardCall; |
---|
835 | m.find=m.findValue; |
---|
836 | if(typeof (encodeURIComponent)!="undefined"){ |
---|
837 | m.urlEncode=function(_130){ |
---|
838 | return encodeURIComponent(_130).replace(/\'/g,"%27"); |
---|
839 | }; |
---|
840 | }else{ |
---|
841 | m.urlEncode=function(_131){ |
---|
842 | return escape(_131).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27"); |
---|
843 | }; |
---|
844 | } |
---|
845 | m.NamedError=function(name){ |
---|
846 | this.message=name; |
---|
847 | this.name=name; |
---|
848 | }; |
---|
849 | m.NamedError.prototype=new Error(); |
---|
850 | m.update(m.NamedError.prototype,{repr:function(){ |
---|
851 | if(this.message&&this.message!=this.name){ |
---|
852 | return this.name+"("+m.repr(this.message)+")"; |
---|
853 | }else{ |
---|
854 | return this.name+"()"; |
---|
855 | } |
---|
856 | },toString:m.forwardCall("repr")}); |
---|
857 | m.NotFound=new m.NamedError("MochiKit.Base.NotFound"); |
---|
858 | m.listMax=m.partial(m.listMinMax,1); |
---|
859 | m.listMin=m.partial(m.listMinMax,-1); |
---|
860 | m.isCallable=m.typeMatcher("function"); |
---|
861 | m.isUndefined=m.typeMatcher("undefined"); |
---|
862 | m.merge=m.partial(m.update,null); |
---|
863 | m.zip=m.partial(m.map,null); |
---|
864 | m.comparatorRegistry=new m.AdapterRegistry(); |
---|
865 | m.registerComparator("dateLike",m.isDateLike,m.compareDateLike); |
---|
866 | m.registerComparator("arrayLike",m.isArrayLike,m.compareArrayLike); |
---|
867 | m.reprRegistry=new m.AdapterRegistry(); |
---|
868 | m.registerRepr("arrayLike",m.isArrayLike,m.reprArrayLike); |
---|
869 | m.registerRepr("string",m.typeMatcher("string"),m.reprString); |
---|
870 | m.registerRepr("numbers",m.typeMatcher("number","boolean"),m.reprNumber); |
---|
871 | m.jsonRegistry=new m.AdapterRegistry(); |
---|
872 | var all=m.concat(m.EXPORT,m.EXPORT_OK); |
---|
873 | m.EXPORT_TAGS={":common":m.concat(m.EXPORT_OK),":all":all}; |
---|
874 | m.nameFunctions(this); |
---|
875 | }; |
---|
876 | MochiKit.Base.__new__(); |
---|
877 | if(!MochiKit.__compat__){ |
---|
878 | compare=MochiKit.Base.compare; |
---|
879 | } |
---|
880 | MochiKit.Base._exportSymbols(this,MochiKit.Base); |
---|
881 | if(typeof (dojo)!="undefined"){ |
---|
882 | dojo.provide("MochiKit.Iter"); |
---|
883 | dojo.require("MochiKit.Base"); |
---|
884 | } |
---|
885 | if(typeof (JSAN)!="undefined"){ |
---|
886 | JSAN.use("MochiKit.Base",[]); |
---|
887 | } |
---|
888 | try{ |
---|
889 | if(typeof (MochiKit.Base)=="undefined"){ |
---|
890 | throw ""; |
---|
891 | } |
---|
892 | } |
---|
893 | catch(e){ |
---|
894 | throw "MochiKit.Iter depends on MochiKit.Base!"; |
---|
895 | } |
---|
896 | if(typeof (MochiKit.Iter)=="undefined"){ |
---|
897 | MochiKit.Iter={}; |
---|
898 | } |
---|
899 | MochiKit.Iter.NAME="MochiKit.Iter"; |
---|
900 | MochiKit.Iter.VERSION="1.3.1"; |
---|
901 | MochiKit.Base.update(MochiKit.Iter,{__repr__:function(){ |
---|
902 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
903 | },toString:function(){ |
---|
904 | return this.__repr__(); |
---|
905 | },registerIteratorFactory:function(name,_132,_133,_134){ |
---|
906 | MochiKit.Iter.iteratorRegistry.register(name,_132,_133,_134); |
---|
907 | },iter:function(_135,_136){ |
---|
908 | var self=MochiKit.Iter; |
---|
909 | if(arguments.length==2){ |
---|
910 | return self.takewhile(function(a){ |
---|
911 | return a!=_136; |
---|
912 | },_135); |
---|
913 | } |
---|
914 | if(typeof (_135.next)=="function"){ |
---|
915 | return _135; |
---|
916 | }else{ |
---|
917 | if(typeof (_135.iter)=="function"){ |
---|
918 | return _135.iter(); |
---|
919 | } |
---|
920 | } |
---|
921 | try{ |
---|
922 | return self.iteratorRegistry.match(_135); |
---|
923 | } |
---|
924 | catch(e){ |
---|
925 | var m=MochiKit.Base; |
---|
926 | if(e==m.NotFound){ |
---|
927 | e=new TypeError(typeof (_135)+": "+m.repr(_135)+" is not iterable"); |
---|
928 | } |
---|
929 | throw e; |
---|
930 | } |
---|
931 | },count:function(n){ |
---|
932 | if(!n){ |
---|
933 | n=0; |
---|
934 | } |
---|
935 | var m=MochiKit.Base; |
---|
936 | return {repr:function(){ |
---|
937 | return "count("+n+")"; |
---|
938 | },toString:m.forwardCall("repr"),next:m.counter(n)}; |
---|
939 | },cycle:function(p){ |
---|
940 | var self=MochiKit.Iter; |
---|
941 | var m=MochiKit.Base; |
---|
942 | var lst=[]; |
---|
943 | var _139=self.iter(p); |
---|
944 | return {repr:function(){ |
---|
945 | return "cycle(...)"; |
---|
946 | },toString:m.forwardCall("repr"),next:function(){ |
---|
947 | try{ |
---|
948 | var rval=_139.next(); |
---|
949 | lst.push(rval); |
---|
950 | return rval; |
---|
951 | } |
---|
952 | catch(e){ |
---|
953 | if(e!=self.StopIteration){ |
---|
954 | throw e; |
---|
955 | } |
---|
956 | if(lst.length===0){ |
---|
957 | this.next=function(){ |
---|
958 | throw self.StopIteration; |
---|
959 | }; |
---|
960 | }else{ |
---|
961 | var i=-1; |
---|
962 | this.next=function(){ |
---|
963 | i=(i+1)%lst.length; |
---|
964 | return lst[i]; |
---|
965 | }; |
---|
966 | } |
---|
967 | return this.next(); |
---|
968 | } |
---|
969 | }}; |
---|
970 | },repeat:function(elem,n){ |
---|
971 | var m=MochiKit.Base; |
---|
972 | if(typeof (n)=="undefined"){ |
---|
973 | return {repr:function(){ |
---|
974 | return "repeat("+m.repr(elem)+")"; |
---|
975 | },toString:m.forwardCall("repr"),next:function(){ |
---|
976 | return elem; |
---|
977 | }}; |
---|
978 | } |
---|
979 | return {repr:function(){ |
---|
980 | return "repeat("+m.repr(elem)+", "+n+")"; |
---|
981 | },toString:m.forwardCall("repr"),next:function(){ |
---|
982 | if(n<=0){ |
---|
983 | throw MochiKit.Iter.StopIteration; |
---|
984 | } |
---|
985 | n-=1; |
---|
986 | return elem; |
---|
987 | }}; |
---|
988 | },next:function(_141){ |
---|
989 | return _141.next(); |
---|
990 | },izip:function(p,q){ |
---|
991 | var m=MochiKit.Base; |
---|
992 | var next=MochiKit.Iter.next; |
---|
993 | var _144=m.map(iter,arguments); |
---|
994 | return {repr:function(){ |
---|
995 | return "izip(...)"; |
---|
996 | },toString:m.forwardCall("repr"),next:function(){ |
---|
997 | return m.map(next,_144); |
---|
998 | }}; |
---|
999 | },ifilter:function(pred,seq){ |
---|
1000 | var m=MochiKit.Base; |
---|
1001 | seq=MochiKit.Iter.iter(seq); |
---|
1002 | if(pred===null){ |
---|
1003 | pred=m.operator.truth; |
---|
1004 | } |
---|
1005 | return {repr:function(){ |
---|
1006 | return "ifilter(...)"; |
---|
1007 | },toString:m.forwardCall("repr"),next:function(){ |
---|
1008 | while(true){ |
---|
1009 | var rval=seq.next(); |
---|
1010 | if(pred(rval)){ |
---|
1011 | return rval; |
---|
1012 | } |
---|
1013 | } |
---|
1014 | return undefined; |
---|
1015 | }}; |
---|
1016 | },ifilterfalse:function(pred,seq){ |
---|
1017 | var m=MochiKit.Base; |
---|
1018 | seq=MochiKit.Iter.iter(seq); |
---|
1019 | if(pred===null){ |
---|
1020 | pred=m.operator.truth; |
---|
1021 | } |
---|
1022 | return {repr:function(){ |
---|
1023 | return "ifilterfalse(...)"; |
---|
1024 | },toString:m.forwardCall("repr"),next:function(){ |
---|
1025 | while(true){ |
---|
1026 | var rval=seq.next(); |
---|
1027 | if(!pred(rval)){ |
---|
1028 | return rval; |
---|
1029 | } |
---|
1030 | } |
---|
1031 | return undefined; |
---|
1032 | }}; |
---|
1033 | },islice:function(seq){ |
---|
1034 | var self=MochiKit.Iter; |
---|
1035 | var m=MochiKit.Base; |
---|
1036 | seq=self.iter(seq); |
---|
1037 | var _147=0; |
---|
1038 | var stop=0; |
---|
1039 | var step=1; |
---|
1040 | var i=-1; |
---|
1041 | if(arguments.length==2){ |
---|
1042 | stop=arguments[1]; |
---|
1043 | }else{ |
---|
1044 | if(arguments.length==3){ |
---|
1045 | _147=arguments[1]; |
---|
1046 | stop=arguments[2]; |
---|
1047 | }else{ |
---|
1048 | _147=arguments[1]; |
---|
1049 | stop=arguments[2]; |
---|
1050 | step=arguments[3]; |
---|
1051 | } |
---|
1052 | } |
---|
1053 | return {repr:function(){ |
---|
1054 | return "islice("+["...",_147,stop,step].join(", ")+")"; |
---|
1055 | },toString:m.forwardCall("repr"),next:function(){ |
---|
1056 | var rval; |
---|
1057 | while(i<_147){ |
---|
1058 | rval=seq.next(); |
---|
1059 | i++; |
---|
1060 | } |
---|
1061 | if(_147>=stop){ |
---|
1062 | throw self.StopIteration; |
---|
1063 | } |
---|
1064 | _147+=step; |
---|
1065 | return rval; |
---|
1066 | }}; |
---|
1067 | },imap:function(fun,p,q){ |
---|
1068 | var m=MochiKit.Base; |
---|
1069 | var self=MochiKit.Iter; |
---|
1070 | var _151=m.map(self.iter,m.extend(null,arguments,1)); |
---|
1071 | var map=m.map; |
---|
1072 | var next=self.next; |
---|
1073 | return {repr:function(){ |
---|
1074 | return "imap(...)"; |
---|
1075 | },toString:m.forwardCall("repr"),next:function(){ |
---|
1076 | return fun.apply(this,map(next,_151)); |
---|
1077 | }}; |
---|
1078 | },applymap:function(fun,seq,self){ |
---|
1079 | seq=MochiKit.Iter.iter(seq); |
---|
1080 | var m=MochiKit.Base; |
---|
1081 | return {repr:function(){ |
---|
1082 | return "applymap(...)"; |
---|
1083 | },toString:m.forwardCall("repr"),next:function(){ |
---|
1084 | return fun.apply(self,seq.next()); |
---|
1085 | }}; |
---|
1086 | },chain:function(p,q){ |
---|
1087 | var self=MochiKit.Iter; |
---|
1088 | var m=MochiKit.Base; |
---|
1089 | if(arguments.length==1){ |
---|
1090 | return self.iter(arguments[0]); |
---|
1091 | } |
---|
1092 | var _153=m.map(self.iter,arguments); |
---|
1093 | return {repr:function(){ |
---|
1094 | return "chain(...)"; |
---|
1095 | },toString:m.forwardCall("repr"),next:function(){ |
---|
1096 | while(_153.length>1){ |
---|
1097 | try{ |
---|
1098 | return _153[0].next(); |
---|
1099 | } |
---|
1100 | catch(e){ |
---|
1101 | if(e!=self.StopIteration){ |
---|
1102 | throw e; |
---|
1103 | } |
---|
1104 | _153.shift(); |
---|
1105 | } |
---|
1106 | } |
---|
1107 | if(_153.length==1){ |
---|
1108 | var arg=_153.shift(); |
---|
1109 | this.next=m.bind("next",arg); |
---|
1110 | return this.next(); |
---|
1111 | } |
---|
1112 | throw self.StopIteration; |
---|
1113 | }}; |
---|
1114 | },takewhile:function(pred,seq){ |
---|
1115 | var self=MochiKit.Iter; |
---|
1116 | seq=self.iter(seq); |
---|
1117 | return {repr:function(){ |
---|
1118 | return "takewhile(...)"; |
---|
1119 | },toString:MochiKit.Base.forwardCall("repr"),next:function(){ |
---|
1120 | var rval=seq.next(); |
---|
1121 | if(!pred(rval)){ |
---|
1122 | this.next=function(){ |
---|
1123 | throw self.StopIteration; |
---|
1124 | }; |
---|
1125 | this.next(); |
---|
1126 | } |
---|
1127 | return rval; |
---|
1128 | }}; |
---|
1129 | },dropwhile:function(pred,seq){ |
---|
1130 | seq=MochiKit.Iter.iter(seq); |
---|
1131 | var m=MochiKit.Base; |
---|
1132 | var bind=m.bind; |
---|
1133 | return {"repr":function(){ |
---|
1134 | return "dropwhile(...)"; |
---|
1135 | },"toString":m.forwardCall("repr"),"next":function(){ |
---|
1136 | while(true){ |
---|
1137 | var rval=seq.next(); |
---|
1138 | if(!pred(rval)){ |
---|
1139 | break; |
---|
1140 | } |
---|
1141 | } |
---|
1142 | this.next=bind("next",seq); |
---|
1143 | return rval; |
---|
1144 | }}; |
---|
1145 | },_tee:function(_155,sync,_157){ |
---|
1146 | sync.pos[_155]=-1; |
---|
1147 | var m=MochiKit.Base; |
---|
1148 | var _158=m.listMin; |
---|
1149 | return {repr:function(){ |
---|
1150 | return "tee("+_155+", ...)"; |
---|
1151 | },toString:m.forwardCall("repr"),next:function(){ |
---|
1152 | var rval; |
---|
1153 | var i=sync.pos[_155]; |
---|
1154 | if(i==sync.max){ |
---|
1155 | rval=_157.next(); |
---|
1156 | sync.deque.push(rval); |
---|
1157 | sync.max+=1; |
---|
1158 | sync.pos[_155]+=1; |
---|
1159 | }else{ |
---|
1160 | rval=sync.deque[i-sync.min]; |
---|
1161 | sync.pos[_155]+=1; |
---|
1162 | if(i==sync.min&&_158(sync.pos)!=sync.min){ |
---|
1163 | sync.min+=1; |
---|
1164 | sync.deque.shift(); |
---|
1165 | } |
---|
1166 | } |
---|
1167 | return rval; |
---|
1168 | }}; |
---|
1169 | },tee:function(_159,n){ |
---|
1170 | var rval=[]; |
---|
1171 | var sync={"pos":[],"deque":[],"max":-1,"min":-1}; |
---|
1172 | if(arguments.length==1){ |
---|
1173 | n=2; |
---|
1174 | } |
---|
1175 | var self=MochiKit.Iter; |
---|
1176 | _159=self.iter(_159); |
---|
1177 | var _tee=self._tee; |
---|
1178 | for(var i=0;i<n;i++){ |
---|
1179 | rval.push(_tee(i,sync,_159)); |
---|
1180 | } |
---|
1181 | return rval; |
---|
1182 | },list:function(_161){ |
---|
1183 | var m=MochiKit.Base; |
---|
1184 | if(typeof (_161.slice)=="function"){ |
---|
1185 | return _161.slice(); |
---|
1186 | }else{ |
---|
1187 | if(m.isArrayLike(_161)){ |
---|
1188 | return m.concat(_161); |
---|
1189 | } |
---|
1190 | } |
---|
1191 | var self=MochiKit.Iter; |
---|
1192 | _161=self.iter(_161); |
---|
1193 | var rval=[]; |
---|
1194 | try{ |
---|
1195 | while(true){ |
---|
1196 | rval.push(_161.next()); |
---|
1197 | } |
---|
1198 | } |
---|
1199 | catch(e){ |
---|
1200 | if(e!=self.StopIteration){ |
---|
1201 | throw e; |
---|
1202 | } |
---|
1203 | return rval; |
---|
1204 | } |
---|
1205 | return undefined; |
---|
1206 | },reduce:function(fn,_162,_163){ |
---|
1207 | var i=0; |
---|
1208 | var x=_163; |
---|
1209 | var self=MochiKit.Iter; |
---|
1210 | _162=self.iter(_162); |
---|
1211 | if(arguments.length<3){ |
---|
1212 | try{ |
---|
1213 | x=_162.next(); |
---|
1214 | } |
---|
1215 | catch(e){ |
---|
1216 | if(e==self.StopIteration){ |
---|
1217 | e=new TypeError("reduce() of empty sequence with no initial value"); |
---|
1218 | } |
---|
1219 | throw e; |
---|
1220 | } |
---|
1221 | i++; |
---|
1222 | } |
---|
1223 | try{ |
---|
1224 | while(true){ |
---|
1225 | x=fn(x,_162.next()); |
---|
1226 | } |
---|
1227 | } |
---|
1228 | catch(e){ |
---|
1229 | if(e!=self.StopIteration){ |
---|
1230 | throw e; |
---|
1231 | } |
---|
1232 | } |
---|
1233 | return x; |
---|
1234 | },range:function(){ |
---|
1235 | var _165=0; |
---|
1236 | var stop=0; |
---|
1237 | var step=1; |
---|
1238 | if(arguments.length==1){ |
---|
1239 | stop=arguments[0]; |
---|
1240 | }else{ |
---|
1241 | if(arguments.length==2){ |
---|
1242 | _165=arguments[0]; |
---|
1243 | stop=arguments[1]; |
---|
1244 | }else{ |
---|
1245 | if(arguments.length==3){ |
---|
1246 | _165=arguments[0]; |
---|
1247 | stop=arguments[1]; |
---|
1248 | step=arguments[2]; |
---|
1249 | }else{ |
---|
1250 | throw new TypeError("range() takes 1, 2, or 3 arguments!"); |
---|
1251 | } |
---|
1252 | } |
---|
1253 | } |
---|
1254 | if(step===0){ |
---|
1255 | throw new TypeError("range() step must not be 0"); |
---|
1256 | } |
---|
1257 | return {next:function(){ |
---|
1258 | if((step>0&&_165>=stop)||(step<0&&_165<=stop)){ |
---|
1259 | throw MochiKit.Iter.StopIteration; |
---|
1260 | } |
---|
1261 | var rval=_165; |
---|
1262 | _165+=step; |
---|
1263 | return rval; |
---|
1264 | },repr:function(){ |
---|
1265 | return "range("+[_165,stop,step].join(", ")+")"; |
---|
1266 | },toString:MochiKit.Base.forwardCall("repr")}; |
---|
1267 | },sum:function(_166,_167){ |
---|
1268 | var x=_167||0; |
---|
1269 | var self=MochiKit.Iter; |
---|
1270 | _166=self.iter(_166); |
---|
1271 | try{ |
---|
1272 | while(true){ |
---|
1273 | x+=_166.next(); |
---|
1274 | } |
---|
1275 | } |
---|
1276 | catch(e){ |
---|
1277 | if(e!=self.StopIteration){ |
---|
1278 | throw e; |
---|
1279 | } |
---|
1280 | } |
---|
1281 | return x; |
---|
1282 | },exhaust:function(_168){ |
---|
1283 | var self=MochiKit.Iter; |
---|
1284 | _168=self.iter(_168); |
---|
1285 | try{ |
---|
1286 | while(true){ |
---|
1287 | _168.next(); |
---|
1288 | } |
---|
1289 | } |
---|
1290 | catch(e){ |
---|
1291 | if(e!=self.StopIteration){ |
---|
1292 | throw e; |
---|
1293 | } |
---|
1294 | } |
---|
1295 | },forEach:function(_169,func,self){ |
---|
1296 | var m=MochiKit.Base; |
---|
1297 | if(arguments.length>2){ |
---|
1298 | func=m.bind(func,self); |
---|
1299 | } |
---|
1300 | if(m.isArrayLike(_169)){ |
---|
1301 | try{ |
---|
1302 | for(var i=0;i<_169.length;i++){ |
---|
1303 | func(_169[i]); |
---|
1304 | } |
---|
1305 | } |
---|
1306 | catch(e){ |
---|
1307 | if(e!=MochiKit.Iter.StopIteration){ |
---|
1308 | throw e; |
---|
1309 | } |
---|
1310 | } |
---|
1311 | }else{ |
---|
1312 | self=MochiKit.Iter; |
---|
1313 | self.exhaust(self.imap(func,_169)); |
---|
1314 | } |
---|
1315 | },every:function(_171,func){ |
---|
1316 | var self=MochiKit.Iter; |
---|
1317 | try{ |
---|
1318 | self.ifilterfalse(func,_171).next(); |
---|
1319 | return false; |
---|
1320 | } |
---|
1321 | catch(e){ |
---|
1322 | if(e!=self.StopIteration){ |
---|
1323 | throw e; |
---|
1324 | } |
---|
1325 | return true; |
---|
1326 | } |
---|
1327 | },sorted:function(_172,cmp){ |
---|
1328 | var rval=MochiKit.Iter.list(_172); |
---|
1329 | if(arguments.length==1){ |
---|
1330 | cmp=MochiKit.Base.compare; |
---|
1331 | } |
---|
1332 | rval.sort(cmp); |
---|
1333 | return rval; |
---|
1334 | },reversed:function(_173){ |
---|
1335 | var rval=MochiKit.Iter.list(_173); |
---|
1336 | rval.reverse(); |
---|
1337 | return rval; |
---|
1338 | },some:function(_174,func){ |
---|
1339 | var self=MochiKit.Iter; |
---|
1340 | try{ |
---|
1341 | self.ifilter(func,_174).next(); |
---|
1342 | return true; |
---|
1343 | } |
---|
1344 | catch(e){ |
---|
1345 | if(e!=self.StopIteration){ |
---|
1346 | throw e; |
---|
1347 | } |
---|
1348 | return false; |
---|
1349 | } |
---|
1350 | },iextend:function(lst,_175){ |
---|
1351 | if(MochiKit.Base.isArrayLike(_175)){ |
---|
1352 | for(var i=0;i<_175.length;i++){ |
---|
1353 | lst.push(_175[i]); |
---|
1354 | } |
---|
1355 | }else{ |
---|
1356 | var self=MochiKit.Iter; |
---|
1357 | _175=self.iter(_175); |
---|
1358 | try{ |
---|
1359 | while(true){ |
---|
1360 | lst.push(_175.next()); |
---|
1361 | } |
---|
1362 | } |
---|
1363 | catch(e){ |
---|
1364 | if(e!=self.StopIteration){ |
---|
1365 | throw e; |
---|
1366 | } |
---|
1367 | } |
---|
1368 | } |
---|
1369 | return lst; |
---|
1370 | },groupby:function(_176,_177){ |
---|
1371 | var m=MochiKit.Base; |
---|
1372 | var self=MochiKit.Iter; |
---|
1373 | if(arguments.length<2){ |
---|
1374 | _177=m.operator.identity; |
---|
1375 | } |
---|
1376 | _176=self.iter(_176); |
---|
1377 | var pk=undefined; |
---|
1378 | var k=undefined; |
---|
1379 | var v; |
---|
1380 | function fetch(){ |
---|
1381 | v=_176.next(); |
---|
1382 | k=_177(v); |
---|
1383 | } |
---|
1384 | function eat(){ |
---|
1385 | var ret=v; |
---|
1386 | v=undefined; |
---|
1387 | return ret; |
---|
1388 | } |
---|
1389 | var _180=true; |
---|
1390 | return {repr:function(){ |
---|
1391 | return "groupby(...)"; |
---|
1392 | },next:function(){ |
---|
1393 | while(k==pk){ |
---|
1394 | fetch(); |
---|
1395 | if(_180){ |
---|
1396 | _180=false; |
---|
1397 | break; |
---|
1398 | } |
---|
1399 | } |
---|
1400 | pk=k; |
---|
1401 | return [k,{next:function(){ |
---|
1402 | if(v==undefined){ |
---|
1403 | fetch(); |
---|
1404 | } |
---|
1405 | if(k!=pk){ |
---|
1406 | throw self.StopIteration; |
---|
1407 | } |
---|
1408 | return eat(); |
---|
1409 | }}]; |
---|
1410 | }}; |
---|
1411 | },groupby_as_array:function(_181,_182){ |
---|
1412 | var m=MochiKit.Base; |
---|
1413 | var self=MochiKit.Iter; |
---|
1414 | if(arguments.length<2){ |
---|
1415 | _182=m.operator.identity; |
---|
1416 | } |
---|
1417 | _181=self.iter(_181); |
---|
1418 | var _183=[]; |
---|
1419 | var _184=true; |
---|
1420 | var _185; |
---|
1421 | while(true){ |
---|
1422 | try{ |
---|
1423 | var _186=_181.next(); |
---|
1424 | var key=_182(_186); |
---|
1425 | } |
---|
1426 | catch(e){ |
---|
1427 | if(e==self.StopIteration){ |
---|
1428 | break; |
---|
1429 | } |
---|
1430 | throw e; |
---|
1431 | } |
---|
1432 | if(_184||key!=_185){ |
---|
1433 | var _187=[]; |
---|
1434 | _183.push([key,_187]); |
---|
1435 | } |
---|
1436 | _187.push(_186); |
---|
1437 | _184=false; |
---|
1438 | _185=key; |
---|
1439 | } |
---|
1440 | return _183; |
---|
1441 | },arrayLikeIter:function(_188){ |
---|
1442 | var i=0; |
---|
1443 | return {repr:function(){ |
---|
1444 | return "arrayLikeIter(...)"; |
---|
1445 | },toString:MochiKit.Base.forwardCall("repr"),next:function(){ |
---|
1446 | if(i>=_188.length){ |
---|
1447 | throw MochiKit.Iter.StopIteration; |
---|
1448 | } |
---|
1449 | return _188[i++]; |
---|
1450 | }}; |
---|
1451 | },hasIterateNext:function(_189){ |
---|
1452 | return (_189&&typeof (_189.iterateNext)=="function"); |
---|
1453 | },iterateNextIter:function(_190){ |
---|
1454 | return {repr:function(){ |
---|
1455 | return "iterateNextIter(...)"; |
---|
1456 | },toString:MochiKit.Base.forwardCall("repr"),next:function(){ |
---|
1457 | var rval=_190.iterateNext(); |
---|
1458 | if(rval===null||rval===undefined){ |
---|
1459 | throw MochiKit.Iter.StopIteration; |
---|
1460 | } |
---|
1461 | return rval; |
---|
1462 | }}; |
---|
1463 | }}); |
---|
1464 | MochiKit.Iter.EXPORT_OK=["iteratorRegistry","arrayLikeIter","hasIterateNext","iterateNextIter",]; |
---|
1465 | MochiKit.Iter.EXPORT=["StopIteration","registerIteratorFactory","iter","count","cycle","repeat","next","izip","ifilter","ifilterfalse","islice","imap","applymap","chain","takewhile","dropwhile","tee","list","reduce","range","sum","exhaust","forEach","every","sorted","reversed","some","iextend","groupby","groupby_as_array"]; |
---|
1466 | MochiKit.Iter.__new__=function(){ |
---|
1467 | var m=MochiKit.Base; |
---|
1468 | this.StopIteration=new m.NamedError("StopIteration"); |
---|
1469 | this.iteratorRegistry=new m.AdapterRegistry(); |
---|
1470 | this.registerIteratorFactory("arrayLike",m.isArrayLike,this.arrayLikeIter); |
---|
1471 | this.registerIteratorFactory("iterateNext",this.hasIterateNext,this.iterateNextIter); |
---|
1472 | this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; |
---|
1473 | m.nameFunctions(this); |
---|
1474 | }; |
---|
1475 | MochiKit.Iter.__new__(); |
---|
1476 | if(!MochiKit.__compat__){ |
---|
1477 | reduce=MochiKit.Iter.reduce; |
---|
1478 | } |
---|
1479 | MochiKit.Base._exportSymbols(this,MochiKit.Iter); |
---|
1480 | if(typeof (dojo)!="undefined"){ |
---|
1481 | dojo.provide("MochiKit.Logging"); |
---|
1482 | dojo.require("MochiKit.Base"); |
---|
1483 | } |
---|
1484 | if(typeof (JSAN)!="undefined"){ |
---|
1485 | JSAN.use("MochiKit.Base",[]); |
---|
1486 | } |
---|
1487 | try{ |
---|
1488 | if(typeof (MochiKit.Base)=="undefined"){ |
---|
1489 | throw ""; |
---|
1490 | } |
---|
1491 | } |
---|
1492 | catch(e){ |
---|
1493 | throw "MochiKit.Logging depends on MochiKit.Base!"; |
---|
1494 | } |
---|
1495 | if(typeof (MochiKit.Logging)=="undefined"){ |
---|
1496 | MochiKit.Logging={}; |
---|
1497 | } |
---|
1498 | MochiKit.Logging.NAME="MochiKit.Logging"; |
---|
1499 | MochiKit.Logging.VERSION="1.3.1"; |
---|
1500 | MochiKit.Logging.__repr__=function(){ |
---|
1501 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
1502 | }; |
---|
1503 | MochiKit.Logging.toString=function(){ |
---|
1504 | return this.__repr__(); |
---|
1505 | }; |
---|
1506 | MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"]; |
---|
1507 | MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"]; |
---|
1508 | MochiKit.Logging.LogMessage=function(num,_192,info){ |
---|
1509 | this.num=num; |
---|
1510 | this.level=_192; |
---|
1511 | this.info=info; |
---|
1512 | this.timestamp=new Date(); |
---|
1513 | }; |
---|
1514 | MochiKit.Logging.LogMessage.prototype={repr:function(){ |
---|
1515 | var m=MochiKit.Base; |
---|
1516 | return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")"; |
---|
1517 | },toString:MochiKit.Base.forwardCall("repr")}; |
---|
1518 | MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_194){ |
---|
1519 | var self=MochiKit.Logging; |
---|
1520 | if(typeof (_194)=="string"){ |
---|
1521 | _194=self.LogLevel[_194]; |
---|
1522 | } |
---|
1523 | return function(msg){ |
---|
1524 | var _196=msg.level; |
---|
1525 | if(typeof (_196)=="string"){ |
---|
1526 | _196=self.LogLevel[_196]; |
---|
1527 | } |
---|
1528 | return _196>=_194; |
---|
1529 | }; |
---|
1530 | },isLogMessage:function(){ |
---|
1531 | var _197=MochiKit.Logging.LogMessage; |
---|
1532 | for(var i=0;i<arguments.length;i++){ |
---|
1533 | if(!(arguments[i] instanceof _197)){ |
---|
1534 | return false; |
---|
1535 | } |
---|
1536 | } |
---|
1537 | return true; |
---|
1538 | },compareLogMessage:function(a,b){ |
---|
1539 | return MochiKit.Base.compare([a.level,a.info],[b.level,b.info]); |
---|
1540 | },alertListener:function(msg){ |
---|
1541 | alert("num: "+msg.num+"\nlevel: "+msg.level+"\ninfo: "+msg.info.join(" ")); |
---|
1542 | }}); |
---|
1543 | MochiKit.Logging.Logger=function(_198){ |
---|
1544 | this.counter=0; |
---|
1545 | if(typeof (_198)=="undefined"||_198===null){ |
---|
1546 | _198=-1; |
---|
1547 | } |
---|
1548 | this.maxSize=_198; |
---|
1549 | this._messages=[]; |
---|
1550 | this.listeners={}; |
---|
1551 | this.useNativeConsole=false; |
---|
1552 | }; |
---|
1553 | MochiKit.Logging.Logger.prototype={clear:function(){ |
---|
1554 | this._messages.splice(0,this._messages.length); |
---|
1555 | },logToConsole:function(msg){ |
---|
1556 | if(typeof (window)!="undefined"&&window.console&&window.console.log){ |
---|
1557 | window.console.log(msg); |
---|
1558 | }else{ |
---|
1559 | if(typeof (opera)!="undefined"&&opera.postError){ |
---|
1560 | opera.postError(msg); |
---|
1561 | }else{ |
---|
1562 | if(typeof (printfire)=="function"){ |
---|
1563 | printfire(msg); |
---|
1564 | } |
---|
1565 | } |
---|
1566 | } |
---|
1567 | },dispatchListeners:function(msg){ |
---|
1568 | for(var k in this.listeners){ |
---|
1569 | var pair=this.listeners[k]; |
---|
1570 | if(pair.ident!=k||(pair[0]&&!pair[0](msg))){ |
---|
1571 | continue; |
---|
1572 | } |
---|
1573 | pair[1](msg); |
---|
1574 | } |
---|
1575 | },addListener:function(_199,_200,_201){ |
---|
1576 | if(typeof (_200)=="string"){ |
---|
1577 | _200=MochiKit.Logging.logLevelAtLeast(_200); |
---|
1578 | } |
---|
1579 | var _202=[_200,_201]; |
---|
1580 | _202.ident=_199; |
---|
1581 | this.listeners[_199]=_202; |
---|
1582 | },removeListener:function(_203){ |
---|
1583 | delete this.listeners[_203]; |
---|
1584 | },baseLog:function(_204,_205){ |
---|
1585 | var msg=new MochiKit.Logging.LogMessage(this.counter,_204,MochiKit.Base.extend(null,arguments,1)); |
---|
1586 | this._messages.push(msg); |
---|
1587 | this.dispatchListeners(msg); |
---|
1588 | if(this.useNativeConsole){ |
---|
1589 | this.logToConsole(msg.level+": "+msg.info.join(" ")); |
---|
1590 | } |
---|
1591 | this.counter+=1; |
---|
1592 | while(this.maxSize>=0&&this._messages.length>this.maxSize){ |
---|
1593 | this._messages.shift(); |
---|
1594 | } |
---|
1595 | },getMessages:function(_206){ |
---|
1596 | var _207=0; |
---|
1597 | if(!(typeof (_206)=="undefined"||_206===null)){ |
---|
1598 | _207=Math.max(0,this._messages.length-_206); |
---|
1599 | } |
---|
1600 | return this._messages.slice(_207); |
---|
1601 | },getMessageText:function(_208){ |
---|
1602 | if(typeof (_208)=="undefined"||_208===null){ |
---|
1603 | _208=30; |
---|
1604 | } |
---|
1605 | var _209=this.getMessages(_208); |
---|
1606 | if(_209.length){ |
---|
1607 | var lst=map(function(m){ |
---|
1608 | return "\n ["+m.num+"] "+m.level+": "+m.info.join(" "); |
---|
1609 | },_209); |
---|
1610 | lst.unshift("LAST "+_209.length+" MESSAGES:"); |
---|
1611 | return lst.join(""); |
---|
1612 | } |
---|
1613 | return ""; |
---|
1614 | },debuggingBookmarklet:function(_210){ |
---|
1615 | if(typeof (MochiKit.LoggingPane)=="undefined"){ |
---|
1616 | alert(this.getMessageText()); |
---|
1617 | }else{ |
---|
1618 | MochiKit.LoggingPane.createLoggingPane(_210||false); |
---|
1619 | } |
---|
1620 | }}; |
---|
1621 | MochiKit.Logging.__new__=function(){ |
---|
1622 | this.LogLevel={ERROR:40,FATAL:50,WARNING:30,INFO:20,DEBUG:10}; |
---|
1623 | var m=MochiKit.Base; |
---|
1624 | m.registerComparator("LogMessage",this.isLogMessage,this.compareLogMessage); |
---|
1625 | var _211=m.partial; |
---|
1626 | var _212=this.Logger; |
---|
1627 | var _213=_212.prototype.baseLog; |
---|
1628 | m.update(this.Logger.prototype,{debug:_211(_213,"DEBUG"),log:_211(_213,"INFO"),error:_211(_213,"ERROR"),fatal:_211(_213,"FATAL"),warning:_211(_213,"WARNING")}); |
---|
1629 | var self=this; |
---|
1630 | var _214=function(name){ |
---|
1631 | return function(){ |
---|
1632 | self.logger[name].apply(self.logger,arguments); |
---|
1633 | }; |
---|
1634 | }; |
---|
1635 | this.log=_214("log"); |
---|
1636 | this.logError=_214("error"); |
---|
1637 | this.logDebug=_214("debug"); |
---|
1638 | this.logFatal=_214("fatal"); |
---|
1639 | this.logWarning=_214("warning"); |
---|
1640 | this.logger=new _212(); |
---|
1641 | this.logger.useNativeConsole=true; |
---|
1642 | this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; |
---|
1643 | m.nameFunctions(this); |
---|
1644 | }; |
---|
1645 | if(typeof (printfire)=="undefined"&&typeof (document)!="undefined"&&document.createEvent&&typeof (dispatchEvent)!="undefined"){ |
---|
1646 | printfire=function(){ |
---|
1647 | printfire.args=arguments; |
---|
1648 | var ev=document.createEvent("Events"); |
---|
1649 | ev.initEvent("printfire",false,true); |
---|
1650 | dispatchEvent(ev); |
---|
1651 | }; |
---|
1652 | } |
---|
1653 | MochiKit.Logging.__new__(); |
---|
1654 | MochiKit.Base._exportSymbols(this,MochiKit.Logging); |
---|
1655 | if(typeof (dojo)!="undefined"){ |
---|
1656 | dojo.provide("MochiKit.DateTime"); |
---|
1657 | } |
---|
1658 | if(typeof (MochiKit)=="undefined"){ |
---|
1659 | MochiKit={}; |
---|
1660 | } |
---|
1661 | if(typeof (MochiKit.DateTime)=="undefined"){ |
---|
1662 | MochiKit.DateTime={}; |
---|
1663 | } |
---|
1664 | MochiKit.DateTime.NAME="MochiKit.DateTime"; |
---|
1665 | MochiKit.DateTime.VERSION="1.3.1"; |
---|
1666 | MochiKit.DateTime.__repr__=function(){ |
---|
1667 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
1668 | }; |
---|
1669 | MochiKit.DateTime.toString=function(){ |
---|
1670 | return this.__repr__(); |
---|
1671 | }; |
---|
1672 | MochiKit.DateTime.isoDate=function(str){ |
---|
1673 | str=str+""; |
---|
1674 | if(typeof (str)!="string"||str.length===0){ |
---|
1675 | return null; |
---|
1676 | } |
---|
1677 | var iso=str.split("-"); |
---|
1678 | if(iso.length===0){ |
---|
1679 | return null; |
---|
1680 | } |
---|
1681 | return new Date(iso[0],iso[1]-1,iso[2]); |
---|
1682 | }; |
---|
1683 | MochiKit.DateTime._isoRegexp=/(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/; |
---|
1684 | MochiKit.DateTime.isoTimestamp=function(str){ |
---|
1685 | str=str+""; |
---|
1686 | if(typeof (str)!="string"||str.length===0){ |
---|
1687 | return null; |
---|
1688 | } |
---|
1689 | var res=str.match(MochiKit.DateTime._isoRegexp); |
---|
1690 | if(typeof (res)=="undefined"||res===null){ |
---|
1691 | return null; |
---|
1692 | } |
---|
1693 | var year,month,day,hour,min,sec,msec; |
---|
1694 | year=parseInt(res[1],10); |
---|
1695 | if(typeof (res[2])=="undefined"||res[2]===""){ |
---|
1696 | return new Date(year); |
---|
1697 | } |
---|
1698 | month=parseInt(res[2],10)-1; |
---|
1699 | day=parseInt(res[3],10); |
---|
1700 | if(typeof (res[4])=="undefined"||res[4]===""){ |
---|
1701 | return new Date(year,month,day); |
---|
1702 | } |
---|
1703 | hour=parseInt(res[4],10); |
---|
1704 | min=parseInt(res[5],10); |
---|
1705 | sec=(typeof (res[6])!="undefined"&&res[6]!=="")?parseInt(res[6],10):0; |
---|
1706 | if(typeof (res[7])!="undefined"&&res[7]!==""){ |
---|
1707 | msec=Math.round(1000*parseFloat("0."+res[7])); |
---|
1708 | }else{ |
---|
1709 | msec=0; |
---|
1710 | } |
---|
1711 | if((typeof (res[8])=="undefined"||res[8]==="")&&(typeof (res[9])=="undefined"||res[9]==="")){ |
---|
1712 | return new Date(year,month,day,hour,min,sec,msec); |
---|
1713 | } |
---|
1714 | var ofs; |
---|
1715 | if(typeof (res[9])!="undefined"&&res[9]!==""){ |
---|
1716 | ofs=parseInt(res[10],10)*3600000; |
---|
1717 | if(typeof (res[11])!="undefined"&&res[11]!==""){ |
---|
1718 | ofs+=parseInt(res[11],10)*60000; |
---|
1719 | } |
---|
1720 | if(res[9]=="-"){ |
---|
1721 | ofs=-ofs; |
---|
1722 | } |
---|
1723 | }else{ |
---|
1724 | ofs=0; |
---|
1725 | } |
---|
1726 | return new Date(Date.UTC(year,month,day,hour,min,sec,msec)-ofs); |
---|
1727 | }; |
---|
1728 | MochiKit.DateTime.toISOTime=function(date,_221){ |
---|
1729 | if(typeof (date)=="undefined"||date===null){ |
---|
1730 | return null; |
---|
1731 | } |
---|
1732 | var hh=date.getHours(); |
---|
1733 | var mm=date.getMinutes(); |
---|
1734 | var ss=date.getSeconds(); |
---|
1735 | var lst=[((_221&&(hh<10))?"0"+hh:hh),((mm<10)?"0"+mm:mm),((ss<10)?"0"+ss:ss)]; |
---|
1736 | return lst.join(":"); |
---|
1737 | }; |
---|
1738 | MochiKit.DateTime.toISOTimestamp=function(date,_225){ |
---|
1739 | if(typeof (date)=="undefined"||date===null){ |
---|
1740 | return null; |
---|
1741 | } |
---|
1742 | var sep=_225?"T":" "; |
---|
1743 | var foot=_225?"Z":""; |
---|
1744 | if(_225){ |
---|
1745 | date=new Date(date.getTime()+(date.getTimezoneOffset()*60000)); |
---|
1746 | } |
---|
1747 | return MochiKit.DateTime.toISODate(date)+sep+MochiKit.DateTime.toISOTime(date,_225)+foot; |
---|
1748 | }; |
---|
1749 | MochiKit.DateTime.toISODate=function(date){ |
---|
1750 | if(typeof (date)=="undefined"||date===null){ |
---|
1751 | return null; |
---|
1752 | } |
---|
1753 | var _228=MochiKit.DateTime._padTwo; |
---|
1754 | return [date.getFullYear(),_228(date.getMonth()+1),_228(date.getDate())].join("-"); |
---|
1755 | }; |
---|
1756 | MochiKit.DateTime.americanDate=function(d){ |
---|
1757 | d=d+""; |
---|
1758 | if(typeof (d)!="string"||d.length===0){ |
---|
1759 | return null; |
---|
1760 | } |
---|
1761 | var a=d.split("/"); |
---|
1762 | return new Date(a[2],a[0]-1,a[1]); |
---|
1763 | }; |
---|
1764 | MochiKit.DateTime._padTwo=function(n){ |
---|
1765 | return (n>9)?n:"0"+n; |
---|
1766 | }; |
---|
1767 | MochiKit.DateTime.toPaddedAmericanDate=function(d){ |
---|
1768 | if(typeof (d)=="undefined"||d===null){ |
---|
1769 | return null; |
---|
1770 | } |
---|
1771 | var _230=MochiKit.DateTime._padTwo; |
---|
1772 | return [_230(d.getMonth()+1),_230(d.getDate()),d.getFullYear()].join("/"); |
---|
1773 | }; |
---|
1774 | MochiKit.DateTime.toAmericanDate=function(d){ |
---|
1775 | if(typeof (d)=="undefined"||d===null){ |
---|
1776 | return null; |
---|
1777 | } |
---|
1778 | return [d.getMonth()+1,d.getDate(),d.getFullYear()].join("/"); |
---|
1779 | }; |
---|
1780 | MochiKit.DateTime.EXPORT=["isoDate","isoTimestamp","toISOTime","toISOTimestamp","toISODate","americanDate","toPaddedAmericanDate","toAmericanDate"]; |
---|
1781 | MochiKit.DateTime.EXPORT_OK=[]; |
---|
1782 | MochiKit.DateTime.EXPORT_TAGS={":common":MochiKit.DateTime.EXPORT,":all":MochiKit.DateTime.EXPORT}; |
---|
1783 | MochiKit.DateTime.__new__=function(){ |
---|
1784 | var base=this.NAME+"."; |
---|
1785 | for(var k in this){ |
---|
1786 | var o=this[k]; |
---|
1787 | if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){ |
---|
1788 | try{ |
---|
1789 | o.NAME=base+k; |
---|
1790 | } |
---|
1791 | catch(e){ |
---|
1792 | } |
---|
1793 | } |
---|
1794 | } |
---|
1795 | }; |
---|
1796 | MochiKit.DateTime.__new__(); |
---|
1797 | if(typeof (MochiKit.Base)!="undefined"){ |
---|
1798 | MochiKit.Base._exportSymbols(this,MochiKit.DateTime); |
---|
1799 | }else{ |
---|
1800 | (function(_231,_232){ |
---|
1801 | if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(typeof (MochiKit.__compat__)=="boolean"&&MochiKit.__compat__)){ |
---|
1802 | var all=_232.EXPORT_TAGS[":all"]; |
---|
1803 | for(var i=0;i<all.length;i++){ |
---|
1804 | _231[all[i]]=_232[all[i]]; |
---|
1805 | } |
---|
1806 | } |
---|
1807 | })(this,MochiKit.DateTime); |
---|
1808 | } |
---|
1809 | if(typeof (dojo)!="undefined"){ |
---|
1810 | dojo.provide("MochiKit.Format"); |
---|
1811 | } |
---|
1812 | if(typeof (MochiKit)=="undefined"){ |
---|
1813 | MochiKit={}; |
---|
1814 | } |
---|
1815 | if(typeof (MochiKit.Format)=="undefined"){ |
---|
1816 | MochiKit.Format={}; |
---|
1817 | } |
---|
1818 | MochiKit.Format.NAME="MochiKit.Format"; |
---|
1819 | MochiKit.Format.VERSION="1.3.1"; |
---|
1820 | MochiKit.Format.__repr__=function(){ |
---|
1821 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
1822 | }; |
---|
1823 | MochiKit.Format.toString=function(){ |
---|
1824 | return this.__repr__(); |
---|
1825 | }; |
---|
1826 | MochiKit.Format._numberFormatter=function(_233,_234,_235,_236,_237,_238,_239,_240,_241){ |
---|
1827 | return function(num){ |
---|
1828 | num=parseFloat(num); |
---|
1829 | if(typeof (num)=="undefined"||num===null||isNaN(num)){ |
---|
1830 | return _233; |
---|
1831 | } |
---|
1832 | var _242=_234; |
---|
1833 | var _243=_235; |
---|
1834 | if(num<0){ |
---|
1835 | num=-num; |
---|
1836 | }else{ |
---|
1837 | _242=_242.replace(/-/,""); |
---|
1838 | } |
---|
1839 | var me=arguments.callee; |
---|
1840 | var fmt=MochiKit.Format.formatLocale(_236); |
---|
1841 | if(_237){ |
---|
1842 | num=num*100; |
---|
1843 | _243=fmt.percent+_243; |
---|
1844 | } |
---|
1845 | num=MochiKit.Format.roundToFixed(num,_238); |
---|
1846 | var _245=num.split(/\./); |
---|
1847 | var _246=_245[0]; |
---|
1848 | var frac=(_245.length==1)?"":_245[1]; |
---|
1849 | var res=""; |
---|
1850 | while(_246.length<_239){ |
---|
1851 | _246="0"+_246; |
---|
1852 | } |
---|
1853 | if(_240){ |
---|
1854 | while(_246.length>_240){ |
---|
1855 | var i=_246.length-_240; |
---|
1856 | res=fmt.separator+_246.substring(i,_246.length)+res; |
---|
1857 | _246=_246.substring(0,i); |
---|
1858 | } |
---|
1859 | } |
---|
1860 | res=_246+res; |
---|
1861 | if(_238>0){ |
---|
1862 | while(frac.length<_241){ |
---|
1863 | frac=frac+"0"; |
---|
1864 | } |
---|
1865 | res=res+fmt.decimal+frac; |
---|
1866 | } |
---|
1867 | return _242+res+_243; |
---|
1868 | }; |
---|
1869 | }; |
---|
1870 | MochiKit.Format.numberFormatter=function(_248,_249,_250){ |
---|
1871 | if(typeof (_249)=="undefined"){ |
---|
1872 | _249=""; |
---|
1873 | } |
---|
1874 | var _251=_248.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/); |
---|
1875 | if(!_251){ |
---|
1876 | throw TypeError("Invalid pattern"); |
---|
1877 | } |
---|
1878 | var _252=_248.substr(0,_251.index); |
---|
1879 | var _253=_248.substr(_251.index+_251[0].length); |
---|
1880 | if(_252.search(/-/)==-1){ |
---|
1881 | _252=_252+"-"; |
---|
1882 | } |
---|
1883 | var _254=_251[1]; |
---|
1884 | var frac=(typeof (_251[2])=="string"&&_251[2]!="")?_251[2]:""; |
---|
1885 | var _255=(typeof (_251[3])=="string"&&_251[3]!=""); |
---|
1886 | var tmp=_254.split(/,/); |
---|
1887 | var _257; |
---|
1888 | if(typeof (_250)=="undefined"){ |
---|
1889 | _250="default"; |
---|
1890 | } |
---|
1891 | if(tmp.length==1){ |
---|
1892 | _257=null; |
---|
1893 | }else{ |
---|
1894 | _257=tmp[1].length; |
---|
1895 | } |
---|
1896 | var _258=_254.length-_254.replace(/0/g,"").length; |
---|
1897 | var _259=frac.length-frac.replace(/0/g,"").length; |
---|
1898 | var _260=frac.length; |
---|
1899 | var rval=MochiKit.Format._numberFormatter(_249,_252,_253,_250,_255,_260,_258,_257,_259); |
---|
1900 | var m=MochiKit.Base; |
---|
1901 | if(m){ |
---|
1902 | var fn=arguments.callee; |
---|
1903 | var args=m.concat(arguments); |
---|
1904 | rval.repr=function(){ |
---|
1905 | return [self.NAME,"(",map(m.repr,args).join(", "),")"].join(""); |
---|
1906 | }; |
---|
1907 | } |
---|
1908 | return rval; |
---|
1909 | }; |
---|
1910 | MochiKit.Format.formatLocale=function(_262){ |
---|
1911 | if(typeof (_262)=="undefined"||_262===null){ |
---|
1912 | _262="default"; |
---|
1913 | } |
---|
1914 | if(typeof (_262)=="string"){ |
---|
1915 | var rval=MochiKit.Format.LOCALE[_262]; |
---|
1916 | if(typeof (rval)=="string"){ |
---|
1917 | rval=arguments.callee(rval); |
---|
1918 | MochiKit.Format.LOCALE[_262]=rval; |
---|
1919 | } |
---|
1920 | return rval; |
---|
1921 | }else{ |
---|
1922 | return _262; |
---|
1923 | } |
---|
1924 | }; |
---|
1925 | MochiKit.Format.twoDigitAverage=function(_263,_264){ |
---|
1926 | if(_264){ |
---|
1927 | var res=_263/_264; |
---|
1928 | if(!isNaN(res)){ |
---|
1929 | return MochiKit.Format.twoDigitFloat(_263/_264); |
---|
1930 | } |
---|
1931 | } |
---|
1932 | return "0"; |
---|
1933 | }; |
---|
1934 | MochiKit.Format.twoDigitFloat=function(_265){ |
---|
1935 | var sign=(_265<0?"-":""); |
---|
1936 | var s=Math.floor(Math.abs(_265)*100).toString(); |
---|
1937 | if(s=="0"){ |
---|
1938 | return s; |
---|
1939 | } |
---|
1940 | if(s.length<3){ |
---|
1941 | while(s.charAt(s.length-1)=="0"){ |
---|
1942 | s=s.substring(0,s.length-1); |
---|
1943 | } |
---|
1944 | return sign+"0."+s; |
---|
1945 | } |
---|
1946 | var head=sign+s.substring(0,s.length-2); |
---|
1947 | var tail=s.substring(s.length-2,s.length); |
---|
1948 | if(tail=="00"){ |
---|
1949 | return head; |
---|
1950 | }else{ |
---|
1951 | if(tail.charAt(1)=="0"){ |
---|
1952 | return head+"."+tail.charAt(0); |
---|
1953 | }else{ |
---|
1954 | return head+"."+tail; |
---|
1955 | } |
---|
1956 | } |
---|
1957 | }; |
---|
1958 | MochiKit.Format.lstrip=function(str,_270){ |
---|
1959 | str=str+""; |
---|
1960 | if(typeof (str)!="string"){ |
---|
1961 | return null; |
---|
1962 | } |
---|
1963 | if(!_270){ |
---|
1964 | return str.replace(/^\s+/,""); |
---|
1965 | }else{ |
---|
1966 | return str.replace(new RegExp("^["+_270+"]+"),""); |
---|
1967 | } |
---|
1968 | }; |
---|
1969 | MochiKit.Format.rstrip=function(str,_271){ |
---|
1970 | str=str+""; |
---|
1971 | if(typeof (str)!="string"){ |
---|
1972 | return null; |
---|
1973 | } |
---|
1974 | if(!_271){ |
---|
1975 | return str.replace(/\s+$/,""); |
---|
1976 | }else{ |
---|
1977 | return str.replace(new RegExp("["+_271+"]+$"),""); |
---|
1978 | } |
---|
1979 | }; |
---|
1980 | MochiKit.Format.strip=function(str,_272){ |
---|
1981 | var self=MochiKit.Format; |
---|
1982 | return self.rstrip(self.lstrip(str,_272),_272); |
---|
1983 | }; |
---|
1984 | MochiKit.Format.truncToFixed=function(_273,_274){ |
---|
1985 | _273=Math.floor(_273*Math.pow(10,_274)); |
---|
1986 | var res=(_273*Math.pow(10,-_274)).toFixed(_274); |
---|
1987 | if(res.charAt(0)=="."){ |
---|
1988 | res="0"+res; |
---|
1989 | } |
---|
1990 | return res; |
---|
1991 | }; |
---|
1992 | MochiKit.Format.roundToFixed=function(_275,_276){ |
---|
1993 | return MochiKit.Format.truncToFixed(_275+0.5*Math.pow(10,-_276),_276); |
---|
1994 | }; |
---|
1995 | MochiKit.Format.percentFormat=function(_277){ |
---|
1996 | return MochiKit.Format.twoDigitFloat(100*_277)+"%"; |
---|
1997 | }; |
---|
1998 | MochiKit.Format.EXPORT=["truncToFixed","roundToFixed","numberFormatter","formatLocale","twoDigitAverage","twoDigitFloat","percentFormat","lstrip","rstrip","strip"]; |
---|
1999 | MochiKit.Format.LOCALE={en_US:{separator:",",decimal:".",percent:"%"},de_DE:{separator:".",decimal:",",percent:"%"},fr_FR:{separator:" ",decimal:",",percent:"%"},"default":"en_US"}; |
---|
2000 | MochiKit.Format.EXPORT_OK=[]; |
---|
2001 | MochiKit.Format.EXPORT_TAGS={":all":MochiKit.Format.EXPORT,":common":MochiKit.Format.EXPORT}; |
---|
2002 | MochiKit.Format.__new__=function(){ |
---|
2003 | var base=this.NAME+"."; |
---|
2004 | var k,v,o; |
---|
2005 | for(k in this.LOCALE){ |
---|
2006 | o=this.LOCALE[k]; |
---|
2007 | if(typeof (o)=="object"){ |
---|
2008 | o.repr=function(){ |
---|
2009 | return this.NAME; |
---|
2010 | }; |
---|
2011 | o.NAME=base+"LOCALE."+k; |
---|
2012 | } |
---|
2013 | } |
---|
2014 | for(k in this){ |
---|
2015 | o=this[k]; |
---|
2016 | if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){ |
---|
2017 | try{ |
---|
2018 | o.NAME=base+k; |
---|
2019 | } |
---|
2020 | catch(e){ |
---|
2021 | } |
---|
2022 | } |
---|
2023 | } |
---|
2024 | }; |
---|
2025 | MochiKit.Format.__new__(); |
---|
2026 | if(typeof (MochiKit.Base)!="undefined"){ |
---|
2027 | MochiKit.Base._exportSymbols(this,MochiKit.Format); |
---|
2028 | }else{ |
---|
2029 | (function(_278,_279){ |
---|
2030 | if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(typeof (MochiKit.__compat__)=="boolean"&&MochiKit.__compat__)){ |
---|
2031 | var all=_279.EXPORT_TAGS[":all"]; |
---|
2032 | for(var i=0;i<all.length;i++){ |
---|
2033 | _278[all[i]]=_279[all[i]]; |
---|
2034 | } |
---|
2035 | } |
---|
2036 | })(this,MochiKit.Format); |
---|
2037 | } |
---|
2038 | if(typeof (dojo)!="undefined"){ |
---|
2039 | dojo.provide("MochiKit.Async"); |
---|
2040 | dojo.require("MochiKit.Base"); |
---|
2041 | } |
---|
2042 | if(typeof (JSAN)!="undefined"){ |
---|
2043 | JSAN.use("MochiKit.Base",[]); |
---|
2044 | } |
---|
2045 | try{ |
---|
2046 | if(typeof (MochiKit.Base)=="undefined"){ |
---|
2047 | throw ""; |
---|
2048 | } |
---|
2049 | } |
---|
2050 | catch(e){ |
---|
2051 | throw "MochiKit.Async depends on MochiKit.Base!"; |
---|
2052 | } |
---|
2053 | if(typeof (MochiKit.Async)=="undefined"){ |
---|
2054 | MochiKit.Async={}; |
---|
2055 | } |
---|
2056 | MochiKit.Async.NAME="MochiKit.Async"; |
---|
2057 | MochiKit.Async.VERSION="1.3.1"; |
---|
2058 | MochiKit.Async.__repr__=function(){ |
---|
2059 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
2060 | }; |
---|
2061 | MochiKit.Async.toString=function(){ |
---|
2062 | return this.__repr__(); |
---|
2063 | }; |
---|
2064 | MochiKit.Async.Deferred=function(_280){ |
---|
2065 | this.chain=[]; |
---|
2066 | this.id=this._nextId(); |
---|
2067 | this.fired=-1; |
---|
2068 | this.paused=0; |
---|
2069 | this.results=[null,null]; |
---|
2070 | this.canceller=_280; |
---|
2071 | this.silentlyCancelled=false; |
---|
2072 | this.chained=false; |
---|
2073 | }; |
---|
2074 | MochiKit.Async.Deferred.prototype={repr:function(){ |
---|
2075 | var _281; |
---|
2076 | if(this.fired==-1){ |
---|
2077 | _281="unfired"; |
---|
2078 | }else{ |
---|
2079 | if(this.fired===0){ |
---|
2080 | _281="success"; |
---|
2081 | }else{ |
---|
2082 | _281="error"; |
---|
2083 | } |
---|
2084 | } |
---|
2085 | return "Deferred("+this.id+", "+_281+")"; |
---|
2086 | },toString:MochiKit.Base.forwardCall("repr"),_nextId:MochiKit.Base.counter(),cancel:function(){ |
---|
2087 | var self=MochiKit.Async; |
---|
2088 | if(this.fired==-1){ |
---|
2089 | if(this.canceller){ |
---|
2090 | this.canceller(this); |
---|
2091 | }else{ |
---|
2092 | this.silentlyCancelled=true; |
---|
2093 | } |
---|
2094 | if(this.fired==-1){ |
---|
2095 | this.errback(new self.CancelledError(this)); |
---|
2096 | } |
---|
2097 | }else{ |
---|
2098 | if((this.fired===0)&&(this.results[0] instanceof self.Deferred)){ |
---|
2099 | this.results[0].cancel(); |
---|
2100 | } |
---|
2101 | } |
---|
2102 | },_pause:function(){ |
---|
2103 | this.paused++; |
---|
2104 | },_unpause:function(){ |
---|
2105 | this.paused--; |
---|
2106 | if((this.paused===0)&&(this.fired>=0)){ |
---|
2107 | this._fire(); |
---|
2108 | } |
---|
2109 | },_continue:function(res){ |
---|
2110 | this._resback(res); |
---|
2111 | this._unpause(); |
---|
2112 | },_resback:function(res){ |
---|
2113 | this.fired=((res instanceof Error)?1:0); |
---|
2114 | this.results[this.fired]=res; |
---|
2115 | this._fire(); |
---|
2116 | },_check:function(){ |
---|
2117 | if(this.fired!=-1){ |
---|
2118 | if(!this.silentlyCancelled){ |
---|
2119 | throw new MochiKit.Async.AlreadyCalledError(this); |
---|
2120 | } |
---|
2121 | this.silentlyCancelled=false; |
---|
2122 | return; |
---|
2123 | } |
---|
2124 | },callback:function(res){ |
---|
2125 | this._check(); |
---|
2126 | if(res instanceof MochiKit.Async.Deferred){ |
---|
2127 | throw new Error("Deferred instances can only be chained if they are the result of a callback"); |
---|
2128 | } |
---|
2129 | this._resback(res); |
---|
2130 | },errback:function(res){ |
---|
2131 | this._check(); |
---|
2132 | var self=MochiKit.Async; |
---|
2133 | if(res instanceof self.Deferred){ |
---|
2134 | throw new Error("Deferred instances can only be chained if they are the result of a callback"); |
---|
2135 | } |
---|
2136 | if(!(res instanceof Error)){ |
---|
2137 | res=new self.GenericError(res); |
---|
2138 | } |
---|
2139 | this._resback(res); |
---|
2140 | },addBoth:function(fn){ |
---|
2141 | if(arguments.length>1){ |
---|
2142 | fn=MochiKit.Base.partial.apply(null,arguments); |
---|
2143 | } |
---|
2144 | return this.addCallbacks(fn,fn); |
---|
2145 | },addCallback:function(fn){ |
---|
2146 | if(arguments.length>1){ |
---|
2147 | fn=MochiKit.Base.partial.apply(null,arguments); |
---|
2148 | } |
---|
2149 | return this.addCallbacks(fn,null); |
---|
2150 | },addErrback:function(fn){ |
---|
2151 | if(arguments.length>1){ |
---|
2152 | fn=MochiKit.Base.partial.apply(null,arguments); |
---|
2153 | } |
---|
2154 | return this.addCallbacks(null,fn); |
---|
2155 | },addCallbacks:function(cb,eb){ |
---|
2156 | if(this.chained){ |
---|
2157 | throw new Error("Chained Deferreds can not be re-used"); |
---|
2158 | } |
---|
2159 | this.chain.push([cb,eb]); |
---|
2160 | if(this.fired>=0){ |
---|
2161 | this._fire(); |
---|
2162 | } |
---|
2163 | return this; |
---|
2164 | },_fire:function(){ |
---|
2165 | var _284=this.chain; |
---|
2166 | var _285=this.fired; |
---|
2167 | var res=this.results[_285]; |
---|
2168 | var self=this; |
---|
2169 | var cb=null; |
---|
2170 | while(_284.length>0&&this.paused===0){ |
---|
2171 | var pair=_284.shift(); |
---|
2172 | var f=pair[_285]; |
---|
2173 | if(f===null){ |
---|
2174 | continue; |
---|
2175 | } |
---|
2176 | try{ |
---|
2177 | res=f(res); |
---|
2178 | _285=((res instanceof Error)?1:0); |
---|
2179 | if(res instanceof MochiKit.Async.Deferred){ |
---|
2180 | cb=function(res){ |
---|
2181 | self._continue(res); |
---|
2182 | }; |
---|
2183 | this._pause(); |
---|
2184 | } |
---|
2185 | } |
---|
2186 | catch(err){ |
---|
2187 | _285=1; |
---|
2188 | if(!(err instanceof Error)){ |
---|
2189 | err=new MochiKit.Async.GenericError(err); |
---|
2190 | } |
---|
2191 | res=err; |
---|
2192 | } |
---|
2193 | } |
---|
2194 | this.fired=_285; |
---|
2195 | this.results[_285]=res; |
---|
2196 | if(cb&&this.paused){ |
---|
2197 | res.addBoth(cb); |
---|
2198 | res.chained=true; |
---|
2199 | } |
---|
2200 | }}; |
---|
2201 | MochiKit.Base.update(MochiKit.Async,{evalJSONRequest:function(){ |
---|
2202 | return eval("("+arguments[0].responseText+")"); |
---|
2203 | },succeed:function(_287){ |
---|
2204 | var d=new MochiKit.Async.Deferred(); |
---|
2205 | d.callback.apply(d,arguments); |
---|
2206 | return d; |
---|
2207 | },fail:function(_288){ |
---|
2208 | var d=new MochiKit.Async.Deferred(); |
---|
2209 | d.errback.apply(d,arguments); |
---|
2210 | return d; |
---|
2211 | },getXMLHttpRequest:function(){ |
---|
2212 | var self=arguments.callee; |
---|
2213 | if(!self.XMLHttpRequest){ |
---|
2214 | var _289=[function(){ |
---|
2215 | return new XMLHttpRequest(); |
---|
2216 | },function(){ |
---|
2217 | return new ActiveXObject("Msxml2.XMLHTTP"); |
---|
2218 | },function(){ |
---|
2219 | return new ActiveXObject("Microsoft.XMLHTTP"); |
---|
2220 | },function(){ |
---|
2221 | return new ActiveXObject("Msxml2.XMLHTTP.4.0"); |
---|
2222 | },function(){ |
---|
2223 | throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest"); |
---|
2224 | }]; |
---|
2225 | for(var i=0;i<_289.length;i++){ |
---|
2226 | var func=_289[i]; |
---|
2227 | try{ |
---|
2228 | self.XMLHttpRequest=func; |
---|
2229 | return func(); |
---|
2230 | } |
---|
2231 | catch(e){ |
---|
2232 | } |
---|
2233 | } |
---|
2234 | } |
---|
2235 | return self.XMLHttpRequest(); |
---|
2236 | },_nothing:function(){ |
---|
2237 | },_xhr_onreadystatechange:function(d){ |
---|
2238 | if(this.readyState==4){ |
---|
2239 | try{ |
---|
2240 | this.onreadystatechange=null; |
---|
2241 | } |
---|
2242 | catch(e){ |
---|
2243 | try{ |
---|
2244 | this.onreadystatechange=MochiKit.Async._nothing; |
---|
2245 | } |
---|
2246 | catch(e){ |
---|
2247 | } |
---|
2248 | } |
---|
2249 | var _290=null; |
---|
2250 | try{ |
---|
2251 | _290=this.status; |
---|
2252 | if(!_290&&MochiKit.Base.isNotEmpty(this.responseText)){ |
---|
2253 | _290=304; |
---|
2254 | } |
---|
2255 | } |
---|
2256 | catch(e){ |
---|
2257 | } |
---|
2258 | if(_290==200||_290==304){ |
---|
2259 | d.callback(this); |
---|
2260 | }else{ |
---|
2261 | var err=new MochiKit.Async.XMLHttpRequestError(this,"Request failed"); |
---|
2262 | if(err.number){ |
---|
2263 | d.errback(err); |
---|
2264 | }else{ |
---|
2265 | d.errback(err); |
---|
2266 | } |
---|
2267 | } |
---|
2268 | } |
---|
2269 | },_xhr_canceller:function(req){ |
---|
2270 | try{ |
---|
2271 | req.onreadystatechange=null; |
---|
2272 | } |
---|
2273 | catch(e){ |
---|
2274 | try{ |
---|
2275 | req.onreadystatechange=MochiKit.Async._nothing; |
---|
2276 | } |
---|
2277 | catch(e){ |
---|
2278 | } |
---|
2279 | } |
---|
2280 | req.abort(); |
---|
2281 | },sendXMLHttpRequest:function(req,_293){ |
---|
2282 | if(typeof (_293)=="undefined"||_293===null){ |
---|
2283 | _293=""; |
---|
2284 | } |
---|
2285 | var m=MochiKit.Base; |
---|
2286 | var self=MochiKit.Async; |
---|
2287 | var d=new self.Deferred(m.partial(self._xhr_canceller,req)); |
---|
2288 | try{ |
---|
2289 | req.onreadystatechange=m.bind(self._xhr_onreadystatechange,req,d); |
---|
2290 | req.send(_293); |
---|
2291 | } |
---|
2292 | catch(e){ |
---|
2293 | try{ |
---|
2294 | req.onreadystatechange=null; |
---|
2295 | } |
---|
2296 | catch(ignore){ |
---|
2297 | } |
---|
2298 | d.errback(e); |
---|
2299 | } |
---|
2300 | return d; |
---|
2301 | },doSimpleXMLHttpRequest:function(url){ |
---|
2302 | var self=MochiKit.Async; |
---|
2303 | var req=self.getXMLHttpRequest(); |
---|
2304 | if(arguments.length>1){ |
---|
2305 | var m=MochiKit.Base; |
---|
2306 | var qs=m.queryString.apply(null,m.extend(null,arguments,1)); |
---|
2307 | if(qs){ |
---|
2308 | url+="?"+qs; |
---|
2309 | } |
---|
2310 | } |
---|
2311 | req.open("GET",url,true); |
---|
2312 | return self.sendXMLHttpRequest(req); |
---|
2313 | },loadJSONDoc:function(url){ |
---|
2314 | var self=MochiKit.Async; |
---|
2315 | var d=self.doSimpleXMLHttpRequest.apply(self,arguments); |
---|
2316 | d=d.addCallback(self.evalJSONRequest); |
---|
2317 | return d; |
---|
2318 | },wait:function(_296,_297){ |
---|
2319 | var d=new MochiKit.Async.Deferred(); |
---|
2320 | var m=MochiKit.Base; |
---|
2321 | if(typeof (_297)!="undefined"){ |
---|
2322 | d.addCallback(function(){ |
---|
2323 | return _297; |
---|
2324 | }); |
---|
2325 | } |
---|
2326 | var _298=setTimeout(m.bind("callback",d),Math.floor(_296*1000)); |
---|
2327 | d.canceller=function(){ |
---|
2328 | try{ |
---|
2329 | clearTimeout(_298); |
---|
2330 | } |
---|
2331 | catch(e){ |
---|
2332 | } |
---|
2333 | }; |
---|
2334 | return d; |
---|
2335 | },callLater:function(_299,func){ |
---|
2336 | var m=MochiKit.Base; |
---|
2337 | var _300=m.partial.apply(m,m.extend(null,arguments,1)); |
---|
2338 | return MochiKit.Async.wait(_299).addCallback(function(res){ |
---|
2339 | return _300(); |
---|
2340 | }); |
---|
2341 | }}); |
---|
2342 | MochiKit.Async.DeferredLock=function(){ |
---|
2343 | this.waiting=[]; |
---|
2344 | this.locked=false; |
---|
2345 | this.id=this._nextId(); |
---|
2346 | }; |
---|
2347 | MochiKit.Async.DeferredLock.prototype={__class__:MochiKit.Async.DeferredLock,acquire:function(){ |
---|
2348 | d=new MochiKit.Async.Deferred(); |
---|
2349 | if(this.locked){ |
---|
2350 | this.waiting.push(d); |
---|
2351 | }else{ |
---|
2352 | this.locked=true; |
---|
2353 | d.callback(this); |
---|
2354 | } |
---|
2355 | return d; |
---|
2356 | },release:function(){ |
---|
2357 | if(!this.locked){ |
---|
2358 | throw TypeError("Tried to release an unlocked DeferredLock"); |
---|
2359 | } |
---|
2360 | this.locked=false; |
---|
2361 | if(this.waiting.length>0){ |
---|
2362 | this.locked=true; |
---|
2363 | this.waiting.shift().callback(this); |
---|
2364 | } |
---|
2365 | },_nextId:MochiKit.Base.counter(),repr:function(){ |
---|
2366 | var _301; |
---|
2367 | if(this.locked){ |
---|
2368 | _301="locked, "+this.waiting.length+" waiting"; |
---|
2369 | }else{ |
---|
2370 | _301="unlocked"; |
---|
2371 | } |
---|
2372 | return "DeferredLock("+this.id+", "+_301+")"; |
---|
2373 | },toString:MochiKit.Base.forwardCall("repr")}; |
---|
2374 | MochiKit.Async.DeferredList=function(list,_303,_304,_305,_306){ |
---|
2375 | this.list=list; |
---|
2376 | this.resultList=new Array(this.list.length); |
---|
2377 | this.chain=[]; |
---|
2378 | this.id=this._nextId(); |
---|
2379 | this.fired=-1; |
---|
2380 | this.paused=0; |
---|
2381 | this.results=[null,null]; |
---|
2382 | this.canceller=_306; |
---|
2383 | this.silentlyCancelled=false; |
---|
2384 | if(this.list.length===0&&!_303){ |
---|
2385 | this.callback(this.resultList); |
---|
2386 | } |
---|
2387 | this.finishedCount=0; |
---|
2388 | this.fireOnOneCallback=_303; |
---|
2389 | this.fireOnOneErrback=_304; |
---|
2390 | this.consumeErrors=_305; |
---|
2391 | var _307=0; |
---|
2392 | MochiKit.Base.map(MochiKit.Base.bind(function(d){ |
---|
2393 | d.addCallback(MochiKit.Base.bind(this._cbDeferred,this),_307,true); |
---|
2394 | d.addErrback(MochiKit.Base.bind(this._cbDeferred,this),_307,false); |
---|
2395 | _307+=1; |
---|
2396 | },this),this.list); |
---|
2397 | }; |
---|
2398 | MochiKit.Base.update(MochiKit.Async.DeferredList.prototype,MochiKit.Async.Deferred.prototype); |
---|
2399 | MochiKit.Base.update(MochiKit.Async.DeferredList.prototype,{_cbDeferred:function(_308,_309,_310){ |
---|
2400 | this.resultList[_308]=[_309,_310]; |
---|
2401 | this.finishedCount+=1; |
---|
2402 | if(this.fired!==0){ |
---|
2403 | if(_309&&this.fireOnOneCallback){ |
---|
2404 | this.callback([_308,_310]); |
---|
2405 | }else{ |
---|
2406 | if(!_309&&this.fireOnOneErrback){ |
---|
2407 | this.errback(_310); |
---|
2408 | }else{ |
---|
2409 | if(this.finishedCount==this.list.length){ |
---|
2410 | this.callback(this.resultList); |
---|
2411 | } |
---|
2412 | } |
---|
2413 | } |
---|
2414 | } |
---|
2415 | if(!_309&&this.consumeErrors){ |
---|
2416 | _310=null; |
---|
2417 | } |
---|
2418 | return _310; |
---|
2419 | }}); |
---|
2420 | MochiKit.Async.gatherResults=function(_311){ |
---|
2421 | var d=new MochiKit.Async.DeferredList(_311,false,true,false); |
---|
2422 | d.addCallback(function(_312){ |
---|
2423 | var ret=[]; |
---|
2424 | for(var i=0;i<_312.length;i++){ |
---|
2425 | ret.push(_312[i][1]); |
---|
2426 | } |
---|
2427 | return ret; |
---|
2428 | }); |
---|
2429 | return d; |
---|
2430 | }; |
---|
2431 | MochiKit.Async.maybeDeferred=function(func){ |
---|
2432 | var self=MochiKit.Async; |
---|
2433 | var _313; |
---|
2434 | try{ |
---|
2435 | var r=func.apply(null,MochiKit.Base.extend([],arguments,1)); |
---|
2436 | if(r instanceof self.Deferred){ |
---|
2437 | _313=r; |
---|
2438 | }else{ |
---|
2439 | if(r instanceof Error){ |
---|
2440 | _313=self.fail(r); |
---|
2441 | }else{ |
---|
2442 | _313=self.succeed(r); |
---|
2443 | } |
---|
2444 | } |
---|
2445 | } |
---|
2446 | catch(e){ |
---|
2447 | _313=self.fail(e); |
---|
2448 | } |
---|
2449 | return _313; |
---|
2450 | }; |
---|
2451 | MochiKit.Async.EXPORT=["AlreadyCalledError","CancelledError","BrowserComplianceError","GenericError","XMLHttpRequestError","Deferred","succeed","fail","getXMLHttpRequest","doSimpleXMLHttpRequest","loadJSONDoc","wait","callLater","sendXMLHttpRequest","DeferredLock","DeferredList","gatherResults","maybeDeferred"]; |
---|
2452 | MochiKit.Async.EXPORT_OK=["evalJSONRequest"]; |
---|
2453 | MochiKit.Async.__new__=function(){ |
---|
2454 | var m=MochiKit.Base; |
---|
2455 | var ne=m.partial(m._newNamedError,this); |
---|
2456 | ne("AlreadyCalledError",function(_316){ |
---|
2457 | this.deferred=_316; |
---|
2458 | }); |
---|
2459 | ne("CancelledError",function(_317){ |
---|
2460 | this.deferred=_317; |
---|
2461 | }); |
---|
2462 | ne("BrowserComplianceError",function(msg){ |
---|
2463 | this.message=msg; |
---|
2464 | }); |
---|
2465 | ne("GenericError",function(msg){ |
---|
2466 | this.message=msg; |
---|
2467 | }); |
---|
2468 | ne("XMLHttpRequestError",function(req,msg){ |
---|
2469 | this.req=req; |
---|
2470 | this.message=msg; |
---|
2471 | try{ |
---|
2472 | this.number=req.status; |
---|
2473 | } |
---|
2474 | catch(e){ |
---|
2475 | } |
---|
2476 | }); |
---|
2477 | this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; |
---|
2478 | m.nameFunctions(this); |
---|
2479 | }; |
---|
2480 | MochiKit.Async.__new__(); |
---|
2481 | MochiKit.Base._exportSymbols(this,MochiKit.Async); |
---|
2482 | if(typeof (dojo)!="undefined"){ |
---|
2483 | dojo.provide("MochiKit.DOM"); |
---|
2484 | dojo.require("MochiKit.Iter"); |
---|
2485 | } |
---|
2486 | if(typeof (JSAN)!="undefined"){ |
---|
2487 | JSAN.use("MochiKit.Iter",[]); |
---|
2488 | } |
---|
2489 | try{ |
---|
2490 | if(typeof (MochiKit.Iter)=="undefined"){ |
---|
2491 | throw ""; |
---|
2492 | } |
---|
2493 | } |
---|
2494 | catch(e){ |
---|
2495 | throw "MochiKit.DOM depends on MochiKit.Iter!"; |
---|
2496 | } |
---|
2497 | if(typeof (MochiKit.DOM)=="undefined"){ |
---|
2498 | MochiKit.DOM={}; |
---|
2499 | } |
---|
2500 | MochiKit.DOM.NAME="MochiKit.DOM"; |
---|
2501 | MochiKit.DOM.VERSION="1.3.1"; |
---|
2502 | MochiKit.DOM.__repr__=function(){ |
---|
2503 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
2504 | }; |
---|
2505 | MochiKit.DOM.toString=function(){ |
---|
2506 | return this.__repr__(); |
---|
2507 | }; |
---|
2508 | MochiKit.DOM.EXPORT=["formContents","currentWindow","currentDocument","withWindow","withDocument","registerDOMConverter","coerceToDOM","createDOM","createDOMFunc","getNodeAttribute","setNodeAttribute","updateNodeAttributes","appendChildNodes","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","$","computedStyle","getElementsByTagAndClassName","addToCallStack","addLoadEvent","focusOnLoad","setElementClass","toggleElementClass","addElementClass","removeElementClass","swapElementClass","hasElementClass","escapeHTML","toHTML","emitHTML","setDisplayForElement","hideElement","showElement","scrapeText","elementDimensions","elementPosition","setElementDimensions","setElementPosition","getViewportDimensions","setOpacity"]; |
---|
2509 | MochiKit.DOM.EXPORT_OK=["domConverters"]; |
---|
2510 | MochiKit.DOM.Dimensions=function(w,h){ |
---|
2511 | this.w=w; |
---|
2512 | this.h=h; |
---|
2513 | }; |
---|
2514 | MochiKit.DOM.Dimensions.prototype.repr=function(){ |
---|
2515 | var repr=MochiKit.Base.repr; |
---|
2516 | return "{w: "+repr(this.w)+", h: "+repr(this.h)+"}"; |
---|
2517 | }; |
---|
2518 | MochiKit.DOM.Coordinates=function(x,y){ |
---|
2519 | this.x=x; |
---|
2520 | this.y=y; |
---|
2521 | }; |
---|
2522 | MochiKit.DOM.Coordinates.prototype.repr=function(){ |
---|
2523 | var repr=MochiKit.Base.repr; |
---|
2524 | return "{x: "+repr(this.x)+", y: "+repr(this.y)+"}"; |
---|
2525 | }; |
---|
2526 | MochiKit.DOM.Coordinates.prototype.toString=function(){ |
---|
2527 | return this.repr(); |
---|
2528 | }; |
---|
2529 | MochiKit.Base.update(MochiKit.DOM,{setOpacity:function(elem,o){ |
---|
2530 | elem=MochiKit.DOM.getElement(elem); |
---|
2531 | MochiKit.DOM.updateNodeAttributes(elem,{"style":{"opacity":o,"-moz-opacity":o,"-khtml-opacity":o,"filter":" alpha(opacity="+(o*100)+")"}}); |
---|
2532 | },getViewportDimensions:function(){ |
---|
2533 | var d=new MochiKit.DOM.Dimensions(); |
---|
2534 | var w=MochiKit.DOM._window; |
---|
2535 | var b=MochiKit.DOM._document.body; |
---|
2536 | if(w.innerWidth){ |
---|
2537 | d.w=w.innerWidth; |
---|
2538 | d.h=w.innerHeight; |
---|
2539 | }else{ |
---|
2540 | if(b.parentElement.clientWidth){ |
---|
2541 | d.w=b.parentElement.clientWidth; |
---|
2542 | d.h=b.parentElement.clientHeight; |
---|
2543 | }else{ |
---|
2544 | if(b&&b.clientWidth){ |
---|
2545 | d.w=b.clientWidth; |
---|
2546 | d.h=b.clientHeight; |
---|
2547 | } |
---|
2548 | } |
---|
2549 | } |
---|
2550 | return d; |
---|
2551 | },elementDimensions:function(elem){ |
---|
2552 | var self=MochiKit.DOM; |
---|
2553 | if(typeof (elem.w)=="number"||typeof (elem.h)=="number"){ |
---|
2554 | return new self.Dimensions(elem.w||0,elem.h||0); |
---|
2555 | } |
---|
2556 | elem=self.getElement(elem); |
---|
2557 | if(!elem){ |
---|
2558 | return undefined; |
---|
2559 | } |
---|
2560 | if(self.computedStyle(elem,"display")!="none"){ |
---|
2561 | return new self.Dimensions(elem.offsetWidth||0,elem.offsetHeight||0); |
---|
2562 | } |
---|
2563 | var s=elem.style; |
---|
2564 | var _322=s.visibility; |
---|
2565 | var _323=s.position; |
---|
2566 | s.visibility="hidden"; |
---|
2567 | s.position="absolute"; |
---|
2568 | s.display=""; |
---|
2569 | var _324=elem.offsetWidth; |
---|
2570 | var _325=elem.offsetHeight; |
---|
2571 | s.display="none"; |
---|
2572 | s.position=_323; |
---|
2573 | s.visibility=_322; |
---|
2574 | return new self.Dimensions(_324,_325); |
---|
2575 | },elementPosition:function(elem,_326){ |
---|
2576 | var self=MochiKit.DOM; |
---|
2577 | elem=self.getElement(elem); |
---|
2578 | if(!elem){ |
---|
2579 | return undefined; |
---|
2580 | } |
---|
2581 | var c=new self.Coordinates(0,0); |
---|
2582 | if(elem.x&&elem.y){ |
---|
2583 | c.x+=elem.x||0; |
---|
2584 | c.y+=elem.y||0; |
---|
2585 | return c; |
---|
2586 | }else{ |
---|
2587 | if(elem.parentNode===null||self.computedStyle(elem,"display")=="none"){ |
---|
2588 | return undefined; |
---|
2589 | } |
---|
2590 | } |
---|
2591 | var box=null; |
---|
2592 | var _329=null; |
---|
2593 | var d=MochiKit.DOM._document; |
---|
2594 | var de=d.documentElement; |
---|
2595 | var b=d.body; |
---|
2596 | if(elem.getBoundingClientRect){ |
---|
2597 | box=elem.getBoundingClientRect(); |
---|
2598 | c.x+=box.left+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||b.clientLeft); |
---|
2599 | c.y+=box.top+(de.scrollTop||b.scrollTop)-(de.clientTop||b.clientTop); |
---|
2600 | }else{ |
---|
2601 | if(d.getBoxObjectFor){ |
---|
2602 | box=d.getBoxObjectFor(elem); |
---|
2603 | c.x+=box.x; |
---|
2604 | c.y+=box.y; |
---|
2605 | }else{ |
---|
2606 | if(elem.offsetParent){ |
---|
2607 | c.x+=elem.offsetLeft; |
---|
2608 | c.y+=elem.offsetTop; |
---|
2609 | _329=elem.offsetParent; |
---|
2610 | if(_329!=elem){ |
---|
2611 | while(_329){ |
---|
2612 | c.x+=_329.offsetLeft; |
---|
2613 | c.y+=_329.offsetTop; |
---|
2614 | _329=_329.offsetParent; |
---|
2615 | } |
---|
2616 | } |
---|
2617 | var ua=navigator.userAgent.toLowerCase(); |
---|
2618 | if((typeof (opera)!="undefined"&&parseFloat(opera.version())<9)||(ua.indexOf("safari")!=-1&&self.computedStyle(elem,"position")=="absolute")){ |
---|
2619 | c.x-=b.offsetLeft; |
---|
2620 | c.y-=b.offsetTop; |
---|
2621 | } |
---|
2622 | } |
---|
2623 | } |
---|
2624 | } |
---|
2625 | if(typeof (_326)!="undefined"){ |
---|
2626 | _326=arguments.callee(_326); |
---|
2627 | if(_326){ |
---|
2628 | c.x-=(_326.x||0); |
---|
2629 | c.y-=(_326.y||0); |
---|
2630 | } |
---|
2631 | } |
---|
2632 | if(elem.parentNode){ |
---|
2633 | _329=elem.parentNode; |
---|
2634 | }else{ |
---|
2635 | _329=null; |
---|
2636 | } |
---|
2637 | while(_329&&_329.tagName!="BODY"&&_329.tagName!="HTML"){ |
---|
2638 | c.x-=_329.scrollLeft; |
---|
2639 | c.y-=_329.scrollTop; |
---|
2640 | if(_329.parentNode){ |
---|
2641 | _329=_329.parentNode; |
---|
2642 | }else{ |
---|
2643 | _329=null; |
---|
2644 | } |
---|
2645 | } |
---|
2646 | return c; |
---|
2647 | },setElementDimensions:function(elem,_332,_333){ |
---|
2648 | elem=MochiKit.DOM.getElement(elem); |
---|
2649 | if(typeof (_333)=="undefined"){ |
---|
2650 | _333="px"; |
---|
2651 | } |
---|
2652 | MochiKit.DOM.updateNodeAttributes(elem,{"style":{"width":_332.w+_333,"height":_332.h+_333}}); |
---|
2653 | },setElementPosition:function(elem,_334,_335){ |
---|
2654 | elem=MochiKit.DOM.getElement(elem); |
---|
2655 | if(typeof (_335)=="undefined"){ |
---|
2656 | _335="px"; |
---|
2657 | } |
---|
2658 | MochiKit.DOM.updateNodeAttributes(elem,{"style":{"left":_334.x+_335,"top":_334.y+_335}}); |
---|
2659 | },currentWindow:function(){ |
---|
2660 | return MochiKit.DOM._window; |
---|
2661 | },currentDocument:function(){ |
---|
2662 | return MochiKit.DOM._document; |
---|
2663 | },withWindow:function(win,func){ |
---|
2664 | var self=MochiKit.DOM; |
---|
2665 | var _337=self._document; |
---|
2666 | var _338=self._win; |
---|
2667 | var rval; |
---|
2668 | try{ |
---|
2669 | self._window=win; |
---|
2670 | self._document=win.document; |
---|
2671 | rval=func(); |
---|
2672 | } |
---|
2673 | catch(e){ |
---|
2674 | self._window=_338; |
---|
2675 | self._document=_337; |
---|
2676 | throw e; |
---|
2677 | } |
---|
2678 | self._window=_338; |
---|
2679 | self._document=_337; |
---|
2680 | return rval; |
---|
2681 | },formContents:function(elem){ |
---|
2682 | var _339=[]; |
---|
2683 | var _340=[]; |
---|
2684 | var m=MochiKit.Base; |
---|
2685 | var self=MochiKit.DOM; |
---|
2686 | if(typeof (elem)=="undefined"||elem===null){ |
---|
2687 | elem=self._document; |
---|
2688 | }else{ |
---|
2689 | elem=self.getElement(elem); |
---|
2690 | } |
---|
2691 | m.nodeWalk(elem,function(elem){ |
---|
2692 | var name=elem.name; |
---|
2693 | if(m.isNotEmpty(name)){ |
---|
2694 | var _341=elem.nodeName; |
---|
2695 | if(_341=="INPUT"&&(elem.type=="radio"||elem.type=="checkbox")&&!elem.checked){ |
---|
2696 | return null; |
---|
2697 | } |
---|
2698 | if(_341=="SELECT"){ |
---|
2699 | if(elem.selectedIndex>=0){ |
---|
2700 | var opt=elem.options[elem.selectedIndex]; |
---|
2701 | _339.push(name); |
---|
2702 | _340.push((opt.value)?opt.value:opt.text); |
---|
2703 | return null; |
---|
2704 | } |
---|
2705 | _339.push(name); |
---|
2706 | _340.push(""); |
---|
2707 | return null; |
---|
2708 | } |
---|
2709 | if(_341=="FORM"||_341=="P"||_341=="SPAN"||_341=="DIV"){ |
---|
2710 | return elem.childNodes; |
---|
2711 | } |
---|
2712 | _339.push(name); |
---|
2713 | _340.push(elem.value||""); |
---|
2714 | return null; |
---|
2715 | } |
---|
2716 | return elem.childNodes; |
---|
2717 | }); |
---|
2718 | return [_339,_340]; |
---|
2719 | },withDocument:function(doc,func){ |
---|
2720 | var self=MochiKit.DOM; |
---|
2721 | var _344=self._document; |
---|
2722 | var rval; |
---|
2723 | try{ |
---|
2724 | self._document=doc; |
---|
2725 | rval=func(); |
---|
2726 | } |
---|
2727 | catch(e){ |
---|
2728 | self._document=_344; |
---|
2729 | throw e; |
---|
2730 | } |
---|
2731 | self._document=_344; |
---|
2732 | return rval; |
---|
2733 | },registerDOMConverter:function(name,_345,wrap,_346){ |
---|
2734 | MochiKit.DOM.domConverters.register(name,_345,wrap,_346); |
---|
2735 | },coerceToDOM:function(node,ctx){ |
---|
2736 | var im=MochiKit.Iter; |
---|
2737 | var self=MochiKit.DOM; |
---|
2738 | var iter=im.iter; |
---|
2739 | var _350=im.repeat; |
---|
2740 | var imap=im.imap; |
---|
2741 | var _352=self.domConverters; |
---|
2742 | var _353=self.coerceToDOM; |
---|
2743 | var _354=MochiKit.Base.NotFound; |
---|
2744 | while(true){ |
---|
2745 | if(typeof (node)=="undefined"||node===null){ |
---|
2746 | return null; |
---|
2747 | } |
---|
2748 | if(typeof (node.nodeType)!="undefined"&&node.nodeType>0){ |
---|
2749 | return node; |
---|
2750 | } |
---|
2751 | if(typeof (node)=="number"||typeof (node)=="boolean"){ |
---|
2752 | node=node.toString(); |
---|
2753 | } |
---|
2754 | if(typeof (node)=="string"){ |
---|
2755 | return self._document.createTextNode(node); |
---|
2756 | } |
---|
2757 | if(typeof (node.toDOM)=="function"){ |
---|
2758 | node=node.toDOM(ctx); |
---|
2759 | continue; |
---|
2760 | } |
---|
2761 | if(typeof (node)=="function"){ |
---|
2762 | node=node(ctx); |
---|
2763 | continue; |
---|
2764 | } |
---|
2765 | var _355=null; |
---|
2766 | try{ |
---|
2767 | _355=iter(node); |
---|
2768 | } |
---|
2769 | catch(e){ |
---|
2770 | } |
---|
2771 | if(_355){ |
---|
2772 | return imap(_353,_355,_350(ctx)); |
---|
2773 | } |
---|
2774 | try{ |
---|
2775 | node=_352.match(node,ctx); |
---|
2776 | continue; |
---|
2777 | } |
---|
2778 | catch(e){ |
---|
2779 | if(e!=_354){ |
---|
2780 | throw e; |
---|
2781 | } |
---|
2782 | } |
---|
2783 | return self._document.createTextNode(node.toString()); |
---|
2784 | } |
---|
2785 | return undefined; |
---|
2786 | },setNodeAttribute:function(node,attr,_357){ |
---|
2787 | var o={}; |
---|
2788 | o[attr]=_357; |
---|
2789 | try{ |
---|
2790 | return MochiKit.DOM.updateNodeAttributes(node,o); |
---|
2791 | } |
---|
2792 | catch(e){ |
---|
2793 | } |
---|
2794 | return null; |
---|
2795 | },getNodeAttribute:function(node,attr){ |
---|
2796 | var self=MochiKit.DOM; |
---|
2797 | var _358=self.attributeArray.renames[attr]; |
---|
2798 | node=self.getElement(node); |
---|
2799 | try{ |
---|
2800 | if(_358){ |
---|
2801 | return node[_358]; |
---|
2802 | } |
---|
2803 | return node.getAttribute(attr); |
---|
2804 | } |
---|
2805 | catch(e){ |
---|
2806 | } |
---|
2807 | return null; |
---|
2808 | },updateNodeAttributes:function(node,_359){ |
---|
2809 | var elem=node; |
---|
2810 | var self=MochiKit.DOM; |
---|
2811 | if(typeof (node)=="string"){ |
---|
2812 | elem=self.getElement(node); |
---|
2813 | } |
---|
2814 | if(_359){ |
---|
2815 | var _360=MochiKit.Base.updatetree; |
---|
2816 | if(self.attributeArray.compliant){ |
---|
2817 | for(var k in _359){ |
---|
2818 | var v=_359[k]; |
---|
2819 | if(typeof (v)=="object"&&typeof (elem[k])=="object"){ |
---|
2820 | _360(elem[k],v); |
---|
2821 | }else{ |
---|
2822 | if(k.substring(0,2)=="on"){ |
---|
2823 | if(typeof (v)=="string"){ |
---|
2824 | v=new Function(v); |
---|
2825 | } |
---|
2826 | elem[k]=v; |
---|
2827 | }else{ |
---|
2828 | elem.setAttribute(k,v); |
---|
2829 | } |
---|
2830 | } |
---|
2831 | } |
---|
2832 | }else{ |
---|
2833 | var _361=self.attributeArray.renames; |
---|
2834 | for(k in _359){ |
---|
2835 | v=_359[k]; |
---|
2836 | var _362=_361[k]; |
---|
2837 | if(k=="style"&&typeof (v)=="string"){ |
---|
2838 | elem.style.cssText=v; |
---|
2839 | }else{ |
---|
2840 | if(typeof (_362)=="string"){ |
---|
2841 | elem[_362]=v; |
---|
2842 | }else{ |
---|
2843 | if(typeof (elem[k])=="object"&&typeof (v)=="object"){ |
---|
2844 | _360(elem[k],v); |
---|
2845 | }else{ |
---|
2846 | if(k.substring(0,2)=="on"){ |
---|
2847 | if(typeof (v)=="string"){ |
---|
2848 | v=new Function(v); |
---|
2849 | } |
---|
2850 | elem[k]=v; |
---|
2851 | }else{ |
---|
2852 | elem.setAttribute(k,v); |
---|
2853 | } |
---|
2854 | } |
---|
2855 | } |
---|
2856 | } |
---|
2857 | } |
---|
2858 | } |
---|
2859 | } |
---|
2860 | return elem; |
---|
2861 | },appendChildNodes:function(node){ |
---|
2862 | var elem=node; |
---|
2863 | var self=MochiKit.DOM; |
---|
2864 | if(typeof (node)=="string"){ |
---|
2865 | elem=self.getElement(node); |
---|
2866 | } |
---|
2867 | var _363=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)]; |
---|
2868 | var _364=MochiKit.Base.concat; |
---|
2869 | while(_363.length){ |
---|
2870 | var n=_363.shift(); |
---|
2871 | if(typeof (n)=="undefined"||n===null){ |
---|
2872 | }else{ |
---|
2873 | if(typeof (n.nodeType)=="number"){ |
---|
2874 | elem.appendChild(n); |
---|
2875 | }else{ |
---|
2876 | _363=_364(n,_363); |
---|
2877 | } |
---|
2878 | } |
---|
2879 | } |
---|
2880 | return elem; |
---|
2881 | },replaceChildNodes:function(node){ |
---|
2882 | var elem=node; |
---|
2883 | var self=MochiKit.DOM; |
---|
2884 | if(typeof (node)=="string"){ |
---|
2885 | elem=self.getElement(node); |
---|
2886 | arguments[0]=elem; |
---|
2887 | } |
---|
2888 | var _365; |
---|
2889 | while((_365=elem.firstChild)){ |
---|
2890 | elem.removeChild(_365); |
---|
2891 | } |
---|
2892 | if(arguments.length<2){ |
---|
2893 | return elem; |
---|
2894 | }else{ |
---|
2895 | return self.appendChildNodes.apply(this,arguments); |
---|
2896 | } |
---|
2897 | },createDOM:function(name,_366){ |
---|
2898 | var elem; |
---|
2899 | var self=MochiKit.DOM; |
---|
2900 | var m=MochiKit.Base; |
---|
2901 | if(typeof (_366)=="string"||typeof (_366)=="number"){ |
---|
2902 | var args=m.extend([name,null],arguments,1); |
---|
2903 | return arguments.callee.apply(this,args); |
---|
2904 | } |
---|
2905 | if(typeof (name)=="string"){ |
---|
2906 | if(_366&&"name" in _366&&!self.attributeArray.compliant){ |
---|
2907 | name=("<"+name+" name=\""+self.escapeHTML(_366.name)+"\">"); |
---|
2908 | } |
---|
2909 | elem=self._document.createElement(name); |
---|
2910 | }else{ |
---|
2911 | elem=name; |
---|
2912 | } |
---|
2913 | if(_366){ |
---|
2914 | self.updateNodeAttributes(elem,_366); |
---|
2915 | } |
---|
2916 | if(arguments.length<=2){ |
---|
2917 | return elem; |
---|
2918 | }else{ |
---|
2919 | var args=m.extend([elem],arguments,2); |
---|
2920 | return self.appendChildNodes.apply(this,args); |
---|
2921 | } |
---|
2922 | },createDOMFunc:function(){ |
---|
2923 | var m=MochiKit.Base; |
---|
2924 | return m.partial.apply(this,m.extend([MochiKit.DOM.createDOM],arguments)); |
---|
2925 | },swapDOM:function(dest,src){ |
---|
2926 | var self=MochiKit.DOM; |
---|
2927 | dest=self.getElement(dest); |
---|
2928 | var _369=dest.parentNode; |
---|
2929 | if(src){ |
---|
2930 | src=self.getElement(src); |
---|
2931 | _369.replaceChild(src,dest); |
---|
2932 | }else{ |
---|
2933 | _369.removeChild(dest); |
---|
2934 | } |
---|
2935 | return src; |
---|
2936 | },getElement:function(id){ |
---|
2937 | var self=MochiKit.DOM; |
---|
2938 | if(arguments.length==1){ |
---|
2939 | return ((typeof (id)=="string")?self._document.getElementById(id):id); |
---|
2940 | }else{ |
---|
2941 | return MochiKit.Base.map(self.getElement,arguments); |
---|
2942 | } |
---|
2943 | },computedStyle:function(_371,_372,_373){ |
---|
2944 | if(arguments.length==2){ |
---|
2945 | _373=_372; |
---|
2946 | } |
---|
2947 | var self=MochiKit.DOM; |
---|
2948 | var el=self.getElement(_371); |
---|
2949 | var _375=self._document; |
---|
2950 | if(!el||el==_375){ |
---|
2951 | return undefined; |
---|
2952 | } |
---|
2953 | if(el.currentStyle){ |
---|
2954 | return el.currentStyle[_372]; |
---|
2955 | } |
---|
2956 | if(typeof (_375.defaultView)=="undefined"){ |
---|
2957 | return undefined; |
---|
2958 | } |
---|
2959 | if(_375.defaultView===null){ |
---|
2960 | return undefined; |
---|
2961 | } |
---|
2962 | var _376=_375.defaultView.getComputedStyle(el,null); |
---|
2963 | if(typeof (_376)=="undefined"||_376===null){ |
---|
2964 | return undefined; |
---|
2965 | } |
---|
2966 | return _376.getPropertyValue(_373); |
---|
2967 | },getElementsByTagAndClassName:function(_377,_378,_379){ |
---|
2968 | var self=MochiKit.DOM; |
---|
2969 | if(typeof (_377)=="undefined"||_377===null){ |
---|
2970 | _377="*"; |
---|
2971 | } |
---|
2972 | if(typeof (_379)=="undefined"||_379===null){ |
---|
2973 | _379=self._document; |
---|
2974 | } |
---|
2975 | _379=self.getElement(_379); |
---|
2976 | var _380=(_379.getElementsByTagName(_377)||self._document.all); |
---|
2977 | if(typeof (_378)=="undefined"||_378===null){ |
---|
2978 | return MochiKit.Base.extend(null,_380); |
---|
2979 | } |
---|
2980 | var _381=[]; |
---|
2981 | for(var i=0;i<_380.length;i++){ |
---|
2982 | var _382=_380[i]; |
---|
2983 | var _383=_382.className.split(" "); |
---|
2984 | for(var j=0;j<_383.length;j++){ |
---|
2985 | if(_383[j]==_378){ |
---|
2986 | _381.push(_382); |
---|
2987 | break; |
---|
2988 | } |
---|
2989 | } |
---|
2990 | } |
---|
2991 | return _381; |
---|
2992 | },_newCallStack:function(path,once){ |
---|
2993 | var rval=function(){ |
---|
2994 | var _386=arguments.callee.callStack; |
---|
2995 | for(var i=0;i<_386.length;i++){ |
---|
2996 | if(_386[i].apply(this,arguments)===false){ |
---|
2997 | break; |
---|
2998 | } |
---|
2999 | } |
---|
3000 | if(once){ |
---|
3001 | try{ |
---|
3002 | this[path]=null; |
---|
3003 | } |
---|
3004 | catch(e){ |
---|
3005 | } |
---|
3006 | } |
---|
3007 | }; |
---|
3008 | rval.callStack=[]; |
---|
3009 | return rval; |
---|
3010 | },addToCallStack:function(_387,path,func,once){ |
---|
3011 | var self=MochiKit.DOM; |
---|
3012 | var _388=_387[path]; |
---|
3013 | var _389=_388; |
---|
3014 | if(!(typeof (_388)=="function"&&typeof (_388.callStack)=="object"&&_388.callStack!==null)){ |
---|
3015 | _389=self._newCallStack(path,once); |
---|
3016 | if(typeof (_388)=="function"){ |
---|
3017 | _389.callStack.push(_388); |
---|
3018 | } |
---|
3019 | _387[path]=_389; |
---|
3020 | } |
---|
3021 | _389.callStack.push(func); |
---|
3022 | },addLoadEvent:function(func){ |
---|
3023 | var self=MochiKit.DOM; |
---|
3024 | self.addToCallStack(self._window,"onload",func,true); |
---|
3025 | },focusOnLoad:function(_390){ |
---|
3026 | var self=MochiKit.DOM; |
---|
3027 | self.addLoadEvent(function(){ |
---|
3028 | _390=self.getElement(_390); |
---|
3029 | if(_390){ |
---|
3030 | _390.focus(); |
---|
3031 | } |
---|
3032 | }); |
---|
3033 | },setElementClass:function(_391,_392){ |
---|
3034 | var self=MochiKit.DOM; |
---|
3035 | var obj=self.getElement(_391); |
---|
3036 | if(self.attributeArray.compliant){ |
---|
3037 | obj.setAttribute("class",_392); |
---|
3038 | }else{ |
---|
3039 | obj.setAttribute("className",_392); |
---|
3040 | } |
---|
3041 | },toggleElementClass:function(_393){ |
---|
3042 | var self=MochiKit.DOM; |
---|
3043 | for(var i=1;i<arguments.length;i++){ |
---|
3044 | var obj=self.getElement(arguments[i]); |
---|
3045 | if(!self.addElementClass(obj,_393)){ |
---|
3046 | self.removeElementClass(obj,_393); |
---|
3047 | } |
---|
3048 | } |
---|
3049 | },addElementClass:function(_394,_395){ |
---|
3050 | var self=MochiKit.DOM; |
---|
3051 | var obj=self.getElement(_394); |
---|
3052 | var cls=obj.className; |
---|
3053 | if(cls.length===0){ |
---|
3054 | self.setElementClass(obj,_395); |
---|
3055 | return true; |
---|
3056 | } |
---|
3057 | if(cls==_395){ |
---|
3058 | return false; |
---|
3059 | } |
---|
3060 | var _397=obj.className.split(" "); |
---|
3061 | for(var i=0;i<_397.length;i++){ |
---|
3062 | if(_397[i]==_395){ |
---|
3063 | return false; |
---|
3064 | } |
---|
3065 | } |
---|
3066 | self.setElementClass(obj,cls+" "+_395); |
---|
3067 | return true; |
---|
3068 | },removeElementClass:function(_398,_399){ |
---|
3069 | var self=MochiKit.DOM; |
---|
3070 | var obj=self.getElement(_398); |
---|
3071 | var cls=obj.className; |
---|
3072 | if(cls.length===0){ |
---|
3073 | return false; |
---|
3074 | } |
---|
3075 | if(cls==_399){ |
---|
3076 | self.setElementClass(obj,""); |
---|
3077 | return true; |
---|
3078 | } |
---|
3079 | var _400=obj.className.split(" "); |
---|
3080 | for(var i=0;i<_400.length;i++){ |
---|
3081 | if(_400[i]==_399){ |
---|
3082 | _400.splice(i,1); |
---|
3083 | self.setElementClass(obj,_400.join(" ")); |
---|
3084 | return true; |
---|
3085 | } |
---|
3086 | } |
---|
3087 | return false; |
---|
3088 | },swapElementClass:function(_401,_402,_403){ |
---|
3089 | var obj=MochiKit.DOM.getElement(_401); |
---|
3090 | var res=MochiKit.DOM.removeElementClass(obj,_402); |
---|
3091 | if(res){ |
---|
3092 | MochiKit.DOM.addElementClass(obj,_403); |
---|
3093 | } |
---|
3094 | return res; |
---|
3095 | },hasElementClass:function(_404,_405){ |
---|
3096 | var obj=MochiKit.DOM.getElement(_404); |
---|
3097 | var _406=obj.className.split(" "); |
---|
3098 | for(var i=1;i<arguments.length;i++){ |
---|
3099 | var good=false; |
---|
3100 | for(var j=0;j<_406.length;j++){ |
---|
3101 | if(_406[j]==arguments[i]){ |
---|
3102 | good=true; |
---|
3103 | break; |
---|
3104 | } |
---|
3105 | } |
---|
3106 | if(!good){ |
---|
3107 | return false; |
---|
3108 | } |
---|
3109 | } |
---|
3110 | return true; |
---|
3111 | },escapeHTML:function(s){ |
---|
3112 | return s.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"); |
---|
3113 | },toHTML:function(dom){ |
---|
3114 | return MochiKit.DOM.emitHTML(dom).join(""); |
---|
3115 | },emitHTML:function(dom,lst){ |
---|
3116 | if(typeof (lst)=="undefined"||lst===null){ |
---|
3117 | lst=[]; |
---|
3118 | } |
---|
3119 | var _409=[dom]; |
---|
3120 | var self=MochiKit.DOM; |
---|
3121 | var _410=self.escapeHTML; |
---|
3122 | var _411=self.attributeArray; |
---|
3123 | while(_409.length){ |
---|
3124 | dom=_409.pop(); |
---|
3125 | if(typeof (dom)=="string"){ |
---|
3126 | lst.push(dom); |
---|
3127 | }else{ |
---|
3128 | if(dom.nodeType==1){ |
---|
3129 | lst.push("<"+dom.nodeName.toLowerCase()); |
---|
3130 | var _412=[]; |
---|
3131 | var _413=_411(dom); |
---|
3132 | for(var i=0;i<_413.length;i++){ |
---|
3133 | var a=_413[i]; |
---|
3134 | _412.push([" ",a.name,"=\"",_410(a.value),"\""]); |
---|
3135 | } |
---|
3136 | _412.sort(); |
---|
3137 | for(i=0;i<_412.length;i++){ |
---|
3138 | var _414=_412[i]; |
---|
3139 | for(var j=0;j<_414.length;j++){ |
---|
3140 | lst.push(_414[j]); |
---|
3141 | } |
---|
3142 | } |
---|
3143 | if(dom.hasChildNodes()){ |
---|
3144 | lst.push(">"); |
---|
3145 | _409.push("</"+dom.nodeName.toLowerCase()+">"); |
---|
3146 | var _415=dom.childNodes; |
---|
3147 | for(i=_415.length-1;i>=0;i--){ |
---|
3148 | _409.push(_415[i]); |
---|
3149 | } |
---|
3150 | }else{ |
---|
3151 | lst.push("/>"); |
---|
3152 | } |
---|
3153 | }else{ |
---|
3154 | if(dom.nodeType==3){ |
---|
3155 | lst.push(_410(dom.nodeValue)); |
---|
3156 | } |
---|
3157 | } |
---|
3158 | } |
---|
3159 | } |
---|
3160 | return lst; |
---|
3161 | },setDisplayForElement:function(_416,_417){ |
---|
3162 | var m=MochiKit.Base; |
---|
3163 | var _418=m.extend(null,arguments,1); |
---|
3164 | MochiKit.Iter.forEach(m.filter(null,m.map(MochiKit.DOM.getElement,_418)),function(_417){ |
---|
3165 | _417.style.display=_416; |
---|
3166 | }); |
---|
3167 | },scrapeText:function(node,_419){ |
---|
3168 | var rval=[]; |
---|
3169 | (function(node){ |
---|
3170 | var cn=node.childNodes; |
---|
3171 | if(cn){ |
---|
3172 | for(var i=0;i<cn.length;i++){ |
---|
3173 | arguments.callee.call(this,cn[i]); |
---|
3174 | } |
---|
3175 | } |
---|
3176 | var _421=node.nodeValue; |
---|
3177 | if(typeof (_421)=="string"){ |
---|
3178 | rval.push(_421); |
---|
3179 | } |
---|
3180 | })(MochiKit.DOM.getElement(node)); |
---|
3181 | if(_419){ |
---|
3182 | return rval; |
---|
3183 | }else{ |
---|
3184 | return rval.join(""); |
---|
3185 | } |
---|
3186 | },__new__:function(win){ |
---|
3187 | var m=MochiKit.Base; |
---|
3188 | this._document=document; |
---|
3189 | this._window=win; |
---|
3190 | this.domConverters=new m.AdapterRegistry(); |
---|
3191 | var _422=this._document.createElement("span"); |
---|
3192 | var _423; |
---|
3193 | if(_422&&_422.attributes&&_422.attributes.length>0){ |
---|
3194 | var _424=m.filter; |
---|
3195 | _423=function(node){ |
---|
3196 | return _424(_423.ignoreAttrFilter,node.attributes); |
---|
3197 | }; |
---|
3198 | _423.ignoreAttr={}; |
---|
3199 | MochiKit.Iter.forEach(_422.attributes,function(a){ |
---|
3200 | _423.ignoreAttr[a.name]=a.value; |
---|
3201 | }); |
---|
3202 | _423.ignoreAttrFilter=function(a){ |
---|
3203 | return (_423.ignoreAttr[a.name]!=a.value); |
---|
3204 | }; |
---|
3205 | _423.compliant=false; |
---|
3206 | _423.renames={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor"}; |
---|
3207 | }else{ |
---|
3208 | _423=function(node){ |
---|
3209 | return node.attributes; |
---|
3210 | }; |
---|
3211 | _423.compliant=true; |
---|
3212 | _423.renames={}; |
---|
3213 | } |
---|
3214 | this.attributeArray=_423; |
---|
3215 | var _425=this.createDOMFunc; |
---|
3216 | this.UL=_425("ul"); |
---|
3217 | this.OL=_425("ol"); |
---|
3218 | this.LI=_425("li"); |
---|
3219 | this.TD=_425("td"); |
---|
3220 | this.TR=_425("tr"); |
---|
3221 | this.TBODY=_425("tbody"); |
---|
3222 | this.THEAD=_425("thead"); |
---|
3223 | this.TFOOT=_425("tfoot"); |
---|
3224 | this.TABLE=_425("table"); |
---|
3225 | this.TH=_425("th"); |
---|
3226 | this.INPUT=_425("input"); |
---|
3227 | this.SPAN=_425("span"); |
---|
3228 | this.A=_425("a"); |
---|
3229 | this.DIV=_425("div"); |
---|
3230 | this.IMG=_425("img"); |
---|
3231 | this.BUTTON=_425("button"); |
---|
3232 | this.TT=_425("tt"); |
---|
3233 | this.PRE=_425("pre"); |
---|
3234 | this.H1=_425("h1"); |
---|
3235 | this.H2=_425("h2"); |
---|
3236 | this.H3=_425("h3"); |
---|
3237 | this.BR=_425("br"); |
---|
3238 | this.HR=_425("hr"); |
---|
3239 | this.LABEL=_425("label"); |
---|
3240 | this.TEXTAREA=_425("textarea"); |
---|
3241 | this.FORM=_425("form"); |
---|
3242 | this.P=_425("p"); |
---|
3243 | this.SELECT=_425("select"); |
---|
3244 | this.OPTION=_425("option"); |
---|
3245 | this.OPTGROUP=_425("optgroup"); |
---|
3246 | this.LEGEND=_425("legend"); |
---|
3247 | this.FIELDSET=_425("fieldset"); |
---|
3248 | this.STRONG=_425("strong"); |
---|
3249 | this.CANVAS=_425("canvas"); |
---|
3250 | this.hideElement=m.partial(this.setDisplayForElement,"none"); |
---|
3251 | this.showElement=m.partial(this.setDisplayForElement,"block"); |
---|
3252 | this.removeElement=this.swapDOM; |
---|
3253 | this.$=this.getElement; |
---|
3254 | this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; |
---|
3255 | m.nameFunctions(this); |
---|
3256 | }}); |
---|
3257 | MochiKit.DOM.__new__(((typeof (window)=="undefined")?this:window)); |
---|
3258 | if(!MochiKit.__compat__){ |
---|
3259 | withWindow=MochiKit.DOM.withWindow; |
---|
3260 | withDocument=MochiKit.DOM.withDocument; |
---|
3261 | } |
---|
3262 | MochiKit.Base._exportSymbols(this,MochiKit.DOM); |
---|
3263 | if(typeof (dojo)!="undefined"){ |
---|
3264 | dojo.provide("MochiKit.LoggingPane"); |
---|
3265 | dojo.require("MochiKit.Logging"); |
---|
3266 | dojo.require("MochiKit.Base"); |
---|
3267 | } |
---|
3268 | if(typeof (JSAN)!="undefined"){ |
---|
3269 | JSAN.use("MochiKit.Logging",[]); |
---|
3270 | JSAN.use("MochiKit.Base",[]); |
---|
3271 | } |
---|
3272 | try{ |
---|
3273 | if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.Logging)=="undefined"){ |
---|
3274 | throw ""; |
---|
3275 | } |
---|
3276 | } |
---|
3277 | catch(e){ |
---|
3278 | throw "MochiKit.LoggingPane depends on MochiKit.Base and MochiKit.Logging!"; |
---|
3279 | } |
---|
3280 | if(typeof (MochiKit.LoggingPane)=="undefined"){ |
---|
3281 | MochiKit.LoggingPane={}; |
---|
3282 | } |
---|
3283 | MochiKit.LoggingPane.NAME="MochiKit.LoggingPane"; |
---|
3284 | MochiKit.LoggingPane.VERSION="1.3.1"; |
---|
3285 | MochiKit.LoggingPane.__repr__=function(){ |
---|
3286 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
3287 | }; |
---|
3288 | MochiKit.LoggingPane.toString=function(){ |
---|
3289 | return this.__repr__(); |
---|
3290 | }; |
---|
3291 | MochiKit.LoggingPane.createLoggingPane=function(_426){ |
---|
3292 | var m=MochiKit.LoggingPane; |
---|
3293 | _426=!(!_426); |
---|
3294 | if(m._loggingPane&&m._loggingPane.inline!=_426){ |
---|
3295 | m._loggingPane.closePane(); |
---|
3296 | m._loggingPane=null; |
---|
3297 | } |
---|
3298 | if(!m._loggingPane||m._loggingPane.closed){ |
---|
3299 | m._loggingPane=new m.LoggingPane(_426,MochiKit.Logging.logger); |
---|
3300 | } |
---|
3301 | return m._loggingPane; |
---|
3302 | }; |
---|
3303 | MochiKit.LoggingPane.LoggingPane=function(_427,_428){ |
---|
3304 | if(typeof (_428)=="undefined"||_428===null){ |
---|
3305 | _428=MochiKit.Logging.logger; |
---|
3306 | } |
---|
3307 | this.logger=_428; |
---|
3308 | var _429=MochiKit.Base.update; |
---|
3309 | var _430=MochiKit.Base.updatetree; |
---|
3310 | var bind=MochiKit.Base.bind; |
---|
3311 | var _431=MochiKit.Base.clone; |
---|
3312 | var win=window; |
---|
3313 | var uid="_MochiKit_LoggingPane"; |
---|
3314 | if(typeof (MochiKit.DOM)!="undefined"){ |
---|
3315 | win=MochiKit.DOM.currentWindow(); |
---|
3316 | } |
---|
3317 | if(!_427){ |
---|
3318 | var url=win.location.href.split("?")[0].replace(/[:\/.><&]/g,"_"); |
---|
3319 | var name=uid+"_"+url; |
---|
3320 | var nwin=win.open("",name,"dependent,resizable,height=200"); |
---|
3321 | if(!nwin){ |
---|
3322 | alert("Not able to open debugging window due to pop-up blocking."); |
---|
3323 | return undefined; |
---|
3324 | } |
---|
3325 | nwin.document.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" "+"\"http://www.w3.org/TR/html4/loose.dtd\">"+"<html><head><title>[MochiKit.LoggingPane]</title></head>"+"<body></body></html>"); |
---|
3326 | nwin.document.close(); |
---|
3327 | nwin.document.title+=" "+win.document.title; |
---|
3328 | win=nwin; |
---|
3329 | } |
---|
3330 | var doc=win.document; |
---|
3331 | this.doc=doc; |
---|
3332 | var _434=doc.getElementById(uid); |
---|
3333 | var _435=!!_434; |
---|
3334 | if(_434&&typeof (_434.loggingPane)!="undefined"){ |
---|
3335 | _434.loggingPane.logger=this.logger; |
---|
3336 | _434.loggingPane.buildAndApplyFilter(); |
---|
3337 | return _434.loggingPane; |
---|
3338 | } |
---|
3339 | if(_435){ |
---|
3340 | var _436; |
---|
3341 | while((_436=_434.firstChild)){ |
---|
3342 | _434.removeChild(_436); |
---|
3343 | } |
---|
3344 | }else{ |
---|
3345 | _434=doc.createElement("div"); |
---|
3346 | _434.id=uid; |
---|
3347 | } |
---|
3348 | _434.loggingPane=this; |
---|
3349 | var _437=doc.createElement("input"); |
---|
3350 | var _438=doc.createElement("input"); |
---|
3351 | var _439=doc.createElement("button"); |
---|
3352 | var _440=doc.createElement("button"); |
---|
3353 | var _441=doc.createElement("button"); |
---|
3354 | var _442=doc.createElement("button"); |
---|
3355 | var _443=doc.createElement("div"); |
---|
3356 | var _444=doc.createElement("div"); |
---|
3357 | var _445=uid+"_Listener"; |
---|
3358 | this.colorTable=_431(this.colorTable); |
---|
3359 | var _446=[]; |
---|
3360 | var _447=null; |
---|
3361 | var _448=function(msg){ |
---|
3362 | var _449=msg.level; |
---|
3363 | if(typeof (_449)=="number"){ |
---|
3364 | _449=MochiKit.Logging.LogLevel[_449]; |
---|
3365 | } |
---|
3366 | return _449; |
---|
3367 | }; |
---|
3368 | var _450=function(msg){ |
---|
3369 | return msg.info.join(" "); |
---|
3370 | }; |
---|
3371 | var _451=bind(function(msg){ |
---|
3372 | var _452=_448(msg); |
---|
3373 | var text=_450(msg); |
---|
3374 | var c=this.colorTable[_452]; |
---|
3375 | var p=doc.createElement("span"); |
---|
3376 | p.className="MochiKit-LogMessage MochiKit-LogLevel-"+_452; |
---|
3377 | p.style.cssText="margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: "+c; |
---|
3378 | p.appendChild(doc.createTextNode(_452+": "+text)); |
---|
3379 | _444.appendChild(p); |
---|
3380 | _444.appendChild(doc.createElement("br")); |
---|
3381 | if(_443.offsetHeight>_443.scrollHeight){ |
---|
3382 | _443.scrollTop=0; |
---|
3383 | }else{ |
---|
3384 | _443.scrollTop=_443.scrollHeight; |
---|
3385 | } |
---|
3386 | },this); |
---|
3387 | var _454=function(msg){ |
---|
3388 | _446[_446.length]=msg; |
---|
3389 | _451(msg); |
---|
3390 | }; |
---|
3391 | var _455=function(){ |
---|
3392 | var _456,infore; |
---|
3393 | try{ |
---|
3394 | _456=new RegExp(_437.value); |
---|
3395 | infore=new RegExp(_438.value); |
---|
3396 | } |
---|
3397 | catch(e){ |
---|
3398 | logDebug("Error in filter regex: "+e.message); |
---|
3399 | return null; |
---|
3400 | } |
---|
3401 | return function(msg){ |
---|
3402 | return (_456.test(_448(msg))&&infore.test(_450(msg))); |
---|
3403 | }; |
---|
3404 | }; |
---|
3405 | var _457=function(){ |
---|
3406 | while(_444.firstChild){ |
---|
3407 | _444.removeChild(_444.firstChild); |
---|
3408 | } |
---|
3409 | }; |
---|
3410 | var _458=function(){ |
---|
3411 | _446=[]; |
---|
3412 | _457(); |
---|
3413 | }; |
---|
3414 | var _459=bind(function(){ |
---|
3415 | if(this.closed){ |
---|
3416 | return; |
---|
3417 | } |
---|
3418 | this.closed=true; |
---|
3419 | if(MochiKit.LoggingPane._loggingPane==this){ |
---|
3420 | MochiKit.LoggingPane._loggingPane=null; |
---|
3421 | } |
---|
3422 | this.logger.removeListener(_445); |
---|
3423 | _434.loggingPane=null; |
---|
3424 | if(_427){ |
---|
3425 | _434.parentNode.removeChild(_434); |
---|
3426 | }else{ |
---|
3427 | this.win.close(); |
---|
3428 | } |
---|
3429 | },this); |
---|
3430 | var _460=function(){ |
---|
3431 | _457(); |
---|
3432 | for(var i=0;i<_446.length;i++){ |
---|
3433 | var msg=_446[i]; |
---|
3434 | if(_447===null||_447(msg)){ |
---|
3435 | _451(msg); |
---|
3436 | } |
---|
3437 | } |
---|
3438 | }; |
---|
3439 | this.buildAndApplyFilter=function(){ |
---|
3440 | _447=_455(); |
---|
3441 | _460(); |
---|
3442 | this.logger.removeListener(_445); |
---|
3443 | this.logger.addListener(_445,_447,_454); |
---|
3444 | }; |
---|
3445 | var _461=bind(function(){ |
---|
3446 | _446=this.logger.getMessages(); |
---|
3447 | _460(); |
---|
3448 | },this); |
---|
3449 | var _462=bind(function(_463){ |
---|
3450 | _463=_463||window.event; |
---|
3451 | key=_463.which||_463.keyCode; |
---|
3452 | if(key==13){ |
---|
3453 | this.buildAndApplyFilter(); |
---|
3454 | } |
---|
3455 | },this); |
---|
3456 | var _464="display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: "+this.logFont; |
---|
3457 | if(_427){ |
---|
3458 | _464+="; height: 10em; border-top: 2px solid black"; |
---|
3459 | }else{ |
---|
3460 | _464+="; height: 100%;"; |
---|
3461 | } |
---|
3462 | _434.style.cssText=_464; |
---|
3463 | if(!_435){ |
---|
3464 | doc.body.appendChild(_434); |
---|
3465 | } |
---|
3466 | _464={"cssText":"width: 33%; display: inline; font: "+this.logFont}; |
---|
3467 | _430(_437,{"value":"FATAL|ERROR|WARNING|INFO|DEBUG","onkeypress":_462,"style":_464}); |
---|
3468 | _434.appendChild(_437); |
---|
3469 | _430(_438,{"value":".*","onkeypress":_462,"style":_464}); |
---|
3470 | _434.appendChild(_438); |
---|
3471 | _464="width: 8%; display:inline; font: "+this.logFont; |
---|
3472 | _439.appendChild(doc.createTextNode("Filter")); |
---|
3473 | _439.onclick=bind("buildAndApplyFilter",this); |
---|
3474 | _439.style.cssText=_464; |
---|
3475 | _434.appendChild(_439); |
---|
3476 | _440.appendChild(doc.createTextNode("Load")); |
---|
3477 | _440.onclick=_461; |
---|
3478 | _440.style.cssText=_464; |
---|
3479 | _434.appendChild(_440); |
---|
3480 | _441.appendChild(doc.createTextNode("Clear")); |
---|
3481 | _441.onclick=_458; |
---|
3482 | _441.style.cssText=_464; |
---|
3483 | _434.appendChild(_441); |
---|
3484 | _442.appendChild(doc.createTextNode("Close")); |
---|
3485 | _442.onclick=_459; |
---|
3486 | _442.style.cssText=_464; |
---|
3487 | _434.appendChild(_442); |
---|
3488 | _443.style.cssText="overflow: auto; width: 100%"; |
---|
3489 | _444.style.cssText="width: 100%; height: "+(_427?"8em":"100%"); |
---|
3490 | _443.appendChild(_444); |
---|
3491 | _434.appendChild(_443); |
---|
3492 | this.buildAndApplyFilter(); |
---|
3493 | _461(); |
---|
3494 | if(_427){ |
---|
3495 | this.win=undefined; |
---|
3496 | }else{ |
---|
3497 | this.win=win; |
---|
3498 | } |
---|
3499 | this.inline=_427; |
---|
3500 | this.closePane=_459; |
---|
3501 | this.closed=false; |
---|
3502 | return this; |
---|
3503 | }; |
---|
3504 | MochiKit.LoggingPane.LoggingPane.prototype={"logFont":"8pt Verdana,sans-serif","colorTable":{"ERROR":"red","FATAL":"darkred","WARNING":"blue","INFO":"black","DEBUG":"green"}}; |
---|
3505 | MochiKit.LoggingPane.EXPORT_OK=["LoggingPane"]; |
---|
3506 | MochiKit.LoggingPane.EXPORT=["createLoggingPane"]; |
---|
3507 | MochiKit.LoggingPane.__new__=function(){ |
---|
3508 | this.EXPORT_TAGS={":common":this.EXPORT,":all":MochiKit.Base.concat(this.EXPORT,this.EXPORT_OK)}; |
---|
3509 | MochiKit.Base.nameFunctions(this); |
---|
3510 | MochiKit.LoggingPane._loggingPane=null; |
---|
3511 | }; |
---|
3512 | MochiKit.LoggingPane.__new__(); |
---|
3513 | MochiKit.Base._exportSymbols(this,MochiKit.LoggingPane); |
---|
3514 | if(typeof (dojo)!="undefined"){ |
---|
3515 | dojo.provide("MochiKit.Color"); |
---|
3516 | dojo.require("MochiKit.Base"); |
---|
3517 | } |
---|
3518 | if(typeof (JSAN)!="undefined"){ |
---|
3519 | JSAN.use("MochiKit.Base",[]); |
---|
3520 | } |
---|
3521 | try{ |
---|
3522 | if(typeof (MochiKit.Base)=="undefined"){ |
---|
3523 | throw ""; |
---|
3524 | } |
---|
3525 | } |
---|
3526 | catch(e){ |
---|
3527 | throw "MochiKit.Color depends on MochiKit.Base"; |
---|
3528 | } |
---|
3529 | if(typeof (MochiKit.Color)=="undefined"){ |
---|
3530 | MochiKit.Color={}; |
---|
3531 | } |
---|
3532 | MochiKit.Color.NAME="MochiKit.Color"; |
---|
3533 | MochiKit.Color.VERSION="1.3.1"; |
---|
3534 | MochiKit.Color.__repr__=function(){ |
---|
3535 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
3536 | }; |
---|
3537 | MochiKit.Color.toString=function(){ |
---|
3538 | return this.__repr__(); |
---|
3539 | }; |
---|
3540 | MochiKit.Color.Color=function(red,_466,blue,_468){ |
---|
3541 | if(typeof (_468)=="undefined"||_468===null){ |
---|
3542 | _468=1; |
---|
3543 | } |
---|
3544 | this.rgb={r:red,g:_466,b:blue,a:_468}; |
---|
3545 | }; |
---|
3546 | MochiKit.Color.Color.prototype={__class__:MochiKit.Color.Color,colorWithAlpha:function(_469){ |
---|
3547 | var rgb=this.rgb; |
---|
3548 | var m=MochiKit.Color; |
---|
3549 | return m.Color.fromRGB(rgb.r,rgb.g,rgb.b,_469); |
---|
3550 | },colorWithHue:function(hue){ |
---|
3551 | var hsl=this.asHSL(); |
---|
3552 | hsl.h=hue; |
---|
3553 | var m=MochiKit.Color; |
---|
3554 | return m.Color.fromHSL(hsl); |
---|
3555 | },colorWithSaturation:function(_473){ |
---|
3556 | var hsl=this.asHSL(); |
---|
3557 | hsl.s=_473; |
---|
3558 | var m=MochiKit.Color; |
---|
3559 | return m.Color.fromHSL(hsl); |
---|
3560 | },colorWithLightness:function(_474){ |
---|
3561 | var hsl=this.asHSL(); |
---|
3562 | hsl.l=_474; |
---|
3563 | var m=MochiKit.Color; |
---|
3564 | return m.Color.fromHSL(hsl); |
---|
3565 | },darkerColorWithLevel:function(_475){ |
---|
3566 | var hsl=this.asHSL(); |
---|
3567 | hsl.l=Math.max(hsl.l-_475,0); |
---|
3568 | var m=MochiKit.Color; |
---|
3569 | return m.Color.fromHSL(hsl); |
---|
3570 | },lighterColorWithLevel:function(_476){ |
---|
3571 | var hsl=this.asHSL(); |
---|
3572 | hsl.l=Math.min(hsl.l+_476,1); |
---|
3573 | var m=MochiKit.Color; |
---|
3574 | return m.Color.fromHSL(hsl); |
---|
3575 | },blendedColor:function(_477,_478){ |
---|
3576 | if(typeof (_478)=="undefined"||_478===null){ |
---|
3577 | _478=0.5; |
---|
3578 | } |
---|
3579 | var sf=1-_478; |
---|
3580 | var s=this.rgb; |
---|
3581 | var d=_477.rgb; |
---|
3582 | var df=_478; |
---|
3583 | 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)); |
---|
3584 | },compareRGB:function(_481){ |
---|
3585 | var a=this.asRGB(); |
---|
3586 | var b=_481.asRGB(); |
---|
3587 | return MochiKit.Base.compare([a.r,a.g,a.b,a.a],[b.r,b.g,b.b,b.a]); |
---|
3588 | },isLight:function(){ |
---|
3589 | return this.asHSL().b>0.5; |
---|
3590 | },isDark:function(){ |
---|
3591 | return (!this.isLight()); |
---|
3592 | },toHSLString:function(){ |
---|
3593 | var c=this.asHSL(); |
---|
3594 | var ccc=MochiKit.Color.clampColorComponent; |
---|
3595 | var rval=this._hslString; |
---|
3596 | if(!rval){ |
---|
3597 | var mid=(ccc(c.h,360).toFixed(0)+","+ccc(c.s,100).toPrecision(4)+"%"+","+ccc(c.l,100).toPrecision(4)+"%"); |
---|
3598 | var a=c.a; |
---|
3599 | if(a>=1){ |
---|
3600 | a=1; |
---|
3601 | rval="hsl("+mid+")"; |
---|
3602 | }else{ |
---|
3603 | if(a<=0){ |
---|
3604 | a=0; |
---|
3605 | } |
---|
3606 | rval="hsla("+mid+","+a+")"; |
---|
3607 | } |
---|
3608 | this._hslString=rval; |
---|
3609 | } |
---|
3610 | return rval; |
---|
3611 | },toRGBString:function(){ |
---|
3612 | var c=this.rgb; |
---|
3613 | var ccc=MochiKit.Color.clampColorComponent; |
---|
3614 | var rval=this._rgbString; |
---|
3615 | if(!rval){ |
---|
3616 | var mid=(ccc(c.r,255).toFixed(0)+","+ccc(c.g,255).toFixed(0)+","+ccc(c.b,255).toFixed(0)); |
---|
3617 | if(c.a!=1){ |
---|
3618 | rval="rgba("+mid+","+c.a+")"; |
---|
3619 | }else{ |
---|
3620 | rval="rgb("+mid+")"; |
---|
3621 | } |
---|
3622 | this._rgbString=rval; |
---|
3623 | } |
---|
3624 | return rval; |
---|
3625 | },asRGB:function(){ |
---|
3626 | return MochiKit.Base.clone(this.rgb); |
---|
3627 | },toHexString:function(){ |
---|
3628 | var m=MochiKit.Color; |
---|
3629 | var c=this.rgb; |
---|
3630 | var ccc=MochiKit.Color.clampColorComponent; |
---|
3631 | var rval=this._hexString; |
---|
3632 | if(!rval){ |
---|
3633 | rval=("#"+m.toColorPart(ccc(c.r,255))+m.toColorPart(ccc(c.g,255))+m.toColorPart(ccc(c.b,255))); |
---|
3634 | this._hexString=rval; |
---|
3635 | } |
---|
3636 | return rval; |
---|
3637 | },asHSV:function(){ |
---|
3638 | var hsv=this.hsv; |
---|
3639 | var c=this.rgb; |
---|
3640 | if(typeof (hsv)=="undefined"||hsv===null){ |
---|
3641 | hsv=MochiKit.Color.rgbToHSV(this.rgb); |
---|
3642 | this.hsv=hsv; |
---|
3643 | } |
---|
3644 | return MochiKit.Base.clone(hsv); |
---|
3645 | },asHSL:function(){ |
---|
3646 | var hsl=this.hsl; |
---|
3647 | var c=this.rgb; |
---|
3648 | if(typeof (hsl)=="undefined"||hsl===null){ |
---|
3649 | hsl=MochiKit.Color.rgbToHSL(this.rgb); |
---|
3650 | this.hsl=hsl; |
---|
3651 | } |
---|
3652 | return MochiKit.Base.clone(hsl); |
---|
3653 | },toString:function(){ |
---|
3654 | return this.toRGBString(); |
---|
3655 | },repr:function(){ |
---|
3656 | var c=this.rgb; |
---|
3657 | var col=[c.r,c.g,c.b,c.a]; |
---|
3658 | return this.__class__.NAME+"("+col.join(", ")+")"; |
---|
3659 | }}; |
---|
3660 | MochiKit.Base.update(MochiKit.Color.Color,{fromRGB:function(red,_486,blue,_487){ |
---|
3661 | var _488=MochiKit.Color.Color; |
---|
3662 | if(arguments.length==1){ |
---|
3663 | var rgb=red; |
---|
3664 | red=rgb.r; |
---|
3665 | _486=rgb.g; |
---|
3666 | blue=rgb.b; |
---|
3667 | if(typeof (rgb.a)=="undefined"){ |
---|
3668 | _487=undefined; |
---|
3669 | }else{ |
---|
3670 | _487=rgb.a; |
---|
3671 | } |
---|
3672 | } |
---|
3673 | return new _488(red,_486,blue,_487); |
---|
3674 | },fromHSL:function(hue,_489,_490,_491){ |
---|
3675 | var m=MochiKit.Color; |
---|
3676 | return m.Color.fromRGB(m.hslToRGB.apply(m,arguments)); |
---|
3677 | },fromHSV:function(hue,_492,_493,_494){ |
---|
3678 | var m=MochiKit.Color; |
---|
3679 | return m.Color.fromRGB(m.hsvToRGB.apply(m,arguments)); |
---|
3680 | },fromName:function(name){ |
---|
3681 | var _495=MochiKit.Color.Color; |
---|
3682 | if(name.charAt(0)=="\""){ |
---|
3683 | name=name.substr(1,name.length-2); |
---|
3684 | } |
---|
3685 | var _496=_495._namedColors[name.toLowerCase()]; |
---|
3686 | if(typeof (_496)=="string"){ |
---|
3687 | return _495.fromHexString(_496); |
---|
3688 | }else{ |
---|
3689 | if(name=="transparent"){ |
---|
3690 | return _495.transparentColor(); |
---|
3691 | } |
---|
3692 | } |
---|
3693 | return null; |
---|
3694 | },fromString:function(_497){ |
---|
3695 | var self=MochiKit.Color.Color; |
---|
3696 | var _498=_497.substr(0,3); |
---|
3697 | if(_498=="rgb"){ |
---|
3698 | return self.fromRGBString(_497); |
---|
3699 | }else{ |
---|
3700 | if(_498=="hsl"){ |
---|
3701 | return self.fromHSLString(_497); |
---|
3702 | }else{ |
---|
3703 | if(_497.charAt(0)=="#"){ |
---|
3704 | return self.fromHexString(_497); |
---|
3705 | } |
---|
3706 | } |
---|
3707 | } |
---|
3708 | return self.fromName(_497); |
---|
3709 | },fromHexString:function(_499){ |
---|
3710 | if(_499.charAt(0)=="#"){ |
---|
3711 | _499=_499.substring(1); |
---|
3712 | } |
---|
3713 | var _500=[]; |
---|
3714 | var i,hex; |
---|
3715 | if(_499.length==3){ |
---|
3716 | for(i=0;i<3;i++){ |
---|
3717 | hex=_499.substr(i,1); |
---|
3718 | _500.push(parseInt(hex+hex,16)/255); |
---|
3719 | } |
---|
3720 | }else{ |
---|
3721 | for(i=0;i<6;i+=2){ |
---|
3722 | hex=_499.substr(i,2); |
---|
3723 | _500.push(parseInt(hex,16)/255); |
---|
3724 | } |
---|
3725 | } |
---|
3726 | var _501=MochiKit.Color.Color; |
---|
3727 | return _501.fromRGB.apply(_501,_500); |
---|
3728 | },_fromColorString:function(pre,_503,_504,_505){ |
---|
3729 | if(_505.indexOf(pre)===0){ |
---|
3730 | _505=_505.substring(_505.indexOf("(",3)+1,_505.length-1); |
---|
3731 | } |
---|
3732 | var _506=_505.split(/\s*,\s*/); |
---|
3733 | var _507=[]; |
---|
3734 | for(var i=0;i<_506.length;i++){ |
---|
3735 | var c=_506[i]; |
---|
3736 | var val; |
---|
3737 | var _508=c.substring(c.length-3); |
---|
3738 | if(c.charAt(c.length-1)=="%"){ |
---|
3739 | val=0.01*parseFloat(c.substring(0,c.length-1)); |
---|
3740 | }else{ |
---|
3741 | if(_508=="deg"){ |
---|
3742 | val=parseFloat(c)/360; |
---|
3743 | }else{ |
---|
3744 | if(_508=="rad"){ |
---|
3745 | val=parseFloat(c)/(Math.PI*2); |
---|
3746 | }else{ |
---|
3747 | val=_504[i]*parseFloat(c); |
---|
3748 | } |
---|
3749 | } |
---|
3750 | } |
---|
3751 | _507.push(val); |
---|
3752 | } |
---|
3753 | return this[_503].apply(this,_507); |
---|
3754 | },fromComputedStyle:function(elem,_509,_510){ |
---|
3755 | var d=MochiKit.DOM; |
---|
3756 | var cls=MochiKit.Color.Color; |
---|
3757 | for(elem=d.getElement(elem);elem;elem=elem.parentNode){ |
---|
3758 | var _511=d.computedStyle.apply(d,arguments); |
---|
3759 | if(!_511){ |
---|
3760 | continue; |
---|
3761 | } |
---|
3762 | var _512=cls.fromString(_511); |
---|
3763 | if(!_512){ |
---|
3764 | break; |
---|
3765 | } |
---|
3766 | if(_512.asRGB().a>0){ |
---|
3767 | return _512; |
---|
3768 | } |
---|
3769 | } |
---|
3770 | return null; |
---|
3771 | },fromBackground:function(elem){ |
---|
3772 | var cls=MochiKit.Color.Color; |
---|
3773 | return cls.fromComputedStyle(elem,"backgroundColor","background-color")||cls.whiteColor(); |
---|
3774 | },fromText:function(elem){ |
---|
3775 | var cls=MochiKit.Color.Color; |
---|
3776 | return cls.fromComputedStyle(elem,"color","color")||cls.blackColor(); |
---|
3777 | },namedColors:function(){ |
---|
3778 | return MochiKit.Base.clone(MochiKit.Color.Color._namedColors); |
---|
3779 | }}); |
---|
3780 | MochiKit.Base.update(MochiKit.Color,{clampColorComponent:function(v,_513){ |
---|
3781 | v*=_513; |
---|
3782 | if(v<0){ |
---|
3783 | return 0; |
---|
3784 | }else{ |
---|
3785 | if(v>_513){ |
---|
3786 | return _513; |
---|
3787 | }else{ |
---|
3788 | return v; |
---|
3789 | } |
---|
3790 | } |
---|
3791 | },_hslValue:function(n1,n2,hue){ |
---|
3792 | if(hue>6){ |
---|
3793 | hue-=6; |
---|
3794 | }else{ |
---|
3795 | if(hue<0){ |
---|
3796 | hue+=6; |
---|
3797 | } |
---|
3798 | } |
---|
3799 | var val; |
---|
3800 | if(hue<1){ |
---|
3801 | val=n1+(n2-n1)*hue; |
---|
3802 | }else{ |
---|
3803 | if(hue<3){ |
---|
3804 | val=n2; |
---|
3805 | }else{ |
---|
3806 | if(hue<4){ |
---|
3807 | val=n1+(n2-n1)*(4-hue); |
---|
3808 | }else{ |
---|
3809 | val=n1; |
---|
3810 | } |
---|
3811 | } |
---|
3812 | } |
---|
3813 | return val; |
---|
3814 | },hsvToRGB:function(hue,_516,_517,_518){ |
---|
3815 | if(arguments.length==1){ |
---|
3816 | var hsv=hue; |
---|
3817 | hue=hsv.h; |
---|
3818 | _516=hsv.s; |
---|
3819 | _517=hsv.v; |
---|
3820 | _518=hsv.a; |
---|
3821 | } |
---|
3822 | var red; |
---|
3823 | var _519; |
---|
3824 | var blue; |
---|
3825 | if(_516===0){ |
---|
3826 | red=0; |
---|
3827 | _519=0; |
---|
3828 | blue=0; |
---|
3829 | }else{ |
---|
3830 | var i=Math.floor(hue*6); |
---|
3831 | var f=(hue*6)-i; |
---|
3832 | var p=_517*(1-_516); |
---|
3833 | var q=_517*(1-(_516*f)); |
---|
3834 | var t=_517*(1-(_516*(1-f))); |
---|
3835 | switch(i){ |
---|
3836 | case 1: |
---|
3837 | red=q; |
---|
3838 | _519=_517; |
---|
3839 | blue=p; |
---|
3840 | break; |
---|
3841 | case 2: |
---|
3842 | red=p; |
---|
3843 | _519=_517; |
---|
3844 | blue=t; |
---|
3845 | break; |
---|
3846 | case 3: |
---|
3847 | red=p; |
---|
3848 | _519=q; |
---|
3849 | blue=_517; |
---|
3850 | break; |
---|
3851 | case 4: |
---|
3852 | red=t; |
---|
3853 | _519=p; |
---|
3854 | blue=_517; |
---|
3855 | break; |
---|
3856 | case 5: |
---|
3857 | red=_517; |
---|
3858 | _519=p; |
---|
3859 | blue=q; |
---|
3860 | break; |
---|
3861 | case 6: |
---|
3862 | case 0: |
---|
3863 | red=_517; |
---|
3864 | _519=t; |
---|
3865 | blue=p; |
---|
3866 | break; |
---|
3867 | } |
---|
3868 | } |
---|
3869 | return {r:red,g:_519,b:blue,a:_518}; |
---|
3870 | },hslToRGB:function(hue,_521,_522,_523){ |
---|
3871 | if(arguments.length==1){ |
---|
3872 | var hsl=hue; |
---|
3873 | hue=hsl.h; |
---|
3874 | _521=hsl.s; |
---|
3875 | _522=hsl.l; |
---|
3876 | _523=hsl.a; |
---|
3877 | } |
---|
3878 | var red; |
---|
3879 | var _524; |
---|
3880 | var blue; |
---|
3881 | if(_521===0){ |
---|
3882 | red=_522; |
---|
3883 | _524=_522; |
---|
3884 | blue=_522; |
---|
3885 | }else{ |
---|
3886 | var m2; |
---|
3887 | if(_522<=0.5){ |
---|
3888 | m2=_522*(1+_521); |
---|
3889 | }else{ |
---|
3890 | m2=_522+_521-(_522*_521); |
---|
3891 | } |
---|
3892 | var m1=(2*_522)-m2; |
---|
3893 | var f=MochiKit.Color._hslValue; |
---|
3894 | var h6=hue*6; |
---|
3895 | red=f(m1,m2,h6+2); |
---|
3896 | _524=f(m1,m2,h6); |
---|
3897 | blue=f(m1,m2,h6-2); |
---|
3898 | } |
---|
3899 | return {r:red,g:_524,b:blue,a:_523}; |
---|
3900 | },rgbToHSV:function(red,_528,blue,_529){ |
---|
3901 | if(arguments.length==1){ |
---|
3902 | var rgb=red; |
---|
3903 | red=rgb.r; |
---|
3904 | _528=rgb.g; |
---|
3905 | blue=rgb.b; |
---|
3906 | _529=rgb.a; |
---|
3907 | } |
---|
3908 | var max=Math.max(Math.max(red,_528),blue); |
---|
3909 | var min=Math.min(Math.min(red,_528),blue); |
---|
3910 | var hue; |
---|
3911 | var _532; |
---|
3912 | var _533=max; |
---|
3913 | if(min==max){ |
---|
3914 | hue=0; |
---|
3915 | _532=0; |
---|
3916 | }else{ |
---|
3917 | var _534=(max-min); |
---|
3918 | _532=_534/max; |
---|
3919 | if(red==max){ |
---|
3920 | hue=(_528-blue)/_534; |
---|
3921 | }else{ |
---|
3922 | if(_528==max){ |
---|
3923 | hue=2+((blue-red)/_534); |
---|
3924 | }else{ |
---|
3925 | hue=4+((red-_528)/_534); |
---|
3926 | } |
---|
3927 | } |
---|
3928 | hue/=6; |
---|
3929 | if(hue<0){ |
---|
3930 | hue+=1; |
---|
3931 | } |
---|
3932 | if(hue>1){ |
---|
3933 | hue-=1; |
---|
3934 | } |
---|
3935 | } |
---|
3936 | return {h:hue,s:_532,v:_533,a:_529}; |
---|
3937 | },rgbToHSL:function(red,_535,blue,_536){ |
---|
3938 | if(arguments.length==1){ |
---|
3939 | var rgb=red; |
---|
3940 | red=rgb.r; |
---|
3941 | _535=rgb.g; |
---|
3942 | blue=rgb.b; |
---|
3943 | _536=rgb.a; |
---|
3944 | } |
---|
3945 | var max=Math.max(red,Math.max(_535,blue)); |
---|
3946 | var min=Math.min(red,Math.min(_535,blue)); |
---|
3947 | var hue; |
---|
3948 | var _537; |
---|
3949 | var _538=(max+min)/2; |
---|
3950 | var _539=max-min; |
---|
3951 | if(_539===0){ |
---|
3952 | hue=0; |
---|
3953 | _537=0; |
---|
3954 | }else{ |
---|
3955 | if(_538<=0.5){ |
---|
3956 | _537=_539/(max+min); |
---|
3957 | }else{ |
---|
3958 | _537=_539/(2-max-min); |
---|
3959 | } |
---|
3960 | if(red==max){ |
---|
3961 | hue=(_535-blue)/_539; |
---|
3962 | }else{ |
---|
3963 | if(_535==max){ |
---|
3964 | hue=2+((blue-red)/_539); |
---|
3965 | }else{ |
---|
3966 | hue=4+((red-_535)/_539); |
---|
3967 | } |
---|
3968 | } |
---|
3969 | hue/=6; |
---|
3970 | if(hue<0){ |
---|
3971 | hue+=1; |
---|
3972 | } |
---|
3973 | if(hue>1){ |
---|
3974 | hue-=1; |
---|
3975 | } |
---|
3976 | } |
---|
3977 | return {h:hue,s:_537,l:_538,a:_536}; |
---|
3978 | },toColorPart:function(num){ |
---|
3979 | num=Math.round(num); |
---|
3980 | var _540=num.toString(16); |
---|
3981 | if(num<16){ |
---|
3982 | return "0"+_540; |
---|
3983 | } |
---|
3984 | return _540; |
---|
3985 | },__new__:function(){ |
---|
3986 | var m=MochiKit.Base; |
---|
3987 | this.Color.fromRGBString=m.bind(this.Color._fromColorString,this.Color,"rgb","fromRGB",[1/255,1/255,1/255,1]); |
---|
3988 | this.Color.fromHSLString=m.bind(this.Color._fromColorString,this.Color,"hsl","fromHSL",[1/360,0.01,0.01,1]); |
---|
3989 | var _541=1/3; |
---|
3990 | var _542={black:[0,0,0],blue:[0,0,1],brown:[0.6,0.4,0.2],cyan:[0,1,1],darkGray:[_541,_541,_541],gray:[0.5,0.5,0.5],green:[0,1,0],lightGray:[2*_541,2*_541,2*_541],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]}; |
---|
3991 | var _543=function(name,r,g,b,a){ |
---|
3992 | var rval=this.fromRGB(r,g,b,a); |
---|
3993 | this[name]=function(){ |
---|
3994 | return rval; |
---|
3995 | }; |
---|
3996 | return rval; |
---|
3997 | }; |
---|
3998 | for(var k in _542){ |
---|
3999 | var name=k+"Color"; |
---|
4000 | var _545=m.concat([_543,this.Color,name],_542[k]); |
---|
4001 | this.Color[name]=m.bind.apply(null,_545); |
---|
4002 | } |
---|
4003 | var _546=function(){ |
---|
4004 | for(var i=0;i<arguments.length;i++){ |
---|
4005 | if(!(arguments[i] instanceof Color)){ |
---|
4006 | return false; |
---|
4007 | } |
---|
4008 | } |
---|
4009 | return true; |
---|
4010 | }; |
---|
4011 | var _547=function(a,b){ |
---|
4012 | return a.compareRGB(b); |
---|
4013 | }; |
---|
4014 | m.nameFunctions(this); |
---|
4015 | m.registerComparator(this.Color.NAME,_546,_547); |
---|
4016 | this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; |
---|
4017 | }}); |
---|
4018 | MochiKit.Color.EXPORT=["Color"]; |
---|
4019 | MochiKit.Color.EXPORT_OK=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"]; |
---|
4020 | MochiKit.Color.__new__(); |
---|
4021 | MochiKit.Base._exportSymbols(this,MochiKit.Color); |
---|
4022 | 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"}; |
---|
4023 | if(typeof (dojo)!="undefined"){ |
---|
4024 | dojo.provide("MochiKit.Signal"); |
---|
4025 | dojo.require("MochiKit.Base"); |
---|
4026 | dojo.require("MochiKit.DOM"); |
---|
4027 | } |
---|
4028 | if(typeof (JSAN)!="undefined"){ |
---|
4029 | JSAN.use("MochiKit.Base",[]); |
---|
4030 | JSAN.use("MochiKit.DOM",[]); |
---|
4031 | } |
---|
4032 | try{ |
---|
4033 | if(typeof (MochiKit.Base)=="undefined"){ |
---|
4034 | throw ""; |
---|
4035 | } |
---|
4036 | } |
---|
4037 | catch(e){ |
---|
4038 | throw "MochiKit.Signal depends on MochiKit.Base!"; |
---|
4039 | } |
---|
4040 | try{ |
---|
4041 | if(typeof (MochiKit.DOM)=="undefined"){ |
---|
4042 | throw ""; |
---|
4043 | } |
---|
4044 | } |
---|
4045 | catch(e){ |
---|
4046 | throw "MochiKit.Signal depends on MochiKit.DOM!"; |
---|
4047 | } |
---|
4048 | if(typeof (MochiKit.Signal)=="undefined"){ |
---|
4049 | MochiKit.Signal={}; |
---|
4050 | } |
---|
4051 | MochiKit.Signal.NAME="MochiKit.Signal"; |
---|
4052 | MochiKit.Signal.VERSION="1.3.1"; |
---|
4053 | MochiKit.Signal._observers=[]; |
---|
4054 | MochiKit.Signal.Event=function(src,e){ |
---|
4055 | this._event=e||window.event; |
---|
4056 | this._src=src; |
---|
4057 | }; |
---|
4058 | MochiKit.Base.update(MochiKit.Signal.Event.prototype,{__repr__:function(){ |
---|
4059 | var repr=MochiKit.Base.repr; |
---|
4060 | var str="{event(): "+repr(this.event())+", src(): "+repr(this.src())+", type(): "+repr(this.type())+", target(): "+repr(this.target())+", 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)+"}"; |
---|
4061 | if(this.type()&&this.type().indexOf("key")===0){ |
---|
4062 | str+=", key(): {code: "+repr(this.key().code)+", string: "+repr(this.key().string)+"}"; |
---|
4063 | } |
---|
4064 | if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){ |
---|
4065 | str+=", mouse(): {page: "+repr(this.mouse().page)+", client: "+repr(this.mouse().client); |
---|
4066 | if(this.type()!="mousemove"){ |
---|
4067 | str+=", button: {left: "+repr(this.mouse().button.left)+", middle: "+repr(this.mouse().button.middle)+", right: "+repr(this.mouse().button.right)+"}}"; |
---|
4068 | }else{ |
---|
4069 | str+="}"; |
---|
4070 | } |
---|
4071 | } |
---|
4072 | if(this.type()=="mouseover"||this.type()=="mouseout"){ |
---|
4073 | str+=", relatedTarget(): "+repr(this.relatedTarget()); |
---|
4074 | } |
---|
4075 | str+="}"; |
---|
4076 | return str; |
---|
4077 | },toString:function(){ |
---|
4078 | return this.__repr__(); |
---|
4079 | },src:function(){ |
---|
4080 | return this._src; |
---|
4081 | },event:function(){ |
---|
4082 | return this._event; |
---|
4083 | },type:function(){ |
---|
4084 | return this._event.type||undefined; |
---|
4085 | },target:function(){ |
---|
4086 | return this._event.target||this._event.srcElement; |
---|
4087 | },relatedTarget:function(){ |
---|
4088 | if(this.type()=="mouseover"){ |
---|
4089 | return (this._event.relatedTarget||this._event.fromElement); |
---|
4090 | }else{ |
---|
4091 | if(this.type()=="mouseout"){ |
---|
4092 | return (this._event.relatedTarget||this._event.toElement); |
---|
4093 | } |
---|
4094 | } |
---|
4095 | return undefined; |
---|
4096 | },modifier:function(){ |
---|
4097 | var m={}; |
---|
4098 | m.alt=this._event.altKey; |
---|
4099 | m.ctrl=this._event.ctrlKey; |
---|
4100 | m.meta=this._event.metaKey||false; |
---|
4101 | m.shift=this._event.shiftKey; |
---|
4102 | m.any=m.alt||m.ctrl||m.shift||m.meta; |
---|
4103 | return m; |
---|
4104 | },key:function(){ |
---|
4105 | var k={}; |
---|
4106 | if(this.type()&&this.type().indexOf("key")===0){ |
---|
4107 | if(this.type()=="keydown"||this.type()=="keyup"){ |
---|
4108 | k.code=this._event.keyCode; |
---|
4109 | k.string=(MochiKit.Signal._specialKeys[k.code]||"KEY_UNKNOWN"); |
---|
4110 | return k; |
---|
4111 | }else{ |
---|
4112 | if(this.type()=="keypress"){ |
---|
4113 | k.code=0; |
---|
4114 | k.string=""; |
---|
4115 | if(typeof (this._event.charCode)!="undefined"&&this._event.charCode!==0&&!MochiKit.Signal._specialMacKeys[this._event.charCode]){ |
---|
4116 | k.code=this._event.charCode; |
---|
4117 | k.string=String.fromCharCode(k.code); |
---|
4118 | }else{ |
---|
4119 | if(this._event.keyCode&&typeof (this._event.charCode)=="undefined"){ |
---|
4120 | k.code=this._event.keyCode; |
---|
4121 | k.string=String.fromCharCode(k.code); |
---|
4122 | } |
---|
4123 | } |
---|
4124 | return k; |
---|
4125 | } |
---|
4126 | } |
---|
4127 | } |
---|
4128 | return undefined; |
---|
4129 | },mouse:function(){ |
---|
4130 | var m={}; |
---|
4131 | var e=this._event; |
---|
4132 | if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){ |
---|
4133 | m.client=new MochiKit.DOM.Coordinates(0,0); |
---|
4134 | if(e.clientX||e.clientY){ |
---|
4135 | m.client.x=(!e.clientX||e.clientX<0)?0:e.clientX; |
---|
4136 | m.client.y=(!e.clientY||e.clientY<0)?0:e.clientY; |
---|
4137 | } |
---|
4138 | m.page=new MochiKit.DOM.Coordinates(0,0); |
---|
4139 | if(e.pageX||e.pageY){ |
---|
4140 | m.page.x=(!e.pageX||e.pageX<0)?0:e.pageX; |
---|
4141 | m.page.y=(!e.pageY||e.pageY<0)?0:e.pageY; |
---|
4142 | }else{ |
---|
4143 | var de=MochiKit.DOM._document.documentElement; |
---|
4144 | var b=MochiKit.DOM._document.body; |
---|
4145 | m.page.x=e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||b.clientLeft); |
---|
4146 | m.page.y=e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||b.clientTop); |
---|
4147 | } |
---|
4148 | if(this.type()!="mousemove"){ |
---|
4149 | m.button={}; |
---|
4150 | m.button.left=false; |
---|
4151 | m.button.right=false; |
---|
4152 | m.button.middle=false; |
---|
4153 | if(e.which){ |
---|
4154 | m.button.left=(e.which==1); |
---|
4155 | m.button.middle=(e.which==2); |
---|
4156 | m.button.right=(e.which==3); |
---|
4157 | }else{ |
---|
4158 | m.button.left=!!(e.button&1); |
---|
4159 | m.button.right=!!(e.button&2); |
---|
4160 | m.button.middle=!!(e.button&4); |
---|
4161 | } |
---|
4162 | } |
---|
4163 | return m; |
---|
4164 | } |
---|
4165 | return undefined; |
---|
4166 | },stop:function(){ |
---|
4167 | this.stopPropagation(); |
---|
4168 | this.preventDefault(); |
---|
4169 | },stopPropagation:function(){ |
---|
4170 | if(this._event.stopPropagation){ |
---|
4171 | this._event.stopPropagation(); |
---|
4172 | }else{ |
---|
4173 | this._event.cancelBubble=true; |
---|
4174 | } |
---|
4175 | },preventDefault:function(){ |
---|
4176 | if(this._event.preventDefault){ |
---|
4177 | this._event.preventDefault(); |
---|
4178 | }else{ |
---|
4179 | this._event.returnValue=false; |
---|
4180 | } |
---|
4181 | }}); |
---|
4182 | 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"}; |
---|
4183 | for(i=63236;i<=63242;i++){ |
---|
4184 | MochiKit.Signal._specialMacKeys[i]="KEY_F"+(i-63236+1); |
---|
4185 | } |
---|
4186 | 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"}; |
---|
4187 | for(var i=48;i<=57;i++){ |
---|
4188 | MochiKit.Signal._specialKeys[i]="KEY_"+(i-48); |
---|
4189 | } |
---|
4190 | for(i=65;i<=90;i++){ |
---|
4191 | MochiKit.Signal._specialKeys[i]="KEY_"+String.fromCharCode(i); |
---|
4192 | } |
---|
4193 | for(i=96;i<=105;i++){ |
---|
4194 | MochiKit.Signal._specialKeys[i]="KEY_NUM_PAD_"+(i-96); |
---|
4195 | } |
---|
4196 | for(i=112;i<=123;i++){ |
---|
4197 | MochiKit.Signal._specialKeys[i]="KEY_F"+(i-112+1); |
---|
4198 | } |
---|
4199 | MochiKit.Base.update(MochiKit.Signal,{__repr__:function(){ |
---|
4200 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
4201 | },toString:function(){ |
---|
4202 | return this.__repr__(); |
---|
4203 | },_unloadCache:function(){ |
---|
4204 | var self=MochiKit.Signal; |
---|
4205 | var _548=self._observers; |
---|
4206 | for(var i=0;i<_548.length;i++){ |
---|
4207 | self._disconnect(_548[i]); |
---|
4208 | } |
---|
4209 | delete self._observers; |
---|
4210 | try{ |
---|
4211 | window.onload=undefined; |
---|
4212 | } |
---|
4213 | catch(e){ |
---|
4214 | } |
---|
4215 | try{ |
---|
4216 | window.onunload=undefined; |
---|
4217 | } |
---|
4218 | catch(e){ |
---|
4219 | } |
---|
4220 | },_listener:function(src,func,obj,_549){ |
---|
4221 | var E=MochiKit.Signal.Event; |
---|
4222 | if(!_549){ |
---|
4223 | return MochiKit.Base.bind(func,obj); |
---|
4224 | } |
---|
4225 | obj=obj||src; |
---|
4226 | if(typeof (func)=="string"){ |
---|
4227 | return function(_551){ |
---|
4228 | obj[func].apply(obj,[new E(src,_551)]); |
---|
4229 | }; |
---|
4230 | }else{ |
---|
4231 | return function(_552){ |
---|
4232 | func.apply(obj,[new E(src,_552)]); |
---|
4233 | }; |
---|
4234 | } |
---|
4235 | },connect:function(src,sig,_554,_555){ |
---|
4236 | src=MochiKit.DOM.getElement(src); |
---|
4237 | var self=MochiKit.Signal; |
---|
4238 | if(typeof (sig)!="string"){ |
---|
4239 | throw new Error("'sig' must be a string"); |
---|
4240 | } |
---|
4241 | var obj=null; |
---|
4242 | var func=null; |
---|
4243 | if(typeof (_555)!="undefined"){ |
---|
4244 | obj=_554; |
---|
4245 | func=_555; |
---|
4246 | if(typeof (_555)=="string"){ |
---|
4247 | if(typeof (_554[_555])!="function"){ |
---|
4248 | throw new Error("'funcOrStr' must be a function on 'objOrFunc'"); |
---|
4249 | } |
---|
4250 | }else{ |
---|
4251 | if(typeof (_555)!="function"){ |
---|
4252 | throw new Error("'funcOrStr' must be a function or string"); |
---|
4253 | } |
---|
4254 | } |
---|
4255 | }else{ |
---|
4256 | if(typeof (_554)!="function"){ |
---|
4257 | throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given"); |
---|
4258 | }else{ |
---|
4259 | func=_554; |
---|
4260 | } |
---|
4261 | } |
---|
4262 | if(typeof (obj)=="undefined"||obj===null){ |
---|
4263 | obj=src; |
---|
4264 | } |
---|
4265 | var _556=!!(src.addEventListener||src.attachEvent); |
---|
4266 | var _557=self._listener(src,func,obj,_556); |
---|
4267 | if(src.addEventListener){ |
---|
4268 | src.addEventListener(sig.substr(2),_557,false); |
---|
4269 | }else{ |
---|
4270 | if(src.attachEvent){ |
---|
4271 | src.attachEvent(sig,_557); |
---|
4272 | } |
---|
4273 | } |
---|
4274 | var _558=[src,sig,_557,_556,_554,_555]; |
---|
4275 | self._observers.push(_558); |
---|
4276 | return _558; |
---|
4277 | },_disconnect:function(_559){ |
---|
4278 | if(!_559[3]){ |
---|
4279 | return; |
---|
4280 | } |
---|
4281 | var src=_559[0]; |
---|
4282 | var sig=_559[1]; |
---|
4283 | var _560=_559[2]; |
---|
4284 | if(src.removeEventListener){ |
---|
4285 | src.removeEventListener(sig.substr(2),_560,false); |
---|
4286 | }else{ |
---|
4287 | if(src.detachEvent){ |
---|
4288 | src.detachEvent(sig,_560); |
---|
4289 | }else{ |
---|
4290 | throw new Error("'src' must be a DOM element"); |
---|
4291 | } |
---|
4292 | } |
---|
4293 | },disconnect:function(_561){ |
---|
4294 | var self=MochiKit.Signal; |
---|
4295 | var _562=self._observers; |
---|
4296 | var m=MochiKit.Base; |
---|
4297 | if(arguments.length>1){ |
---|
4298 | var src=MochiKit.DOM.getElement(arguments[0]); |
---|
4299 | var sig=arguments[1]; |
---|
4300 | var obj=arguments[2]; |
---|
4301 | var func=arguments[3]; |
---|
4302 | for(var i=_562.length-1;i>=0;i--){ |
---|
4303 | var o=_562[i]; |
---|
4304 | if(o[0]===src&&o[1]===sig&&o[4]===obj&&o[5]===func){ |
---|
4305 | self._disconnect(o); |
---|
4306 | _562.splice(i,1); |
---|
4307 | return true; |
---|
4308 | } |
---|
4309 | } |
---|
4310 | }else{ |
---|
4311 | var idx=m.findIdentical(_562,_561); |
---|
4312 | if(idx>=0){ |
---|
4313 | self._disconnect(_561); |
---|
4314 | _562.splice(idx,1); |
---|
4315 | return true; |
---|
4316 | } |
---|
4317 | } |
---|
4318 | return false; |
---|
4319 | },disconnectAll:function(src,sig){ |
---|
4320 | src=MochiKit.DOM.getElement(src); |
---|
4321 | var m=MochiKit.Base; |
---|
4322 | var _563=m.flattenArguments(m.extend(null,arguments,1)); |
---|
4323 | var self=MochiKit.Signal; |
---|
4324 | var _564=self._disconnect; |
---|
4325 | var _565=self._observers; |
---|
4326 | if(_563.length===0){ |
---|
4327 | for(var i=_565.length-1;i>=0;i--){ |
---|
4328 | var _566=_565[i]; |
---|
4329 | if(_566[0]===src){ |
---|
4330 | _564(_566); |
---|
4331 | _565.splice(i,1); |
---|
4332 | } |
---|
4333 | } |
---|
4334 | }else{ |
---|
4335 | var sigs={}; |
---|
4336 | for(var i=0;i<_563.length;i++){ |
---|
4337 | sigs[_563[i]]=true; |
---|
4338 | } |
---|
4339 | for(var i=_565.length-1;i>=0;i--){ |
---|
4340 | var _566=_565[i]; |
---|
4341 | if(_566[0]===src&&_566[1] in sigs){ |
---|
4342 | _564(_566); |
---|
4343 | _565.splice(i,1); |
---|
4344 | } |
---|
4345 | } |
---|
4346 | } |
---|
4347 | },signal:function(src,sig){ |
---|
4348 | var _568=MochiKit.Signal._observers; |
---|
4349 | src=MochiKit.DOM.getElement(src); |
---|
4350 | var args=MochiKit.Base.extend(null,arguments,2); |
---|
4351 | var _569=[]; |
---|
4352 | for(var i=0;i<_568.length;i++){ |
---|
4353 | var _570=_568[i]; |
---|
4354 | if(_570[0]===src&&_570[1]===sig){ |
---|
4355 | try{ |
---|
4356 | _570[2].apply(src,args); |
---|
4357 | } |
---|
4358 | catch(e){ |
---|
4359 | _569.push(e); |
---|
4360 | } |
---|
4361 | } |
---|
4362 | } |
---|
4363 | if(_569.length==1){ |
---|
4364 | throw _569[0]; |
---|
4365 | }else{ |
---|
4366 | if(_569.length>1){ |
---|
4367 | var e=new Error("Multiple errors thrown in handling 'sig', see errors property"); |
---|
4368 | e.errors=_569; |
---|
4369 | throw e; |
---|
4370 | } |
---|
4371 | } |
---|
4372 | }}); |
---|
4373 | MochiKit.Signal.EXPORT_OK=[]; |
---|
4374 | MochiKit.Signal.EXPORT=["connect","disconnect","signal","disconnectAll"]; |
---|
4375 | MochiKit.Signal.__new__=function(win){ |
---|
4376 | var m=MochiKit.Base; |
---|
4377 | this._document=document; |
---|
4378 | this._window=win; |
---|
4379 | try{ |
---|
4380 | this.connect(window,"onunload",this._unloadCache); |
---|
4381 | } |
---|
4382 | catch(e){ |
---|
4383 | } |
---|
4384 | this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; |
---|
4385 | m.nameFunctions(this); |
---|
4386 | }; |
---|
4387 | MochiKit.Signal.__new__(this); |
---|
4388 | if(!MochiKit.__compat__){ |
---|
4389 | connect=MochiKit.Signal.connect; |
---|
4390 | disconnect=MochiKit.Signal.disconnect; |
---|
4391 | disconnectAll=MochiKit.Signal.disconnectAll; |
---|
4392 | signal=MochiKit.Signal.signal; |
---|
4393 | } |
---|
4394 | MochiKit.Base._exportSymbols(this,MochiKit.Signal); |
---|
4395 | if(typeof (dojo)!="undefined"){ |
---|
4396 | dojo.provide("MochiKit.Visual"); |
---|
4397 | dojo.require("MochiKit.Base"); |
---|
4398 | dojo.require("MochiKit.DOM"); |
---|
4399 | dojo.require("MochiKit.Color"); |
---|
4400 | } |
---|
4401 | if(typeof (JSAN)!="undefined"){ |
---|
4402 | JSAN.use("MochiKit.Base",[]); |
---|
4403 | JSAN.use("MochiKit.DOM",[]); |
---|
4404 | JSAN.use("MochiKit.Color",[]); |
---|
4405 | } |
---|
4406 | try{ |
---|
4407 | if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.DOM)=="undefined"||typeof (MochiKit.Color)=="undefined"){ |
---|
4408 | throw ""; |
---|
4409 | } |
---|
4410 | } |
---|
4411 | catch(e){ |
---|
4412 | throw "MochiKit.Visual depends on MochiKit.Base, MochiKit.DOM and MochiKit.Color!"; |
---|
4413 | } |
---|
4414 | if(typeof (MochiKit.Visual)=="undefined"){ |
---|
4415 | MochiKit.Visual={}; |
---|
4416 | } |
---|
4417 | MochiKit.Visual.NAME="MochiKit.Visual"; |
---|
4418 | MochiKit.Visual.VERSION="1.3.1"; |
---|
4419 | MochiKit.Visual.__repr__=function(){ |
---|
4420 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
4421 | }; |
---|
4422 | MochiKit.Visual.toString=function(){ |
---|
4423 | return this.__repr__(); |
---|
4424 | }; |
---|
4425 | MochiKit.Visual._RoundCorners=function(e,_571){ |
---|
4426 | e=MochiKit.DOM.getElement(e); |
---|
4427 | this._setOptions(_571); |
---|
4428 | if(this.options.__unstable__wrapElement){ |
---|
4429 | e=this._doWrap(e); |
---|
4430 | } |
---|
4431 | var _572=this.options.color; |
---|
4432 | var C=MochiKit.Color.Color; |
---|
4433 | if(this.options.color=="fromElement"){ |
---|
4434 | _572=C.fromBackground(e); |
---|
4435 | }else{ |
---|
4436 | if(!(_572 instanceof C)){ |
---|
4437 | _572=C.fromString(_572); |
---|
4438 | } |
---|
4439 | } |
---|
4440 | this.isTransparent=(_572.asRGB().a<=0); |
---|
4441 | var _574=this.options.bgColor; |
---|
4442 | if(this.options.bgColor=="fromParent"){ |
---|
4443 | _574=C.fromBackground(e.offsetParent); |
---|
4444 | }else{ |
---|
4445 | if(!(_574 instanceof C)){ |
---|
4446 | _574=C.fromString(_574); |
---|
4447 | } |
---|
4448 | } |
---|
4449 | this._roundCornersImpl(e,_572,_574); |
---|
4450 | }; |
---|
4451 | MochiKit.Visual._RoundCorners.prototype={_doWrap:function(e){ |
---|
4452 | var _575=e.parentNode; |
---|
4453 | var doc=MochiKit.DOM.currentDocument(); |
---|
4454 | if(typeof (doc.defaultView)=="undefined"||doc.defaultView===null){ |
---|
4455 | return e; |
---|
4456 | } |
---|
4457 | var _576=doc.defaultView.getComputedStyle(e,null); |
---|
4458 | if(typeof (_576)=="undefined"||_576===null){ |
---|
4459 | return e; |
---|
4460 | } |
---|
4461 | var _577=MochiKit.DOM.DIV({"style":{display:"block",marginTop:_576.getPropertyValue("padding-top"),marginRight:_576.getPropertyValue("padding-right"),marginBottom:_576.getPropertyValue("padding-bottom"),marginLeft:_576.getPropertyValue("padding-left"),padding:"0px"}}); |
---|
4462 | _577.innerHTML=e.innerHTML; |
---|
4463 | e.innerHTML=""; |
---|
4464 | e.appendChild(_577); |
---|
4465 | return e; |
---|
4466 | },_roundCornersImpl:function(e,_578,_579){ |
---|
4467 | if(this.options.border){ |
---|
4468 | this._renderBorder(e,_579); |
---|
4469 | } |
---|
4470 | if(this._isTopRounded()){ |
---|
4471 | this._roundTopCorners(e,_578,_579); |
---|
4472 | } |
---|
4473 | if(this._isBottomRounded()){ |
---|
4474 | this._roundBottomCorners(e,_578,_579); |
---|
4475 | } |
---|
4476 | },_renderBorder:function(el,_580){ |
---|
4477 | var _581="1px solid "+this._borderColor(_580); |
---|
4478 | var _582="border-left: "+_581; |
---|
4479 | var _583="border-right: "+_581; |
---|
4480 | var _584="style='"+_582+";"+_583+"'"; |
---|
4481 | el.innerHTML="<div "+_584+">"+el.innerHTML+"</div>"; |
---|
4482 | },_roundTopCorners:function(el,_585,_586){ |
---|
4483 | var _587=this._createCorner(_586); |
---|
4484 | for(var i=0;i<this.options.numSlices;i++){ |
---|
4485 | _587.appendChild(this._createCornerSlice(_585,_586,i,"top")); |
---|
4486 | } |
---|
4487 | el.style.paddingTop=0; |
---|
4488 | el.insertBefore(_587,el.firstChild); |
---|
4489 | },_roundBottomCorners:function(el,_588,_589){ |
---|
4490 | var _590=this._createCorner(_589); |
---|
4491 | for(var i=(this.options.numSlices-1);i>=0;i--){ |
---|
4492 | _590.appendChild(this._createCornerSlice(_588,_589,i,"bottom")); |
---|
4493 | } |
---|
4494 | el.style.paddingBottom=0; |
---|
4495 | el.appendChild(_590); |
---|
4496 | },_createCorner:function(_591){ |
---|
4497 | var dom=MochiKit.DOM; |
---|
4498 | return dom.DIV({style:{backgroundColor:_591.toString()}}); |
---|
4499 | },_createCornerSlice:function(_592,_593,n,_594){ |
---|
4500 | var _595=MochiKit.DOM.SPAN(); |
---|
4501 | var _596=_595.style; |
---|
4502 | _596.backgroundColor=_592.toString(); |
---|
4503 | _596.display="block"; |
---|
4504 | _596.height="1px"; |
---|
4505 | _596.overflow="hidden"; |
---|
4506 | _596.fontSize="1px"; |
---|
4507 | var _597=this._borderColor(_592,_593); |
---|
4508 | if(this.options.border&&n===0){ |
---|
4509 | _596.borderTopStyle="solid"; |
---|
4510 | _596.borderTopWidth="1px"; |
---|
4511 | _596.borderLeftWidth="0px"; |
---|
4512 | _596.borderRightWidth="0px"; |
---|
4513 | _596.borderBottomWidth="0px"; |
---|
4514 | _596.height="0px"; |
---|
4515 | _596.borderColor=_597.toString(); |
---|
4516 | }else{ |
---|
4517 | if(_597){ |
---|
4518 | _596.borderColor=_597.toString(); |
---|
4519 | _596.borderStyle="solid"; |
---|
4520 | _596.borderWidth="0px 1px"; |
---|
4521 | } |
---|
4522 | } |
---|
4523 | if(!this.options.compact&&(n==(this.options.numSlices-1))){ |
---|
4524 | _596.height="2px"; |
---|
4525 | } |
---|
4526 | this._setMargin(_595,n,_594); |
---|
4527 | this._setBorder(_595,n,_594); |
---|
4528 | return _595; |
---|
4529 | },_setOptions:function(_598){ |
---|
4530 | this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false,__unstable__wrapElement:false}; |
---|
4531 | MochiKit.Base.update(this.options,_598); |
---|
4532 | this.options.numSlices=(this.options.compact?2:4); |
---|
4533 | },_whichSideTop:function(){ |
---|
4534 | var _599=this.options.corners; |
---|
4535 | if(this._hasString(_599,"all","top")){ |
---|
4536 | return ""; |
---|
4537 | } |
---|
4538 | var _600=(_599.indexOf("tl")!=-1); |
---|
4539 | var _601=(_599.indexOf("tr")!=-1); |
---|
4540 | if(_600&&_601){ |
---|
4541 | return ""; |
---|
4542 | } |
---|
4543 | if(_600){ |
---|
4544 | return "left"; |
---|
4545 | } |
---|
4546 | if(_601){ |
---|
4547 | return "right"; |
---|
4548 | } |
---|
4549 | return ""; |
---|
4550 | },_whichSideBottom:function(){ |
---|
4551 | var _602=this.options.corners; |
---|
4552 | if(this._hasString(_602,"all","bottom")){ |
---|
4553 | return ""; |
---|
4554 | } |
---|
4555 | var _603=(_602.indexOf("bl")!=-1); |
---|
4556 | var _604=(_602.indexOf("br")!=-1); |
---|
4557 | if(_603&&_604){ |
---|
4558 | return ""; |
---|
4559 | } |
---|
4560 | if(_603){ |
---|
4561 | return "left"; |
---|
4562 | } |
---|
4563 | if(_604){ |
---|
4564 | return "right"; |
---|
4565 | } |
---|
4566 | return ""; |
---|
4567 | },_borderColor:function(_605,_606){ |
---|
4568 | if(_605=="transparent"){ |
---|
4569 | return _606; |
---|
4570 | }else{ |
---|
4571 | if(this.options.border){ |
---|
4572 | return this.options.border; |
---|
4573 | }else{ |
---|
4574 | if(this.options.blend){ |
---|
4575 | return _606.blendedColor(_605); |
---|
4576 | } |
---|
4577 | } |
---|
4578 | } |
---|
4579 | return ""; |
---|
4580 | },_setMargin:function(el,n,_607){ |
---|
4581 | var _608=this._marginSize(n)+"px"; |
---|
4582 | var _609=(_607=="top"?this._whichSideTop():this._whichSideBottom()); |
---|
4583 | var _610=el.style; |
---|
4584 | if(_609=="left"){ |
---|
4585 | _610.marginLeft=_608; |
---|
4586 | _610.marginRight="0px"; |
---|
4587 | }else{ |
---|
4588 | if(_609=="right"){ |
---|
4589 | _610.marginRight=_608; |
---|
4590 | _610.marginLeft="0px"; |
---|
4591 | }else{ |
---|
4592 | _610.marginLeft=_608; |
---|
4593 | _610.marginRight=_608; |
---|
4594 | } |
---|
4595 | } |
---|
4596 | },_setBorder:function(el,n,_611){ |
---|
4597 | var _612=this._borderSize(n)+"px"; |
---|
4598 | var _613=(_611=="top"?this._whichSideTop():this._whichSideBottom()); |
---|
4599 | var _614=el.style; |
---|
4600 | if(_613=="left"){ |
---|
4601 | _614.borderLeftWidth=_612; |
---|
4602 | _614.borderRightWidth="0px"; |
---|
4603 | }else{ |
---|
4604 | if(_613=="right"){ |
---|
4605 | _614.borderRightWidth=_612; |
---|
4606 | _614.borderLeftWidth="0px"; |
---|
4607 | }else{ |
---|
4608 | _614.borderLeftWidth=_612; |
---|
4609 | _614.borderRightWidth=_612; |
---|
4610 | } |
---|
4611 | } |
---|
4612 | },_marginSize:function(n){ |
---|
4613 | if(this.isTransparent){ |
---|
4614 | return 0; |
---|
4615 | } |
---|
4616 | var o=this.options; |
---|
4617 | if(o.compact&&o.blend){ |
---|
4618 | var _615=[1,0]; |
---|
4619 | return _615[n]; |
---|
4620 | }else{ |
---|
4621 | if(o.compact){ |
---|
4622 | var _616=[2,1]; |
---|
4623 | return _616[n]; |
---|
4624 | }else{ |
---|
4625 | if(o.blend){ |
---|
4626 | var _617=[3,2,1,0]; |
---|
4627 | return _617[n]; |
---|
4628 | }else{ |
---|
4629 | var _618=[5,3,2,1]; |
---|
4630 | return _618[n]; |
---|
4631 | } |
---|
4632 | } |
---|
4633 | } |
---|
4634 | },_borderSize:function(n){ |
---|
4635 | var o=this.options; |
---|
4636 | var _619; |
---|
4637 | if(o.compact&&(o.blend||this.isTransparent)){ |
---|
4638 | return 1; |
---|
4639 | }else{ |
---|
4640 | if(o.compact){ |
---|
4641 | _619=[1,0]; |
---|
4642 | }else{ |
---|
4643 | if(o.blend){ |
---|
4644 | _619=[2,1,1,1]; |
---|
4645 | }else{ |
---|
4646 | if(o.border){ |
---|
4647 | _619=[0,2,0,0]; |
---|
4648 | }else{ |
---|
4649 | if(this.isTransparent){ |
---|
4650 | _619=[5,3,2,1]; |
---|
4651 | }else{ |
---|
4652 | return 0; |
---|
4653 | } |
---|
4654 | } |
---|
4655 | } |
---|
4656 | } |
---|
4657 | } |
---|
4658 | return _619[n]; |
---|
4659 | },_hasString:function(str){ |
---|
4660 | for(var i=1;i<arguments.length;i++){ |
---|
4661 | if(str.indexOf(arguments[i])!=-1){ |
---|
4662 | return true; |
---|
4663 | } |
---|
4664 | } |
---|
4665 | return false; |
---|
4666 | },_isTopRounded:function(){ |
---|
4667 | return this._hasString(this.options.corners,"all","top","tl","tr"); |
---|
4668 | },_isBottomRounded:function(){ |
---|
4669 | return this._hasString(this.options.corners,"all","bottom","bl","br"); |
---|
4670 | },_hasSingleTextChild:function(el){ |
---|
4671 | return (el.childNodes.length==1&&el.childNodes[0].nodeType==3); |
---|
4672 | }}; |
---|
4673 | MochiKit.Visual.roundElement=function(e,_620){ |
---|
4674 | new MochiKit.Visual._RoundCorners(e,_620); |
---|
4675 | }; |
---|
4676 | MochiKit.Visual.roundClass=function(_621,_622,_623){ |
---|
4677 | var _624=MochiKit.DOM.getElementsByTagAndClassName(_621,_622); |
---|
4678 | for(var i=0;i<_624.length;i++){ |
---|
4679 | MochiKit.Visual.roundElement(_624[i],_623); |
---|
4680 | } |
---|
4681 | }; |
---|
4682 | MochiKit.Visual.Color=MochiKit.Color.Color; |
---|
4683 | MochiKit.Visual.getElementsComputedStyle=MochiKit.DOM.computedStyle; |
---|
4684 | MochiKit.Visual.__new__=function(){ |
---|
4685 | var m=MochiKit.Base; |
---|
4686 | m.nameFunctions(this); |
---|
4687 | this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; |
---|
4688 | }; |
---|
4689 | MochiKit.Visual.EXPORT=["roundElement","roundClass"]; |
---|
4690 | MochiKit.Visual.EXPORT_OK=[]; |
---|
4691 | MochiKit.Visual.__new__(); |
---|
4692 | MochiKit.Base._exportSymbols(this,MochiKit.Visual); |
---|
4693 | if(typeof (MochiKit)=="undefined"){ |
---|
4694 | MochiKit={}; |
---|
4695 | } |
---|
4696 | if(typeof (MochiKit.MochiKit)=="undefined"){ |
---|
4697 | MochiKit.MochiKit={}; |
---|
4698 | } |
---|
4699 | MochiKit.MochiKit.NAME="MochiKit.MochiKit"; |
---|
4700 | MochiKit.MochiKit.VERSION="1.3.1"; |
---|
4701 | MochiKit.MochiKit.__repr__=function(){ |
---|
4702 | return "["+this.NAME+" "+this.VERSION+"]"; |
---|
4703 | }; |
---|
4704 | MochiKit.MochiKit.toString=function(){ |
---|
4705 | return this.__repr__(); |
---|
4706 | }; |
---|
4707 | MochiKit.MochiKit.SUBMODULES=["Base","Iter","Logging","DateTime","Format","Async","DOM","LoggingPane","Color","Signal","Visual"]; |
---|
4708 | if(typeof (JSAN)!="undefined"||typeof (dojo)!="undefined"){ |
---|
4709 | if(typeof (dojo)!="undefined"){ |
---|
4710 | dojo.provide("MochiKit.MochiKit"); |
---|
4711 | dojo.require("MochiKit.*"); |
---|
4712 | } |
---|
4713 | if(typeof (JSAN)!="undefined"){ |
---|
4714 | JSAN.use("MochiKit.Base",[]); |
---|
4715 | JSAN.use("MochiKit.Iter",[]); |
---|
4716 | JSAN.use("MochiKit.Logging",[]); |
---|
4717 | JSAN.use("MochiKit.DateTime",[]); |
---|
4718 | JSAN.use("MochiKit.Format",[]); |
---|
4719 | JSAN.use("MochiKit.Async",[]); |
---|
4720 | JSAN.use("MochiKit.DOM",[]); |
---|
4721 | JSAN.use("MochiKit.LoggingPane",[]); |
---|
4722 | JSAN.use("MochiKit.Color",[]); |
---|
4723 | JSAN.use("MochiKit.Signal",[]); |
---|
4724 | JSAN.use("MochiKit.Visual",[]); |
---|
4725 | } |
---|
4726 | (function(){ |
---|
4727 | var _625=MochiKit.Base.extend; |
---|
4728 | var self=MochiKit.MochiKit; |
---|
4729 | var _626=self.SUBMODULES; |
---|
4730 | var _627=[]; |
---|
4731 | var _628=[]; |
---|
4732 | var _629={}; |
---|
4733 | var i,k,m,all; |
---|
4734 | for(i=0;i<_626.length;i++){ |
---|
4735 | m=MochiKit[_626[i]]; |
---|
4736 | _625(_627,m.EXPORT); |
---|
4737 | _625(_628,m.EXPORT_OK); |
---|
4738 | for(k in m.EXPORT_TAGS){ |
---|
4739 | _629[k]=_625(_629[k],m.EXPORT_TAGS[k]); |
---|
4740 | } |
---|
4741 | all=m.EXPORT_TAGS[":all"]; |
---|
4742 | if(!all){ |
---|
4743 | all=_625(null,m.EXPORT,m.EXPORT_OK); |
---|
4744 | } |
---|
4745 | var j; |
---|
4746 | for(j=0;j<all.length;j++){ |
---|
4747 | k=all[j]; |
---|
4748 | self[k]=m[k]; |
---|
4749 | } |
---|
4750 | } |
---|
4751 | self.EXPORT=_627; |
---|
4752 | self.EXPORT_OK=_628; |
---|
4753 | self.EXPORT_TAGS=_629; |
---|
4754 | }()); |
---|
4755 | }else{ |
---|
4756 | if(typeof (MochiKit.__compat__)=="undefined"){ |
---|
4757 | MochiKit.__compat__=true; |
---|
4758 | } |
---|
4759 | (function(){ |
---|
4760 | var _630=document.getElementsByTagName("script"); |
---|
4761 | var _631="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
4762 | var base=null; |
---|
4763 | var _632=null; |
---|
4764 | var _633={}; |
---|
4765 | var i; |
---|
4766 | for(i=0;i<_630.length;i++){ |
---|
4767 | var src=_630[i].getAttribute("src"); |
---|
4768 | if(!src){ |
---|
4769 | continue; |
---|
4770 | } |
---|
4771 | _633[src]=true; |
---|
4772 | if(src.match(/MochiKit.js$/)){ |
---|
4773 | base=src.substring(0,src.lastIndexOf("MochiKit.js")); |
---|
4774 | _632=_630[i]; |
---|
4775 | } |
---|
4776 | } |
---|
4777 | if(base===null){ |
---|
4778 | return; |
---|
4779 | } |
---|
4780 | var _634=MochiKit.MochiKit.SUBMODULES; |
---|
4781 | for(var i=0;i<_634.length;i++){ |
---|
4782 | if(MochiKit[_634[i]]){ |
---|
4783 | continue; |
---|
4784 | } |
---|
4785 | var uri=base+_634[i]+".js"; |
---|
4786 | if(uri in _633){ |
---|
4787 | continue; |
---|
4788 | } |
---|
4789 | if(document.documentElement&&document.documentElement.namespaceURI==_631){ |
---|
4790 | var s=document.createElementNS(_631,"script"); |
---|
4791 | s.setAttribute("id","MochiKit_"+base+_634[i]); |
---|
4792 | s.setAttribute("src",uri); |
---|
4793 | s.setAttribute("type","application/x-javascript"); |
---|
4794 | _632.parentNode.appendChild(s); |
---|
4795 | }else{ |
---|
4796 | document.write("<script src=\""+uri+"\" type=\"text/javascript\"></script>"); |
---|
4797 | } |
---|
4798 | } |
---|
4799 | })(); |
---|
4800 | } |
---|
4801 | |
---|
4802 | |
---|