testing/mochitest/MochiKit/packed.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /***
michael@0 2
michael@0 3 MochiKit.MochiKit 1.4 : PACKED VERSION
michael@0 4
michael@0 5 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
michael@0 6 diff against the source tree, not this file.
michael@0 7
michael@0 8 See <http://mochikit.com/> for documentation, downloads, license, etc.
michael@0 9
michael@0 10 (c) 2005 Bob Ippolito. All rights Reserved.
michael@0 11
michael@0 12 ***/
michael@0 13
michael@0 14 if(typeof (dojo)!="undefined"){
michael@0 15 dojo.provide("MochiKit.Base");
michael@0 16 }
michael@0 17 if(typeof (MochiKit)=="undefined"){
michael@0 18 MochiKit={};
michael@0 19 }
michael@0 20 if(typeof (MochiKit.Base)=="undefined"){
michael@0 21 MochiKit.Base={};
michael@0 22 }
michael@0 23 if(typeof (MochiKit.__export__)=="undefined"){
michael@0 24 MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined"));
michael@0 25 }
michael@0 26 MochiKit.Base.VERSION="1.4";
michael@0 27 MochiKit.Base.NAME="MochiKit.Base";
michael@0 28 MochiKit.Base.update=function(_1,_2){
michael@0 29 if(_1===null){
michael@0 30 _1={};
michael@0 31 }
michael@0 32 for(var i=1;i<arguments.length;i++){
michael@0 33 var o=arguments[i];
michael@0 34 if(typeof (o)!="undefined"&&o!==null){
michael@0 35 for(var k in o){
michael@0 36 _1[k]=o[k];
michael@0 37 }
michael@0 38 }
michael@0 39 }
michael@0 40 return _1;
michael@0 41 };
michael@0 42 MochiKit.Base.update(MochiKit.Base,{__repr__:function(){
michael@0 43 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 44 },toString:function(){
michael@0 45 return this.__repr__();
michael@0 46 },camelize:function(_6){
michael@0 47 var _7=_6.split("-");
michael@0 48 var cc=_7[0];
michael@0 49 for(var i=1;i<_7.length;i++){
michael@0 50 cc+=_7[i].charAt(0).toUpperCase()+_7[i].substring(1);
michael@0 51 }
michael@0 52 return cc;
michael@0 53 },counter:function(n){
michael@0 54 if(arguments.length===0){
michael@0 55 n=1;
michael@0 56 }
michael@0 57 return function(){
michael@0 58 return n++;
michael@0 59 };
michael@0 60 },clone:function(_b){
michael@0 61 var me=arguments.callee;
michael@0 62 if(arguments.length==1){
michael@0 63 me.prototype=_b;
michael@0 64 return new me();
michael@0 65 }
michael@0 66 },_flattenArray:function(_d,_e){
michael@0 67 for(var i=0;i<_e.length;i++){
michael@0 68 var o=_e[i];
michael@0 69 if(o instanceof Array){
michael@0 70 arguments.callee(_d,o);
michael@0 71 }else{
michael@0 72 _d.push(o);
michael@0 73 }
michael@0 74 }
michael@0 75 return _d;
michael@0 76 },flattenArray:function(lst){
michael@0 77 return MochiKit.Base._flattenArray([],lst);
michael@0 78 },flattenArguments:function(lst){
michael@0 79 var res=[];
michael@0 80 var m=MochiKit.Base;
michael@0 81 var _15=m.extend(null,arguments);
michael@0 82 while(_15.length){
michael@0 83 var o=_15.shift();
michael@0 84 if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){
michael@0 85 for(var i=o.length-1;i>=0;i--){
michael@0 86 _15.unshift(o[i]);
michael@0 87 }
michael@0 88 }else{
michael@0 89 res.push(o);
michael@0 90 }
michael@0 91 }
michael@0 92 return res;
michael@0 93 },extend:function(_18,obj,_1a){
michael@0 94 if(!_1a){
michael@0 95 _1a=0;
michael@0 96 }
michael@0 97 if(obj){
michael@0 98 var l=obj.length;
michael@0 99 if(typeof (l)!="number"){
michael@0 100 if(typeof (MochiKit.Iter)!="undefined"){
michael@0 101 obj=MochiKit.Iter.list(obj);
michael@0 102 l=obj.length;
michael@0 103 }else{
michael@0 104 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
michael@0 105 }
michael@0 106 }
michael@0 107 if(!_18){
michael@0 108 _18=[];
michael@0 109 }
michael@0 110 for(var i=_1a;i<l;i++){
michael@0 111 _18.push(obj[i]);
michael@0 112 }
michael@0 113 }
michael@0 114 return _18;
michael@0 115 },updatetree:function(_1d,obj){
michael@0 116 if(_1d===null){
michael@0 117 _1d={};
michael@0 118 }
michael@0 119 for(var i=1;i<arguments.length;i++){
michael@0 120 var o=arguments[i];
michael@0 121 if(typeof (o)!="undefined"&&o!==null){
michael@0 122 for(var k in o){
michael@0 123 var v=o[k];
michael@0 124 if(typeof (_1d[k])=="object"&&typeof (v)=="object"){
michael@0 125 arguments.callee(_1d[k],v);
michael@0 126 }else{
michael@0 127 _1d[k]=v;
michael@0 128 }
michael@0 129 }
michael@0 130 }
michael@0 131 }
michael@0 132 return _1d;
michael@0 133 },setdefault:function(_23,obj){
michael@0 134 if(_23===null){
michael@0 135 _23={};
michael@0 136 }
michael@0 137 for(var i=1;i<arguments.length;i++){
michael@0 138 var o=arguments[i];
michael@0 139 for(var k in o){
michael@0 140 if(!(k in _23)){
michael@0 141 _23[k]=o[k];
michael@0 142 }
michael@0 143 }
michael@0 144 }
michael@0 145 return _23;
michael@0 146 },keys:function(obj){
michael@0 147 var _29=[];
michael@0 148 for(var _2a in obj){
michael@0 149 _29.push(_2a);
michael@0 150 }
michael@0 151 return _29;
michael@0 152 },values:function(obj){
michael@0 153 var _2c=[];
michael@0 154 for(var _2d in obj){
michael@0 155 _2c.push(obj[_2d]);
michael@0 156 }
michael@0 157 return _2c;
michael@0 158 },items:function(obj){
michael@0 159 var _2f=[];
michael@0 160 var e;
michael@0 161 for(var _31 in obj){
michael@0 162 var v;
michael@0 163 try{
michael@0 164 v=obj[_31];
michael@0 165 }
michael@0 166 catch(e){
michael@0 167 continue;
michael@0 168 }
michael@0 169 _2f.push([_31,v]);
michael@0 170 }
michael@0 171 return _2f;
michael@0 172 },_newNamedError:function(_33,_34,_35){
michael@0 173 _35.prototype=new MochiKit.Base.NamedError(_33.NAME+"."+_34);
michael@0 174 _33[_34]=_35;
michael@0 175 },operator:{truth:function(a){
michael@0 176 return !!a;
michael@0 177 },lognot:function(a){
michael@0 178 return !a;
michael@0 179 },identity:function(a){
michael@0 180 return a;
michael@0 181 },not:function(a){
michael@0 182 return ~a;
michael@0 183 },neg:function(a){
michael@0 184 return -a;
michael@0 185 },add:function(a,b){
michael@0 186 return a+b;
michael@0 187 },sub:function(a,b){
michael@0 188 return a-b;
michael@0 189 },div:function(a,b){
michael@0 190 return a/b;
michael@0 191 },mod:function(a,b){
michael@0 192 return a%b;
michael@0 193 },mul:function(a,b){
michael@0 194 return a*b;
michael@0 195 },and:function(a,b){
michael@0 196 return a&b;
michael@0 197 },or:function(a,b){
michael@0 198 return a|b;
michael@0 199 },xor:function(a,b){
michael@0 200 return a^b;
michael@0 201 },lshift:function(a,b){
michael@0 202 return a<<b;
michael@0 203 },rshift:function(a,b){
michael@0 204 return a>>b;
michael@0 205 },zrshift:function(a,b){
michael@0 206 return a>>>b;
michael@0 207 },eq:function(a,b){
michael@0 208 return a==b;
michael@0 209 },ne:function(a,b){
michael@0 210 return a!=b;
michael@0 211 },gt:function(a,b){
michael@0 212 return a>b;
michael@0 213 },ge:function(a,b){
michael@0 214 return a>=b;
michael@0 215 },lt:function(a,b){
michael@0 216 return a<b;
michael@0 217 },le:function(a,b){
michael@0 218 return a<=b;
michael@0 219 },seq:function(a,b){
michael@0 220 return a===b;
michael@0 221 },sne:function(a,b){
michael@0 222 return a!==b;
michael@0 223 },ceq:function(a,b){
michael@0 224 return MochiKit.Base.compare(a,b)===0;
michael@0 225 },cne:function(a,b){
michael@0 226 return MochiKit.Base.compare(a,b)!==0;
michael@0 227 },cgt:function(a,b){
michael@0 228 return MochiKit.Base.compare(a,b)==1;
michael@0 229 },cge:function(a,b){
michael@0 230 return MochiKit.Base.compare(a,b)!=-1;
michael@0 231 },clt:function(a,b){
michael@0 232 return MochiKit.Base.compare(a,b)==-1;
michael@0 233 },cle:function(a,b){
michael@0 234 return MochiKit.Base.compare(a,b)!=1;
michael@0 235 },logand:function(a,b){
michael@0 236 return a&&b;
michael@0 237 },logor:function(a,b){
michael@0 238 return a||b;
michael@0 239 },contains:function(a,b){
michael@0 240 return b in a;
michael@0 241 }},forwardCall:function(_73){
michael@0 242 return function(){
michael@0 243 return this[_73].apply(this,arguments);
michael@0 244 };
michael@0 245 },itemgetter:function(_74){
michael@0 246 return function(arg){
michael@0 247 return arg[_74];
michael@0 248 };
michael@0 249 },typeMatcher:function(){
michael@0 250 var _76={};
michael@0 251 for(var i=0;i<arguments.length;i++){
michael@0 252 var typ=arguments[i];
michael@0 253 _76[typ]=typ;
michael@0 254 }
michael@0 255 return function(){
michael@0 256 for(var i=0;i<arguments.length;i++){
michael@0 257 if(!(typeof (arguments[i]) in _76)){
michael@0 258 return false;
michael@0 259 }
michael@0 260 }
michael@0 261 return true;
michael@0 262 };
michael@0 263 },isNull:function(){
michael@0 264 for(var i=0;i<arguments.length;i++){
michael@0 265 if(arguments[i]!==null){
michael@0 266 return false;
michael@0 267 }
michael@0 268 }
michael@0 269 return true;
michael@0 270 },isUndefinedOrNull:function(){
michael@0 271 for(var i=0;i<arguments.length;i++){
michael@0 272 var o=arguments[i];
michael@0 273 if(!(typeof (o)=="undefined"||o===null)){
michael@0 274 return false;
michael@0 275 }
michael@0 276 }
michael@0 277 return true;
michael@0 278 },isEmpty:function(obj){
michael@0 279 return !MochiKit.Base.isNotEmpty.apply(this,arguments);
michael@0 280 },isNotEmpty:function(obj){
michael@0 281 for(var i=0;i<arguments.length;i++){
michael@0 282 var o=arguments[i];
michael@0 283 if(!(o&&o.length)){
michael@0 284 return false;
michael@0 285 }
michael@0 286 }
michael@0 287 return true;
michael@0 288 },isArrayLike:function(){
michael@0 289 for(var i=0;i<arguments.length;i++){
michael@0 290 var o=arguments[i];
michael@0 291 var typ=typeof (o);
michael@0 292 if((typ!="object"&&!(typ=="function"&&typeof (o.item)=="function"))||o===null||typeof (o.length)!="number"||o.nodeType===3){
michael@0 293 return false;
michael@0 294 }
michael@0 295 }
michael@0 296 return true;
michael@0 297 },isDateLike:function(){
michael@0 298 for(var i=0;i<arguments.length;i++){
michael@0 299 var o=arguments[i];
michael@0 300 if(typeof (o)!="object"||o===null||typeof (o.getTime)!="function"){
michael@0 301 return false;
michael@0 302 }
michael@0 303 }
michael@0 304 return true;
michael@0 305 },xmap:function(fn){
michael@0 306 if(fn===null){
michael@0 307 return MochiKit.Base.extend(null,arguments,1);
michael@0 308 }
michael@0 309 var _87=[];
michael@0 310 for(var i=1;i<arguments.length;i++){
michael@0 311 _87.push(fn(arguments[i]));
michael@0 312 }
michael@0 313 return _87;
michael@0 314 },map:function(fn,lst){
michael@0 315 var m=MochiKit.Base;
michael@0 316 var itr=MochiKit.Iter;
michael@0 317 var _8d=m.isArrayLike;
michael@0 318 if(arguments.length<=2){
michael@0 319 if(!_8d(lst)){
michael@0 320 if(itr){
michael@0 321 lst=itr.list(lst);
michael@0 322 if(fn===null){
michael@0 323 return lst;
michael@0 324 }
michael@0 325 }else{
michael@0 326 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
michael@0 327 }
michael@0 328 }
michael@0 329 if(fn===null){
michael@0 330 return m.extend(null,lst);
michael@0 331 }
michael@0 332 var _8e=[];
michael@0 333 for(var i=0;i<lst.length;i++){
michael@0 334 _8e.push(fn(lst[i]));
michael@0 335 }
michael@0 336 return _8e;
michael@0 337 }else{
michael@0 338 if(fn===null){
michael@0 339 fn=Array;
michael@0 340 }
michael@0 341 var _90=null;
michael@0 342 for(i=1;i<arguments.length;i++){
michael@0 343 if(!_8d(arguments[i])){
michael@0 344 if(itr){
michael@0 345 return itr.list(itr.imap.apply(null,arguments));
michael@0 346 }else{
michael@0 347 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
michael@0 348 }
michael@0 349 }
michael@0 350 var l=arguments[i].length;
michael@0 351 if(_90===null||_90>l){
michael@0 352 _90=l;
michael@0 353 }
michael@0 354 }
michael@0 355 _8e=[];
michael@0 356 for(i=0;i<_90;i++){
michael@0 357 var _92=[];
michael@0 358 for(var j=1;j<arguments.length;j++){
michael@0 359 _92.push(arguments[j][i]);
michael@0 360 }
michael@0 361 _8e.push(fn.apply(this,_92));
michael@0 362 }
michael@0 363 return _8e;
michael@0 364 }
michael@0 365 },xfilter:function(fn){
michael@0 366 var _95=[];
michael@0 367 if(fn===null){
michael@0 368 fn=MochiKit.Base.operator.truth;
michael@0 369 }
michael@0 370 for(var i=1;i<arguments.length;i++){
michael@0 371 var o=arguments[i];
michael@0 372 if(fn(o)){
michael@0 373 _95.push(o);
michael@0 374 }
michael@0 375 }
michael@0 376 return _95;
michael@0 377 },filter:function(fn,lst,_9a){
michael@0 378 var _9b=[];
michael@0 379 var m=MochiKit.Base;
michael@0 380 if(!m.isArrayLike(lst)){
michael@0 381 if(MochiKit.Iter){
michael@0 382 lst=MochiKit.Iter.list(lst);
michael@0 383 }else{
michael@0 384 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
michael@0 385 }
michael@0 386 }
michael@0 387 if(fn===null){
michael@0 388 fn=m.operator.truth;
michael@0 389 }
michael@0 390 if(typeof (Array.prototype.filter)=="function"){
michael@0 391 return Array.prototype.filter.call(lst,fn,_9a);
michael@0 392 }else{
michael@0 393 if(typeof (_9a)=="undefined"||_9a===null){
michael@0 394 for(var i=0;i<lst.length;i++){
michael@0 395 var o=lst[i];
michael@0 396 if(fn(o)){
michael@0 397 _9b.push(o);
michael@0 398 }
michael@0 399 }
michael@0 400 }else{
michael@0 401 for(i=0;i<lst.length;i++){
michael@0 402 o=lst[i];
michael@0 403 if(fn.call(_9a,o)){
michael@0 404 _9b.push(o);
michael@0 405 }
michael@0 406 }
michael@0 407 }
michael@0 408 }
michael@0 409 return _9b;
michael@0 410 },_wrapDumbFunction:function(_9f){
michael@0 411 return function(){
michael@0 412 switch(arguments.length){
michael@0 413 case 0:
michael@0 414 return _9f();
michael@0 415 case 1:
michael@0 416 return _9f(arguments[0]);
michael@0 417 case 2:
michael@0 418 return _9f(arguments[0],arguments[1]);
michael@0 419 case 3:
michael@0 420 return _9f(arguments[0],arguments[1],arguments[2]);
michael@0 421 }
michael@0 422 var _a0=[];
michael@0 423 for(var i=0;i<arguments.length;i++){
michael@0 424 _a0.push("arguments["+i+"]");
michael@0 425 }
michael@0 426 return eval("(func("+_a0.join(",")+"))");
michael@0 427 };
michael@0 428 },methodcaller:function(_a2){
michael@0 429 var _a3=MochiKit.Base.extend(null,arguments,1);
michael@0 430 if(typeof (_a2)=="function"){
michael@0 431 return function(obj){
michael@0 432 return _a2.apply(obj,_a3);
michael@0 433 };
michael@0 434 }else{
michael@0 435 return function(obj){
michael@0 436 return obj[_a2].apply(obj,_a3);
michael@0 437 };
michael@0 438 }
michael@0 439 },method:function(_a6,_a7){
michael@0 440 var m=MochiKit.Base;
michael@0 441 return m.bind.apply(this,m.extend([_a7,_a6],arguments,2));
michael@0 442 },compose:function(f1,f2){
michael@0 443 var _ab=[];
michael@0 444 var m=MochiKit.Base;
michael@0 445 if(arguments.length===0){
michael@0 446 throw new TypeError("compose() requires at least one argument");
michael@0 447 }
michael@0 448 for(var i=0;i<arguments.length;i++){
michael@0 449 var fn=arguments[i];
michael@0 450 if(typeof (fn)!="function"){
michael@0 451 throw new TypeError(m.repr(fn)+" is not a function");
michael@0 452 }
michael@0 453 _ab.push(fn);
michael@0 454 }
michael@0 455 return function(){
michael@0 456 var _af=arguments;
michael@0 457 for(var i=_ab.length-1;i>=0;i--){
michael@0 458 _af=[_ab[i].apply(this,_af)];
michael@0 459 }
michael@0 460 return _af[0];
michael@0 461 };
michael@0 462 },bind:function(_b1,_b2){
michael@0 463 if(typeof (_b1)=="string"){
michael@0 464 _b1=_b2[_b1];
michael@0 465 }
michael@0 466 var _b3=_b1.im_func;
michael@0 467 var _b4=_b1.im_preargs;
michael@0 468 var _b5=_b1.im_self;
michael@0 469 var m=MochiKit.Base;
michael@0 470 if(typeof (_b1)=="function"&&typeof (_b1.apply)=="undefined"){
michael@0 471 _b1=m._wrapDumbFunction(_b1);
michael@0 472 }
michael@0 473 if(typeof (_b3)!="function"){
michael@0 474 _b3=_b1;
michael@0 475 }
michael@0 476 if(typeof (_b2)!="undefined"){
michael@0 477 _b5=_b2;
michael@0 478 }
michael@0 479 if(typeof (_b4)=="undefined"){
michael@0 480 _b4=[];
michael@0 481 }else{
michael@0 482 _b4=_b4.slice();
michael@0 483 }
michael@0 484 m.extend(_b4,arguments,2);
michael@0 485 var _b7=function(){
michael@0 486 var _b8=arguments;
michael@0 487 var me=arguments.callee;
michael@0 488 if(me.im_preargs.length>0){
michael@0 489 _b8=m.concat(me.im_preargs,_b8);
michael@0 490 }
michael@0 491 var _ba=me.im_self;
michael@0 492 if(!_ba){
michael@0 493 _ba=this;
michael@0 494 }
michael@0 495 return me.im_func.apply(_ba,_b8);
michael@0 496 };
michael@0 497 _b7.im_self=_b5;
michael@0 498 _b7.im_func=_b3;
michael@0 499 _b7.im_preargs=_b4;
michael@0 500 return _b7;
michael@0 501 },bindMethods:function(_bb){
michael@0 502 var _bc=MochiKit.Base.bind;
michael@0 503 for(var k in _bb){
michael@0 504 var _be=_bb[k];
michael@0 505 if(typeof (_be)=="function"){
michael@0 506 _bb[k]=_bc(_be,_bb);
michael@0 507 }
michael@0 508 }
michael@0 509 },registerComparator:function(_bf,_c0,_c1,_c2){
michael@0 510 MochiKit.Base.comparatorRegistry.register(_bf,_c0,_c1,_c2);
michael@0 511 },_primitives:{"boolean":true,"string":true,"number":true},compare:function(a,b){
michael@0 512 if(a==b){
michael@0 513 return 0;
michael@0 514 }
michael@0 515 var _c5=(typeof (a)=="undefined"||a===null);
michael@0 516 var _c6=(typeof (b)=="undefined"||b===null);
michael@0 517 if(_c5&&_c6){
michael@0 518 return 0;
michael@0 519 }else{
michael@0 520 if(_c5){
michael@0 521 return -1;
michael@0 522 }else{
michael@0 523 if(_c6){
michael@0 524 return 1;
michael@0 525 }
michael@0 526 }
michael@0 527 }
michael@0 528 var m=MochiKit.Base;
michael@0 529 var _c8=m._primitives;
michael@0 530 if(!(typeof (a) in _c8&&typeof (b) in _c8)){
michael@0 531 try{
michael@0 532 return m.comparatorRegistry.match(a,b);
michael@0 533 }
michael@0 534 catch(e){
michael@0 535 if(e!=m.NotFound){
michael@0 536 throw e;
michael@0 537 }
michael@0 538 }
michael@0 539 }
michael@0 540 if(a<b){
michael@0 541 return -1;
michael@0 542 }else{
michael@0 543 if(a>b){
michael@0 544 return 1;
michael@0 545 }
michael@0 546 }
michael@0 547 var _c9=m.repr;
michael@0 548 throw new TypeError(_c9(a)+" and "+_c9(b)+" can not be compared");
michael@0 549 },compareDateLike:function(a,b){
michael@0 550 return MochiKit.Base.compare(a.getTime(),b.getTime());
michael@0 551 },compareArrayLike:function(a,b){
michael@0 552 var _ce=MochiKit.Base.compare;
michael@0 553 var _cf=a.length;
michael@0 554 var _d0=0;
michael@0 555 if(_cf>b.length){
michael@0 556 _d0=1;
michael@0 557 _cf=b.length;
michael@0 558 }else{
michael@0 559 if(_cf<b.length){
michael@0 560 _d0=-1;
michael@0 561 }
michael@0 562 }
michael@0 563 for(var i=0;i<_cf;i++){
michael@0 564 var cmp=_ce(a[i],b[i]);
michael@0 565 if(cmp){
michael@0 566 return cmp;
michael@0 567 }
michael@0 568 }
michael@0 569 return _d0;
michael@0 570 },registerRepr:function(_d3,_d4,_d5,_d6){
michael@0 571 MochiKit.Base.reprRegistry.register(_d3,_d4,_d5,_d6);
michael@0 572 },repr:function(o){
michael@0 573 if(typeof (o)=="undefined"){
michael@0 574 return "undefined";
michael@0 575 }else{
michael@0 576 if(o===null){
michael@0 577 return "null";
michael@0 578 }
michael@0 579 }
michael@0 580 try{
michael@0 581 if(typeof (o.__repr__)=="function"){
michael@0 582 return o.__repr__();
michael@0 583 }else{
michael@0 584 if(typeof (o.repr)=="function"&&o.repr!=arguments.callee){
michael@0 585 return o.repr();
michael@0 586 }
michael@0 587 }
michael@0 588 return MochiKit.Base.reprRegistry.match(o);
michael@0 589 }
michael@0 590 catch(e){
michael@0 591 if(typeof (o.NAME)=="string"&&(o.toString==Function.prototype.toString||o.toString==Object.prototype.toString)){
michael@0 592 return o.NAME;
michael@0 593 }
michael@0 594 }
michael@0 595 try{
michael@0 596 var _d8=(o+"");
michael@0 597 }
michael@0 598 catch(e){
michael@0 599 return "["+typeof (o)+"]";
michael@0 600 }
michael@0 601 if(typeof (o)=="function"){
michael@0 602 o=_d8.replace(/^\s+/,"");
michael@0 603 var idx=o.indexOf("{");
michael@0 604 if(idx!=-1){
michael@0 605 o=o.substr(0,idx)+"{...}";
michael@0 606 }
michael@0 607 }
michael@0 608 return _d8;
michael@0 609 },reprArrayLike:function(o){
michael@0 610 var m=MochiKit.Base;
michael@0 611 return "["+m.map(m.repr,o).join(", ")+"]";
michael@0 612 },reprString:function(o){
michael@0 613 return ("\""+o.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r");
michael@0 614 },reprNumber:function(o){
michael@0 615 return o+"";
michael@0 616 },registerJSON:function(_de,_df,_e0,_e1){
michael@0 617 MochiKit.Base.jsonRegistry.register(_de,_df,_e0,_e1);
michael@0 618 },evalJSON:function(){
michael@0 619 return eval("("+arguments[0]+")");
michael@0 620 },serializeJSON:function(o){
michael@0 621 var _e3=typeof (o);
michael@0 622 if(_e3=="number"||_e3=="boolean"){
michael@0 623 return o+"";
michael@0 624 }else{
michael@0 625 if(o===null){
michael@0 626 return "null";
michael@0 627 }
michael@0 628 }
michael@0 629 var m=MochiKit.Base;
michael@0 630 var _e5=m.reprString;
michael@0 631 if(_e3=="string"){
michael@0 632 return _e5(o);
michael@0 633 }
michael@0 634 var me=arguments.callee;
michael@0 635 var _e7;
michael@0 636 if(typeof (o.__json__)=="function"){
michael@0 637 _e7=o.__json__();
michael@0 638 if(o!==_e7){
michael@0 639 return me(_e7);
michael@0 640 }
michael@0 641 }
michael@0 642 if(typeof (o.json)=="function"){
michael@0 643 _e7=o.json();
michael@0 644 if(o!==_e7){
michael@0 645 return me(_e7);
michael@0 646 }
michael@0 647 }
michael@0 648 if(_e3!="function"&&typeof (o.length)=="number"){
michael@0 649 var res=[];
michael@0 650 for(var i=0;i<o.length;i++){
michael@0 651 var val=me(o[i]);
michael@0 652 if(typeof (val)!="string"){
michael@0 653 val="undefined";
michael@0 654 }
michael@0 655 res.push(val);
michael@0 656 }
michael@0 657 return "["+res.join(", ")+"]";
michael@0 658 }
michael@0 659 try{
michael@0 660 _e7=m.jsonRegistry.match(o);
michael@0 661 if(o!==_e7){
michael@0 662 return me(_e7);
michael@0 663 }
michael@0 664 }
michael@0 665 catch(e){
michael@0 666 if(e!=m.NotFound){
michael@0 667 throw e;
michael@0 668 }
michael@0 669 }
michael@0 670 if(_e3=="undefined"){
michael@0 671 throw new TypeError("undefined can not be serialized as JSON");
michael@0 672 }
michael@0 673 if(_e3=="function"){
michael@0 674 return null;
michael@0 675 }
michael@0 676 res=[];
michael@0 677 for(var k in o){
michael@0 678 var _ec;
michael@0 679 if(typeof (k)=="number"){
michael@0 680 _ec="\""+k+"\"";
michael@0 681 }else{
michael@0 682 if(typeof (k)=="string"){
michael@0 683 _ec=_e5(k);
michael@0 684 }else{
michael@0 685 continue;
michael@0 686 }
michael@0 687 }
michael@0 688 val=me(o[k]);
michael@0 689 if(typeof (val)!="string"){
michael@0 690 continue;
michael@0 691 }
michael@0 692 res.push(_ec+":"+val);
michael@0 693 }
michael@0 694 return "{"+res.join(", ")+"}";
michael@0 695 },objEqual:function(a,b){
michael@0 696 return (MochiKit.Base.compare(a,b)===0);
michael@0 697 },arrayEqual:function(_ef,arr){
michael@0 698 if(_ef.length!=arr.length){
michael@0 699 return false;
michael@0 700 }
michael@0 701 return (MochiKit.Base.compare(_ef,arr)===0);
michael@0 702 },concat:function(){
michael@0 703 var _f1=[];
michael@0 704 var _f2=MochiKit.Base.extend;
michael@0 705 for(var i=0;i<arguments.length;i++){
michael@0 706 _f2(_f1,arguments[i]);
michael@0 707 }
michael@0 708 return _f1;
michael@0 709 },keyComparator:function(key){
michael@0 710 var m=MochiKit.Base;
michael@0 711 var _f6=m.compare;
michael@0 712 if(arguments.length==1){
michael@0 713 return function(a,b){
michael@0 714 return _f6(a[key],b[key]);
michael@0 715 };
michael@0 716 }
michael@0 717 var _f9=m.extend(null,arguments);
michael@0 718 return function(a,b){
michael@0 719 var _fc=0;
michael@0 720 for(var i=0;(_fc===0)&&(i<_f9.length);i++){
michael@0 721 var key=_f9[i];
michael@0 722 _fc=_f6(a[key],b[key]);
michael@0 723 }
michael@0 724 return _fc;
michael@0 725 };
michael@0 726 },reverseKeyComparator:function(key){
michael@0 727 var _100=MochiKit.Base.keyComparator.apply(this,arguments);
michael@0 728 return function(a,b){
michael@0 729 return _100(b,a);
michael@0 730 };
michael@0 731 },partial:function(func){
michael@0 732 var m=MochiKit.Base;
michael@0 733 return m.bind.apply(this,m.extend([func,undefined],arguments,1));
michael@0 734 },listMinMax:function(_105,lst){
michael@0 735 if(lst.length===0){
michael@0 736 return null;
michael@0 737 }
michael@0 738 var cur=lst[0];
michael@0 739 var _108=MochiKit.Base.compare;
michael@0 740 for(var i=1;i<lst.length;i++){
michael@0 741 var o=lst[i];
michael@0 742 if(_108(o,cur)==_105){
michael@0 743 cur=o;
michael@0 744 }
michael@0 745 }
michael@0 746 return cur;
michael@0 747 },objMax:function(){
michael@0 748 return MochiKit.Base.listMinMax(1,arguments);
michael@0 749 },objMin:function(){
michael@0 750 return MochiKit.Base.listMinMax(-1,arguments);
michael@0 751 },findIdentical:function(lst,_10c,_10d,end){
michael@0 752 if(typeof (end)=="undefined"||end===null){
michael@0 753 end=lst.length;
michael@0 754 }
michael@0 755 if(typeof (_10d)=="undefined"||_10d===null){
michael@0 756 _10d=0;
michael@0 757 }
michael@0 758 for(var i=_10d;i<end;i++){
michael@0 759 if(lst[i]===_10c){
michael@0 760 return i;
michael@0 761 }
michael@0 762 }
michael@0 763 return -1;
michael@0 764 },mean:function(){
michael@0 765 var sum=0;
michael@0 766 var m=MochiKit.Base;
michael@0 767 var args=m.extend(null,arguments);
michael@0 768 var _113=args.length;
michael@0 769 while(args.length){
michael@0 770 var o=args.shift();
michael@0 771 if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){
michael@0 772 _113+=o.length-1;
michael@0 773 for(var i=o.length-1;i>=0;i--){
michael@0 774 sum+=o[i];
michael@0 775 }
michael@0 776 }else{
michael@0 777 sum+=o;
michael@0 778 }
michael@0 779 }
michael@0 780 if(_113<=0){
michael@0 781 throw new TypeError("mean() requires at least one argument");
michael@0 782 }
michael@0 783 return sum/_113;
michael@0 784 },median:function(){
michael@0 785 var data=MochiKit.Base.flattenArguments(arguments);
michael@0 786 if(data.length===0){
michael@0 787 throw new TypeError("median() requires at least one argument");
michael@0 788 }
michael@0 789 data.sort(compare);
michael@0 790 if(data.length%2==0){
michael@0 791 var _117=data.length/2;
michael@0 792 return (data[_117]+data[_117-1])/2;
michael@0 793 }else{
michael@0 794 return data[(data.length-1)/2];
michael@0 795 }
michael@0 796 },findValue:function(lst,_119,_11a,end){
michael@0 797 if(typeof (end)=="undefined"||end===null){
michael@0 798 end=lst.length;
michael@0 799 }
michael@0 800 if(typeof (_11a)=="undefined"||_11a===null){
michael@0 801 _11a=0;
michael@0 802 }
michael@0 803 var cmp=MochiKit.Base.compare;
michael@0 804 for(var i=_11a;i<end;i++){
michael@0 805 if(cmp(lst[i],_119)===0){
michael@0 806 return i;
michael@0 807 }
michael@0 808 }
michael@0 809 return -1;
michael@0 810 },nodeWalk:function(node,_11f){
michael@0 811 var _120=[node];
michael@0 812 var _121=MochiKit.Base.extend;
michael@0 813 while(_120.length){
michael@0 814 var res=_11f(_120.shift());
michael@0 815 if(res){
michael@0 816 _121(_120,res);
michael@0 817 }
michael@0 818 }
michael@0 819 },nameFunctions:function(_123){
michael@0 820 var base=_123.NAME;
michael@0 821 if(typeof (base)=="undefined"){
michael@0 822 base="";
michael@0 823 }else{
michael@0 824 base=base+".";
michael@0 825 }
michael@0 826 for(var name in _123){
michael@0 827 var o=_123[name];
michael@0 828 if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
michael@0 829 try{
michael@0 830 o.NAME=base+name;
michael@0 831 }
michael@0 832 catch(e){
michael@0 833 }
michael@0 834 }
michael@0 835 }
michael@0 836 },queryString:function(_127,_128){
michael@0 837 if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_127)=="string"||(typeof (_127.nodeType)!="undefined"&&_127.nodeType>0))){
michael@0 838 var kv=MochiKit.DOM.formContents(_127);
michael@0 839 _127=kv[0];
michael@0 840 _128=kv[1];
michael@0 841 }else{
michael@0 842 if(arguments.length==1){
michael@0 843 var o=_127;
michael@0 844 _127=[];
michael@0 845 _128=[];
michael@0 846 for(var k in o){
michael@0 847 var v=o[k];
michael@0 848 if(typeof (v)=="function"){
michael@0 849 continue;
michael@0 850 }else{
michael@0 851 if(typeof (v)!="string"&&typeof (v.length)=="number"){
michael@0 852 for(var i=0;i<v.length;i++){
michael@0 853 _127.push(k);
michael@0 854 _128.push(v[i]);
michael@0 855 }
michael@0 856 }else{
michael@0 857 _127.push(k);
michael@0 858 _128.push(v);
michael@0 859 }
michael@0 860 }
michael@0 861 }
michael@0 862 }
michael@0 863 }
michael@0 864 var rval=[];
michael@0 865 var len=Math.min(_127.length,_128.length);
michael@0 866 var _130=MochiKit.Base.urlEncode;
michael@0 867 for(var i=0;i<len;i++){
michael@0 868 v=_128[i];
michael@0 869 if(typeof (v)!="undefined"&&v!==null){
michael@0 870 rval.push(_130(_127[i])+"="+_130(v));
michael@0 871 }
michael@0 872 }
michael@0 873 return rval.join("&");
michael@0 874 },parseQueryString:function(_131,_132){
michael@0 875 var qstr=(_131[0]=="?")?_131.substring(1):_131;
michael@0 876 var _134=qstr.replace(/\+/g,"%20").split(/(\&amp\;|\&\#38\;|\&#x26;|\&)/);
michael@0 877 var o={};
michael@0 878 var _136;
michael@0 879 if(typeof (decodeURIComponent)!="undefined"){
michael@0 880 _136=decodeURIComponent;
michael@0 881 }else{
michael@0 882 _136=unescape;
michael@0 883 }
michael@0 884 if(_132){
michael@0 885 for(var i=0;i<_134.length;i++){
michael@0 886 var pair=_134[i].split("=");
michael@0 887 if(pair.length!==2){
michael@0 888 continue;
michael@0 889 }
michael@0 890 var name=_136(pair[0]);
michael@0 891 var arr=o[name];
michael@0 892 if(!(arr instanceof Array)){
michael@0 893 arr=[];
michael@0 894 o[name]=arr;
michael@0 895 }
michael@0 896 arr.push(_136(pair[1]));
michael@0 897 }
michael@0 898 }else{
michael@0 899 for(i=0;i<_134.length;i++){
michael@0 900 pair=_134[i].split("=");
michael@0 901 if(pair.length!==2){
michael@0 902 continue;
michael@0 903 }
michael@0 904 o[_136(pair[0])]=_136(pair[1]);
michael@0 905 }
michael@0 906 }
michael@0 907 return o;
michael@0 908 }});
michael@0 909 MochiKit.Base.AdapterRegistry=function(){
michael@0 910 this.pairs=[];
michael@0 911 };
michael@0 912 MochiKit.Base.AdapterRegistry.prototype={register:function(name,_13c,wrap,_13e){
michael@0 913 if(_13e){
michael@0 914 this.pairs.unshift([name,_13c,wrap]);
michael@0 915 }else{
michael@0 916 this.pairs.push([name,_13c,wrap]);
michael@0 917 }
michael@0 918 },match:function(){
michael@0 919 for(var i=0;i<this.pairs.length;i++){
michael@0 920 var pair=this.pairs[i];
michael@0 921 if(pair[1].apply(this,arguments)){
michael@0 922 return pair[2].apply(this,arguments);
michael@0 923 }
michael@0 924 }
michael@0 925 throw MochiKit.Base.NotFound;
michael@0 926 },unregister:function(name){
michael@0 927 for(var i=0;i<this.pairs.length;i++){
michael@0 928 var pair=this.pairs[i];
michael@0 929 if(pair[0]==name){
michael@0 930 this.pairs.splice(i,1);
michael@0 931 return true;
michael@0 932 }
michael@0 933 }
michael@0 934 return false;
michael@0 935 }};
michael@0 936 MochiKit.Base.EXPORT=["flattenArray","noop","camelize","counter","clone","extend","update","updatetree","setdefault","keys","values","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isEmpty","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","methodcaller","compose","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","findValue","findIdentical","flattenArguments","method","average","mean","median"];
michael@0 937 MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"];
michael@0 938 MochiKit.Base._exportSymbols=function(_144,_145){
michael@0 939 if(!MochiKit.__export__){
michael@0 940 return;
michael@0 941 }
michael@0 942 var all=_145.EXPORT_TAGS[":all"];
michael@0 943 for(var i=0;i<all.length;i++){
michael@0 944 _144[all[i]]=_145[all[i]];
michael@0 945 }
michael@0 946 };
michael@0 947 MochiKit.Base.__new__=function(){
michael@0 948 var m=this;
michael@0 949 m.noop=m.operator.identity;
michael@0 950 m.forward=m.forwardCall;
michael@0 951 m.find=m.findValue;
michael@0 952 if(typeof (encodeURIComponent)!="undefined"){
michael@0 953 m.urlEncode=function(_149){
michael@0 954 return encodeURIComponent(_149).replace(/\'/g,"%27");
michael@0 955 };
michael@0 956 }else{
michael@0 957 m.urlEncode=function(_14a){
michael@0 958 return escape(_14a).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27");
michael@0 959 };
michael@0 960 }
michael@0 961 m.NamedError=function(name){
michael@0 962 this.message=name;
michael@0 963 this.name=name;
michael@0 964 };
michael@0 965 m.NamedError.prototype=new Error();
michael@0 966 m.update(m.NamedError.prototype,{repr:function(){
michael@0 967 if(this.message&&this.message!=this.name){
michael@0 968 return this.name+"("+m.repr(this.message)+")";
michael@0 969 }else{
michael@0 970 return this.name+"()";
michael@0 971 }
michael@0 972 },toString:m.forwardCall("repr")});
michael@0 973 m.NotFound=new m.NamedError("MochiKit.Base.NotFound");
michael@0 974 m.listMax=m.partial(m.listMinMax,1);
michael@0 975 m.listMin=m.partial(m.listMinMax,-1);
michael@0 976 m.isCallable=m.typeMatcher("function");
michael@0 977 m.isUndefined=m.typeMatcher("undefined");
michael@0 978 m.merge=m.partial(m.update,null);
michael@0 979 m.zip=m.partial(m.map,null);
michael@0 980 m.average=m.mean;
michael@0 981 m.comparatorRegistry=new m.AdapterRegistry();
michael@0 982 m.registerComparator("dateLike",m.isDateLike,m.compareDateLike);
michael@0 983 m.registerComparator("arrayLike",m.isArrayLike,m.compareArrayLike);
michael@0 984 m.reprRegistry=new m.AdapterRegistry();
michael@0 985 m.registerRepr("arrayLike",m.isArrayLike,m.reprArrayLike);
michael@0 986 m.registerRepr("string",m.typeMatcher("string"),m.reprString);
michael@0 987 m.registerRepr("numbers",m.typeMatcher("number","boolean"),m.reprNumber);
michael@0 988 m.jsonRegistry=new m.AdapterRegistry();
michael@0 989 var all=m.concat(m.EXPORT,m.EXPORT_OK);
michael@0 990 m.EXPORT_TAGS={":common":m.concat(m.EXPORT_OK),":all":all};
michael@0 991 m.nameFunctions(this);
michael@0 992 };
michael@0 993 MochiKit.Base.__new__();
michael@0 994 if(MochiKit.__export__){
michael@0 995 compare=MochiKit.Base.compare;
michael@0 996 compose=MochiKit.Base.compose;
michael@0 997 serializeJSON=MochiKit.Base.serializeJSON;
michael@0 998 }
michael@0 999 MochiKit.Base._exportSymbols(this,MochiKit.Base);
michael@0 1000 if(typeof (dojo)!="undefined"){
michael@0 1001 dojo.provide("MochiKit.Iter");
michael@0 1002 dojo.require("MochiKit.Base");
michael@0 1003 }
michael@0 1004 if(typeof (JSAN)!="undefined"){
michael@0 1005 JSAN.use("MochiKit.Base",[]);
michael@0 1006 }
michael@0 1007 try{
michael@0 1008 if(typeof (MochiKit.Base)=="undefined"){
michael@0 1009 throw "";
michael@0 1010 }
michael@0 1011 }
michael@0 1012 catch(e){
michael@0 1013 throw "MochiKit.Iter depends on MochiKit.Base!";
michael@0 1014 }
michael@0 1015 if(typeof (MochiKit.Iter)=="undefined"){
michael@0 1016 MochiKit.Iter={};
michael@0 1017 }
michael@0 1018 MochiKit.Iter.NAME="MochiKit.Iter";
michael@0 1019 MochiKit.Iter.VERSION="1.4";
michael@0 1020 MochiKit.Base.update(MochiKit.Iter,{__repr__:function(){
michael@0 1021 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 1022 },toString:function(){
michael@0 1023 return this.__repr__();
michael@0 1024 },registerIteratorFactory:function(name,_14e,_14f,_150){
michael@0 1025 MochiKit.Iter.iteratorRegistry.register(name,_14e,_14f,_150);
michael@0 1026 },iter:function(_151,_152){
michael@0 1027 var self=MochiKit.Iter;
michael@0 1028 if(arguments.length==2){
michael@0 1029 return self.takewhile(function(a){
michael@0 1030 return a!=_152;
michael@0 1031 },_151);
michael@0 1032 }
michael@0 1033 if(typeof (_151.next)=="function"){
michael@0 1034 return _151;
michael@0 1035 }else{
michael@0 1036 if(typeof (_151.iter)=="function"){
michael@0 1037 return _151.iter();
michael@0 1038 }
michael@0 1039 }
michael@0 1040 try{
michael@0 1041 return self.iteratorRegistry.match(_151);
michael@0 1042 }
michael@0 1043 catch(e){
michael@0 1044 var m=MochiKit.Base;
michael@0 1045 if(e==m.NotFound){
michael@0 1046 e=new TypeError(typeof (_151)+": "+m.repr(_151)+" is not iterable");
michael@0 1047 }
michael@0 1048 throw e;
michael@0 1049 }
michael@0 1050 },count:function(n){
michael@0 1051 if(!n){
michael@0 1052 n=0;
michael@0 1053 }
michael@0 1054 var m=MochiKit.Base;
michael@0 1055 return {repr:function(){
michael@0 1056 return "count("+n+")";
michael@0 1057 },toString:m.forwardCall("repr"),next:m.counter(n)};
michael@0 1058 },cycle:function(p){
michael@0 1059 var self=MochiKit.Iter;
michael@0 1060 var m=MochiKit.Base;
michael@0 1061 var lst=[];
michael@0 1062 var _15c=self.iter(p);
michael@0 1063 return {repr:function(){
michael@0 1064 return "cycle(...)";
michael@0 1065 },toString:m.forwardCall("repr"),next:function(){
michael@0 1066 try{
michael@0 1067 var rval=_15c.next();
michael@0 1068 lst.push(rval);
michael@0 1069 return rval;
michael@0 1070 }
michael@0 1071 catch(e){
michael@0 1072 if(e!=self.StopIteration){
michael@0 1073 throw e;
michael@0 1074 }
michael@0 1075 if(lst.length===0){
michael@0 1076 this.next=function(){
michael@0 1077 throw self.StopIteration;
michael@0 1078 };
michael@0 1079 }else{
michael@0 1080 var i=-1;
michael@0 1081 this.next=function(){
michael@0 1082 i=(i+1)%lst.length;
michael@0 1083 return lst[i];
michael@0 1084 };
michael@0 1085 }
michael@0 1086 return this.next();
michael@0 1087 }
michael@0 1088 }};
michael@0 1089 },repeat:function(elem,n){
michael@0 1090 var m=MochiKit.Base;
michael@0 1091 if(typeof (n)=="undefined"){
michael@0 1092 return {repr:function(){
michael@0 1093 return "repeat("+m.repr(elem)+")";
michael@0 1094 },toString:m.forwardCall("repr"),next:function(){
michael@0 1095 return elem;
michael@0 1096 }};
michael@0 1097 }
michael@0 1098 return {repr:function(){
michael@0 1099 return "repeat("+m.repr(elem)+", "+n+")";
michael@0 1100 },toString:m.forwardCall("repr"),next:function(){
michael@0 1101 if(n<=0){
michael@0 1102 throw MochiKit.Iter.StopIteration;
michael@0 1103 }
michael@0 1104 n-=1;
michael@0 1105 return elem;
michael@0 1106 }};
michael@0 1107 },next:function(_162){
michael@0 1108 return _162.next();
michael@0 1109 },izip:function(p,q){
michael@0 1110 var m=MochiKit.Base;
michael@0 1111 var self=MochiKit.Iter;
michael@0 1112 var next=self.next;
michael@0 1113 var _168=m.map(self.iter,arguments);
michael@0 1114 return {repr:function(){
michael@0 1115 return "izip(...)";
michael@0 1116 },toString:m.forwardCall("repr"),next:function(){
michael@0 1117 return m.map(next,_168);
michael@0 1118 }};
michael@0 1119 },ifilter:function(pred,seq){
michael@0 1120 var m=MochiKit.Base;
michael@0 1121 seq=MochiKit.Iter.iter(seq);
michael@0 1122 if(pred===null){
michael@0 1123 pred=m.operator.truth;
michael@0 1124 }
michael@0 1125 return {repr:function(){
michael@0 1126 return "ifilter(...)";
michael@0 1127 },toString:m.forwardCall("repr"),next:function(){
michael@0 1128 while(true){
michael@0 1129 var rval=seq.next();
michael@0 1130 if(pred(rval)){
michael@0 1131 return rval;
michael@0 1132 }
michael@0 1133 }
michael@0 1134 return undefined;
michael@0 1135 }};
michael@0 1136 },ifilterfalse:function(pred,seq){
michael@0 1137 var m=MochiKit.Base;
michael@0 1138 seq=MochiKit.Iter.iter(seq);
michael@0 1139 if(pred===null){
michael@0 1140 pred=m.operator.truth;
michael@0 1141 }
michael@0 1142 return {repr:function(){
michael@0 1143 return "ifilterfalse(...)";
michael@0 1144 },toString:m.forwardCall("repr"),next:function(){
michael@0 1145 while(true){
michael@0 1146 var rval=seq.next();
michael@0 1147 if(!pred(rval)){
michael@0 1148 return rval;
michael@0 1149 }
michael@0 1150 }
michael@0 1151 return undefined;
michael@0 1152 }};
michael@0 1153 },islice:function(seq){
michael@0 1154 var self=MochiKit.Iter;
michael@0 1155 var m=MochiKit.Base;
michael@0 1156 seq=self.iter(seq);
michael@0 1157 var _174=0;
michael@0 1158 var stop=0;
michael@0 1159 var step=1;
michael@0 1160 var i=-1;
michael@0 1161 if(arguments.length==2){
michael@0 1162 stop=arguments[1];
michael@0 1163 }else{
michael@0 1164 if(arguments.length==3){
michael@0 1165 _174=arguments[1];
michael@0 1166 stop=arguments[2];
michael@0 1167 }else{
michael@0 1168 _174=arguments[1];
michael@0 1169 stop=arguments[2];
michael@0 1170 step=arguments[3];
michael@0 1171 }
michael@0 1172 }
michael@0 1173 return {repr:function(){
michael@0 1174 return "islice("+["...",_174,stop,step].join(", ")+")";
michael@0 1175 },toString:m.forwardCall("repr"),next:function(){
michael@0 1176 var rval;
michael@0 1177 while(i<_174){
michael@0 1178 rval=seq.next();
michael@0 1179 i++;
michael@0 1180 }
michael@0 1181 if(_174>=stop){
michael@0 1182 throw self.StopIteration;
michael@0 1183 }
michael@0 1184 _174+=step;
michael@0 1185 return rval;
michael@0 1186 }};
michael@0 1187 },imap:function(fun,p,q){
michael@0 1188 var m=MochiKit.Base;
michael@0 1189 var self=MochiKit.Iter;
michael@0 1190 var _17e=m.map(self.iter,m.extend(null,arguments,1));
michael@0 1191 var map=m.map;
michael@0 1192 var next=self.next;
michael@0 1193 return {repr:function(){
michael@0 1194 return "imap(...)";
michael@0 1195 },toString:m.forwardCall("repr"),next:function(){
michael@0 1196 return fun.apply(this,map(next,_17e));
michael@0 1197 }};
michael@0 1198 },applymap:function(fun,seq,self){
michael@0 1199 seq=MochiKit.Iter.iter(seq);
michael@0 1200 var m=MochiKit.Base;
michael@0 1201 return {repr:function(){
michael@0 1202 return "applymap(...)";
michael@0 1203 },toString:m.forwardCall("repr"),next:function(){
michael@0 1204 return fun.apply(self,seq.next());
michael@0 1205 }};
michael@0 1206 },chain:function(p,q){
michael@0 1207 var self=MochiKit.Iter;
michael@0 1208 var m=MochiKit.Base;
michael@0 1209 if(arguments.length==1){
michael@0 1210 return self.iter(arguments[0]);
michael@0 1211 }
michael@0 1212 var _189=m.map(self.iter,arguments);
michael@0 1213 return {repr:function(){
michael@0 1214 return "chain(...)";
michael@0 1215 },toString:m.forwardCall("repr"),next:function(){
michael@0 1216 while(_189.length>1){
michael@0 1217 try{
michael@0 1218 return _189[0].next();
michael@0 1219 }
michael@0 1220 catch(e){
michael@0 1221 if(e!=self.StopIteration){
michael@0 1222 throw e;
michael@0 1223 }
michael@0 1224 _189.shift();
michael@0 1225 }
michael@0 1226 }
michael@0 1227 if(_189.length==1){
michael@0 1228 var arg=_189.shift();
michael@0 1229 this.next=m.bind("next",arg);
michael@0 1230 return this.next();
michael@0 1231 }
michael@0 1232 throw self.StopIteration;
michael@0 1233 }};
michael@0 1234 },takewhile:function(pred,seq){
michael@0 1235 var self=MochiKit.Iter;
michael@0 1236 seq=self.iter(seq);
michael@0 1237 return {repr:function(){
michael@0 1238 return "takewhile(...)";
michael@0 1239 },toString:MochiKit.Base.forwardCall("repr"),next:function(){
michael@0 1240 var rval=seq.next();
michael@0 1241 if(!pred(rval)){
michael@0 1242 this.next=function(){
michael@0 1243 throw self.StopIteration;
michael@0 1244 };
michael@0 1245 this.next();
michael@0 1246 }
michael@0 1247 return rval;
michael@0 1248 }};
michael@0 1249 },dropwhile:function(pred,seq){
michael@0 1250 seq=MochiKit.Iter.iter(seq);
michael@0 1251 var m=MochiKit.Base;
michael@0 1252 var bind=m.bind;
michael@0 1253 return {"repr":function(){
michael@0 1254 return "dropwhile(...)";
michael@0 1255 },"toString":m.forwardCall("repr"),"next":function(){
michael@0 1256 while(true){
michael@0 1257 var rval=seq.next();
michael@0 1258 if(!pred(rval)){
michael@0 1259 break;
michael@0 1260 }
michael@0 1261 }
michael@0 1262 this.next=bind("next",seq);
michael@0 1263 return rval;
michael@0 1264 }};
michael@0 1265 },_tee:function(_194,sync,_196){
michael@0 1266 sync.pos[_194]=-1;
michael@0 1267 var m=MochiKit.Base;
michael@0 1268 var _198=m.listMin;
michael@0 1269 return {repr:function(){
michael@0 1270 return "tee("+_194+", ...)";
michael@0 1271 },toString:m.forwardCall("repr"),next:function(){
michael@0 1272 var rval;
michael@0 1273 var i=sync.pos[_194];
michael@0 1274 if(i==sync.max){
michael@0 1275 rval=_196.next();
michael@0 1276 sync.deque.push(rval);
michael@0 1277 sync.max+=1;
michael@0 1278 sync.pos[_194]+=1;
michael@0 1279 }else{
michael@0 1280 rval=sync.deque[i-sync.min];
michael@0 1281 sync.pos[_194]+=1;
michael@0 1282 if(i==sync.min&&_198(sync.pos)!=sync.min){
michael@0 1283 sync.min+=1;
michael@0 1284 sync.deque.shift();
michael@0 1285 }
michael@0 1286 }
michael@0 1287 return rval;
michael@0 1288 }};
michael@0 1289 },tee:function(_19b,n){
michael@0 1290 var rval=[];
michael@0 1291 var sync={"pos":[],"deque":[],"max":-1,"min":-1};
michael@0 1292 if(arguments.length==1||typeof (n)=="undefined"||n===null){
michael@0 1293 n=2;
michael@0 1294 }
michael@0 1295 var self=MochiKit.Iter;
michael@0 1296 _19b=self.iter(_19b);
michael@0 1297 var _tee=self._tee;
michael@0 1298 for(var i=0;i<n;i++){
michael@0 1299 rval.push(_tee(i,sync,_19b));
michael@0 1300 }
michael@0 1301 return rval;
michael@0 1302 },list:function(_1a2){
michael@0 1303 var m=MochiKit.Base;
michael@0 1304 if(typeof (_1a2.slice)=="function"){
michael@0 1305 return _1a2.slice();
michael@0 1306 }else{
michael@0 1307 if(m.isArrayLike(_1a2)){
michael@0 1308 return m.concat(_1a2);
michael@0 1309 }
michael@0 1310 }
michael@0 1311 var self=MochiKit.Iter;
michael@0 1312 _1a2=self.iter(_1a2);
michael@0 1313 var rval=[];
michael@0 1314 try{
michael@0 1315 while(true){
michael@0 1316 rval.push(_1a2.next());
michael@0 1317 }
michael@0 1318 }
michael@0 1319 catch(e){
michael@0 1320 if(e!=self.StopIteration){
michael@0 1321 throw e;
michael@0 1322 }
michael@0 1323 return rval;
michael@0 1324 }
michael@0 1325 return undefined;
michael@0 1326 },reduce:function(fn,_1a7,_1a8){
michael@0 1327 var i=0;
michael@0 1328 var x=_1a8;
michael@0 1329 var self=MochiKit.Iter;
michael@0 1330 _1a7=self.iter(_1a7);
michael@0 1331 if(arguments.length<3){
michael@0 1332 try{
michael@0 1333 x=_1a7.next();
michael@0 1334 }
michael@0 1335 catch(e){
michael@0 1336 if(e==self.StopIteration){
michael@0 1337 e=new TypeError("reduce() of empty sequence with no initial value");
michael@0 1338 }
michael@0 1339 throw e;
michael@0 1340 }
michael@0 1341 i++;
michael@0 1342 }
michael@0 1343 try{
michael@0 1344 while(true){
michael@0 1345 x=fn(x,_1a7.next());
michael@0 1346 }
michael@0 1347 }
michael@0 1348 catch(e){
michael@0 1349 if(e!=self.StopIteration){
michael@0 1350 throw e;
michael@0 1351 }
michael@0 1352 }
michael@0 1353 return x;
michael@0 1354 },range:function(){
michael@0 1355 var _1ac=0;
michael@0 1356 var stop=0;
michael@0 1357 var step=1;
michael@0 1358 if(arguments.length==1){
michael@0 1359 stop=arguments[0];
michael@0 1360 }else{
michael@0 1361 if(arguments.length==2){
michael@0 1362 _1ac=arguments[0];
michael@0 1363 stop=arguments[1];
michael@0 1364 }else{
michael@0 1365 if(arguments.length==3){
michael@0 1366 _1ac=arguments[0];
michael@0 1367 stop=arguments[1];
michael@0 1368 step=arguments[2];
michael@0 1369 }else{
michael@0 1370 throw new TypeError("range() takes 1, 2, or 3 arguments!");
michael@0 1371 }
michael@0 1372 }
michael@0 1373 }
michael@0 1374 if(step===0){
michael@0 1375 throw new TypeError("range() step must not be 0");
michael@0 1376 }
michael@0 1377 return {next:function(){
michael@0 1378 if((step>0&&_1ac>=stop)||(step<0&&_1ac<=stop)){
michael@0 1379 throw MochiKit.Iter.StopIteration;
michael@0 1380 }
michael@0 1381 var rval=_1ac;
michael@0 1382 _1ac+=step;
michael@0 1383 return rval;
michael@0 1384 },repr:function(){
michael@0 1385 return "range("+[_1ac,stop,step].join(", ")+")";
michael@0 1386 },toString:MochiKit.Base.forwardCall("repr")};
michael@0 1387 },sum:function(_1b0,_1b1){
michael@0 1388 if(typeof (_1b1)=="undefined"||_1b1===null){
michael@0 1389 _1b1=0;
michael@0 1390 }
michael@0 1391 var x=_1b1;
michael@0 1392 var self=MochiKit.Iter;
michael@0 1393 _1b0=self.iter(_1b0);
michael@0 1394 try{
michael@0 1395 while(true){
michael@0 1396 x+=_1b0.next();
michael@0 1397 }
michael@0 1398 }
michael@0 1399 catch(e){
michael@0 1400 if(e!=self.StopIteration){
michael@0 1401 throw e;
michael@0 1402 }
michael@0 1403 }
michael@0 1404 return x;
michael@0 1405 },exhaust:function(_1b4){
michael@0 1406 var self=MochiKit.Iter;
michael@0 1407 _1b4=self.iter(_1b4);
michael@0 1408 try{
michael@0 1409 while(true){
michael@0 1410 _1b4.next();
michael@0 1411 }
michael@0 1412 }
michael@0 1413 catch(e){
michael@0 1414 if(e!=self.StopIteration){
michael@0 1415 throw e;
michael@0 1416 }
michael@0 1417 }
michael@0 1418 },forEach:function(_1b6,func,self){
michael@0 1419 var m=MochiKit.Base;
michael@0 1420 if(arguments.length>2){
michael@0 1421 func=m.bind(func,self);
michael@0 1422 }
michael@0 1423 if(m.isArrayLike(_1b6)){
michael@0 1424 try{
michael@0 1425 for(var i=0;i<_1b6.length;i++){
michael@0 1426 func(_1b6[i]);
michael@0 1427 }
michael@0 1428 }
michael@0 1429 catch(e){
michael@0 1430 if(e!=MochiKit.Iter.StopIteration){
michael@0 1431 throw e;
michael@0 1432 }
michael@0 1433 }
michael@0 1434 }else{
michael@0 1435 self=MochiKit.Iter;
michael@0 1436 self.exhaust(self.imap(func,_1b6));
michael@0 1437 }
michael@0 1438 },every:function(_1bb,func){
michael@0 1439 var self=MochiKit.Iter;
michael@0 1440 try{
michael@0 1441 self.ifilterfalse(func,_1bb).next();
michael@0 1442 return false;
michael@0 1443 }
michael@0 1444 catch(e){
michael@0 1445 if(e!=self.StopIteration){
michael@0 1446 throw e;
michael@0 1447 }
michael@0 1448 return true;
michael@0 1449 }
michael@0 1450 },sorted:function(_1be,cmp){
michael@0 1451 var rval=MochiKit.Iter.list(_1be);
michael@0 1452 if(arguments.length==1){
michael@0 1453 cmp=MochiKit.Base.compare;
michael@0 1454 }
michael@0 1455 rval.sort(cmp);
michael@0 1456 return rval;
michael@0 1457 },reversed:function(_1c1){
michael@0 1458 var rval=MochiKit.Iter.list(_1c1);
michael@0 1459 rval.reverse();
michael@0 1460 return rval;
michael@0 1461 },some:function(_1c3,func){
michael@0 1462 var self=MochiKit.Iter;
michael@0 1463 try{
michael@0 1464 self.ifilter(func,_1c3).next();
michael@0 1465 return true;
michael@0 1466 }
michael@0 1467 catch(e){
michael@0 1468 if(e!=self.StopIteration){
michael@0 1469 throw e;
michael@0 1470 }
michael@0 1471 return false;
michael@0 1472 }
michael@0 1473 },iextend:function(lst,_1c7){
michael@0 1474 if(MochiKit.Base.isArrayLike(_1c7)){
michael@0 1475 for(var i=0;i<_1c7.length;i++){
michael@0 1476 lst.push(_1c7[i]);
michael@0 1477 }
michael@0 1478 }else{
michael@0 1479 var self=MochiKit.Iter;
michael@0 1480 _1c7=self.iter(_1c7);
michael@0 1481 try{
michael@0 1482 while(true){
michael@0 1483 lst.push(_1c7.next());
michael@0 1484 }
michael@0 1485 }
michael@0 1486 catch(e){
michael@0 1487 if(e!=self.StopIteration){
michael@0 1488 throw e;
michael@0 1489 }
michael@0 1490 }
michael@0 1491 }
michael@0 1492 return lst;
michael@0 1493 },groupby:function(_1ca,_1cb){
michael@0 1494 var m=MochiKit.Base;
michael@0 1495 var self=MochiKit.Iter;
michael@0 1496 if(arguments.length<2){
michael@0 1497 _1cb=m.operator.identity;
michael@0 1498 }
michael@0 1499 _1ca=self.iter(_1ca);
michael@0 1500 var pk=undefined;
michael@0 1501 var k=undefined;
michael@0 1502 var v;
michael@0 1503 function fetch(){
michael@0 1504 v=_1ca.next();
michael@0 1505 k=_1cb(v);
michael@0 1506 }
michael@0 1507 function eat(){
michael@0 1508 var ret=v;
michael@0 1509 v=undefined;
michael@0 1510 return ret;
michael@0 1511 }
michael@0 1512 var _1d2=true;
michael@0 1513 var _1d3=m.compare;
michael@0 1514 return {repr:function(){
michael@0 1515 return "groupby(...)";
michael@0 1516 },next:function(){
michael@0 1517 while(_1d3(k,pk)===0){
michael@0 1518 fetch();
michael@0 1519 if(_1d2){
michael@0 1520 _1d2=false;
michael@0 1521 break;
michael@0 1522 }
michael@0 1523 }
michael@0 1524 pk=k;
michael@0 1525 return [k,{next:function(){
michael@0 1526 if(v==undefined){
michael@0 1527 fetch();
michael@0 1528 }
michael@0 1529 if(_1d3(k,pk)!==0){
michael@0 1530 throw self.StopIteration;
michael@0 1531 }
michael@0 1532 return eat();
michael@0 1533 }}];
michael@0 1534 }};
michael@0 1535 },groupby_as_array:function(_1d4,_1d5){
michael@0 1536 var m=MochiKit.Base;
michael@0 1537 var self=MochiKit.Iter;
michael@0 1538 if(arguments.length<2){
michael@0 1539 _1d5=m.operator.identity;
michael@0 1540 }
michael@0 1541 _1d4=self.iter(_1d4);
michael@0 1542 var _1d8=[];
michael@0 1543 var _1d9=true;
michael@0 1544 var _1da;
michael@0 1545 var _1db=m.compare;
michael@0 1546 while(true){
michael@0 1547 try{
michael@0 1548 var _1dc=_1d4.next();
michael@0 1549 var key=_1d5(_1dc);
michael@0 1550 }
michael@0 1551 catch(e){
michael@0 1552 if(e==self.StopIteration){
michael@0 1553 break;
michael@0 1554 }
michael@0 1555 throw e;
michael@0 1556 }
michael@0 1557 if(_1d9||_1db(key,_1da)!==0){
michael@0 1558 var _1de=[];
michael@0 1559 _1d8.push([key,_1de]);
michael@0 1560 }
michael@0 1561 _1de.push(_1dc);
michael@0 1562 _1d9=false;
michael@0 1563 _1da=key;
michael@0 1564 }
michael@0 1565 return _1d8;
michael@0 1566 },arrayLikeIter:function(_1df){
michael@0 1567 var i=0;
michael@0 1568 return {repr:function(){
michael@0 1569 return "arrayLikeIter(...)";
michael@0 1570 },toString:MochiKit.Base.forwardCall("repr"),next:function(){
michael@0 1571 if(i>=_1df.length){
michael@0 1572 throw MochiKit.Iter.StopIteration;
michael@0 1573 }
michael@0 1574 return _1df[i++];
michael@0 1575 }};
michael@0 1576 },hasIterateNext:function(_1e1){
michael@0 1577 return (_1e1&&typeof (_1e1.iterateNext)=="function");
michael@0 1578 },iterateNextIter:function(_1e2){
michael@0 1579 return {repr:function(){
michael@0 1580 return "iterateNextIter(...)";
michael@0 1581 },toString:MochiKit.Base.forwardCall("repr"),next:function(){
michael@0 1582 var rval=_1e2.iterateNext();
michael@0 1583 if(rval===null||rval===undefined){
michael@0 1584 throw MochiKit.Iter.StopIteration;
michael@0 1585 }
michael@0 1586 return rval;
michael@0 1587 }};
michael@0 1588 }});
michael@0 1589 MochiKit.Iter.EXPORT_OK=["iteratorRegistry","arrayLikeIter","hasIterateNext","iterateNextIter",];
michael@0 1590 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"];
michael@0 1591 MochiKit.Iter.__new__=function(){
michael@0 1592 var m=MochiKit.Base;
michael@0 1593 if(typeof (StopIteration)!="undefined"){
michael@0 1594 this.StopIteration=StopIteration;
michael@0 1595 }else{
michael@0 1596 this.StopIteration=new m.NamedError("StopIteration");
michael@0 1597 }
michael@0 1598 this.iteratorRegistry=new m.AdapterRegistry();
michael@0 1599 this.registerIteratorFactory("arrayLike",m.isArrayLike,this.arrayLikeIter);
michael@0 1600 this.registerIteratorFactory("iterateNext",this.hasIterateNext,this.iterateNextIter);
michael@0 1601 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 1602 m.nameFunctions(this);
michael@0 1603 };
michael@0 1604 MochiKit.Iter.__new__();
michael@0 1605 if(MochiKit.__export__){
michael@0 1606 reduce=MochiKit.Iter.reduce;
michael@0 1607 }
michael@0 1608 MochiKit.Base._exportSymbols(this,MochiKit.Iter);
michael@0 1609 if(typeof (dojo)!="undefined"){
michael@0 1610 dojo.provide("MochiKit.Logging");
michael@0 1611 dojo.require("MochiKit.Base");
michael@0 1612 }
michael@0 1613 if(typeof (JSAN)!="undefined"){
michael@0 1614 JSAN.use("MochiKit.Base",[]);
michael@0 1615 }
michael@0 1616 try{
michael@0 1617 if(typeof (MochiKit.Base)=="undefined"){
michael@0 1618 throw "";
michael@0 1619 }
michael@0 1620 }
michael@0 1621 catch(e){
michael@0 1622 throw "MochiKit.Logging depends on MochiKit.Base!";
michael@0 1623 }
michael@0 1624 if(typeof (MochiKit.Logging)=="undefined"){
michael@0 1625 MochiKit.Logging={};
michael@0 1626 }
michael@0 1627 MochiKit.Logging.NAME="MochiKit.Logging";
michael@0 1628 MochiKit.Logging.VERSION="1.4";
michael@0 1629 MochiKit.Logging.__repr__=function(){
michael@0 1630 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 1631 };
michael@0 1632 MochiKit.Logging.toString=function(){
michael@0 1633 return this.__repr__();
michael@0 1634 };
michael@0 1635 MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"];
michael@0 1636 MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"];
michael@0 1637 MochiKit.Logging.LogMessage=function(num,_1e6,info){
michael@0 1638 this.num=num;
michael@0 1639 this.level=_1e6;
michael@0 1640 this.info=info;
michael@0 1641 this.timestamp=new Date();
michael@0 1642 };
michael@0 1643 MochiKit.Logging.LogMessage.prototype={repr:function(){
michael@0 1644 var m=MochiKit.Base;
michael@0 1645 return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")";
michael@0 1646 },toString:MochiKit.Base.forwardCall("repr")};
michael@0 1647 MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_1e9){
michael@0 1648 var self=MochiKit.Logging;
michael@0 1649 if(typeof (_1e9)=="string"){
michael@0 1650 _1e9=self.LogLevel[_1e9];
michael@0 1651 }
michael@0 1652 return function(msg){
michael@0 1653 var _1ec=msg.level;
michael@0 1654 if(typeof (_1ec)=="string"){
michael@0 1655 _1ec=self.LogLevel[_1ec];
michael@0 1656 }
michael@0 1657 return _1ec>=_1e9;
michael@0 1658 };
michael@0 1659 },isLogMessage:function(){
michael@0 1660 var _1ed=MochiKit.Logging.LogMessage;
michael@0 1661 for(var i=0;i<arguments.length;i++){
michael@0 1662 if(!(arguments[i] instanceof _1ed)){
michael@0 1663 return false;
michael@0 1664 }
michael@0 1665 }
michael@0 1666 return true;
michael@0 1667 },compareLogMessage:function(a,b){
michael@0 1668 return MochiKit.Base.compare([a.level,a.info],[b.level,b.info]);
michael@0 1669 },alertListener:function(msg){
michael@0 1670 alert("num: "+msg.num+"\nlevel: "+msg.level+"\ninfo: "+msg.info.join(" "));
michael@0 1671 }});
michael@0 1672 MochiKit.Logging.Logger=function(_1f2){
michael@0 1673 this.counter=0;
michael@0 1674 if(typeof (_1f2)=="undefined"||_1f2===null){
michael@0 1675 _1f2=-1;
michael@0 1676 }
michael@0 1677 this.maxSize=_1f2;
michael@0 1678 this._messages=[];
michael@0 1679 this.listeners={};
michael@0 1680 this.useNativeConsole=false;
michael@0 1681 };
michael@0 1682 MochiKit.Logging.Logger.prototype={clear:function(){
michael@0 1683 this._messages.splice(0,this._messages.length);
michael@0 1684 },logToConsole:function(msg){
michael@0 1685 if(typeof (window)!="undefined"&&window.console&&window.console.log){
michael@0 1686 window.console.log(msg.replace(/%/g,"\uff05"));
michael@0 1687 }else{
michael@0 1688 if(typeof (opera)!="undefined"&&opera.postError){
michael@0 1689 opera.postError(msg);
michael@0 1690 }else{
michael@0 1691 if(typeof (printfire)=="function"){
michael@0 1692 printfire(msg);
michael@0 1693 }else{
michael@0 1694 if(typeof (Debug)!="undefined"&&Debug.writeln){
michael@0 1695 Debug.writeln(msg);
michael@0 1696 }else{
michael@0 1697 if(typeof (debug)!="undefined"&&debug.trace){
michael@0 1698 debug.trace(msg);
michael@0 1699 }
michael@0 1700 }
michael@0 1701 }
michael@0 1702 }
michael@0 1703 }
michael@0 1704 },dispatchListeners:function(msg){
michael@0 1705 for(var k in this.listeners){
michael@0 1706 var pair=this.listeners[k];
michael@0 1707 if(pair.ident!=k||(pair[0]&&!pair[0](msg))){
michael@0 1708 continue;
michael@0 1709 }
michael@0 1710 pair[1](msg);
michael@0 1711 }
michael@0 1712 },addListener:function(_1f7,_1f8,_1f9){
michael@0 1713 if(typeof (_1f8)=="string"){
michael@0 1714 _1f8=MochiKit.Logging.logLevelAtLeast(_1f8);
michael@0 1715 }
michael@0 1716 var _1fa=[_1f8,_1f9];
michael@0 1717 _1fa.ident=_1f7;
michael@0 1718 this.listeners[_1f7]=_1fa;
michael@0 1719 },removeListener:function(_1fb){
michael@0 1720 delete this.listeners[_1fb];
michael@0 1721 },baseLog:function(_1fc,_1fd){
michael@0 1722 var msg=new MochiKit.Logging.LogMessage(this.counter,_1fc,MochiKit.Base.extend(null,arguments,1));
michael@0 1723 this._messages.push(msg);
michael@0 1724 this.dispatchListeners(msg);
michael@0 1725 if(this.useNativeConsole){
michael@0 1726 this.logToConsole(msg.level+": "+msg.info.join(" "));
michael@0 1727 }
michael@0 1728 this.counter+=1;
michael@0 1729 while(this.maxSize>=0&&this._messages.length>this.maxSize){
michael@0 1730 this._messages.shift();
michael@0 1731 }
michael@0 1732 },getMessages:function(_1ff){
michael@0 1733 var _200=0;
michael@0 1734 if(!(typeof (_1ff)=="undefined"||_1ff===null)){
michael@0 1735 _200=Math.max(0,this._messages.length-_1ff);
michael@0 1736 }
michael@0 1737 return this._messages.slice(_200);
michael@0 1738 },getMessageText:function(_201){
michael@0 1739 if(typeof (_201)=="undefined"||_201===null){
michael@0 1740 _201=30;
michael@0 1741 }
michael@0 1742 var _202=this.getMessages(_201);
michael@0 1743 if(_202.length){
michael@0 1744 var lst=map(function(m){
michael@0 1745 return "\n ["+m.num+"] "+m.level+": "+m.info.join(" ");
michael@0 1746 },_202);
michael@0 1747 lst.unshift("LAST "+_202.length+" MESSAGES:");
michael@0 1748 return lst.join("");
michael@0 1749 }
michael@0 1750 return "";
michael@0 1751 },debuggingBookmarklet:function(_205){
michael@0 1752 if(typeof (MochiKit.LoggingPane)=="undefined"){
michael@0 1753 alert(this.getMessageText());
michael@0 1754 }else{
michael@0 1755 MochiKit.LoggingPane.createLoggingPane(_205||false);
michael@0 1756 }
michael@0 1757 }};
michael@0 1758 MochiKit.Logging.__new__=function(){
michael@0 1759 this.LogLevel={ERROR:40,FATAL:50,WARNING:30,INFO:20,DEBUG:10};
michael@0 1760 var m=MochiKit.Base;
michael@0 1761 m.registerComparator("LogMessage",this.isLogMessage,this.compareLogMessage);
michael@0 1762 var _207=m.partial;
michael@0 1763 var _208=this.Logger;
michael@0 1764 var _209=_208.prototype.baseLog;
michael@0 1765 m.update(this.Logger.prototype,{debug:_207(_209,"DEBUG"),log:_207(_209,"INFO"),error:_207(_209,"ERROR"),fatal:_207(_209,"FATAL"),warning:_207(_209,"WARNING")});
michael@0 1766 var self=this;
michael@0 1767 var _20b=function(name){
michael@0 1768 return function(){
michael@0 1769 self.logger[name].apply(self.logger,arguments);
michael@0 1770 };
michael@0 1771 };
michael@0 1772 this.log=_20b("log");
michael@0 1773 this.logError=_20b("error");
michael@0 1774 this.logDebug=_20b("debug");
michael@0 1775 this.logFatal=_20b("fatal");
michael@0 1776 this.logWarning=_20b("warning");
michael@0 1777 this.logger=new _208();
michael@0 1778 this.logger.useNativeConsole=true;
michael@0 1779 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 1780 m.nameFunctions(this);
michael@0 1781 };
michael@0 1782 if(typeof (printfire)=="undefined"&&typeof (document)!="undefined"&&document.createEvent&&typeof (dispatchEvent)!="undefined"){
michael@0 1783 printfire=function(){
michael@0 1784 printfire.args=arguments;
michael@0 1785 var ev=document.createEvent("Events");
michael@0 1786 ev.initEvent("printfire",false,true);
michael@0 1787 dispatchEvent(ev);
michael@0 1788 };
michael@0 1789 }
michael@0 1790 MochiKit.Logging.__new__();
michael@0 1791 MochiKit.Base._exportSymbols(this,MochiKit.Logging);
michael@0 1792 if(typeof (dojo)!="undefined"){
michael@0 1793 dojo.provide("MochiKit.DateTime");
michael@0 1794 }
michael@0 1795 if(typeof (MochiKit)=="undefined"){
michael@0 1796 MochiKit={};
michael@0 1797 }
michael@0 1798 if(typeof (MochiKit.DateTime)=="undefined"){
michael@0 1799 MochiKit.DateTime={};
michael@0 1800 }
michael@0 1801 MochiKit.DateTime.NAME="MochiKit.DateTime";
michael@0 1802 MochiKit.DateTime.VERSION="1.4";
michael@0 1803 MochiKit.DateTime.__repr__=function(){
michael@0 1804 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 1805 };
michael@0 1806 MochiKit.DateTime.toString=function(){
michael@0 1807 return this.__repr__();
michael@0 1808 };
michael@0 1809 MochiKit.DateTime.isoDate=function(str){
michael@0 1810 str=str+"";
michael@0 1811 if(typeof (str)!="string"||str.length===0){
michael@0 1812 return null;
michael@0 1813 }
michael@0 1814 var iso=str.split("-");
michael@0 1815 if(iso.length===0){
michael@0 1816 return null;
michael@0 1817 }
michael@0 1818 return new Date(iso[0],iso[1]-1,iso[2]);
michael@0 1819 };
michael@0 1820 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}))?)?)?)?)?/;
michael@0 1821 MochiKit.DateTime.isoTimestamp=function(str){
michael@0 1822 str=str+"";
michael@0 1823 if(typeof (str)!="string"||str.length===0){
michael@0 1824 return null;
michael@0 1825 }
michael@0 1826 var res=str.match(MochiKit.DateTime._isoRegexp);
michael@0 1827 if(typeof (res)=="undefined"||res===null){
michael@0 1828 return null;
michael@0 1829 }
michael@0 1830 var year,_213,day,hour,min,sec,msec;
michael@0 1831 year=parseInt(res[1],10);
michael@0 1832 if(typeof (res[2])=="undefined"||res[2]===""){
michael@0 1833 return new Date(year);
michael@0 1834 }
michael@0 1835 _213=parseInt(res[2],10)-1;
michael@0 1836 day=parseInt(res[3],10);
michael@0 1837 if(typeof (res[4])=="undefined"||res[4]===""){
michael@0 1838 return new Date(year,_213,day);
michael@0 1839 }
michael@0 1840 hour=parseInt(res[4],10);
michael@0 1841 min=parseInt(res[5],10);
michael@0 1842 sec=(typeof (res[6])!="undefined"&&res[6]!=="")?parseInt(res[6],10):0;
michael@0 1843 if(typeof (res[7])!="undefined"&&res[7]!==""){
michael@0 1844 msec=Math.round(1000*parseFloat("0."+res[7]));
michael@0 1845 }else{
michael@0 1846 msec=0;
michael@0 1847 }
michael@0 1848 if((typeof (res[8])=="undefined"||res[8]==="")&&(typeof (res[9])=="undefined"||res[9]==="")){
michael@0 1849 return new Date(year,_213,day,hour,min,sec,msec);
michael@0 1850 }
michael@0 1851 var ofs;
michael@0 1852 if(typeof (res[9])!="undefined"&&res[9]!==""){
michael@0 1853 ofs=parseInt(res[10],10)*3600000;
michael@0 1854 if(typeof (res[11])!="undefined"&&res[11]!==""){
michael@0 1855 ofs+=parseInt(res[11],10)*60000;
michael@0 1856 }
michael@0 1857 if(res[9]=="-"){
michael@0 1858 ofs=-ofs;
michael@0 1859 }
michael@0 1860 }else{
michael@0 1861 ofs=0;
michael@0 1862 }
michael@0 1863 return new Date(Date.UTC(year,_213,day,hour,min,sec,msec)-ofs);
michael@0 1864 };
michael@0 1865 MochiKit.DateTime.toISOTime=function(date,_21b){
michael@0 1866 if(typeof (date)=="undefined"||date===null){
michael@0 1867 return null;
michael@0 1868 }
michael@0 1869 var hh=date.getHours();
michael@0 1870 var mm=date.getMinutes();
michael@0 1871 var ss=date.getSeconds();
michael@0 1872 var lst=[((_21b&&(hh<10))?"0"+hh:hh),((mm<10)?"0"+mm:mm),((ss<10)?"0"+ss:ss)];
michael@0 1873 return lst.join(":");
michael@0 1874 };
michael@0 1875 MochiKit.DateTime.toISOTimestamp=function(date,_221){
michael@0 1876 if(typeof (date)=="undefined"||date===null){
michael@0 1877 return null;
michael@0 1878 }
michael@0 1879 var sep=_221?"T":" ";
michael@0 1880 var foot=_221?"Z":"";
michael@0 1881 if(_221){
michael@0 1882 date=new Date(date.getTime()+(date.getTimezoneOffset()*60000));
michael@0 1883 }
michael@0 1884 return MochiKit.DateTime.toISODate(date)+sep+MochiKit.DateTime.toISOTime(date,_221)+foot;
michael@0 1885 };
michael@0 1886 MochiKit.DateTime.toISODate=function(date){
michael@0 1887 if(typeof (date)=="undefined"||date===null){
michael@0 1888 return null;
michael@0 1889 }
michael@0 1890 var _225=MochiKit.DateTime._padTwo;
michael@0 1891 return [date.getFullYear(),_225(date.getMonth()+1),_225(date.getDate())].join("-");
michael@0 1892 };
michael@0 1893 MochiKit.DateTime.americanDate=function(d){
michael@0 1894 d=d+"";
michael@0 1895 if(typeof (d)!="string"||d.length===0){
michael@0 1896 return null;
michael@0 1897 }
michael@0 1898 var a=d.split("/");
michael@0 1899 return new Date(a[2],a[0]-1,a[1]);
michael@0 1900 };
michael@0 1901 MochiKit.DateTime._padTwo=function(n){
michael@0 1902 return (n>9)?n:"0"+n;
michael@0 1903 };
michael@0 1904 MochiKit.DateTime.toPaddedAmericanDate=function(d){
michael@0 1905 if(typeof (d)=="undefined"||d===null){
michael@0 1906 return null;
michael@0 1907 }
michael@0 1908 var _22a=MochiKit.DateTime._padTwo;
michael@0 1909 return [_22a(d.getMonth()+1),_22a(d.getDate()),d.getFullYear()].join("/");
michael@0 1910 };
michael@0 1911 MochiKit.DateTime.toAmericanDate=function(d){
michael@0 1912 if(typeof (d)=="undefined"||d===null){
michael@0 1913 return null;
michael@0 1914 }
michael@0 1915 return [d.getMonth()+1,d.getDate(),d.getFullYear()].join("/");
michael@0 1916 };
michael@0 1917 MochiKit.DateTime.EXPORT=["isoDate","isoTimestamp","toISOTime","toISOTimestamp","toISODate","americanDate","toPaddedAmericanDate","toAmericanDate"];
michael@0 1918 MochiKit.DateTime.EXPORT_OK=[];
michael@0 1919 MochiKit.DateTime.EXPORT_TAGS={":common":MochiKit.DateTime.EXPORT,":all":MochiKit.DateTime.EXPORT};
michael@0 1920 MochiKit.DateTime.__new__=function(){
michael@0 1921 var base=this.NAME+".";
michael@0 1922 for(var k in this){
michael@0 1923 var o=this[k];
michael@0 1924 if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
michael@0 1925 try{
michael@0 1926 o.NAME=base+k;
michael@0 1927 }
michael@0 1928 catch(e){
michael@0 1929 }
michael@0 1930 }
michael@0 1931 }
michael@0 1932 };
michael@0 1933 MochiKit.DateTime.__new__();
michael@0 1934 if(typeof (MochiKit.Base)!="undefined"){
michael@0 1935 MochiKit.Base._exportSymbols(this,MochiKit.DateTime);
michael@0 1936 }else{
michael@0 1937 (function(_22f,_230){
michael@0 1938 if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){
michael@0 1939 var all=_230.EXPORT_TAGS[":all"];
michael@0 1940 for(var i=0;i<all.length;i++){
michael@0 1941 _22f[all[i]]=_230[all[i]];
michael@0 1942 }
michael@0 1943 }
michael@0 1944 })(this,MochiKit.DateTime);
michael@0 1945 }
michael@0 1946 if(typeof (dojo)!="undefined"){
michael@0 1947 dojo.provide("MochiKit.Format");
michael@0 1948 }
michael@0 1949 if(typeof (MochiKit)=="undefined"){
michael@0 1950 MochiKit={};
michael@0 1951 }
michael@0 1952 if(typeof (MochiKit.Format)=="undefined"){
michael@0 1953 MochiKit.Format={};
michael@0 1954 }
michael@0 1955 MochiKit.Format.NAME="MochiKit.Format";
michael@0 1956 MochiKit.Format.VERSION="1.4";
michael@0 1957 MochiKit.Format.__repr__=function(){
michael@0 1958 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 1959 };
michael@0 1960 MochiKit.Format.toString=function(){
michael@0 1961 return this.__repr__();
michael@0 1962 };
michael@0 1963 MochiKit.Format._numberFormatter=function(_233,_234,_235,_236,_237,_238,_239,_23a,_23b){
michael@0 1964 return function(num){
michael@0 1965 num=parseFloat(num);
michael@0 1966 if(typeof (num)=="undefined"||num===null||isNaN(num)){
michael@0 1967 return _233;
michael@0 1968 }
michael@0 1969 var _23d=_234;
michael@0 1970 var _23e=_235;
michael@0 1971 if(num<0){
michael@0 1972 num=-num;
michael@0 1973 }else{
michael@0 1974 _23d=_23d.replace(/-/,"");
michael@0 1975 }
michael@0 1976 var me=arguments.callee;
michael@0 1977 var fmt=MochiKit.Format.formatLocale(_236);
michael@0 1978 if(_237){
michael@0 1979 num=num*100;
michael@0 1980 _23e=fmt.percent+_23e;
michael@0 1981 }
michael@0 1982 num=MochiKit.Format.roundToFixed(num,_238);
michael@0 1983 var _241=num.split(/\./);
michael@0 1984 var _242=_241[0];
michael@0 1985 var frac=(_241.length==1)?"":_241[1];
michael@0 1986 var res="";
michael@0 1987 while(_242.length<_239){
michael@0 1988 _242="0"+_242;
michael@0 1989 }
michael@0 1990 if(_23a){
michael@0 1991 while(_242.length>_23a){
michael@0 1992 var i=_242.length-_23a;
michael@0 1993 res=fmt.separator+_242.substring(i,_242.length)+res;
michael@0 1994 _242=_242.substring(0,i);
michael@0 1995 }
michael@0 1996 }
michael@0 1997 res=_242+res;
michael@0 1998 if(_238>0){
michael@0 1999 while(frac.length<_23b){
michael@0 2000 frac=frac+"0";
michael@0 2001 }
michael@0 2002 res=res+fmt.decimal+frac;
michael@0 2003 }
michael@0 2004 return _23d+res+_23e;
michael@0 2005 };
michael@0 2006 };
michael@0 2007 MochiKit.Format.numberFormatter=function(_246,_247,_248){
michael@0 2008 if(typeof (_247)=="undefined"){
michael@0 2009 _247="";
michael@0 2010 }
michael@0 2011 var _249=_246.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);
michael@0 2012 if(!_249){
michael@0 2013 throw TypeError("Invalid pattern");
michael@0 2014 }
michael@0 2015 var _24a=_246.substr(0,_249.index);
michael@0 2016 var _24b=_246.substr(_249.index+_249[0].length);
michael@0 2017 if(_24a.search(/-/)==-1){
michael@0 2018 _24a=_24a+"-";
michael@0 2019 }
michael@0 2020 var _24c=_249[1];
michael@0 2021 var frac=(typeof (_249[2])=="string"&&_249[2]!="")?_249[2]:"";
michael@0 2022 var _24e=(typeof (_249[3])=="string"&&_249[3]!="");
michael@0 2023 var tmp=_24c.split(/,/);
michael@0 2024 var _250;
michael@0 2025 if(typeof (_248)=="undefined"){
michael@0 2026 _248="default";
michael@0 2027 }
michael@0 2028 if(tmp.length==1){
michael@0 2029 _250=null;
michael@0 2030 }else{
michael@0 2031 _250=tmp[1].length;
michael@0 2032 }
michael@0 2033 var _251=_24c.length-_24c.replace(/0/g,"").length;
michael@0 2034 var _252=frac.length-frac.replace(/0/g,"").length;
michael@0 2035 var _253=frac.length;
michael@0 2036 var rval=MochiKit.Format._numberFormatter(_247,_24a,_24b,_248,_24e,_253,_251,_250,_252);
michael@0 2037 var m=MochiKit.Base;
michael@0 2038 if(m){
michael@0 2039 var fn=arguments.callee;
michael@0 2040 var args=m.concat(arguments);
michael@0 2041 rval.repr=function(){
michael@0 2042 return [self.NAME,"(",map(m.repr,args).join(", "),")"].join("");
michael@0 2043 };
michael@0 2044 }
michael@0 2045 return rval;
michael@0 2046 };
michael@0 2047 MochiKit.Format.formatLocale=function(_258){
michael@0 2048 if(typeof (_258)=="undefined"||_258===null){
michael@0 2049 _258="default";
michael@0 2050 }
michael@0 2051 if(typeof (_258)=="string"){
michael@0 2052 var rval=MochiKit.Format.LOCALE[_258];
michael@0 2053 if(typeof (rval)=="string"){
michael@0 2054 rval=arguments.callee(rval);
michael@0 2055 MochiKit.Format.LOCALE[_258]=rval;
michael@0 2056 }
michael@0 2057 return rval;
michael@0 2058 }else{
michael@0 2059 return _258;
michael@0 2060 }
michael@0 2061 };
michael@0 2062 MochiKit.Format.twoDigitAverage=function(_25a,_25b){
michael@0 2063 if(_25b){
michael@0 2064 var res=_25a/_25b;
michael@0 2065 if(!isNaN(res)){
michael@0 2066 return MochiKit.Format.twoDigitFloat(_25a/_25b);
michael@0 2067 }
michael@0 2068 }
michael@0 2069 return "0";
michael@0 2070 };
michael@0 2071 MochiKit.Format.twoDigitFloat=function(_25d){
michael@0 2072 var sign=(_25d<0?"-":"");
michael@0 2073 var s=Math.floor(Math.abs(_25d)*100).toString();
michael@0 2074 if(s=="0"){
michael@0 2075 return s;
michael@0 2076 }
michael@0 2077 if(s.length<3){
michael@0 2078 while(s.charAt(s.length-1)=="0"){
michael@0 2079 s=s.substring(0,s.length-1);
michael@0 2080 }
michael@0 2081 return sign+"0."+s;
michael@0 2082 }
michael@0 2083 var head=sign+s.substring(0,s.length-2);
michael@0 2084 var tail=s.substring(s.length-2,s.length);
michael@0 2085 if(tail=="00"){
michael@0 2086 return head;
michael@0 2087 }else{
michael@0 2088 if(tail.charAt(1)=="0"){
michael@0 2089 return head+"."+tail.charAt(0);
michael@0 2090 }else{
michael@0 2091 return head+"."+tail;
michael@0 2092 }
michael@0 2093 }
michael@0 2094 };
michael@0 2095 MochiKit.Format.lstrip=function(str,_263){
michael@0 2096 str=str+"";
michael@0 2097 if(typeof (str)!="string"){
michael@0 2098 return null;
michael@0 2099 }
michael@0 2100 if(!_263){
michael@0 2101 return str.replace(/^\s+/,"");
michael@0 2102 }else{
michael@0 2103 return str.replace(new RegExp("^["+_263+"]+"),"");
michael@0 2104 }
michael@0 2105 };
michael@0 2106 MochiKit.Format.rstrip=function(str,_265){
michael@0 2107 str=str+"";
michael@0 2108 if(typeof (str)!="string"){
michael@0 2109 return null;
michael@0 2110 }
michael@0 2111 if(!_265){
michael@0 2112 return str.replace(/\s+$/,"");
michael@0 2113 }else{
michael@0 2114 return str.replace(new RegExp("["+_265+"]+$"),"");
michael@0 2115 }
michael@0 2116 };
michael@0 2117 MochiKit.Format.strip=function(str,_267){
michael@0 2118 var self=MochiKit.Format;
michael@0 2119 return self.rstrip(self.lstrip(str,_267),_267);
michael@0 2120 };
michael@0 2121 MochiKit.Format.truncToFixed=function(_269,_26a){
michael@0 2122 _269=Math.floor(_269*Math.pow(10,_26a));
michael@0 2123 var res=(_269*Math.pow(10,-_26a)).toFixed(_26a);
michael@0 2124 if(res.charAt(0)=="."){
michael@0 2125 res="0"+res;
michael@0 2126 }
michael@0 2127 return res;
michael@0 2128 };
michael@0 2129 MochiKit.Format.roundToFixed=function(_26c,_26d){
michael@0 2130 return MochiKit.Format.truncToFixed(_26c+0.5*Math.pow(10,-_26d),_26d);
michael@0 2131 };
michael@0 2132 MochiKit.Format.percentFormat=function(_26e){
michael@0 2133 return MochiKit.Format.twoDigitFloat(100*_26e)+"%";
michael@0 2134 };
michael@0 2135 MochiKit.Format.EXPORT=["truncToFixed","roundToFixed","numberFormatter","formatLocale","twoDigitAverage","twoDigitFloat","percentFormat","lstrip","rstrip","strip"];
michael@0 2136 MochiKit.Format.LOCALE={en_US:{separator:",",decimal:".",percent:"%"},de_DE:{separator:".",decimal:",",percent:"%"},fr_FR:{separator:" ",decimal:",",percent:"%"},"default":"en_US"};
michael@0 2137 MochiKit.Format.EXPORT_OK=[];
michael@0 2138 MochiKit.Format.EXPORT_TAGS={":all":MochiKit.Format.EXPORT,":common":MochiKit.Format.EXPORT};
michael@0 2139 MochiKit.Format.__new__=function(){
michael@0 2140 var base=this.NAME+".";
michael@0 2141 var k,v,o;
michael@0 2142 for(k in this.LOCALE){
michael@0 2143 o=this.LOCALE[k];
michael@0 2144 if(typeof (o)=="object"){
michael@0 2145 o.repr=function(){
michael@0 2146 return this.NAME;
michael@0 2147 };
michael@0 2148 o.NAME=base+"LOCALE."+k;
michael@0 2149 }
michael@0 2150 }
michael@0 2151 for(k in this){
michael@0 2152 o=this[k];
michael@0 2153 if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
michael@0 2154 try{
michael@0 2155 o.NAME=base+k;
michael@0 2156 }
michael@0 2157 catch(e){
michael@0 2158 }
michael@0 2159 }
michael@0 2160 }
michael@0 2161 };
michael@0 2162 MochiKit.Format.__new__();
michael@0 2163 if(typeof (MochiKit.Base)!="undefined"){
michael@0 2164 MochiKit.Base._exportSymbols(this,MochiKit.Format);
michael@0 2165 }else{
michael@0 2166 (function(_273,_274){
michael@0 2167 if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){
michael@0 2168 var all=_274.EXPORT_TAGS[":all"];
michael@0 2169 for(var i=0;i<all.length;i++){
michael@0 2170 _273[all[i]]=_274[all[i]];
michael@0 2171 }
michael@0 2172 }
michael@0 2173 })(this,MochiKit.Format);
michael@0 2174 }
michael@0 2175 if(typeof (dojo)!="undefined"){
michael@0 2176 dojo.provide("MochiKit.Async");
michael@0 2177 dojo.require("MochiKit.Base");
michael@0 2178 }
michael@0 2179 if(typeof (JSAN)!="undefined"){
michael@0 2180 JSAN.use("MochiKit.Base",[]);
michael@0 2181 }
michael@0 2182 try{
michael@0 2183 if(typeof (MochiKit.Base)=="undefined"){
michael@0 2184 throw "";
michael@0 2185 }
michael@0 2186 }
michael@0 2187 catch(e){
michael@0 2188 throw "MochiKit.Async depends on MochiKit.Base!";
michael@0 2189 }
michael@0 2190 if(typeof (MochiKit.Async)=="undefined"){
michael@0 2191 MochiKit.Async={};
michael@0 2192 }
michael@0 2193 MochiKit.Async.NAME="MochiKit.Async";
michael@0 2194 MochiKit.Async.VERSION="1.4";
michael@0 2195 MochiKit.Async.__repr__=function(){
michael@0 2196 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 2197 };
michael@0 2198 MochiKit.Async.toString=function(){
michael@0 2199 return this.__repr__();
michael@0 2200 };
michael@0 2201 MochiKit.Async.Deferred=function(_277){
michael@0 2202 this.chain=[];
michael@0 2203 this.id=this._nextId();
michael@0 2204 this.fired=-1;
michael@0 2205 this.paused=0;
michael@0 2206 this.results=[null,null];
michael@0 2207 this.canceller=_277;
michael@0 2208 this.silentlyCancelled=false;
michael@0 2209 this.chained=false;
michael@0 2210 };
michael@0 2211 MochiKit.Async.Deferred.prototype={repr:function(){
michael@0 2212 var _278;
michael@0 2213 if(this.fired==-1){
michael@0 2214 _278="unfired";
michael@0 2215 }else{
michael@0 2216 if(this.fired===0){
michael@0 2217 _278="success";
michael@0 2218 }else{
michael@0 2219 _278="error";
michael@0 2220 }
michael@0 2221 }
michael@0 2222 return "Deferred("+this.id+", "+_278+")";
michael@0 2223 },toString:MochiKit.Base.forwardCall("repr"),_nextId:MochiKit.Base.counter(),cancel:function(){
michael@0 2224 var self=MochiKit.Async;
michael@0 2225 if(this.fired==-1){
michael@0 2226 if(this.canceller){
michael@0 2227 this.canceller(this);
michael@0 2228 }else{
michael@0 2229 this.silentlyCancelled=true;
michael@0 2230 }
michael@0 2231 if(this.fired==-1){
michael@0 2232 this.errback(new self.CancelledError(this));
michael@0 2233 }
michael@0 2234 }else{
michael@0 2235 if((this.fired===0)&&(this.results[0] instanceof self.Deferred)){
michael@0 2236 this.results[0].cancel();
michael@0 2237 }
michael@0 2238 }
michael@0 2239 },_resback:function(res){
michael@0 2240 this.fired=((res instanceof Error)?1:0);
michael@0 2241 this.results[this.fired]=res;
michael@0 2242 this._fire();
michael@0 2243 },_check:function(){
michael@0 2244 if(this.fired!=-1){
michael@0 2245 if(!this.silentlyCancelled){
michael@0 2246 throw new MochiKit.Async.AlreadyCalledError(this);
michael@0 2247 }
michael@0 2248 this.silentlyCancelled=false;
michael@0 2249 return;
michael@0 2250 }
michael@0 2251 },callback:function(res){
michael@0 2252 this._check();
michael@0 2253 if(res instanceof MochiKit.Async.Deferred){
michael@0 2254 throw new Error("Deferred instances can only be chained if they are the result of a callback");
michael@0 2255 }
michael@0 2256 this._resback(res);
michael@0 2257 },errback:function(res){
michael@0 2258 this._check();
michael@0 2259 var self=MochiKit.Async;
michael@0 2260 if(res instanceof self.Deferred){
michael@0 2261 throw new Error("Deferred instances can only be chained if they are the result of a callback");
michael@0 2262 }
michael@0 2263 if(!(res instanceof Error)){
michael@0 2264 res=new self.GenericError(res);
michael@0 2265 }
michael@0 2266 this._resback(res);
michael@0 2267 },addBoth:function(fn){
michael@0 2268 if(arguments.length>1){
michael@0 2269 fn=MochiKit.Base.partial.apply(null,arguments);
michael@0 2270 }
michael@0 2271 return this.addCallbacks(fn,fn);
michael@0 2272 },addCallback:function(fn){
michael@0 2273 if(arguments.length>1){
michael@0 2274 fn=MochiKit.Base.partial.apply(null,arguments);
michael@0 2275 }
michael@0 2276 return this.addCallbacks(fn,null);
michael@0 2277 },addErrback:function(fn){
michael@0 2278 if(arguments.length>1){
michael@0 2279 fn=MochiKit.Base.partial.apply(null,arguments);
michael@0 2280 }
michael@0 2281 return this.addCallbacks(null,fn);
michael@0 2282 },addCallbacks:function(cb,eb){
michael@0 2283 if(this.chained){
michael@0 2284 throw new Error("Chained Deferreds can not be re-used");
michael@0 2285 }
michael@0 2286 this.chain.push([cb,eb]);
michael@0 2287 if(this.fired>=0){
michael@0 2288 this._fire();
michael@0 2289 }
michael@0 2290 return this;
michael@0 2291 },_fire:function(){
michael@0 2292 var _283=this.chain;
michael@0 2293 var _284=this.fired;
michael@0 2294 var res=this.results[_284];
michael@0 2295 var self=this;
michael@0 2296 var cb=null;
michael@0 2297 while(_283.length>0&&this.paused===0){
michael@0 2298 var pair=_283.shift();
michael@0 2299 var f=pair[_284];
michael@0 2300 if(f===null){
michael@0 2301 continue;
michael@0 2302 }
michael@0 2303 try{
michael@0 2304 res=f(res);
michael@0 2305 _284=((res instanceof Error)?1:0);
michael@0 2306 if(res instanceof MochiKit.Async.Deferred){
michael@0 2307 cb=function(res){
michael@0 2308 self._resback(res);
michael@0 2309 self.paused--;
michael@0 2310 if((self.paused===0)&&(self.fired>=0)){
michael@0 2311 self._fire();
michael@0 2312 }
michael@0 2313 };
michael@0 2314 this.paused++;
michael@0 2315 }
michael@0 2316 }
michael@0 2317 catch(err){
michael@0 2318 _284=1;
michael@0 2319 if(!(err instanceof Error)){
michael@0 2320 err=new MochiKit.Async.GenericError(err);
michael@0 2321 }
michael@0 2322 res=err;
michael@0 2323 }
michael@0 2324 }
michael@0 2325 this.fired=_284;
michael@0 2326 this.results[_284]=res;
michael@0 2327 if(cb&&this.paused){
michael@0 2328 res.addBoth(cb);
michael@0 2329 res.chained=true;
michael@0 2330 }
michael@0 2331 }};
michael@0 2332 MochiKit.Base.update(MochiKit.Async,{evalJSONRequest:function(){
michael@0 2333 return eval("("+arguments[0].responseText+")");
michael@0 2334 },succeed:function(_28b){
michael@0 2335 var d=new MochiKit.Async.Deferred();
michael@0 2336 d.callback.apply(d,arguments);
michael@0 2337 return d;
michael@0 2338 },fail:function(_28d){
michael@0 2339 var d=new MochiKit.Async.Deferred();
michael@0 2340 d.errback.apply(d,arguments);
michael@0 2341 return d;
michael@0 2342 },getXMLHttpRequest:function(){
michael@0 2343 var self=arguments.callee;
michael@0 2344 if(!self.XMLHttpRequest){
michael@0 2345 var _290=[function(){
michael@0 2346 return new XMLHttpRequest();
michael@0 2347 },function(){
michael@0 2348 return new ActiveXObject("Msxml2.XMLHTTP");
michael@0 2349 },function(){
michael@0 2350 return new ActiveXObject("Microsoft.XMLHTTP");
michael@0 2351 },function(){
michael@0 2352 return new ActiveXObject("Msxml2.XMLHTTP.4.0");
michael@0 2353 },function(){
michael@0 2354 throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest");
michael@0 2355 }];
michael@0 2356 for(var i=0;i<_290.length;i++){
michael@0 2357 var func=_290[i];
michael@0 2358 try{
michael@0 2359 self.XMLHttpRequest=func;
michael@0 2360 return func();
michael@0 2361 }
michael@0 2362 catch(e){
michael@0 2363 }
michael@0 2364 }
michael@0 2365 }
michael@0 2366 return self.XMLHttpRequest();
michael@0 2367 },_xhr_onreadystatechange:function(d){
michael@0 2368 var m=MochiKit.Base;
michael@0 2369 if(this.readyState==4){
michael@0 2370 try{
michael@0 2371 this.onreadystatechange=null;
michael@0 2372 }
michael@0 2373 catch(e){
michael@0 2374 try{
michael@0 2375 this.onreadystatechange=m.noop;
michael@0 2376 }
michael@0 2377 catch(e){
michael@0 2378 }
michael@0 2379 }
michael@0 2380 var _295=null;
michael@0 2381 try{
michael@0 2382 _295=this.status;
michael@0 2383 if(!_295&&m.isNotEmpty(this.responseText)){
michael@0 2384 _295=304;
michael@0 2385 }
michael@0 2386 }
michael@0 2387 catch(e){
michael@0 2388 }
michael@0 2389 if(_295==200||_295==304){
michael@0 2390 d.callback(this);
michael@0 2391 }else{
michael@0 2392 var err=new MochiKit.Async.XMLHttpRequestError(this,"Request failed");
michael@0 2393 if(err.number){
michael@0 2394 d.errback(err);
michael@0 2395 }else{
michael@0 2396 d.errback(err);
michael@0 2397 }
michael@0 2398 }
michael@0 2399 }
michael@0 2400 },_xhr_canceller:function(req){
michael@0 2401 try{
michael@0 2402 req.onreadystatechange=null;
michael@0 2403 }
michael@0 2404 catch(e){
michael@0 2405 try{
michael@0 2406 req.onreadystatechange=MochiKit.Base.noop;
michael@0 2407 }
michael@0 2408 catch(e){
michael@0 2409 }
michael@0 2410 }
michael@0 2411 req.abort();
michael@0 2412 },sendXMLHttpRequest:function(req,_299){
michael@0 2413 if(typeof (_299)=="undefined"||_299===null){
michael@0 2414 _299="";
michael@0 2415 }
michael@0 2416 var m=MochiKit.Base;
michael@0 2417 var self=MochiKit.Async;
michael@0 2418 var d=new self.Deferred(m.partial(self._xhr_canceller,req));
michael@0 2419 try{
michael@0 2420 req.onreadystatechange=m.bind(self._xhr_onreadystatechange,req,d);
michael@0 2421 req.send(_299);
michael@0 2422 }
michael@0 2423 catch(e){
michael@0 2424 try{
michael@0 2425 req.onreadystatechange=null;
michael@0 2426 }
michael@0 2427 catch(ignore){
michael@0 2428 }
michael@0 2429 d.errback(e);
michael@0 2430 }
michael@0 2431 return d;
michael@0 2432 },doXHR:function(url,opts){
michael@0 2433 var m=MochiKit.Base;
michael@0 2434 opts=m.update({method:"GET",sendContent:""},opts);
michael@0 2435 var self=MochiKit.Async;
michael@0 2436 var req=self.getXMLHttpRequest();
michael@0 2437 if(opts.queryString){
michael@0 2438 var qs=m.queryString(opts.queryString);
michael@0 2439 if(qs){
michael@0 2440 url+="?"+qs;
michael@0 2441 }
michael@0 2442 }
michael@0 2443 req.open(opts.method,url,true,opts.username,opts.password);
michael@0 2444 if(req.overrideMimeType&&opts.mimeType){
michael@0 2445 req.overrideMimeType(opts.mimeType);
michael@0 2446 }
michael@0 2447 if(opts.headers){
michael@0 2448 var _2a3=opts.headers;
michael@0 2449 if(!m.isArrayLike(_2a3)){
michael@0 2450 _2a3=m.items(_2a3);
michael@0 2451 }
michael@0 2452 for(var i=0;i<_2a3.length;i++){
michael@0 2453 var _2a5=_2a3[i];
michael@0 2454 var name=_2a5[0];
michael@0 2455 var _2a7=_2a5[1];
michael@0 2456 req.setRequestHeader(name,_2a7);
michael@0 2457 }
michael@0 2458 }
michael@0 2459 return self.sendXMLHttpRequest(req,opts.sendContent);
michael@0 2460 },_buildURL:function(url){
michael@0 2461 if(arguments.length>1){
michael@0 2462 var m=MochiKit.Base;
michael@0 2463 var qs=m.queryString.apply(null,m.extend(null,arguments,1));
michael@0 2464 if(qs){
michael@0 2465 return url+"?"+qs;
michael@0 2466 }
michael@0 2467 }
michael@0 2468 return url;
michael@0 2469 },doSimpleXMLHttpRequest:function(url){
michael@0 2470 var self=MochiKit.Async;
michael@0 2471 url=self._buildURL.apply(self,arguments);
michael@0 2472 return self.doXHR(url);
michael@0 2473 },loadJSONDoc:function(url){
michael@0 2474 var self=MochiKit.Async;
michael@0 2475 url=self._buildURL.apply(self,arguments);
michael@0 2476 var d=self.doXHR(url,{"mimeType":"text/plain","headers":[["Accept","application/json"]]});
michael@0 2477 d=d.addCallback(self.evalJSONRequest);
michael@0 2478 return d;
michael@0 2479 },wait:function(_2b0,_2b1){
michael@0 2480 var d=new MochiKit.Async.Deferred();
michael@0 2481 var m=MochiKit.Base;
michael@0 2482 if(typeof (_2b1)!="undefined"){
michael@0 2483 d.addCallback(function(){
michael@0 2484 return _2b1;
michael@0 2485 });
michael@0 2486 }
michael@0 2487 var _2b4=setTimeout(m.bind("callback",d),Math.floor(_2b0*1000));
michael@0 2488 d.canceller=function(){
michael@0 2489 try{
michael@0 2490 clearTimeout(_2b4);
michael@0 2491 }
michael@0 2492 catch(e){
michael@0 2493 }
michael@0 2494 };
michael@0 2495 return d;
michael@0 2496 },callLater:function(_2b5,func){
michael@0 2497 var m=MochiKit.Base;
michael@0 2498 var _2b8=m.partial.apply(m,m.extend(null,arguments,1));
michael@0 2499 return MochiKit.Async.wait(_2b5).addCallback(function(res){
michael@0 2500 return _2b8();
michael@0 2501 });
michael@0 2502 }});
michael@0 2503 MochiKit.Async.DeferredLock=function(){
michael@0 2504 this.waiting=[];
michael@0 2505 this.locked=false;
michael@0 2506 this.id=this._nextId();
michael@0 2507 };
michael@0 2508 MochiKit.Async.DeferredLock.prototype={__class__:MochiKit.Async.DeferredLock,acquire:function(){
michael@0 2509 var d=new MochiKit.Async.Deferred();
michael@0 2510 if(this.locked){
michael@0 2511 this.waiting.push(d);
michael@0 2512 }else{
michael@0 2513 this.locked=true;
michael@0 2514 d.callback(this);
michael@0 2515 }
michael@0 2516 return d;
michael@0 2517 },release:function(){
michael@0 2518 if(!this.locked){
michael@0 2519 throw TypeError("Tried to release an unlocked DeferredLock");
michael@0 2520 }
michael@0 2521 this.locked=false;
michael@0 2522 if(this.waiting.length>0){
michael@0 2523 this.locked=true;
michael@0 2524 this.waiting.shift().callback(this);
michael@0 2525 }
michael@0 2526 },_nextId:MochiKit.Base.counter(),repr:function(){
michael@0 2527 var _2bb;
michael@0 2528 if(this.locked){
michael@0 2529 _2bb="locked, "+this.waiting.length+" waiting";
michael@0 2530 }else{
michael@0 2531 _2bb="unlocked";
michael@0 2532 }
michael@0 2533 return "DeferredLock("+this.id+", "+_2bb+")";
michael@0 2534 },toString:MochiKit.Base.forwardCall("repr")};
michael@0 2535 MochiKit.Async.DeferredList=function(list,_2bd,_2be,_2bf,_2c0){
michael@0 2536 MochiKit.Async.Deferred.apply(this,[_2c0]);
michael@0 2537 this.list=list;
michael@0 2538 var _2c1=[];
michael@0 2539 this.resultList=_2c1;
michael@0 2540 this.finishedCount=0;
michael@0 2541 this.fireOnOneCallback=_2bd;
michael@0 2542 this.fireOnOneErrback=_2be;
michael@0 2543 this.consumeErrors=_2bf;
michael@0 2544 var cb=MochiKit.Base.bind(this._cbDeferred,this);
michael@0 2545 for(var i=0;i<list.length;i++){
michael@0 2546 var d=list[i];
michael@0 2547 _2c1.push(undefined);
michael@0 2548 d.addCallback(cb,i,true);
michael@0 2549 d.addErrback(cb,i,false);
michael@0 2550 }
michael@0 2551 if(list.length===0&&!_2bd){
michael@0 2552 this.callback(this.resultList);
michael@0 2553 }
michael@0 2554 };
michael@0 2555 MochiKit.Async.DeferredList.prototype=new MochiKit.Async.Deferred();
michael@0 2556 MochiKit.Async.DeferredList.prototype._cbDeferred=function(_2c5,_2c6,_2c7){
michael@0 2557 this.resultList[_2c5]=[_2c6,_2c7];
michael@0 2558 this.finishedCount+=1;
michael@0 2559 if(this.fired==-1){
michael@0 2560 if(_2c6&&this.fireOnOneCallback){
michael@0 2561 this.callback([_2c5,_2c7]);
michael@0 2562 }else{
michael@0 2563 if(!_2c6&&this.fireOnOneErrback){
michael@0 2564 this.errback(_2c7);
michael@0 2565 }else{
michael@0 2566 if(this.finishedCount==this.list.length){
michael@0 2567 this.callback(this.resultList);
michael@0 2568 }
michael@0 2569 }
michael@0 2570 }
michael@0 2571 }
michael@0 2572 if(!_2c6&&this.consumeErrors){
michael@0 2573 _2c7=null;
michael@0 2574 }
michael@0 2575 return _2c7;
michael@0 2576 };
michael@0 2577 MochiKit.Async.gatherResults=function(_2c8){
michael@0 2578 var d=new MochiKit.Async.DeferredList(_2c8,false,true,false);
michael@0 2579 d.addCallback(function(_2ca){
michael@0 2580 var ret=[];
michael@0 2581 for(var i=0;i<_2ca.length;i++){
michael@0 2582 ret.push(_2ca[i][1]);
michael@0 2583 }
michael@0 2584 return ret;
michael@0 2585 });
michael@0 2586 return d;
michael@0 2587 };
michael@0 2588 MochiKit.Async.maybeDeferred=function(func){
michael@0 2589 var self=MochiKit.Async;
michael@0 2590 var _2cf;
michael@0 2591 try{
michael@0 2592 var r=func.apply(null,MochiKit.Base.extend([],arguments,1));
michael@0 2593 if(r instanceof self.Deferred){
michael@0 2594 _2cf=r;
michael@0 2595 }else{
michael@0 2596 if(r instanceof Error){
michael@0 2597 _2cf=self.fail(r);
michael@0 2598 }else{
michael@0 2599 _2cf=self.succeed(r);
michael@0 2600 }
michael@0 2601 }
michael@0 2602 }
michael@0 2603 catch(e){
michael@0 2604 _2cf=self.fail(e);
michael@0 2605 }
michael@0 2606 return _2cf;
michael@0 2607 };
michael@0 2608 MochiKit.Async.EXPORT=["AlreadyCalledError","CancelledError","BrowserComplianceError","GenericError","XMLHttpRequestError","Deferred","succeed","fail","getXMLHttpRequest","doSimpleXMLHttpRequest","loadJSONDoc","wait","callLater","sendXMLHttpRequest","DeferredLock","DeferredList","gatherResults","maybeDeferred","doXHR"];
michael@0 2609 MochiKit.Async.EXPORT_OK=["evalJSONRequest"];
michael@0 2610 MochiKit.Async.__new__=function(){
michael@0 2611 var m=MochiKit.Base;
michael@0 2612 var ne=m.partial(m._newNamedError,this);
michael@0 2613 ne("AlreadyCalledError",function(_2d3){
michael@0 2614 this.deferred=_2d3;
michael@0 2615 });
michael@0 2616 ne("CancelledError",function(_2d4){
michael@0 2617 this.deferred=_2d4;
michael@0 2618 });
michael@0 2619 ne("BrowserComplianceError",function(msg){
michael@0 2620 this.message=msg;
michael@0 2621 });
michael@0 2622 ne("GenericError",function(msg){
michael@0 2623 this.message=msg;
michael@0 2624 });
michael@0 2625 ne("XMLHttpRequestError",function(req,msg){
michael@0 2626 this.req=req;
michael@0 2627 this.message=msg;
michael@0 2628 try{
michael@0 2629 this.number=req.status;
michael@0 2630 }
michael@0 2631 catch(e){
michael@0 2632 }
michael@0 2633 });
michael@0 2634 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 2635 m.nameFunctions(this);
michael@0 2636 };
michael@0 2637 MochiKit.Async.__new__();
michael@0 2638 MochiKit.Base._exportSymbols(this,MochiKit.Async);
michael@0 2639 if(typeof (dojo)!="undefined"){
michael@0 2640 dojo.provide("MochiKit.DOM");
michael@0 2641 dojo.require("MochiKit.Base");
michael@0 2642 }
michael@0 2643 if(typeof (JSAN)!="undefined"){
michael@0 2644 JSAN.use("MochiKit.Base",[]);
michael@0 2645 }
michael@0 2646 try{
michael@0 2647 if(typeof (MochiKit.Base)=="undefined"){
michael@0 2648 throw "";
michael@0 2649 }
michael@0 2650 }
michael@0 2651 catch(e){
michael@0 2652 throw "MochiKit.DOM depends on MochiKit.Base!";
michael@0 2653 }
michael@0 2654 if(typeof (MochiKit.DOM)=="undefined"){
michael@0 2655 MochiKit.DOM={};
michael@0 2656 }
michael@0 2657 MochiKit.DOM.NAME="MochiKit.DOM";
michael@0 2658 MochiKit.DOM.VERSION="1.4";
michael@0 2659 MochiKit.DOM.__repr__=function(){
michael@0 2660 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 2661 };
michael@0 2662 MochiKit.DOM.toString=function(){
michael@0 2663 return this.__repr__();
michael@0 2664 };
michael@0 2665 MochiKit.DOM.EXPORT=["removeEmptyTextNodes","formContents","currentWindow","currentDocument","withWindow","withDocument","registerDOMConverter","coerceToDOM","createDOM","createDOMFunc","isChildNode","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","$","getElementsByTagAndClassName","addToCallStack","addLoadEvent","focusOnLoad","setElementClass","toggleElementClass","addElementClass","removeElementClass","swapElementClass","hasElementClass","escapeHTML","toHTML","emitHTML","scrapeText"];
michael@0 2666 MochiKit.DOM.EXPORT_OK=["domConverters"];
michael@0 2667 MochiKit.DOM.DEPRECATED=[["computedStyle","MochiKit.Style.computedStyle","1.4"],["elementDimensions","MochiKit.Style.getElementDimensions","1.4"],["elementPosition","MochiKit.Style.getElementPosition","1.4"],["hideElement","MochiKit.Style.hideElement","1.4"],["setElementDimensions","MochiKit.Style.setElementDimensions","1.4"],["setElementPosition","MochiKit.Style.setElementPosition","1.4"],["setDisplayForElement","MochiKit.Style.setDisplayForElement","1.4"],["setOpacity","MochiKit.Style.setOpacity","1.4"],["showElement","MochiKit.Style.showElement","1.4"],["Coordinates","MochiKit.Style.Coordinates","1.4"],["Dimensions","MochiKit.Style.Dimensions","1.4"]];
michael@0 2668 MochiKit.DOM.getViewportDimensions=new Function(""+"if (!MochiKit[\"Style\"]) {"+" throw new Error(\"This function has been deprecated and depends on MochiKit.Style.\");"+"}"+"return MochiKit.Style.getViewportDimensions.apply(this, arguments);");
michael@0 2669 MochiKit.Base.update(MochiKit.DOM,{currentWindow:function(){
michael@0 2670 return MochiKit.DOM._window;
michael@0 2671 },currentDocument:function(){
michael@0 2672 return MochiKit.DOM._document;
michael@0 2673 },withWindow:function(win,func){
michael@0 2674 var self=MochiKit.DOM;
michael@0 2675 var _2dc=self._document;
michael@0 2676 var _2dd=self._win;
michael@0 2677 var rval;
michael@0 2678 try{
michael@0 2679 self._window=win;
michael@0 2680 self._document=win.document;
michael@0 2681 rval=func();
michael@0 2682 }
michael@0 2683 catch(e){
michael@0 2684 self._window=_2dd;
michael@0 2685 self._document=_2dc;
michael@0 2686 throw e;
michael@0 2687 }
michael@0 2688 self._window=_2dd;
michael@0 2689 self._document=_2dc;
michael@0 2690 return rval;
michael@0 2691 },formContents:function(elem){
michael@0 2692 var _2e0=[];
michael@0 2693 var _2e1=[];
michael@0 2694 var m=MochiKit.Base;
michael@0 2695 var self=MochiKit.DOM;
michael@0 2696 if(typeof (elem)=="undefined"||elem===null){
michael@0 2697 elem=self._document;
michael@0 2698 }else{
michael@0 2699 elem=self.getElement(elem);
michael@0 2700 }
michael@0 2701 m.nodeWalk(elem,function(elem){
michael@0 2702 var name=elem.name;
michael@0 2703 if(m.isNotEmpty(name)){
michael@0 2704 var _2e6=elem.tagName.toUpperCase();
michael@0 2705 if(_2e6==="INPUT"&&(elem.type=="radio"||elem.type=="checkbox")&&!elem.checked){
michael@0 2706 return null;
michael@0 2707 }
michael@0 2708 if(_2e6==="SELECT"){
michael@0 2709 if(elem.type=="select-one"){
michael@0 2710 if(elem.selectedIndex>=0){
michael@0 2711 var opt=elem.options[elem.selectedIndex];
michael@0 2712 _2e0.push(name);
michael@0 2713 _2e1.push(opt.value);
michael@0 2714 return null;
michael@0 2715 }
michael@0 2716 _2e0.push(name);
michael@0 2717 _2e1.push("");
michael@0 2718 return null;
michael@0 2719 }else{
michael@0 2720 var opts=elem.options;
michael@0 2721 if(!opts.length){
michael@0 2722 _2e0.push(name);
michael@0 2723 _2e1.push("");
michael@0 2724 return null;
michael@0 2725 }
michael@0 2726 for(var i=0;i<opts.length;i++){
michael@0 2727 var opt=opts[i];
michael@0 2728 if(!opt.selected){
michael@0 2729 continue;
michael@0 2730 }
michael@0 2731 _2e0.push(name);
michael@0 2732 _2e1.push(opt.value);
michael@0 2733 }
michael@0 2734 return null;
michael@0 2735 }
michael@0 2736 }
michael@0 2737 if(_2e6==="FORM"||_2e6==="P"||_2e6==="SPAN"||_2e6==="DIV"){
michael@0 2738 return elem.childNodes;
michael@0 2739 }
michael@0 2740 _2e0.push(name);
michael@0 2741 _2e1.push(elem.value||"");
michael@0 2742 return null;
michael@0 2743 }
michael@0 2744 return elem.childNodes;
michael@0 2745 });
michael@0 2746 return [_2e0,_2e1];
michael@0 2747 },withDocument:function(doc,func){
michael@0 2748 var self=MochiKit.DOM;
michael@0 2749 var _2ed=self._document;
michael@0 2750 var rval;
michael@0 2751 try{
michael@0 2752 self._document=doc;
michael@0 2753 rval=func();
michael@0 2754 }
michael@0 2755 catch(e){
michael@0 2756 self._document=_2ed;
michael@0 2757 throw e;
michael@0 2758 }
michael@0 2759 self._document=_2ed;
michael@0 2760 return rval;
michael@0 2761 },registerDOMConverter:function(name,_2f0,wrap,_2f2){
michael@0 2762 MochiKit.DOM.domConverters.register(name,_2f0,wrap,_2f2);
michael@0 2763 },coerceToDOM:function(node,ctx){
michael@0 2764 var m=MochiKit.Base;
michael@0 2765 var im=MochiKit.Iter;
michael@0 2766 var self=MochiKit.DOM;
michael@0 2767 if(im){
michael@0 2768 var iter=im.iter;
michael@0 2769 var _2f9=im.repeat;
michael@0 2770 var map=m.map;
michael@0 2771 }
michael@0 2772 var _2fb=self.domConverters;
michael@0 2773 var _2fc=arguments.callee;
michael@0 2774 var _2fd=m.NotFound;
michael@0 2775 while(true){
michael@0 2776 if(typeof (node)=="undefined"||node===null){
michael@0 2777 return null;
michael@0 2778 }
michael@0 2779 if(typeof (node.nodeType)!="undefined"&&node.nodeType>0){
michael@0 2780 return node;
michael@0 2781 }
michael@0 2782 if(typeof (node)=="number"||typeof (node)=="boolean"){
michael@0 2783 node=node.toString();
michael@0 2784 }
michael@0 2785 if(typeof (node)=="string"){
michael@0 2786 return self._document.createTextNode(node);
michael@0 2787 }
michael@0 2788 if(typeof (node.__dom__)=="function"){
michael@0 2789 node=node.__dom__(ctx);
michael@0 2790 continue;
michael@0 2791 }
michael@0 2792 if(typeof (node.dom)=="function"){
michael@0 2793 node=node.dom(ctx);
michael@0 2794 continue;
michael@0 2795 }
michael@0 2796 if(typeof (node)=="function"){
michael@0 2797 node=node.apply(ctx,[ctx]);
michael@0 2798 continue;
michael@0 2799 }
michael@0 2800 if(im){
michael@0 2801 var _2fe=null;
michael@0 2802 try{
michael@0 2803 _2fe=iter(node);
michael@0 2804 }
michael@0 2805 catch(e){
michael@0 2806 }
michael@0 2807 if(_2fe){
michael@0 2808 return map(_2fc,_2fe,_2f9(ctx));
michael@0 2809 }
michael@0 2810 }
michael@0 2811 try{
michael@0 2812 node=_2fb.match(node,ctx);
michael@0 2813 continue;
michael@0 2814 }
michael@0 2815 catch(e){
michael@0 2816 if(e!=_2fd){
michael@0 2817 throw e;
michael@0 2818 }
michael@0 2819 }
michael@0 2820 return self._document.createTextNode(node.toString());
michael@0 2821 }
michael@0 2822 return undefined;
michael@0 2823 },isChildNode:function(node,_300){
michael@0 2824 var self=MochiKit.DOM;
michael@0 2825 if(typeof (node)=="string"){
michael@0 2826 node=self.getElement(node);
michael@0 2827 }
michael@0 2828 if(typeof (_300)=="string"){
michael@0 2829 _300=self.getElement(_300);
michael@0 2830 }
michael@0 2831 if(node===_300){
michael@0 2832 return true;
michael@0 2833 }
michael@0 2834 while(node&&node.tagName.toUpperCase()!="BODY"){
michael@0 2835 node=node.parentNode;
michael@0 2836 if(node===_300){
michael@0 2837 return true;
michael@0 2838 }
michael@0 2839 }
michael@0 2840 return false;
michael@0 2841 },setNodeAttribute:function(node,attr,_304){
michael@0 2842 var o={};
michael@0 2843 o[attr]=_304;
michael@0 2844 try{
michael@0 2845 return MochiKit.DOM.updateNodeAttributes(node,o);
michael@0 2846 }
michael@0 2847 catch(e){
michael@0 2848 }
michael@0 2849 return null;
michael@0 2850 },getNodeAttribute:function(node,attr){
michael@0 2851 var self=MochiKit.DOM;
michael@0 2852 var _309=self.attributeArray.renames[attr];
michael@0 2853 node=self.getElement(node);
michael@0 2854 try{
michael@0 2855 if(_309){
michael@0 2856 return node[_309];
michael@0 2857 }
michael@0 2858 return node.getAttribute(attr);
michael@0 2859 }
michael@0 2860 catch(e){
michael@0 2861 }
michael@0 2862 return null;
michael@0 2863 },updateNodeAttributes:function(node,_30b){
michael@0 2864 var elem=node;
michael@0 2865 var self=MochiKit.DOM;
michael@0 2866 if(typeof (node)=="string"){
michael@0 2867 elem=self.getElement(node);
michael@0 2868 }
michael@0 2869 if(_30b){
michael@0 2870 var _30e=MochiKit.Base.updatetree;
michael@0 2871 if(self.attributeArray.compliant){
michael@0 2872 for(var k in _30b){
michael@0 2873 var v=_30b[k];
michael@0 2874 if(typeof (v)=="object"&&typeof (elem[k])=="object"){
michael@0 2875 _30e(elem[k],v);
michael@0 2876 }else{
michael@0 2877 if(k.substring(0,2)=="on"){
michael@0 2878 if(typeof (v)=="string"){
michael@0 2879 v=new Function(v);
michael@0 2880 }
michael@0 2881 elem[k]=v;
michael@0 2882 }else{
michael@0 2883 elem.setAttribute(k,v);
michael@0 2884 }
michael@0 2885 }
michael@0 2886 }
michael@0 2887 }else{
michael@0 2888 var _311=self.attributeArray.renames;
michael@0 2889 for(k in _30b){
michael@0 2890 v=_30b[k];
michael@0 2891 var _312=_311[k];
michael@0 2892 if(k=="style"&&typeof (v)=="string"){
michael@0 2893 elem.style.cssText=v;
michael@0 2894 }else{
michael@0 2895 if(typeof (_312)=="string"){
michael@0 2896 elem[_312]=v;
michael@0 2897 }else{
michael@0 2898 if(typeof (elem[k])=="object"&&typeof (v)=="object"){
michael@0 2899 _30e(elem[k],v);
michael@0 2900 }else{
michael@0 2901 if(k.substring(0,2)=="on"){
michael@0 2902 if(typeof (v)=="string"){
michael@0 2903 v=new Function(v);
michael@0 2904 }
michael@0 2905 elem[k]=v;
michael@0 2906 }else{
michael@0 2907 elem.setAttribute(k,v);
michael@0 2908 }
michael@0 2909 }
michael@0 2910 }
michael@0 2911 }
michael@0 2912 }
michael@0 2913 }
michael@0 2914 }
michael@0 2915 return elem;
michael@0 2916 },appendChildNodes:function(node){
michael@0 2917 var elem=node;
michael@0 2918 var self=MochiKit.DOM;
michael@0 2919 if(typeof (node)=="string"){
michael@0 2920 elem=self.getElement(node);
michael@0 2921 }
michael@0 2922 var _316=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
michael@0 2923 var _317=MochiKit.Base.concat;
michael@0 2924 while(_316.length){
michael@0 2925 var n=_316.shift();
michael@0 2926 if(typeof (n)=="undefined"||n===null){
michael@0 2927 }else{
michael@0 2928 if(typeof (n.nodeType)=="number"){
michael@0 2929 elem.appendChild(n);
michael@0 2930 }else{
michael@0 2931 _316=_317(n,_316);
michael@0 2932 }
michael@0 2933 }
michael@0 2934 }
michael@0 2935 return elem;
michael@0 2936 },replaceChildNodes:function(node){
michael@0 2937 var elem=node;
michael@0 2938 var self=MochiKit.DOM;
michael@0 2939 if(typeof (node)=="string"){
michael@0 2940 elem=self.getElement(node);
michael@0 2941 arguments[0]=elem;
michael@0 2942 }
michael@0 2943 var _31c;
michael@0 2944 while((_31c=elem.firstChild)){
michael@0 2945 elem.removeChild(_31c);
michael@0 2946 }
michael@0 2947 if(arguments.length<2){
michael@0 2948 return elem;
michael@0 2949 }else{
michael@0 2950 return self.appendChildNodes.apply(this,arguments);
michael@0 2951 }
michael@0 2952 },createDOM:function(name,_31e){
michael@0 2953 var elem;
michael@0 2954 var self=MochiKit.DOM;
michael@0 2955 var m=MochiKit.Base;
michael@0 2956 if(typeof (_31e)=="string"||typeof (_31e)=="number"){
michael@0 2957 var args=m.extend([name,null],arguments,1);
michael@0 2958 return arguments.callee.apply(this,args);
michael@0 2959 }
michael@0 2960 if(typeof (name)=="string"){
michael@0 2961 var _323=self._xhtml;
michael@0 2962 if(_31e&&!self.attributeArray.compliant){
michael@0 2963 var _324="";
michael@0 2964 if("name" in _31e){
michael@0 2965 _324+=" name=\""+self.escapeHTML(_31e.name)+"\"";
michael@0 2966 }
michael@0 2967 if(name=="input"&&"type" in _31e){
michael@0 2968 _324+=" type=\""+self.escapeHTML(_31e.type)+"\"";
michael@0 2969 }
michael@0 2970 if(_324){
michael@0 2971 name="<"+name+_324+">";
michael@0 2972 _323=false;
michael@0 2973 }
michael@0 2974 }
michael@0 2975 var d=self._document;
michael@0 2976 if(_323&&d===document){
michael@0 2977 elem=d.createElementNS("http://www.w3.org/1999/xhtml",name);
michael@0 2978 }else{
michael@0 2979 elem=d.createElement(name);
michael@0 2980 }
michael@0 2981 }else{
michael@0 2982 elem=name;
michael@0 2983 }
michael@0 2984 if(_31e){
michael@0 2985 self.updateNodeAttributes(elem,_31e);
michael@0 2986 }
michael@0 2987 if(arguments.length<=2){
michael@0 2988 return elem;
michael@0 2989 }else{
michael@0 2990 var args=m.extend([elem],arguments,2);
michael@0 2991 return self.appendChildNodes.apply(this,args);
michael@0 2992 }
michael@0 2993 },createDOMFunc:function(){
michael@0 2994 var m=MochiKit.Base;
michael@0 2995 return m.partial.apply(this,m.extend([MochiKit.DOM.createDOM],arguments));
michael@0 2996 },removeElement:function(elem){
michael@0 2997 var e=MochiKit.DOM.getElement(elem);
michael@0 2998 e.parentNode.removeChild(e);
michael@0 2999 return e;
michael@0 3000 },swapDOM:function(dest,src){
michael@0 3001 var self=MochiKit.DOM;
michael@0 3002 dest=self.getElement(dest);
michael@0 3003 var _32c=dest.parentNode;
michael@0 3004 if(src){
michael@0 3005 src=self.getElement(src);
michael@0 3006 _32c.replaceChild(src,dest);
michael@0 3007 }else{
michael@0 3008 _32c.removeChild(dest);
michael@0 3009 }
michael@0 3010 return src;
michael@0 3011 },getElement:function(id){
michael@0 3012 var self=MochiKit.DOM;
michael@0 3013 if(arguments.length==1){
michael@0 3014 return ((typeof (id)=="string")?self._document.getElementById(id):id);
michael@0 3015 }else{
michael@0 3016 return MochiKit.Base.map(self.getElement,arguments);
michael@0 3017 }
michael@0 3018 },getElementsByTagAndClassName:function(_32f,_330,_331){
michael@0 3019 var self=MochiKit.DOM;
michael@0 3020 if(typeof (_32f)=="undefined"||_32f===null){
michael@0 3021 _32f="*";
michael@0 3022 }
michael@0 3023 if(typeof (_331)=="undefined"||_331===null){
michael@0 3024 _331=self._document;
michael@0 3025 }
michael@0 3026 _331=self.getElement(_331);
michael@0 3027 var _333=(_331.getElementsByTagName(_32f)||self._document.all);
michael@0 3028 if(typeof (_330)=="undefined"||_330===null){
michael@0 3029 return MochiKit.Base.extend(null,_333);
michael@0 3030 }
michael@0 3031 var _334=[];
michael@0 3032 for(var i=0;i<_333.length;i++){
michael@0 3033 var _336=_333[i];
michael@0 3034 var cls=_336.className;
michael@0 3035 if(!cls){
michael@0 3036 continue;
michael@0 3037 }
michael@0 3038 var _338=cls.split(" ");
michael@0 3039 for(var j=0;j<_338.length;j++){
michael@0 3040 if(_338[j]==_330){
michael@0 3041 _334.push(_336);
michael@0 3042 break;
michael@0 3043 }
michael@0 3044 }
michael@0 3045 }
michael@0 3046 return _334;
michael@0 3047 },_newCallStack:function(path,once){
michael@0 3048 var rval=function(){
michael@0 3049 var _33d=arguments.callee.callStack;
michael@0 3050 for(var i=0;i<_33d.length;i++){
michael@0 3051 if(_33d[i].apply(this,arguments)===false){
michael@0 3052 break;
michael@0 3053 }
michael@0 3054 }
michael@0 3055 if(once){
michael@0 3056 try{
michael@0 3057 this[path]=null;
michael@0 3058 }
michael@0 3059 catch(e){
michael@0 3060 }
michael@0 3061 }
michael@0 3062 };
michael@0 3063 rval.callStack=[];
michael@0 3064 return rval;
michael@0 3065 },addToCallStack:function(_33f,path,func,once){
michael@0 3066 var self=MochiKit.DOM;
michael@0 3067 var _344=_33f[path];
michael@0 3068 var _345=_344;
michael@0 3069 if(!(typeof (_344)=="function"&&typeof (_344.callStack)=="object"&&_344.callStack!==null)){
michael@0 3070 _345=self._newCallStack(path,once);
michael@0 3071 if(typeof (_344)=="function"){
michael@0 3072 _345.callStack.push(_344);
michael@0 3073 }
michael@0 3074 _33f[path]=_345;
michael@0 3075 }
michael@0 3076 _345.callStack.push(func);
michael@0 3077 },addLoadEvent:function(func){
michael@0 3078 var self=MochiKit.DOM;
michael@0 3079 self.addToCallStack(self._window,"onload",func,true);
michael@0 3080 },focusOnLoad:function(_348){
michael@0 3081 var self=MochiKit.DOM;
michael@0 3082 self.addLoadEvent(function(){
michael@0 3083 _348=self.getElement(_348);
michael@0 3084 if(_348){
michael@0 3085 _348.focus();
michael@0 3086 }
michael@0 3087 });
michael@0 3088 },setElementClass:function(_34a,_34b){
michael@0 3089 var self=MochiKit.DOM;
michael@0 3090 var obj=self.getElement(_34a);
michael@0 3091 if(self.attributeArray.compliant){
michael@0 3092 obj.setAttribute("class",_34b);
michael@0 3093 }else{
michael@0 3094 obj.setAttribute("className",_34b);
michael@0 3095 }
michael@0 3096 },toggleElementClass:function(_34e){
michael@0 3097 var self=MochiKit.DOM;
michael@0 3098 for(var i=1;i<arguments.length;i++){
michael@0 3099 var obj=self.getElement(arguments[i]);
michael@0 3100 if(!self.addElementClass(obj,_34e)){
michael@0 3101 self.removeElementClass(obj,_34e);
michael@0 3102 }
michael@0 3103 }
michael@0 3104 },addElementClass:function(_352,_353){
michael@0 3105 var self=MochiKit.DOM;
michael@0 3106 var obj=self.getElement(_352);
michael@0 3107 var cls=obj.className;
michael@0 3108 if(cls==undefined||cls.length===0){
michael@0 3109 self.setElementClass(obj,_353);
michael@0 3110 return true;
michael@0 3111 }
michael@0 3112 if(cls==_353){
michael@0 3113 return false;
michael@0 3114 }
michael@0 3115 var _357=cls.split(" ");
michael@0 3116 for(var i=0;i<_357.length;i++){
michael@0 3117 if(_357[i]==_353){
michael@0 3118 return false;
michael@0 3119 }
michael@0 3120 }
michael@0 3121 self.setElementClass(obj,cls+" "+_353);
michael@0 3122 return true;
michael@0 3123 },removeElementClass:function(_359,_35a){
michael@0 3124 var self=MochiKit.DOM;
michael@0 3125 var obj=self.getElement(_359);
michael@0 3126 var cls=obj.className;
michael@0 3127 if(cls==undefined||cls.length===0){
michael@0 3128 return false;
michael@0 3129 }
michael@0 3130 if(cls==_35a){
michael@0 3131 self.setElementClass(obj,"");
michael@0 3132 return true;
michael@0 3133 }
michael@0 3134 var _35e=cls.split(" ");
michael@0 3135 for(var i=0;i<_35e.length;i++){
michael@0 3136 if(_35e[i]==_35a){
michael@0 3137 _35e.splice(i,1);
michael@0 3138 self.setElementClass(obj,_35e.join(" "));
michael@0 3139 return true;
michael@0 3140 }
michael@0 3141 }
michael@0 3142 return false;
michael@0 3143 },swapElementClass:function(_360,_361,_362){
michael@0 3144 var obj=MochiKit.DOM.getElement(_360);
michael@0 3145 var res=MochiKit.DOM.removeElementClass(obj,_361);
michael@0 3146 if(res){
michael@0 3147 MochiKit.DOM.addElementClass(obj,_362);
michael@0 3148 }
michael@0 3149 return res;
michael@0 3150 },hasElementClass:function(_365,_366){
michael@0 3151 var obj=MochiKit.DOM.getElement(_365);
michael@0 3152 var cls=obj.className;
michael@0 3153 if(!cls){
michael@0 3154 return false;
michael@0 3155 }
michael@0 3156 var _369=cls.split(" ");
michael@0 3157 for(var i=1;i<arguments.length;i++){
michael@0 3158 var good=false;
michael@0 3159 for(var j=0;j<_369.length;j++){
michael@0 3160 if(_369[j]==arguments[i]){
michael@0 3161 good=true;
michael@0 3162 break;
michael@0 3163 }
michael@0 3164 }
michael@0 3165 if(!good){
michael@0 3166 return false;
michael@0 3167 }
michael@0 3168 }
michael@0 3169 return true;
michael@0 3170 },escapeHTML:function(s){
michael@0 3171 return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
michael@0 3172 },toHTML:function(dom){
michael@0 3173 return MochiKit.DOM.emitHTML(dom).join("");
michael@0 3174 },emitHTML:function(dom,lst){
michael@0 3175 if(typeof (lst)=="undefined"||lst===null){
michael@0 3176 lst=[];
michael@0 3177 }
michael@0 3178 var _371=[dom];
michael@0 3179 var self=MochiKit.DOM;
michael@0 3180 var _373=self.escapeHTML;
michael@0 3181 var _374=self.attributeArray;
michael@0 3182 while(_371.length){
michael@0 3183 dom=_371.pop();
michael@0 3184 if(typeof (dom)=="string"){
michael@0 3185 lst.push(dom);
michael@0 3186 }else{
michael@0 3187 if(dom.nodeType==1){
michael@0 3188 lst.push("<"+dom.tagName.toLowerCase());
michael@0 3189 var _375=[];
michael@0 3190 var _376=_374(dom);
michael@0 3191 for(var i=0;i<_376.length;i++){
michael@0 3192 var a=_376[i];
michael@0 3193 _375.push([" ",a.name,"=\"",_373(a.value),"\""]);
michael@0 3194 }
michael@0 3195 _375.sort();
michael@0 3196 for(i=0;i<_375.length;i++){
michael@0 3197 var _379=_375[i];
michael@0 3198 for(var j=0;j<_379.length;j++){
michael@0 3199 lst.push(_379[j]);
michael@0 3200 }
michael@0 3201 }
michael@0 3202 if(dom.hasChildNodes()){
michael@0 3203 lst.push(">");
michael@0 3204 _371.push("</"+dom.tagName.toLowerCase()+">");
michael@0 3205 var _37b=dom.childNodes;
michael@0 3206 for(i=_37b.length-1;i>=0;i--){
michael@0 3207 _371.push(_37b[i]);
michael@0 3208 }
michael@0 3209 }else{
michael@0 3210 lst.push("/>");
michael@0 3211 }
michael@0 3212 }else{
michael@0 3213 if(dom.nodeType==3){
michael@0 3214 lst.push(_373(dom.nodeValue));
michael@0 3215 }
michael@0 3216 }
michael@0 3217 }
michael@0 3218 }
michael@0 3219 return lst;
michael@0 3220 },scrapeText:function(node,_37d){
michael@0 3221 var rval=[];
michael@0 3222 (function(node){
michael@0 3223 var cn=node.childNodes;
michael@0 3224 if(cn){
michael@0 3225 for(var i=0;i<cn.length;i++){
michael@0 3226 arguments.callee.call(this,cn[i]);
michael@0 3227 }
michael@0 3228 }
michael@0 3229 var _382=node.nodeValue;
michael@0 3230 if(typeof (_382)=="string"){
michael@0 3231 rval.push(_382);
michael@0 3232 }
michael@0 3233 })(MochiKit.DOM.getElement(node));
michael@0 3234 if(_37d){
michael@0 3235 return rval;
michael@0 3236 }else{
michael@0 3237 return rval.join("");
michael@0 3238 }
michael@0 3239 },removeEmptyTextNodes:function(_383){
michael@0 3240 _383=MochiKit.DOM.getElement(_383);
michael@0 3241 for(var i=0;i<_383.childNodes.length;i++){
michael@0 3242 var node=_383.childNodes[i];
michael@0 3243 if(node.nodeType==3&&!/\S/.test(node.nodeValue)){
michael@0 3244 node.parentNode.removeChild(node);
michael@0 3245 }
michael@0 3246 }
michael@0 3247 },__new__:function(win){
michael@0 3248 var m=MochiKit.Base;
michael@0 3249 if(typeof (document)!="undefined"){
michael@0 3250 this._document=document;
michael@0 3251 this._xhtml=document.createElementNS&&document.createElement("testname").localName=="testname";
michael@0 3252 }else{
michael@0 3253 if(MochiKit.MockDOM){
michael@0 3254 this._document=MochiKit.MockDOM.document;
michael@0 3255 }
michael@0 3256 }
michael@0 3257 this._window=win;
michael@0 3258 this.domConverters=new m.AdapterRegistry();
michael@0 3259 var _388=this._document.createElement("span");
michael@0 3260 var _389;
michael@0 3261 if(_388&&_388.attributes&&_388.attributes.length>0){
michael@0 3262 var _38a=m.filter;
michael@0 3263 _389=function(node){
michael@0 3264 return _38a(_389.ignoreAttrFilter,node.attributes);
michael@0 3265 };
michael@0 3266 _389.ignoreAttr={};
michael@0 3267 var _38c=_388.attributes;
michael@0 3268 var _38d=_389.ignoreAttr;
michael@0 3269 for(var i=0;i<_38c.length;i++){
michael@0 3270 var a=_38c[i];
michael@0 3271 _38d[a.name]=a.value;
michael@0 3272 }
michael@0 3273 _389.ignoreAttrFilter=function(a){
michael@0 3274 return (_389.ignoreAttr[a.name]!=a.value);
michael@0 3275 };
michael@0 3276 _389.compliant=false;
michael@0 3277 _389.renames={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor"};
michael@0 3278 }else{
michael@0 3279 _389=function(node){
michael@0 3280 return node.attributes;
michael@0 3281 };
michael@0 3282 _389.compliant=true;
michael@0 3283 _389.renames={};
michael@0 3284 }
michael@0 3285 this.attributeArray=_389;
michael@0 3286 var _392=function(_393,arr){
michael@0 3287 var _395=arr[1].split(".");
michael@0 3288 var str="";
michael@0 3289 var obj={};
michael@0 3290 str+="if (!MochiKit."+_395[1]+") { throw new Error(\"";
michael@0 3291 str+="This function has been deprecated and depends on MochiKit.";
michael@0 3292 str+=_395[1]+".\");}";
michael@0 3293 str+="return MochiKit."+_395[1]+"."+arr[0];
michael@0 3294 str+=".apply(this, arguments);";
michael@0 3295 obj[_395[2]]=new Function(str);
michael@0 3296 MochiKit.Base.update(MochiKit[_393],obj);
michael@0 3297 };
michael@0 3298 for(var i;i<MochiKit.DOM.DEPRECATED.length;i++){
michael@0 3299 _392("DOM",MochiKit.DOM.DEPRECATED[i]);
michael@0 3300 }
michael@0 3301 var _398=this.createDOMFunc;
michael@0 3302 this.UL=_398("ul");
michael@0 3303 this.OL=_398("ol");
michael@0 3304 this.LI=_398("li");
michael@0 3305 this.TD=_398("td");
michael@0 3306 this.TR=_398("tr");
michael@0 3307 this.TBODY=_398("tbody");
michael@0 3308 this.THEAD=_398("thead");
michael@0 3309 this.TFOOT=_398("tfoot");
michael@0 3310 this.TABLE=_398("table");
michael@0 3311 this.TH=_398("th");
michael@0 3312 this.INPUT=_398("input");
michael@0 3313 this.SPAN=_398("span");
michael@0 3314 this.A=_398("a");
michael@0 3315 this.DIV=_398("div");
michael@0 3316 this.IMG=_398("img");
michael@0 3317 this.BUTTON=_398("button");
michael@0 3318 this.TT=_398("tt");
michael@0 3319 this.PRE=_398("pre");
michael@0 3320 this.H1=_398("h1");
michael@0 3321 this.H2=_398("h2");
michael@0 3322 this.H3=_398("h3");
michael@0 3323 this.BR=_398("br");
michael@0 3324 this.HR=_398("hr");
michael@0 3325 this.LABEL=_398("label");
michael@0 3326 this.TEXTAREA=_398("textarea");
michael@0 3327 this.FORM=_398("form");
michael@0 3328 this.P=_398("p");
michael@0 3329 this.SELECT=_398("select");
michael@0 3330 this.OPTION=_398("option");
michael@0 3331 this.OPTGROUP=_398("optgroup");
michael@0 3332 this.LEGEND=_398("legend");
michael@0 3333 this.FIELDSET=_398("fieldset");
michael@0 3334 this.STRONG=_398("strong");
michael@0 3335 this.CANVAS=_398("canvas");
michael@0 3336 this.$=this.getElement;
michael@0 3337 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 3338 m.nameFunctions(this);
michael@0 3339 }});
michael@0 3340 MochiKit.DOM.__new__(((typeof (window)=="undefined")?this:window));
michael@0 3341 if(MochiKit.__export__){
michael@0 3342 withWindow=MochiKit.DOM.withWindow;
michael@0 3343 withDocument=MochiKit.DOM.withDocument;
michael@0 3344 }
michael@0 3345 MochiKit.Base._exportSymbols(this,MochiKit.DOM);
michael@0 3346 if(typeof (dojo)!="undefined"){
michael@0 3347 dojo.provide("MochiKit.Style");
michael@0 3348 dojo.require("MochiKit.Base");
michael@0 3349 dojo.require("MochiKit.DOM");
michael@0 3350 }
michael@0 3351 if(typeof (JSAN)!="undefined"){
michael@0 3352 JSAN.use("MochiKit.Base",[]);
michael@0 3353 }
michael@0 3354 try{
michael@0 3355 if(typeof (MochiKit.Base)=="undefined"){
michael@0 3356 throw "";
michael@0 3357 }
michael@0 3358 }
michael@0 3359 catch(e){
michael@0 3360 throw "MochiKit.Style depends on MochiKit.Base!";
michael@0 3361 }
michael@0 3362 try{
michael@0 3363 if(typeof (MochiKit.DOM)=="undefined"){
michael@0 3364 throw "";
michael@0 3365 }
michael@0 3366 }
michael@0 3367 catch(e){
michael@0 3368 throw "MochiKit.Style depends on MochiKit.DOM!";
michael@0 3369 }
michael@0 3370 if(typeof (MochiKit.Style)=="undefined"){
michael@0 3371 MochiKit.Style={};
michael@0 3372 }
michael@0 3373 MochiKit.Style.NAME="MochiKit.Style";
michael@0 3374 MochiKit.Style.VERSION="1.4";
michael@0 3375 MochiKit.Style.__repr__=function(){
michael@0 3376 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 3377 };
michael@0 3378 MochiKit.Style.toString=function(){
michael@0 3379 return this.__repr__();
michael@0 3380 };
michael@0 3381 MochiKit.Style.EXPORT_OK=[];
michael@0 3382 MochiKit.Style.EXPORT=["setOpacity","getOpacity","setStyle","getStyle","computedStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
michael@0 3383 MochiKit.Style.Dimensions=function(w,h){
michael@0 3384 this.w=w;
michael@0 3385 this.h=h;
michael@0 3386 };
michael@0 3387 MochiKit.Style.Dimensions.prototype.__repr__=function(){
michael@0 3388 var repr=MochiKit.Base.repr;
michael@0 3389 return "{w: "+repr(this.w)+", h: "+repr(this.h)+"}";
michael@0 3390 };
michael@0 3391 MochiKit.Style.Dimensions.prototype.toString=function(){
michael@0 3392 return this.__repr__();
michael@0 3393 };
michael@0 3394 MochiKit.Style.Coordinates=function(x,y){
michael@0 3395 this.x=x;
michael@0 3396 this.y=y;
michael@0 3397 };
michael@0 3398 MochiKit.Style.Coordinates.prototype.__repr__=function(){
michael@0 3399 var repr=MochiKit.Base.repr;
michael@0 3400 return "{x: "+repr(this.x)+", y: "+repr(this.y)+"}";
michael@0 3401 };
michael@0 3402 MochiKit.Style.Coordinates.prototype.toString=function(){
michael@0 3403 return this.__repr__();
michael@0 3404 };
michael@0 3405 MochiKit.Base.update(MochiKit.Style,{computedStyle:function(elem,_3a0){
michael@0 3406 var dom=MochiKit.DOM;
michael@0 3407 var d=dom._document;
michael@0 3408 elem=dom.getElement(elem);
michael@0 3409 _3a0=MochiKit.Base.camelize(_3a0);
michael@0 3410 if(!elem||elem==d){
michael@0 3411 return undefined;
michael@0 3412 }
michael@0 3413 if(_3a0=="opacity"&&elem.filters){
michael@0 3414 try{
michael@0 3415 return elem.filters.item("DXImageTransform.Microsoft.Alpha").opacity/100;
michael@0 3416 }
michael@0 3417 catch(e){
michael@0 3418 try{
michael@0 3419 return elem.filters.item("alpha").opacity/100;
michael@0 3420 }
michael@0 3421 catch(e){
michael@0 3422 }
michael@0 3423 }
michael@0 3424 }
michael@0 3425 if(elem.currentStyle){
michael@0 3426 return elem.currentStyle[_3a0];
michael@0 3427 }
michael@0 3428 if(typeof (d.defaultView)=="undefined"){
michael@0 3429 return undefined;
michael@0 3430 }
michael@0 3431 if(d.defaultView===null){
michael@0 3432 return undefined;
michael@0 3433 }
michael@0 3434 var _3a3=d.defaultView.getComputedStyle(elem,null);
michael@0 3435 if(typeof (_3a3)=="undefined"||_3a3===null){
michael@0 3436 return undefined;
michael@0 3437 }
michael@0 3438 var _3a4=_3a0.replace(/([A-Z])/g,"-$1").toLowerCase();
michael@0 3439 return _3a3.getPropertyValue(_3a4);
michael@0 3440 },getStyle:function(elem,_3a6){
michael@0 3441 elem=MochiKit.DOM.getElement(elem);
michael@0 3442 var _3a7=elem.style[MochiKit.Base.camelize(_3a6)];
michael@0 3443 if(!_3a7){
michael@0 3444 if(document.defaultView&&document.defaultView.getComputedStyle){
michael@0 3445 var css=document.defaultView.getComputedStyle(elem,null);
michael@0 3446 _3a7=css?css.getPropertyValue(_3a6):null;
michael@0 3447 }else{
michael@0 3448 if(elem.currentStyle){
michael@0 3449 _3a7=elem.currentStyle[MochiKit.Base.camelize(_3a6)];
michael@0 3450 }
michael@0 3451 }
michael@0 3452 }
michael@0 3453 if(/Opera/.test(navigator.userAgent)&&(MochiKit.Base.find(["left","top","right","bottom"],_3a6)!=-1)){
michael@0 3454 if(MochiKit.Style.getStyle(elem,"position")=="static"){
michael@0 3455 _3a7="auto";
michael@0 3456 }
michael@0 3457 }
michael@0 3458 return _3a7=="auto"?null:_3a7;
michael@0 3459 },setStyle:function(elem,_3aa){
michael@0 3460 elem=MochiKit.DOM.getElement(elem);
michael@0 3461 for(name in _3aa){
michael@0 3462 elem.style[MochiKit.Base.camelize(name)]=_3aa[name];
michael@0 3463 }
michael@0 3464 },getOpacity:function(elem){
michael@0 3465 var _3ac;
michael@0 3466 if(_3ac=MochiKit.Style.getStyle(elem,"opacity")){
michael@0 3467 return parseFloat(_3ac);
michael@0 3468 }
michael@0 3469 if(_3ac=(MochiKit.Style.getStyle(elem,"filter")||"").match(/alpha\(opacity=(.*)\)/)){
michael@0 3470 if(_3ac[1]){
michael@0 3471 return parseFloat(_3ac[1])/100;
michael@0 3472 }
michael@0 3473 }
michael@0 3474 return 1;
michael@0 3475 },setOpacity:function(elem,o){
michael@0 3476 elem=MochiKit.DOM.getElement(elem);
michael@0 3477 var self=MochiKit.Style;
michael@0 3478 if(o==1){
michael@0 3479 var _3b0=/Gecko/.test(navigator.userAgent)&&!(/Konqueror|Safari|KHTML/.test(navigator.userAgent));
michael@0 3480 self.setStyle(elem,{opacity:_3b0?0.999999:1});
michael@0 3481 if(/MSIE/.test(navigator.userAgent)){
michael@0 3482 self.setStyle(elem,{filter:self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"")});
michael@0 3483 }
michael@0 3484 }else{
michael@0 3485 if(o<0.00001){
michael@0 3486 o=0;
michael@0 3487 }
michael@0 3488 self.setStyle(elem,{opacity:o});
michael@0 3489 if(/MSIE/.test(navigator.userAgent)){
michael@0 3490 self.setStyle(elem,{filter:self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o*100+")"});
michael@0 3491 }
michael@0 3492 }
michael@0 3493 },getElementPosition:function(elem,_3b2){
michael@0 3494 var self=MochiKit.Style;
michael@0 3495 var dom=MochiKit.DOM;
michael@0 3496 elem=dom.getElement(elem);
michael@0 3497 if(!elem||(!(elem.x&&elem.y)&&(!elem.parentNode==null||self.computedStyle(elem,"display")=="none"))){
michael@0 3498 return undefined;
michael@0 3499 }
michael@0 3500 var c=new self.Coordinates(0,0);
michael@0 3501 var box=null;
michael@0 3502 var _3b7=null;
michael@0 3503 var d=MochiKit.DOM._document;
michael@0 3504 var de=d.documentElement;
michael@0 3505 var b=d.body;
michael@0 3506 if(!elem.parentNode&&elem.x&&elem.y){
michael@0 3507 c.x+=elem.x||0;
michael@0 3508 c.y+=elem.y||0;
michael@0 3509 }else{
michael@0 3510 if(elem.getBoundingClientRect){
michael@0 3511 box=elem.getBoundingClientRect();
michael@0 3512 c.x+=box.left+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
michael@0 3513 c.y+=box.top+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
michael@0 3514 }else{
michael@0 3515 if(elem.offsetParent){
michael@0 3516 c.x+=elem.offsetLeft;
michael@0 3517 c.y+=elem.offsetTop;
michael@0 3518 _3b7=elem.offsetParent;
michael@0 3519 if(_3b7!=elem){
michael@0 3520 while(_3b7){
michael@0 3521 c.x+=_3b7.offsetLeft;
michael@0 3522 c.y+=_3b7.offsetTop;
michael@0 3523 _3b7=_3b7.offsetParent;
michael@0 3524 }
michael@0 3525 }
michael@0 3526 var ua=navigator.userAgent.toLowerCase();
michael@0 3527 if((typeof (opera)!="undefined"&&parseFloat(opera.version())<9)||(ua.indexOf("safari")!=-1&&self.computedStyle(elem,"position")=="absolute")){
michael@0 3528 c.x-=b.offsetLeft;
michael@0 3529 c.y-=b.offsetTop;
michael@0 3530 }
michael@0 3531 }
michael@0 3532 }
michael@0 3533 }
michael@0 3534 if(typeof (_3b2)!="undefined"){
michael@0 3535 _3b2=arguments.callee(_3b2);
michael@0 3536 if(_3b2){
michael@0 3537 c.x-=(_3b2.x||0);
michael@0 3538 c.y-=(_3b2.y||0);
michael@0 3539 }
michael@0 3540 }
michael@0 3541 if(elem.parentNode){
michael@0 3542 _3b7=elem.parentNode;
michael@0 3543 }else{
michael@0 3544 _3b7=null;
michael@0 3545 }
michael@0 3546 while(_3b7){
michael@0 3547 var _3bc=_3b7.tagName.toUpperCase();
michael@0 3548 if(_3bc==="BODY"||_3bc==="HTML"){
michael@0 3549 break;
michael@0 3550 }
michael@0 3551 c.x-=_3b7.scrollLeft;
michael@0 3552 c.y-=_3b7.scrollTop;
michael@0 3553 if(_3b7.parentNode){
michael@0 3554 _3b7=_3b7.parentNode;
michael@0 3555 }else{
michael@0 3556 _3b7=null;
michael@0 3557 }
michael@0 3558 }
michael@0 3559 return c;
michael@0 3560 },setElementPosition:function(elem,_3be,_3bf){
michael@0 3561 elem=MochiKit.DOM.getElement(elem);
michael@0 3562 if(typeof (_3bf)=="undefined"){
michael@0 3563 _3bf="px";
michael@0 3564 }
michael@0 3565 var _3c0={};
michael@0 3566 var _3c1=MochiKit.Base.isUndefinedOrNull;
michael@0 3567 if(!_3c1(_3be.x)){
michael@0 3568 _3c0["left"]=_3be.x+_3bf;
michael@0 3569 }
michael@0 3570 if(!_3c1(_3be.y)){
michael@0 3571 _3c0["top"]=_3be.y+_3bf;
michael@0 3572 }
michael@0 3573 MochiKit.DOM.updateNodeAttributes(elem,{"style":_3c0});
michael@0 3574 },getElementDimensions:function(elem){
michael@0 3575 var self=MochiKit.Style;
michael@0 3576 var dom=MochiKit.DOM;
michael@0 3577 if(typeof (elem.w)=="number"||typeof (elem.h)=="number"){
michael@0 3578 return new self.Dimensions(elem.w||0,elem.h||0);
michael@0 3579 }
michael@0 3580 elem=dom.getElement(elem);
michael@0 3581 if(!elem){
michael@0 3582 return undefined;
michael@0 3583 }
michael@0 3584 var disp=self.computedStyle(elem,"display");
michael@0 3585 if(disp!="none"&&disp!=""&&typeof (disp)!="undefined"){
michael@0 3586 return new self.Dimensions(elem.offsetWidth||0,elem.offsetHeight||0);
michael@0 3587 }
michael@0 3588 var s=elem.style;
michael@0 3589 var _3c7=s.visibility;
michael@0 3590 var _3c8=s.position;
michael@0 3591 s.visibility="hidden";
michael@0 3592 s.position="absolute";
michael@0 3593 s.display="";
michael@0 3594 var _3c9=elem.offsetWidth;
michael@0 3595 var _3ca=elem.offsetHeight;
michael@0 3596 s.display="none";
michael@0 3597 s.position=_3c8;
michael@0 3598 s.visibility=_3c7;
michael@0 3599 return new self.Dimensions(_3c9,_3ca);
michael@0 3600 },setElementDimensions:function(elem,_3cc,_3cd){
michael@0 3601 elem=MochiKit.DOM.getElement(elem);
michael@0 3602 if(typeof (_3cd)=="undefined"){
michael@0 3603 _3cd="px";
michael@0 3604 }
michael@0 3605 var _3ce={};
michael@0 3606 var _3cf=MochiKit.Base.isUndefinedOrNull;
michael@0 3607 if(!_3cf(_3cc.w)){
michael@0 3608 _3ce["width"]=_3cc.w+_3cd;
michael@0 3609 }
michael@0 3610 if(!_3cf(_3cc.h)){
michael@0 3611 _3ce["height"]=_3cc.h+_3cd;
michael@0 3612 }
michael@0 3613 MochiKit.DOM.updateNodeAttributes(elem,{"style":_3ce});
michael@0 3614 },setDisplayForElement:function(_3d0,_3d1){
michael@0 3615 var _3d2=MochiKit.Base.extend(null,arguments,1);
michael@0 3616 var _3d3=MochiKit.DOM.getElement;
michael@0 3617 for(var i=0;i<_3d2.length;i++){
michael@0 3618 var _3d1=_3d3(_3d2[i]);
michael@0 3619 if(_3d1){
michael@0 3620 _3d1.style.display=_3d0;
michael@0 3621 }
michael@0 3622 }
michael@0 3623 },getViewportDimensions:function(){
michael@0 3624 var d=new MochiKit.Style.Dimensions();
michael@0 3625 var w=MochiKit.DOM._window;
michael@0 3626 var b=MochiKit.DOM._document.body;
michael@0 3627 if(w.innerWidth){
michael@0 3628 d.w=w.innerWidth;
michael@0 3629 d.h=w.innerHeight;
michael@0 3630 }else{
michael@0 3631 if(b.parentElement.clientWidth){
michael@0 3632 d.w=b.parentElement.clientWidth;
michael@0 3633 d.h=b.parentElement.clientHeight;
michael@0 3634 }else{
michael@0 3635 if(b&&b.clientWidth){
michael@0 3636 d.w=b.clientWidth;
michael@0 3637 d.h=b.clientHeight;
michael@0 3638 }
michael@0 3639 }
michael@0 3640 }
michael@0 3641 return d;
michael@0 3642 },getViewportPosition:function(){
michael@0 3643 var c=new MochiKit.Style.Coordinates(0,0);
michael@0 3644 var d=MochiKit.DOM._document;
michael@0 3645 var de=d.documentElement;
michael@0 3646 var db=d.body;
michael@0 3647 if(de&&(de.scrollTop||de.scrollLeft)){
michael@0 3648 c.x=de.scrollLeft;
michael@0 3649 c.y=de.scrollTop;
michael@0 3650 }else{
michael@0 3651 if(db){
michael@0 3652 c.x=db.scrollLeft;
michael@0 3653 c.y=db.scrollTop;
michael@0 3654 }
michael@0 3655 }
michael@0 3656 return c;
michael@0 3657 },__new__:function(){
michael@0 3658 var m=MochiKit.Base;
michael@0 3659 this.elementPosition=this.getElementPosition;
michael@0 3660 this.elementDimensions=this.getElementDimensions;
michael@0 3661 this.hideElement=m.partial(this.setDisplayForElement,"none");
michael@0 3662 this.showElement=m.partial(this.setDisplayForElement,"block");
michael@0 3663 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 3664 m.nameFunctions(this);
michael@0 3665 }});
michael@0 3666 MochiKit.Style.__new__();
michael@0 3667 MochiKit.Base._exportSymbols(this,MochiKit.Style);
michael@0 3668 if(typeof (dojo)!="undefined"){
michael@0 3669 dojo.provide("MochiKit.LoggingPane");
michael@0 3670 dojo.require("MochiKit.Logging");
michael@0 3671 dojo.require("MochiKit.Base");
michael@0 3672 }
michael@0 3673 if(typeof (JSAN)!="undefined"){
michael@0 3674 JSAN.use("MochiKit.Logging",[]);
michael@0 3675 JSAN.use("MochiKit.Base",[]);
michael@0 3676 }
michael@0 3677 try{
michael@0 3678 if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.Logging)=="undefined"){
michael@0 3679 throw "";
michael@0 3680 }
michael@0 3681 }
michael@0 3682 catch(e){
michael@0 3683 throw "MochiKit.LoggingPane depends on MochiKit.Base and MochiKit.Logging!";
michael@0 3684 }
michael@0 3685 if(typeof (MochiKit.LoggingPane)=="undefined"){
michael@0 3686 MochiKit.LoggingPane={};
michael@0 3687 }
michael@0 3688 MochiKit.LoggingPane.NAME="MochiKit.LoggingPane";
michael@0 3689 MochiKit.LoggingPane.VERSION="1.4";
michael@0 3690 MochiKit.LoggingPane.__repr__=function(){
michael@0 3691 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 3692 };
michael@0 3693 MochiKit.LoggingPane.toString=function(){
michael@0 3694 return this.__repr__();
michael@0 3695 };
michael@0 3696 MochiKit.LoggingPane.createLoggingPane=function(_3dd){
michael@0 3697 var m=MochiKit.LoggingPane;
michael@0 3698 _3dd=!(!_3dd);
michael@0 3699 if(m._loggingPane&&m._loggingPane.inline!=_3dd){
michael@0 3700 m._loggingPane.closePane();
michael@0 3701 m._loggingPane=null;
michael@0 3702 }
michael@0 3703 if(!m._loggingPane||m._loggingPane.closed){
michael@0 3704 m._loggingPane=new m.LoggingPane(_3dd,MochiKit.Logging.logger);
michael@0 3705 }
michael@0 3706 return m._loggingPane;
michael@0 3707 };
michael@0 3708 MochiKit.LoggingPane.LoggingPane=function(_3df,_3e0){
michael@0 3709 if(typeof (_3e0)=="undefined"||_3e0===null){
michael@0 3710 _3e0=MochiKit.Logging.logger;
michael@0 3711 }
michael@0 3712 this.logger=_3e0;
michael@0 3713 var _3e1=MochiKit.Base.update;
michael@0 3714 var _3e2=MochiKit.Base.updatetree;
michael@0 3715 var bind=MochiKit.Base.bind;
michael@0 3716 var _3e4=MochiKit.Base.clone;
michael@0 3717 var win=window;
michael@0 3718 var uid="_MochiKit_LoggingPane";
michael@0 3719 if(typeof (MochiKit.DOM)!="undefined"){
michael@0 3720 win=MochiKit.DOM.currentWindow();
michael@0 3721 }
michael@0 3722 if(!_3df){
michael@0 3723 var url=win.location.href.split("?")[0].replace(/[#:\/.><&-]/g,"_");
michael@0 3724 var name=uid+"_"+url;
michael@0 3725 var nwin=win.open("",name,"dependent,resizable,height=200");
michael@0 3726 if(!nwin){
michael@0 3727 alert("Not able to open debugging window due to pop-up blocking.");
michael@0 3728 return undefined;
michael@0 3729 }
michael@0 3730 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>");
michael@0 3731 nwin.document.close();
michael@0 3732 nwin.document.title+=" "+win.document.title;
michael@0 3733 win=nwin;
michael@0 3734 }
michael@0 3735 var doc=win.document;
michael@0 3736 this.doc=doc;
michael@0 3737 var _3eb=doc.getElementById(uid);
michael@0 3738 var _3ec=!!_3eb;
michael@0 3739 if(_3eb&&typeof (_3eb.loggingPane)!="undefined"){
michael@0 3740 _3eb.loggingPane.logger=this.logger;
michael@0 3741 _3eb.loggingPane.buildAndApplyFilter();
michael@0 3742 return _3eb.loggingPane;
michael@0 3743 }
michael@0 3744 if(_3ec){
michael@0 3745 var _3ed;
michael@0 3746 while((_3ed=_3eb.firstChild)){
michael@0 3747 _3eb.removeChild(_3ed);
michael@0 3748 }
michael@0 3749 }else{
michael@0 3750 _3eb=doc.createElement("div");
michael@0 3751 _3eb.id=uid;
michael@0 3752 }
michael@0 3753 _3eb.loggingPane=this;
michael@0 3754 var _3ee=doc.createElement("input");
michael@0 3755 var _3ef=doc.createElement("input");
michael@0 3756 var _3f0=doc.createElement("button");
michael@0 3757 var _3f1=doc.createElement("button");
michael@0 3758 var _3f2=doc.createElement("button");
michael@0 3759 var _3f3=doc.createElement("button");
michael@0 3760 var _3f4=doc.createElement("div");
michael@0 3761 var _3f5=doc.createElement("div");
michael@0 3762 var _3f6=uid+"_Listener";
michael@0 3763 this.colorTable=_3e4(this.colorTable);
michael@0 3764 var _3f7=[];
michael@0 3765 var _3f8=null;
michael@0 3766 var _3f9=function(msg){
michael@0 3767 var _3fb=msg.level;
michael@0 3768 if(typeof (_3fb)=="number"){
michael@0 3769 _3fb=MochiKit.Logging.LogLevel[_3fb];
michael@0 3770 }
michael@0 3771 return _3fb;
michael@0 3772 };
michael@0 3773 var _3fc=function(msg){
michael@0 3774 return msg.info.join(" ");
michael@0 3775 };
michael@0 3776 var _3fe=bind(function(msg){
michael@0 3777 var _400=_3f9(msg);
michael@0 3778 var text=_3fc(msg);
michael@0 3779 var c=this.colorTable[_400];
michael@0 3780 var p=doc.createElement("span");
michael@0 3781 p.className="MochiKit-LogMessage MochiKit-LogLevel-"+_400;
michael@0 3782 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;
michael@0 3783 p.appendChild(doc.createTextNode(_400+": "+text));
michael@0 3784 _3f5.appendChild(p);
michael@0 3785 _3f5.appendChild(doc.createElement("br"));
michael@0 3786 if(_3f4.offsetHeight>_3f4.scrollHeight){
michael@0 3787 _3f4.scrollTop=0;
michael@0 3788 }else{
michael@0 3789 _3f4.scrollTop=_3f4.scrollHeight;
michael@0 3790 }
michael@0 3791 },this);
michael@0 3792 var _404=function(msg){
michael@0 3793 _3f7[_3f7.length]=msg;
michael@0 3794 _3fe(msg);
michael@0 3795 };
michael@0 3796 var _406=function(){
michael@0 3797 var _407,_408;
michael@0 3798 try{
michael@0 3799 _407=new RegExp(_3ee.value);
michael@0 3800 _408=new RegExp(_3ef.value);
michael@0 3801 }
michael@0 3802 catch(e){
michael@0 3803 logDebug("Error in filter regex: "+e.message);
michael@0 3804 return null;
michael@0 3805 }
michael@0 3806 return function(msg){
michael@0 3807 return (_407.test(_3f9(msg))&&_408.test(_3fc(msg)));
michael@0 3808 };
michael@0 3809 };
michael@0 3810 var _40a=function(){
michael@0 3811 while(_3f5.firstChild){
michael@0 3812 _3f5.removeChild(_3f5.firstChild);
michael@0 3813 }
michael@0 3814 };
michael@0 3815 var _40b=function(){
michael@0 3816 _3f7=[];
michael@0 3817 _40a();
michael@0 3818 };
michael@0 3819 var _40c=bind(function(){
michael@0 3820 if(this.closed){
michael@0 3821 return;
michael@0 3822 }
michael@0 3823 this.closed=true;
michael@0 3824 if(MochiKit.LoggingPane._loggingPane==this){
michael@0 3825 MochiKit.LoggingPane._loggingPane=null;
michael@0 3826 }
michael@0 3827 this.logger.removeListener(_3f6);
michael@0 3828 _3eb.loggingPane=null;
michael@0 3829 if(_3df){
michael@0 3830 _3eb.parentNode.removeChild(_3eb);
michael@0 3831 }else{
michael@0 3832 this.win.close();
michael@0 3833 }
michael@0 3834 },this);
michael@0 3835 var _40d=function(){
michael@0 3836 _40a();
michael@0 3837 for(var i=0;i<_3f7.length;i++){
michael@0 3838 var msg=_3f7[i];
michael@0 3839 if(_3f8===null||_3f8(msg)){
michael@0 3840 _3fe(msg);
michael@0 3841 }
michael@0 3842 }
michael@0 3843 };
michael@0 3844 this.buildAndApplyFilter=function(){
michael@0 3845 _3f8=_406();
michael@0 3846 _40d();
michael@0 3847 this.logger.removeListener(_3f6);
michael@0 3848 this.logger.addListener(_3f6,_3f8,_404);
michael@0 3849 };
michael@0 3850 var _410=bind(function(){
michael@0 3851 _3f7=this.logger.getMessages();
michael@0 3852 _40d();
michael@0 3853 },this);
michael@0 3854 var _411=bind(function(_412){
michael@0 3855 _412=_412||window.event;
michael@0 3856 key=_412.which||_412.keyCode;
michael@0 3857 if(key==13){
michael@0 3858 this.buildAndApplyFilter();
michael@0 3859 }
michael@0 3860 },this);
michael@0 3861 var _413="display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: "+this.logFont;
michael@0 3862 if(_3df){
michael@0 3863 _413+="; height: 10em; border-top: 2px solid black";
michael@0 3864 }else{
michael@0 3865 _413+="; height: 100%;";
michael@0 3866 }
michael@0 3867 _3eb.style.cssText=_413;
michael@0 3868 if(!_3ec){
michael@0 3869 doc.body.appendChild(_3eb);
michael@0 3870 }
michael@0 3871 _413={"cssText":"width: 33%; display: inline; font: "+this.logFont};
michael@0 3872 _3e2(_3ee,{"value":"FATAL|ERROR|WARNING|INFO|DEBUG","onkeypress":_411,"style":_413});
michael@0 3873 _3eb.appendChild(_3ee);
michael@0 3874 _3e2(_3ef,{"value":".*","onkeypress":_411,"style":_413});
michael@0 3875 _3eb.appendChild(_3ef);
michael@0 3876 _413="width: 8%; display:inline; font: "+this.logFont;
michael@0 3877 _3f0.appendChild(doc.createTextNode("Filter"));
michael@0 3878 _3f0.onclick=bind("buildAndApplyFilter",this);
michael@0 3879 _3f0.style.cssText=_413;
michael@0 3880 _3eb.appendChild(_3f0);
michael@0 3881 _3f1.appendChild(doc.createTextNode("Load"));
michael@0 3882 _3f1.onclick=_410;
michael@0 3883 _3f1.style.cssText=_413;
michael@0 3884 _3eb.appendChild(_3f1);
michael@0 3885 _3f2.appendChild(doc.createTextNode("Clear"));
michael@0 3886 _3f2.onclick=_40b;
michael@0 3887 _3f2.style.cssText=_413;
michael@0 3888 _3eb.appendChild(_3f2);
michael@0 3889 _3f3.appendChild(doc.createTextNode("Close"));
michael@0 3890 _3f3.onclick=_40c;
michael@0 3891 _3f3.style.cssText=_413;
michael@0 3892 _3eb.appendChild(_3f3);
michael@0 3893 _3f4.style.cssText="overflow: auto; width: 100%";
michael@0 3894 _3f5.style.cssText="width: 100%; height: "+(_3df?"8em":"100%");
michael@0 3895 _3f4.appendChild(_3f5);
michael@0 3896 _3eb.appendChild(_3f4);
michael@0 3897 this.buildAndApplyFilter();
michael@0 3898 _410();
michael@0 3899 if(_3df){
michael@0 3900 this.win=undefined;
michael@0 3901 }else{
michael@0 3902 this.win=win;
michael@0 3903 }
michael@0 3904 this.inline=_3df;
michael@0 3905 this.closePane=_40c;
michael@0 3906 this.closed=false;
michael@0 3907 return this;
michael@0 3908 };
michael@0 3909 MochiKit.LoggingPane.LoggingPane.prototype={"logFont":"8pt Verdana,sans-serif","colorTable":{"ERROR":"red","FATAL":"darkred","WARNING":"blue","INFO":"black","DEBUG":"green"}};
michael@0 3910 MochiKit.LoggingPane.EXPORT_OK=["LoggingPane"];
michael@0 3911 MochiKit.LoggingPane.EXPORT=["createLoggingPane"];
michael@0 3912 MochiKit.LoggingPane.__new__=function(){
michael@0 3913 this.EXPORT_TAGS={":common":this.EXPORT,":all":MochiKit.Base.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 3914 MochiKit.Base.nameFunctions(this);
michael@0 3915 MochiKit.LoggingPane._loggingPane=null;
michael@0 3916 };
michael@0 3917 MochiKit.LoggingPane.__new__();
michael@0 3918 MochiKit.Base._exportSymbols(this,MochiKit.LoggingPane);
michael@0 3919 if(typeof (dojo)!="undefined"){
michael@0 3920 dojo.provide("MochiKit.Color");
michael@0 3921 dojo.require("MochiKit.Base");
michael@0 3922 dojo.require("MochiKit.DOM");
michael@0 3923 dojo.require("MochiKit.Style");
michael@0 3924 }
michael@0 3925 if(typeof (JSAN)!="undefined"){
michael@0 3926 JSAN.use("MochiKit.Base",[]);
michael@0 3927 JSAN.use("MochiKit.DOM",[]);
michael@0 3928 JSAN.use("MochiKit.Style",[]);
michael@0 3929 }
michael@0 3930 try{
michael@0 3931 if(typeof (MochiKit.Base)=="undefined"){
michael@0 3932 throw "";
michael@0 3933 }
michael@0 3934 }
michael@0 3935 catch(e){
michael@0 3936 throw "MochiKit.Color depends on MochiKit.Base";
michael@0 3937 }
michael@0 3938 try{
michael@0 3939 if(typeof (MochiKit.Base)=="undefined"){
michael@0 3940 throw "";
michael@0 3941 }
michael@0 3942 }
michael@0 3943 catch(e){
michael@0 3944 throw "MochiKit.Color depends on MochiKit.DOM";
michael@0 3945 }
michael@0 3946 try{
michael@0 3947 if(typeof (MochiKit.Base)=="undefined"){
michael@0 3948 throw "";
michael@0 3949 }
michael@0 3950 }
michael@0 3951 catch(e){
michael@0 3952 throw "MochiKit.Color depends on MochiKit.Style";
michael@0 3953 }
michael@0 3954 if(typeof (MochiKit.Color)=="undefined"){
michael@0 3955 MochiKit.Color={};
michael@0 3956 }
michael@0 3957 MochiKit.Color.NAME="MochiKit.Color";
michael@0 3958 MochiKit.Color.VERSION="1.4";
michael@0 3959 MochiKit.Color.__repr__=function(){
michael@0 3960 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 3961 };
michael@0 3962 MochiKit.Color.toString=function(){
michael@0 3963 return this.__repr__();
michael@0 3964 };
michael@0 3965 MochiKit.Color.Color=function(red,_415,blue,_417){
michael@0 3966 if(typeof (_417)=="undefined"||_417===null){
michael@0 3967 _417=1;
michael@0 3968 }
michael@0 3969 this.rgb={r:red,g:_415,b:blue,a:_417};
michael@0 3970 };
michael@0 3971 MochiKit.Color.Color.prototype={__class__:MochiKit.Color.Color,colorWithAlpha:function(_418){
michael@0 3972 var rgb=this.rgb;
michael@0 3973 var m=MochiKit.Color;
michael@0 3974 return m.Color.fromRGB(rgb.r,rgb.g,rgb.b,_418);
michael@0 3975 },colorWithHue:function(hue){
michael@0 3976 var hsl=this.asHSL();
michael@0 3977 hsl.h=hue;
michael@0 3978 var m=MochiKit.Color;
michael@0 3979 return m.Color.fromHSL(hsl);
michael@0 3980 },colorWithSaturation:function(_41e){
michael@0 3981 var hsl=this.asHSL();
michael@0 3982 hsl.s=_41e;
michael@0 3983 var m=MochiKit.Color;
michael@0 3984 return m.Color.fromHSL(hsl);
michael@0 3985 },colorWithLightness:function(_421){
michael@0 3986 var hsl=this.asHSL();
michael@0 3987 hsl.l=_421;
michael@0 3988 var m=MochiKit.Color;
michael@0 3989 return m.Color.fromHSL(hsl);
michael@0 3990 },darkerColorWithLevel:function(_424){
michael@0 3991 var hsl=this.asHSL();
michael@0 3992 hsl.l=Math.max(hsl.l-_424,0);
michael@0 3993 var m=MochiKit.Color;
michael@0 3994 return m.Color.fromHSL(hsl);
michael@0 3995 },lighterColorWithLevel:function(_427){
michael@0 3996 var hsl=this.asHSL();
michael@0 3997 hsl.l=Math.min(hsl.l+_427,1);
michael@0 3998 var m=MochiKit.Color;
michael@0 3999 return m.Color.fromHSL(hsl);
michael@0 4000 },blendedColor:function(_42a,_42b){
michael@0 4001 if(typeof (_42b)=="undefined"||_42b===null){
michael@0 4002 _42b=0.5;
michael@0 4003 }
michael@0 4004 var sf=1-_42b;
michael@0 4005 var s=this.rgb;
michael@0 4006 var d=_42a.rgb;
michael@0 4007 var df=_42b;
michael@0 4008 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));
michael@0 4009 },compareRGB:function(_430){
michael@0 4010 var a=this.asRGB();
michael@0 4011 var b=_430.asRGB();
michael@0 4012 return MochiKit.Base.compare([a.r,a.g,a.b,a.a],[b.r,b.g,b.b,b.a]);
michael@0 4013 },isLight:function(){
michael@0 4014 return this.asHSL().b>0.5;
michael@0 4015 },isDark:function(){
michael@0 4016 return (!this.isLight());
michael@0 4017 },toHSLString:function(){
michael@0 4018 var c=this.asHSL();
michael@0 4019 var ccc=MochiKit.Color.clampColorComponent;
michael@0 4020 var rval=this._hslString;
michael@0 4021 if(!rval){
michael@0 4022 var mid=(ccc(c.h,360).toFixed(0)+","+ccc(c.s,100).toPrecision(4)+"%"+","+ccc(c.l,100).toPrecision(4)+"%");
michael@0 4023 var a=c.a;
michael@0 4024 if(a>=1){
michael@0 4025 a=1;
michael@0 4026 rval="hsl("+mid+")";
michael@0 4027 }else{
michael@0 4028 if(a<=0){
michael@0 4029 a=0;
michael@0 4030 }
michael@0 4031 rval="hsla("+mid+","+a+")";
michael@0 4032 }
michael@0 4033 this._hslString=rval;
michael@0 4034 }
michael@0 4035 return rval;
michael@0 4036 },toRGBString:function(){
michael@0 4037 var c=this.rgb;
michael@0 4038 var ccc=MochiKit.Color.clampColorComponent;
michael@0 4039 var rval=this._rgbString;
michael@0 4040 if(!rval){
michael@0 4041 var mid=(ccc(c.r,255).toFixed(0)+","+ccc(c.g,255).toFixed(0)+","+ccc(c.b,255).toFixed(0));
michael@0 4042 if(c.a!=1){
michael@0 4043 rval="rgba("+mid+","+c.a+")";
michael@0 4044 }else{
michael@0 4045 rval="rgb("+mid+")";
michael@0 4046 }
michael@0 4047 this._rgbString=rval;
michael@0 4048 }
michael@0 4049 return rval;
michael@0 4050 },asRGB:function(){
michael@0 4051 return MochiKit.Base.clone(this.rgb);
michael@0 4052 },toHexString:function(){
michael@0 4053 var m=MochiKit.Color;
michael@0 4054 var c=this.rgb;
michael@0 4055 var ccc=MochiKit.Color.clampColorComponent;
michael@0 4056 var rval=this._hexString;
michael@0 4057 if(!rval){
michael@0 4058 rval=("#"+m.toColorPart(ccc(c.r,255))+m.toColorPart(ccc(c.g,255))+m.toColorPart(ccc(c.b,255)));
michael@0 4059 this._hexString=rval;
michael@0 4060 }
michael@0 4061 return rval;
michael@0 4062 },asHSV:function(){
michael@0 4063 var hsv=this.hsv;
michael@0 4064 var c=this.rgb;
michael@0 4065 if(typeof (hsv)=="undefined"||hsv===null){
michael@0 4066 hsv=MochiKit.Color.rgbToHSV(this.rgb);
michael@0 4067 this.hsv=hsv;
michael@0 4068 }
michael@0 4069 return MochiKit.Base.clone(hsv);
michael@0 4070 },asHSL:function(){
michael@0 4071 var hsl=this.hsl;
michael@0 4072 var c=this.rgb;
michael@0 4073 if(typeof (hsl)=="undefined"||hsl===null){
michael@0 4074 hsl=MochiKit.Color.rgbToHSL(this.rgb);
michael@0 4075 this.hsl=hsl;
michael@0 4076 }
michael@0 4077 return MochiKit.Base.clone(hsl);
michael@0 4078 },toString:function(){
michael@0 4079 return this.toRGBString();
michael@0 4080 },repr:function(){
michael@0 4081 var c=this.rgb;
michael@0 4082 var col=[c.r,c.g,c.b,c.a];
michael@0 4083 return this.__class__.NAME+"("+col.join(", ")+")";
michael@0 4084 }};
michael@0 4085 MochiKit.Base.update(MochiKit.Color.Color,{fromRGB:function(red,_447,blue,_449){
michael@0 4086 var _44a=MochiKit.Color.Color;
michael@0 4087 if(arguments.length==1){
michael@0 4088 var rgb=red;
michael@0 4089 red=rgb.r;
michael@0 4090 _447=rgb.g;
michael@0 4091 blue=rgb.b;
michael@0 4092 if(typeof (rgb.a)=="undefined"){
michael@0 4093 _449=undefined;
michael@0 4094 }else{
michael@0 4095 _449=rgb.a;
michael@0 4096 }
michael@0 4097 }
michael@0 4098 return new _44a(red,_447,blue,_449);
michael@0 4099 },fromHSL:function(hue,_44d,_44e,_44f){
michael@0 4100 var m=MochiKit.Color;
michael@0 4101 return m.Color.fromRGB(m.hslToRGB.apply(m,arguments));
michael@0 4102 },fromHSV:function(hue,_452,_453,_454){
michael@0 4103 var m=MochiKit.Color;
michael@0 4104 return m.Color.fromRGB(m.hsvToRGB.apply(m,arguments));
michael@0 4105 },fromName:function(name){
michael@0 4106 var _457=MochiKit.Color.Color;
michael@0 4107 if(name.charAt(0)=="\""){
michael@0 4108 name=name.substr(1,name.length-2);
michael@0 4109 }
michael@0 4110 var _458=_457._namedColors[name.toLowerCase()];
michael@0 4111 if(typeof (_458)=="string"){
michael@0 4112 return _457.fromHexString(_458);
michael@0 4113 }else{
michael@0 4114 if(name=="transparent"){
michael@0 4115 return _457.transparentColor();
michael@0 4116 }
michael@0 4117 }
michael@0 4118 return null;
michael@0 4119 },fromString:function(_459){
michael@0 4120 var self=MochiKit.Color.Color;
michael@0 4121 var _45b=_459.substr(0,3);
michael@0 4122 if(_45b=="rgb"){
michael@0 4123 return self.fromRGBString(_459);
michael@0 4124 }else{
michael@0 4125 if(_45b=="hsl"){
michael@0 4126 return self.fromHSLString(_459);
michael@0 4127 }else{
michael@0 4128 if(_459.charAt(0)=="#"){
michael@0 4129 return self.fromHexString(_459);
michael@0 4130 }
michael@0 4131 }
michael@0 4132 }
michael@0 4133 return self.fromName(_459);
michael@0 4134 },fromHexString:function(_45c){
michael@0 4135 if(_45c.charAt(0)=="#"){
michael@0 4136 _45c=_45c.substring(1);
michael@0 4137 }
michael@0 4138 var _45d=[];
michael@0 4139 var i,hex;
michael@0 4140 if(_45c.length==3){
michael@0 4141 for(i=0;i<3;i++){
michael@0 4142 hex=_45c.substr(i,1);
michael@0 4143 _45d.push(parseInt(hex+hex,16)/255);
michael@0 4144 }
michael@0 4145 }else{
michael@0 4146 for(i=0;i<6;i+=2){
michael@0 4147 hex=_45c.substr(i,2);
michael@0 4148 _45d.push(parseInt(hex,16)/255);
michael@0 4149 }
michael@0 4150 }
michael@0 4151 var _460=MochiKit.Color.Color;
michael@0 4152 return _460.fromRGB.apply(_460,_45d);
michael@0 4153 },_fromColorString:function(pre,_462,_463,_464){
michael@0 4154 if(_464.indexOf(pre)===0){
michael@0 4155 _464=_464.substring(_464.indexOf("(",3)+1,_464.length-1);
michael@0 4156 }
michael@0 4157 var _465=_464.split(/\s*,\s*/);
michael@0 4158 var _466=[];
michael@0 4159 for(var i=0;i<_465.length;i++){
michael@0 4160 var c=_465[i];
michael@0 4161 var val;
michael@0 4162 var _46a=c.substring(c.length-3);
michael@0 4163 if(c.charAt(c.length-1)=="%"){
michael@0 4164 val=0.01*parseFloat(c.substring(0,c.length-1));
michael@0 4165 }else{
michael@0 4166 if(_46a=="deg"){
michael@0 4167 val=parseFloat(c)/360;
michael@0 4168 }else{
michael@0 4169 if(_46a=="rad"){
michael@0 4170 val=parseFloat(c)/(Math.PI*2);
michael@0 4171 }else{
michael@0 4172 val=_463[i]*parseFloat(c);
michael@0 4173 }
michael@0 4174 }
michael@0 4175 }
michael@0 4176 _466.push(val);
michael@0 4177 }
michael@0 4178 return this[_462].apply(this,_466);
michael@0 4179 },fromComputedStyle:function(elem,_46c){
michael@0 4180 var d=MochiKit.DOM;
michael@0 4181 var cls=MochiKit.Color.Color;
michael@0 4182 for(elem=d.getElement(elem);elem;elem=elem.parentNode){
michael@0 4183 var _46f=MochiKit.Style.computedStyle.apply(d,arguments);
michael@0 4184 if(!_46f){
michael@0 4185 continue;
michael@0 4186 }
michael@0 4187 var _470=cls.fromString(_46f);
michael@0 4188 if(!_470){
michael@0 4189 break;
michael@0 4190 }
michael@0 4191 if(_470.asRGB().a>0){
michael@0 4192 return _470;
michael@0 4193 }
michael@0 4194 }
michael@0 4195 return null;
michael@0 4196 },fromBackground:function(elem){
michael@0 4197 var cls=MochiKit.Color.Color;
michael@0 4198 return cls.fromComputedStyle(elem,"backgroundColor","background-color")||cls.whiteColor();
michael@0 4199 },fromText:function(elem){
michael@0 4200 var cls=MochiKit.Color.Color;
michael@0 4201 return cls.fromComputedStyle(elem,"color","color")||cls.blackColor();
michael@0 4202 },namedColors:function(){
michael@0 4203 return MochiKit.Base.clone(MochiKit.Color.Color._namedColors);
michael@0 4204 }});
michael@0 4205 MochiKit.Base.update(MochiKit.Color,{clampColorComponent:function(v,_476){
michael@0 4206 v*=_476;
michael@0 4207 if(v<0){
michael@0 4208 return 0;
michael@0 4209 }else{
michael@0 4210 if(v>_476){
michael@0 4211 return _476;
michael@0 4212 }else{
michael@0 4213 return v;
michael@0 4214 }
michael@0 4215 }
michael@0 4216 },_hslValue:function(n1,n2,hue){
michael@0 4217 if(hue>6){
michael@0 4218 hue-=6;
michael@0 4219 }else{
michael@0 4220 if(hue<0){
michael@0 4221 hue+=6;
michael@0 4222 }
michael@0 4223 }
michael@0 4224 var val;
michael@0 4225 if(hue<1){
michael@0 4226 val=n1+(n2-n1)*hue;
michael@0 4227 }else{
michael@0 4228 if(hue<3){
michael@0 4229 val=n2;
michael@0 4230 }else{
michael@0 4231 if(hue<4){
michael@0 4232 val=n1+(n2-n1)*(4-hue);
michael@0 4233 }else{
michael@0 4234 val=n1;
michael@0 4235 }
michael@0 4236 }
michael@0 4237 }
michael@0 4238 return val;
michael@0 4239 },hsvToRGB:function(hue,_47c,_47d,_47e){
michael@0 4240 if(arguments.length==1){
michael@0 4241 var hsv=hue;
michael@0 4242 hue=hsv.h;
michael@0 4243 _47c=hsv.s;
michael@0 4244 _47d=hsv.v;
michael@0 4245 _47e=hsv.a;
michael@0 4246 }
michael@0 4247 var red;
michael@0 4248 var _481;
michael@0 4249 var blue;
michael@0 4250 if(_47c===0){
michael@0 4251 red=0;
michael@0 4252 _481=0;
michael@0 4253 blue=0;
michael@0 4254 }else{
michael@0 4255 var i=Math.floor(hue*6);
michael@0 4256 var f=(hue*6)-i;
michael@0 4257 var p=_47d*(1-_47c);
michael@0 4258 var q=_47d*(1-(_47c*f));
michael@0 4259 var t=_47d*(1-(_47c*(1-f)));
michael@0 4260 switch(i){
michael@0 4261 case 1:
michael@0 4262 red=q;
michael@0 4263 _481=_47d;
michael@0 4264 blue=p;
michael@0 4265 break;
michael@0 4266 case 2:
michael@0 4267 red=p;
michael@0 4268 _481=_47d;
michael@0 4269 blue=t;
michael@0 4270 break;
michael@0 4271 case 3:
michael@0 4272 red=p;
michael@0 4273 _481=q;
michael@0 4274 blue=_47d;
michael@0 4275 break;
michael@0 4276 case 4:
michael@0 4277 red=t;
michael@0 4278 _481=p;
michael@0 4279 blue=_47d;
michael@0 4280 break;
michael@0 4281 case 5:
michael@0 4282 red=_47d;
michael@0 4283 _481=p;
michael@0 4284 blue=q;
michael@0 4285 break;
michael@0 4286 case 6:
michael@0 4287 case 0:
michael@0 4288 red=_47d;
michael@0 4289 _481=t;
michael@0 4290 blue=p;
michael@0 4291 break;
michael@0 4292 }
michael@0 4293 }
michael@0 4294 return {r:red,g:_481,b:blue,a:_47e};
michael@0 4295 },hslToRGB:function(hue,_489,_48a,_48b){
michael@0 4296 if(arguments.length==1){
michael@0 4297 var hsl=hue;
michael@0 4298 hue=hsl.h;
michael@0 4299 _489=hsl.s;
michael@0 4300 _48a=hsl.l;
michael@0 4301 _48b=hsl.a;
michael@0 4302 }
michael@0 4303 var red;
michael@0 4304 var _48e;
michael@0 4305 var blue;
michael@0 4306 if(_489===0){
michael@0 4307 red=_48a;
michael@0 4308 _48e=_48a;
michael@0 4309 blue=_48a;
michael@0 4310 }else{
michael@0 4311 var m2;
michael@0 4312 if(_48a<=0.5){
michael@0 4313 m2=_48a*(1+_489);
michael@0 4314 }else{
michael@0 4315 m2=_48a+_489-(_48a*_489);
michael@0 4316 }
michael@0 4317 var m1=(2*_48a)-m2;
michael@0 4318 var f=MochiKit.Color._hslValue;
michael@0 4319 var h6=hue*6;
michael@0 4320 red=f(m1,m2,h6+2);
michael@0 4321 _48e=f(m1,m2,h6);
michael@0 4322 blue=f(m1,m2,h6-2);
michael@0 4323 }
michael@0 4324 return {r:red,g:_48e,b:blue,a:_48b};
michael@0 4325 },rgbToHSV:function(red,_495,blue,_497){
michael@0 4326 if(arguments.length==1){
michael@0 4327 var rgb=red;
michael@0 4328 red=rgb.r;
michael@0 4329 _495=rgb.g;
michael@0 4330 blue=rgb.b;
michael@0 4331 _497=rgb.a;
michael@0 4332 }
michael@0 4333 var max=Math.max(Math.max(red,_495),blue);
michael@0 4334 var min=Math.min(Math.min(red,_495),blue);
michael@0 4335 var hue;
michael@0 4336 var _49c;
michael@0 4337 var _49d=max;
michael@0 4338 if(min==max){
michael@0 4339 hue=0;
michael@0 4340 _49c=0;
michael@0 4341 }else{
michael@0 4342 var _49e=(max-min);
michael@0 4343 _49c=_49e/max;
michael@0 4344 if(red==max){
michael@0 4345 hue=(_495-blue)/_49e;
michael@0 4346 }else{
michael@0 4347 if(_495==max){
michael@0 4348 hue=2+((blue-red)/_49e);
michael@0 4349 }else{
michael@0 4350 hue=4+((red-_495)/_49e);
michael@0 4351 }
michael@0 4352 }
michael@0 4353 hue/=6;
michael@0 4354 if(hue<0){
michael@0 4355 hue+=1;
michael@0 4356 }
michael@0 4357 if(hue>1){
michael@0 4358 hue-=1;
michael@0 4359 }
michael@0 4360 }
michael@0 4361 return {h:hue,s:_49c,v:_49d,a:_497};
michael@0 4362 },rgbToHSL:function(red,_4a0,blue,_4a2){
michael@0 4363 if(arguments.length==1){
michael@0 4364 var rgb=red;
michael@0 4365 red=rgb.r;
michael@0 4366 _4a0=rgb.g;
michael@0 4367 blue=rgb.b;
michael@0 4368 _4a2=rgb.a;
michael@0 4369 }
michael@0 4370 var max=Math.max(red,Math.max(_4a0,blue));
michael@0 4371 var min=Math.min(red,Math.min(_4a0,blue));
michael@0 4372 var hue;
michael@0 4373 var _4a7;
michael@0 4374 var _4a8=(max+min)/2;
michael@0 4375 var _4a9=max-min;
michael@0 4376 if(_4a9===0){
michael@0 4377 hue=0;
michael@0 4378 _4a7=0;
michael@0 4379 }else{
michael@0 4380 if(_4a8<=0.5){
michael@0 4381 _4a7=_4a9/(max+min);
michael@0 4382 }else{
michael@0 4383 _4a7=_4a9/(2-max-min);
michael@0 4384 }
michael@0 4385 if(red==max){
michael@0 4386 hue=(_4a0-blue)/_4a9;
michael@0 4387 }else{
michael@0 4388 if(_4a0==max){
michael@0 4389 hue=2+((blue-red)/_4a9);
michael@0 4390 }else{
michael@0 4391 hue=4+((red-_4a0)/_4a9);
michael@0 4392 }
michael@0 4393 }
michael@0 4394 hue/=6;
michael@0 4395 if(hue<0){
michael@0 4396 hue+=1;
michael@0 4397 }
michael@0 4398 if(hue>1){
michael@0 4399 hue-=1;
michael@0 4400 }
michael@0 4401 }
michael@0 4402 return {h:hue,s:_4a7,l:_4a8,a:_4a2};
michael@0 4403 },toColorPart:function(num){
michael@0 4404 num=Math.round(num);
michael@0 4405 var _4ab=num.toString(16);
michael@0 4406 if(num<16){
michael@0 4407 return "0"+_4ab;
michael@0 4408 }
michael@0 4409 return _4ab;
michael@0 4410 },__new__:function(){
michael@0 4411 var m=MochiKit.Base;
michael@0 4412 this.Color.fromRGBString=m.bind(this.Color._fromColorString,this.Color,"rgb","fromRGB",[1/255,1/255,1/255,1]);
michael@0 4413 this.Color.fromHSLString=m.bind(this.Color._fromColorString,this.Color,"hsl","fromHSL",[1/360,0.01,0.01,1]);
michael@0 4414 var _4ad=1/3;
michael@0 4415 var _4ae={black:[0,0,0],blue:[0,0,1],brown:[0.6,0.4,0.2],cyan:[0,1,1],darkGray:[_4ad,_4ad,_4ad],gray:[0.5,0.5,0.5],green:[0,1,0],lightGray:[2*_4ad,2*_4ad,2*_4ad],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]};
michael@0 4416 var _4af=function(name,r,g,b,a){
michael@0 4417 var rval=this.fromRGB(r,g,b,a);
michael@0 4418 this[name]=function(){
michael@0 4419 return rval;
michael@0 4420 };
michael@0 4421 return rval;
michael@0 4422 };
michael@0 4423 for(var k in _4ae){
michael@0 4424 var name=k+"Color";
michael@0 4425 var _4b8=m.concat([_4af,this.Color,name],_4ae[k]);
michael@0 4426 this.Color[name]=m.bind.apply(null,_4b8);
michael@0 4427 }
michael@0 4428 var _4b9=function(){
michael@0 4429 for(var i=0;i<arguments.length;i++){
michael@0 4430 if(!(arguments[i] instanceof Color)){
michael@0 4431 return false;
michael@0 4432 }
michael@0 4433 }
michael@0 4434 return true;
michael@0 4435 };
michael@0 4436 var _4bb=function(a,b){
michael@0 4437 return a.compareRGB(b);
michael@0 4438 };
michael@0 4439 m.nameFunctions(this);
michael@0 4440 m.registerComparator(this.Color.NAME,_4b9,_4bb);
michael@0 4441 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 4442 }});
michael@0 4443 MochiKit.Color.EXPORT=["Color"];
michael@0 4444 MochiKit.Color.EXPORT_OK=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
michael@0 4445 MochiKit.Color.__new__();
michael@0 4446 MochiKit.Base._exportSymbols(this,MochiKit.Color);
michael@0 4447 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"};
michael@0 4448 if(typeof (dojo)!="undefined"){
michael@0 4449 dojo.provide("MochiKit.Signal");
michael@0 4450 dojo.require("MochiKit.Base");
michael@0 4451 dojo.require("MochiKit.DOM");
michael@0 4452 dojo.require("MochiKit.Style");
michael@0 4453 }
michael@0 4454 if(typeof (JSAN)!="undefined"){
michael@0 4455 JSAN.use("MochiKit.Base",[]);
michael@0 4456 JSAN.use("MochiKit.DOM",[]);
michael@0 4457 JSAN.use("MochiKit.Style",[]);
michael@0 4458 }
michael@0 4459 try{
michael@0 4460 if(typeof (MochiKit.Base)=="undefined"){
michael@0 4461 throw "";
michael@0 4462 }
michael@0 4463 }
michael@0 4464 catch(e){
michael@0 4465 throw "MochiKit.Signal depends on MochiKit.Base!";
michael@0 4466 }
michael@0 4467 try{
michael@0 4468 if(typeof (MochiKit.DOM)=="undefined"){
michael@0 4469 throw "";
michael@0 4470 }
michael@0 4471 }
michael@0 4472 catch(e){
michael@0 4473 throw "MochiKit.Signal depends on MochiKit.DOM!";
michael@0 4474 }
michael@0 4475 try{
michael@0 4476 if(typeof (MochiKit.Style)=="undefined"){
michael@0 4477 throw "";
michael@0 4478 }
michael@0 4479 }
michael@0 4480 catch(e){
michael@0 4481 throw "MochiKit.Signal depends on MochiKit.Style!";
michael@0 4482 }
michael@0 4483 if(typeof (MochiKit.Signal)=="undefined"){
michael@0 4484 MochiKit.Signal={};
michael@0 4485 }
michael@0 4486 MochiKit.Signal.NAME="MochiKit.Signal";
michael@0 4487 MochiKit.Signal.VERSION="1.4";
michael@0 4488 MochiKit.Signal._observers=[];
michael@0 4489 MochiKit.Signal.Event=function(src,e){
michael@0 4490 this._event=e||window.event;
michael@0 4491 this._src=src;
michael@0 4492 };
michael@0 4493 MochiKit.Base.update(MochiKit.Signal.Event.prototype,{__repr__:function(){
michael@0 4494 var repr=MochiKit.Base.repr;
michael@0 4495 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)+"}";
michael@0 4496 if(this.type()&&this.type().indexOf("key")===0){
michael@0 4497 str+=", key(): {code: "+repr(this.key().code)+", string: "+repr(this.key().string)+"}";
michael@0 4498 }
michael@0 4499 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
michael@0 4500 str+=", mouse(): {page: "+repr(this.mouse().page)+", client: "+repr(this.mouse().client);
michael@0 4501 if(this.type()!="mousemove"){
michael@0 4502 str+=", button: {left: "+repr(this.mouse().button.left)+", middle: "+repr(this.mouse().button.middle)+", right: "+repr(this.mouse().button.right)+"}}";
michael@0 4503 }else{
michael@0 4504 str+="}";
michael@0 4505 }
michael@0 4506 }
michael@0 4507 if(this.type()=="mouseover"||this.type()=="mouseout"){
michael@0 4508 str+=", relatedTarget(): "+repr(this.relatedTarget());
michael@0 4509 }
michael@0 4510 str+="}";
michael@0 4511 return str;
michael@0 4512 },toString:function(){
michael@0 4513 return this.__repr__();
michael@0 4514 },src:function(){
michael@0 4515 return this._src;
michael@0 4516 },event:function(){
michael@0 4517 return this._event;
michael@0 4518 },type:function(){
michael@0 4519 return this._event.type||undefined;
michael@0 4520 },target:function(){
michael@0 4521 return this._event.target||this._event.srcElement;
michael@0 4522 },_relatedTarget:null,relatedTarget:function(){
michael@0 4523 if(this._relatedTarget!==null){
michael@0 4524 return this._relatedTarget;
michael@0 4525 }
michael@0 4526 var elem=null;
michael@0 4527 if(this.type()=="mouseover"){
michael@0 4528 elem=(this._event.relatedTarget||this._event.fromElement);
michael@0 4529 }else{
michael@0 4530 if(this.type()=="mouseout"){
michael@0 4531 elem=(this._event.relatedTarget||this._event.toElement);
michael@0 4532 }
michael@0 4533 }
michael@0 4534 if(elem!==null){
michael@0 4535 this._relatedTarget=elem;
michael@0 4536 return elem;
michael@0 4537 }
michael@0 4538 return undefined;
michael@0 4539 },_modifier:null,modifier:function(){
michael@0 4540 if(this._modifier!==null){
michael@0 4541 return this._modifier;
michael@0 4542 }
michael@0 4543 var m={};
michael@0 4544 m.alt=this._event.altKey;
michael@0 4545 m.ctrl=this._event.ctrlKey;
michael@0 4546 m.meta=this._event.metaKey||false;
michael@0 4547 m.shift=this._event.shiftKey;
michael@0 4548 m.any=m.alt||m.ctrl||m.shift||m.meta;
michael@0 4549 this._modifier=m;
michael@0 4550 return m;
michael@0 4551 },_key:null,key:function(){
michael@0 4552 if(this._key!==null){
michael@0 4553 return this._key;
michael@0 4554 }
michael@0 4555 var k={};
michael@0 4556 if(this.type()&&this.type().indexOf("key")===0){
michael@0 4557 if(this.type()=="keydown"||this.type()=="keyup"){
michael@0 4558 k.code=this._event.keyCode;
michael@0 4559 k.string=(MochiKit.Signal._specialKeys[k.code]||"KEY_UNKNOWN");
michael@0 4560 this._key=k;
michael@0 4561 return k;
michael@0 4562 }else{
michael@0 4563 if(this.type()=="keypress"){
michael@0 4564 k.code=0;
michael@0 4565 k.string="";
michael@0 4566 if(typeof (this._event.charCode)!="undefined"&&this._event.charCode!==0&&!MochiKit.Signal._specialMacKeys[this._event.charCode]){
michael@0 4567 k.code=this._event.charCode;
michael@0 4568 k.string=String.fromCharCode(k.code);
michael@0 4569 }else{
michael@0 4570 if(this._event.keyCode&&typeof (this._event.charCode)=="undefined"){
michael@0 4571 k.code=this._event.keyCode;
michael@0 4572 k.string=String.fromCharCode(k.code);
michael@0 4573 }
michael@0 4574 }
michael@0 4575 this._key=k;
michael@0 4576 return k;
michael@0 4577 }
michael@0 4578 }
michael@0 4579 }
michael@0 4580 return undefined;
michael@0 4581 },_mouse:null,mouse:function(){
michael@0 4582 if(this._mouse!==null){
michael@0 4583 return this._mouse;
michael@0 4584 }
michael@0 4585 var m={};
michael@0 4586 var e=this._event;
michael@0 4587 if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
michael@0 4588 m.client=new MochiKit.Style.Coordinates(0,0);
michael@0 4589 if(e.clientX||e.clientY){
michael@0 4590 m.client.x=(!e.clientX||e.clientX<0)?0:e.clientX;
michael@0 4591 m.client.y=(!e.clientY||e.clientY<0)?0:e.clientY;
michael@0 4592 }
michael@0 4593 m.page=new MochiKit.Style.Coordinates(0,0);
michael@0 4594 if(e.pageX||e.pageY){
michael@0 4595 m.page.x=(!e.pageX||e.pageX<0)?0:e.pageX;
michael@0 4596 m.page.y=(!e.pageY||e.pageY<0)?0:e.pageY;
michael@0 4597 }else{
michael@0 4598 var de=MochiKit.DOM._document.documentElement;
michael@0 4599 var b=MochiKit.DOM._document.body;
michael@0 4600 m.page.x=e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
michael@0 4601 m.page.y=e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
michael@0 4602 }
michael@0 4603 if(this.type()!="mousemove"){
michael@0 4604 m.button={};
michael@0 4605 m.button.left=false;
michael@0 4606 m.button.right=false;
michael@0 4607 m.button.middle=false;
michael@0 4608 if(e.which){
michael@0 4609 m.button.left=(e.which==1);
michael@0 4610 m.button.middle=(e.which==2);
michael@0 4611 m.button.right=(e.which==3);
michael@0 4612 }else{
michael@0 4613 m.button.left=!!(e.button&1);
michael@0 4614 m.button.right=!!(e.button&2);
michael@0 4615 m.button.middle=!!(e.button&4);
michael@0 4616 }
michael@0 4617 }
michael@0 4618 this._mouse=m;
michael@0 4619 return m;
michael@0 4620 }
michael@0 4621 return undefined;
michael@0 4622 },stop:function(){
michael@0 4623 this.stopPropagation();
michael@0 4624 this.preventDefault();
michael@0 4625 },stopPropagation:function(){
michael@0 4626 if(this._event.stopPropagation){
michael@0 4627 this._event.stopPropagation();
michael@0 4628 }else{
michael@0 4629 this._event.cancelBubble=true;
michael@0 4630 }
michael@0 4631 },preventDefault:function(){
michael@0 4632 if(this._event.preventDefault){
michael@0 4633 this._event.preventDefault();
michael@0 4634 }else{
michael@0 4635 if(this._confirmUnload===null){
michael@0 4636 this._event.returnValue=false;
michael@0 4637 }
michael@0 4638 }
michael@0 4639 },_confirmUnload:null,confirmUnload:function(msg){
michael@0 4640 if(this.type()=="beforeunload"){
michael@0 4641 this._confirmUnload=msg;
michael@0 4642 this._event.returnValue=msg;
michael@0 4643 }
michael@0 4644 }});
michael@0 4645 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"};
michael@0 4646 (function(){
michael@0 4647 var _4ca=MochiKit.Signal._specialMacKeys;
michael@0 4648 for(i=63236;i<=63242;i++){
michael@0 4649 _4ca[i]="KEY_F"+(i-63236+1);
michael@0 4650 }
michael@0 4651 })();
michael@0 4652 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"};
michael@0 4653 (function(){
michael@0 4654 var _4cb=MochiKit.Signal._specialKeys;
michael@0 4655 for(var i=48;i<=57;i++){
michael@0 4656 _4cb[i]="KEY_"+(i-48);
michael@0 4657 }
michael@0 4658 for(i=65;i<=90;i++){
michael@0 4659 _4cb[i]="KEY_"+String.fromCharCode(i);
michael@0 4660 }
michael@0 4661 for(i=96;i<=105;i++){
michael@0 4662 _4cb[i]="KEY_NUM_PAD_"+(i-96);
michael@0 4663 }
michael@0 4664 for(i=112;i<=123;i++){
michael@0 4665 _4cb[i]="KEY_F"+(i-112+1);
michael@0 4666 }
michael@0 4667 })();
michael@0 4668 MochiKit.Base.update(MochiKit.Signal,{__repr__:function(){
michael@0 4669 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 4670 },toString:function(){
michael@0 4671 return this.__repr__();
michael@0 4672 },_unloadCache:function(){
michael@0 4673 var self=MochiKit.Signal;
michael@0 4674 var _4ce=self._observers;
michael@0 4675 for(var i=0;i<_4ce.length;i++){
michael@0 4676 self._disconnect(_4ce[i]);
michael@0 4677 }
michael@0 4678 delete self._observers;
michael@0 4679 try{
michael@0 4680 window.onload=undefined;
michael@0 4681 }
michael@0 4682 catch(e){
michael@0 4683 }
michael@0 4684 try{
michael@0 4685 window.onunload=undefined;
michael@0 4686 }
michael@0 4687 catch(e){
michael@0 4688 }
michael@0 4689 },_listener:function(src,func,obj,_4d3){
michael@0 4690 var self=MochiKit.Signal;
michael@0 4691 var E=self.Event;
michael@0 4692 if(!_4d3){
michael@0 4693 return MochiKit.Base.bind(func,obj);
michael@0 4694 }
michael@0 4695 obj=obj||src;
michael@0 4696 if(typeof (func)=="string"){
michael@0 4697 return function(_4d6){
michael@0 4698 obj[func].apply(obj,[new E(src,_4d6)]);
michael@0 4699 };
michael@0 4700 }else{
michael@0 4701 return function(_4d7){
michael@0 4702 func.apply(obj,[new E(src,_4d7)]);
michael@0 4703 };
michael@0 4704 }
michael@0 4705 },_browserAlreadyHasMouseEnterAndLeave:function(){
michael@0 4706 return /MSIE/.test(navigator.userAgent);
michael@0 4707 },_mouseEnterListener:function(src,sig,func,obj){
michael@0 4708 var E=MochiKit.Signal.Event;
michael@0 4709 return function(_4dd){
michael@0 4710 var e=new E(src,_4dd);
michael@0 4711 try{
michael@0 4712 e.relatedTarget().nodeName;
michael@0 4713 }
michael@0 4714 catch(err){
michael@0 4715 return;
michael@0 4716 }
michael@0 4717 e.stop();
michael@0 4718 if(MochiKit.DOM.isChildNode(e.relatedTarget(),src)){
michael@0 4719 return;
michael@0 4720 }
michael@0 4721 e.type=function(){
michael@0 4722 return sig;
michael@0 4723 };
michael@0 4724 if(typeof (func)=="string"){
michael@0 4725 return obj[func].apply(obj,[e]);
michael@0 4726 }else{
michael@0 4727 return func.apply(obj,[e]);
michael@0 4728 }
michael@0 4729 };
michael@0 4730 },_getDestPair:function(_4df,_4e0){
michael@0 4731 var obj=null;
michael@0 4732 var func=null;
michael@0 4733 if(typeof (_4e0)!="undefined"){
michael@0 4734 obj=_4df;
michael@0 4735 func=_4e0;
michael@0 4736 if(typeof (_4e0)=="string"){
michael@0 4737 if(typeof (_4df[_4e0])!="function"){
michael@0 4738 throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
michael@0 4739 }
michael@0 4740 }else{
michael@0 4741 if(typeof (_4e0)!="function"){
michael@0 4742 throw new Error("'funcOrStr' must be a function or string");
michael@0 4743 }
michael@0 4744 }
michael@0 4745 }else{
michael@0 4746 if(typeof (_4df)!="function"){
michael@0 4747 throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
michael@0 4748 }else{
michael@0 4749 func=_4df;
michael@0 4750 }
michael@0 4751 }
michael@0 4752 return [obj,func];
michael@0 4753 },connect:function(src,sig,_4e5,_4e6){
michael@0 4754 src=MochiKit.DOM.getElement(src);
michael@0 4755 var self=MochiKit.Signal;
michael@0 4756 if(typeof (sig)!="string"){
michael@0 4757 throw new Error("'sig' must be a string");
michael@0 4758 }
michael@0 4759 var _4e8=self._getDestPair(_4e5,_4e6);
michael@0 4760 var obj=_4e8[0];
michael@0 4761 var func=_4e8[1];
michael@0 4762 if(typeof (obj)=="undefined"||obj===null){
michael@0 4763 obj=src;
michael@0 4764 }
michael@0 4765 var _4eb=!!(src.addEventListener||src.attachEvent);
michael@0 4766 if(_4eb&&(sig==="onmouseenter"||sig==="onmouseleave")&&!self._browserAlreadyHasMouseEnterAndLeave()){
michael@0 4767 var _4ec=self._mouseEnterListener(src,sig.substr(2),func,obj);
michael@0 4768 if(sig==="onmouseenter"){
michael@0 4769 sig="onmouseover";
michael@0 4770 }else{
michael@0 4771 sig="onmouseout";
michael@0 4772 }
michael@0 4773 }else{
michael@0 4774 var _4ec=self._listener(src,func,obj,_4eb);
michael@0 4775 }
michael@0 4776 if(src.addEventListener){
michael@0 4777 src.addEventListener(sig.substr(2),_4ec,false);
michael@0 4778 }else{
michael@0 4779 if(src.attachEvent){
michael@0 4780 src.attachEvent(sig,_4ec);
michael@0 4781 }
michael@0 4782 }
michael@0 4783 var _4ed=[src,sig,_4ec,_4eb,_4e5,_4e6,true];
michael@0 4784 self._observers.push(_4ed);
michael@0 4785 if(!_4eb&&typeof (src.__connect__)=="function"){
michael@0 4786 var args=MochiKit.Base.extend([_4ed],arguments,1);
michael@0 4787 src.__connect__.apply(src,args);
michael@0 4788 }
michael@0 4789 return _4ed;
michael@0 4790 },_disconnect:function(_4ef){
michael@0 4791 if(!_4ef[6]){
michael@0 4792 return;
michael@0 4793 }
michael@0 4794 _4ef[6]=false;
michael@0 4795 if(!_4ef[3]){
michael@0 4796 return;
michael@0 4797 }
michael@0 4798 var src=_4ef[0];
michael@0 4799 var sig=_4ef[1];
michael@0 4800 var _4f2=_4ef[2];
michael@0 4801 if(src.removeEventListener){
michael@0 4802 src.removeEventListener(sig.substr(2),_4f2,false);
michael@0 4803 }else{
michael@0 4804 if(src.detachEvent){
michael@0 4805 src.detachEvent(sig,_4f2);
michael@0 4806 }else{
michael@0 4807 throw new Error("'src' must be a DOM element");
michael@0 4808 }
michael@0 4809 }
michael@0 4810 },disconnect:function(_4f3){
michael@0 4811 var self=MochiKit.Signal;
michael@0 4812 var _4f5=self._observers;
michael@0 4813 var m=MochiKit.Base;
michael@0 4814 if(arguments.length>1){
michael@0 4815 var src=MochiKit.DOM.getElement(arguments[0]);
michael@0 4816 var sig=arguments[1];
michael@0 4817 var obj=arguments[2];
michael@0 4818 var func=arguments[3];
michael@0 4819 for(var i=_4f5.length-1;i>=0;i--){
michael@0 4820 var o=_4f5[i];
michael@0 4821 if(o[0]===src&&o[1]===sig&&o[4]===obj&&o[5]===func){
michael@0 4822 self._disconnect(o);
michael@0 4823 if(!self._lock){
michael@0 4824 _4f5.splice(i,1);
michael@0 4825 }else{
michael@0 4826 self._dirty=true;
michael@0 4827 }
michael@0 4828 return true;
michael@0 4829 }
michael@0 4830 }
michael@0 4831 }else{
michael@0 4832 var idx=m.findIdentical(_4f5,_4f3);
michael@0 4833 if(idx>=0){
michael@0 4834 self._disconnect(_4f3);
michael@0 4835 if(!self._lock){
michael@0 4836 _4f5.splice(idx,1);
michael@0 4837 }else{
michael@0 4838 self._dirty=true;
michael@0 4839 }
michael@0 4840 return true;
michael@0 4841 }
michael@0 4842 }
michael@0 4843 return false;
michael@0 4844 },disconnectAllTo:function(_4fe,_4ff){
michael@0 4845 var self=MochiKit.Signal;
michael@0 4846 var _501=self._observers;
michael@0 4847 var _502=self._disconnect;
michael@0 4848 var _503=self._lock;
michael@0 4849 var _504=self._dirty;
michael@0 4850 if(typeof (_4ff)==="undefined"){
michael@0 4851 _4ff=null;
michael@0 4852 }
michael@0 4853 for(var i=_501.length-1;i>=0;i--){
michael@0 4854 var _506=_501[i];
michael@0 4855 if(_506[4]===_4fe&&(_4ff===null||_506[5]===_4ff)){
michael@0 4856 _502(_506);
michael@0 4857 if(_503){
michael@0 4858 _504=true;
michael@0 4859 }else{
michael@0 4860 _501.splice(i,1);
michael@0 4861 }
michael@0 4862 }
michael@0 4863 }
michael@0 4864 self._dirty=_504;
michael@0 4865 },disconnectAll:function(src,sig){
michael@0 4866 src=MochiKit.DOM.getElement(src);
michael@0 4867 var m=MochiKit.Base;
michael@0 4868 var _50a=m.flattenArguments(m.extend(null,arguments,1));
michael@0 4869 var self=MochiKit.Signal;
michael@0 4870 var _50c=self._disconnect;
michael@0 4871 var _50d=self._observers;
michael@0 4872 var i,_50f;
michael@0 4873 var _510=self._lock;
michael@0 4874 var _511=self._dirty;
michael@0 4875 if(_50a.length===0){
michael@0 4876 for(i=_50d.length-1;i>=0;i--){
michael@0 4877 _50f=_50d[i];
michael@0 4878 if(_50f[0]===src){
michael@0 4879 _50c(_50f);
michael@0 4880 if(!_510){
michael@0 4881 _50d.splice(i,1);
michael@0 4882 }else{
michael@0 4883 _511=true;
michael@0 4884 }
michael@0 4885 }
michael@0 4886 }
michael@0 4887 }else{
michael@0 4888 var sigs={};
michael@0 4889 for(i=0;i<_50a.length;i++){
michael@0 4890 sigs[_50a[i]]=true;
michael@0 4891 }
michael@0 4892 for(i=_50d.length-1;i>=0;i--){
michael@0 4893 _50f=_50d[i];
michael@0 4894 if(_50f[0]===src&&_50f[1] in sigs){
michael@0 4895 _50c(_50f);
michael@0 4896 if(!_510){
michael@0 4897 _50d.splice(i,1);
michael@0 4898 }else{
michael@0 4899 _511=true;
michael@0 4900 }
michael@0 4901 }
michael@0 4902 }
michael@0 4903 }
michael@0 4904 self._dirty=_511;
michael@0 4905 },signal:function(src,sig){
michael@0 4906 var self=MochiKit.Signal;
michael@0 4907 var _516=self._observers;
michael@0 4908 src=MochiKit.DOM.getElement(src);
michael@0 4909 var args=MochiKit.Base.extend(null,arguments,2);
michael@0 4910 var _518=[];
michael@0 4911 self._lock=true;
michael@0 4912 for(var i=0;i<_516.length;i++){
michael@0 4913 var _51a=_516[i];
michael@0 4914 if(_51a[0]===src&&_51a[1]===sig){
michael@0 4915 try{
michael@0 4916 _51a[2].apply(src,args);
michael@0 4917 }
michael@0 4918 catch(e){
michael@0 4919 _518.push(e);
michael@0 4920 }
michael@0 4921 }
michael@0 4922 }
michael@0 4923 self._lock=false;
michael@0 4924 if(self._dirty){
michael@0 4925 self._dirty=false;
michael@0 4926 for(var i=_516.length-1;i>=0;i--){
michael@0 4927 if(!_516[i][6]){
michael@0 4928 _516.splice(i,1);
michael@0 4929 }
michael@0 4930 }
michael@0 4931 }
michael@0 4932 if(_518.length==1){
michael@0 4933 throw _518[0];
michael@0 4934 }else{
michael@0 4935 if(_518.length>1){
michael@0 4936 var e=new Error("Multiple errors thrown in handling 'sig', see errors property");
michael@0 4937 e.errors=_518;
michael@0 4938 throw e;
michael@0 4939 }
michael@0 4940 }
michael@0 4941 }});
michael@0 4942 MochiKit.Signal.EXPORT_OK=[];
michael@0 4943 MochiKit.Signal.EXPORT=["connect","disconnect","signal","disconnectAll","disconnectAllTo"];
michael@0 4944 MochiKit.Signal.__new__=function(win){
michael@0 4945 var m=MochiKit.Base;
michael@0 4946 this._document=document;
michael@0 4947 this._window=win;
michael@0 4948 this._lock=false;
michael@0 4949 this._dirty=false;
michael@0 4950 try{
michael@0 4951 this.connect(window,"onunload",this._unloadCache);
michael@0 4952 }
michael@0 4953 catch(e){
michael@0 4954 }
michael@0 4955 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 4956 m.nameFunctions(this);
michael@0 4957 };
michael@0 4958 MochiKit.Signal.__new__(this);
michael@0 4959 if(MochiKit.__export__){
michael@0 4960 connect=MochiKit.Signal.connect;
michael@0 4961 disconnect=MochiKit.Signal.disconnect;
michael@0 4962 disconnectAll=MochiKit.Signal.disconnectAll;
michael@0 4963 signal=MochiKit.Signal.signal;
michael@0 4964 }
michael@0 4965 MochiKit.Base._exportSymbols(this,MochiKit.Signal);
michael@0 4966 if(typeof (dojo)!="undefined"){
michael@0 4967 dojo.provide("MochiKit.Visual");
michael@0 4968 dojo.require("MochiKit.Base");
michael@0 4969 dojo.require("MochiKit.DOM");
michael@0 4970 dojo.require("MochiKit.Style");
michael@0 4971 dojo.require("MochiKit.Color");
michael@0 4972 }
michael@0 4973 if(typeof (JSAN)!="undefined"){
michael@0 4974 JSAN.use("MochiKit.Base",[]);
michael@0 4975 JSAN.use("MochiKit.DOM",[]);
michael@0 4976 JSAN.use("MochiKit.Style",[]);
michael@0 4977 JSAN.use("MochiKit.Color",[]);
michael@0 4978 }
michael@0 4979 try{
michael@0 4980 if(typeof (MochiKit.Base)==="undefined"||typeof (MochiKit.DOM)==="undefined"||typeof (MochiKit.Style)==="undefined"||typeof (MochiKit.Color)==="undefined"){
michael@0 4981 throw "";
michael@0 4982 }
michael@0 4983 }
michael@0 4984 catch(e){
michael@0 4985 throw "MochiKit.Visual depends on MochiKit.Base, MochiKit.DOM, MochiKit.Style and MochiKit.Color!";
michael@0 4986 }
michael@0 4987 if(typeof (MochiKit.Visual)=="undefined"){
michael@0 4988 MochiKit.Visual={};
michael@0 4989 }
michael@0 4990 MochiKit.Visual.NAME="MochiKit.Visual";
michael@0 4991 MochiKit.Visual.VERSION="1.4";
michael@0 4992 MochiKit.Visual.__repr__=function(){
michael@0 4993 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 4994 };
michael@0 4995 MochiKit.Visual.toString=function(){
michael@0 4996 return this.__repr__();
michael@0 4997 };
michael@0 4998 MochiKit.Visual._RoundCorners=function(e,_51f){
michael@0 4999 e=MochiKit.DOM.getElement(e);
michael@0 5000 this._setOptions(_51f);
michael@0 5001 if(this.options.__unstable__wrapElement){
michael@0 5002 e=this._doWrap(e);
michael@0 5003 }
michael@0 5004 var _520=this.options.color;
michael@0 5005 var C=MochiKit.Color.Color;
michael@0 5006 if(this.options.color==="fromElement"){
michael@0 5007 _520=C.fromBackground(e);
michael@0 5008 }else{
michael@0 5009 if(!(_520 instanceof C)){
michael@0 5010 _520=C.fromString(_520);
michael@0 5011 }
michael@0 5012 }
michael@0 5013 this.isTransparent=(_520.asRGB().a<=0);
michael@0 5014 var _522=this.options.bgColor;
michael@0 5015 if(this.options.bgColor==="fromParent"){
michael@0 5016 _522=C.fromBackground(e.offsetParent);
michael@0 5017 }else{
michael@0 5018 if(!(_522 instanceof C)){
michael@0 5019 _522=C.fromString(_522);
michael@0 5020 }
michael@0 5021 }
michael@0 5022 this._roundCornersImpl(e,_520,_522);
michael@0 5023 };
michael@0 5024 MochiKit.Visual._RoundCorners.prototype={_doWrap:function(e){
michael@0 5025 var _524=e.parentNode;
michael@0 5026 var doc=MochiKit.DOM.currentDocument();
michael@0 5027 if(typeof (doc.defaultView)==="undefined"||doc.defaultView===null){
michael@0 5028 return e;
michael@0 5029 }
michael@0 5030 var _526=doc.defaultView.getComputedStyle(e,null);
michael@0 5031 if(typeof (_526)==="undefined"||_526===null){
michael@0 5032 return e;
michael@0 5033 }
michael@0 5034 var _527=MochiKit.DOM.DIV({"style":{display:"block",marginTop:_526.getPropertyValue("padding-top"),marginRight:_526.getPropertyValue("padding-right"),marginBottom:_526.getPropertyValue("padding-bottom"),marginLeft:_526.getPropertyValue("padding-left"),padding:"0px"}});
michael@0 5035 _527.innerHTML=e.innerHTML;
michael@0 5036 e.innerHTML="";
michael@0 5037 e.appendChild(_527);
michael@0 5038 return e;
michael@0 5039 },_roundCornersImpl:function(e,_529,_52a){
michael@0 5040 if(this.options.border){
michael@0 5041 this._renderBorder(e,_52a);
michael@0 5042 }
michael@0 5043 if(this._isTopRounded()){
michael@0 5044 this._roundTopCorners(e,_529,_52a);
michael@0 5045 }
michael@0 5046 if(this._isBottomRounded()){
michael@0 5047 this._roundBottomCorners(e,_529,_52a);
michael@0 5048 }
michael@0 5049 },_renderBorder:function(el,_52c){
michael@0 5050 var _52d="1px solid "+this._borderColor(_52c);
michael@0 5051 var _52e="border-left: "+_52d;
michael@0 5052 var _52f="border-right: "+_52d;
michael@0 5053 var _530="style='"+_52e+";"+_52f+"'";
michael@0 5054 el.innerHTML="<div "+_530+">"+el.innerHTML+"</div>";
michael@0 5055 },_roundTopCorners:function(el,_532,_533){
michael@0 5056 var _534=this._createCorner(_533);
michael@0 5057 for(var i=0;i<this.options.numSlices;i++){
michael@0 5058 _534.appendChild(this._createCornerSlice(_532,_533,i,"top"));
michael@0 5059 }
michael@0 5060 el.style.paddingTop=0;
michael@0 5061 el.insertBefore(_534,el.firstChild);
michael@0 5062 },_roundBottomCorners:function(el,_537,_538){
michael@0 5063 var _539=this._createCorner(_538);
michael@0 5064 for(var i=(this.options.numSlices-1);i>=0;i--){
michael@0 5065 _539.appendChild(this._createCornerSlice(_537,_538,i,"bottom"));
michael@0 5066 }
michael@0 5067 el.style.paddingBottom=0;
michael@0 5068 el.appendChild(_539);
michael@0 5069 },_createCorner:function(_53b){
michael@0 5070 var dom=MochiKit.DOM;
michael@0 5071 return dom.DIV({style:{backgroundColor:_53b.toString()}});
michael@0 5072 },_createCornerSlice:function(_53d,_53e,n,_540){
michael@0 5073 var _541=MochiKit.DOM.SPAN();
michael@0 5074 var _542=_541.style;
michael@0 5075 _542.backgroundColor=_53d.toString();
michael@0 5076 _542.display="block";
michael@0 5077 _542.height="1px";
michael@0 5078 _542.overflow="hidden";
michael@0 5079 _542.fontSize="1px";
michael@0 5080 var _543=this._borderColor(_53d,_53e);
michael@0 5081 if(this.options.border&&n===0){
michael@0 5082 _542.borderTopStyle="solid";
michael@0 5083 _542.borderTopWidth="1px";
michael@0 5084 _542.borderLeftWidth="0px";
michael@0 5085 _542.borderRightWidth="0px";
michael@0 5086 _542.borderBottomWidth="0px";
michael@0 5087 _542.height="0px";
michael@0 5088 _542.borderColor=_543.toString();
michael@0 5089 }else{
michael@0 5090 if(_543){
michael@0 5091 _542.borderColor=_543.toString();
michael@0 5092 _542.borderStyle="solid";
michael@0 5093 _542.borderWidth="0px 1px";
michael@0 5094 }
michael@0 5095 }
michael@0 5096 if(!this.options.compact&&(n==(this.options.numSlices-1))){
michael@0 5097 _542.height="2px";
michael@0 5098 }
michael@0 5099 this._setMargin(_541,n,_540);
michael@0 5100 this._setBorder(_541,n,_540);
michael@0 5101 return _541;
michael@0 5102 },_setOptions:function(_544){
michael@0 5103 this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false,__unstable__wrapElement:false};
michael@0 5104 MochiKit.Base.update(this.options,_544);
michael@0 5105 this.options.numSlices=(this.options.compact?2:4);
michael@0 5106 },_whichSideTop:function(){
michael@0 5107 var _545=this.options.corners;
michael@0 5108 if(this._hasString(_545,"all","top")){
michael@0 5109 return "";
michael@0 5110 }
michael@0 5111 var _546=(_545.indexOf("tl")!=-1);
michael@0 5112 var _547=(_545.indexOf("tr")!=-1);
michael@0 5113 if(_546&&_547){
michael@0 5114 return "";
michael@0 5115 }
michael@0 5116 if(_546){
michael@0 5117 return "left";
michael@0 5118 }
michael@0 5119 if(_547){
michael@0 5120 return "right";
michael@0 5121 }
michael@0 5122 return "";
michael@0 5123 },_whichSideBottom:function(){
michael@0 5124 var _548=this.options.corners;
michael@0 5125 if(this._hasString(_548,"all","bottom")){
michael@0 5126 return "";
michael@0 5127 }
michael@0 5128 var _549=(_548.indexOf("bl")!=-1);
michael@0 5129 var _54a=(_548.indexOf("br")!=-1);
michael@0 5130 if(_549&&_54a){
michael@0 5131 return "";
michael@0 5132 }
michael@0 5133 if(_549){
michael@0 5134 return "left";
michael@0 5135 }
michael@0 5136 if(_54a){
michael@0 5137 return "right";
michael@0 5138 }
michael@0 5139 return "";
michael@0 5140 },_borderColor:function(_54b,_54c){
michael@0 5141 if(_54b=="transparent"){
michael@0 5142 return _54c;
michael@0 5143 }else{
michael@0 5144 if(this.options.border){
michael@0 5145 return this.options.border;
michael@0 5146 }else{
michael@0 5147 if(this.options.blend){
michael@0 5148 return _54c.blendedColor(_54b);
michael@0 5149 }
michael@0 5150 }
michael@0 5151 }
michael@0 5152 return "";
michael@0 5153 },_setMargin:function(el,n,_54f){
michael@0 5154 var _550=this._marginSize(n)+"px";
michael@0 5155 var _551=(_54f=="top"?this._whichSideTop():this._whichSideBottom());
michael@0 5156 var _552=el.style;
michael@0 5157 if(_551=="left"){
michael@0 5158 _552.marginLeft=_550;
michael@0 5159 _552.marginRight="0px";
michael@0 5160 }else{
michael@0 5161 if(_551=="right"){
michael@0 5162 _552.marginRight=_550;
michael@0 5163 _552.marginLeft="0px";
michael@0 5164 }else{
michael@0 5165 _552.marginLeft=_550;
michael@0 5166 _552.marginRight=_550;
michael@0 5167 }
michael@0 5168 }
michael@0 5169 },_setBorder:function(el,n,_555){
michael@0 5170 var _556=this._borderSize(n)+"px";
michael@0 5171 var _557=(_555=="top"?this._whichSideTop():this._whichSideBottom());
michael@0 5172 var _558=el.style;
michael@0 5173 if(_557=="left"){
michael@0 5174 _558.borderLeftWidth=_556;
michael@0 5175 _558.borderRightWidth="0px";
michael@0 5176 }else{
michael@0 5177 if(_557=="right"){
michael@0 5178 _558.borderRightWidth=_556;
michael@0 5179 _558.borderLeftWidth="0px";
michael@0 5180 }else{
michael@0 5181 _558.borderLeftWidth=_556;
michael@0 5182 _558.borderRightWidth=_556;
michael@0 5183 }
michael@0 5184 }
michael@0 5185 },_marginSize:function(n){
michael@0 5186 if(this.isTransparent){
michael@0 5187 return 0;
michael@0 5188 }
michael@0 5189 var o=this.options;
michael@0 5190 if(o.compact&&o.blend){
michael@0 5191 var _55b=[1,0];
michael@0 5192 return _55b[n];
michael@0 5193 }else{
michael@0 5194 if(o.compact){
michael@0 5195 var _55c=[2,1];
michael@0 5196 return _55c[n];
michael@0 5197 }else{
michael@0 5198 if(o.blend){
michael@0 5199 var _55d=[3,2,1,0];
michael@0 5200 return _55d[n];
michael@0 5201 }else{
michael@0 5202 var _55e=[5,3,2,1];
michael@0 5203 return _55e[n];
michael@0 5204 }
michael@0 5205 }
michael@0 5206 }
michael@0 5207 },_borderSize:function(n){
michael@0 5208 var o=this.options;
michael@0 5209 var _561;
michael@0 5210 if(o.compact&&(o.blend||this.isTransparent)){
michael@0 5211 return 1;
michael@0 5212 }else{
michael@0 5213 if(o.compact){
michael@0 5214 _561=[1,0];
michael@0 5215 }else{
michael@0 5216 if(o.blend){
michael@0 5217 _561=[2,1,1,1];
michael@0 5218 }else{
michael@0 5219 if(o.border){
michael@0 5220 _561=[0,2,0,0];
michael@0 5221 }else{
michael@0 5222 if(this.isTransparent){
michael@0 5223 _561=[5,3,2,1];
michael@0 5224 }else{
michael@0 5225 return 0;
michael@0 5226 }
michael@0 5227 }
michael@0 5228 }
michael@0 5229 }
michael@0 5230 }
michael@0 5231 return _561[n];
michael@0 5232 },_hasString:function(str){
michael@0 5233 for(var i=1;i<arguments.length;i++){
michael@0 5234 if(str.indexOf(arguments[i])!=-1){
michael@0 5235 return true;
michael@0 5236 }
michael@0 5237 }
michael@0 5238 return false;
michael@0 5239 },_isTopRounded:function(){
michael@0 5240 return this._hasString(this.options.corners,"all","top","tl","tr");
michael@0 5241 },_isBottomRounded:function(){
michael@0 5242 return this._hasString(this.options.corners,"all","bottom","bl","br");
michael@0 5243 },_hasSingleTextChild:function(el){
michael@0 5244 return (el.childNodes.length==1&&el.childNodes[0].nodeType==3);
michael@0 5245 }};
michael@0 5246 MochiKit.Visual.roundElement=function(e,_566){
michael@0 5247 new MochiKit.Visual._RoundCorners(e,_566);
michael@0 5248 };
michael@0 5249 MochiKit.Visual.roundClass=function(_567,_568,_569){
michael@0 5250 var _56a=MochiKit.DOM.getElementsByTagAndClassName(_567,_568);
michael@0 5251 for(var i=0;i<_56a.length;i++){
michael@0 5252 MochiKit.Visual.roundElement(_56a[i],_569);
michael@0 5253 }
michael@0 5254 };
michael@0 5255 MochiKit.Visual.tagifyText=function(_56c,_56d){
michael@0 5256 var _56d=_56d||"position:relative";
michael@0 5257 if(/MSIE/.test(navigator.userAgent)){
michael@0 5258 _56d+=";zoom:1";
michael@0 5259 }
michael@0 5260 _56c=MochiKit.DOM.getElement(_56c);
michael@0 5261 var ma=MochiKit.Base.map;
michael@0 5262 ma(function(_56f){
michael@0 5263 if(_56f.nodeType==3){
michael@0 5264 ma(function(_570){
michael@0 5265 _56c.insertBefore(MochiKit.DOM.SPAN({style:_56d},_570==" "?String.fromCharCode(160):_570),_56f);
michael@0 5266 },_56f.nodeValue.split(""));
michael@0 5267 MochiKit.DOM.removeElement(_56f);
michael@0 5268 }
michael@0 5269 },_56c.childNodes);
michael@0 5270 };
michael@0 5271 MochiKit.Visual.forceRerendering=function(_571){
michael@0 5272 try{
michael@0 5273 _571=MochiKit.DOM.getElement(_571);
michael@0 5274 var n=document.createTextNode(" ");
michael@0 5275 _571.appendChild(n);
michael@0 5276 _571.removeChild(n);
michael@0 5277 }
michael@0 5278 catch(e){
michael@0 5279 }
michael@0 5280 };
michael@0 5281 MochiKit.Visual.multiple=function(_573,_574,_575){
michael@0 5282 _575=MochiKit.Base.update({speed:0.1,delay:0},_575||{});
michael@0 5283 var _576=_575.delay;
michael@0 5284 var _577=0;
michael@0 5285 MochiKit.Base.map(function(_578){
michael@0 5286 _575.delay=_577*_575.speed+_576;
michael@0 5287 new _574(_578,_575);
michael@0 5288 _577+=1;
michael@0 5289 },_573);
michael@0 5290 };
michael@0 5291 MochiKit.Visual.PAIRS={"slide":["slideDown","slideUp"],"blind":["blindDown","blindUp"],"appear":["appear","fade"],"size":["grow","shrink"]};
michael@0 5292 MochiKit.Visual.toggle=function(_579,_57a,_57b){
michael@0 5293 _579=MochiKit.DOM.getElement(_579);
michael@0 5294 _57a=(_57a||"appear").toLowerCase();
michael@0 5295 _57b=MochiKit.Base.update({queue:{position:"end",scope:(_579.id||"global"),limit:1}},_57b||{});
michael@0 5296 var v=MochiKit.Visual;
michael@0 5297 v[_579.style.display!="none"?v.PAIRS[_57a][1]:v.PAIRS[_57a][0]](_579,_57b);
michael@0 5298 };
michael@0 5299 MochiKit.Visual.Transitions={};
michael@0 5300 MochiKit.Visual.Transitions.linear=function(pos){
michael@0 5301 return pos;
michael@0 5302 };
michael@0 5303 MochiKit.Visual.Transitions.sinoidal=function(pos){
michael@0 5304 return (-Math.cos(pos*Math.PI)/2)+0.5;
michael@0 5305 };
michael@0 5306 MochiKit.Visual.Transitions.reverse=function(pos){
michael@0 5307 return 1-pos;
michael@0 5308 };
michael@0 5309 MochiKit.Visual.Transitions.flicker=function(pos){
michael@0 5310 return ((-Math.cos(pos*Math.PI)/4)+0.75)+Math.random()/4;
michael@0 5311 };
michael@0 5312 MochiKit.Visual.Transitions.wobble=function(pos){
michael@0 5313 return (-Math.cos(pos*Math.PI*(9*pos))/2)+0.5;
michael@0 5314 };
michael@0 5315 MochiKit.Visual.Transitions.pulse=function(pos){
michael@0 5316 return (Math.floor(pos*10)%2==0?(pos*10-Math.floor(pos*10)):1-(pos*10-Math.floor(pos*10)));
michael@0 5317 };
michael@0 5318 MochiKit.Visual.Transitions.none=function(pos){
michael@0 5319 return 0;
michael@0 5320 };
michael@0 5321 MochiKit.Visual.Transitions.full=function(pos){
michael@0 5322 return 1;
michael@0 5323 };
michael@0 5324 MochiKit.Visual.ScopedQueue=function(){
michael@0 5325 this.__init__();
michael@0 5326 };
michael@0 5327 MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype,{__init__:function(){
michael@0 5328 this.effects=[];
michael@0 5329 this.interval=null;
michael@0 5330 },add:function(_585){
michael@0 5331 var _586=new Date().getTime();
michael@0 5332 var _587=(typeof (_585.options.queue)=="string")?_585.options.queue:_585.options.queue.position;
michael@0 5333 var ma=MochiKit.Base.map;
michael@0 5334 switch(_587){
michael@0 5335 case "front":
michael@0 5336 ma(function(e){
michael@0 5337 if(e.state=="idle"){
michael@0 5338 e.startOn+=_585.finishOn;
michael@0 5339 e.finishOn+=_585.finishOn;
michael@0 5340 }
michael@0 5341 },this.effects);
michael@0 5342 break;
michael@0 5343 case "end":
michael@0 5344 var _58a;
michael@0 5345 ma(function(e){
michael@0 5346 var i=e.finishOn;
michael@0 5347 if(i>=(_58a||i)){
michael@0 5348 _58a=i;
michael@0 5349 }
michael@0 5350 },this.effects);
michael@0 5351 _586=_58a||_586;
michael@0 5352 break;
michael@0 5353 case "break":
michael@0 5354 ma(function(e){
michael@0 5355 e.finalize();
michael@0 5356 },this.effects);
michael@0 5357 break;
michael@0 5358 }
michael@0 5359 _585.startOn+=_586;
michael@0 5360 _585.finishOn+=_586;
michael@0 5361 if(!_585.options.queue.limit||this.effects.length<_585.options.queue.limit){
michael@0 5362 this.effects.push(_585);
michael@0 5363 }
michael@0 5364 if(!this.interval){
michael@0 5365 this.interval=this.startLoop(MochiKit.Base.bind(this.loop,this),40);
michael@0 5366 }
michael@0 5367 },startLoop:function(func,_58f){
michael@0 5368 return setInterval(func,_58f);
michael@0 5369 },remove:function(_590){
michael@0 5370 this.effects=MochiKit.Base.filter(function(e){
michael@0 5371 return e!=_590;
michael@0 5372 },this.effects);
michael@0 5373 if(this.effects.length==0){
michael@0 5374 this.stopLoop(this.interval);
michael@0 5375 this.interval=null;
michael@0 5376 }
michael@0 5377 },stopLoop:function(_592){
michael@0 5378 clearInterval(_592);
michael@0 5379 },loop:function(){
michael@0 5380 var _593=new Date().getTime();
michael@0 5381 MochiKit.Base.map(function(_594){
michael@0 5382 _594.loop(_593);
michael@0 5383 },this.effects);
michael@0 5384 }});
michael@0 5385 MochiKit.Visual.Queues={instances:{},get:function(_595){
michael@0 5386 if(typeof (_595)!="string"){
michael@0 5387 return _595;
michael@0 5388 }
michael@0 5389 if(!this.instances[_595]){
michael@0 5390 this.instances[_595]=new MochiKit.Visual.ScopedQueue();
michael@0 5391 }
michael@0 5392 return this.instances[_595];
michael@0 5393 }};
michael@0 5394 MochiKit.Visual.Queue=MochiKit.Visual.Queues.get("global");
michael@0 5395 MochiKit.Visual.DefaultOptions={transition:MochiKit.Visual.Transitions.sinoidal,duration:1,fps:25,sync:false,from:0,to:1,delay:0,queue:"parallel"};
michael@0 5396 MochiKit.Visual.Base=function(){
michael@0 5397 };
michael@0 5398 MochiKit.Visual.Base.prototype={__class__:MochiKit.Visual.Base,start:function(_596){
michael@0 5399 var v=MochiKit.Visual;
michael@0 5400 this.options=MochiKit.Base.setdefault(_596||{},v.DefaultOptions);
michael@0 5401 this.currentFrame=0;
michael@0 5402 this.state="idle";
michael@0 5403 this.startOn=this.options.delay*1000;
michael@0 5404 this.finishOn=this.startOn+(this.options.duration*1000);
michael@0 5405 this.event("beforeStart");
michael@0 5406 if(!this.options.sync){
michael@0 5407 v.Queues.get(typeof (this.options.queue)=="string"?"global":this.options.queue.scope).add(this);
michael@0 5408 }
michael@0 5409 },loop:function(_598){
michael@0 5410 if(_598>=this.startOn){
michael@0 5411 if(_598>=this.finishOn){
michael@0 5412 return this.finalize();
michael@0 5413 }
michael@0 5414 var pos=(_598-this.startOn)/(this.finishOn-this.startOn);
michael@0 5415 var _59a=Math.round(pos*this.options.fps*this.options.duration);
michael@0 5416 if(_59a>this.currentFrame){
michael@0 5417 this.render(pos);
michael@0 5418 this.currentFrame=_59a;
michael@0 5419 }
michael@0 5420 }
michael@0 5421 },render:function(pos){
michael@0 5422 if(this.state=="idle"){
michael@0 5423 this.state="running";
michael@0 5424 this.event("beforeSetup");
michael@0 5425 this.setup();
michael@0 5426 this.event("afterSetup");
michael@0 5427 }
michael@0 5428 if(this.state=="running"){
michael@0 5429 if(this.options.transition){
michael@0 5430 pos=this.options.transition(pos);
michael@0 5431 }
michael@0 5432 pos*=(this.options.to-this.options.from);
michael@0 5433 pos+=this.options.from;
michael@0 5434 this.event("beforeUpdate");
michael@0 5435 this.update(pos);
michael@0 5436 this.event("afterUpdate");
michael@0 5437 }
michael@0 5438 },cancel:function(){
michael@0 5439 if(!this.options.sync){
michael@0 5440 MochiKit.Visual.Queues.get(typeof (this.options.queue)=="string"?"global":this.options.queue.scope).remove(this);
michael@0 5441 }
michael@0 5442 this.state="finished";
michael@0 5443 },finalize:function(){
michael@0 5444 this.render(1);
michael@0 5445 this.cancel();
michael@0 5446 this.event("beforeFinish");
michael@0 5447 this.finish();
michael@0 5448 this.event("afterFinish");
michael@0 5449 },setup:function(){
michael@0 5450 },finish:function(){
michael@0 5451 },update:function(_59c){
michael@0 5452 },event:function(_59d){
michael@0 5453 if(this.options[_59d+"Internal"]){
michael@0 5454 this.options[_59d+"Internal"](this);
michael@0 5455 }
michael@0 5456 if(this.options[_59d]){
michael@0 5457 this.options[_59d](this);
michael@0 5458 }
michael@0 5459 },repr:function(){
michael@0 5460 return "["+this.__class__.NAME+", options:"+MochiKit.Base.repr(this.options)+"]";
michael@0 5461 }};
michael@0 5462 MochiKit.Visual.Parallel=function(_59e,_59f){
michael@0 5463 this.__init__(_59e,_59f);
michael@0 5464 };
michael@0 5465 MochiKit.Visual.Parallel.prototype=new MochiKit.Visual.Base();
michael@0 5466 MochiKit.Base.update(MochiKit.Visual.Parallel.prototype,{__init__:function(_5a0,_5a1){
michael@0 5467 this.effects=_5a0||[];
michael@0 5468 this.start(_5a1);
michael@0 5469 },update:function(_5a2){
michael@0 5470 MochiKit.Base.map(function(_5a3){
michael@0 5471 _5a3.render(_5a2);
michael@0 5472 },this.effects);
michael@0 5473 },finish:function(){
michael@0 5474 MochiKit.Base.map(function(_5a4){
michael@0 5475 _5a4.finalize();
michael@0 5476 },this.effects);
michael@0 5477 }});
michael@0 5478 MochiKit.Visual.Opacity=function(_5a5,_5a6){
michael@0 5479 this.__init__(_5a5,_5a6);
michael@0 5480 };
michael@0 5481 MochiKit.Visual.Opacity.prototype=new MochiKit.Visual.Base();
michael@0 5482 MochiKit.Base.update(MochiKit.Visual.Opacity.prototype,{__init__:function(_5a7,_5a8){
michael@0 5483 var b=MochiKit.Base;
michael@0 5484 var s=MochiKit.Style;
michael@0 5485 this.element=MochiKit.DOM.getElement(_5a7);
michael@0 5486 if(this.element.currentStyle&&(!this.element.currentStyle.hasLayout)){
michael@0 5487 s.setStyle(this.element,{zoom:1});
michael@0 5488 }
michael@0 5489 _5a8=b.update({from:s.getOpacity(this.element)||0,to:1},_5a8||{});
michael@0 5490 this.start(_5a8);
michael@0 5491 },update:function(_5ab){
michael@0 5492 MochiKit.Style.setOpacity(this.element,_5ab);
michael@0 5493 }});
michael@0 5494 MochiKit.Visual.Move=function(_5ac,_5ad){
michael@0 5495 this.__init__(_5ac,_5ad);
michael@0 5496 };
michael@0 5497 MochiKit.Visual.Move.prototype=new MochiKit.Visual.Base();
michael@0 5498 MochiKit.Base.update(MochiKit.Visual.Move.prototype,{__init__:function(_5ae,_5af){
michael@0 5499 this.element=MochiKit.DOM.getElement(_5ae);
michael@0 5500 _5af=MochiKit.Base.update({x:0,y:0,mode:"relative"},_5af||{});
michael@0 5501 this.start(_5af);
michael@0 5502 },setup:function(){
michael@0 5503 MochiKit.DOM.makePositioned(this.element);
michael@0 5504 var s=this.element.style;
michael@0 5505 var _5b1=s.visibility;
michael@0 5506 var _5b2=s.display;
michael@0 5507 if(_5b2=="none"){
michael@0 5508 s.visibility="hidden";
michael@0 5509 s.display="";
michael@0 5510 }
michael@0 5511 this.originalLeft=parseFloat(MochiKit.Style.getStyle(this.element,"left")||"0");
michael@0 5512 this.originalTop=parseFloat(MochiKit.Style.getStyle(this.element,"top")||"0");
michael@0 5513 if(this.options.mode=="absolute"){
michael@0 5514 this.options.x-=this.originalLeft;
michael@0 5515 this.options.y-=this.originalTop;
michael@0 5516 }
michael@0 5517 if(_5b2=="none"){
michael@0 5518 s.visibility=_5b1;
michael@0 5519 s.display=_5b2;
michael@0 5520 }
michael@0 5521 },update:function(_5b3){
michael@0 5522 MochiKit.Style.setStyle(this.element,{left:Math.round(this.options.x*_5b3+this.originalLeft)+"px",top:Math.round(this.options.y*_5b3+this.originalTop)+"px"});
michael@0 5523 }});
michael@0 5524 MochiKit.Visual.Scale=function(_5b4,_5b5,_5b6){
michael@0 5525 this.__init__(_5b4,_5b5,_5b6);
michael@0 5526 };
michael@0 5527 MochiKit.Visual.Scale.prototype=new MochiKit.Visual.Base();
michael@0 5528 MochiKit.Base.update(MochiKit.Visual.Scale.prototype,{__init__:function(_5b7,_5b8,_5b9){
michael@0 5529 this.element=MochiKit.DOM.getElement(_5b7);
michael@0 5530 _5b9=MochiKit.Base.update({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:_5b8},_5b9||{});
michael@0 5531 this.start(_5b9);
michael@0 5532 },setup:function(){
michael@0 5533 this.restoreAfterFinish=this.options.restoreAfterFinish||false;
michael@0 5534 this.elementPositioning=MochiKit.Style.getStyle(this.element,"position");
michael@0 5535 var ma=MochiKit.Base.map;
michael@0 5536 var b=MochiKit.Base.bind;
michael@0 5537 this.originalStyle={};
michael@0 5538 ma(b(function(k){
michael@0 5539 this.originalStyle[k]=this.element.style[k];
michael@0 5540 },this),["top","left","width","height","fontSize"]);
michael@0 5541 this.originalTop=this.element.offsetTop;
michael@0 5542 this.originalLeft=this.element.offsetLeft;
michael@0 5543 var _5bd=MochiKit.Style.getStyle(this.element,"font-size")||"100%";
michael@0 5544 ma(b(function(_5be){
michael@0 5545 if(_5bd.indexOf(_5be)>0){
michael@0 5546 this.fontSize=parseFloat(_5bd);
michael@0 5547 this.fontSizeType=_5be;
michael@0 5548 }
michael@0 5549 },this),["em","px","%"]);
michael@0 5550 this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;
michael@0 5551 if(/^content/.test(this.options.scaleMode)){
michael@0 5552 this.dims=[this.element.scrollHeight,this.element.scrollWidth];
michael@0 5553 }else{
michael@0 5554 if(this.options.scaleMode=="box"){
michael@0 5555 this.dims=[this.element.offsetHeight,this.element.offsetWidth];
michael@0 5556 }else{
michael@0 5557 this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth];
michael@0 5558 }
michael@0 5559 }
michael@0 5560 },update:function(_5bf){
michael@0 5561 var _5c0=(this.options.scaleFrom/100)+(this.factor*_5bf);
michael@0 5562 if(this.options.scaleContent&&this.fontSize){
michael@0 5563 MochiKit.Style.setStyle(this.element,{fontSize:this.fontSize*_5c0+this.fontSizeType});
michael@0 5564 }
michael@0 5565 this.setDimensions(this.dims[0]*_5c0,this.dims[1]*_5c0);
michael@0 5566 },finish:function(){
michael@0 5567 if(this.restoreAfterFinish){
michael@0 5568 MochiKit.Style.setStyle(this.element,this.originalStyle);
michael@0 5569 }
michael@0 5570 },setDimensions:function(_5c1,_5c2){
michael@0 5571 var d={};
michael@0 5572 var r=Math.round;
michael@0 5573 if(/MSIE/.test(navigator.userAgent)){
michael@0 5574 r=Math.ceil;
michael@0 5575 }
michael@0 5576 if(this.options.scaleX){
michael@0 5577 d.width=r(_5c2)+"px";
michael@0 5578 }
michael@0 5579 if(this.options.scaleY){
michael@0 5580 d.height=r(_5c1)+"px";
michael@0 5581 }
michael@0 5582 if(this.options.scaleFromCenter){
michael@0 5583 var topd=(_5c1-this.dims[0])/2;
michael@0 5584 var _5c6=(_5c2-this.dims[1])/2;
michael@0 5585 if(this.elementPositioning=="absolute"){
michael@0 5586 if(this.options.scaleY){
michael@0 5587 d.top=this.originalTop-topd+"px";
michael@0 5588 }
michael@0 5589 if(this.options.scaleX){
michael@0 5590 d.left=this.originalLeft-_5c6+"px";
michael@0 5591 }
michael@0 5592 }else{
michael@0 5593 if(this.options.scaleY){
michael@0 5594 d.top=-topd+"px";
michael@0 5595 }
michael@0 5596 if(this.options.scaleX){
michael@0 5597 d.left=-_5c6+"px";
michael@0 5598 }
michael@0 5599 }
michael@0 5600 }
michael@0 5601 MochiKit.Style.setStyle(this.element,d);
michael@0 5602 }});
michael@0 5603 MochiKit.Visual.Highlight=function(_5c7,_5c8){
michael@0 5604 this.__init__(_5c7,_5c8);
michael@0 5605 };
michael@0 5606 MochiKit.Visual.Highlight.prototype=new MochiKit.Visual.Base();
michael@0 5607 MochiKit.Base.update(MochiKit.Visual.Highlight.prototype,{__init__:function(_5c9,_5ca){
michael@0 5608 this.element=MochiKit.DOM.getElement(_5c9);
michael@0 5609 _5ca=MochiKit.Base.update({startcolor:"#ffff99"},_5ca||{});
michael@0 5610 this.start(_5ca);
michael@0 5611 },setup:function(){
michael@0 5612 var b=MochiKit.Base;
michael@0 5613 var s=MochiKit.Style;
michael@0 5614 if(s.getStyle(this.element,"display")=="none"){
michael@0 5615 this.cancel();
michael@0 5616 return;
michael@0 5617 }
michael@0 5618 this.oldStyle={backgroundImage:s.getStyle(this.element,"background-image")};
michael@0 5619 s.setStyle(this.element,{backgroundImage:"none"});
michael@0 5620 if(!this.options.endcolor){
michael@0 5621 this.options.endcolor=MochiKit.Color.Color.fromBackground(this.element).toHexString();
michael@0 5622 }
michael@0 5623 if(b.isUndefinedOrNull(this.options.restorecolor)){
michael@0 5624 this.options.restorecolor=s.getStyle(this.element,"background-color");
michael@0 5625 }
michael@0 5626 this._base=b.map(b.bind(function(i){
michael@0 5627 return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16);
michael@0 5628 },this),[0,1,2]);
michael@0 5629 this._delta=b.map(b.bind(function(i){
michael@0 5630 return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i];
michael@0 5631 },this),[0,1,2]);
michael@0 5632 },update:function(_5cf){
michael@0 5633 var m="#";
michael@0 5634 MochiKit.Base.map(MochiKit.Base.bind(function(i){
michael@0 5635 m+=MochiKit.Color.toColorPart(Math.round(this._base[i]+this._delta[i]*_5cf));
michael@0 5636 },this),[0,1,2]);
michael@0 5637 MochiKit.Style.setStyle(this.element,{backgroundColor:m});
michael@0 5638 },finish:function(){
michael@0 5639 MochiKit.Style.setStyle(this.element,MochiKit.Base.update(this.oldStyle,{backgroundColor:this.options.restorecolor}));
michael@0 5640 }});
michael@0 5641 MochiKit.Visual.ScrollTo=function(_5d2,_5d3){
michael@0 5642 this.__init__(_5d2,_5d3);
michael@0 5643 };
michael@0 5644 MochiKit.Visual.ScrollTo.prototype=new MochiKit.Visual.Base();
michael@0 5645 MochiKit.Base.update(MochiKit.Visual.ScrollTo.prototype,{__init__:function(_5d4,_5d5){
michael@0 5646 this.element=MochiKit.DOM.getElement(_5d4);
michael@0 5647 this.start(_5d5||{});
michael@0 5648 },setup:function(){
michael@0 5649 var p=MochiKit.Position;
michael@0 5650 p.prepare();
michael@0 5651 var _5d7=p.cumulativeOffset(this.element);
michael@0 5652 if(this.options.offset){
michael@0 5653 _5d7.y+=this.options.offset;
michael@0 5654 }
michael@0 5655 var max;
michael@0 5656 if(window.innerHeight){
michael@0 5657 max=window.innerHeight-window.height;
michael@0 5658 }else{
michael@0 5659 if(document.documentElement&&document.documentElement.clientHeight){
michael@0 5660 max=document.documentElement.clientHeight-document.body.scrollHeight;
michael@0 5661 }else{
michael@0 5662 if(document.body){
michael@0 5663 max=document.body.clientHeight-document.body.scrollHeight;
michael@0 5664 }
michael@0 5665 }
michael@0 5666 }
michael@0 5667 this.scrollStart=p.windowOffset.y;
michael@0 5668 this.delta=(_5d7.y>max?max:_5d7.y)-this.scrollStart;
michael@0 5669 },update:function(_5d9){
michael@0 5670 var p=MochiKit.Position;
michael@0 5671 p.prepare();
michael@0 5672 window.scrollTo(p.windowOffset.x,this.scrollStart+(_5d9*this.delta));
michael@0 5673 }});
michael@0 5674 MochiKit.Visual.fade=function(_5db,_5dc){
michael@0 5675 var s=MochiKit.Style;
michael@0 5676 var _5de=MochiKit.DOM.getElement(_5db).style.opacity||"";
michael@0 5677 _5dc=MochiKit.Base.update({from:s.getOpacity(_5db)||1,to:0,afterFinishInternal:function(_5df){
michael@0 5678 if(_5df.options.to!==0){
michael@0 5679 return;
michael@0 5680 }
michael@0 5681 s.hideElement(_5df.element);
michael@0 5682 s.setStyle(_5df.element,{opacity:_5de});
michael@0 5683 }},_5dc||{});
michael@0 5684 return new MochiKit.Visual.Opacity(_5db,_5dc);
michael@0 5685 };
michael@0 5686 MochiKit.Visual.appear=function(_5e0,_5e1){
michael@0 5687 var s=MochiKit.Style;
michael@0 5688 var v=MochiKit.Visual;
michael@0 5689 _5e1=MochiKit.Base.update({from:(s.getStyle(_5e0,"display")=="none"?0:s.getOpacity(_5e0)||0),to:1,afterFinishInternal:function(_5e4){
michael@0 5690 v.forceRerendering(_5e4.element);
michael@0 5691 },beforeSetupInternal:function(_5e5){
michael@0 5692 s.setOpacity(_5e5.element,_5e5.options.from);
michael@0 5693 s.showElement(_5e5.element);
michael@0 5694 }},_5e1||{});
michael@0 5695 return new v.Opacity(_5e0,_5e1);
michael@0 5696 };
michael@0 5697 MochiKit.Visual.puff=function(_5e6,_5e7){
michael@0 5698 var s=MochiKit.Style;
michael@0 5699 var v=MochiKit.Visual;
michael@0 5700 _5e6=MochiKit.DOM.getElement(_5e6);
michael@0 5701 var _5ea={opacity:_5e6.style.opacity||"",position:s.getStyle(_5e6,"position"),top:_5e6.style.top,left:_5e6.style.left,width:_5e6.style.width,height:_5e6.style.height};
michael@0 5702 _5e7=MochiKit.Base.update({beforeSetupInternal:function(_5eb){
michael@0 5703 MochiKit.Position.absolutize(_5eb.effects[0].element);
michael@0 5704 },afterFinishInternal:function(_5ec){
michael@0 5705 s.hideElement(_5ec.effects[0].element);
michael@0 5706 s.setStyle(_5ec.effects[0].element,_5ea);
michael@0 5707 }},_5e7||{});
michael@0 5708 return new v.Parallel([new v.Scale(_5e6,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new v.Opacity(_5e6,{sync:true,to:0})],_5e7);
michael@0 5709 };
michael@0 5710 MochiKit.Visual.blindUp=function(_5ed,_5ee){
michael@0 5711 var d=MochiKit.DOM;
michael@0 5712 _5ed=d.getElement(_5ed);
michael@0 5713 var _5f0=d.makeClipping(_5ed);
michael@0 5714 _5ee=MochiKit.Base.update({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(_5f1){
michael@0 5715 MochiKit.Style.hideElement(_5f1.element);
michael@0 5716 d.undoClipping(_5f1.element,_5f0);
michael@0 5717 }},_5ee||{});
michael@0 5718 return new MochiKit.Visual.Scale(_5ed,0,_5ee);
michael@0 5719 };
michael@0 5720 MochiKit.Visual.blindDown=function(_5f2,_5f3){
michael@0 5721 var d=MochiKit.DOM;
michael@0 5722 var s=MochiKit.Style;
michael@0 5723 _5f2=d.getElement(_5f2);
michael@0 5724 var _5f6=s.getElementDimensions(_5f2);
michael@0 5725 var _5f7;
michael@0 5726 _5f3=MochiKit.Base.update({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_5f6.h,originalWidth:_5f6.w},restoreAfterFinish:true,afterSetupInternal:function(_5f8){
michael@0 5727 _5f7=d.makeClipping(_5f8.element);
michael@0 5728 s.setStyle(_5f8.element,{height:"0px"});
michael@0 5729 s.showElement(_5f8.element);
michael@0 5730 },afterFinishInternal:function(_5f9){
michael@0 5731 d.undoClipping(_5f9.element,_5f7);
michael@0 5732 }},_5f3||{});
michael@0 5733 return new MochiKit.Visual.Scale(_5f2,100,_5f3);
michael@0 5734 };
michael@0 5735 MochiKit.Visual.switchOff=function(_5fa,_5fb){
michael@0 5736 var d=MochiKit.DOM;
michael@0 5737 _5fa=d.getElement(_5fa);
michael@0 5738 var _5fd=_5fa.style.opacity||"";
michael@0 5739 var _5fe;
michael@0 5740 var _5fb=MochiKit.Base.update({duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetupInternal:function(_5ff){
michael@0 5741 d.makePositioned(_5ff.element);
michael@0 5742 _5fe=d.makeClipping(_5ff.element);
michael@0 5743 },afterFinishInternal:function(_600){
michael@0 5744 MochiKit.Style.hideElement(_600.element);
michael@0 5745 d.undoClipping(_600.element,_5fe);
michael@0 5746 d.undoPositioned(_600.element);
michael@0 5747 MochiKit.Style.setStyle(_600.element,{opacity:_5fd});
michael@0 5748 }},_5fb||{});
michael@0 5749 var v=MochiKit.Visual;
michael@0 5750 return new v.appear(_5fa,{duration:0.4,from:0,transition:v.Transitions.flicker,afterFinishInternal:function(_602){
michael@0 5751 new v.Scale(_602.element,1,_5fb);
michael@0 5752 }});
michael@0 5753 };
michael@0 5754 MochiKit.Visual.dropOut=function(_603,_604){
michael@0 5755 var d=MochiKit.DOM;
michael@0 5756 var s=MochiKit.Style;
michael@0 5757 _603=d.getElement(_603);
michael@0 5758 var _607={top:s.getStyle(_603,"top"),left:s.getStyle(_603,"left"),opacity:_603.style.opacity||""};
michael@0 5759 _604=MochiKit.Base.update({duration:0.5,beforeSetupInternal:function(_608){
michael@0 5760 d.makePositioned(_608.effects[0].element);
michael@0 5761 },afterFinishInternal:function(_609){
michael@0 5762 s.hideElement(_609.effects[0].element);
michael@0 5763 d.undoPositioned(_609.effects[0].element);
michael@0 5764 s.setStyle(_609.effects[0].element,_607);
michael@0 5765 }},_604||{});
michael@0 5766 var v=MochiKit.Visual;
michael@0 5767 return new v.Parallel([new v.Move(_603,{x:0,y:100,sync:true}),new v.Opacity(_603,{sync:true,to:0})],_604);
michael@0 5768 };
michael@0 5769 MochiKit.Visual.shake=function(_60b,_60c){
michael@0 5770 var d=MochiKit.DOM;
michael@0 5771 var v=MochiKit.Visual;
michael@0 5772 var s=MochiKit.Style;
michael@0 5773 _60b=d.getElement(_60b);
michael@0 5774 _60c=MochiKit.Base.update({x:-20,y:0,duration:0.05,afterFinishInternal:function(_610){
michael@0 5775 d.undoPositioned(_610.element);
michael@0 5776 s.setStyle(_610.element,_611);
michael@0 5777 }},_60c||{});
michael@0 5778 var _611={top:s.getStyle(_60b,"top"),left:s.getStyle(_60b,"left")};
michael@0 5779 return new v.Move(_60b,{x:20,y:0,duration:0.05,afterFinishInternal:function(_612){
michael@0 5780 new v.Move(_612.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_613){
michael@0 5781 new v.Move(_613.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_614){
michael@0 5782 new v.Move(_614.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_615){
michael@0 5783 new v.Move(_615.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_616){
michael@0 5784 new v.Move(_616.element,_60c);
michael@0 5785 }});
michael@0 5786 }});
michael@0 5787 }});
michael@0 5788 }});
michael@0 5789 }});
michael@0 5790 };
michael@0 5791 MochiKit.Visual.slideDown=function(_617,_618){
michael@0 5792 var d=MochiKit.DOM;
michael@0 5793 var b=MochiKit.Base;
michael@0 5794 var s=MochiKit.Style;
michael@0 5795 _617=d.getElement(_617);
michael@0 5796 if(!_617.firstChild){
michael@0 5797 throw "MochiKit.Visual.slideDown must be used on a element with a child";
michael@0 5798 }
michael@0 5799 d.removeEmptyTextNodes(_617);
michael@0 5800 var _61c=s.getStyle(_617.firstChild,"bottom")||0;
michael@0 5801 var _61d=s.getElementDimensions(_617);
michael@0 5802 var _61e;
michael@0 5803 _618=b.update({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_61d.h,originalWidth:_61d.w},restoreAfterFinish:true,afterSetupInternal:function(_61f){
michael@0 5804 d.makePositioned(_61f.element);
michael@0 5805 d.makePositioned(_61f.element.firstChild);
michael@0 5806 if(/Opera/.test(navigator.userAgent)){
michael@0 5807 s.setStyle(_61f.element,{top:""});
michael@0 5808 }
michael@0 5809 _61e=d.makeClipping(_61f.element);
michael@0 5810 s.setStyle(_61f.element,{height:"0px"});
michael@0 5811 s.showElement(_61f.element);
michael@0 5812 },afterUpdateInternal:function(_620){
michael@0 5813 s.setStyle(_620.element.firstChild,{bottom:(_620.dims[0]-_620.element.clientHeight)+"px"});
michael@0 5814 },afterFinishInternal:function(_621){
michael@0 5815 d.undoClipping(_621.element,_61e);
michael@0 5816 if(/MSIE/.test(navigator.userAgent)){
michael@0 5817 d.undoPositioned(_621.element);
michael@0 5818 d.undoPositioned(_621.element.firstChild);
michael@0 5819 }else{
michael@0 5820 d.undoPositioned(_621.element.firstChild);
michael@0 5821 d.undoPositioned(_621.element);
michael@0 5822 }
michael@0 5823 s.setStyle(_621.element.firstChild,{bottom:_61c});
michael@0 5824 }},_618||{});
michael@0 5825 return new MochiKit.Visual.Scale(_617,100,_618);
michael@0 5826 };
michael@0 5827 MochiKit.Visual.slideUp=function(_622,_623){
michael@0 5828 var d=MochiKit.DOM;
michael@0 5829 var b=MochiKit.Base;
michael@0 5830 var s=MochiKit.Style;
michael@0 5831 _622=d.getElement(_622);
michael@0 5832 if(!_622.firstChild){
michael@0 5833 throw "MochiKit.Visual.slideUp must be used on a element with a child";
michael@0 5834 }
michael@0 5835 d.removeEmptyTextNodes(_622);
michael@0 5836 var _627=s.getStyle(_622.firstChild,"bottom");
michael@0 5837 var _628;
michael@0 5838 _623=b.update({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,beforeStartInternal:function(_629){
michael@0 5839 d.makePositioned(_629.element);
michael@0 5840 d.makePositioned(_629.element.firstChild);
michael@0 5841 if(/Opera/.test(navigator.userAgent)){
michael@0 5842 s.setStyle(_629.element,{top:""});
michael@0 5843 }
michael@0 5844 _628=d.makeClipping(_629.element);
michael@0 5845 s.showElement(_629.element);
michael@0 5846 },afterUpdateInternal:function(_62a){
michael@0 5847 s.setStyle(_62a.element.firstChild,{bottom:(_62a.dims[0]-_62a.element.clientHeight)+"px"});
michael@0 5848 },afterFinishInternal:function(_62b){
michael@0 5849 s.hideElement(_62b.element);
michael@0 5850 d.undoClipping(_62b.element,_628);
michael@0 5851 d.undoPositioned(_62b.element.firstChild);
michael@0 5852 d.undoPositioned(_62b.element);
michael@0 5853 s.setStyle(_62b.element.firstChild,{bottom:_627});
michael@0 5854 }},_623||{});
michael@0 5855 return new MochiKit.Visual.Scale(_622,0,_623);
michael@0 5856 };
michael@0 5857 MochiKit.Visual.squish=function(_62c,_62d){
michael@0 5858 var d=MochiKit.DOM;
michael@0 5859 var b=MochiKit.Base;
michael@0 5860 var _630;
michael@0 5861 _62d=b.update({restoreAfterFinish:true,beforeSetupInternal:function(_631){
michael@0 5862 _630=d.makeClipping(_631.element);
michael@0 5863 },afterFinishInternal:function(_632){
michael@0 5864 MochiKit.Style.hideElement(_632.element);
michael@0 5865 d.undoClipping(_632.element,_630);
michael@0 5866 }},_62d||{});
michael@0 5867 return new MochiKit.Visual.Scale(_62c,/Opera/.test(navigator.userAgent)?1:0,_62d);
michael@0 5868 };
michael@0 5869 MochiKit.Visual.grow=function(_633,_634){
michael@0 5870 var d=MochiKit.DOM;
michael@0 5871 var v=MochiKit.Visual;
michael@0 5872 var s=MochiKit.Style;
michael@0 5873 _633=d.getElement(_633);
michael@0 5874 _634=MochiKit.Base.update({direction:"center",moveTransition:v.Transitions.sinoidal,scaleTransition:v.Transitions.sinoidal,opacityTransition:v.Transitions.full},_634||{});
michael@0 5875 var _638={top:_633.style.top,left:_633.style.left,height:_633.style.height,width:_633.style.width,opacity:_633.style.opacity||""};
michael@0 5876 var dims=s.getElementDimensions(_633);
michael@0 5877 var _63a,_63b;
michael@0 5878 var _63c,_63d;
michael@0 5879 switch(_634.direction){
michael@0 5880 case "top-left":
michael@0 5881 _63a=_63b=_63c=_63d=0;
michael@0 5882 break;
michael@0 5883 case "top-right":
michael@0 5884 _63a=dims.w;
michael@0 5885 _63b=_63d=0;
michael@0 5886 _63c=-dims.w;
michael@0 5887 break;
michael@0 5888 case "bottom-left":
michael@0 5889 _63a=_63c=0;
michael@0 5890 _63b=dims.h;
michael@0 5891 _63d=-dims.h;
michael@0 5892 break;
michael@0 5893 case "bottom-right":
michael@0 5894 _63a=dims.w;
michael@0 5895 _63b=dims.h;
michael@0 5896 _63c=-dims.w;
michael@0 5897 _63d=-dims.h;
michael@0 5898 break;
michael@0 5899 case "center":
michael@0 5900 _63a=dims.w/2;
michael@0 5901 _63b=dims.h/2;
michael@0 5902 _63c=-dims.w/2;
michael@0 5903 _63d=-dims.h/2;
michael@0 5904 break;
michael@0 5905 }
michael@0 5906 var _63e=MochiKit.Base.update({beforeSetupInternal:function(_63f){
michael@0 5907 s.setStyle(_63f.effects[0].element,{height:"0px"});
michael@0 5908 s.showElement(_63f.effects[0].element);
michael@0 5909 },afterFinishInternal:function(_640){
michael@0 5910 d.undoClipping(_640.effects[0].element);
michael@0 5911 d.undoPositioned(_640.effects[0].element);
michael@0 5912 s.setStyle(_640.effects[0].element,_638);
michael@0 5913 }},_634||{});
michael@0 5914 return new v.Move(_633,{x:_63a,y:_63b,duration:0.01,beforeSetupInternal:function(_641){
michael@0 5915 s.hideElement(_641.element);
michael@0 5916 d.makeClipping(_641.element);
michael@0 5917 d.makePositioned(_641.element);
michael@0 5918 },afterFinishInternal:function(_642){
michael@0 5919 new v.Parallel([new v.Opacity(_642.element,{sync:true,to:1,from:0,transition:_634.opacityTransition}),new v.Move(_642.element,{x:_63c,y:_63d,sync:true,transition:_634.moveTransition}),new v.Scale(_642.element,100,{scaleMode:{originalHeight:dims.h,originalWidth:dims.w},sync:true,scaleFrom:/Opera/.test(navigator.userAgent)?1:0,transition:_634.scaleTransition,restoreAfterFinish:true})],_63e);
michael@0 5920 }});
michael@0 5921 };
michael@0 5922 MochiKit.Visual.shrink=function(_643,_644){
michael@0 5923 var d=MochiKit.DOM;
michael@0 5924 var v=MochiKit.Visual;
michael@0 5925 var s=MochiKit.Style;
michael@0 5926 _643=d.getElement(_643);
michael@0 5927 _644=MochiKit.Base.update({direction:"center",moveTransition:v.Transitions.sinoidal,scaleTransition:v.Transitions.sinoidal,opacityTransition:v.Transitions.none},_644||{});
michael@0 5928 var _648={top:_643.style.top,left:_643.style.left,height:_643.style.height,width:_643.style.width,opacity:_643.style.opacity||""};
michael@0 5929 var dims=s.getElementDimensions(_643);
michael@0 5930 var _64a,_64b;
michael@0 5931 switch(_644.direction){
michael@0 5932 case "top-left":
michael@0 5933 _64a=_64b=0;
michael@0 5934 break;
michael@0 5935 case "top-right":
michael@0 5936 _64a=dims.w;
michael@0 5937 _64b=0;
michael@0 5938 break;
michael@0 5939 case "bottom-left":
michael@0 5940 _64a=0;
michael@0 5941 _64b=dims.h;
michael@0 5942 break;
michael@0 5943 case "bottom-right":
michael@0 5944 _64a=dims.w;
michael@0 5945 _64b=dims.h;
michael@0 5946 break;
michael@0 5947 case "center":
michael@0 5948 _64a=dims.w/2;
michael@0 5949 _64b=dims.h/2;
michael@0 5950 break;
michael@0 5951 }
michael@0 5952 var _64c;
michael@0 5953 var _64d=MochiKit.Base.update({beforeStartInternal:function(_64e){
michael@0 5954 _64c=d.makePositioned(_64e.effects[0].element);
michael@0 5955 d.makeClipping(_64e.effects[0].element);
michael@0 5956 },afterFinishInternal:function(_64f){
michael@0 5957 s.hideElement(_64f.effects[0].element);
michael@0 5958 d.undoClipping(_64f.effects[0].element,_64c);
michael@0 5959 d.undoPositioned(_64f.effects[0].element);
michael@0 5960 s.setStyle(_64f.effects[0].element,_648);
michael@0 5961 }},_644||{});
michael@0 5962 return new v.Parallel([new v.Opacity(_643,{sync:true,to:0,from:1,transition:_644.opacityTransition}),new v.Scale(_643,/Opera/.test(navigator.userAgent)?1:0,{sync:true,transition:_644.scaleTransition,restoreAfterFinish:true}),new v.Move(_643,{x:_64a,y:_64b,sync:true,transition:_644.moveTransition})],_64d);
michael@0 5963 };
michael@0 5964 MochiKit.Visual.pulsate=function(_650,_651){
michael@0 5965 var d=MochiKit.DOM;
michael@0 5966 var v=MochiKit.Visual;
michael@0 5967 var b=MochiKit.Base;
michael@0 5968 var _655=d.getElement(_650).style.opacity||"";
michael@0 5969 _651=b.update({duration:3,from:0,afterFinishInternal:function(_656){
michael@0 5970 MochiKit.Style.setStyle(_656.element,{opacity:_655});
michael@0 5971 }},_651||{});
michael@0 5972 var _657=_651.transition||v.Transitions.sinoidal;
michael@0 5973 var _658=b.bind(function(pos){
michael@0 5974 return _657(1-v.Transitions.pulse(pos));
michael@0 5975 },_657);
michael@0 5976 b.bind(_658,_657);
michael@0 5977 return new v.Opacity(_650,b.update({transition:_658},_651));
michael@0 5978 };
michael@0 5979 MochiKit.Visual.fold=function(_65a,_65b){
michael@0 5980 var d=MochiKit.DOM;
michael@0 5981 var v=MochiKit.Visual;
michael@0 5982 var s=MochiKit.Style;
michael@0 5983 _65a=d.getElement(_65a);
michael@0 5984 var _65f={top:_65a.style.top,left:_65a.style.left,width:_65a.style.width,height:_65a.style.height};
michael@0 5985 var _660=d.makeClipping(_65a);
michael@0 5986 _65b=MochiKit.Base.update({scaleContent:false,scaleX:false,afterFinishInternal:function(_661){
michael@0 5987 new v.Scale(_65a,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(_662){
michael@0 5988 s.hideElement(_662.element);
michael@0 5989 d.undoClipping(_662.element,_660);
michael@0 5990 s.setStyle(_662.element,_65f);
michael@0 5991 }});
michael@0 5992 }},_65b||{});
michael@0 5993 return new v.Scale(_65a,5,_65b);
michael@0 5994 };
michael@0 5995 MochiKit.Visual.Color=MochiKit.Color.Color;
michael@0 5996 MochiKit.Visual.getElementsComputedStyle=MochiKit.DOM.computedStyle;
michael@0 5997 MochiKit.Visual.__new__=function(){
michael@0 5998 var m=MochiKit.Base;
michael@0 5999 m.nameFunctions(this);
michael@0 6000 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
michael@0 6001 };
michael@0 6002 MochiKit.Visual.EXPORT=["roundElement","roundClass","tagifyText","multiple","toggle","Base","Parallel","Opacity","Move","Scale","Highlight","ScrollTo","fade","appear","puff","blindUp","blindDown","switchOff","dropOut","shake","slideDown","slideUp","squish","grow","shrink","pulsate","fold"];
michael@0 6003 MochiKit.Visual.EXPORT_OK=["PAIRS"];
michael@0 6004 MochiKit.Visual.__new__();
michael@0 6005 MochiKit.Base._exportSymbols(this,MochiKit.Visual);
michael@0 6006 if(typeof (MochiKit)=="undefined"){
michael@0 6007 MochiKit={};
michael@0 6008 }
michael@0 6009 if(typeof (MochiKit.MochiKit)=="undefined"){
michael@0 6010 MochiKit.MochiKit={};
michael@0 6011 }
michael@0 6012 MochiKit.MochiKit.NAME="MochiKit.MochiKit";
michael@0 6013 MochiKit.MochiKit.VERSION="1.4";
michael@0 6014 MochiKit.MochiKit.__repr__=function(){
michael@0 6015 return "["+this.NAME+" "+this.VERSION+"]";
michael@0 6016 };
michael@0 6017 MochiKit.MochiKit.toString=function(){
michael@0 6018 return this.__repr__();
michael@0 6019 };
michael@0 6020 MochiKit.MochiKit.SUBMODULES=["Base","Iter","Logging","DateTime","Format","Async","DOM","Style","LoggingPane","Color","Signal","Visual"];
michael@0 6021 if(typeof (JSAN)!="undefined"||typeof (dojo)!="undefined"){
michael@0 6022 if(typeof (dojo)!="undefined"){
michael@0 6023 dojo.provide("MochiKit.MochiKit");
michael@0 6024 dojo.require("MochiKit.*");
michael@0 6025 }
michael@0 6026 if(typeof (JSAN)!="undefined"){
michael@0 6027 (function(lst){
michael@0 6028 for(var i=0;i<lst.length;i++){
michael@0 6029 JSAN.use("MochiKit."+lst[i],[]);
michael@0 6030 }
michael@0 6031 })(MochiKit.MochiKit.SUBMODULES);
michael@0 6032 }
michael@0 6033 (function(){
michael@0 6034 var _666=MochiKit.Base.extend;
michael@0 6035 var self=MochiKit.MochiKit;
michael@0 6036 var _668=self.SUBMODULES;
michael@0 6037 var _669=[];
michael@0 6038 var _66a=[];
michael@0 6039 var _66b={};
michael@0 6040 var i,k,m,all;
michael@0 6041 for(i=0;i<_668.length;i++){
michael@0 6042 m=MochiKit[_668[i]];
michael@0 6043 _666(_669,m.EXPORT);
michael@0 6044 _666(_66a,m.EXPORT_OK);
michael@0 6045 for(k in m.EXPORT_TAGS){
michael@0 6046 _66b[k]=_666(_66b[k],m.EXPORT_TAGS[k]);
michael@0 6047 }
michael@0 6048 all=m.EXPORT_TAGS[":all"];
michael@0 6049 if(!all){
michael@0 6050 all=_666(null,m.EXPORT,m.EXPORT_OK);
michael@0 6051 }
michael@0 6052 var j;
michael@0 6053 for(j=0;j<all.length;j++){
michael@0 6054 k=all[j];
michael@0 6055 self[k]=m[k];
michael@0 6056 }
michael@0 6057 }
michael@0 6058 self.EXPORT=_669;
michael@0 6059 self.EXPORT_OK=_66a;
michael@0 6060 self.EXPORT_TAGS=_66b;
michael@0 6061 }());
michael@0 6062 }else{
michael@0 6063 if(typeof (MochiKit.__compat__)=="undefined"){
michael@0 6064 MochiKit.__compat__=true;
michael@0 6065 }
michael@0 6066 (function(){
michael@0 6067 if(typeof (document)=="undefined"){
michael@0 6068 return;
michael@0 6069 }
michael@0 6070 var _671=document.getElementsByTagName("script");
michael@0 6071 var _672="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
michael@0 6072 var base=null;
michael@0 6073 var _674=null;
michael@0 6074 var _675={};
michael@0 6075 var i;
michael@0 6076 for(i=0;i<_671.length;i++){
michael@0 6077 var src=_671[i].getAttribute("src");
michael@0 6078 if(!src){
michael@0 6079 continue;
michael@0 6080 }
michael@0 6081 _675[src]=true;
michael@0 6082 if(src.match(/MochiKit.js$/)){
michael@0 6083 base=src.substring(0,src.lastIndexOf("MochiKit.js"));
michael@0 6084 _674=_671[i];
michael@0 6085 }
michael@0 6086 }
michael@0 6087 if(base===null){
michael@0 6088 return;
michael@0 6089 }
michael@0 6090 var _678=MochiKit.MochiKit.SUBMODULES;
michael@0 6091 for(var i=0;i<_678.length;i++){
michael@0 6092 if(MochiKit[_678[i]]){
michael@0 6093 continue;
michael@0 6094 }
michael@0 6095 var uri=base+_678[i]+".js";
michael@0 6096 if(uri in _675){
michael@0 6097 continue;
michael@0 6098 }
michael@0 6099 if(document.documentElement&&document.documentElement.namespaceURI==_672){
michael@0 6100 var s=document.createElementNS(_672,"script");
michael@0 6101 s.setAttribute("id","MochiKit_"+base+_678[i]);
michael@0 6102 s.setAttribute("src",uri);
michael@0 6103 s.setAttribute("type","application/x-javascript");
michael@0 6104 _674.parentNode.appendChild(s);
michael@0 6105 }else{
michael@0 6106 document.write("<script src=\""+uri+"\" type=\"text/javascript\"></script>");
michael@0 6107 }
michael@0 6108 }
michael@0 6109 })();
michael@0 6110 }
michael@0 6111
michael@0 6112

mercurial